Updated on 2026-08-14
This commit is contained in:
parent
4e42025453
commit
df4a8d6dc3
6 changed files with 40 additions and 7 deletions
|
|
@ -97,6 +97,8 @@ public class TangemCard {
|
|||
}
|
||||
|
||||
public void setBlockchainID(String blockchainID) {
|
||||
|
||||
|
||||
this.blockchainID = blockchainID;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,6 +113,17 @@ public class TokenEngine extends CoinEngine {
|
|||
return output;
|
||||
}
|
||||
|
||||
public BigDecimal GetBalanceAlterValueBigDecimal(TangemCard mCard) {
|
||||
String dec = mCard.getDecimalBalanceAlter();
|
||||
BigDecimal d = convertToEth(dec);
|
||||
// String s = d.toString();
|
||||
|
||||
// String pattern = "#0.000"; // If you like 4 zeros
|
||||
// DecimalFormat myFormatter = new DecimalFormat(pattern);
|
||||
// String output = myFormatter.format(d);
|
||||
return d;
|
||||
}
|
||||
|
||||
public String GetBalanceValue(TangemCard mCard) {
|
||||
if (!HasBalanceInfo(mCard))
|
||||
return "-- -- -- " + GetBalanceCurrency(mCard);
|
||||
|
|
@ -129,10 +140,21 @@ public class TokenEngine extends CoinEngine {
|
|||
return output;
|
||||
}
|
||||
|
||||
public BigDecimal GetBalanceValueBigDecimal(TangemCard mCard) {
|
||||
|
||||
String dec = mCard.getDecimalBalance();
|
||||
BigDecimal d = new BigDecimal(dec);
|
||||
BigDecimal p = new BigDecimal(10);
|
||||
p = p.pow(GetTokenDecimals(mCard));
|
||||
BigDecimal l = d.divide(p);
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
public boolean CheckAmount(TangemCard card, String amount) throws Exception {
|
||||
DecimalFormat decimalFormat = GetDecimalFormat();
|
||||
BigDecimal amountValue = (BigDecimal) decimalFormat.parse(amount); //new BigDecimal(strAmount);
|
||||
BigDecimal maxValue = new BigDecimal(GetBalanceValue(card));
|
||||
BigDecimal maxValue = GetBalanceValueBigDecimal(card);
|
||||
if (amountValue.compareTo(maxValue) > 0) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -270,7 +292,7 @@ public class TokenEngine extends CoinEngine {
|
|||
Long fee = null;
|
||||
BigDecimal amount = null;
|
||||
try {
|
||||
amount = new BigDecimal(GetBalanceAlterValue(mCard));//mCard.InternalUnitsFromString(amountValue);
|
||||
amount = GetBalanceAlterValueBigDecimal(mCard);//mCard.InternalUnitsFromString(amountValue);
|
||||
fee = mCard.InternalUnitsFromString(feeValue);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
|||
|
|
@ -450,6 +450,7 @@ public class ConfirmPaymentActivity extends AppCompatActivity implements NfcAdap
|
|||
btnSend.setVisibility(View.INVISIBLE);
|
||||
feeRequestSuccess = false;
|
||||
balanceRequestSuccess = false;
|
||||
|
||||
btnSend.setOnClickListener(v -> {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.MINUTE, -1);
|
||||
|
|
|
|||
|
|
@ -26,15 +26,15 @@ import com.tangem.util.FormatUtil;
|
|||
import com.tangem.wallet.R;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PreparePaymentActivity extends AppCompatActivity implements NfcAdapter.ReaderCallback {
|
||||
public static final String TAG = PreparePaymentActivity.class.getSimpleName();
|
||||
|
||||
private static final int REQUEST_CODE_SCAN_QR = 1;
|
||||
private static final int REQUEST_CODE_SEND_PAYMENT = 2;
|
||||
private EditText etWallet;
|
||||
private EditText etAmount;
|
||||
// private TextView tvAmountEquivalent;
|
||||
// private TextView tvAmountEquivalent;
|
||||
boolean use_mCurrency;
|
||||
private TangemCard mCard;
|
||||
private NfcManager mNfcManager;
|
||||
|
|
@ -138,8 +138,11 @@ public class PreparePaymentActivity extends AppCompatActivity implements NfcAdap
|
|||
String strAmount;
|
||||
strAmount = etAmount.getText().toString();
|
||||
CoinEngine engine1 = CoinEngineFactory.Create(mCard.getBlockchain());
|
||||
|
||||
Log.i(TAG, mCard.getBlockchain().getOfficialName());
|
||||
|
||||
try {
|
||||
if (!Objects.requireNonNull(engine1).CheckAmount(mCard, etAmount.getText().toString())) {
|
||||
if (!engine.CheckAmount(mCard, etAmount.getText().toString())) {
|
||||
etAmount.setError(getString(R.string.not_enough_funds_on_your_card));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
|
|
@ -171,7 +171,12 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
BigInteger l = new BigInteger(balanceCap, 16);
|
||||
Long balance = l.longValue();
|
||||
|
||||
// Log.i(TAG, " dvddvdv BigInteger.ZERO");
|
||||
|
||||
if (l.compareTo(BigInteger.ZERO) == 0) {
|
||||
|
||||
// Log.i(TAG, "BigInteger.ZERO");
|
||||
|
||||
mCard.setBlockchainID(Blockchain.Ethereum.getID());
|
||||
mCard.addTokenToBlockchainName();
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
|
|
@ -667,7 +672,6 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
Toast.makeText(getContext(), R.string.please_wait_while_previous, Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
|
||||
|
||||
} else if (!engine.CheckUnspentTransaction(mCard)) {
|
||||
Toast.makeText(getContext(), R.string.please_wait_for_confirmation, Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ public class FormatUtil {
|
|||
symbols.setDecimalSeparator('.');
|
||||
|
||||
String pattern = "#0.######";
|
||||
DecimalFormat myFormatter = new DecimalFormat(pattern, symbols);
|
||||
// DecimalFormat myFormatter = new DecimalFormat(pattern, symbols);
|
||||
DecimalFormat myFormatter = new DecimalFormat(pattern);
|
||||
|
||||
myFormatter.setParseBigDecimal(true);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue