use of androidx.appcompat.app.AlertDialog in project xabber-android by redsolution.
the class FileInteractionFragment method onAttachButtonPressed.
protected void onAttachButtonPressed() {
if (!HttpFileUploadManager.getInstance().isFileUploadSupported(account)) {
// show notification
String serverName = account.getFullJid().getDomain().toString();
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(getActivity().getResources().getString(R.string.error_file_upload_not_support, serverName)).setTitle(getString(R.string.error_sending_file, "")).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
return;
}
if (PermissionsRequester.requestFileReadPermissionIfNeeded(this, PERMISSIONS_REQUEST_ATTACH_FILE)) {
((ChatActivity) getActivity()).showAttachDialog();
}
}
use of androidx.appcompat.app.AlertDialog in project Signal-Android by WhisperSystems.
the class ImageEditorFragment method onBlurFacesToggled.
@Override
public void onBlurFacesToggled(boolean enabled) {
EditorModel model = imageEditorView.getModel();
EditorElement mainImage = model.getMainImage();
if (mainImage == null) {
imageEditorHud.hideBlurToast();
return;
}
if (!enabled) {
model.clearFaceRenderers();
imageEditorHud.hideBlurToast();
return;
}
Matrix inverseCropPosition = model.getInverseCropPosition();
if (cachedFaceDetection != null) {
if (cachedFaceDetection.first().equals(getUri()) && cachedFaceDetection.second().position.equals(inverseCropPosition)) {
renderFaceBlurs(cachedFaceDetection.second());
imageEditorHud.showBlurToast();
return;
} else {
cachedFaceDetection = null;
}
}
AlertDialog progress = SimpleProgressDialog.show(requireContext());
mainImage.getFlags().setChildrenVisible(false);
SimpleTask.run(getLifecycle(), () -> {
if (mainImage.getRenderer() != null) {
Bitmap bitmap = ((UriGlideRenderer) mainImage.getRenderer()).getBitmap();
if (bitmap != null) {
FaceDetector detector = new AndroidFaceDetector();
Point size = model.getOutputSizeMaxWidth(1000);
Bitmap render = model.render(ApplicationDependencies.getApplication(), size);
try {
return new FaceDetectionResult(detector.detect(render), new Point(render.getWidth(), render.getHeight()), inverseCropPosition);
} finally {
render.recycle();
mainImage.getFlags().reset();
}
}
}
return new FaceDetectionResult(Collections.emptyList(), new Point(0, 0), new Matrix());
}, result -> {
mainImage.getFlags().reset();
renderFaceBlurs(result);
progress.dismiss();
imageEditorHud.showBlurToast();
});
}
use of androidx.appcompat.app.AlertDialog in project Signal-Android by WhisperSystems.
the class GroupMembersDialog method display.
public void display() {
AlertDialog dialog = new AlertDialog.Builder(fragmentActivity).setTitle(R.string.ConversationActivity_group_members).setIcon(R.drawable.ic_group_24).setCancelable(true).setView(R.layout.dialog_group_members).setPositiveButton(android.R.string.ok, null).show();
GroupMemberListView memberListView = dialog.findViewById(R.id.list_members);
memberListView.initializeAdapter(fragmentActivity);
LiveGroup liveGroup = new LiveGroup(groupRecipient.requireGroupId());
LiveData<List<GroupMemberEntry.FullMember>> fullMembers = liveGroup.getFullMembers();
// noinspection ConstantConditions
fullMembers.observe(fragmentActivity, memberListView::setMembers);
dialog.setOnDismissListener(d -> fullMembers.removeObservers(fragmentActivity));
memberListView.setRecipientClickListener(recipient -> {
dialog.dismiss();
contactClick(recipient);
});
}
use of androidx.appcompat.app.AlertDialog in project Signal-Android by WhisperSystems.
the class NewConversationActivity method onBeforeContactSelected.
@Override
public void onBeforeContactSelected(Optional<RecipientId> recipientId, String number, Consumer<Boolean> callback) {
if (recipientId.isPresent()) {
launch(Recipient.resolved(recipientId.get()));
} else {
Log.i(TAG, "[onContactSelected] Maybe creating a new recipient.");
if (SignalStore.account().isRegistered() && NetworkConstraint.isMet(getApplication())) {
Log.i(TAG, "[onContactSelected] Doing contact refresh.");
AlertDialog progress = SimpleProgressDialog.show(this);
SimpleTask.run(getLifecycle(), () -> {
Recipient resolved = Recipient.external(this, number);
if (!resolved.isRegistered() || !resolved.hasServiceId()) {
Log.i(TAG, "[onContactSelected] Not registered or no UUID. Doing a directory refresh.");
try {
DirectoryHelper.refreshDirectoryFor(this, resolved, false);
resolved = Recipient.resolved(resolved.getId());
} catch (IOException e) {
Log.w(TAG, "[onContactSelected] Failed to refresh directory for new contact.");
}
}
return resolved;
}, resolved -> {
progress.dismiss();
launch(resolved);
});
} else {
launch(Recipient.external(this, number));
}
}
callback.accept(true);
}
use of androidx.appcompat.app.AlertDialog in project Signal-Android by WhisperSystems.
the class BackupDialog method showEnableBackupDialog.
public static void showEnableBackupDialog(@NonNull Context context, @Nullable Intent backupDirectorySelectionIntent, @Nullable String backupDirectoryDisplayName, @NonNull Runnable onBackupsEnabled) {
String[] password = BackupUtil.generateBackupPassphrase();
AlertDialog dialog = new AlertDialog.Builder(context).setTitle(R.string.BackupDialog_enable_local_backups).setView(backupDirectorySelectionIntent != null ? R.layout.backup_enable_dialog_v29 : R.layout.backup_enable_dialog).setPositiveButton(R.string.BackupDialog_enable_backups, null).setNegativeButton(android.R.string.cancel, null).create();
dialog.setOnShowListener(created -> {
if (backupDirectoryDisplayName != null) {
TextView folderName = dialog.findViewById(R.id.backup_enable_dialog_folder_name);
if (folderName != null) {
folderName.setText(backupDirectoryDisplayName);
}
}
Button button = ((AlertDialog) created).getButton(AlertDialog.BUTTON_POSITIVE);
button.setOnClickListener(v -> {
CheckBox confirmationCheckBox = dialog.findViewById(R.id.confirmation_check);
if (confirmationCheckBox.isChecked()) {
if (backupDirectorySelectionIntent != null && backupDirectorySelectionIntent.getData() != null) {
Uri backupDirectoryUri = backupDirectorySelectionIntent.getData();
int takeFlags = Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION;
SignalStore.settings().setSignalBackupDirectory(backupDirectoryUri);
context.getContentResolver().takePersistableUriPermission(backupDirectoryUri, takeFlags);
}
BackupPassphrase.set(context, Util.join(password, " "));
TextSecurePreferences.setNextBackupTime(context, 0);
SignalStore.settings().setBackupEnabled(true);
LocalBackupListener.schedule(context);
onBackupsEnabled.run();
created.dismiss();
} else {
Toast.makeText(context, R.string.BackupDialog_please_acknowledge_your_understanding_by_marking_the_confirmation_check_box, Toast.LENGTH_LONG).show();
}
});
});
dialog.show();
CheckBox checkBox = dialog.findViewById(R.id.confirmation_check);
TextView textView = dialog.findViewById(R.id.confirmation_text);
((TextView) dialog.findViewById(R.id.code_first)).setText(password[0]);
((TextView) dialog.findViewById(R.id.code_second)).setText(password[1]);
((TextView) dialog.findViewById(R.id.code_third)).setText(password[2]);
((TextView) dialog.findViewById(R.id.code_fourth)).setText(password[3]);
((TextView) dialog.findViewById(R.id.code_fifth)).setText(password[4]);
((TextView) dialog.findViewById(R.id.code_sixth)).setText(password[5]);
textView.setOnClickListener(v -> checkBox.toggle());
dialog.findViewById(R.id.number_table).setOnClickListener(v -> {
((ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("text", Util.join(password, " ")));
Toast.makeText(context, R.string.BackupDialog_copied_to_clipboard, Toast.LENGTH_LONG).show();
});
}
Aggregations