diff --git a/common/src/main/kotlin/com/tangem/common/TangemSiteShareUrlBuilder.kt b/common/src/main/kotlin/com/tangem/common/TangemSiteShareUrlBuilder.kt new file mode 100644 index 0000000000..64554a30e0 --- /dev/null +++ b/common/src/main/kotlin/com/tangem/common/TangemSiteShareUrlBuilder.kt @@ -0,0 +1,31 @@ +package com.tangem.common + +import com.tangem.utils.SupportedLanguages.CHINESE +import com.tangem.utils.SupportedLanguages.ENGLISH +import com.tangem.utils.SupportedLanguages.FRANCH +import com.tangem.utils.SupportedLanguages.GERMAN +import com.tangem.utils.SupportedLanguages.JAPANESE +import java.util.Locale + +object TangemSiteShareUrlBuilder { + + private const val BASE_URL = "https://tangem.com" + private const val CRYPTOCURRENCIES_PATH = "cryptocurrencies" + + @Deprecated("Should use CHINESE from SupportedLanguages, but the site expects zh-Hans in the URL path") + private const val CHINESE_SITE_LOCALE = "zh-Hans" + + @Deprecated("Should rely on SupportedLanguages instead of maintaining a separate list") + private val siteLocales = mapOf( + ENGLISH to ENGLISH, + FRANCH to FRANCH, + GERMAN to GERMAN, + JAPANESE to JAPANESE, + CHINESE to CHINESE_SITE_LOCALE, + ) + + fun shareUrl(tokenId: String): String { + val locale = siteLocales[Locale.getDefault().language] ?: ENGLISH + return "$BASE_URL/$locale/$CRYPTOCURRENCIES_PATH/$tokenId" + } +} \ No newline at end of file diff --git a/features/feed/impl/src/main/kotlin/com/tangem/features/feed/model/market/details/MarketsTokenDetailsModel.kt b/features/feed/impl/src/main/kotlin/com/tangem/features/feed/model/market/details/MarketsTokenDetailsModel.kt index 257c93ed3b..e4af70344b 100644 --- a/features/feed/impl/src/main/kotlin/com/tangem/features/feed/model/market/details/MarketsTokenDetailsModel.kt +++ b/features/feed/impl/src/main/kotlin/com/tangem/features/feed/model/market/details/MarketsTokenDetailsModel.kt @@ -4,6 +4,7 @@ import androidx.compose.runtime.Stable import arrow.core.Either import arrow.core.getOrElse import com.tangem.blockchainsdk.utils.ExcludedBlockchains +import com.tangem.common.TangemSiteShareUrlBuilder import com.tangem.common.ui.charts.state.MarketChartData import com.tangem.common.ui.charts.state.MarketChartDataProducer import com.tangem.common.ui.charts.state.sorted @@ -667,7 +668,7 @@ internal class MarketsTokenDetailsModel @Inject constructor( private fun onShareClick() { val tokenId = params.token.id.value - val shareUrl = "$CRYPTOCURRENCIES_BASE_URL$tokenId" + val shareUrl = TangemSiteShareUrlBuilder.shareUrl(tokenId) shareManager.shareText(shareUrl) analyticsEventHandler.send(analyticsEventBuilder.shareClicked()) } @@ -735,6 +736,5 @@ internal class MarketsTokenDetailsModel @Inject constructor( private companion object { const val QUOTES_UPDATE_INTERVAL_MILLIS = 60000L const val RELATED_NEWS_LIMIT = 10 - const val CRYPTOCURRENCIES_BASE_URL = "https://tangem.com/en/cryptocurrencies/" } } \ No newline at end of file