Search in sources :

Example 16 with BatteryTip

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

the class BatteryTipPreferenceController method handlePreferenceTreeClick.

@Override
public boolean handlePreferenceTreeClick(Preference preference) {
    final BatteryTip batteryTip = mBatteryTipMap.get(preference.getKey());
    if (batteryTip != null) {
        if (batteryTip.shouldShowDialog()) {
            BatteryTipDialogFragment dialogFragment = BatteryTipDialogFragment.newInstance(batteryTip, mFragment.getMetricsCategory());
            dialogFragment.setTargetFragment(mFragment, REQUEST_ANOMALY_ACTION);
            dialogFragment.show(mFragment.getFragmentManager(), TAG);
        } else {
            final BatteryTipAction action = BatteryTipUtils.getActionForBatteryTip(batteryTip, mSettingsActivity, mFragment);
            if (action != null) {
                action.handlePositiveAction(mFragment.getMetricsCategory());
            }
            if (mBatteryTipListener != null) {
                mBatteryTipListener.onBatteryTipHandled(batteryTip);
            }
        }
        return true;
    }
    return super.handlePreferenceTreeClick(preference);
}
Also used : BatteryTipAction(com.android.settings.fuelgauge.batterytip.actions.BatteryTipAction) BatteryTip(com.android.settings.fuelgauge.batterytip.tips.BatteryTip)

Example 17 with BatteryTip

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

the class BatteryFixSliceTest method updateBatteryTipAvailabilityCache_hasImportantTip_shouldReturnTrue.

@Test
public void updateBatteryTipAvailabilityCache_hasImportantTip_shouldReturnTrue() {
    final List<BatteryTip> tips = new ArrayList<>();
    tips.add(new LowBatteryTip(BatteryTip.StateType.INVISIBLE, false, ""));
    tips.add(new EarlyWarningTip(BatteryTip.StateType.NEW, false));
    ShadowBatteryTipLoader.setBatteryTips(tips);
    BatteryFixSlice.updateBatteryTipAvailabilityCache(mContext);
    assertThat(BatteryFixSlice.isBatteryTipAvailableFromCache(mContext)).isTrue();
}
Also used : EarlyWarningTip(com.android.settings.fuelgauge.batterytip.tips.EarlyWarningTip) ArrayList(java.util.ArrayList) LowBatteryTip(com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip) BatteryTip(com.android.settings.fuelgauge.batterytip.tips.BatteryTip) LowBatteryTip(com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip) Test(org.junit.Test)

Example 18 with BatteryTip

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

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 19 with BatteryTip

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

the class BatteryHeaderPreferenceControllerTest method updateHeaderByBatteryTips_lowBatteryTip_showLowBattery.

@Test
public void updateHeaderByBatteryTips_lowBatteryTip_showLowBattery() {
    setChargingState(/* isDischarging */
    true, /* updatedByStatusFeature */
    false);
    BatteryTip lowBatteryTip = new LowBatteryTip(BatteryTip.StateType.NEW, /* powerSaveModeOn */
    false);
    mController.updateHeaderByBatteryTips(lowBatteryTip, mBatteryInfo);
    final String expectedResult = "Low battery • " + TIME_LEFT;
    verify(mBatteryUsageProgressBarPref).setBottomSummary(expectedResult);
}
Also used : LowBatteryTip(com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip) SmartBatteryTip(com.android.settings.fuelgauge.batterytip.tips.SmartBatteryTip) BatteryTip(com.android.settings.fuelgauge.batterytip.tips.BatteryTip) LowBatteryTip(com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip) Test(org.junit.Test)

Example 20 with BatteryTip

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

the class BatteryHeaderPreferenceControllerTest method updateHeaderByBatteryTips_noBatteryInfo_noAction.

@Test
public void updateHeaderByBatteryTips_noBatteryInfo_noAction() {
    BatteryTip lowBatteryTip = new LowBatteryTip(BatteryTip.StateType.NEW, /* powerSaveModeOn */
    false);
    mController.updateHeaderByBatteryTips(lowBatteryTip, null);
    verifyZeroInteractions(mBatteryUsageProgressBarPref);
}
Also used : LowBatteryTip(com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip) SmartBatteryTip(com.android.settings.fuelgauge.batterytip.tips.SmartBatteryTip) BatteryTip(com.android.settings.fuelgauge.batterytip.tips.BatteryTip) LowBatteryTip(com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip) Test(org.junit.Test)

Aggregations

BatteryTip (com.android.settings.fuelgauge.batterytip.tips.BatteryTip)23 LowBatteryTip (com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip)13 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)9 EarlyWarningTip (com.android.settings.fuelgauge.batterytip.tips.EarlyWarningTip)6 Slice (androidx.slice.Slice)4 VisibleForTesting (androidx.annotation.VisibleForTesting)3 AppInfo (com.android.settings.fuelgauge.batterytip.AppInfo)3 SmartBatteryTip (com.android.settings.fuelgauge.batterytip.tips.SmartBatteryTip)3 Context (android.content.Context)2 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)2 Drawable (android.graphics.drawable.Drawable)2 WorkerThread (androidx.annotation.WorkerThread)2 IconCompat (androidx.core.graphics.drawable.IconCompat)2 ListBuilder (androidx.slice.builders.ListBuilder)2 RowBuilder (androidx.slice.builders.ListBuilder.RowBuilder)2 SliceAction (androidx.slice.builders.SliceAction)2 BatteryInfo (com.android.settings.fuelgauge.BatteryInfo)2 BatteryTipDialogFragment (com.android.settings.fuelgauge.batterytip.BatteryTipDialogFragment)2 BatteryTipLoader (com.android.settings.fuelgauge.batterytip.BatteryTipLoader)2