@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { // must be for someone else... if(requestCode != LOCATION_PERMISSION_REQUEST) return; if(permissions.length == 0 || !permissions[0].equals(Manifest.permission.ACCESS_FINE_LOCATION)) return; if(grantResults[0] == PackageManager.PERMISSION_GRANTED) { requestLocationPermissions(); // retry then... } else { new AlertDialog.Builder(getContext()) .setMessage(R.string.no_location_permission_warning) .setPositiveButton(R.string.retry, (dialog, which) -> requestLocationPermissions()) .setNegativeButton(android.R.string.cancel, (dialog, which) -> deniedLocationPermissions()) .setOnCancelListener(dialog -> deniedLocationPermissions()) .show(); } }
private void requestLocationSettingsToBeOn() { if(LocationUtil.isLocationOn(getContext())) { state = LocationState.ENABLED; nextStep(); } else { final AlertDialog dlg = new AlertDialog.Builder(getContext()) .setMessage(R.string.turn_on_location_request) .setPositiveButton(android.R.string.yes, (dialog, which) -> { dialog.dismiss(); Intent viewIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivityForResult(viewIntent, LOCATION_TURN_ON_REQUEST); }) .setNegativeButton(android.R.string.no, (dialog, which) -> cancelTurnLocationOnDialog()) .setOnCancelListener(dialog -> cancelTurnLocationOnDialog()) .create(); // the user may turn on location in the pull-down-overlay, without actually going into // settings dialog registerForLocationProviderChanges(dlg); dlg.show(); } }
finish(); }) .setOnCancelListener(d -> finish()) .setOnDismissListener(d -> finish()) .create();
builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) {
ModelHelper.setTemporaryTrustAllCertificatesAccessGrant( account, false)) .setOnCancelListener(dialogInterface -> ModelHelper.setTemporaryTrustAllCertificatesAccessGrant( account, false))
public AlertDialog createDownloadApprovalDialog(Context context, ActivityDialogHandler handler) { String title; if (getFileSize() > 0) title = context.getString(R.string.dcc_approve_download_title_with_size, getUnescapedFileName(), FormatUtils.formatByteSize(getFileSize())); else title = context.getString(R.string.dcc_approve_download_title, getUnescapedFileName()); AlertDialog ret = new AlertDialog.Builder(context) .setTitle(title) .setMessage(context.getString(R.string.dcc_approve_download_body, mSender.toString(), getServerName())) .setPositiveButton(R.string.action_accept, (DialogInterface dialog, int which) -> { if (needsAskSystemDownloadsPermission()) handler.askSystemDownloadsPermission(() -> approve()); else approve(); }) .setNegativeButton(R.string.action_reject, (DialogInterface dialog, int which) -> reject()) .setOnCancelListener((DialogInterface dialog) -> reject()) .create(); ret.setCanceledOnTouchOutside(false); return ret; }
private void showDCCWarning(CheckBoxSetting setting) { new AlertDialog.Builder(getContext()) .setTitle(R.string.dcc_enable_send_warning_title) .setMessage(R.string.dcc_enable_send_warning_body) .setPositiveButton(R.string.dcc_approve_download_enable_anyway, null) .setNegativeButton(R.string.action_cancel, (DialogInterface di, int w) -> { setting.setChecked(false); }) .setOnCancelListener((DialogInterface di) -> { setting.setChecked(false); }) .show(); }
@Override public Builder setOnCancelListener(OnCancelListener onCancelListener) { super.setOnCancelListener(onCancelListener); return this; }