use of androidx.appcompat.app.AlertDialog in project Conversations by siacs.
the class ConversationsActivity method openBatteryOptimizationDialogIfNeeded.
private void openBatteryOptimizationDialogIfNeeded() {
if (hasAccountWithoutPush() && isOptimizingBattery() && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M && getPreferences().getBoolean(getBatteryOptimizationPreferenceKey(), true)) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.battery_optimizations_enabled);
builder.setMessage(getString(R.string.battery_optimizations_enabled_dialog, getString(R.string.app_name)));
builder.setPositiveButton(R.string.next, (dialog, which) -> {
Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
Uri uri = Uri.parse("package:" + getPackageName());
intent.setData(uri);
try {
startActivityForResult(intent, REQUEST_BATTERY_OP);
} catch (ActivityNotFoundException e) {
Toast.makeText(this, R.string.device_does_not_support_battery_op, Toast.LENGTH_SHORT).show();
}
});
builder.setOnDismissListener(dialog -> setNeverAskForBatteryOptimizationsAgain());
final AlertDialog dialog = builder.create();
dialog.setCanceledOnTouchOutside(false);
dialog.show();
}
}
use of androidx.appcompat.app.AlertDialog in project quickstart-android by firebase.
the class MainActivity method showMessageDialog.
private void showMessageDialog(String title, String message) {
AlertDialog ad = new AlertDialog.Builder(this).setTitle(title).setMessage(message).create();
ad.show();
}
use of androidx.appcompat.app.AlertDialog in project Signal-Android by WhisperSystems.
the class RegistrationLockV2Dialog method showEnableDialog.
public static void showEnableDialog(@NonNull Context context, @NonNull Runnable onSuccess) {
AlertDialog dialog = new AlertDialog.Builder(context).setTitle(R.string.RegistrationLockV2Dialog_turn_on_registration_lock).setView(R.layout.registration_lock_v2_dialog).setMessage(R.string.RegistrationLockV2Dialog_if_you_forget_your_signal_pin_when_registering_again).setNegativeButton(android.R.string.cancel, null).setPositiveButton(R.string.RegistrationLockV2Dialog_turn_on, null).create();
dialog.setOnShowListener(d -> {
ProgressBar progress = Objects.requireNonNull(dialog.findViewById(R.id.reglockv2_dialog_progress));
View positiveButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
positiveButton.setOnClickListener(v -> {
progress.setIndeterminate(true);
progress.setVisibility(View.VISIBLE);
SimpleTask.run(SignalExecutors.UNBOUNDED, () -> {
try {
PinState.onEnableRegistrationLockForUserWithPin();
Log.i(TAG, "Successfully enabled registration lock.");
return true;
} catch (IOException e) {
Log.w(TAG, "Failed to enable registration lock setting.", e);
return false;
}
}, (success) -> {
progress.setVisibility(View.GONE);
if (!success) {
Toast.makeText(context, R.string.preferences_app_protection__failed_to_enable_registration_lock, Toast.LENGTH_LONG).show();
} else {
onSuccess.run();
}
dialog.dismiss();
});
});
});
dialog.show();
}
use of androidx.appcompat.app.AlertDialog 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 androidx.appcompat.app.AlertDialog in project Signal-Android by WhisperSystems.
the class ShakeToReport method submitLog.
private void submitLog(@NonNull Activity activity) {
AlertDialog spinner = SimpleProgressDialog.show(activity);
SubmitDebugLogRepository repo = new SubmitDebugLogRepository();
Log.i(TAG, "Submitting log...");
repo.buildAndSubmitLog(url -> {
Log.i(TAG, "Logs uploaded!");
ThreadUtil.runOnMain(() -> {
spinner.dismiss();
if (url.isPresent()) {
showPostSubmitDialog(activity, url.get());
} else {
Toast.makeText(activity, R.string.ShakeToReport_failed_to_submit, Toast.LENGTH_SHORT).show();
enableIfVisible();
}
});
});
}
Aggregations