Updated on 2026-08-14
This commit is contained in:
commit
28066a7206
18 changed files with 151 additions and 90 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue