Search in sources :

Example 31 with AlertDialog

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();
    }
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) ActivityNotFoundException(android.content.ActivityNotFoundException) Intent(android.content.Intent) Uri(android.net.Uri) XmppUri(eu.siacs.conversations.utils.XmppUri)

Example 32 with AlertDialog

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();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog)

Example 33 with AlertDialog

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();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) IOException(java.io.IOException) ProgressBar(android.widget.ProgressBar) View(android.view.View)

Example 34 with AlertDialog

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);
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) ShakeDetector(org.signal.core.util.ShakeDetector) SignalStore(org.thoughtcrime.securesms.keyvalue.SignalStore) AlertDialog(androidx.appcompat.app.AlertDialog) SubmitDebugLogRepository(org.thoughtcrime.securesms.logsubmit.SubmitDebugLogRepository) NonNull(androidx.annotation.NonNull) SimpleProgressDialog(org.thoughtcrime.securesms.util.views.SimpleProgressDialog) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) ApplicationDependencies(org.thoughtcrime.securesms.dependencies.ApplicationDependencies) ThreadUtil(org.signal.core.util.ThreadUtil) R(org.thoughtcrime.securesms.R) Tracer(org.signal.core.util.tracing.Tracer) Log(org.signal.core.util.logging.Log) FeatureFlags(org.thoughtcrime.securesms.util.FeatureFlags) TextView(android.widget.TextView) Application(android.app.Application) ShareIntents(org.thoughtcrime.securesms.sharing.ShareIntents) Toast(android.widget.Toast) WeakReference(java.lang.ref.WeakReference) Activity(android.app.Activity) ServiceUtil(org.thoughtcrime.securesms.util.ServiceUtil) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) TextView(android.widget.TextView) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder)

Example 35 with AlertDialog

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();
            }
        });
    });
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) SubmitDebugLogRepository(org.thoughtcrime.securesms.logsubmit.SubmitDebugLogRepository)

Aggregations

AlertDialog (androidx.appcompat.app.AlertDialog)261 Test (org.junit.Test)89 View (android.view.View)49 DialogInterface (android.content.DialogInterface)42 TextView (android.widget.TextView)40 Button (android.widget.Button)39 Intent (android.content.Intent)30 ShadowAlertDialogCompat (com.android.settings.testutils.shadow.ShadowAlertDialogCompat)30 NonNull (androidx.annotation.NonNull)28 Context (android.content.Context)26 Bundle (android.os.Bundle)20 EditText (android.widget.EditText)18 MaterialAlertDialogBuilder (com.google.android.material.dialog.MaterialAlertDialogBuilder)18 SuppressLint (android.annotation.SuppressLint)17 ArrayList (java.util.ArrayList)17 List (java.util.List)12 Activity (android.app.Activity)11 Uri (android.net.Uri)11 LayoutInflater (android.view.LayoutInflater)11 ListView (android.widget.ListView)10