use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project Signal-Android by signalapp.
the class MediaActions method handleDeleteMedia.
static void handleDeleteMedia(@NonNull Context context, @NonNull Collection<MediaDatabase.MediaRecord> mediaRecords) {
int recordCount = mediaRecords.size();
Resources res = context.getResources();
String confirmTitle = res.getQuantityString(R.plurals.MediaOverviewActivity_Media_delete_confirm_title, recordCount, recordCount);
String confirmMessage = res.getQuantityString(R.plurals.MediaOverviewActivity_Media_delete_confirm_message, recordCount, recordCount);
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context).setTitle(confirmTitle).setMessage(confirmMessage).setCancelable(true);
builder.setPositiveButton(R.string.delete, (dialogInterface, i) -> new ProgressDialogAsyncTask<MediaDatabase.MediaRecord, Void, Void>(context, R.string.MediaOverviewActivity_Media_delete_progress_title, R.string.MediaOverviewActivity_Media_delete_progress_message) {
@Override
protected Void doInBackground(MediaDatabase.MediaRecord... records) {
if (records == null || records.length == 0) {
return null;
}
for (MediaDatabase.MediaRecord record : records) {
AttachmentUtil.deleteAttachment(context, record.getAttachment());
}
return null;
}
}.execute(mediaRecords.toArray(new MediaDatabase.MediaRecord[0])));
builder.setNegativeButton(android.R.string.cancel, null);
builder.show();
}
use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project Signal-Android by signalapp.
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 signalapp.
the class BaseEnterSmsCodeFragment method handleRateLimited.
protected void handleRateLimited() {
keyboard.displayFailure().addListener(new AssertedSuccessListener<Boolean>() {
@Override
public void onSuccess(Boolean r) {
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireContext());
builder.setTitle(R.string.RegistrationActivity_too_many_attempts).setMessage(R.string.RegistrationActivity_you_have_made_too_many_attempts_please_try_again_later).setPositiveButton(android.R.string.ok, (dialog, which) -> {
callMeCountDown.setVisibility(View.VISIBLE);
wrongNumber.setVisibility(View.VISIBLE);
verificationCodeView.clear();
keyboard.displayKeyboard();
}).show();
}
});
}
use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project Signal-Android by signalapp.
the class ImageEditorFragment method onCancel.
@Override
public void onCancel() {
if (hasMadeAnEditThisSession) {
new MaterialAlertDialogBuilder(requireContext()).setTitle(R.string.MediaReviewImagePageFragment__discard_changes).setMessage(R.string.MediaReviewImagePageFragment__youll_lose_any_changes).setPositiveButton(R.string.MediaReviewImagePageFragment__discard, (d, w) -> {
d.dismiss();
imageEditorHud.setMode(ImageEditorHudV2.Mode.NONE);
controller.onCancelEditing();
}).setNegativeButton(android.R.string.cancel, (d, w) -> d.dismiss()).show();
} else {
imageEditorHud.setMode(ImageEditorHudV2.Mode.NONE);
controller.onCancelEditing();
}
}
use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project Signal-Android by signalapp.
the class BadDecryptLearnMoreDialog method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
MaterialAlertDialogBuilder dialogBuilder = new MaterialAlertDialogBuilder(requireContext());
View view = LayoutInflater.from(requireContext()).inflate(R.layout.bad_decrypt_learn_more_dialog_fragment, null);
TextView body = view.findViewById(R.id.bad_decrypt_dialog_body);
String displayName = requireArguments().getString(KEY_DISPLAY_NAME);
boolean isGroup = requireArguments().getBoolean(KEY_GROUP_CHAT);
if (isGroup) {
body.setText(getString(R.string.BadDecryptLearnMoreDialog_couldnt_be_delivered_group, displayName));
} else {
body.setText(getString(R.string.BadDecryptLearnMoreDialog_couldnt_be_delivered_individual, displayName));
}
dialogBuilder.setView(view).setPositiveButton(android.R.string.ok, null);
return dialogBuilder.create();
}
Aggregations