diff options
author | Evan Laird <evanlaird@google.com> | 2018-10-22 14:24:32 -0400 |
---|---|---|
committer | Evan Laird <evanlaird@google.com> | 2018-11-13 10:47:14 -0500 |
commit | 4bf21dffaa09de83d9242e1cd8a73d930eeea780 (patch) | |
tree | 9c88d93529ebb1fdcdf504578d9bbee95d9dfb50 /packages/SystemUI/src/com/android/systemui/BatteryMeterView.java | |
parent | b513876655e04eb520d5d9b36558d3a8d3dd49e9 (diff) |
Add estimated time remaining text to QS
- Add an API to BatteryController to get an estimated time remaining
string.
- BatteryController will now check up to once per minute what the
estimated time will be and builds the string using PowerUtil.
- If the "show percentage" setting is on, the estimated time remaining
string (and battery icon) will show next to the system icons in QS
- Also make the battery percent in QS obey the setting
Test: visual
Bug: 116481529
Change-Id: Iaafa00127c8b8baae40956254a1237c8b7ac079b
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/BatteryMeterView.java')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/BatteryMeterView.java | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java index f6fec5456ed8..053ea67b92c8 100644 --- a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java +++ b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java @@ -19,7 +19,10 @@ import static android.app.StatusBarManager.DISABLE2_SYSTEM_ICONS; import static android.app.StatusBarManager.DISABLE_NONE; import static android.provider.Settings.System.SHOW_BATTERY_PERCENT; +import static java.lang.annotation.RetentionPolicy.SOURCE; + import android.animation.ArgbEvaluator; +import android.annotation.IntDef; import android.app.ActivityManager; import android.content.Context; import android.content.res.Resources; @@ -55,15 +58,23 @@ import com.android.systemui.statusbar.policy.IconLogger; import com.android.systemui.tuner.TunerService; import com.android.systemui.tuner.TunerService.Tunable; import com.android.systemui.util.Utils.DisableStateTracker; -import com.android.systemui.R; import java.io.FileDescriptor; import java.io.PrintWriter; +import java.lang.annotation.Retention; import java.text.NumberFormat; public class BatteryMeterView extends LinearLayout implements BatteryStateChangeCallback, Tunable, DarkReceiver, ConfigurationListener { + + @Retention(SOURCE) + @IntDef({MODE_DEFAULT, MODE_ON, MODE_OFF}) + public @interface BatteryPercentMode {} + public static final int MODE_DEFAULT = 0; + public static final int MODE_ON = 1; + public static final int MODE_OFF = 2; + private final BatteryMeterDrawableBase mDrawable; private final String mSlotBattery; private final ImageView mBatteryIconView; @@ -74,6 +85,7 @@ public class BatteryMeterView extends LinearLayout implements private SettingObserver mSettingObserver; private int mTextColor; private int mLevel; + private int mShowPercentMode = MODE_DEFAULT; private boolean mForceShowPercent; private boolean mShowPercentAvailable; @@ -154,7 +166,19 @@ public class BatteryMeterView extends LinearLayout implements } public void setForceShowPercent(boolean show) { - mForceShowPercent = show; + setPercentShowMode(show ? MODE_ON : MODE_DEFAULT); + } + + /** + * Force a particular mode of showing percent + * + * 0 - No preference + * 1 - Force on + * 2 - Force off + * @param mode desired mode (none, on, off) + */ + public void setPercentShowMode(@BatteryPercentMode int mode) { + mShowPercentMode = mode; updateShowPercent(); } @@ -273,7 +297,8 @@ public class BatteryMeterView extends LinearLayout implements .getIntForUser(getContext().getContentResolver(), SHOW_BATTERY_PERCENT, 0, mUser); - if ((mShowPercentAvailable && systemSetting) || mForceShowPercent) { + if ((mShowPercentAvailable && systemSetting && mShowPercentMode != MODE_OFF) + || mShowPercentMode == MODE_ON) { if (!showing) { mBatteryPercentView = loadPercentView(); if (mTextColor != 0) mBatteryPercentView.setTextColor(mTextColor); |