Search in sources :

Example 1 with BatteryTipDialogFragment

use of com.android.settings.fuelgauge.batterytip.BatteryTipDialogFragment in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class RestrictedAppDetailsTest method createDialogFragment_toRestrict_createRestrictDialog.

@Test
public void createDialogFragment_toRestrict_createRestrictDialog() {
    final BatteryTipDialogFragment dialogFragment = mRestrictedAppDetails.createDialogFragment(mAppInfo, true);
    FragmentController.setupFragment(dialogFragment, FragmentActivity.class, 0, /* containerViewId */
    null);
    final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
    ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
    assertThat(shadowDialog.getTitle()).isEqualTo("Restrict app?");
}
Also used : BatteryTipDialogFragment(com.android.settings.fuelgauge.batterytip.BatteryTipDialogFragment) AlertDialog(androidx.appcompat.app.AlertDialog) ShadowAlertDialogCompat(com.android.settings.testutils.shadow.ShadowAlertDialogCompat) Test(org.junit.Test)

Example 2 with BatteryTipDialogFragment

use of com.android.settings.fuelgauge.batterytip.BatteryTipDialogFragment in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BackgroundActivityPreferenceController method showDialog.

@VisibleForTesting
void showDialog(boolean restricted) {
    final AppInfo appInfo = new AppInfo.Builder().setUid(mUid).setPackageName(mTargetPackage).build();
    BatteryTip tip = restricted ? new UnrestrictAppTip(BatteryTip.StateType.NEW, appInfo) : new RestrictAppTip(BatteryTip.StateType.NEW, appInfo);
    final BatteryTipDialogFragment dialogFragment = BatteryTipDialogFragment.newInstance(tip, mFragment.getMetricsCategory());
    dialogFragment.setTargetFragment(mFragment, 0);
    dialogFragment.show(mFragment.getFragmentManager(), TAG);
}
Also used : BatteryTipDialogFragment(com.android.settings.fuelgauge.batterytip.BatteryTipDialogFragment) RestrictAppTip(com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip) BatteryTip(com.android.settings.fuelgauge.batterytip.tips.BatteryTip) AppInfo(com.android.settings.fuelgauge.batterytip.AppInfo) UnrestrictAppTip(com.android.settings.fuelgauge.batterytip.tips.UnrestrictAppTip) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 3 with BatteryTipDialogFragment

use of com.android.settings.fuelgauge.batterytip.BatteryTipDialogFragment in project android_packages_apps_Settings by omnirom.

the class RestrictedAppDetailsTest method createDialogFragment_toRestrict_createRestrictDialog.

@Test
public void createDialogFragment_toRestrict_createRestrictDialog() {
    final BatteryTipDialogFragment dialogFragment = mRestrictedAppDetails.createDialogFragment(mAppInfo, true);
    FragmentController.setupFragment(dialogFragment, FragmentActivity.class, 0, /* containerViewId */
    null);
    final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
    ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
    assertThat(shadowDialog.getTitle()).isEqualTo("Restrict app?");
}
Also used : BatteryTipDialogFragment(com.android.settings.fuelgauge.batterytip.BatteryTipDialogFragment) AlertDialog(androidx.appcompat.app.AlertDialog) ShadowAlertDialogCompat(com.android.settings.testutils.shadow.ShadowAlertDialogCompat) Test(org.junit.Test)

Example 4 with BatteryTipDialogFragment

use of com.android.settings.fuelgauge.batterytip.BatteryTipDialogFragment in project android_packages_apps_Settings by omnirom.

the class RestrictedAppDetailsTest method createDialogFragment_toUnrestrict_createUnrestrictDialog.

@Test
public void createDialogFragment_toUnrestrict_createUnrestrictDialog() {
    final BatteryTipDialogFragment dialogFragment = mRestrictedAppDetails.createDialogFragment(mAppInfo, false);
    FragmentController.setupFragment(dialogFragment, FragmentActivity.class, 0, /* containerViewId */
    null);
    final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
    ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
    assertThat(shadowDialog.getTitle()).isEqualTo("Remove restriction?");
}
Also used : BatteryTipDialogFragment(com.android.settings.fuelgauge.batterytip.BatteryTipDialogFragment) AlertDialog(androidx.appcompat.app.AlertDialog) ShadowAlertDialogCompat(com.android.settings.testutils.shadow.ShadowAlertDialogCompat) Test(org.junit.Test)

Example 5 with BatteryTipDialogFragment

use of com.android.settings.fuelgauge.batterytip.BatteryTipDialogFragment in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class RestrictedAppDetailsTest method createDialogFragment_toUnrestrict_createUnrestrictDialog.

@Test
public void createDialogFragment_toUnrestrict_createUnrestrictDialog() {
    final BatteryTipDialogFragment dialogFragment = mRestrictedAppDetails.createDialogFragment(mAppInfo, false);
    FragmentController.setupFragment(dialogFragment, FragmentActivity.class, 0, /* containerViewId */
    null);
    final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
    ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
    assertThat(shadowDialog.getTitle()).isEqualTo("Remove restriction?");
}
Also used : BatteryTipDialogFragment(com.android.settings.fuelgauge.batterytip.BatteryTipDialogFragment) AlertDialog(androidx.appcompat.app.AlertDialog) ShadowAlertDialogCompat(com.android.settings.testutils.shadow.ShadowAlertDialogCompat) Test(org.junit.Test)

Aggregations

BatteryTipDialogFragment (com.android.settings.fuelgauge.batterytip.BatteryTipDialogFragment)8 VisibleForTesting (androidx.annotation.VisibleForTesting)4 AlertDialog (androidx.appcompat.app.AlertDialog)4 AppInfo (com.android.settings.fuelgauge.batterytip.AppInfo)4 ShadowAlertDialogCompat (com.android.settings.testutils.shadow.ShadowAlertDialogCompat)4 Test (org.junit.Test)4 Context (android.content.Context)2 ApplicationInfo (android.content.pm.ApplicationInfo)2 PackageManager (android.content.pm.PackageManager)2 SparseLongArray (android.util.SparseLongArray)2 CheckBoxPreference (androidx.preference.CheckBoxPreference)2 BatteryTip (com.android.settings.fuelgauge.batterytip.tips.BatteryTip)2 RestrictAppTip (com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip)2 UnrestrictAppTip (com.android.settings.fuelgauge.batterytip.tips.UnrestrictAppTip)2 AppCheckBoxPreference (com.android.settings.widget.AppCheckBoxPreference)2