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;
}
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;
}
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;
}
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();
}
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();
}
}
Aggregations