Search in sources :

Example 66 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project android_frameworks_base by AOSPA.

the class CreateDirectoryFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Context context = getActivity();
    final ContentResolver resolver = context.getContentResolver();
    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    final LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
    final View view = dialogInflater.inflate(R.layout.dialog_file_name, null, false);
    final EditText editText = (EditText) view.findViewById(android.R.id.text1);
    builder.setTitle(R.string.menu_create_dir);
    builder.setView(view);
    builder.setPositiveButton(android.R.string.ok, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            createDirectory(editText.getText().toString());
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);
    final AlertDialog dialog = builder.create();
    // Workaround for the problem - virtual keyboard doesn't show on the phone.
    Shared.ensureKeyboardPresent(context, dialog);
    editText.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView view, int actionId, @Nullable KeyEvent event) {
            if ((actionId == EditorInfo.IME_ACTION_DONE) || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.hasNoModifiers())) {
                createDirectory(editText.getText().toString());
                dialog.dismiss();
                return true;
            }
            return false;
        }
    });
    return dialog;
}
Also used : Context(android.content.Context) AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText) DialogInterface(android.content.DialogInterface) View(android.view.View) TextView(android.widget.TextView) ContentResolver(android.content.ContentResolver) KeyEvent(android.view.KeyEvent) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.content.DialogInterface.OnClickListener) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) TextView(android.widget.TextView)

Example 67 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project bitcoin-wallet by bitcoin-wallet.

the class RestoreWalletDialogFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final View view = LayoutInflater.from(activity).inflate(R.layout.restore_wallet_dialog, null);
    messageView = (TextView) view.findViewById(R.id.restore_wallet_dialog_message);
    fileView = (Spinner) view.findViewById(R.id.import_keys_from_storage_file);
    passwordView = (EditText) view.findViewById(R.id.import_keys_from_storage_password);
    showView = (CheckBox) view.findViewById(R.id.import_keys_from_storage_show);
    replaceWarningView = view.findViewById(R.id.restore_wallet_from_storage_dialog_replace_warning);
    final DialogBuilder builder = new DialogBuilder(activity);
    builder.setTitle(R.string.import_keys_dialog_title);
    builder.setView(view);
    builder.setPositiveButton(R.string.import_keys_dialog_button_import, new OnClickListener() {

        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            final File file = (File) fileView.getSelectedItem();
            final String password = passwordView.getText().toString().trim();
            // get rid of it asap
            passwordView.setText(null);
            if (WalletUtils.BACKUP_FILE_FILTER.accept(file))
                restoreWalletFromProtobuf(file);
            else if (WalletUtils.KEYS_FILE_FILTER.accept(file))
                restorePrivateKeysFromBase58(file);
            else if (Crypto.OPENSSL_FILE_FILTER.accept(file))
                restoreWalletFromEncrypted(file, password);
        }
    });
    builder.setNegativeButton(R.string.button_cancel, new OnClickListener() {

        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            // get rid of it asap
            passwordView.setText(null);
        }
    });
    builder.setOnCancelListener(new OnCancelListener() {

        @Override
        public void onCancel(final DialogInterface dialog) {
            // get rid of it asap
            passwordView.setText(null);
        }
    });
    fileView.setAdapter(new FileAdapter(activity) {

        @Override
        public View getDropDownView(final int position, View row, final ViewGroup parent) {
            final File file = getItem(position);
            final boolean isExternal = Constants.Files.EXTERNAL_WALLET_BACKUP_DIR.equals(file.getParentFile());
            final boolean isEncrypted = Crypto.OPENSSL_FILE_FILTER.accept(file);
            if (row == null)
                row = inflater.inflate(R.layout.restore_wallet_file_row, null);
            final TextView filenameView = (TextView) row.findViewById(R.id.wallet_import_keys_file_row_filename);
            filenameView.setText(file.getName());
            final TextView securityView = (TextView) row.findViewById(R.id.wallet_import_keys_file_row_security);
            final String encryptedStr = context.getString(isEncrypted ? R.string.import_keys_dialog_file_security_encrypted : R.string.import_keys_dialog_file_security_unencrypted);
            final String storageStr = context.getString(isExternal ? R.string.import_keys_dialog_file_security_external : R.string.import_keys_dialog_file_security_internal);
            securityView.setText(encryptedStr + ", " + storageStr);
            final TextView createdView = (TextView) row.findViewById(R.id.wallet_import_keys_file_row_created);
            createdView.setText(context.getString(isExternal ? R.string.import_keys_dialog_file_created_manual : R.string.import_keys_dialog_file_created_automatic, DateUtils.getRelativeTimeSpanString(context, file.lastModified(), true)));
            return row;
        }
    });
    final AlertDialog dialog = builder.create();
    dialog.setOnShowListener(new OnShowListener() {

        @Override
        public void onShow(final DialogInterface d) {
            final ImportDialogButtonEnablerListener dialogButtonEnabler = new ImportDialogButtonEnablerListener(passwordView, dialog) {

                @Override
                protected boolean hasFile() {
                    return fileView.getSelectedItem() != null;
                }

                @Override
                protected boolean needsPassword() {
                    final File selectedFile = (File) fileView.getSelectedItem();
                    return selectedFile != null ? Crypto.OPENSSL_FILE_FILTER.accept(selectedFile) : false;
                }
            };
            passwordView.addTextChangedListener(dialogButtonEnabler);
            fileView.setOnItemSelectedListener(dialogButtonEnabler);
            RestoreWalletDialogFragment.this.dialog = dialog;
            updateView();
        }
    });
    return dialog;
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) ViewGroup(android.view.ViewGroup) View(android.view.View) TextView(android.widget.TextView) OnShowListener(android.content.DialogInterface.OnShowListener) OnClickListener(android.content.DialogInterface.OnClickListener) TextView(android.widget.TextView) DialogBuilder(de.schildbach.wallet.ui.DialogBuilder) File(java.io.File) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Example 68 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project bitcoin-wallet by bitcoin-wallet.

the class RestoreWalletFromExternalDialogFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final View view = LayoutInflater.from(activity).inflate(R.layout.restore_wallet_from_external_dialog, null);
    passwordView = (EditText) view.findViewById(R.id.import_keys_from_content_dialog_password);
    showView = (CheckBox) view.findViewById(R.id.import_keys_from_content_dialog_show);
    replaceWarningView = view.findViewById(R.id.restore_wallet_from_content_dialog_replace_warning);
    final DialogBuilder builder = new DialogBuilder(activity);
    builder.setTitle(R.string.import_keys_dialog_title);
    builder.setView(view);
    builder.setPositiveButton(R.string.import_keys_dialog_button_import, new OnClickListener() {

        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            final String password = passwordView.getText().toString().trim();
            // get rid of it asap
            passwordView.setText(null);
            handleRestore(password);
        }
    });
    builder.setNegativeButton(R.string.button_cancel, new OnClickListener() {

        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            // get rid of it asap
            passwordView.setText(null);
            activity.finish();
        }
    });
    builder.setOnCancelListener(new OnCancelListener() {

        @Override
        public void onCancel(final DialogInterface dialog) {
            // get rid of it asap
            passwordView.setText(null);
            activity.finish();
        }
    });
    final AlertDialog dialog = builder.create();
    dialog.setOnShowListener(new OnShowListener() {

        @Override
        public void onShow(final DialogInterface d) {
            final ImportDialogButtonEnablerListener dialogButtonEnabler = new ImportDialogButtonEnablerListener(passwordView, dialog) {

                @Override
                protected boolean hasFile() {
                    return true;
                }
            };
            passwordView.addTextChangedListener(dialogButtonEnabler);
            RestoreWalletFromExternalDialogFragment.this.dialog = dialog;
            updateView();
        }
    });
    return dialog;
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener) DialogBuilder(de.schildbach.wallet.ui.DialogBuilder) View(android.view.View) OnShowListener(android.content.DialogInterface.OnShowListener) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Example 69 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project bitcoin-wallet by bitcoin-wallet.

the class DiagnosticsFragment method handleInitiateReset.

private void handleInitiateReset() {
    final DialogBuilder dialog = new DialogBuilder(activity);
    dialog.setTitle(R.string.preferences_initiate_reset_title);
    dialog.setMessage(R.string.preferences_initiate_reset_dialog_message);
    dialog.setPositiveButton(R.string.preferences_initiate_reset_dialog_positive, new OnClickListener() {

        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            log.info("manually initiated blockchain reset");
            BlockchainService.resetBlockchain(activity);
            // TODO doesn't fully finish prefs on single pane layouts
            activity.finish();
        }
    });
    dialog.setNegativeButton(R.string.button_dismiss, null);
    dialog.show();
}
Also used : DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener) DialogBuilder(de.schildbach.wallet.ui.DialogBuilder)

Example 70 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project bitcoin-wallet by bitcoin-wallet.

the class SendCoinsQrActivity method onActivityResult.

@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent intent) {
    if (requestCode == REQUEST_CODE_SCAN && resultCode == Activity.RESULT_OK) {
        final String input = intent.getStringExtra(ScanActivity.INTENT_EXTRA_RESULT);
        new StringInputParser(input) {

            @Override
            protected void handlePaymentIntent(final PaymentIntent paymentIntent) {
                SendCoinsActivity.start(SendCoinsQrActivity.this, paymentIntent);
                SendCoinsQrActivity.this.finish();
            }

            @Override
            protected void handlePrivateKey(final VersionedChecksummedBytes key) {
                if (Constants.ENABLE_SWEEP_WALLET) {
                    SweepWalletActivity.start(SendCoinsQrActivity.this, key);
                    SendCoinsQrActivity.this.finish();
                } else {
                    super.handlePrivateKey(key);
                }
            }

            @Override
            protected void handleDirectTransaction(final Transaction transaction) throws VerificationException {
                final WalletApplication application = (WalletApplication) getApplication();
                application.processDirectTransaction(transaction);
                SendCoinsQrActivity.this.finish();
            }

            @Override
            protected void error(final int messageResId, final Object... messageArgs) {
                dialog(SendCoinsQrActivity.this, dismissListener, 0, messageResId, messageArgs);
            }

            private final OnClickListener dismissListener = new OnClickListener() {

                @Override
                public void onClick(final DialogInterface dialog, final int which) {
                    SendCoinsQrActivity.this.finish();
                }
            };
        }.parse();
    } else {
        finish();
    }
}
Also used : VersionedChecksummedBytes(org.bitcoinj.core.VersionedChecksummedBytes) Transaction(org.bitcoinj.core.Transaction) DialogInterface(android.content.DialogInterface) WalletApplication(de.schildbach.wallet.WalletApplication) StringInputParser(de.schildbach.wallet.ui.InputParser.StringInputParser) VerificationException(org.bitcoinj.core.VerificationException) OnClickListener(android.content.DialogInterface.OnClickListener) PaymentIntent(de.schildbach.wallet.data.PaymentIntent)

Aggregations

OnClickListener (android.content.DialogInterface.OnClickListener)264 DialogInterface (android.content.DialogInterface)259 AlertDialog (android.app.AlertDialog)161 View (android.view.View)75 TextView (android.widget.TextView)52 Intent (android.content.Intent)44 SuppressLint (android.annotation.SuppressLint)41 Context (android.content.Context)35 AlertDialog (android.support.v7.app.AlertDialog)32 LayoutInflater (android.view.LayoutInflater)30 EditText (android.widget.EditText)30 Activity (android.app.Activity)27 Bundle (android.os.Bundle)25 OnCancelListener (android.content.DialogInterface.OnCancelListener)21 ImageView (android.widget.ImageView)17 Builder (android.app.AlertDialog.Builder)16 Dialog (android.app.Dialog)16 ProgressDialog (android.app.ProgressDialog)15 Paint (android.graphics.Paint)15 AdapterView (android.widget.AdapterView)15