use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project WordPress-Login-Flow-Android by wordpress-mobile.
the class LoginHttpAuthDialogFragment method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder alert = new MaterialAlertDialogBuilder(getActivity());
alert.setTitle(R.string.http_authorization_required);
if (!TextUtils.isEmpty(mMessage))
alert.setMessage(mMessage);
// noinspection InflateParams
View httpAuth = getActivity().getLayoutInflater().inflate(R.layout.login_alert_http_auth, null);
alert.setView(httpAuth);
final EditText usernameEditText = (EditText) httpAuth.findViewById(R.id.login_http_username);
final EditText passwordEditText = (EditText) httpAuth.findViewById(R.id.login_http_password);
passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
String username = EditTextUtils.getText(usernameEditText);
String password = EditTextUtils.getText(passwordEditText);
sendResult(username, password);
dismiss();
return true;
}
});
alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dismiss();
}
});
alert.setPositiveButton(R.string.next, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String username = EditTextUtils.getText(usernameEditText);
String password = EditTextUtils.getText(passwordEditText);
sendResult(username, password);
}
});
final AlertDialog alertDialog = alert.create();
// update the Next button when username edit box changes
usernameEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
updateButton(alertDialog, usernameEditText);
}
});
// update the Next button on first appearance
alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
updateButton(alertDialog, usernameEditText);
}
});
return alertDialog;
}
use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project WordPress-Login-Flow-Android by wordpress-mobile.
the class LoginEmailFragment method showErrorDialog.
private void showErrorDialog(String message) {
AlertDialog dialog = new MaterialAlertDialogBuilder(getActivity()).setMessage(message).setPositiveButton(R.string.login_error_button, null).create();
dialog.show();
}
use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project Signal-Android by WhisperSystems.
the class BaseRegistrationLockFragment method onViewCreated.
@Override
@CallSuper
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
setDebugLogSubmitMultiTapView(view.findViewById(R.id.kbs_lock_pin_title));
pinEntry = view.findViewById(R.id.kbs_lock_pin_input);
pinButton = view.findViewById(R.id.kbs_lock_pin_confirm);
errorLabel = view.findViewById(R.id.kbs_lock_pin_input_label);
keyboardToggle = view.findViewById(R.id.kbs_lock_keyboard_toggle);
forgotPin = view.findViewById(R.id.kbs_lock_forgot_pin);
RegistrationLockFragmentArgs args = RegistrationLockFragmentArgs.fromBundle(requireArguments());
timeRemaining = args.getTimeRemaining();
forgotPin.setVisibility(View.GONE);
forgotPin.setOnClickListener(v -> handleForgottenPin(timeRemaining));
pinEntry.setImeOptions(EditorInfo.IME_ACTION_DONE);
pinEntry.setOnEditorActionListener((v, actionId, event) -> {
if (actionId == EditorInfo.IME_ACTION_DONE) {
ViewUtil.hideKeyboard(requireContext(), v);
handlePinEntry();
return true;
}
return false;
});
enableAndFocusPinEntry();
pinButton.setOnClickListener((v) -> {
ViewUtil.hideKeyboard(requireContext(), pinEntry);
handlePinEntry();
});
keyboardToggle.setOnClickListener((v) -> {
PinKeyboardType keyboardType = getPinEntryKeyboardType();
updateKeyboard(keyboardType.getOther());
keyboardToggle.setText(resolveKeyboardToggleText(keyboardType));
});
PinKeyboardType keyboardType = getPinEntryKeyboardType().getOther();
keyboardToggle.setText(resolveKeyboardToggleText(keyboardType));
disposables.bindTo(getViewLifecycleOwner().getLifecycle());
viewModel = getViewModel();
viewModel.getLockedTimeRemaining().observe(getViewLifecycleOwner(), t -> timeRemaining = t);
TokenData keyBackupCurrentToken = viewModel.getKeyBackupCurrentToken();
if (keyBackupCurrentToken != null) {
int triesRemaining = keyBackupCurrentToken.getTriesRemaining();
if (triesRemaining <= 3) {
int daysRemaining = getLockoutDays(timeRemaining);
new MaterialAlertDialogBuilder(requireContext()).setTitle(R.string.RegistrationLockFragment__not_many_tries_left).setMessage(getTriesRemainingDialogMessage(triesRemaining, daysRemaining)).setPositiveButton(android.R.string.ok, null).setNeutralButton(R.string.PinRestoreEntryFragment_contact_support, (dialog, which) -> sendEmailToSupport()).show();
}
if (triesRemaining < 5) {
errorLabel.setText(requireContext().getResources().getQuantityString(R.plurals.RegistrationLockFragment__d_attempts_remaining, triesRemaining, triesRemaining));
}
}
}
use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project Signal-Android by WhisperSystems.
the class ShakeToReport method showPostSubmitDialog.
private void showPostSubmitDialog(@NonNull Activity activity, @NonNull String url) {
AlertDialog dialog = new MaterialAlertDialogBuilder(activity).setTitle(R.string.ShakeToReport_success).setMessage(url).setNegativeButton(android.R.string.cancel, (d, i) -> {
d.dismiss();
enableIfVisible();
}).setPositiveButton(R.string.ShakeToReport_share, (d, i) -> {
d.dismiss();
enableIfVisible();
activity.startActivity(new ShareIntents.Builder(activity).setText(url).build());
}).show();
((TextView) dialog.findViewById(android.R.id.message)).setTextIsSelectable(true);
}
use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project Signal-Android by WhisperSystems.
the class BlockUnblockDialog method buildBlockFor.
@WorkerThread
private static AlertDialog.Builder buildBlockFor(@NonNull Context context, @NonNull Recipient recipient, @NonNull Runnable onBlock, @Nullable Runnable onBlockAndReportSpam) {
recipient = recipient.resolve();
AlertDialog.Builder builder = new MaterialAlertDialogBuilder(context);
Resources resources = context.getResources();
if (recipient.isGroup()) {
if (SignalDatabase.groups().isActive(recipient.requireGroupId())) {
builder.setTitle(resources.getString(R.string.BlockUnblockDialog_block_and_leave_s, recipient.getDisplayName(context)));
builder.setMessage(R.string.BlockUnblockDialog_you_will_no_longer_receive_messages_or_updates);
builder.setPositiveButton(R.string.BlockUnblockDialog_block_and_leave, ((dialog, which) -> onBlock.run()));
builder.setNegativeButton(android.R.string.cancel, null);
} else {
builder.setTitle(resources.getString(R.string.BlockUnblockDialog_block_s, recipient.getDisplayName(context)));
builder.setMessage(R.string.BlockUnblockDialog_group_members_wont_be_able_to_add_you);
builder.setPositiveButton(R.string.RecipientPreferenceActivity_block, ((dialog, which) -> onBlock.run()));
builder.setNegativeButton(android.R.string.cancel, null);
}
} else if (recipient.isReleaseNotes()) {
builder.setTitle(resources.getString(R.string.BlockUnblockDialog_block_s, recipient.getDisplayName(context)));
builder.setMessage(R.string.BlockUnblockDialog_block_getting_signal_updates_and_news);
builder.setPositiveButton(R.string.BlockUnblockDialog_block, ((dialog, which) -> onBlock.run()));
builder.setNegativeButton(android.R.string.cancel, null);
} else {
builder.setTitle(resources.getString(R.string.BlockUnblockDialog_block_s, recipient.getDisplayName(context)));
builder.setMessage(R.string.BlockUnblockDialog_blocked_people_wont_be_able_to_call_you_or_send_you_messages);
if (onBlockAndReportSpam != null) {
builder.setNeutralButton(android.R.string.cancel, null);
builder.setNegativeButton(R.string.BlockUnblockDialog_report_spam_and_block, (d, w) -> onBlockAndReportSpam.run());
builder.setPositiveButton(R.string.BlockUnblockDialog_block, (d, w) -> onBlock.run());
} else {
builder.setPositiveButton(R.string.BlockUnblockDialog_block, ((dialog, which) -> onBlock.run()));
builder.setNegativeButton(android.R.string.cancel, null);
}
}
return builder;
}
Aggregations