Search in sources :

Example 61 with AlertDialog

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);
    }
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Button(android.widget.Button)

Example 62 with AlertDialog

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);
    }
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) View(android.view.View) TextView(android.widget.TextView) PreferenceImageView(androidx.preference.internal.PreferenceImageView)

Example 63 with AlertDialog

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;
}
Also used : Context(android.content.Context) AlertDialog(androidx.appcompat.app.AlertDialog) Context(android.content.Context) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) ERROR_DIALOG_TYPE(com.android.settings.wifi.NetworkRequestErrorDialogFragment.ERROR_DIALOG_TYPE) ProgressBar(android.widget.ProgressBar) NonNull(androidx.annotation.NonNull) WifiTrackerFactory(com.android.settingslib.wifi.WifiTrackerFactory) Dialog(android.app.Dialog) Intent(android.content.Intent) Drawable(android.graphics.drawable.Drawable) ArrayList(java.util.ArrayList) NetworkRequestUserSelectionCallback(android.net.wifi.WifiManager.NetworkRequestUserSelectionCallback) Handler(android.os.Handler) Toast(android.widget.Toast) View(android.view.View) Button(android.widget.Button) InstrumentedDialogFragment(com.android.settings.core.instrumentation.InstrumentedDialogFragment) AccessPoint(com.android.settingslib.wifi.AccessPoint) DialogInterface(android.content.DialogInterface) WifiConfiguration(android.net.wifi.WifiConfiguration) R(com.android.settings.R) ScanResult(android.net.wifi.ScanResult) LayoutInflater(android.view.LayoutInflater) Utils(com.android.settingslib.Utils) NetworkRequestMatchCallback(android.net.wifi.WifiManager.NetworkRequestMatchCallback) SettingsEnums(android.app.settings.SettingsEnums) TextUtils(android.text.TextUtils) ViewGroup(android.view.ViewGroup) WifiManager(android.net.wifi.WifiManager) ArrayAdapter(android.widget.ArrayAdapter) List(java.util.List) TextView(android.widget.TextView) Message(android.os.Message) BaseAdapter(android.widget.BaseAdapter) WifiTracker(com.android.settingslib.wifi.WifiTracker) PreferenceImageView(androidx.preference.internal.PreferenceImageView) Activity(android.app.Activity) VisibleForTesting(androidx.annotation.VisibleForTesting) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) Button(android.widget.Button) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) Intent(android.content.Intent) View(android.view.View) TextView(android.widget.TextView) PreferenceImageView(androidx.preference.internal.PreferenceImageView) ProgressBar(android.widget.ProgressBar)

Example 64 with AlertDialog

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));
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) ShadowAlertDialogCompat(com.android.settings.testutils.shadow.ShadowAlertDialogCompat) Test(org.junit.Test)

Example 65 with AlertDialog

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));
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) ShadowAlertDialogCompat(com.android.settings.testutils.shadow.ShadowAlertDialogCompat) 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