use of androidx.appcompat.app.AlertDialog in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class NetworkRequestDialogFragment method showAllButton.
private void showAllButton() {
final AlertDialog alertDialog = (AlertDialog) getDialog();
if (alertDialog == null) {
return;
}
final Button neutralBtn = alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL);
if (neutralBtn != null) {
neutralBtn.setVisibility(View.VISIBLE);
}
}
use of androidx.appcompat.app.AlertDialog in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class NetworkRequestDialogFragment method hideProgressIcon.
private void hideProgressIcon() {
final AlertDialog alertDialog = (AlertDialog) getDialog();
if (alertDialog == null) {
return;
}
final View progress = alertDialog.findViewById(R.id.network_request_title_progress);
if (progress != null) {
progress.setVisibility(View.GONE);
}
}
use of androidx.appcompat.app.AlertDialog in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class NetworkRequestDialogFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Context context = getContext();
// Prepares title.
final LayoutInflater inflater = LayoutInflater.from(context);
final View customTitle = inflater.inflate(R.layout.network_request_dialog_title, null);
final TextView title = customTitle.findViewById(R.id.network_request_title_text);
title.setText(getTitle());
final Intent intent = getActivity().getIntent();
if (intent != null) {
mIsSpecifiedSsid = intent.getBooleanExtra(EXTRA_IS_SPECIFIED_SSID, false);
}
final ProgressBar progressBar = customTitle.findViewById(R.id.network_request_title_progress);
progressBar.setVisibility(View.VISIBLE);
// Prepares adapter.
mDialogAdapter = new AccessPointAdapter(context, R.layout.preference_access_point, getAccessPointList());
final AlertDialog.Builder builder = new AlertDialog.Builder(context).setCustomTitle(customTitle).setAdapter(mDialogAdapter, this).setNegativeButton(R.string.cancel, (dialog, which) -> onCancel(dialog)).setNeutralButton(R.string.network_connection_request_dialog_showall, null);
if (mIsSpecifiedSsid) {
builder.setPositiveButton(R.string.wifi_connect, null);
}
// Clicking list item is to connect wifi ap.
final AlertDialog dialog = builder.create();
dialog.getListView().setOnItemClickListener((parent, view, position, id) -> this.onClick(dialog, position));
// Don't dismiss dialog when touching outside. User reports it is easy to touch outside.
// This causes dialog to close.
setCancelable(false);
dialog.setOnShowListener((dialogInterface) -> {
// Replace NeutralButton onClickListener to avoid closing dialog
final Button neutralBtn = dialog.getButton(AlertDialog.BUTTON_NEUTRAL);
neutralBtn.setVisibility(View.GONE);
neutralBtn.setOnClickListener(v -> {
mShowLimitedItem = false;
renewAccessPointList(null);
notifyAdapterRefresh();
neutralBtn.setVisibility(View.GONE);
});
// Replace Positive onClickListener to avoid closing dialog
if (mIsSpecifiedSsid) {
final Button positiveBtn = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
positiveBtn.setOnClickListener(v -> {
// When clicking connect button, should connect to the first and the only one
// list item.
this.onClick(dialog, 0);
});
// Disable button in first, and enable it after there are some accesspoints in list.
positiveBtn.setEnabled(false);
}
});
return dialog;
}
use of androidx.appcompat.app.AlertDialog in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class InstantAppButtonDialogFragmentTest method onCreateDialog_clearAppDialog_shouldShowClearAppDataConfirmation.
@Test
public void onCreateDialog_clearAppDialog_shouldShowClearAppDataConfirmation() {
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(dialog).isNotNull();
final ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getMessage()).isEqualTo(mContext.getString(R.string.clear_instant_app_confirmation));
assertThat(shadowDialog.getTitle()).isEqualTo(mContext.getString(R.string.clear_instant_app_data));
assertThat(dialog.getButton(DialogInterface.BUTTON_POSITIVE).getText()).isEqualTo(mContext.getString(R.string.clear_instant_app_data));
assertThat(dialog.getButton(DialogInterface.BUTTON_NEGATIVE).getText()).isEqualTo(mContext.getString(R.string.cancel));
}
use of androidx.appcompat.app.AlertDialog in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ButtonActionDialogFragmentTest method testOnCreateDialog_forceStopDialog.
@Test
public void testOnCreateDialog_forceStopDialog() {
ButtonActionDialogFragment fragment = ButtonActionDialogFragment.newInstance(FORCE_STOP_ID);
FragmentController.setupFragment(fragment, FragmentActivity.class, 0, /* containerViewId */
null);
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
assertThat(dialog).isNotNull();
ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getMessage()).isEqualTo(mShadowContext.getString(R.string.force_stop_dlg_text));
assertThat(shadowDialog.getTitle()).isEqualTo(mShadowContext.getString(R.string.force_stop_dlg_title));
assertThat(dialog.getButton(DialogInterface.BUTTON_POSITIVE).getText()).isEqualTo(mShadowContext.getString(R.string.dlg_ok));
assertThat(dialog.getButton(DialogInterface.BUTTON_NEGATIVE).getText()).isEqualTo(mShadowContext.getString(R.string.dlg_cancel));
}
Aggregations