diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index f0a3593fd3..c5e3043e28 100644 Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ diff --git a/app/src/main/java/com/tangem/domain/wallet/BalanceValidator.java b/app/src/main/java/com/tangem/domain/wallet/BalanceValidator.java index 5e3327e435..0ef65ff1c9 100644 --- a/app/src/main/java/com/tangem/domain/wallet/BalanceValidator.java +++ b/app/src/main/java/com/tangem/domain/wallet/BalanceValidator.java @@ -1,7 +1,13 @@ package com.tangem.domain.wallet; +import android.graphics.Color; +import android.support.v4.content.ContextCompat; import android.util.Pair; +import com.tangem.wallet.R; + +import java.util.Objects; + public class BalanceValidator { private String firstLine; private String secondLine; @@ -19,27 +25,30 @@ public class BalanceValidator { return score + "% safe. " + secondLine; } } + public int GetColor() { + if (score>89) { return R.color.msg_okay;} + else if (score>74) { return android.R.color.holo_orange_light;} + else if (score>0) { return android.R.color.holo_orange_dark;} + else { return android.R.color.holo_red_light;} + } public void Check(TangemCard card) { - String defaultFirstLine = "Unknown balance"; - String successFirstLine = "Verified balance"; - - firstLine = successFirstLine; + firstLine = ""; secondLine = ""; // rule 1 if(!CheckOfflineBalance(card) && !CheckOnlineBalance(card)) { score = 0; - secondLine = "Balance cannot be verified."; - firstLine = defaultFirstLine; + firstLine = "Unknown balance"; + secondLine = "Balance cannot be verified. Swipe down to refresh."; return; } // rule 2.a if(!VerificationWalletKey(card)) { score = 0; - secondLine = "Wallet verification failed."; - firstLine = defaultFirstLine; + firstLine = "Verification failed"; + secondLine = "Wallet verification failed. Tap again."; return; } @@ -47,8 +56,8 @@ public class BalanceValidator { // rule 2.c if(!CheckAttestationServiceResult(card)) { score = 0; - secondLine = "Do not accept. Tangem Attestation service says card is not genuine. "; - firstLine = successFirstLine; + firstLine = "Not genuine banknote"; + secondLine = "Tangem Attestation service says the banknote is not genuine."; return; } @@ -58,17 +67,20 @@ public class BalanceValidator { if(card.isBalanceRecieved() && card.isBalanceEqual()) { score = 100; firstLine = "Verified balance"; - secondLine += " Confirmed balance and banknote identity. "; + secondLine += "Confirmed balance and banknote identity. "; + if(card.getBalance() == 0) { + firstLine = "Zero balance"; + } } if(card.getFailedBalanceRequestCounter()!=0) { - score = 100 - 5 * card.getFailedBalanceRequestCounter(); - firstLine = "Verified balance"; + score -= 5 * card.getFailedBalanceRequestCounter(); secondLine += "Not all nodes have returned balance. Swipe down to refresh. "; if(score <= 0) return; } -// + + // // if(card.isBalanceRecieved() && !card.isBalanceEqual()) { // score = 0; // firstLine = "Disputed balance"; @@ -80,9 +92,9 @@ public class BalanceValidator { // rule 7 if(CheckOfflineBalance(card) && !CheckOnlineBalance(card)) { - score -= 10; - String firstLine = "Verified offline balance"; - secondLine += "Restore internet connection to be more confidient. "; + score = 90; + firstLine = "Verified offline balance"; + secondLine += "Restore internet connection to be more confident. "; if(score <= 0) return; } @@ -92,7 +104,6 @@ public class BalanceValidator { { score -= 15; secondLine += "Card identity was not verified. Cannot reach attestation service. "; - firstLine = successFirstLine; if(score <= 0) return; } @@ -101,7 +112,7 @@ public class BalanceValidator { if(IsLostSecondRead(card)) { score -= 30; - secondLine += "Wallet and banknote keys were not verified (tap again). "; + secondLine += "Wallet and banknote keys were not verified. Tap again. "; if(score <= 0) return; } @@ -110,8 +121,8 @@ public class BalanceValidator { if(!CheckSignHashes(card)) { score -= 50; - secondLine = "Unguaranteed balance"; - firstLine += "Potential unsent transaction at the moment. Try to tap and check this banknote later. "; + firstLine = "Unguaranteed balance"; + secondLine += "Potential unsent transaction at the moment. Try to tap and check this banknote later. "; if(score <= 0) return; } diff --git a/app/src/main/java/com/tangem/presentation/fragment/LoadedWallet.java b/app/src/main/java/com/tangem/presentation/fragment/LoadedWallet.java index eb0e08f954..aaa8b69154 100644 --- a/app/src/main/java/com/tangem/presentation/fragment/LoadedWallet.java +++ b/app/src/main/java/com/tangem/presentation/fragment/LoadedWallet.java @@ -748,6 +748,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre validator.Check(mCard); tvBalanceLine1.setText(validator.GetFirstLine()); tvBalanceLine2.setText(validator.GetSecondLine()); + tvBalanceLine1.setTextColor(ContextCompat.getColor(Objects.requireNonNull(getContext()),validator.GetColor())); } if (engine.HasBalanceInfo(mCard) || mCard.getOfflineBalance() == null) { diff --git a/app/src/main/res/layout/fr_loaded_wallet.xml b/app/src/main/res/layout/fr_loaded_wallet.xml index ef7e432227..722f8e79bb 100644 --- a/app/src/main/res/layout/fr_loaded_wallet.xml +++ b/app/src/main/res/layout/fr_loaded_wallet.xml @@ -142,7 +142,7 @@ android:layout_marginTop="5dp" android:fontFamily="@font/montserrat_light" android:textAlignment="center" - android:textColor="@color/msg_okay" + android:textColor="@android:color/holo_orange_dark" android:textSize="18sp" />