Search in sources :

Example 1 with SelectCahootsType

use of com.samourai.wallet.send.cahoots.SelectCahootsType in project samourai-wallet-android by Samourai-Wallet.

the class SendActivity method setUpCahoots.

private void setUpCahoots() {
    if (account == WhirlpoolMeta.getInstance(getApplicationContext()).getWhirlpoolPostmix()) {
        cahootsNotice.setVisibility(View.VISIBLE);
    }
    cahootsSwitch.setOnCheckedChangeListener((compoundButton, b) -> {
        // to check whether bottomsheet is closed or selected a value
        final boolean[] chosen = { false };
        if (b) {
            SelectCahootsType cahootsType = new SelectCahootsType();
            cahootsType.show(getSupportFragmentManager(), cahootsType.getTag());
            cahootsType.setOnSelectListener(new SelectCahootsType.OnSelectListener() {

                @Override
                public void onSelect(SelectCahootsType.type type) {
                    chosen[0] = true;
                    selectedCahootsType = type;
                    switch(selectedCahootsType) {
                        case NONE:
                            {
                                cahootsStatusText.setText("Off");
                                cahootsStatusText.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.warning_yellow));
                                break;
                            }
                        case STOWAWAY:
                            {
                                cahootsStatusText.setText("Stowaway");
                                cahootsStatusText.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.green_ui_2));
                                toAddressEditText.setText("Stowaway Collaborator");
                                toAddressEditText.setEnabled(false);
                                address = "";
                                break;
                            }
                        case STONEWALLX2_MANUAL:
                            {
                                cahootsStatusText.setText("StonewallX2 Manual");
                                cahootsStatusText.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.green_ui_2));
                                break;
                            }
                        case STONEWALLX2_SAMOURAI:
                            {
                                cahootsStatusText.setText("Stonewallx2 Samourai");
                                cahootsStatusText.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.green_ui_2));
                                break;
                            }
                    }
                    validateSpend();
                }

                @Override
                public void onDismiss() {
                    if (!chosen[0]) {
                        compoundButton.setChecked(false);
                        selectedCahootsType = SelectCahootsType.type.NONE;
                        hideToAddressForStowaway();
                    }
                    validateSpend();
                }
            });
        } else {
            selectedCahootsType = SelectCahootsType.type.NONE;
            cahootsStatusText.setText("Off");
            cahootsStatusText.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.warning_yellow));
            hideToAddressForStowaway();
            validateSpend();
            enableReviewButton(false);
        }
    });
}
Also used : SelectCahootsType(com.samourai.wallet.send.cahoots.SelectCahootsType)

Aggregations

SelectCahootsType (com.samourai.wallet.send.cahoots.SelectCahootsType)1