Search in sources :

Example 96 with AlertDialog

use of android.app.AlertDialog in project android_packages_apps_Settings by LineageOS.

the class ButtonActionDialogFragmentTest method testOnCreateDialog_specialDisableDialog.

@Test
public void testOnCreateDialog_specialDisableDialog() {
    ButtonActionDialogFragment fragment = ButtonActionDialogFragment.newInstance(SPECIAL_DISABLE_ID);
    FragmentTestUtil.startFragment(fragment);
    final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
    ShadowAlertDialog shadowDialog = shadowOf(dialog);
    assertThat(shadowDialog.getMessage()).isEqualTo(mShadowContext.getString(R.string.app_disable_dlg_text));
    assertThat(dialog.getButton(DialogInterface.BUTTON_POSITIVE).getText()).isEqualTo(mShadowContext.getString(R.string.app_disable_dlg_positive));
    assertThat(dialog.getButton(DialogInterface.BUTTON_NEGATIVE).getText()).isEqualTo(mShadowContext.getString(R.string.dlg_cancel));
}
Also used : AlertDialog(android.app.AlertDialog) ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) Test(org.junit.Test)

Example 97 with AlertDialog

use of android.app.AlertDialog in project android_packages_apps_Settings by LineageOS.

the class AnomalyDialogFragmentTest method testOnCreateDialog_wakelockAnomaly_fireForceStopDialog.

@Test
public void testOnCreateDialog_wakelockAnomaly_fireForceStopDialog() {
    mAnomalyDialogFragment = AnomalyDialogFragment.newInstance(mWakeLockAnomaly, 0);
    FragmentTestUtil.startFragment(mAnomalyDialogFragment);
    final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
    ShadowAlertDialog shadowDialog = shadowOf(dialog);
    assertThat(shadowDialog.getMessage()).isEqualTo(mContext.getString(R.string.dialog_stop_message, mWakeLockAnomaly.displayName));
    assertThat(shadowDialog.getTitle()).isEqualTo(mContext.getString(R.string.dialog_stop_title));
    assertThat(dialog.getButton(DialogInterface.BUTTON_POSITIVE).getText()).isEqualTo(mContext.getString(R.string.dialog_stop_ok));
    assertThat(dialog.getButton(DialogInterface.BUTTON_NEGATIVE).getText()).isEqualTo(mContext.getString(R.string.dlg_cancel));
}
Also used : ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) AlertDialog(android.app.AlertDialog) ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) Test(org.junit.Test)

Example 98 with AlertDialog

use of android.app.AlertDialog in project android_packages_apps_Settings by LineageOS.

the class AnomalyDialogFragmentTest method testOnCreateDialog_wakeupAlarmAnomalyTargetingO_fireForceStopDialog.

@Test
public void testOnCreateDialog_wakeupAlarmAnomalyTargetingO_fireForceStopDialog() {
    mAnomalyDialogFragment = AnomalyDialogFragment.newInstance(mWakeupAlarmAnomaly2, 0);
    FragmentTestUtil.startFragment(mAnomalyDialogFragment);
    final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
    ShadowAlertDialog shadowDialog = shadowOf(dialog);
    assertThat(shadowDialog.getMessage()).isEqualTo(mContext.getString(R.string.dialog_stop_message_wakeup_alarm, mWakeLockAnomaly.displayName));
    assertThat(shadowDialog.getTitle()).isEqualTo(mContext.getString(R.string.dialog_stop_title));
    assertThat(dialog.getButton(DialogInterface.BUTTON_POSITIVE).getText()).isEqualTo(mContext.getString(R.string.dialog_stop_ok));
    assertThat(dialog.getButton(DialogInterface.BUTTON_NEGATIVE).getText()).isEqualTo(mContext.getString(R.string.dlg_cancel));
}
Also used : ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) AlertDialog(android.app.AlertDialog) ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) Test(org.junit.Test)

Example 99 with AlertDialog

use of android.app.AlertDialog in project android_packages_apps_Settings by LineageOS.

the class AnomalyDialogFragmentTest method testOnCreateDialog_wakeupAlarmAnomalyPriorO_fireStopAndBackgroundCheckDialog.

@Test
public void testOnCreateDialog_wakeupAlarmAnomalyPriorO_fireStopAndBackgroundCheckDialog() {
    mAnomalyDialogFragment = AnomalyDialogFragment.newInstance(mWakeupAlarmAnomaly, 0);
    FragmentTestUtil.startFragment(mAnomalyDialogFragment);
    final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
    ShadowAlertDialog shadowDialog = shadowOf(dialog);
    assertThat(shadowDialog.getMessage()).isEqualTo(mContext.getString(R.string.dialog_background_check_message, mWakeLockAnomaly.displayName));
    assertThat(shadowDialog.getTitle()).isEqualTo(mContext.getString(R.string.dialog_background_check_title));
    assertThat(dialog.getButton(DialogInterface.BUTTON_POSITIVE).getText()).isEqualTo(mContext.getString(R.string.dialog_background_check_ok));
    assertThat(dialog.getButton(DialogInterface.BUTTON_NEGATIVE).getText()).isEqualTo(mContext.getString(R.string.dlg_cancel));
}
Also used : ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) AlertDialog(android.app.AlertDialog) ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) Test(org.junit.Test)

Example 100 with AlertDialog

use of android.app.AlertDialog in project android_packages_apps_crDroidSettings by crdroidandroid.

the class SlimRecentsBlacklist method onCreateDialog.

@Override
public Dialog onCreateDialog(int dialogId) {
    switch(dialogId) {
        case DIALOG_BLACKLIST_APPS:
            {
                Dialog dialog;
                AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
                final ListView list = new ListView(getActivity());
                list.setAdapter(mPackageAdapter);
                alertDialog.setTitle(R.string.profile_choose_app);
                alertDialog.setView(list);
                dialog = alertDialog.create();
                list.setOnItemClickListener(new OnItemClickListener() {

                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                        // Add empty application definition, the user will be able to edit it later
                        PackageItem info = (PackageItem) parent.getItemAtPosition(position);
                        addCustomApplicationPref(info.packageName, mBlacklistPackages);
                        dialog.cancel();
                    }
                });
                return dialog;
            }
    }
    return super.onCreateDialog(dialogId);
}
Also used : AlertDialog(android.app.AlertDialog) ListView(android.widget.ListView) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) Dialog(android.app.Dialog) AlertDialog(android.app.AlertDialog) AdapterView(android.widget.AdapterView) PackageItem(com.crdroid.settings.preferences.PackageListAdapter.PackageItem) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Aggregations

AlertDialog (android.app.AlertDialog)1029 DialogInterface (android.content.DialogInterface)573 View (android.view.View)278 TextView (android.widget.TextView)213 Intent (android.content.Intent)172 EditText (android.widget.EditText)160 Test (org.junit.Test)148 ShadowAlertDialog (org.robolectric.shadows.ShadowAlertDialog)111 Context (android.content.Context)96 ListView (android.widget.ListView)87 ImageView (android.widget.ImageView)86 LayoutInflater (android.view.LayoutInflater)80 Button (android.widget.Button)78 AdapterView (android.widget.AdapterView)72 Activity (android.app.Activity)66 SuppressLint (android.annotation.SuppressLint)61 Bundle (android.os.Bundle)56 OnClickListener (android.content.DialogInterface.OnClickListener)54 ArrayList (java.util.ArrayList)50 Dialog (android.app.Dialog)46