use of androidx.appcompat.app.AlertDialog in project Signal-Android by WhisperSystems.
the class DeviceProvisioningActivity method onCreate.
@Override
protected void onCreate(Bundle bundle, boolean ready) {
AlertDialog dialog = new AlertDialog.Builder(this).setTitle(getString(R.string.DeviceProvisioningActivity_link_a_signal_device)).setMessage(getString(R.string.DeviceProvisioningActivity_it_looks_like_youre_trying_to_link_a_signal_device_using_a_3rd_party_scanner)).setPositiveButton(R.string.DeviceProvisioningActivity_continue, (dialog1, which) -> {
Intent intent = new Intent(DeviceProvisioningActivity.this, DeviceActivity.class);
intent.putExtra("add", true);
startActivity(intent);
finish();
}).setNegativeButton(android.R.string.cancel, (dialog12, which) -> {
dialog12.dismiss();
finish();
}).setOnDismissListener(dialog13 -> finish()).create();
dialog.setIcon(getResources().getDrawable(R.drawable.icon_dialog));
dialog.show();
}
use of androidx.appcompat.app.AlertDialog in project Signal-Android by WhisperSystems.
the class SimpleProgressDialog method showDelayed.
/**
* Shows the dialog after {@param delayMs} ms.
* <p>
* To dismiss, call {@link DismissibleDialog#dismiss()} on the result. If dismiss is called before
* the delay has elapsed, the dialog will not show at all.
* <p>
* Dismiss can be called on any thread.
*
* @param minimumShowTimeMs If the dialog does display, then it will be visible for at least this duration.
* This is to prevent flicker.
*/
@AnyThread
@NonNull
public static DismissibleDialog showDelayed(@NonNull Context context, int delayMs, int minimumShowTimeMs) {
AtomicReference<AlertDialog> dialogAtomicReference = new AtomicReference<>();
AtomicLong shownAt = new AtomicLong();
Runnable showRunnable = () -> {
Log.i(TAG, "Taking some time. Showing a progress dialog.");
shownAt.set(System.currentTimeMillis());
dialogAtomicReference.set(show(context));
};
ThreadUtil.runOnMainDelayed(showRunnable, delayMs);
return new DismissibleDialog() {
@Override
public void dismiss() {
ThreadUtil.cancelRunnableOnMain(showRunnable);
ThreadUtil.runOnMain(() -> {
AlertDialog alertDialog = dialogAtomicReference.getAndSet(null);
if (alertDialog != null) {
long beenShowingForMs = System.currentTimeMillis() - shownAt.get();
long remainingTimeMs = minimumShowTimeMs - beenShowingForMs;
if (remainingTimeMs > 0) {
ThreadUtil.runOnMainDelayed(alertDialog::dismiss, remainingTimeMs);
} else {
alertDialog.dismiss();
}
}
});
}
@Override
public void dismissNow() {
ThreadUtil.cancelRunnableOnMain(showRunnable);
ThreadUtil.runOnMain(() -> {
AlertDialog alertDialog = dialogAtomicReference.getAndSet(null);
if (alertDialog != null) {
alertDialog.dismiss();
}
});
}
};
}
use of androidx.appcompat.app.AlertDialog in project Signal-Android by WhisperSystems.
the class SimpleProgressDialog method show.
@MainThread
@NonNull
public static AlertDialog show(@NonNull Context context) {
AlertDialog dialog = new AlertDialog.Builder(context).setView(R.layout.progress_dialog).setCancelable(false).create();
dialog.show();
dialog.getWindow().setLayout(context.getResources().getDimensionPixelSize(R.dimen.progress_dialog_size), context.getResources().getDimensionPixelSize(R.dimen.progress_dialog_size));
return dialog;
}
use of androidx.appcompat.app.AlertDialog in project Signal-Android by WhisperSystems.
the class EnableCallNotificationSettingsDialog method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
MaterialAlertDialogBuilder dialogBuilder = new MaterialAlertDialogBuilder(requireContext(), R.style.Signal_ThemeOverlay_Dialog_Rounded);
Runnable action = null;
switch(getCallNotificationSettingsBitmask(requireContext())) {
case NOTIFICATIONS_DISABLED:
dialogBuilder.setTitle(R.string.EnableCallNotificationSettingsDialog__enable_call_notifications).setMessage(R.string.EnableCallNotificationSettingsDialog__to_receive_call_notifications_tap_settings_and_turn_on_show_notifications).setPositiveButton(R.string.EnableCallNotificationSettingsDialog__settings, null);
action = this::showNotificationSettings;
break;
case CALL_CHANNEL_INVALID:
dialogBuilder.setTitle(R.string.EnableCallNotificationSettingsDialog__enable_call_notifications).setMessage(R.string.EnableCallNotificationSettingsDialog__to_receive_call_notifications_tap_settings_and_turn_on_notifications).setPositiveButton(R.string.EnableCallNotificationSettingsDialog__settings, null);
action = this::showNotificationChannelSettings;
break;
case BACKGROUND_RESTRICTED:
dialogBuilder.setTitle(R.string.EnableCallNotificationSettingsDialog__enable_background_activity).setMessage(R.string.EnableCallNotificationSettingsDialog__to_receive_call_notifications_tap_settings_and_enable_background_activity_in_battery_settings).setPositiveButton(R.string.EnableCallNotificationSettingsDialog__settings, null);
action = this::showAppSettings;
break;
default:
dialogBuilder.setTitle(R.string.EnableCallNotificationSettingsDialog__enable_call_notifications).setView(createView()).setPositiveButton(android.R.string.ok, null);
break;
}
dialogBuilder.setNegativeButton(android.R.string.cancel, null);
AlertDialog dialog = dialogBuilder.create();
if (action != null) {
final Runnable localAction = action;
dialog.setOnShowListener(d -> dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(v -> localAction.run()));
}
return dialog;
}
use of androidx.appcompat.app.AlertDialog in project Signal-Android by WhisperSystems.
the class WallpaperCropActivity method setWallpaper.
private void setWallpaper() {
EditorModel model = imageEditor.getModel();
Point size = new Point(imageEditor.getWidth(), imageEditor.getHeight());
AlertDialog dialog = SimpleProgressDialog.show(this);
viewModel.render(this, model, size, new AsynchronousCallback.MainThread<ChatWallpaper, WallpaperCropViewModel.Error>() {
@Override
public void onComplete(@Nullable ChatWallpaper result) {
dialog.dismiss();
setResult(RESULT_OK, new Intent().putExtra(ChatWallpaperPreviewActivity.EXTRA_CHAT_WALLPAPER, result));
finish();
}
@Override
public void onError(@Nullable WallpaperCropViewModel.Error error) {
dialog.dismiss();
Toast.makeText(WallpaperCropActivity.this, R.string.WallpaperCropActivity__error_setting_wallpaper, Toast.LENGTH_SHORT).show();
}
}.toWorkerCallback());
}
Aggregations