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);
}
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();
}
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);
}
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);
}
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);
}
Aggregations