Updated on 2026-08-14

This commit is contained in:
Tangem 2018-07-11 10:54:58 +03:00
commit 28066a7206
18 changed files with 151 additions and 90 deletions

View file

@ -79,7 +79,7 @@ public class ReadCardInfoTask extends Thread {
if (protocol.haveReadResult()) {
//already have read result (obtained while get supported encryption), only read issuer data and define offline balance
protocol.parseReadResult();
protocol.run_ReadOrWriteIssuerDataAndDefineOfflineBalance();
protocol.run_ReadWriteIssuerData();
mNotifications.OnReadProgress(protocol, 60);
PINStorage.setLastUsedPIN(protocol.getCard().getPIN());
} else {

View file

@ -423,7 +423,7 @@ public class CardProtocol {
parseReadResult();
run_ReadOrWriteIssuerDataAndDefineOfflineBalance();
run_ReadWriteIssuerData();
} else if (rspApdu.isStatus(SW_PIN_ERROR)) {
throw new TangemException_InvalidPIN(String.format("FAILED: [%04X] - Possible PIN is invalid!\n", rspApdu.getSW1SW2()));
@ -432,7 +432,7 @@ public class CardProtocol {
}
}
public void run_ReadOrWriteIssuerDataAndDefineOfflineBalance() throws Exception {
public void run_ReadWriteIssuerData() throws Exception {
TLVList tlvIssuerData;
if (mCard.getNeedWriteIssuerData()) {
run_WriteIssuerData(mCard.getIssuerData(), mCard.getIssuerDataSignature());
@ -450,16 +450,24 @@ public class CardProtocol {
tlvIssuerData = null;
}
}
// try read offline balance data
if (mCard.getStatus() == TangemCard.Status.Loaded) {
// try read offline balance data
if (tlvIssuerData != null && tlvIssuerData.getTLV(TLV.Tag.TAG_Denomination) != null && mCard.getMaxSignatures() == mCard.getRemainingSignatures()) {
mCard.setOfflineBalance(tlvIssuerData.getTLV(TLV.Tag.TAG_Denomination).Value);
if (tlvIssuerData != null && tlvIssuerData.getTLV(TLV.Tag.TAG_ValidatedBalance) != null && mCard.getMaxSignatures() == mCard.getRemainingSignatures()) {
mCard.setOfflineBalance(tlvIssuerData.getTLV(TLV.Tag.TAG_ValidatedBalance).Value);
} else {
mCard.clearOfflineBalance();
}
} else {
mCard.clearOfflineBalance();
}
// try read denomination
if (tlvIssuerData != null && tlvIssuerData.getTLV(TLV.Tag.TAG_Denomination) != null) {
mCard.setDenomination(tlvIssuerData.getTLV(TLV.Tag.TAG_Denomination).Value);
} else {
mCard.clearDenomination();
}
}
private TLVList readResult = null;

View file

@ -88,7 +88,7 @@ public class TLV {
TAG_Token_Symbol(0xA0),
TAG_Token_Contract_Address(0xA1),
TAG_Token_Decimal(0xA2),
TAG_Denomination(/*0xC0*/0xee), //TODO: quick fix
TAG_Denomination(0xC0),
TAG_ValidatedBalance(0xC1),
TAG_LastSign_Date(0xC2);

View file

@ -12,7 +12,7 @@ public enum Blockchain {
BitcoinTestNet("BTC/test", "BTC", 100000000.0, R.drawable.ic_logo_bitcoin_testnet, "Bitcoin Testnet"),
Ethereum("ETH", "ETH", 1.0, R.drawable.ic_logo_ethereum, "Ethereum"),
EthereumTestNet("ETH/test", "ETH", 1.0, R.drawable.ic_logo_ethereum_testnet, "Ethereum Testnet"),
Token("ETH\\XTZ", "BAT", 1.0, R.drawable.ic_logo_bat_token, "Ethereum"),
Token("Token", "ERC20", 1.0, R.drawable.ic_logo_bat_token, "Ethereum"),
BitcoinCash("BCH", "BCH", 100000000.0, R.drawable.ic_logo_bitcoin_cash, "Bitcoin Cash"),
BitcoinCashTestNet("BCH/test", "BTC", 100000000.0, R.drawable.ic_logo_bitcoin_cash, "Bitcoin Cash Testnet");
@ -89,7 +89,7 @@ public enum Blockchain {
case "BTC":
return R.drawable.ic_logo_bitcoin;
case "ETH\\XTZ":
case "Token":
if (symbolName.equals("SEED"))
return R.drawable.ic_logo_seed;
else

View file

@ -104,7 +104,7 @@ public class EthEngine extends CoinEngine {
BigDecimal d = convertToEth(dec);
String s = d.toString();
String pattern = "#0.000"; // If you like 4 zeros
String pattern = "#0.000###############"; // If you like 4 zeros
DecimalFormat myFormatter = new DecimalFormat(pattern);
String output = myFormatter.format(d);
return output;

View file

@ -11,6 +11,7 @@ import com.tangem.wallet.R;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@ -1365,16 +1366,36 @@ public class TangemCard {
countConfirmTX = new BigInteger(B.getString("confirmTx"), 16);
}
private final static char[] hexArray = "0123456789ABCDEF".toCharArray();
public static String bytesToHex(byte[] bytes) {
if (bytes == null) return "";
char[] hexChars = new char[bytes.length * 2];
for ( int j = 0; j < bytes.length; j++ ) {
int v = bytes[j] & 0xFF;
hexChars[j * 2] = hexArray[v >>> 4];
hexChars[j * 2 + 1] = hexArray[v & 0x0F];
}
return new String(hexChars);
}
public int getCardImageResource() {
switch (getBlockchainID()) {
case "BTC":
return R.drawable.card_btc001;
if ( bytesToHex(getDenomination()).equals("40420F0000000000") )
return R.drawable.card_btc001;
else if (bytesToHex(getDenomination()).equals("404B4C0000000000") )
return R.drawable.card_btc005;
else
return R.drawable.card_default;
case "ETH\\XTZ":
return R.drawable.card_seed;
case "Token":
if (getTokenSymbol().equals("SEED"))
return R.drawable.card_seed;
else
return R.drawable.card_default;
default:
return R.drawable.card_btc001;
return R.drawable.card_default;
}
}

View file

@ -107,7 +107,7 @@ public class TokenEngine extends CoinEngine {
BigDecimal d = convertToEth(dec);
String s = d.toString();
String pattern = "#0.000"; // If you like 4 zeros
String pattern = "#0.000###############"; // If you like 4 zeros
DecimalFormat myFormatter = new DecimalFormat(pattern);
String output = myFormatter.format(d);
return output;
@ -134,7 +134,7 @@ public class TokenEngine extends CoinEngine {
p = p.pow(GetTokenDecimals(mCard));
BigDecimal l = d.divide(p);
String pattern = "#0.000"; // If you like 4 zeros
String pattern = "#0.000###############"; // If you like 4 zeros
DecimalFormat myFormatter = new DecimalFormat(pattern);
String output = myFormatter.format(l);
return output;

View file

@ -566,7 +566,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
public void OnReadStart(CardProtocol cardProtocol) {
progressBar.post(() -> {
rlProgressBar.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.VISIBLE);
//progressBar.setVisibility(View.VISIBLE);
progressBar.setProgress(5);
});
}

View file

@ -275,7 +275,7 @@ public class Main extends Fragment implements NfcAdapter.ReaderCallback, CardLis
public void OnReadStart(CardProtocol cardProtocol) {
progressBar.post(() -> {
rlProgressBar.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.VISIBLE);
//progressBar.setVisibility(View.VISIBLE);
progressBar.setProgress(5);
});
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 KiB

After

Width:  |  Height:  |  Size: 176 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 KiB

After

Width:  |  Height:  |  Size: 177 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 KiB

After

Width:  |  Height:  |  Size: 211 KiB

Before After
Before After

View file

@ -49,12 +49,53 @@
android:textSize="@dimen/text_size_1_small"
android:visibility="gone"/>
<ImageView
android:id="@+id/ivTangemCard"
android:layout_width="325dp"
android:layout_height="0dp"
android:layout_weight="1"
tools:src="@drawable/card_btc001"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp">
<ImageView
android:id="@+id/ivTangemCard"
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_weight="1"
tools:src="@drawable/card_default" />
<RelativeLayout
android:id="@+id/rlProgressBar"
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_centerHorizontal="true"
android:elevation="3dp"
android:visibility="gone">
<TextView
android:id="@+id/textView10"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.75"
android:background="@color/white" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:alpha="0.8"
android:text="@string/verifying"
android:textColor="@color/colorPrimary"
android:textStyle="bold" />
<ProgressBar
android:layout_width="@dimen/size_progress_bar_big"
android:layout_height="@dimen/size_progress_bar_big"
android:layout_centerInParent="true"
android:alpha="0.8"
android:elevation="1dp"
android:progressTint="@color/colorPrimary" />
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
@ -63,33 +104,57 @@
android:layout_marginStart="10dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/tvBalance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/montserrat_light"
android:paddingRight="10dp"
android:text="@string/no_data_string"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="@dimen/text_size_large"
tools:text="0.05 BTC" />
<TextView
android:id="@+id/tvBlockchain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:fontFamily="@font/montserrat_light"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="@color/primary"
android:textStyle="normal|bold"
tools:text="Bitcoin" />
</LinearLayout>
<TextView
android:id="@+id/tvBalanceLine1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:fontFamily="@font/montserrat_light"
android:text="Verified balance"
android:textColor="@color/black"
android:textSize="@dimen/text_size_large"
tools:text="Verified balance"/>
<TextView
android:id="@+id/tvBalance"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/montserrat_light"
android:text="@string/no_data_string"
android:textColor="@color/black"
android:textSize="@dimen/text_size_large"
tools:text="0.05 BTC (Bitcoin)"/>
android:textAlignment="center"
android:textColor="@color/msg_okay"
android:textSize="18sp"
tools:text="Verified balance" />
<TextView
android:id="@+id/tvBalanceLine2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginTop="5dp"
android:fontFamily="@font/montserrat_light"
android:text="100% safe. Confirmed balance and banknote identity"/>
android:text="100% safe\nConfirmed balance and banknote identity"
android:textAlignment="center" />
</LinearLayout>
@ -191,15 +256,6 @@
android:text="@string/blockchain"
android:textColor="@color/primary_dark"/>
<TextView
android:id="@+id/tvBlockchain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/montserrat_light"
android:textColor="@color/primary_dark"
android:textStyle="normal|bold"
tools:text="Bitcoin"/>
</LinearLayout>
@ -354,32 +410,6 @@
</LinearLayout>
<RelativeLayout
android:id="@+id/rlProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="215dp"
android:visibility="gone">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:alpha="0.5"
android:text="@string/verifying"
android:textColor="@color/colorPrimary"
android:textStyle="bold"/>
<ProgressBar
android:layout_width="@dimen/size_progress_bar_big"
android:layout_height="@dimen/size_progress_bar_big"
android:layout_centerInParent="true"
android:alpha="0.5"
android:elevation="1dp"/>
</RelativeLayout>
</RelativeLayout>
</android.support.v4.widget.SwipeRefreshLayout>
@ -425,6 +455,7 @@
android:id="@+id/rlToolButtons"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:gravity="center"
app:layout_constraintBottom_toTopOf="@+id/rlCardIdAndIcons"
app:layout_constraintHorizontal_bias="0.0"
@ -436,7 +467,8 @@
style="@style/AppTheme.RoundedCornerMaterialButton"
android:layout_width="wrap_content"
android:layout_margin="10dp"
android:text="@string/load"/>
android:elevation="15dp"
android:text="@string/load" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fabInfo"
@ -445,7 +477,7 @@
android:layout_margin="10dp"
android:layout_marginEnd="5dp"
app:fabSize="mini"
app:srcCompat="@drawable/ic_information_variant_white_24dp"/>
app:srcCompat="@drawable/ic_information_variant_white_24dp" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fabNFC"
@ -455,7 +487,7 @@
android:layout_margin="10dp"
android:layout_marginStart="5dp"
app:fabSize="mini"
app:srcCompat="@drawable/ic_nfc_white_24dp"/>
app:srcCompat="@drawable/ic_nfc_white_24dp" />
<android.support.v7.widget.AppCompatButton
android:id="@+id/btnExtract"
@ -463,7 +495,7 @@
android:layout_width="wrap_content"
android:layout_margin="10dp"
android:width="100dp"
android:text="@string/extract"/>
android:text="@string/extract" />
</LinearLayout>
@ -540,6 +572,7 @@
<include
layout="@layout/layout_progress_horizontal"
android:visibility="invisible"/>
android:visibility="gone"
tools:layout_editor_absoluteY="495dp" />
</android.support.constraint.ConstraintLayout>

View file

@ -15,19 +15,19 @@
android:visibility="gone">
<TextView
android:textStyle="bold"
android:alpha="0.5"
android:textColor="@color/colorPrimary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/reading"/>
android:alpha="0.8"
android:text="@string/reading"
android:textColor="@color/colorPrimary"
android:textStyle="bold" />
<ProgressBar
android:layout_width="@dimen/size_progress_bar_big"
android:layout_height="@dimen/size_progress_bar_big"
android:alpha="0.5"
android:elevation="1dp"/>
android:alpha="0.8"
android:elevation="1dp" />
</RelativeLayout>

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<ProgressBar
<ProgressBar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/progressBar"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
@ -10,4 +9,4 @@
android:layout_alignParentBottom="true"
android:elevation="1dp"
app:layout_constraintBottom_toBottomOf="parent"
tools:showIn="@layout/activity_swap_pin"/>
tools:showIn="@layout/activity_swap_pin" />

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/tools">
<color name="colorPrimary">#027AFF</color>
<color name="colorPrimary">#027aff</color>
<color name="colorPrimaryDark">#027AFF</color>
<color name="colorAccent">#027AFF</color>

View file

@ -45,7 +45,7 @@
<string name="scan_again_to_verify_the_card">Scan again to verify the card</string>
<string name="smart_cash_ag">Smart Cash AG</string>
<string name="wallet">Wallet</string>
<string name="need_attach_card_again">Need attach card again</string>
<string name="need_attach_card_again">Scan again to verify the card</string>
<string name="reading">READING…</string>
<string name="verifying">VERIFYING…</string>