Updated on 2026-08-14
This commit is contained in:
commit
63e9f37adb
18 changed files with 214 additions and 86 deletions
|
|
@ -102,6 +102,7 @@ dependencies {
|
|||
|
||||
// Firebase
|
||||
implementation 'com.google.firebase:firebase-crashlytics:17.2.2'
|
||||
implementation 'com.google.firebase:firebase-analytics:17.6.0'
|
||||
|
||||
testImplementation 'junit:junit:4.13'
|
||||
testImplementation "com.google.truth:truth:1.0.1"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
|
||||
<uses-feature android:name="android.hardware.camera" />
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" />
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import android.content.pm.ActivityInfo
|
|||
import android.nfc.NfcAdapter
|
||||
import android.nfc.Tag
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.tangem.CardFilter
|
||||
import com.tangem.Config
|
||||
|
|
@ -78,7 +77,7 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
override fun onNewIntent(intent: Intent?) {
|
||||
super.onNewIntent(intent)
|
||||
Handler(mainLooper).postDelayed( { handleBackgroundScan(intent) } , 200)
|
||||
handleBackgroundScan(intent)
|
||||
}
|
||||
|
||||
private fun handleBackgroundScan(intent: Intent?) {
|
||||
|
|
@ -88,6 +87,7 @@ class MainActivity : AppCompatActivity() {
|
|||
val tag = intent.getParcelableExtra<Tag>(NfcAdapter.EXTRA_TAG)
|
||||
if (tag != null) {
|
||||
intent.action = null
|
||||
store.dispatch(NavigationAction.NavigateTo(AppScreen.Home, false))
|
||||
store.dispatch(HomeAction.ReadCard)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.tangem.tap
|
||||
|
||||
import android.app.Application
|
||||
import com.tangem.tap.common.analytics.AnalyticsHandler
|
||||
import com.tangem.tap.common.analytics.FirebaseAnalyticsHandler
|
||||
import com.tangem.tap.common.images.PicassoHelper
|
||||
import com.tangem.tap.common.redux.AppState
|
||||
import com.tangem.tap.common.redux.appReducer
|
||||
|
|
@ -16,6 +18,7 @@ val store = Store(
|
|||
state = AppState()
|
||||
)
|
||||
lateinit var preferencesStorage: PreferencesStorage
|
||||
lateinit var analytics: AnalyticsHandler
|
||||
|
||||
class TapApplication : Application() {
|
||||
override fun onCreate() {
|
||||
|
|
@ -26,5 +29,6 @@ class TapApplication : Application() {
|
|||
NetworkConnectivity.createInstance(store, this)
|
||||
preferencesStorage = PreferencesStorage(this)
|
||||
PicassoHelper.initPicassoWithCaching(this)
|
||||
analytics = FirebaseAnalyticsHandler(this)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package com.tangem.tap.common.analytics
|
||||
|
||||
enum class AnalyticsEvent(val event: String) {
|
||||
CARD_IS_SCANNED("card_is_scanned"),
|
||||
TRANSACTION_IS_SENT("transaction_is_sent"),
|
||||
READY_TO_SCAN("ready_to_scan"),
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package com.tangem.tap.common.analytics
|
||||
|
||||
import com.tangem.commands.Card
|
||||
|
||||
interface AnalyticsHandler {
|
||||
fun triggerEvent(event: AnalyticsEvent, card: Card?)
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.tangem.tap.common.analytics
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import androidx.core.os.bundleOf
|
||||
import com.google.firebase.analytics.FirebaseAnalytics
|
||||
import com.tangem.commands.Card
|
||||
|
||||
class FirebaseAnalyticsHandler(private val context: Context): AnalyticsHandler {
|
||||
override fun triggerEvent(event: AnalyticsEvent, card: Card?) {
|
||||
FirebaseAnalytics.getInstance(context)
|
||||
.logEvent(AnalyticsEvent.CARD_IS_SCANNED.event, setCardData(card))
|
||||
}
|
||||
|
||||
private fun setCardData(card: Card?): Bundle {
|
||||
if (card == null) return bundleOf()
|
||||
return bundleOf(
|
||||
AnalyticsParam.BLOCKCHAIN.param to card.cardData?.blockchainName,
|
||||
AnalyticsParam.BATCH_ID.param to card.cardData?.batchId,
|
||||
AnalyticsParam.FIRMWARE.param to card.firmwareVersion
|
||||
)
|
||||
}
|
||||
|
||||
private enum class AnalyticsParam(val param: String) {
|
||||
BLOCKCHAIN("blockchain"),
|
||||
BATCH_ID("batch_id"),
|
||||
FIRMWARE("firmware"),
|
||||
}
|
||||
}
|
||||
|
|
@ -8,8 +8,8 @@ import com.tangem.tap.features.details.redux.DetailsMiddleware
|
|||
import com.tangem.tap.features.details.redux.DetailsState
|
||||
import com.tangem.tap.features.disclaimer.redux.DisclaimerMiddleware
|
||||
import com.tangem.tap.features.disclaimer.redux.DisclaimerState
|
||||
import com.tangem.tap.features.home.redux.HomeMiddleware
|
||||
import com.tangem.tap.features.home.redux.HomeState
|
||||
import com.tangem.tap.features.home.redux.homeMiddleware
|
||||
import com.tangem.tap.features.send.redux.middlewares.sendMiddleware
|
||||
import com.tangem.tap.features.send.redux.states.SendState
|
||||
import com.tangem.tap.features.wallet.redux.WalletState
|
||||
|
|
@ -31,7 +31,7 @@ data class AppState(
|
|||
fun getMiddleware(): List<Middleware<AppState>> {
|
||||
return listOf(
|
||||
logMiddleware, navigationMiddleware, notificationsMiddleware, globalMiddleware,
|
||||
homeMiddleware, walletMiddleware, sendMiddleware,
|
||||
HomeMiddleware().homeMiddleware, walletMiddleware, sendMiddleware,
|
||||
DetailsMiddleware().detailsMiddleware,
|
||||
DisclaimerMiddleware().disclaimerMiddleware
|
||||
)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import com.tangem.common.CompletionResult
|
|||
import com.tangem.common.extensions.CardType
|
||||
import com.tangem.common.extensions.calculateSha256
|
||||
import com.tangem.tangem_sdk_new.extensions.init
|
||||
import com.tangem.tap.common.analytics.AnalyticsEvent
|
||||
import com.tangem.tap.common.analytics.AnalyticsHandler
|
||||
import com.tangem.tap.domain.tasks.CreateWalletAndRescanTask
|
||||
import com.tangem.tap.domain.tasks.ScanNoteResponse
|
||||
import com.tangem.tap.domain.tasks.ScanNoteTask
|
||||
|
|
@ -22,7 +24,8 @@ class TangemSdkManager(val activity: ComponentActivity) {
|
|||
activity, Config(cardFilter = CardFilter(EnumSet.allOf(CardType::class.java)))
|
||||
)
|
||||
|
||||
suspend fun scanNote(): CompletionResult<ScanNoteResponse> {
|
||||
suspend fun scanNote(analyticsHandler: AnalyticsHandler): CompletionResult<ScanNoteResponse> {
|
||||
analyticsHandler.triggerEvent(AnalyticsEvent.READY_TO_SCAN, null)
|
||||
return runTaskAsyncReturnOnMain(ScanNoteTask(),
|
||||
initialMessage = Message(activity.getString(R.string.initial_message_scan_header)))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import com.tangem.commands.CardStatus
|
|||
import com.tangem.commands.common.network.Result
|
||||
import com.tangem.common.extensions.toHexString
|
||||
import com.tangem.tap.TapConfig
|
||||
import com.tangem.tap.analytics
|
||||
import com.tangem.tap.common.analytics.AnalyticsEvent
|
||||
import com.tangem.tap.common.redux.global.CryptoCurrencyName
|
||||
import com.tangem.tap.common.redux.global.FiatCurrencyName
|
||||
import com.tangem.tap.common.redux.global.GlobalAction
|
||||
|
|
@ -77,7 +79,10 @@ class TapWalletManager {
|
|||
handleFiatRatesResult(results)
|
||||
}
|
||||
|
||||
suspend fun onCardScanned(data: ScanNoteResponse) {
|
||||
suspend fun onCardScanned(data: ScanNoteResponse, addAnalyticsEvent: Boolean = false) {
|
||||
if (addAnalyticsEvent) {
|
||||
analytics.triggerEvent(AnalyticsEvent.CARD_IS_SCANNED, data.card)
|
||||
}
|
||||
tapWorkarounds = TapWorkarounds(data.card)
|
||||
withContext(Dispatchers.Main) {
|
||||
store.dispatch(WalletAction.ResetState)
|
||||
|
|
|
|||
|
|
@ -4,74 +4,64 @@ import android.content.Intent
|
|||
import android.net.Uri
|
||||
import androidx.core.content.ContextCompat.startActivity
|
||||
import com.tangem.common.CompletionResult
|
||||
import com.tangem.tap.*
|
||||
import com.tangem.tap.common.redux.AppState
|
||||
import com.tangem.tap.common.redux.global.GlobalAction
|
||||
import com.tangem.tap.common.redux.navigation.AppScreen
|
||||
import com.tangem.tap.common.redux.navigation.NavigationAction
|
||||
import com.tangem.tap.preferencesStorage
|
||||
import com.tangem.tap.scope
|
||||
import com.tangem.tap.store
|
||||
import com.tangem.tap.tangemSdkManager
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.rekotlin.Middleware
|
||||
|
||||
val homeMiddleware: Middleware<AppState> = { dispatch, state ->
|
||||
{ next ->
|
||||
{ action ->
|
||||
when (action) {
|
||||
is HomeAction.CheckIfFirstLaunch -> {
|
||||
store.dispatch(
|
||||
HomeAction.CheckIfFirstLaunch.Result(preferencesStorage.isFirstLaunch())
|
||||
)
|
||||
}
|
||||
is HomeAction.ReadCard -> {
|
||||
scope.launch {
|
||||
val result = tangemSdkManager.scanNote()
|
||||
withContext(Dispatchers.Main) {
|
||||
when (result) {
|
||||
is CompletionResult.Success -> {
|
||||
store.dispatch(GlobalAction.RestoreAppCurrency)
|
||||
store.state.globalState.tapWalletManager.onCardScanned(result.data)
|
||||
showDisclaimerOrNavigateToWallet()
|
||||
class HomeMiddleware {
|
||||
val homeMiddleware: Middleware<AppState> = { dispatch, state ->
|
||||
{ next ->
|
||||
{ action ->
|
||||
when (action) {
|
||||
is HomeAction.CheckIfFirstLaunch -> {
|
||||
store.dispatch(
|
||||
HomeAction.CheckIfFirstLaunch.Result(preferencesStorage.isFirstLaunch())
|
||||
)
|
||||
}
|
||||
is HomeAction.ReadCard -> {
|
||||
scope.launch {
|
||||
val result = tangemSdkManager.scanNote(analytics)
|
||||
withContext(Dispatchers.Main) {
|
||||
when (result) {
|
||||
is CompletionResult.Success -> {
|
||||
store.dispatch(GlobalAction.RestoreAppCurrency)
|
||||
store.state.globalState.tapWalletManager.onCardScanned(result.data)
|
||||
showDisclaimerOrNavigateToWallet()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
is HomeAction.GoToShop -> {
|
||||
val uri = Uri.parse(CARD_SHOP_URI)
|
||||
val intent = Intent(Intent.ACTION_VIEW, uri)
|
||||
startActivity(action.context, intent, null)
|
||||
}
|
||||
}
|
||||
is HomeAction.GoToShop -> {
|
||||
val uri = Uri.parse(CARD_SHOP_URI)
|
||||
val intent = Intent(Intent.ACTION_VIEW, uri)
|
||||
startActivity(action.context, intent, null)
|
||||
}
|
||||
next(action)
|
||||
}
|
||||
next(action)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showDisclaimerOrNavigateToWallet() {
|
||||
if (preferencesStorage.wasDisclaimerAccepted()) {
|
||||
navigateToWallet()
|
||||
} else {
|
||||
store.dispatch(NavigationAction.NavigateTo(AppScreen.Disclaimer))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun navigateToWallet() {
|
||||
if (store.state.navigationState.backStack.isNotEmpty()) {
|
||||
val currentScreen = store.state.navigationState.backStack.last()
|
||||
if (currentScreen == AppScreen.Home) {
|
||||
store.dispatch(NavigationAction.NavigateTo(AppScreen.Wallet))
|
||||
} else if (currentScreen != AppScreen.Wallet) {
|
||||
store.dispatch(NavigationAction.PopBackTo(AppScreen.Home))
|
||||
private fun showDisclaimerOrNavigateToWallet() {
|
||||
if (preferencesStorage.wasDisclaimerAccepted()) {
|
||||
store.dispatch(NavigationAction.NavigateTo(AppScreen.Wallet))
|
||||
} else {
|
||||
store.dispatch(NavigationAction.NavigateTo(AppScreen.Disclaimer))
|
||||
}
|
||||
} else {
|
||||
store.dispatch(NavigationAction.NavigateTo(AppScreen.Wallet))
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val CARD_SHOP_URI =
|
||||
"https://shop.tangem.com/?afmc=1i&utm_campaign=1i&utm_source=leaddyno&utm_medium=affiliate"
|
||||
}
|
||||
}
|
||||
|
||||
private const val CARD_SHOP_URI = "https://shop.tangem.com/?afmc=1i&utm_campaign=1i&utm_source=leaddyno&utm_medium=affiliate"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@ import com.google.firebase.crashlytics.FirebaseCrashlytics
|
|||
import com.tangem.blockchain.common.*
|
||||
import com.tangem.blockchain.extensions.Result
|
||||
import com.tangem.blockchain.extensions.Signer
|
||||
import com.tangem.commands.Card
|
||||
import com.tangem.tap.analytics
|
||||
import com.tangem.tap.common.analytics.AnalyticsEvent
|
||||
import com.tangem.tap.common.extensions.stripZeroPlainString
|
||||
import com.tangem.tap.common.redux.AppState
|
||||
import com.tangem.tap.common.redux.global.GlobalAction
|
||||
|
|
@ -47,6 +50,7 @@ private fun verifyAndSendTransaction(
|
|||
) {
|
||||
val sendState = appState?.sendState ?: return
|
||||
val walletManager = appState.globalState.scanNoteResponse?.walletManager ?: return
|
||||
val card = appState.globalState.scanNoteResponse.card
|
||||
val recipientAddress = sendState.addressPayIdState.recipientWalletAddress ?: return
|
||||
val typedAmount = sendState.amountState.amountToExtract ?: return
|
||||
val feeAmount = sendState.feeState.currentFee ?: return
|
||||
|
|
@ -62,14 +66,14 @@ private fun verifyAndSendTransaction(
|
|||
dispatch(AmountAction.SetAmount(typedAmount.value!!.minus(reduceAmount), false))
|
||||
dispatch(AmountActionUi.CheckAmountToSend)
|
||||
}, sendAllCallback = {
|
||||
sendTransaction(action, walletManager, amountToSend, feeAmount, recipientAddress, dispatch)
|
||||
sendTransaction(action, walletManager, amountToSend, feeAmount, recipientAddress, card, dispatch)
|
||||
}, reduceAmount))
|
||||
}
|
||||
transactionErrors.isNotEmpty() -> {
|
||||
dispatch(SendAction.SendError(createValidateTransactionError(transactionErrors, walletManager)))
|
||||
}
|
||||
else -> {
|
||||
sendTransaction(action, walletManager, amountToSend, feeAmount, recipientAddress, dispatch)
|
||||
sendTransaction(action, walletManager, amountToSend, feeAmount, recipientAddress, card, dispatch)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -80,6 +84,7 @@ private fun sendTransaction(
|
|||
amountToSend: Amount,
|
||||
feeAmount: Amount,
|
||||
recipientAddress: String,
|
||||
card: Card,
|
||||
dispatch: (Action) -> Unit
|
||||
) {
|
||||
dispatch(SendAction.ChangeSendButtonState(SendButtonState.PROGRESS))
|
||||
|
|
@ -91,6 +96,7 @@ private fun sendTransaction(
|
|||
withContext(Dispatchers.Main) {
|
||||
when (result) {
|
||||
is Result.Success -> {
|
||||
analytics.triggerEvent(AnalyticsEvent.TRANSACTION_IS_SENT, card)
|
||||
dispatch(SendAction.SendSuccess)
|
||||
dispatch(GlobalAction.UpdateWalletSignedHashes(result.data.walletSignedHashes))
|
||||
dispatch(WalletAction.UpdateWallet)
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import com.tangem.common.CompletionResult
|
|||
import com.tangem.common.extensions.CardType
|
||||
import com.tangem.common.extensions.getType
|
||||
import com.tangem.common.extensions.toHexString
|
||||
import com.tangem.tap.*
|
||||
import com.tangem.tap.common.extensions.copyToClipboard
|
||||
import com.tangem.tap.common.redux.AppState
|
||||
import com.tangem.tap.common.redux.navigation.AppScreen
|
||||
|
|
@ -22,10 +23,6 @@ import com.tangem.tap.features.send.redux.PrepareSendScreen
|
|||
import com.tangem.tap.features.wallet.models.toPendingTransactions
|
||||
import com.tangem.tap.network.NetworkConnectivity
|
||||
import com.tangem.tap.network.NetworkStateChanged
|
||||
import com.tangem.tap.preferencesStorage
|
||||
import com.tangem.tap.scope
|
||||
import com.tangem.tap.store
|
||||
import com.tangem.tap.tangemSdkManager
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
|
@ -100,10 +97,11 @@ val walletMiddleware: Middleware<AppState> = { dispatch, state ->
|
|||
}
|
||||
is WalletAction.Scan -> {
|
||||
scope.launch {
|
||||
val result = tangemSdkManager.scanNote()
|
||||
val result = tangemSdkManager.scanNote(analytics)
|
||||
when (result) {
|
||||
is CompletionResult.Success -> {
|
||||
store.state.globalState.tapWalletManager.onCardScanned(result.data)
|
||||
store.state.globalState.tapWalletManager
|
||||
.onCardScanned(result.data, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,10 @@ private fun internalReduce(action: Action, state: AppState): WalletState {
|
|||
addressData = addressData,
|
||||
currencyData = BalanceWidgetData(
|
||||
status = BalanceStatus.Unreachable,
|
||||
currency = wallet?.blockchain?.fullName),
|
||||
currency = wallet?.blockchain?.fullName,
|
||||
token = wallet?.token?.symbol?.let {
|
||||
TokenData("", tokenSymbol = it)
|
||||
}),
|
||||
mainButton = WalletMainButton.SendButton(false)
|
||||
)
|
||||
}
|
||||
|
|
@ -84,7 +87,10 @@ private fun internalReduce(action: Action, state: AppState): WalletState {
|
|||
cardImage = cardImage,
|
||||
currencyData = BalanceWidgetData(
|
||||
BalanceStatus.Loading,
|
||||
wallet?.blockchain?.fullName
|
||||
wallet?.blockchain?.fullName,
|
||||
token = wallet?.token?.symbol?.let {
|
||||
TokenData("", tokenSymbol = it)
|
||||
}
|
||||
),
|
||||
addressData = addressData,
|
||||
mainButton = WalletMainButton.SendButton(false)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import com.tangem.wallet.R
|
|||
import kotlinx.android.synthetic.main.card_balance.*
|
||||
import kotlinx.android.synthetic.main.layout_balance.*
|
||||
import kotlinx.android.synthetic.main.layout_balance_error.*
|
||||
import kotlinx.android.synthetic.main.layout_token.view.*
|
||||
|
||||
enum class BalanceStatus {
|
||||
VerifiedOnline,
|
||||
|
|
@ -50,20 +49,21 @@ class BalanceWidget(
|
|||
fragment.l_balance.show()
|
||||
fragment.l_balance_error.hide()
|
||||
fragment.tv_fiat_amount.hide()
|
||||
fragment.l_token.hide()
|
||||
|
||||
fragment.tv_currency.text = data.currency
|
||||
fragment.tv_amount.text = ""
|
||||
|
||||
showStatus(R.id.tv_status_loading)
|
||||
|
||||
if (data.token != null) {
|
||||
showBalanceWithToken(data, false)
|
||||
} else {
|
||||
showBalanceWithoutToken(data, false)
|
||||
}
|
||||
}
|
||||
BalanceStatus.VerifiedOnline, BalanceStatus.TransactionInProgress -> {
|
||||
fragment.l_balance.show()
|
||||
fragment.l_balance_error.hide()
|
||||
fragment.tv_currency.text = data.currency
|
||||
fragment.tv_amount.text = data.amount
|
||||
fragment.tv_fiat_amount.show()
|
||||
fragment.tv_fiat_amount.text = data.fiatAmount
|
||||
val statusView = if (data.status == BalanceStatus.VerifiedOnline) {
|
||||
R.id.tv_status_verified
|
||||
} else {
|
||||
|
|
@ -75,22 +75,21 @@ class BalanceWidget(
|
|||
fragment.tv_status_error_message.hide()
|
||||
|
||||
if (data.token != null) {
|
||||
fragment.l_token.show()
|
||||
fragment.l_token.tv_token_symbol.text = data.token.tokenSymbol
|
||||
fragment.l_token.tv_token_amount.text = data.token.amount
|
||||
fragment.l_token.tv_token_fiat_amount.text = data.token.fiatAmount
|
||||
showBalanceWithToken(data, true)
|
||||
} else {
|
||||
fragment.l_token.hide()
|
||||
showBalanceWithoutToken(data, true)
|
||||
}
|
||||
}
|
||||
BalanceStatus.Unreachable -> {
|
||||
fragment.l_balance.show()
|
||||
fragment.l_balance_error.hide()
|
||||
fragment.l_token.hide()
|
||||
fragment.tv_fiat_amount.hide()
|
||||
fragment.group_base_currency.hide()
|
||||
|
||||
fragment.tv_currency.text = data.currency
|
||||
val currency = if (data.token != null) data.token.tokenSymbol else data.currency
|
||||
fragment.tv_currency.text = currency
|
||||
fragment.tv_amount.text = ""
|
||||
|
||||
fragment.tv_status_error_message.text = data.errorMessage
|
||||
fragment.tv_status_error.text =
|
||||
fragment.getString(R.string.wallet_balance_blockchain_unreachable)
|
||||
|
|
@ -129,4 +128,26 @@ class BalanceWidget(
|
|||
fragment.tv_status_loading.show(viewRes == R.id.tv_status_loading)
|
||||
fragment.tv_status_verified.show(viewRes == R.id.tv_status_verified)
|
||||
}
|
||||
|
||||
private fun showBalanceWithToken(data: BalanceWidgetData, showAmount: Boolean) {
|
||||
fragment.group_base_currency.show()
|
||||
fragment.tv_currency.text = data.token?.tokenSymbol
|
||||
fragment.tv_base_currency.text = data.currency
|
||||
fragment.tv_amount.text = if (showAmount) data.token?.amount else ""
|
||||
fragment.tv_base_amount.text = if (showAmount) data.amount else ""
|
||||
if (showAmount) {
|
||||
fragment.tv_fiat_amount.show()
|
||||
fragment.tv_fiat_amount.text = data.token?.fiatAmount
|
||||
}
|
||||
}
|
||||
|
||||
private fun showBalanceWithoutToken(data: BalanceWidgetData, showAmount: Boolean) {
|
||||
fragment.group_base_currency.hide()
|
||||
fragment.tv_currency.text = data.currency
|
||||
fragment.tv_amount.text = if (showAmount) data.amount else ""
|
||||
if (showAmount) {
|
||||
fragment.tv_fiat_amount.show()
|
||||
fragment.tv_fiat_amount.text = data.fiatAmount
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -103,10 +103,10 @@
|
|||
app:autoSizeMinTextSize="12sp"
|
||||
app:autoSizeStepGranularity="1sp"
|
||||
app:autoSizeTextType="uniform"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tv_currency"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_weight="1"
|
||||
app:layout_constraintStart_toEndOf="@id/tv_currency"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tv_currency"
|
||||
tools:text="0.43 BTC" />
|
||||
|
||||
<TextView
|
||||
|
|
@ -130,22 +130,64 @@
|
|||
android:paddingTop="4dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:textSize="14sp"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_amount"
|
||||
tools:text="USD 3 588"
|
||||
android:visibility="invisible"/>
|
||||
tools:text="USD 3 588" />
|
||||
|
||||
|
||||
<include
|
||||
android:id="@+id/l_token"
|
||||
layout="@layout/layout_token"
|
||||
<View
|
||||
android:id="@+id/v_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.5dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:background="@color/lightGray5"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_placeholder" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_base_currency"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="35dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:textColor="@color/darkGray6"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/v_divider"
|
||||
tools:text="Ethereum" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_base_amount"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:ellipsize="end"
|
||||
android:gravity="end"
|
||||
android:maxLines="1"
|
||||
android:textAlignment="textEnd"
|
||||
android:textColor="@color/darkGray6"
|
||||
android:textSize="14sp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_currency" />
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="1"
|
||||
app:layout_constraintStart_toEndOf="@id/tv_base_currency"
|
||||
app:layout_constraintTop_toBottomOf="@id/v_divider"
|
||||
tools:text="0.00434143 ETH"
|
||||
/>
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/group_base_currency"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:constraint_referenced_ids="v_divider, tv_base_currency, tv_base_amount" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
6
app/src/main/res/values-v29/styles.xml
Normal file
6
app/src/main/res/values-v29/styles.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="AppTheme" parent="BaseAppTheme">
|
||||
<item name="android:forceDarkAllowed">false</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<resources>
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
|
||||
<style name="BaseAppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorSecondary">@color/colorSecondary</item>
|
||||
|
|
@ -10,6 +10,8 @@
|
|||
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme" parent="BaseAppTheme" />
|
||||
|
||||
<!-- Toolbar -->
|
||||
<style name="DarkToolbarStyle" parent="Theme.AppCompat">
|
||||
<item name="android:textColorPrimary">@android:color/white</item>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue