diff --git a/app/src/main/java/com/tangem/tap/common/extensions/Navigation.kt b/app/src/main/java/com/tangem/tap/common/extensions/Navigation.kt index 588342e8f7..bb69887342 100644 --- a/app/src/main/java/com/tangem/tap/common/extensions/Navigation.kt +++ b/app/src/main/java/com/tangem/tap/common/extensions/Navigation.kt @@ -11,7 +11,6 @@ import com.tangem.tap.features.disclaimer.ui.DisclaimerFragment import com.tangem.tap.features.home.HomeFragment import com.tangem.tap.features.send.ui.SendFragment import com.tangem.tap.features.wallet.ui.WalletFragment -import com.tangem.tap.features.wallet.ui.topup.TopUpFragment import com.tangem.wallet.R fun FragmentActivity.openFragment(screen: AppScreen, addToBackStack: Boolean = true) { @@ -40,7 +39,6 @@ private fun fragmentFactory(screen: AppScreen): Fragment { return when (screen) { AppScreen.Home -> HomeFragment() AppScreen.Wallet -> WalletFragment() - AppScreen.TopUp -> TopUpFragment() AppScreen.Send -> SendFragment() AppScreen.Details -> DetailsFragment() AppScreen.DetailsConfirm -> DetailsConfirmFragment() diff --git a/app/src/main/java/com/tangem/tap/common/redux/navigation/NavigationState.kt b/app/src/main/java/com/tangem/tap/common/redux/navigation/NavigationState.kt index 33d2b18a16..5edfad540b 100644 --- a/app/src/main/java/com/tangem/tap/common/redux/navigation/NavigationState.kt +++ b/app/src/main/java/com/tangem/tap/common/redux/navigation/NavigationState.kt @@ -9,4 +9,4 @@ data class NavigationState( val activity: WeakReference? = null ) : StateType -enum class AppScreen { Home, Wallet, TopUp, Send, Details, DetailsConfirm, DetailsSecurity, Disclaimer } \ No newline at end of file +enum class AppScreen { Home, Wallet, Send, Details, DetailsConfirm, DetailsSecurity, Disclaimer } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/domain/TapWorkarounds.kt b/app/src/main/java/com/tangem/tap/domain/TapWorkarounds.kt index 7ac2457aa0..de1640fd9c 100644 --- a/app/src/main/java/com/tangem/tap/domain/TapWorkarounds.kt +++ b/app/src/main/java/com/tangem/tap/domain/TapWorkarounds.kt @@ -3,12 +3,19 @@ package com.tangem.tap.domain import com.tangem.commands.Card import java.util.* -class TapWorkarounds(val card: Card) { +object TapWorkarounds { - val isStart2Coin: Boolean = - card.cardData?.issuerName?.toLowerCase(Locale.US) == START_2_COIN_ISSUER + var isStart2Coin: Boolean = false + private set - companion object { - const val START_2_COIN_ISSUER = "start2coin" + fun updateCard(card: Card) { + isStart2Coin = card.cardData?.issuerName?.toLowerCase(Locale.US) == START_2_COIN_ISSUER } + + fun isPayIdEnabled(): Boolean { + if (isStart2Coin) return false + return true + } + + const val START_2_COIN_ISSUER = "start2coin" } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/domain/TopUpHelper.kt b/app/src/main/java/com/tangem/tap/domain/TopUpHelper.kt index 67d07b20d0..5f5ae80096 100644 --- a/app/src/main/java/com/tangem/tap/domain/TopUpHelper.kt +++ b/app/src/main/java/com/tangem/tap/domain/TopUpHelper.kt @@ -9,20 +9,20 @@ import javax.crypto.spec.SecretKeySpec class TopUpHelper { companion object { - const val REDIRECT_URL = "https://success.tangem.com" +// const val REDIRECT_URL = "https://success.tangem.com" - private const val BASE_URL = "https://buy-staging.moonpay.io" + private const val BASE_URL = "https://buy.moonpay.io" private const val API_KEY_PATH = "?apiKey=" private const val CURRENCY_PATH = "¤cyCode=" private const val WALLET_ADDRESS_PATH = "&walletAddress=" - private const val REDIRECT_URL_PATH = "&redirectUrl=" +// private const val REDIRECT_URL_PATH = "&redirectUrl=" private const val SIGNATURE_PATH = "&signature=" fun getUrl(cryptoCurrencyName: CryptoCurrencyName, walletAddress: String, apiKey: String, secretKey: String): String { val originalQuery = API_KEY_PATH + apiKey.urlEncode() + CURRENCY_PATH + cryptoCurrencyName.urlEncode() + - WALLET_ADDRESS_PATH + walletAddress.urlEncode() + - REDIRECT_URL_PATH + REDIRECT_URL.urlEncode() + WALLET_ADDRESS_PATH + walletAddress.urlEncode() +// REDIRECT_URL_PATH + REDIRECT_URL.urlEncode() val signature = createSignature(originalQuery, secretKey) return BASE_URL + originalQuery + SIGNATURE_PATH + signature.urlEncode() diff --git a/app/src/main/java/com/tangem/tap/features/details/redux/DetailsReducer.kt b/app/src/main/java/com/tangem/tap/features/details/redux/DetailsReducer.kt index bab4e4649f..5f4641aed7 100644 --- a/app/src/main/java/com/tangem/tap/features/details/redux/DetailsReducer.kt +++ b/app/src/main/java/com/tangem/tap/features/details/redux/DetailsReducer.kt @@ -3,6 +3,7 @@ package com.tangem.tap.features.details.redux import com.tangem.commands.Card import com.tangem.commands.Settings import com.tangem.tap.common.redux.AppState +import com.tangem.tap.domain.TapWorkarounds import com.tangem.tap.domain.extensions.toSendableAmounts import org.rekotlin.Action import java.util.* @@ -112,6 +113,12 @@ private fun handleSecurityAction( ): DetailsState { return when (action) { is DetailsAction.ManageSecurity.OpenSecurity -> { + if (TapWorkarounds.isStart2Coin) { + return state.copy(securityScreenState = state.securityScreenState?.copy( + allowedOptions = EnumSet.of(SecurityOption.LongTap), + selectedOption = state.securityScreenState.currentOption + )) + } if (state.card?.isPin2Default == null) { return state.copy(securityScreenState = state.securityScreenState?.copy( allowedOptions = EnumSet.noneOf(SecurityOption::class.java) diff --git a/app/src/main/java/com/tangem/tap/features/home/redux/HomeMiddleware.kt b/app/src/main/java/com/tangem/tap/features/home/redux/HomeMiddleware.kt index 987e3c1b3b..586051a676 100644 --- a/app/src/main/java/com/tangem/tap/features/home/redux/HomeMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/home/redux/HomeMiddleware.kt @@ -25,7 +25,7 @@ class HomeMiddleware { when (action) { is HomeAction.CheckIfFirstLaunch -> { store.dispatch( - HomeAction.CheckIfFirstLaunch.Result(preferencesStorage.isFirstLaunch()) + HomeAction.CheckIfFirstLaunch.Result(preferencesStorage.getCountOfLaunches() == 1) ) } is HomeAction.ReadCard -> { diff --git a/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AddressPayIdMiddleware.kt b/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AddressPayIdMiddleware.kt index 320eac8f91..680654633b 100644 --- a/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AddressPayIdMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AddressPayIdMiddleware.kt @@ -4,6 +4,7 @@ import com.tangem.blockchain.common.Wallet import com.tangem.commands.common.network.Result import com.tangem.tap.common.redux.AppState import com.tangem.tap.domain.PayIdManager +import com.tangem.tap.domain.TapWorkarounds import com.tangem.tap.domain.isPayIdSupported import com.tangem.tap.features.send.redux.AddressPayIdActionUi import com.tangem.tap.features.send.redux.AddressPayIdVerifyAction @@ -48,7 +49,7 @@ internal class AddressPayIdMiddleware { private fun setAddressAndCheck(data: String, isUserInput: Boolean, dispatch: (Action) -> Unit) { val potentialPayId = data.toLowerCase() - if (PayIdManager.isPayId(potentialPayId)) { + if (PayIdManager.isPayId(potentialPayId) && TapWorkarounds.isPayIdEnabled()) { dispatch(SetPayIdWalletAddress(potentialPayId, "", isUserInput)) } else { dispatch(SetWalletAddress(data, isUserInput)) @@ -62,7 +63,7 @@ internal class AddressPayIdMiddleware { val addressPayId = sendState.addressPayIdState.normalFieldValue ?: return val isUserInput = sendState.addressPayIdState.viewFieldValue.isFromUserInput - if (PayIdManager.isPayId(addressPayId)) { + if (PayIdManager.isPayId(addressPayId) && TapWorkarounds.isPayIdEnabled()) { verifyPayId(addressPayId, wallet, isUserInput, dispatch) } else { verifyAddress(addressPayId, wallet, isUserInput, dispatch) @@ -104,7 +105,7 @@ internal class AddressPayIdMiddleware { } private fun verifyAddress(address: String, wallet: Wallet, isUserInput: Boolean, dispatch: (Action) -> Unit) { - val supposedAddress = extractAddressFromShareUri(address) + val supposedAddress = extractAddressFromShareUri(address).removeNonAddressData() val failReason = isValidBlockchainAddressAndNotTheSameAsWallet(wallet, supposedAddress) if (failReason == null) { @@ -133,6 +134,8 @@ internal class AddressPayIdMiddleware { return if (prefixes.isEmpty()) shareUri else shareUri.replace(prefixes[0], "") } + private fun String.removeNonAddressData(): String = this.substringBefore("?") + private fun verifyClipboard(input: String?, appState: AppState?, dispatch: DispatchFunction) { val addressPayId = input ?: return val wallet = appState?.sendState?.walletManager?.wallet ?: return @@ -149,7 +152,7 @@ internal class AddressPayIdMiddleware { } } - if (PayIdManager.isPayId(addressPayId)) { + if (PayIdManager.isPayId(addressPayId) && TapWorkarounds.isPayIdEnabled()) { verifyPayId(addressPayId, wallet, false, internalDispatcher) } else { verifyAddress(addressPayId, wallet, false, internalDispatcher) diff --git a/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/SendMiddleware.kt b/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/SendMiddleware.kt index 34414e9381..845373fe34 100644 --- a/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/SendMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/SendMiddleware.kt @@ -12,11 +12,11 @@ import com.tangem.tap.common.redux.AppState import com.tangem.tap.common.redux.global.GlobalAction import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.domain.TapError +import com.tangem.tap.domain.TapWorkarounds import com.tangem.tap.domain.extensions.minimalAmount import com.tangem.tap.features.send.redux.* import com.tangem.tap.features.send.redux.FeeAction.RequestFee import com.tangem.tap.features.send.redux.states.SendButtonState -import com.tangem.tap.features.wallet.redux.WalletAction import com.tangem.tap.scope import com.tangem.tap.tangemSdk import kotlinx.coroutines.Dispatchers @@ -91,15 +91,19 @@ private fun sendTransaction( val txData = walletManager.createTransaction(amountToSend, feeAmount, recipientAddress) scope.launch { walletManager.update() + val isLinkedTerminal = tangemSdk.config.linkedTerminal + if (TapWorkarounds.isStart2Coin) { + tangemSdk.config.linkedTerminal = false + } val signer = Signer(tangemSdk, action.messageForSigner) val result = (walletManager as TransactionSender).send(txData, signer) withContext(Dispatchers.Main) { when (result) { is Result.Success -> { + tangemSdk.config.linkedTerminal = isLinkedTerminal FirebaseAnalyticsHandler.triggerEvent(AnalyticsEvent.TRANSACTION_IS_SENT, card) dispatch(SendAction.SendSuccess) dispatch(GlobalAction.UpdateWalletSignedHashes(result.data.walletSignedHashes)) - dispatch(WalletAction.UpdateWallet) dispatch(NavigationAction.PopBackTo()) } is Result.Failure -> { diff --git a/app/src/main/java/com/tangem/tap/features/send/ui/SendFragment.kt b/app/src/main/java/com/tangem/tap/features/send/ui/SendFragment.kt index 1de12344d5..b9d542836f 100644 --- a/app/src/main/java/com/tangem/tap/features/send/ui/SendFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/send/ui/SendFragment.kt @@ -9,6 +9,7 @@ import android.view.inputmethod.EditorInfo import android.widget.EditText import androidx.core.view.postDelayed import androidx.core.widget.addTextChangedListener +import com.google.android.material.textfield.TextInputEditText import com.tangem.Message import com.tangem.merchant.common.toggleWidget.ToggleWidget import com.tangem.tangem_sdk_new.extensions.hideSoftKeyboard @@ -48,6 +49,8 @@ class SendFragment : BaseStoreFragment(R.layout.fragment_send) { lateinit var sendBtn: ToggleWidget + private lateinit var etAmountToSend: TextInputEditText + private fun initSendButtonStates() { sendBtn = ToggleWidget(flSendButtonContainer, btnSend, progress, ProgressState.None()) sendBtn.setupSendButtonStateModifiers(requireContext()) @@ -60,6 +63,8 @@ class SendFragment : BaseStoreFragment(R.layout.fragment_send) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + etAmountToSend = view.findViewById(R.id.etAmountToSend) + initSendButtonStates() setupAddressOrPayIdLayout() setupAmountLayout() diff --git a/app/src/main/java/com/tangem/tap/features/send/ui/stateSubscribers/SendStateSubscriber.kt b/app/src/main/java/com/tangem/tap/features/send/ui/stateSubscribers/SendStateSubscriber.kt index 0e266fcc54..bdd2e9f3c4 100644 --- a/app/src/main/java/com/tangem/tap/features/send/ui/stateSubscribers/SendStateSubscriber.kt +++ b/app/src/main/java/com/tangem/tap/features/send/ui/stateSubscribers/SendStateSubscriber.kt @@ -5,14 +5,12 @@ import android.content.Context import android.text.SpannableStringBuilder import android.view.ViewGroup import androidx.core.text.bold -import com.tangem.tap.common.extensions.beginDelayedTransition -import com.tangem.tap.common.extensions.enableError -import com.tangem.tap.common.extensions.show -import com.tangem.tap.common.extensions.update +import com.tangem.tap.common.extensions.* import com.tangem.tap.common.redux.getMessageString import com.tangem.tap.common.text.DecimalDigitsInputFilter import com.tangem.tap.common.toggleWidget.ProgressState import com.tangem.tap.domain.MultiMessageError +import com.tangem.tap.domain.TapWorkarounds import com.tangem.tap.domain.assembleErrors import com.tangem.tap.features.send.BaseStoreFragment import com.tangem.tap.features.send.redux.AddressPayIdVerifyAction.Error @@ -106,6 +104,12 @@ class SendStateSubscriber(fragment: BaseStoreFragment) : FragmentStateSubscriber val til = fg.tilAddressOrPayId val parsedError = parseError(til.context, state.error) + val hintResId = if (TapWorkarounds.isPayIdEnabled()) { + R.string.send_destination_hint_address_payid + }else { + R.string.send_destination_hint_address + } + til.hint = til.getString(hintResId) til.parent?.parent?.beginDelayedTransition() til.error = parsedError til.isErrorEnabled = parsedError != null diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletAction.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletAction.kt index 5ac957f1f4..e129bf08b3 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletAction.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletAction.kt @@ -89,8 +89,6 @@ sealed class WalletAction : Action { object EmptyWallet : WalletAction() sealed class TopUpAction : WalletAction() { - data class TopUp(val context: Context, val toolbarColor: Int?) : TopUpAction() - data class Start(val url: String, val redirectUrl: String) : TopUpAction() - data class Finish(val topUpCompleted: Boolean) : TopUpAction() + data class TopUp(val context: Context, val toolbarColor: Int) : TopUpAction() } } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletMiddleware.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletMiddleware.kt index 3b8e7a3fb5..129123e56c 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletMiddleware.kt @@ -2,6 +2,7 @@ package com.tangem.tap.features.wallet.redux import android.content.Intent import android.net.Uri +import androidx.browser.customtabs.CustomTabsIntent import androidx.core.content.ContextCompat import com.tangem.blockchain.common.* import com.tangem.blockchain.extensions.SimpleResult @@ -34,7 +35,6 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import org.rekotlin.Action import org.rekotlin.Middleware -import timber.log.Timber class WalletMiddleware { private val topUpMiddleware = TopUpMiddleware() @@ -73,7 +73,9 @@ class WalletMiddleware { } } is WalletAction.UpdateWallet -> { - scope.launch { store.state.globalState.tapWalletManager.updateWallet() } + if (store.state.walletState.state == ProgressState.Done) { + scope.launch { store.state.globalState.tapWalletManager.updateWallet() } + } } is WalletAction.UpdateWallet.Success -> setupWalletUpdate(action.wallet) is WalletAction.LoadWallet.Success -> { @@ -260,16 +262,10 @@ private class TopUpMiddleware { config.moonPayApiKey, config.moonPayApiSecretKey ) - Timber.d(url) - store.dispatch(WalletAction.TopUpAction.Start(url, TopUpHelper.REDIRECT_URL)) - store.dispatch(NavigationAction.NavigateTo(AppScreen.TopUp)) - } - is WalletAction.TopUpAction.Start -> { - - } - is WalletAction.TopUpAction.Finish -> { - if (action.topUpCompleted) store.dispatch(WalletAction.UpdateWallet) - store.dispatch(NavigationAction.PopBackTo()) + val customTabsIntent = CustomTabsIntent.Builder() + .setToolbarColor(action.toolbarColor) + .build() + customTabsIntent.launchUrl(action.context, Uri.parse(url)); } } } diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletReducer.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletReducer.kt index 358fe8cffc..10fc1610b8 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletReducer.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletReducer.kt @@ -116,7 +116,11 @@ private fun internalReduce(action: Action, state: AppState): WalletState { ), topUpState = TopUpState(false) ) - is WalletAction.UpdateWallet -> newState = newState.copy(updatingWallet = true) + is WalletAction.UpdateWallet -> { + if (store.state.walletState.state == ProgressState.Done) { + newState = newState.copy(updatingWallet = true) + } + } is WalletAction.UpdateWallet.ScheduleUpdatingWallet -> newState = newState.copy(updatingWallet = true) is WalletAction.UpdateWallet.Success -> { @@ -219,9 +223,6 @@ private fun internalReduce(action: Action, state: AppState): WalletState { private fun handleTopUpActions(action: WalletAction.TopUpAction, state: TopUpState): TopUpState { return when (action) { is WalletAction.TopUpAction.TopUp -> state - is WalletAction.TopUpAction.Start -> - state.copy(url = action.url, redirectUrl = action.redirectUrl) - is WalletAction.TopUpAction.Finish -> state.copy(url = null) } } diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletFragment.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletFragment.kt index 25f00a2e49..2be04ad3c9 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletFragment.kt @@ -61,6 +61,7 @@ class WalletFragment : Fragment(R.layout.fragment_wallet), StoreSubscriber { - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - activity?.onBackPressedDispatcher?.addCallback(this, object : OnBackPressedCallback(true) { - override fun handleOnBackPressed() { - store.dispatch(NavigationAction.PopBackTo()) - } - }) - val inflater = TransitionInflater.from(requireContext()) - enterTransition = inflater.inflateTransition(R.transition.slide_right) - exitTransition = inflater.inflateTransition(R.transition.fade) - } - - override fun onStart() { - super.onStart() - store.subscribe(this) { state -> - state.skipRepeats { oldState, newState -> - oldState.walletState == newState.walletState - }.select { it.walletState } - } - } - - override fun onStop() { - super.onStop() - store.unsubscribe(this) - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - web_view.settings.javaScriptEnabled = true - - toolbar.setNavigationOnClickListener { - store.dispatch(NavigationAction.PopBackTo()) - } - - } - - override fun newState(state: WalletState) { - if (activity == null) return - - if (state.topUpState.url != null) { - web_view.webViewClient = TopUpWebViewClient(progress_bar, state.topUpState.redirectUrl) - web_view.loadUrl(state.topUpState.url) - } - } - -} diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/topup/TopUpWebViewClient.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/topup/TopUpWebViewClient.kt deleted file mode 100644 index d728b16128..0000000000 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/topup/TopUpWebViewClient.kt +++ /dev/null @@ -1,31 +0,0 @@ -package com.tangem.tap.features.wallet.ui.topup - -import android.webkit.WebView -import android.webkit.WebViewClient -import android.widget.ProgressBar -import com.tangem.tap.common.extensions.hide -import com.tangem.tap.common.extensions.show -import com.tangem.tap.features.wallet.redux.WalletAction -import com.tangem.tap.store - -class TopUpWebViewClient( - private val progressBar: ProgressBar, private val redirectUrl: String? -) : WebViewClient() { - override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean { - if (redirectUrl != null && url.contains(redirectUrl)) { - store.dispatch(WalletAction.TopUpAction.Finish(true)) - return true - } - view.loadUrl(url) - return true - } - - override fun onPageFinished(view: WebView, url: String) { - super.onPageFinished(view, url) - progressBar.hide() - } - - init { - progressBar.show() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/persistence/PreferencesStorage.kt b/app/src/main/java/com/tangem/tap/persistence/PreferencesStorage.kt index 47f832dbac..6ce4249585 100644 --- a/app/src/main/java/com/tangem/tap/persistence/PreferencesStorage.kt +++ b/app/src/main/java/com/tangem/tap/persistence/PreferencesStorage.kt @@ -3,6 +3,7 @@ package com.tangem.tap.persistence import android.app.Application import android.content.Context import android.content.SharedPreferences +import androidx.core.content.edit import com.squareup.moshi.JsonAdapter import com.squareup.moshi.Moshi import com.squareup.moshi.Types @@ -18,6 +19,10 @@ class PreferencesStorage(applicationContext: Application) { applicationContext.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE) } + init { + incrementLaunchCounter() + } + private val fiatCurrenciesAdapter: JsonAdapter> by lazy { val moshi = Moshi.Builder() .add(KotlinJsonAdapterFactory()) @@ -45,11 +50,7 @@ class PreferencesStorage(applicationContext: Application) { return preferences.edit().putString(FIAT_CURRENCIES_KEY, json).apply() } - fun isFirstLaunch(): Boolean { - val isFirst = !preferences.contains(FIRST_LAUNCH_CHECK_KEY) - if (isFirst) preferences.edit().putInt(FIRST_LAUNCH_CHECK_KEY, System.currentTimeMillis().toInt()).apply() - return isFirst - } + fun getCountOfLaunches(): Int = preferences.getInt(APP_LAUNCH_COUNT_KEY, 1) fun saveScannedCardId(cardId: String) { val scannedCardsIds: String = restoreScannedCardIds() @@ -65,7 +66,6 @@ class PreferencesStorage(applicationContext: Application) { private fun restoreScannedCardIds(): String = preferences.getString(SCANNED_CARDS_IDS_KEY, "") ?: "" - fun saveDisclaimerAccepted() { preferences.edit().putBoolean(DISCLAIMER_ACCEPTED_KEY, true).apply() } @@ -74,6 +74,11 @@ class PreferencesStorage(applicationContext: Application) { return preferences.getBoolean(DISCLAIMER_ACCEPTED_KEY, false) } + private fun incrementLaunchCounter() { + var count = preferences.getInt(APP_LAUNCH_COUNT_KEY, 0) + preferences.edit { putInt(APP_LAUNCH_COUNT_KEY, ++count) } + } + companion object { private const val PREFERENCES_NAME = "tapPrefs" private const val APP_CURRENCY_KEY = "appCurrency" @@ -81,6 +86,7 @@ class PreferencesStorage(applicationContext: Application) { private const val FIRST_LAUNCH_CHECK_KEY = "firstLaunchCheck" private const val SCANNED_CARDS_IDS_KEY = "scannedCardIds" private const val DISCLAIMER_ACCEPTED_KEY = "disclaimerAccepted" + private const val APP_LAUNCH_COUNT_KEY = "launchCount" } } \ No newline at end of file diff --git a/app/src/main/res/layout/layout_send_address_payid.xml b/app/src/main/res/layout/layout_send_address_payid.xml index a1423a4ed9..12a9d76915 100644 --- a/app/src/main/res/layout/layout_send_address_payid.xml +++ b/app/src/main/res/layout/layout_send_address_payid.xml @@ -11,7 +11,7 @@ android:id="@+id/tilAddressOrPayId" android:layout_width="0dp" android:layout_height="wrap_content" - android:hint="@string/send_destination_hint" + android:hint="@string/send_destination_hint_address_payid" app:boxBackgroundColor="@color/backgroundLightGray" app:errorIconDrawable="@null" app:layout_constraintEnd_toEndOf="parent" diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 467c665f4f..d2b3bb460e 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -51,7 +51,8 @@ Ihre PayID wurde erfolgreich erstellt und zum Clipboard kopiert Fehlerantwort beim Erstellen der ZahlungsID Diese PayID existiert bereits. Versuchen Sie mit einer anderen erneut. - Adresse oder PayID + Adresse oder PayID + Adresse Absenden Netzgebühr Betrag diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index f315ba278d..6c2934f23c 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -52,7 +52,8 @@ PayID a été créé avec succès et copié dans le presse-papiers Mauvaise réponse lors de la création de PayID Ce PayID existe déjà. Essayez une autre variante. - Adresse ou PayID + Adresse ou PayID + Adresse Envoyer Commissions du réseau Somme diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 93bac3c897..909b654b6b 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -40,7 +40,7 @@ da %s Cerca indirizzo Crea PayID - portafoglio $s + portafoglio %s Crea PayID Scheda: %s Nome PayID @@ -50,7 +50,8 @@ PayID creato con successo e copiato negli appunti Errore di risposta durante la creazione del PayID Questo PayID esiste già. Scegline un altro. - Indirizzo o PayID + Indirizzo o PayID + Indirizzo Invia Rete libera Importo diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a14f49d345..80f2e89d5f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -62,7 +62,8 @@ Error response while creating PayID This PayID already exists. Try a different one. - Address or PayID + Address or PayID + Address Send Network fee Amount