From 1e0876eea6a965a6113e852ca84e8b77b756a6cc Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 8 Feb 2024 11:17:26 +0300 Subject: [PATCH] Updated on 2026-08-14 --- app/build.gradle.kts | 1 + .../tap/di/domain/TokensDomainModule.kt | 2 + .../datasource/api/promotion/PromotionApi.kt | 29 ------------ .../models/AbstractPromotionResponse.kt | 18 ------- .../api/promotion/models/AwardRequestBody.kt | 12 ----- .../api/promotion/models/AwardResponse.kt | 11 ----- .../promotion/models/CodeAwardRequestBody.kt | 12 ----- .../api/promotion/models/CodeAwardResponse.kt | 11 ----- .../models/CodeValidateRequestBody.kt | 11 ----- .../promotion/models/CodeValidateResponse.kt | 11 ----- .../promotion/models/PromotionInfoResponse.kt | 43 ++++++----------- .../promotion/models/ValidateRequestBody.kt | 11 ----- .../api/promotion/models/ValidateResponse.kt | 11 ----- .../api/tangemTech/TangemTechApi.kt | 4 ++ .../{PromotionOneInch.kt => DevTangemApi.kt} | 2 +- .../com/tangem/datasource/di/NetworkModule.kt | 39 ++++++---------- .../local/preferences/PreferencesKeys.kt | 8 +++- core/res/src/main/res/values-ru/strings.xml | 8 ++-- core/res/src/main/res/values/strings.xml | 8 ++-- .../NotificationWithBackground.kt | 19 +++++--- ...mg_swap_promo_blue_banner_background.webp} | Bin ...mg_swap_promo_green_banner_background.webp | Bin 0 -> 12118 bytes data/promo/.gitignore | 1 + data/promo/build.gradle.kts | 25 ++++++++++ .../data/promo/DefaultPromoRepository.kt | 29 ++++++++++++ .../converters/PromoResponseConverter.kt | 23 +++++++++ .../tangem/data/promo/di/PromoDataModule.kt | 26 +++++++++++ .../settings/DefaultSwapPromoRepository.kt | 44 ++++-------------- .../ShouldShowSwapPromoTokenUseCase.kt | 4 +- .../ShouldShowSwapPromoWalletUseCase.kt | 4 +- .../repositories/SwapPromoRepository.kt | 8 ++-- domain/tokens/models/build.gradle.kts | 1 + .../com/tangem/domain/promo/PromoBanner.kt | 25 ++++++++++ .../model/warnings/CryptoCurrencyWarning.kt | 6 ++- .../tokens/GetCurrencyWarningsUseCase.kt | 15 +++--- .../tokens/repository/PromoRepository.kt | 8 ++++ .../components/TokenDetailsNotification.kt | 15 ++++-- .../TokenDetailsNotificationConverter.kt | 2 + .../domain/GetMultiWalletWarningsFactory.kt | 31 +++++++++++- .../state/components/WalletNotification.kt | 15 ++++-- .../wallet/viewmodels/WalletClickIntents.kt | 2 - .../WalletNotificationsListFactory.kt | 19 +------- .../wallet/viewmodels/WalletViewModel.kt | 8 ---- .../intents/WalletWarningsClickIntents.kt | 10 ++++ settings.gradle.kts | 1 + 45 files changed, 301 insertions(+), 292 deletions(-) delete mode 100644 core/datasource/src/main/java/com/tangem/datasource/api/promotion/PromotionApi.kt delete mode 100644 core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/AbstractPromotionResponse.kt delete mode 100644 core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/AwardRequestBody.kt delete mode 100644 core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/AwardResponse.kt delete mode 100644 core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/CodeAwardRequestBody.kt delete mode 100644 core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/CodeAwardResponse.kt delete mode 100644 core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/CodeValidateRequestBody.kt delete mode 100644 core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/CodeValidateResponse.kt delete mode 100644 core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/ValidateRequestBody.kt delete mode 100644 core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/ValidateResponse.kt rename core/datasource/src/main/java/com/tangem/datasource/di/{PromotionOneInch.kt => DevTangemApi.kt} (80%) rename core/ui/src/main/res/drawable/{img_swap_promo_banner_background.webp => img_swap_promo_blue_banner_background.webp} (100%) create mode 100644 core/ui/src/main/res/drawable/img_swap_promo_green_banner_background.webp create mode 100644 data/promo/.gitignore create mode 100644 data/promo/build.gradle.kts create mode 100644 data/promo/src/main/java/com/tangem/data/promo/DefaultPromoRepository.kt create mode 100644 data/promo/src/main/java/com/tangem/data/promo/converters/PromoResponseConverter.kt create mode 100644 data/promo/src/main/java/com/tangem/data/promo/di/PromoDataModule.kt create mode 100644 domain/tokens/models/src/main/java/com/tangem/domain/promo/PromoBanner.kt create mode 100644 domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/PromoRepository.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 8c5969e599..aa64c0d699 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -80,6 +80,7 @@ dependencies { implementation(projects.data.analytics) implementation(projects.data.transaction) implementation(projects.data.visa) + implementation(projects.data.promo) /** Features */ implementation(projects.features.onboarding) diff --git a/app/src/main/java/com/tangem/tap/di/domain/TokensDomainModule.kt b/app/src/main/java/com/tangem/tap/di/domain/TokensDomainModule.kt index b439d53019..7149fc13da 100644 --- a/app/src/main/java/com/tangem/tap/di/domain/TokensDomainModule.kt +++ b/app/src/main/java/com/tangem/tap/di/domain/TokensDomainModule.kt @@ -100,6 +100,7 @@ internal object TokensDomainModule { marketCryptoCurrencyRepository: MarketCryptoCurrencyRepository, swapRepository: SwapRepository, showSwapPromoTokenUseCase: ShouldShowSwapPromoTokenUseCase, + promoRepository: PromoRepository, dispatchers: CoroutineDispatcherProvider, ): GetCurrencyWarningsUseCase { return GetCurrencyWarningsUseCase( @@ -110,6 +111,7 @@ internal object TokensDomainModule { marketCryptoCurrencyRepository = marketCryptoCurrencyRepository, swapRepository = swapRepository, showSwapPromoTokenUseCase = showSwapPromoTokenUseCase, + promoRepository = promoRepository, dispatchers = dispatchers, ) } diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/promotion/PromotionApi.kt b/core/datasource/src/main/java/com/tangem/datasource/api/promotion/PromotionApi.kt deleted file mode 100644 index d71061c21a..0000000000 --- a/core/datasource/src/main/java/com/tangem/datasource/api/promotion/PromotionApi.kt +++ /dev/null @@ -1,29 +0,0 @@ -package com.tangem.datasource.api.promotion - -import com.tangem.datasource.api.promotion.models.* -import retrofit2.http.* - -/** - * - * Promotion API - * @see Documentation -[REDACTED_AUTHOR] - */ -interface PromotionApi { - - @Headers("Cache-Control: max-age=3600") - @GET("promotion") - suspend fun getPromotionInfo(@Query("programName") name: String): PromotionInfoResponse - - @POST("promotion/code/validate") - suspend fun validateCode(@Body request: CodeValidateRequestBody): CodeValidateResponse - - @POST("promotion/code/award") - suspend fun requestAwardByCode(@Body request: CodeAwardRequestBody): CodeAwardResponse - - @POST("promotion/validate") - suspend fun validate(@Body request: ValidateRequestBody): ValidateResponse - - @POST("promotion/award") - suspend fun requestAward(@Body request: AwardRequestBody): AwardResponse -} \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/AbstractPromotionResponse.kt b/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/AbstractPromotionResponse.kt deleted file mode 100644 index edfc8e990d..0000000000 --- a/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/AbstractPromotionResponse.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.tangem.datasource.api.promotion.models - -import com.squareup.moshi.Json - -/** -[REDACTED_AUTHOR] - */ -abstract class AbstractPromotionResponse { - - abstract val error: Error? - - fun isError(): Boolean = error != null - - data class Error( - @Json(name = "code") val code: Int, - @Json(name = "message") val message: String, - ) -} \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/AwardRequestBody.kt b/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/AwardRequestBody.kt deleted file mode 100644 index c8ac7faed1..0000000000 --- a/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/AwardRequestBody.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.tangem.datasource.api.promotion.models - -import com.squareup.moshi.Json - -/** -[REDACTED_AUTHOR] - */ -data class AwardRequestBody( - @Json(name = "walletId") val walletId: String, - @Json(name = "address") val address: String, - @Json(name = "programName") val programName: String, -) \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/AwardResponse.kt b/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/AwardResponse.kt deleted file mode 100644 index c43c59fa45..0000000000 --- a/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/AwardResponse.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.tangem.datasource.api.promotion.models - -import com.squareup.moshi.Json - -/** -[REDACTED_AUTHOR] - */ -data class AwardResponse( - @Json(name = "status") val status: Boolean?, - @Json(name = "error") override val error: Error? = null, -) : AbstractPromotionResponse() \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/CodeAwardRequestBody.kt b/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/CodeAwardRequestBody.kt deleted file mode 100644 index 51e8626d4b..0000000000 --- a/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/CodeAwardRequestBody.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.tangem.datasource.api.promotion.models - -import com.squareup.moshi.Json - -/** -[REDACTED_AUTHOR] - */ -data class CodeAwardRequestBody( - @Json(name = "walletId") val walletId: String, - @Json(name = "address") val address: String, - @Json(name = "code") val code: String?, -) \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/CodeAwardResponse.kt b/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/CodeAwardResponse.kt deleted file mode 100644 index 33d9313c42..0000000000 --- a/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/CodeAwardResponse.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.tangem.datasource.api.promotion.models - -import com.squareup.moshi.Json - -/** -[REDACTED_AUTHOR] - */ -data class CodeAwardResponse( - @Json(name = "status") val status: Boolean?, - @Json(name = "error") override val error: Error? = null, -) : AbstractPromotionResponse() \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/CodeValidateRequestBody.kt b/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/CodeValidateRequestBody.kt deleted file mode 100644 index 769ecdad26..0000000000 --- a/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/CodeValidateRequestBody.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.tangem.datasource.api.promotion.models - -import com.squareup.moshi.Json - -/** -[REDACTED_AUTHOR] - */ -data class CodeValidateRequestBody( - @Json(name = "walletId") val walletId: String, - @Json(name = "code") val code: String?, -) \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/CodeValidateResponse.kt b/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/CodeValidateResponse.kt deleted file mode 100644 index e6e87e0ff3..0000000000 --- a/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/CodeValidateResponse.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.tangem.datasource.api.promotion.models - -import com.squareup.moshi.Json - -/** -[REDACTED_AUTHOR] - */ -data class CodeValidateResponse( - @Json(name = "valid") val valid: Boolean?, - @Json(name = "error") override val error: Error? = null, -) : AbstractPromotionResponse() \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/PromotionInfoResponse.kt b/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/PromotionInfoResponse.kt index ca5406aba5..fa9140eea1 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/PromotionInfoResponse.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/PromotionInfoResponse.kt @@ -1,40 +1,23 @@ package com.tangem.datasource.api.promotion.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass -/** -[REDACTED_AUTHOR] - */ +@JsonClass(generateAdapter = true) data class PromotionInfoResponse( - @Json(name = "newCard") val newCard: Data?, - @Json(name = "oldCard") val oldCard: Data?, - @Json(name = "awardPaymentToken") val awardPaymentToken: TokenData?, - @Json(name = "error") override val error: Error? = null, -) : AbstractPromotionResponse() { + @Json(name = "name") val name: String, + @Json(name = "all") val bannerState: BannerState?, +) { - data class Data( - @Json(name = "status") val status: Status, - @Json(name = "award") val award: Double, + @JsonClass(generateAdapter = true) + data class BannerState( + @Json(name = "timeline") val timeline: Timeline, + @Json(name = "status") val status: String, ) - enum class Status(val value: String) { - @Json(name = "pending") - PENDING("pending"), - - @Json(name = "active") - ACTIVE("active"), - - @Json(name = "finished") - FINISHED("finished"), - } - - data class TokenData( - @Json(name = "id") val id: String, - @Json(name = "name") val name: String, - @Json(name = "symbol") val symbol: String, - @Json(name = "active") val active: Boolean, - @Json(name = "networkId") val networkId: String, - @Json(name = "contractAddress") val contractAddress: String, - @Json(name = "decimalCount") val decimalCount: Int, + @JsonClass(generateAdapter = true) + data class Timeline( + @Json(name = "start") val start: String, + @Json(name = "end") val end: String, ) } \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/ValidateRequestBody.kt b/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/ValidateRequestBody.kt deleted file mode 100644 index 090f0e0d29..0000000000 --- a/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/ValidateRequestBody.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.tangem.datasource.api.promotion.models - -import com.squareup.moshi.Json - -/** -[REDACTED_AUTHOR] - */ -data class ValidateRequestBody( - @Json(name = "walletId") val walletId: String, - @Json(name = "programName") val programName: String, -) \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/ValidateResponse.kt b/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/ValidateResponse.kt deleted file mode 100644 index 97cd74645d..0000000000 --- a/core/datasource/src/main/java/com/tangem/datasource/api/promotion/models/ValidateResponse.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.tangem.datasource.api.promotion.models - -import com.squareup.moshi.Json - -/** -[REDACTED_AUTHOR] - */ -data class ValidateResponse( - @Json(name = "valid") val valid: Boolean?, - @Json(name = "error") override val error: Error? = null, -) : AbstractPromotionResponse() \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/TangemTechApi.kt b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/TangemTechApi.kt index 9992d45c5f..43ff3af6e5 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/TangemTechApi.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/TangemTechApi.kt @@ -1,6 +1,7 @@ package com.tangem.datasource.api.tangemTech import com.tangem.datasource.api.common.response.ApiResponse +import com.tangem.datasource.api.promotion.models.PromotionInfoResponse import com.tangem.datasource.api.tangemTech.models.* import retrofit2.http.* @@ -71,4 +72,7 @@ interface TangemTechApi { @Query("coinIds") coinIds: String, @Query("fields") fields: String = "price,priceChange24h,lastUpdatedAt", ): ApiResponse + + @GET("promotion") + suspend fun getPromotionInfo(@Query("programName") name: String): ApiResponse } \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/di/PromotionOneInch.kt b/core/datasource/src/main/java/com/tangem/datasource/di/DevTangemApi.kt similarity index 80% rename from core/datasource/src/main/java/com/tangem/datasource/di/PromotionOneInch.kt rename to core/datasource/src/main/java/com/tangem/datasource/di/DevTangemApi.kt index 9e2d6b3981..4bfacf89db 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/di/PromotionOneInch.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/di/DevTangemApi.kt @@ -5,4 +5,4 @@ import javax.inject.Qualifier @Qualifier @MustBeDocumented @Retention(AnnotationRetention.RUNTIME) -annotation class PromotionOneInch \ No newline at end of file +annotation class DevTangemApi \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/di/NetworkModule.kt b/core/datasource/src/main/java/com/tangem/datasource/di/NetworkModule.kt index 754936c7a5..eb61db86b2 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/di/NetworkModule.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/di/NetworkModule.kt @@ -5,12 +5,10 @@ import com.squareup.moshi.Moshi import com.tangem.datasource.BuildConfig import com.tangem.datasource.api.common.response.ApiResponseCallAdapterFactory import com.tangem.datasource.api.express.TangemExpressApi -import com.tangem.datasource.api.promotion.PromotionApi import com.tangem.datasource.api.tangemTech.TangemTechApi import com.tangem.datasource.utils.RequestHeader.* import com.tangem.datasource.utils.addHeaders import com.tangem.datasource.utils.addLoggers -import com.tangem.lib.auth.AuthProvider import com.tangem.lib.auth.ExpressAuthProvider import dagger.Module import dagger.Provides @@ -20,7 +18,6 @@ import dagger.hilt.components.SingletonComponent import okhttp3.OkHttpClient import retrofit2.Retrofit import retrofit2.converter.moshi.MoshiConverterFactory -import java.util.concurrent.TimeUnit import javax.inject.Singleton @Module @@ -75,31 +72,25 @@ class NetworkModule { } @Provides + @DevTangemApi @Singleton - @PromotionOneInch - fun providePromotionOneInchApi( - authProvider: AuthProvider, - @NetworkMoshi moshi: Moshi, - @ApplicationContext context: Context, - ): PromotionApi { - val okClient = OkHttpClient.Builder() - .addHeaders(AuthenticationHeader(authProvider)) - .addLoggers(context) - .callTimeout(API_ONE_INCH_TIMEOUT_MS, TimeUnit.MILLISECONDS) - .connectTimeout(API_ONE_INCH_TIMEOUT_MS, TimeUnit.MILLISECONDS) - .readTimeout(API_ONE_INCH_TIMEOUT_MS, TimeUnit.MILLISECONDS) - .writeTimeout(API_ONE_INCH_TIMEOUT_MS, TimeUnit.MILLISECONDS) - .build() - return createBasePromotionRetrofit(okClient, moshi) - } - - private fun createBasePromotionRetrofit(okHttpClient: OkHttpClient, moshi: Moshi): PromotionApi { + fun provideTangemTechDevApi(@NetworkMoshi moshi: Moshi, @ApplicationContext context: Context): TangemTechApi { return Retrofit.Builder() .addConverterFactory(MoshiConverterFactory.create(moshi)) - .baseUrl(PROD_TANGEM_TECH_BASE_URL) - .client(okHttpClient) + .addCallAdapterFactory(ApiResponseCallAdapterFactory.create()) + .baseUrl(DEV_TANGEM_TECH_BASE_URL) + .client( + OkHttpClient.Builder() + .addHeaders( + CacheControlHeader, + // TODO("refactor header init") get auth data after biometric auth to avoid race condition + // AuthenticationHeader(authProvider), + ) + .addLoggers(context) + .build(), + ) .build() - .create(PromotionApi::class.java) + .create(TangemTechApi::class.java) } private companion object { diff --git a/core/datasource/src/main/java/com/tangem/datasource/local/preferences/PreferencesKeys.kt b/core/datasource/src/main/java/com/tangem/datasource/local/preferences/PreferencesKeys.kt index 02432a3d03..652187147e 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/local/preferences/PreferencesKeys.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/local/preferences/PreferencesKeys.kt @@ -45,9 +45,13 @@ object PreferencesKeys { val LAST_SWAPPED_CRYPTOCURRENCY_ID_KEY by lazy { stringPreferencesKey(name = "lastSwappedCryptoCurrency") } - val IS_WALLET_SWAP_PROMO_SHOW_KEY by lazy { booleanPreferencesKey(name = "isWalletSwapPromoShown") } + val IS_WALLET_SWAP_PROMO_CHANGELLY_SHOW_KEY by lazy { + booleanPreferencesKey(name = "isWalletSwapPromoChangellyShown") + } - val IS_TOKEN_SWAP_PROMO_SHOW_KEY by lazy { booleanPreferencesKey(name = "isTokenSwapPromoShown") } + val IS_TOKEN_SWAP_PROMO_CHANGELLY_SHOW_KEY by lazy { + booleanPreferencesKey(name = "isTokenSwapPromoChangellyShown") + } } /** Preferences keys set that should be migrated from "PreferencesDataSource" to a new DataStore */ diff --git a/core/res/src/main/res/values-ru/strings.xml b/core/res/src/main/res/values-ru/strings.xml index e257132463..0276e3c034 100644 --- a/core/res/src/main/res/values-ru/strings.xml +++ b/core/res/src/main/res/values-ru/strings.xml @@ -273,8 +273,8 @@ 1INCH токены будут зачислены на адрес вашего кошелька в сети %s в течение 48 часов Чтобы получить доступ ко всем сетям, вам необходимо отсканировать карту Отсканируйте карту - Обменивайте свои цифровые активы между различными сетями - Кроссчейн-своп теперь доступен + Обменивайте свои токены с %1$s комиссии провайдера через Changelly с %2$s по %3$s февраля. + Обмен с Changelly, %s комиссии Токены Добавить Изменить @@ -575,9 +575,9 @@ Токен %1$s является основной валютой в сети %2$s и не может быть скрыт до тех пор, пока у вас в списке есть другие токены этой сети. Невозможно скрыть %s Нет цены + Обменивайте этот токен на другие с %1$s комиссии за обслуживание с %2$s по %3$s февраля. + Обмен с Changelly, %s комиссии Обменять - Обменяйте этот токен на другие активы в вашем портфеле - Представляем кроссчейн-своп контракт: %s У вас еще нет транзакций Не удалось загрузить историю транзакций.\nНажмите на кнопку перезагрузки, чтобы обновить информацию. diff --git a/core/res/src/main/res/values/strings.xml b/core/res/src/main/res/values/strings.xml index dd42088e6b..43914b654e 100644 --- a/core/res/src/main/res/values/strings.xml +++ b/core/res/src/main/res/values/strings.xml @@ -273,8 +273,8 @@ 1INCH tokens will be credited to your %s wallet address within 48 hours To access all the networks you need to scan the card Scan your card - Swap multiple currencies across several blockchains - Cross-chain swaps are now available + Enjoy %1$s service fees on swaps via Changelly from February %2$s-%3$s + Swap with Changelly, %s fees Tokens Add Edit @@ -587,8 +587,8 @@ The %1$s token is the main currency on the %2$s network and cannot be hidden as long as you have other tokens on this network in the list. Unable to hide %s No rate - Exchange this token for other assets in your portfolio - Introducing cross-chain swaps + Exchange this token for another at %1$s service fees from February %2$s-%3$s. + Swap with Changelly, %s fees Swap now contract: %s You don\'t have any transactions yet diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/notifications/NotificationWithBackground.kt b/core/ui/src/main/java/com/tangem/core/ui/components/notifications/NotificationWithBackground.kt index 691cded7ba..e4e8a06833 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/notifications/NotificationWithBackground.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/notifications/NotificationWithBackground.kt @@ -28,6 +28,7 @@ import com.tangem.core.ui.components.buttons.common.TangemButtonIconPosition import com.tangem.core.ui.extensions.resolveReference import com.tangem.core.ui.extensions.resourceReference import com.tangem.core.ui.extensions.stringReference +import com.tangem.core.ui.extensions.wrappedList import com.tangem.core.ui.res.LocalIsInDarkTheme import com.tangem.core.ui.res.TangemColorPalette.Dark6 import com.tangem.core.ui.res.TangemColorPalette.Light4 @@ -55,7 +56,7 @@ fun NotificationWithBackground(config: NotificationConfig, modifier: Modifier = val spacing14 = TangemTheme.dimens.spacing14 Image( - painter = painterResource(config.backgroundResId ?: R.drawable.img_swap_promo_banner_background), + painter = painterResource(config.backgroundResId ?: R.drawable.img_swap_promo_blue_banner_background), contentDescription = null, contentScale = ContentScale.Crop, modifier = Modifier.constrainAs(backgroundRef) { @@ -171,13 +172,19 @@ private class NotificationWithBackgroundPreviewProvider : PreviewParameterProvid override val values: Sequence get() = sequenceOf( NotificationConfig( - title = resourceReference(id = R.string.main_swap_promotion_title), - subtitle = resourceReference(id = R.string.main_swap_promotion_message), + title = resourceReference(id = R.string.main_swap_changelly_promotion_title), + subtitle = resourceReference( + id = R.string.main_swap_changelly_promotion_message, + formatArgs = wrappedList("1", "2"), + ), iconResId = R.drawable.img_swap_promo, - backgroundResId = R.drawable.img_swap_promo_banner_background, + backgroundResId = R.drawable.img_swap_promo_blue_banner_background, ), NotificationConfig( - title = resourceReference(id = R.string.token_swap_promotion_title), + title = resourceReference( + id = R.string.token_swap_changelly_promotion_title, + formatArgs = wrappedList("1", "2"), + ), subtitle = stringReference( "Swap multiple currencies between any chains you wish. Swap multiple " + "currencies between any chains you wish. Swap multiple " + @@ -185,7 +192,7 @@ private class NotificationWithBackgroundPreviewProvider : PreviewParameterProvid "till Dec 31.", ), iconResId = R.drawable.img_swap_promo, - backgroundResId = R.drawable.img_swap_promo_banner_background, + backgroundResId = R.drawable.img_swap_promo_blue_banner_background, buttonsState = NotificationConfig.ButtonsState.SecondaryButtonConfig( text = resourceReference(id = R.string.token_swap_promotion_button), onClick = {}, diff --git a/core/ui/src/main/res/drawable/img_swap_promo_banner_background.webp b/core/ui/src/main/res/drawable/img_swap_promo_blue_banner_background.webp similarity index 100% rename from core/ui/src/main/res/drawable/img_swap_promo_banner_background.webp rename to core/ui/src/main/res/drawable/img_swap_promo_blue_banner_background.webp diff --git a/core/ui/src/main/res/drawable/img_swap_promo_green_banner_background.webp b/core/ui/src/main/res/drawable/img_swap_promo_green_banner_background.webp new file mode 100644 index 0000000000000000000000000000000000000000..ffaced2ad24053b210b26e771c88376f428826da GIT binary patch literal 12118 zcmV-cFR9Q{Nk&FaF8}~nMM6+kP&gn$F8~1WzyO^ADg^{A0X|VCk47V=p`#-)%h1pY z32A4*zh94F|NmP*z~t5c^Wf%|x?IflF>){e{-^)OsTy-Pc%do1|1q<$f3Sbd<)O$t zXWujSAO1D((B+&r`Mn_g+9`Ga|C*2QfB#+s`ak=0Oa1id!iP=K{Iat-nHgu zub%h+K0m*I{`86W|NgwW{j>kxa6kX+Z}K;3fB)(K`&?*0|L7!7AOG(I{p*9r!~g%; zr~054w43_)X>iXfucUyN8o3-ai62tuzZfjLF{cxW#F9k|kY5<{a2Cj>01#flu9KMi9{2U`!~$r3~eGc`kwMaoHox$P}HE7bU(f2w9^~2 zLDw(#dRmTc9_WBQT-w+iPwvB4$y-U>NcY^FaL`4UMl5Yd7LBdV>TTiZuqa?q#HZy6 z405J!>VCzH-9|3B(x<$ggYH)7Jq|n{fu28MgY_;^j6y-<7Vi}VinJFqUlN~WV%}_J zSLqiG#|^COq)tvG-3Iy)v41}9n2&!GyTa1aHW~o;UdQ_R?QDqrNEVW?zhyB~?hI@o zTx$6vd&dgD0Lvx%P$s$)*}8FLYeQz@FuZ)*=7@h&xX=6a?c=e;*DlKI=es7F^nhL8 zATnK$4CZ}PmUL!L0c1U8$PcupN812!@`ux6%CuRsZ6|GI=5#X{Lu%Im(|*)TI6+O#3;i z+32n=W&d+RJv#_l6c}qbW6}_^;pjlCevZYF(htkxGg)FqgCl+MK>euWw}hA+zq^w`xQ$kgEH^aT@(QOkUYmE713r-IF$3>0N?D>ujtyFj~N zn@Pi%AmGe3=J6Et=nXUF5yeZjcNcWYWfkcF4$$eCfRHJXSQU4VFmF-ImnOVV1_`c% z_*^7>PXs$IKDQ)DX=4$UIU~aTJKE7vdJbZyjN3h2uV35mKy4_r5|SHj#~!CM*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Y5Xt#lWqnWE0jj{ApdZF%)xX^-F zpCkq~6>*dBFlg(fFIe5z%!+CdFFWnXD*PQfTC97_d6*tYd{3j}b28MX@`4J$7}P94 zXnMym1WGZ9Lp0T`id%Q74*~J4JI>2~KQ~Z!X;%$RBA0 z=RPEK!bLw~Zh}02+r}TC!fP_2U9o8!`hkMO6)5@79hv0CMXVKy==n|hew2u`%HVq` zEk^7+Ej}fHp_&;;Rh#Zl=%A4K@n%28Lc25x(%Kdf|MAWHptOo$N51J`PDfZq0vU)Y z25MLvt@89;*3B718*VLa*CpvIH{L3smh&i9?cT3ad&_E=ICx{rrw^(4BfEyu#oXef zbf1^m*XCj+?Pq`w_ zKe{jB=gpV8aJUtpcI!hF%*oENJ@5uB-9!uP@UaIC8#O$-x{($je6$04?>88=P>-9M z>N}y)I8NMREcb!?od;k8WSkMl(-XY?5<8+2d9E#iv$8&1;da(Dy}_BA3{K}S5*^R0 zBA=UhXWzkB&(*yyTjB8v!}qLd8HSvDJ;tuH+q^y>X5)%4o^dy$zCo9vUMEzi<}EYc zX$91sD;KLo)hEa7vw`%GF3I0B`qffHyFXH^m?V52vJJ>6-jV1Y(7-TcRNs1@&79cR zHS9VFp~jr?ova}sBHa8yiJ$`kg;~MIe3<1e)x_$s6t+hzM`HNfB!xG}uR7dc_pO)^ zJD}=&2`(QpCP9EG;=L5{1$Ju5u^MAOdwxI6Tqc@>U-#2sW$PUsXF5gm*L@H(ihwjv z#}{th6biP8^#^PUhGKkPD58*4KD@)5muk-9m07j(=D1gH^l=GA5*Bj5PvNx*I58?E zg6tj&NyvzGMO#k~cU4Y$F`*?UZaseW4TaYH$%MYQd;emkNuv#QX^rfVnbc&j^RJEp MDW{!NqL?560Qs9?9RL6T literal 0 HcmV?d00001 diff --git a/data/promo/.gitignore b/data/promo/.gitignore new file mode 100644 index 0000000000..42afabfd2a --- /dev/null +++ b/data/promo/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/data/promo/build.gradle.kts b/data/promo/build.gradle.kts new file mode 100644 index 0000000000..b11dc26ed9 --- /dev/null +++ b/data/promo/build.gradle.kts @@ -0,0 +1,25 @@ +plugins { + alias(deps.plugins.android.library) + alias(deps.plugins.kotlin.android) + alias(deps.plugins.kotlin.kapt) + alias(deps.plugins.hilt.android) + id("configuration") +} + +android { + namespace = "com.tangem.data.promo" +} + +dependencies { + implementation(deps.androidx.datastore) + + implementation(deps.jodatime) + implementation(deps.hilt.android) + kapt(deps.hilt.kapt) + + implementation(projects.domain.tokens) + implementation(projects.domain.tokens.models) + + implementation(projects.core.datasource) + implementation(projects.core.utils) +} \ No newline at end of file diff --git a/data/promo/src/main/java/com/tangem/data/promo/DefaultPromoRepository.kt b/data/promo/src/main/java/com/tangem/data/promo/DefaultPromoRepository.kt new file mode 100644 index 0000000000..3121a961d7 --- /dev/null +++ b/data/promo/src/main/java/com/tangem/data/promo/DefaultPromoRepository.kt @@ -0,0 +1,29 @@ +package com.tangem.data.promo + +import com.tangem.data.promo.converters.PromoResponseConverter +import com.tangem.datasource.api.common.response.getOrThrow +import com.tangem.datasource.api.tangemTech.TangemTechApi +import com.tangem.domain.promo.PromoBanner +import com.tangem.domain.tokens.repository.PromoRepository +import com.tangem.utils.coroutines.CoroutineDispatcherProvider +import com.tangem.utils.coroutines.runCatching + +internal class DefaultPromoRepository( + private val tangemApi: TangemTechApi, + private val dispatchers: CoroutineDispatcherProvider, +) : PromoRepository { + + private val promoResponseConverter = PromoResponseConverter() + override suspend fun getChangellyPromoBanner(): PromoBanner? { + return runCatching(dispatchers.io) { + promoResponseConverter.convert( + tangemApi.getPromotionInfo(CHANGELLY_NAME) + .getOrThrow(), + ) + }.getOrNull() + } + + private companion object { + private const val CHANGELLY_NAME = "changelly" + } +} \ No newline at end of file diff --git a/data/promo/src/main/java/com/tangem/data/promo/converters/PromoResponseConverter.kt b/data/promo/src/main/java/com/tangem/data/promo/converters/PromoResponseConverter.kt new file mode 100644 index 0000000000..c7ad8f331a --- /dev/null +++ b/data/promo/src/main/java/com/tangem/data/promo/converters/PromoResponseConverter.kt @@ -0,0 +1,23 @@ +package com.tangem.data.promo.converters + +import com.tangem.datasource.api.promotion.models.PromotionInfoResponse +import com.tangem.domain.promo.PromoBanner +import com.tangem.utils.converter.Converter +import org.joda.time.DateTime + +class PromoResponseConverter : Converter { + + override fun convert(value: PromotionInfoResponse): PromoBanner? { + val bannerState = value.bannerState ?: return null + return PromoBanner( + name = value.name, + bannerState = PromoBanner.BannerState( + status = bannerState.status, + timeline = PromoBanner.Timeline( + start = DateTime.parse(bannerState.timeline.start), + end = DateTime.parse(bannerState.timeline.end), + ), + ), + ) + } +} \ No newline at end of file diff --git a/data/promo/src/main/java/com/tangem/data/promo/di/PromoDataModule.kt b/data/promo/src/main/java/com/tangem/data/promo/di/PromoDataModule.kt new file mode 100644 index 0000000000..c094043a9c --- /dev/null +++ b/data/promo/src/main/java/com/tangem/data/promo/di/PromoDataModule.kt @@ -0,0 +1,26 @@ +package com.tangem.data.promo.di + +import com.tangem.data.promo.DefaultPromoRepository +import com.tangem.datasource.api.tangemTech.TangemTechApi +import com.tangem.datasource.di.DevTangemApi +import com.tangem.domain.tokens.repository.PromoRepository +import com.tangem.utils.coroutines.CoroutineDispatcherProvider +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +internal object PromoDataModule { + + @Provides + @Singleton + fun providePromoRepository( + @DevTangemApi tangemTechApi: TangemTechApi, + dispatchers: CoroutineDispatcherProvider, + ): PromoRepository { + return DefaultPromoRepository(tangemTechApi, dispatchers) + } +} \ No newline at end of file diff --git a/data/settings/src/main/java/com/tangem/data/settings/DefaultSwapPromoRepository.kt b/data/settings/src/main/java/com/tangem/data/settings/DefaultSwapPromoRepository.kt index 8ba9fe211e..6d9ccf740a 100644 --- a/data/settings/src/main/java/com/tangem/data/settings/DefaultSwapPromoRepository.kt +++ b/data/settings/src/main/java/com/tangem/data/settings/DefaultSwapPromoRepository.kt @@ -1,14 +1,12 @@ package com.tangem.data.settings import com.tangem.datasource.local.preferences.AppPreferencesStore -import com.tangem.datasource.local.preferences.PreferencesKeys.IS_TOKEN_SWAP_PROMO_SHOW_KEY -import com.tangem.datasource.local.preferences.PreferencesKeys.IS_WALLET_SWAP_PROMO_SHOW_KEY +import com.tangem.datasource.local.preferences.PreferencesKeys.IS_TOKEN_SWAP_PROMO_CHANGELLY_SHOW_KEY +import com.tangem.datasource.local.preferences.PreferencesKeys.IS_WALLET_SWAP_PROMO_CHANGELLY_SHOW_KEY import com.tangem.datasource.local.preferences.utils.get import com.tangem.datasource.local.preferences.utils.store import com.tangem.domain.settings.repositories.SwapPromoRepository import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.map -import java.util.Calendar /** * Repository for showing swap promo notification. @@ -16,47 +14,25 @@ import java.util.Calendar class DefaultSwapPromoRepository( private val appPreferencesStore: AppPreferencesStore, ) : SwapPromoRepository { - override fun isReadyToShowWallet(): Flow { - return appPreferencesStore.get(IS_WALLET_SWAP_PROMO_SHOW_KEY, true) - .map { it && checkPromoPeriod() } + override fun isReadyToShowWalletPromo(): Flow { + return appPreferencesStore.get(IS_WALLET_SWAP_PROMO_CHANGELLY_SHOW_KEY, true) } - override fun isReadyToShowToken(): Flow { - return appPreferencesStore.get(IS_TOKEN_SWAP_PROMO_SHOW_KEY, true) - .map { it && checkPromoPeriod() } + override fun isReadyToShowTokenPromo(): Flow { + return appPreferencesStore.get(IS_TOKEN_SWAP_PROMO_CHANGELLY_SHOW_KEY, true) } - override suspend fun setNeverToShowWallet() { + override suspend fun setNeverToShowWalletPromo() { appPreferencesStore.store( - key = IS_WALLET_SWAP_PROMO_SHOW_KEY, + key = IS_WALLET_SWAP_PROMO_CHANGELLY_SHOW_KEY, value = false, ) } - override suspend fun setNeverToShowToken() { + override suspend fun setNeverToShowTokenPromo() { appPreferencesStore.store( - key = IS_TOKEN_SWAP_PROMO_SHOW_KEY, + key = IS_TOKEN_SWAP_PROMO_CHANGELLY_SHOW_KEY, value = false, ) } - - private suspend fun checkPromoPeriod(): Boolean { - val calendar = Calendar.getInstance() - val currentTime = calendar.timeInMillis - calendar.set(END_YEAR_KEY, END_MONTH_KEY, END_DAY_KEY, 0, 0, 0) - val endTime = calendar.timeInMillis - - val shouldShow = endTime - currentTime > 0 - if (!shouldShow) { - setNeverToShowToken() - setNeverToShowWallet() - } - return shouldShow - } - - companion object { - private const val END_DAY_KEY = 1 - private const val END_MONTH_KEY = 1 // February - private const val END_YEAR_KEY = 2024 - } } \ No newline at end of file diff --git a/domain/settings/src/main/java/com/tangem/domain/settings/ShouldShowSwapPromoTokenUseCase.kt b/domain/settings/src/main/java/com/tangem/domain/settings/ShouldShowSwapPromoTokenUseCase.kt index 0c75a4f52a..966e1bcf83 100644 --- a/domain/settings/src/main/java/com/tangem/domain/settings/ShouldShowSwapPromoTokenUseCase.kt +++ b/domain/settings/src/main/java/com/tangem/domain/settings/ShouldShowSwapPromoTokenUseCase.kt @@ -5,7 +5,7 @@ import kotlinx.coroutines.flow.Flow class ShouldShowSwapPromoTokenUseCase(private val swapPromoRepository: SwapPromoRepository) { - operator fun invoke(): Flow = swapPromoRepository.isReadyToShowToken() + operator fun invoke(): Flow = swapPromoRepository.isReadyToShowTokenPromo() - suspend fun neverToShow() = swapPromoRepository.setNeverToShowToken() + suspend fun neverToShow() = swapPromoRepository.setNeverToShowTokenPromo() } \ No newline at end of file diff --git a/domain/settings/src/main/java/com/tangem/domain/settings/ShouldShowSwapPromoWalletUseCase.kt b/domain/settings/src/main/java/com/tangem/domain/settings/ShouldShowSwapPromoWalletUseCase.kt index 573a5ea94b..e2b30e1ba5 100644 --- a/domain/settings/src/main/java/com/tangem/domain/settings/ShouldShowSwapPromoWalletUseCase.kt +++ b/domain/settings/src/main/java/com/tangem/domain/settings/ShouldShowSwapPromoWalletUseCase.kt @@ -5,7 +5,7 @@ import kotlinx.coroutines.flow.Flow class ShouldShowSwapPromoWalletUseCase(private val swapPromoRepository: SwapPromoRepository) { - operator fun invoke(): Flow = swapPromoRepository.isReadyToShowWallet() + operator fun invoke(): Flow = swapPromoRepository.isReadyToShowWalletPromo() - suspend fun neverToShow() = swapPromoRepository.setNeverToShowWallet() + suspend fun neverToShow() = swapPromoRepository.setNeverToShowWalletPromo() } \ No newline at end of file diff --git a/domain/settings/src/main/java/com/tangem/domain/settings/repositories/SwapPromoRepository.kt b/domain/settings/src/main/java/com/tangem/domain/settings/repositories/SwapPromoRepository.kt index 95d31f65d8..ca97755e66 100644 --- a/domain/settings/src/main/java/com/tangem/domain/settings/repositories/SwapPromoRepository.kt +++ b/domain/settings/src/main/java/com/tangem/domain/settings/repositories/SwapPromoRepository.kt @@ -3,11 +3,11 @@ package com.tangem.domain.settings.repositories import kotlinx.coroutines.flow.Flow interface SwapPromoRepository { - fun isReadyToShowWallet(): Flow + fun isReadyToShowWalletPromo(): Flow - fun isReadyToShowToken(): Flow + fun isReadyToShowTokenPromo(): Flow - suspend fun setNeverToShowWallet() + suspend fun setNeverToShowWalletPromo() - suspend fun setNeverToShowToken() + suspend fun setNeverToShowTokenPromo() } \ No newline at end of file diff --git a/domain/tokens/models/build.gradle.kts b/domain/tokens/models/build.gradle.kts index a354fa4700..f3bf4ce59c 100644 --- a/domain/tokens/models/build.gradle.kts +++ b/domain/tokens/models/build.gradle.kts @@ -15,4 +15,5 @@ dependencies { implementation(deps.tangem.blockchain) { exclude(module = "joda-time") } + implementation(deps.jodatime) } \ No newline at end of file diff --git a/domain/tokens/models/src/main/java/com/tangem/domain/promo/PromoBanner.kt b/domain/tokens/models/src/main/java/com/tangem/domain/promo/PromoBanner.kt new file mode 100644 index 0000000000..564a49e3d4 --- /dev/null +++ b/domain/tokens/models/src/main/java/com/tangem/domain/promo/PromoBanner.kt @@ -0,0 +1,25 @@ +package com.tangem.domain.promo + +import org.joda.time.DateTime + +data class PromoBanner( + val name: String, + val bannerState: BannerState, +) { + + val isActive = bannerState.status == ACTIVE_STATUS && bannerState.timeline.end.isAfterNow + + data class BannerState( + val timeline: Timeline, + val status: String, + ) + + data class Timeline( + val start: DateTime, + val end: DateTime, + ) + + private companion object { + const val ACTIVE_STATUS = "active" + } +} \ No newline at end of file diff --git a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/warnings/CryptoCurrencyWarning.kt b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/warnings/CryptoCurrencyWarning.kt index e393e4fbd3..b90d787043 100644 --- a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/warnings/CryptoCurrencyWarning.kt +++ b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/warnings/CryptoCurrencyWarning.kt @@ -1,6 +1,7 @@ package com.tangem.domain.tokens.model.warnings import com.tangem.domain.tokens.model.CryptoCurrency +import org.joda.time.DateTime import java.math.BigDecimal sealed class CryptoCurrencyWarning { @@ -42,5 +43,8 @@ sealed class CryptoCurrencyWarning { data class HasPendingTransactions(val blockchainSymbol: String) : CryptoCurrencyWarning() - object SwapPromo : CryptoCurrencyWarning() + data class SwapPromo( + val startDateTime: DateTime, + val endDateTime: DateTime, + ) : CryptoCurrencyWarning() } \ No newline at end of file diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyWarningsUseCase.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyWarningsUseCase.kt index b43052898e..3e5b6a3ed4 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyWarningsUseCase.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyWarningsUseCase.kt @@ -7,10 +7,7 @@ import com.tangem.domain.tokens.model.FeePaidCurrency import com.tangem.domain.tokens.model.Network import com.tangem.domain.tokens.model.warnings.CryptoCurrencyWarning import com.tangem.domain.tokens.operations.CurrenciesStatusesOperations -import com.tangem.domain.tokens.repository.CurrenciesRepository -import com.tangem.domain.tokens.repository.MarketCryptoCurrencyRepository -import com.tangem.domain.tokens.repository.NetworksRepository -import com.tangem.domain.tokens.repository.QuotesRepository +import com.tangem.domain.tokens.repository.* import com.tangem.domain.walletmanager.WalletManagersFacade import com.tangem.domain.wallets.models.UserWalletId import com.tangem.feature.swap.domain.api.SwapRepository @@ -29,6 +26,7 @@ class GetCurrencyWarningsUseCase( private val networksRepository: NetworksRepository, private val swapRepository: SwapRepository, private val marketCryptoCurrencyRepository: MarketCryptoCurrencyRepository, + private val promoRepository: PromoRepository, private val showSwapPromoTokenUseCase: ShouldShowSwapPromoTokenUseCase, private val dispatchers: CoroutineDispatcherProvider, ) { @@ -90,7 +88,9 @@ class GetCurrencyWarningsUseCase( showSwapPromoTokenUseCase().conflate(), flowOf(marketCryptoCurrencyRepository.isExchangeable(userWalletId, currency)).conflate(), ) { shouldShowSwapPromo, isExchangeable -> - if (shouldShowSwapPromo && isExchangeable && currencyStatus.value !is CryptoCurrencyStatus.Unreachable) { + val promoBanner = promoRepository.getChangellyPromoBanner() ?: return@combine null + val showPromo = promoBanner.isActive && shouldShowSwapPromo + if (showPromo && isExchangeable && currencyStatus.value !is CryptoCurrencyStatus.Unreachable) { cryptoStatuses.fold( ifLeft = { null }, ifRight = { cryptoCurrencyStatuses -> @@ -124,7 +124,10 @@ class GetCurrencyWarningsUseCase( } } if (showPromo) { - CryptoCurrencyWarning.SwapPromo + CryptoCurrencyWarning.SwapPromo( + startDateTime = promoBanner.bannerState.timeline.start, + endDateTime = promoBanner.bannerState.timeline.end, + ) } else { null } diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/PromoRepository.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/PromoRepository.kt new file mode 100644 index 0000000000..b15e05db54 --- /dev/null +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/PromoRepository.kt @@ -0,0 +1,8 @@ +package com.tangem.domain.tokens.repository + +import com.tangem.domain.promo.PromoBanner + +interface PromoRepository { + + suspend fun getChangellyPromoBanner(): PromoBanner? +} \ No newline at end of file diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt index 8a4732ea16..185abeff5d 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt @@ -9,6 +9,7 @@ import com.tangem.core.ui.extensions.wrappedList import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.tokens.model.warnings.CryptoCurrencyWarning import com.tangem.features.tokendetails.impl.R +import org.joda.time.DateTime @Immutable internal sealed class TokenDetailsNotification(val config: NotificationConfig) { @@ -41,14 +42,22 @@ internal sealed class TokenDetailsNotification(val config: NotificationConfig) { ) data class SwapPromo( + val startDateTime: DateTime, + val endDateTime: DateTime, val onSwapClick: () -> Unit, val onCloseClick: () -> Unit, ) : TokenDetailsNotification( config = NotificationConfig( - title = resourceReference(id = R.string.token_swap_promotion_title), - subtitle = resourceReference(id = R.string.token_swap_promotion_message), + title = resourceReference( + id = R.string.token_swap_changelly_promotion_title, + formatArgs = wrappedList("0%"), + ), + subtitle = resourceReference( + id = R.string.token_swap_changelly_promotion_message, + formatArgs = wrappedList("0%", startDateTime.dayOfMonth, endDateTime.dayOfMonth), + ), iconResId = R.drawable.img_swap_promo, - backgroundResId = R.drawable.img_swap_promo_banner_background, + backgroundResId = R.drawable.img_swap_promo_green_banner_background, onCloseClick = onCloseClick, buttonsState = NotificationConfig.ButtonsState.SecondaryButtonConfig( text = resourceReference(id = com.tangem.core.ui.R.string.token_swap_promotion_button), diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt index c2a5ea5591..bf37784e25 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt @@ -68,6 +68,8 @@ internal class TokenDetailsNotificationConverter( coinSymbol = warning.blockchainSymbol, ) is CryptoCurrencyWarning.SwapPromo -> SwapPromo( + startDateTime = warning.startDateTime, + endDateTime = warning.endDateTime, onSwapClick = clickIntents::onSwapPromoClick, onCloseClick = clickIntents::onSwapPromoDismiss, ) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetMultiWalletWarningsFactory.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetMultiWalletWarningsFactory.kt index 574705c9f4..e4bec421bb 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetMultiWalletWarningsFactory.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetMultiWalletWarningsFactory.kt @@ -4,13 +4,16 @@ import arrow.core.Either import com.tangem.domain.common.CardTypesResolver import com.tangem.domain.common.util.cardTypesResolver import com.tangem.domain.demo.IsDemoCardUseCase +import com.tangem.domain.promo.PromoBanner import com.tangem.domain.settings.IsReadyToShowRateAppUseCase +import com.tangem.domain.settings.ShouldShowSwapPromoWalletUseCase import com.tangem.domain.tokens.GetTokenListUseCase import com.tangem.domain.tokens.error.TokenListError import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.tokens.model.CryptoCurrencyStatus import com.tangem.domain.tokens.model.NetworkGroup import com.tangem.domain.tokens.model.TokenList +import com.tangem.domain.tokens.repository.PromoRepository import com.tangem.domain.wallets.usecase.GetSelectedWalletSyncUseCase import com.tangem.domain.wallets.usecase.IsNeedToBackupUseCase import com.tangem.feature.wallet.presentation.wallet.state.components.WalletNotification @@ -26,12 +29,15 @@ import kotlinx.coroutines.flow.flowOf import timber.log.Timber import javax.inject.Inject +@Suppress("LongParameterList") @ViewModelScoped internal class GetMultiWalletWarningsFactory @Inject constructor( private val getSelectedWalletSyncUseCase: GetSelectedWalletSyncUseCase, private val getTokenListUseCase: GetTokenListUseCase, private val isDemoCardUseCase: IsDemoCardUseCase, private val isReadyToShowRateAppUseCase: IsReadyToShowRateAppUseCase, + private val shouldShowSwapPromoWalletUseCase: ShouldShowSwapPromoWalletUseCase, + private val promoRepository: PromoRepository, private val isNeedToBackupUseCase: IsNeedToBackupUseCase, ) { @@ -52,9 +58,15 @@ internal class GetMultiWalletWarningsFactory @Inject constructor( flow = getTokenListUseCase(userWallet.walletId).conflate(), flow2 = isReadyToShowRateAppUseCase().conflate(), flow3 = isNeedToBackupUseCase(userWallet.walletId).conflate(), - ) { maybeTokenList, isReadyToShowRating, isNeedToBackup -> + flow4 = shouldShowSwapPromoWalletUseCase().conflate(), + ) { maybeTokenList, isReadyToShowRating, isNeedToBackup, shouldShowPromo -> + + val promoBanner = promoRepository.getChangellyPromoBanner() + readyForRateAppNotification = true buildList { + addSwapPromoNotification(shouldShowPromo, promoBanner, clickIntents) + addCriticalNotifications(cardTypesResolver) addInformationalNotifications(cardTypesResolver, maybeTokenList, clickIntents) @@ -66,6 +78,23 @@ internal class GetMultiWalletWarningsFactory @Inject constructor( } } + private fun MutableList.addSwapPromoNotification( + shouldShowPromo: Boolean, + promoBanner: PromoBanner?, + clickIntents: WalletClickIntentsV2, + ) { + promoBanner ?: return + val promoNotification = WalletNotification.SwapPromo( + startDateTime = promoBanner.bannerState.timeline.start, + endDateTime = promoBanner.bannerState.timeline.end, + onCloseClick = clickIntents::onCloseSwapPromoClick, + ) + addIf( + element = promoNotification, + condition = shouldShowPromo && promoBanner.isActive, + ) + } + private fun MutableList.addCriticalNotifications(cardTypesResolver: CardTypesResolver) { addIf( element = WalletNotification.Critical.DevCard, diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletNotification.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletNotification.kt index 7f6bfd6b46..6feefe3150 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletNotification.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletNotification.kt @@ -7,6 +7,7 @@ import com.tangem.core.ui.extensions.pluralReference import com.tangem.core.ui.extensions.resourceReference import com.tangem.core.ui.extensions.wrappedList import com.tangem.feature.wallet.impl.R +import org.joda.time.DateTime /** * Wallet notification component state @@ -168,13 +169,21 @@ sealed class WalletNotification(val config: NotificationConfig) { ) data class SwapPromo( + val startDateTime: DateTime, + val endDateTime: DateTime, val onCloseClick: () -> Unit, ) : WalletNotification( config = NotificationConfig( - title = resourceReference(id = R.string.main_swap_promotion_title), - subtitle = resourceReference(id = R.string.main_swap_promotion_message), + title = resourceReference( + id = R.string.main_swap_changelly_promotion_title, + formatArgs = wrappedList("0%"), + ), + subtitle = resourceReference( + id = R.string.main_swap_changelly_promotion_message, + formatArgs = wrappedList("0%", startDateTime.dayOfMonth, endDateTime.dayOfMonth), + ), iconResId = R.drawable.img_swap_promo, - backgroundResId = R.drawable.img_swap_promo_banner_background, + backgroundResId = R.drawable.img_swap_promo_green_banner_background, onCloseClick = onCloseClick, ), ) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletClickIntents.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletClickIntents.kt index dad5efb741..5c390dcb0b 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletClickIntents.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletClickIntents.kt @@ -72,6 +72,4 @@ internal interface WalletClickIntents { fun onExploreClick() fun onTransactionClick(txHash: String) - - fun onCloseSwapPromoNotificationClick() } \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletNotificationsListFactory.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletNotificationsListFactory.kt index c0145c919b..da74cc71c1 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletNotificationsListFactory.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletNotificationsListFactory.kt @@ -5,7 +5,6 @@ import com.tangem.domain.common.CardTypesResolver import com.tangem.domain.common.util.cardTypesResolver import com.tangem.domain.demo.IsDemoCardUseCase import com.tangem.domain.settings.IsReadyToShowRateAppUseCase -import com.tangem.domain.settings.ShouldShowSwapPromoWalletUseCase import com.tangem.domain.tokens.GetMissedAddressesCryptoCurrenciesUseCase import com.tangem.domain.tokens.error.GetCurrenciesError import com.tangem.domain.tokens.model.CryptoCurrency @@ -41,7 +40,6 @@ internal class WalletNotificationsListFactory( private val isNeedToBackupUseCase: IsNeedToBackupUseCase, private val getMissedAddressCryptoCurrenciesUseCase: GetMissedAddressesCryptoCurrenciesUseCase, private val hasSingleWalletSignedHashesUseCase: HasSingleWalletSignedHashesUseCase, - private val shouldShowSwapPromoWalletUseCase: ShouldShowSwapPromoWalletUseCase, private val clickIntents: WalletClickIntents, ) { @@ -57,12 +55,9 @@ internal class WalletNotificationsListFactory( flow2 = isReadyToShowRateAppUseCase().conflate(), flow3 = isNeedToBackupUseCase(selectedWallet.walletId).conflate(), flow4 = getMissedAddressCryptoCurrenciesUseCase(selectedWallet.walletId).conflate(), - flow5 = shouldShowSwapPromoWalletUseCase().conflate(), - ) { hasSignedHashes, isReadyToShowRating, isNeedToBackup, maybeMissedAddressCurrencies, isShowSwapPromo -> + ) { hasSignedHashes, isReadyToShowRating, isNeedToBackup, maybeMissedAddressCurrencies -> readyForRateAppNotification = true buildList { - addSwapPromoNotification(isShowSwapPromo, cardTypesResolver) - addCriticalNotifications(cardTypesResolver) addInformationalNotifications(cardTypesResolver, maybeMissedAddressCurrencies) @@ -86,18 +81,6 @@ internal class WalletNotificationsListFactory( } } - private fun MutableList.addSwapPromoNotification( - showSwapPromo: Boolean, - cardTypesResolver: CardTypesResolver, - ) { - addIf( - element = WalletNotification.SwapPromo( - clickIntents::onCloseSwapPromoNotificationClick, - ), - condition = showSwapPromo && cardTypesResolver.isMultiwalletAllowed(), - ) - } - private fun MutableList.addCriticalNotifications(cardTypesResolver: CardTypesResolver) { addIf( element = WalletNotification.Critical.DevCard, diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt index 8adfe05590..b1c839e9d0 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt @@ -129,7 +129,6 @@ internal class WalletViewModel @Inject constructor( private val getExplorerTransactionUrlUseCase: GetExplorerTransactionUrlUseCase, private val isDemoCardUseCase: IsDemoCardUseCase, private val scanCardToUnlockWalletUseCase: ScanCardToUnlockWalletClickHandler, - private val shouldShowSwapPromoWalletUseCase: ShouldShowSwapPromoWalletUseCase, isReadyToShowRateAppUseCase: IsReadyToShowRateAppUseCase, isNeedToBackupUseCase: IsNeedToBackupUseCase, getMissedAddressesCryptoCurrenciesUseCase: GetMissedAddressesCryptoCurrenciesUseCase, @@ -148,7 +147,6 @@ internal class WalletViewModel @Inject constructor( isNeedToBackupUseCase = isNeedToBackupUseCase, getMissedAddressCryptoCurrenciesUseCase = getMissedAddressesCryptoCurrenciesUseCase, hasSingleWalletSignedHashesUseCase = hasSingleWalletSignedHashesUseCase, - shouldShowSwapPromoWalletUseCase = shouldShowSwapPromoWalletUseCase, clickIntents = this, ) @@ -795,12 +793,6 @@ internal class WalletViewModel @Inject constructor( refreshSingleCurrencyContent(selectedWalletIndex) } - override fun onCloseSwapPromoNotificationClick() { - viewModelScope.launch(dispatchers.main) { - shouldShowSwapPromoWalletUseCase.neverToShow() - } - } - // FIXME: refreshSingleCurrencyContent mustn't update the TxHistory and Buttons. It only must fetch primary // currency. Now it not works because GetPrimaryCurrency's subscriber uses .distinctUntilChanged() private fun refreshSingleCurrencyContent(walletIndex: Int) { diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/intents/WalletWarningsClickIntents.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/intents/WalletWarningsClickIntents.kt index ae87db6d02..a9c4287571 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/intents/WalletWarningsClickIntents.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/intents/WalletWarningsClickIntents.kt @@ -18,6 +18,7 @@ import com.tangem.domain.redux.LegacyAction import com.tangem.domain.redux.ReduxStateHolder import com.tangem.domain.settings.NeverToSuggestRateAppUseCase import com.tangem.domain.settings.RemindToRateAppLaterUseCase +import com.tangem.domain.settings.ShouldShowSwapPromoWalletUseCase import com.tangem.domain.tokens.FetchTokenListUseCase import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.wallets.models.UnlockWalletsError @@ -62,6 +63,8 @@ internal interface WalletWarningsClickIntents { fun onDislikeAppClick() fun onCloseRateAppWarningClick() + + fun onCloseSwapPromoClick() } @Suppress("LongParameterList") @@ -82,6 +85,7 @@ internal class WalletWarningsClickIntentsImplementer @Inject constructor( private val reduxStateHolder: ReduxStateHolder, private val testerFeatureToggles: TesterFeatureToggles, private val dispatchers: CoroutineDispatcherProvider, + private val shouldShowSwapPromoWalletUseCase: ShouldShowSwapPromoWalletUseCase, ) : BaseWalletClickIntents(), WalletWarningsClickIntents { override fun onAddBackupCardClick() { @@ -302,4 +306,10 @@ internal class WalletWarningsClickIntentsImplementer @Inject constructor( remindToRateAppLaterUseCase() } } + + override fun onCloseSwapPromoClick() { + viewModelScope.launch(dispatchers.main) { + shouldShowSwapPromoWalletUseCase.neverToShow() + } + } } \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 7fc4e85cba..11c13bfbe1 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -152,4 +152,5 @@ include(":data:wallets") include(":data:analytics") include(":data:transaction") include(":data:visa") +include(":data:promo") // endregion Data modules \ No newline at end of file