Search in sources :

Example 86 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AppDialogFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Bundle args = getArguments();
    final String label = args.getString(ARG_LABEL);
    boolean managing = args.getBoolean(ARG_MANAGING);
    boolean connected = args.getBoolean(ARG_CONNECTED);
    mPackageInfo = args.getParcelable(ARG_PACKAGE);
    if (managing) {
        return new AppDialog(getActivity(), this, mPackageInfo, label);
    } else {
        // Build an AlertDialog with an option to disconnect.
        AlertDialog.Builder dlog = new AlertDialog.Builder(getActivity()).setTitle(label).setMessage(getActivity().getString(R.string.vpn_disconnect_confirm)).setNegativeButton(getActivity().getString(R.string.vpn_cancel), null);
        if (connected && !isUiRestricted()) {
            dlog.setPositiveButton(getActivity().getString(R.string.vpn_disconnect), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    onDisconnect(dialog);
                }
            });
        }
        return dlog.create();
    }
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) DialogInterface(android.content.DialogInterface) Bundle(android.os.Bundle)

Example 87 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project zype-android by zype.

the class DialogHelper method showSubscriptionAlertIssue.

public static void showSubscriptionAlertIssue(final Context context) {
    final AlertDialog.Builder alertDialog = new AlertDialog.Builder(context);
    alertDialog.setTitle(context.getString(R.string.dialog_subscribe_title));
    alertDialog.setMessage(context.getString(R.string.dialog_subscribe_message));
    alertDialog.setPositiveButton(context.getString(R.string.dialog_button_ok), new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            String url = SettingsProvider.getInstance().getSubscribeUrl();
            if (!TextUtils.isEmpty(url)) {
                Intent i = new Intent(Intent.ACTION_VIEW);
                i.setData(Uri.parse(url));
                context.startActivity(i);
            }
            dialog.cancel();
        }
    });
    alertDialog.setNegativeButton(context.getString(R.string.dialog_button_cancel), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    AlertDialog alert = alertDialog.create();
    alert.show();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent)

Example 88 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project zype-android by zype.

the class DialogHelper method showEntitlementAlert.

public static void showEntitlementAlert(final Context context, String message) {
    final AlertDialog.Builder alertDialog = new AlertDialog.Builder(context);
    alertDialog.setTitle(context.getString(R.string.entitlement_dialog_error_title));
    alertDialog.setMessage(message);
    alertDialog.setPositiveButton(context.getString(R.string.dialog_button_ok), new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    AlertDialog alert = alertDialog.create();
    alert.show();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) DialogInterface(android.content.DialogInterface)

Example 89 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project zype-android by zype.

the class DialogHelper method showLoginAlert.

public static void showLoginAlert(final Activity activity) {
    final AlertDialog.Builder alertDialog = new AlertDialog.Builder(activity);
    alertDialog.setTitle(activity.getString(R.string.dialog_login_title));
    alertDialog.setMessage(activity.getString(R.string.dialog_login_message));
    alertDialog.setPositiveButton(activity.getString(R.string.dialog_login_button_login), new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            NavigationHelper.getInstance(activity).switchToLoginScreen(activity);
            dialog.dismiss();
        }
    });
    alertDialog.setNegativeButton(activity.getString(R.string.dialog_button_cancel), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    AlertDialog alert = alertDialog.create();
    alert.show();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) DialogInterface(android.content.DialogInterface)

Example 90 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project easypermissions by googlesamples.

the class AppSettingsDialogTest method shouldNegativeListener_whenClickingPositiveButtonFromActivity.

@Test
public void shouldNegativeListener_whenClickingPositiveButtonFromActivity() {
    AlertDialog alertDialog = new AppSettingsDialog.Builder(spyActivity).setTitle(TITLE).setRationale(RATIONALE).setPositiveButton(POSITIVE).setNegativeButton(NEGATIVE).setThemeResId(R.style.Theme_AppCompat).build().showDialog(positiveListener, negativeListener);
    Button positive = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
    positive.performClick();
    verify(negativeListener, times(1)).onClick(any(DialogInterface.class), anyInt());
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Button(android.widget.Button) DialogInterface(android.content.DialogInterface) Test(org.junit.Test)

Aggregations

AlertDialog (androidx.appcompat.app.AlertDialog)256 Test (org.junit.Test)89 View (android.view.View)48 DialogInterface (android.content.DialogInterface)40 Button (android.widget.Button)39 TextView (android.widget.TextView)39 Intent (android.content.Intent)30 ShadowAlertDialogCompat (com.android.settings.testutils.shadow.ShadowAlertDialogCompat)30 NonNull (androidx.annotation.NonNull)27 Context (android.content.Context)26 Bundle (android.os.Bundle)20 SuppressLint (android.annotation.SuppressLint)17 EditText (android.widget.EditText)17 ArrayList (java.util.ArrayList)17 MaterialAlertDialogBuilder (com.google.android.material.dialog.MaterialAlertDialogBuilder)14 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