use of androidx.appcompat.app.AlertDialog in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RegulatoryInfoDisplayActivity method onCreate.
/**
* Display the regulatory info graphic in a dialog window.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Resources resources = getResources();
if (!resources.getBoolean(R.bool.config_show_regulatory_info)) {
// no regulatory info to display for this device
finish();
}
AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle(R.string.regulatory_labels).setOnDismissListener(this);
boolean regulatoryInfoDrawableExists = false;
final String regulatoryInfoFile = getRegulatoryInfoImageFileName();
final Bitmap regulatoryInfoBitmap = BitmapFactory.decodeFile(regulatoryInfoFile);
if (regulatoryInfoBitmap != null) {
regulatoryInfoDrawableExists = true;
}
int resId = 0;
if (!regulatoryInfoDrawableExists) {
resId = getResourceId();
}
if (resId != 0) {
try {
Drawable d = getDrawable(resId);
// set to false if the width or height is <= 2
// (missing PNG can return an empty 2x2 pixel Drawable)
regulatoryInfoDrawableExists = (d.getIntrinsicWidth() > 2 && d.getIntrinsicHeight() > 2);
} catch (Resources.NotFoundException ignored) {
regulatoryInfoDrawableExists = false;
}
}
CharSequence regulatoryText = resources.getText(R.string.regulatory_info_text);
if (regulatoryInfoDrawableExists) {
View view = getLayoutInflater().inflate(R.layout.regulatory_info, null);
ImageView image = view.findViewById(R.id.regulatoryInfo);
if (regulatoryInfoBitmap != null) {
image.setImageBitmap(regulatoryInfoBitmap);
} else {
image.setImageResource(resId);
}
builder.setView(view);
builder.show();
} else if (regulatoryText.length() > 0) {
builder.setMessage(regulatoryText);
AlertDialog dialog = builder.show();
// we have to show the dialog first, or the setGravity() call will throw a NPE
TextView messageText = (TextView) dialog.findViewById(android.R.id.message);
messageText.setGravity(Gravity.CENTER);
} else {
// neither drawable nor text resource exists, finish activity
finish();
}
}
use of androidx.appcompat.app.AlertDialog in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BluetoothPairingDialogFragment method createConfirmationDialog.
/**
* Creates a dialog with UI elements that allow the user to confirm a pairing request.
*/
private AlertDialog createConfirmationDialog() {
mBuilder.setTitle(getString(R.string.bluetooth_pairing_request, mPairingController.getDeviceName()));
mBuilder.setView(createView());
mBuilder.setPositiveButton(getString(R.string.bluetooth_pairing_accept), this);
mBuilder.setNegativeButton(getString(R.string.bluetooth_pairing_decline), this);
AlertDialog dialog = mBuilder.create();
return dialog;
}
use of androidx.appcompat.app.AlertDialog in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BluetoothPairingDialogFragment method createDisplayPasskeyOrPinDialog.
/**
* Creates a dialog that informs users of a pairing request and shows them the passkey/pin
* of the device.
*/
private AlertDialog createDisplayPasskeyOrPinDialog() {
mBuilder.setTitle(getString(R.string.bluetooth_pairing_request, mPairingController.getDeviceName()));
mBuilder.setView(createView());
mBuilder.setNegativeButton(getString(android.R.string.cancel), this);
AlertDialog dialog = mBuilder.create();
// Tell the controller the dialog has been created.
mPairingController.notifyDialogDisplayed();
return dialog;
}
use of androidx.appcompat.app.AlertDialog in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BluetoothPairingDialogFragment method createUserEntryDialog.
/**
* Returns a dialog with UI elements that allow a user to provide input.
*/
private AlertDialog createUserEntryDialog() {
mBuilder.setTitle(getString(R.string.bluetooth_pairing_request, mPairingController.getDeviceName()));
mBuilder.setView(createPinEntryView());
mBuilder.setPositiveButton(getString(android.R.string.ok), this);
mBuilder.setNegativeButton(getString(android.R.string.cancel), this);
AlertDialog dialog = mBuilder.create();
dialog.setOnShowListener(d -> {
if (TextUtils.isEmpty(getPairingViewText())) {
mDialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(false);
}
if (mPairingView != null && mPairingView.requestFocus()) {
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.showSoftInput(mPairingView, InputMethodManager.SHOW_IMPLICIT);
}
}
});
return dialog;
}
use of androidx.appcompat.app.AlertDialog in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ZenDeleteRuleDialog method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Bundle arguments = getArguments();
String ruleName = arguments.getString(EXTRA_ZEN_RULE_NAME);
String id = arguments.getString(EXTRA_ZEN_RULE_ID);
final AlertDialog dialog = new AlertDialog.Builder(getContext()).setMessage(getString(R.string.zen_mode_delete_rule_confirmation, ruleName)).setNegativeButton(R.string.cancel, null).setPositiveButton(R.string.zen_mode_delete_rule_button, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (arguments != null) {
mPositiveClickListener.onOk(id);
}
}
}).create();
final View messageView = dialog.findViewById(android.R.id.message);
if (messageView != null) {
messageView.setTextDirection(View.TEXT_DIRECTION_LOCALE);
}
return dialog;
}
Aggregations