Fix sendAll bug

This commit is contained in:
pokkst 2022-09-07 20:00:14 -05:00
parent 569e1e5f5b
commit 6674f894b7
No known key found for this signature in database
GPG key ID: 90C2ED85E67A50FF

View file

@ -56,21 +56,22 @@ public class SendBottomSheetDialog extends BottomSheetDialogFragment {
});
sendButton.setOnClickListener(view1 -> {
boolean sendAll = sendingMax.getValue() != null ? sendingMax.getValue() : false;
String address = addressEditText.getText().toString().trim();
String amount = amountEditText.getText().toString().trim();
boolean validAddress = Wallet.isAddressValid(address);
if (validAddress && !amount.isEmpty()) {
if (validAddress && (!amount.isEmpty() || sendAll)) {
long amountRaw = Wallet.getAmountFromString(amount);
long balance = BalanceService.getInstance().getUnlockedBalanceRaw();
if(amountRaw >= balance || amountRaw <= 0) {
if((amountRaw >= balance || amountRaw <= 0) && !sendAll) {
Toast.makeText(getActivity(), getString(R.string.send_amount_invalid), Toast.LENGTH_SHORT).show();
return;
}
sendButton.setEnabled(false);
boolean sendAll = sendingMax.getValue() != null ? sendingMax.getValue() : false;
TxService.getInstance().sendTx(address, amount, sendAll);
} else if (!validAddress) {
Toast.makeText(getActivity(), getString(R.string.send_address_invalid), Toast.LENGTH_SHORT).show();
} else if (amount.isEmpty()) {
} else {
Toast.makeText(getActivity(), getString(R.string.send_amount_empty), Toast.LENGTH_SHORT).show();
}
});