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();
}
}
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();
}
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();
}
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();
}
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());
}
Aggregations