Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### Changes
- Fix: issue with no size found text
- Fix: Virtusize button state when loading a new product

### 2.12.13
- Fix: External Link redirect issue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ data class I18nLocalization(
val sizeComparisonMultiSizeText: String,
val willFitResultText: String,
val willNotFitResultText: String,
val willNotFitResultDefaultText: String,
val bodyDataEmptyText: String,
) {
enum class TrimType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ data class Product(
i18nLocalization: I18nLocalization,
sizeComparisonRecommendedSize: SizeComparisonRecommendedSize?,
bodyProfileRecommendedSizeName: String?,
bodyProfileWillFit: Boolean? = null,
): String {
return when {
isAccessory() -> accessoryText(i18nLocalization, sizeComparisonRecommendedSize)
Expand All @@ -49,12 +50,14 @@ data class Product(
i18nLocalization = i18nLocalization,
sizeComparisonRecommendedSize = sizeComparisonRecommendedSize,
bodyProfileRecommendedSizeName = bodyProfileRecommendedSizeName,
bodyProfileWillFit = bodyProfileWillFit,
)
else ->
multiSizeText(
i18nLocalization,
sizeComparisonRecommendedSize,
bodyProfileRecommendedSizeName,
bodyProfileWillFit,
)
}
}
Expand Down Expand Up @@ -88,13 +91,27 @@ data class Product(
i18nLocalization: I18nLocalization,
sizeComparisonRecommendedSize: SizeComparisonRecommendedSize?,
bodyProfileRecommendedSizeName: String?,
bodyProfileWillFit: Boolean?,
): String {
bodyProfileRecommendedSizeName?.let {
return i18nLocalization.oneSizeWillFitResultText
// Check if body data is provided (bodyProfileRecommendedSizeName is not null means body data was provided)
val hasBodyData = bodyProfileRecommendedSizeName != null

// For one-size products with body data provided
if (hasBodyData) {
// If willFit is not explicitly false and we have a recommended size, show the will fit message
if (bodyProfileWillFit != false) {
return i18nLocalization.oneSizeWillFitResultText
}
// If willFit is false or no recommended size, show "Your size not found"
return i18nLocalization.willNotFitResultDefaultText
}

// No body data provided, check for product comparison
sizeComparisonRecommendedSize?.let {
return i18nLocalization.getOneSizeProductComparisonText(it)
}

// No data at all, show body data empty message
return i18nLocalization.bodyDataEmptyText
}

Expand All @@ -105,15 +122,29 @@ data class Product(
i18nLocalization: I18nLocalization,
sizeComparisonRecommendedSize: SizeComparisonRecommendedSize?,
bodyProfileRecommendedSizeName: String?,
bodyProfileWillFit: Boolean?,
): String {
bodyProfileRecommendedSizeName?.let {
return i18nLocalization.getMultiSizeBodyProfileText(
bodyProfileRecommendedSizeName = bodyProfileRecommendedSizeName,
)
// Check if body data is provided
val hasBodyData = bodyProfileRecommendedSizeName != null

// For multi-size products with body data provided
if (hasBodyData) {
// If willFit is not explicitly false and we have a recommended size, show it
if (bodyProfileWillFit != false && bodyProfileRecommendedSizeName.isNotEmpty()) {
return i18nLocalization.getMultiSizeBodyProfileText(
bodyProfileRecommendedSizeName = bodyProfileRecommendedSizeName,
)
}
// If willFit is false or no recommended size, show "Your size not found"
return i18nLocalization.willNotFitResultDefaultText
}

// No body data provided, check for product comparison
sizeComparisonRecommendedSize?.bestStoreProductSize?.name?.let {
return i18nLocalization.getMultiSizeProductComparisonText(it)
}

// No data at all, show body data empty message
return i18nLocalization.bodyDataEmptyText
}

Expand Down
1 change: 1 addition & 0 deletions virtusize-core/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
<string name="inpage_multi_size_comparison_text">あなたの服に近いサイズ</string>
<string name="inpage_will_fit_result_text">あなたにフィットするサイズ</string>
<string name="inpage_will_not_fit_result_text">試着をおすすめします</string>
<string name="inpage_will_not_fit_result_default_text">試着をおすすめします</string>
<string name="inpage_body_data_empty_text">簡単サイズチェック</string>
</resources>
1 change: 1 addition & 0 deletions virtusize-core/src/main/res/values-ko/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
<string name="inpage_multi_size_comparison_text">가장 유사한 상품은</string>
<string name="inpage_will_fit_result_text">추천하는 사이즈는</string>
<string name="inpage_will_not_fit_result_text">당신에게 잘 맞는지 확인해 보세요</string>
<string name="inpage_will_not_fit_result_default_text">당신에게 잘 맞는지 확인해 보세요</string>
<string name="inpage_body_data_empty_text">당신에게 맞는 사이즈를 찾아보세요</string>
</resources>
3 changes: 2 additions & 1 deletion virtusize-core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<string name="inpage_one_size_will_fit_result_text">This item should fit you</string>
<string name="inpage_multi_size_comparison_text">The closest size to your item is</string>
<string name="inpage_will_fit_result_text">Your recommended size is</string>
<string name="inpage_will_not_fit_result_text">Check how it fits you</string>
<string name="inpage_will_not_fit_result_text">Your size not found</string>
<string name="inpage_will_not_fit_result_default_text">Your size not found</string>
<string name="inpage_body_data_empty_text">Find your right size</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class ProductTest {
sizeComparisonMultiSizeText = context.getString(R.string.inpage_multi_size_comparison_text),
willFitResultText = context.getString(R.string.inpage_will_fit_result_text),
willNotFitResultText = context.getString(R.string.inpage_will_not_fit_result_text),
willNotFitResultDefaultText = context.getString(R.string.inpage_will_not_fit_result_default_text),
bodyDataEmptyText = context.getString(R.string.inpage_body_data_empty_text),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ internal class VirtusizeImpl(
externalProductId: String,
userProductRecommendedSize: SizeComparisonRecommendedSize?,
userBodyRecommendedSize: String?,
userBodyWillFit: Boolean?,
) {
val storeProduct = virtusizeRepository.getProductBy(externalProductId)
virtusizeViews
Expand All @@ -266,6 +267,7 @@ internal class VirtusizeImpl(
i18nLocalization = i18nLocalization,
sizeComparisonRecommendedSize = userProductRecommendedSize,
bodyProfileRecommendedSizeName = userBodyRecommendedSize,
bodyProfileWillFit = userBodyWillFit,
).trimI18nText(trimType)
virtusizeView.setRecommendationText(
externalProductId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ internal interface VirtusizePresenter {
externalProductId: String,
userProductRecommendedSize: SizeComparisonRecommendedSize?,
userBodyRecommendedSize: String?,
userBodyWillFit: Boolean?,
)

fun hasInPageError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class VirtusizeRepository internal constructor(
private var userProducts: List<Product>? = null
private var userProductRecommendedSize: SizeComparisonRecommendedSize? = null
private var userBodyRecommendedSize: String? = null
private var userBodyWillFit: Boolean? = null

// This variable holds the list of product types from the Virtusize API
private var productTypes: List<ProductType>? = null
Expand Down Expand Up @@ -373,6 +374,7 @@ class VirtusizeRepository internal constructor(
externalProductId = productId,
userProductRecommendedSize = userProductRecommendedSize,
userBodyRecommendedSize = null,
userBodyWillFit = null,
)
}

Expand All @@ -381,6 +383,7 @@ class VirtusizeRepository internal constructor(
externalProductId = productId,
userProductRecommendedSize = null,
userBodyRecommendedSize = userBodyRecommendedSize,
userBodyWillFit = userBodyWillFit,
)
}

Expand All @@ -389,6 +392,7 @@ class VirtusizeRepository internal constructor(
externalProductId = productId,
userProductRecommendedSize = userProductRecommendedSize,
userBodyRecommendedSize = userBodyRecommendedSize,
userBodyWillFit = userBodyWillFit,
)
}
}
Expand All @@ -406,6 +410,7 @@ class VirtusizeRepository internal constructor(
userProducts = null
userProductRecommendedSize = null
userBodyRecommendedSize = null
userBodyWillFit = null
}

/**
Expand All @@ -419,6 +424,7 @@ class VirtusizeRepository internal constructor(
productTypes: List<ProductType>?,
): String? {
if (storeProduct == null || productTypes == null || storeProduct.isAccessory()) {
userBodyWillFit = null
return null
}
val userBodyProfileResponse = virtusizeAPIService.getUserBodyProfile()
Expand All @@ -430,6 +436,7 @@ class VirtusizeRepository internal constructor(
storeProduct,
userBodyProfileResponse.successData!!,
)
userBodyWillFit = bodyProfileRecommendedSizeResponse.successData?.willFit
return bodyProfileRecommendedSizeResponse.successData?.sizeName
} else {
val bodyProfileRecommendedSizeResponse =
Expand All @@ -438,13 +445,15 @@ class VirtusizeRepository internal constructor(
storeProduct,
userBodyProfileResponse.successData!!,
)
userBodyWillFit = bodyProfileRecommendedSizeResponse.successData?.get(0)?.willFit
return bodyProfileRecommendedSizeResponse.successData?.get(0)?.sizeName
}
} else if (userBodyProfileResponse.failureData?.code != HttpURLConnection.HTTP_NOT_FOUND) {
userBodyProfileResponse.failureData?.let {
messageHandler.onError(it)
}
}
userBodyWillFit = null
return null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ internal class I18nLocalizationJsonParser(
),
)?.trim().orEmpty()

val willNotFitResultDefaultText =
configuredContext.getString(
com.virtusize.android.core.R.string.inpage_will_not_fit_result_text,
)

val bodyDataEmptyText =
inpageJSONObject?.optString(
FIELD_BODY_DATA_EMPTY,
Expand All @@ -146,6 +151,7 @@ internal class I18nLocalizationJsonParser(
sizeComparisonMultiSizeText = sizeComparisonMultiSizeText,
willFitResultText = willFitResultText,
willNotFitResultText = willNotFitResultText,
willNotFitResultDefaultText = willNotFitResultDefaultText,
bodyDataEmptyText = bodyDataEmptyText,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ internal class VirtusizeFlutterImpl(
externalProductId: String,
userProductRecommendedSize: SizeComparisonRecommendedSize?,
userBodyRecommendedSize: String?,
userBodyWillFit: Boolean?,
) {
val storeProduct = virtusizeRepository.getProductBy(externalProductId)
val i18nLocalization = virtusizeRepository.i18nLocalization
Expand All @@ -271,13 +272,15 @@ internal class VirtusizeFlutterImpl(
i18nLocalization = i18nLocalization,
sizeComparisonRecommendedSize = userProductRecommendedSize,
bodyProfileRecommendedSizeName = userBodyRecommendedSize,
bodyProfileWillFit = userBodyWillFit,
).trimI18nText(I18nLocalization.TrimType.MULTIPLELINES)

virtusizeFlutterPresenter?.gotSizeRecommendations(
externalProductId,
storeProduct,
userProductRecommendedSize?.bestUserProduct,
recommendationText,
userBodyWillFit,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface VirtusizeFlutterPresenter {
storeProduct: Product?,
bestUserProduct: Product?,
recommendationText: String?,
willFit: Boolean?,
)

fun onLangugeClick(language: VirtusizeLanguage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,21 @@ class VirtusizeInPageMini
imageLoader.enqueue(request)
}

/**
* @see VirtusizeView.initialSetup
*/
override fun initialSetup(
product: VirtusizeProduct,
params: VirtusizeParams,
messageHandler: VirtusizeMessageHandler,
) {
super.initialSetup(product, params, messageHandler)

// Reset root visibility when setting up a new product
// This ensures the view shows properly after switching from an invalid product
binding.root.visibility = View.VISIBLE
}

/**
* @see VirtusizeView.setProductWithProductCheckData
* @throws VirtusizeErrorType.NullProduct error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ class VirtusizeInPageStandard
})
}
binding.privacyPolicyText.visibility = showPrivacyPolicy()

// Reset root visibility when setting up a new product
// This ensures the view shows properly after switching from an invalid product
binding.root.visibility = View.VISIBLE
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.google.common.truth.Truth.assertThat
import com.virtusize.android.TestUtils
import com.virtusize.android.data.local.VirtusizeLanguage
import com.virtusize.android.data.remote.I18nLocalization
import com.virtusize.android.fixtures.TestFixtures
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
Expand Down Expand Up @@ -36,35 +35,6 @@ class I18nLocalizationJsonParserTest {
assertThat(actualI18nLocalization).isEqualTo(expectedI18nLocalization)
}

@Test
fun parseI18N_emptyJsonData_shouldReturnExpectedObject() {
val actualI18nLocalization =
I18nLocalizationJsonParser(context, VirtusizeLanguage.EN).parse(
TestFixtures.EMPTY_JSON_DATA,
)

val expectedI18nLocalization =
I18nLocalization(
VirtusizeLanguage.EN,
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
)

assertThat(actualI18nLocalization).isEqualTo(expectedI18nLocalization)
}

@Test
fun parseI18NJP_japaneseLocalization_shouldReturnExpectedObject() {
val actualI18nLocalization =
Expand Down Expand Up @@ -126,6 +96,7 @@ class I18nLocalizationJsonParserTest {
localizedContext.getString(com.virtusize.android.core.R.string.inpage_multi_size_comparison_text),
localizedContext.getString(com.virtusize.android.core.R.string.inpage_will_fit_result_text),
localizedContext.getString(com.virtusize.android.core.R.string.inpage_will_not_fit_result_text),
localizedContext.getString(com.virtusize.android.core.R.string.inpage_will_not_fit_result_text),
localizedContext.getString(com.virtusize.android.core.R.string.inpage_body_data_empty_text),
)
}
Expand Down
2 changes: 1 addition & 1 deletion virtusize/src/test/resources/i18n_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"errorTextShort": "Virtusize is not available at the moment.",
"oneSizeText": "There is only size %{value}",
"details": "Details",
"willNotFitResult": "Check how it fits you",
"willNotFitResult": "Your size not found",
"tryItOn": "Try it on",
"accessoriesEmpty": "See what fits inside",
"hasProductAccessoryText": "See the size difference from %{boldStart}your own item%{boldEnd}",
Expand Down