use of com.samourai.wallet.widgets.SendTransactionDetailsView in project samourai-wallet-android by Samourai-Wallet.
the class SendActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_send);
setSupportActionBar(findViewById(R.id.toolbar_send));
Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
setTitle("");
// CustomView for showing and hiding body of th UI
sendTransactionDetailsView = findViewById(R.id.sendTransactionDetailsView);
// ViewSwitcher Element for toolbar section of the UI.
// we can switch between Form and review screen with this element
amountViewSwitcher = findViewById(R.id.toolbar_view_switcher);
// Input elements from toolbar section of the UI
toAddressEditText = findViewById(R.id.edt_send_to);
btcEditText = findViewById(R.id.amountBTC);
satEditText = findViewById(R.id.amountSat);
tvToAddress = findViewById(R.id.to_address_review);
tvReviewSpendAmount = findViewById(R.id.send_review_amount);
tvReviewSpendAmountInSats = findViewById(R.id.send_review_amount_in_sats);
tvMaxAmount = findViewById(R.id.totalBTC);
// view elements from review segment and transaction segment can be access through respective
// methods which returns root viewGroup
btnReview = sendTransactionDetailsView.getTransactionView().findViewById(R.id.review_button);
cahootsSwitch = sendTransactionDetailsView.getTransactionView().findViewById(R.id.cahoots_switch);
ricochetHopsSwitch = sendTransactionDetailsView.getTransactionView().findViewById(R.id.ricochet_hops_switch);
ricochetTitle = sendTransactionDetailsView.getTransactionView().findViewById(R.id.ricochet_desc);
ricochetDesc = sendTransactionDetailsView.getTransactionView().findViewById(R.id.ricochet_title);
ricochetStaggeredDelivery = sendTransactionDetailsView.getTransactionView().findViewById(R.id.ricochet_staggered_option);
ricochetStaggeredOptionGroup = sendTransactionDetailsView.getTransactionView().findViewById(R.id.ricochet_staggered_option_group);
tvSelectedFeeRate = sendTransactionDetailsView.getTransactionReview().findViewById(R.id.selected_fee_rate);
tvSelectedFeeRateLayman = sendTransactionDetailsView.getTransactionReview().findViewById(R.id.selected_fee_rate_in_layman);
tvTotalFee = sendTransactionDetailsView.getTransactionReview().findViewById(R.id.total_fee);
btnSend = sendTransactionDetailsView.getTransactionReview().findViewById(R.id.send_btn);
feeSeekBar = sendTransactionDetailsView.getTransactionReview().findViewById(R.id.fee_seekbar);
tvEstimatedBlockWait = sendTransactionDetailsView.getTransactionReview().findViewById(R.id.est_block_time);
feeSeekBar = sendTransactionDetailsView.getTransactionReview().findViewById(R.id.fee_seekbar);
cahootsGroup = sendTransactionDetailsView.findViewById(R.id.cohoots_options);
cahootsStatusText = sendTransactionDetailsView.findViewById(R.id.cahoot_status_text);
totalMinerFeeLayout = sendTransactionDetailsView.getTransactionReview().findViewById(R.id.total_miner_fee_group);
cahootsNotice = sendTransactionDetailsView.findViewById(R.id.cahoots_not_enabled_notice);
btcEditText.addTextChangedListener(BTCWatcher);
btcEditText.setFilters(new InputFilter[] { new DecimalDigitsInputFilter(8, 8) });
satEditText.addTextChangedListener(satWatcher);
toAddressEditText.addTextChangedListener(AddressWatcher);
btnReview.setOnClickListener(v -> review());
btnSend.setOnClickListener(v -> initiateSpend());
View.OnClickListener clipboardCopy = view -> {
ClipboardManager cm = (ClipboardManager) this.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clipData = android.content.ClipData.newPlainText("Miner fee", tvTotalFee.getText());
if (cm != null) {
cm.setPrimaryClip(clipData);
Toast.makeText(this, getString(R.string.copied_to_clipboard), Toast.LENGTH_SHORT).show();
}
};
tvTotalFee.setOnClickListener(clipboardCopy);
tvSelectedFeeRate.setOnClickListener(clipboardCopy);
SPEND_TYPE = SPEND_BOLTZMANN;
saveChangeIndexes();
setUpRicochet();
setUpCahoots();
setUpFee();
setBalance();
enableReviewButton(false);
setUpBoltzman();
validateSpend();
checkDeepLinks();
if (getIntent().getExtras().containsKey("preselected")) {
preselectedUTXOs = PreSelectUtil.getInstance().getPreSelected(getIntent().getExtras().getString("preselected"));
setBalance();
if (preselectedUTXOs != null && preselectedUTXOs.size() > 0) {
cahootsGroup.setVisibility(View.GONE);
ricochetHopsSwitch.setVisibility(View.GONE);
ricochetTitle.setVisibility(View.GONE);
ricochetDesc.setVisibility(View.GONE);
}
} else {
Disposable disposable = APIFactory.getInstance(getApplicationContext()).walletBalanceObserver.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(aLong -> {
if (balance == aLong) {
return;
}
setBalance();
}, Throwable::printStackTrace);
compositeDisposables.add(disposable);
// Update fee
Disposable feeDisposable = Observable.fromCallable(() -> APIFactory.getInstance(getApplicationContext()).getDynamicFees()).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).subscribe(t -> {
Log.i(TAG, "Fees : ".concat(t.toString()));
setUpFee();
}, Throwable::printStackTrace);
compositeDisposables.add(feeDisposable);
if (getIntent().getExtras() != null) {
if (!getIntent().getExtras().containsKey("balance")) {
return;
}
balance = getIntent().getExtras().getLong("balance");
}
}
}
Aggregations