diff options
| author | 2017-02-21 14:51:11 -0500 | |
|---|---|---|
| committer | 2017-02-21 16:17:09 -0500 | |
| commit | df14c20be4c2c8a4d715cb483683fa688348c35f (patch) | |
| tree | d73fa6898264fd0ea5b54e64257abf4ed91fc05f | |
| parent | c98c16ded8738054242b2576a74e145f834b6efa (diff) | |
Don't show the percentage twice when charging.
The old percentage textview is now gone from the layout.
When the device is charging (but the user doesn't have
percentage display turned on all the time) use the new
percentage built-in to BatteryMeterView.
Bug: 35521962
Test: visual
Change-Id: I91f3350f6203fd007f003ca260ac0ed78e29b771
6 files changed, 13 insertions, 41 deletions
diff --git a/packages/SystemUI/res/layout/battery_percentage_view.xml b/packages/SystemUI/res/layout/battery_percentage_view.xml index acae9f51c142..f5c3d4071dfc 100644 --- a/packages/SystemUI/res/layout/battery_percentage_view.xml +++ b/packages/SystemUI/res/layout/battery_percentage_view.xml @@ -25,5 +25,5 @@ android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Clock" android:textColor="?android:attr/textColorPrimary" android:gravity="center_vertical|start" - android:paddingStart="4dp" + android:paddingStart="@dimen/battery_level_padding_start" /> diff --git a/packages/SystemUI/res/layout/keyguard_status_bar.xml b/packages/SystemUI/res/layout/keyguard_status_bar.xml index a2dfc0dd115d..c5f2f4ab6caa 100644 --- a/packages/SystemUI/res/layout/keyguard_status_bar.xml +++ b/packages/SystemUI/res/layout/keyguard_status_bar.xml @@ -52,16 +52,6 @@ > <include layout="@layout/system_icons" /> </FrameLayout> - <TextView android:id="@+id/battery_level" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="center_vertical" - android:layout_marginStart="@dimen/header_battery_margin_keyguard" - android:paddingEnd="@dimen/battery_level_padding_end" - android:textColor="#ffffff" - android:visibility="gone" - android:textSize="@dimen/battery_level_text_size" - android:importantForAccessibility="noHideDescendants"/> </LinearLayout> <com.android.keyguard.CarrierText diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 6e399b4406df..51b6b2fff628 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -445,8 +445,8 @@ <!-- Amount the date/time move when emergency calls only is present --> <dimen name="qs_date_time_translation">8dp</dimen> - <!-- Battery level text padding end when in expanded QS and on Keyguard --> - <dimen name="battery_level_padding_end">2dp</dimen> + <!-- Padding before battery level text in status bar, QS, and Keyguard --> + <dimen name="battery_level_padding_start">4dp</dimen> <!-- The top padding of the clear all button --> <dimen name="clear_all_padding_top">12dp</dimen> diff --git a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java index bda4c957c5e8..ee8641bbc5cf 100644 --- a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java +++ b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java @@ -16,7 +16,6 @@ package com.android.systemui; import android.content.Context; -import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Rect; @@ -27,8 +26,6 @@ import android.database.ContentObserver; import android.net.Uri; import android.os.Handler; import android.provider.Settings; -import android.util.ArraySet; -import android.util.AttributeSet; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; @@ -36,7 +33,6 @@ import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; -import android.widget.LinearLayout; import android.widget.TextView; import com.android.settingslib.graph.BatteryMeterDrawableBase; import com.android.systemui.statusbar.phone.StatusBarIconController; @@ -104,8 +100,8 @@ public class BatteryMeterView extends LinearLayout implements updateShowPercent(); } - public void forceShowPercent() { - mForceShowPercent = true; + public void setForceShowPercent(boolean show) { + mForceShowPercent = show; updateShowPercent(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java index ff58e54ee1ae..42b09dfe99c7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java @@ -28,6 +28,7 @@ import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; +import com.android.systemui.BatteryMeterView; import com.android.systemui.Dependency; import com.android.systemui.Interpolators; import com.android.systemui.R; @@ -39,8 +40,6 @@ import com.android.systemui.statusbar.policy.UserInfoController; import com.android.systemui.statusbar.policy.UserInfoController.OnUserInfoChangedListener; import com.android.systemui.statusbar.policy.UserSwitcherController; -import java.text.NumberFormat; - /** * The header group on Keyguard. */ @@ -55,7 +54,7 @@ public class KeyguardStatusBarView extends RelativeLayout private View mSystemIconsSuperContainer; private MultiUserSwitch mMultiUserSwitch; private ImageView mMultiUserAvatar; - private TextView mBatteryLevel; + private BatteryMeterView mBatteryView; private BatteryController mBatteryController; private KeyguardUserSwitcher mKeyguardUserSwitcher; @@ -76,8 +75,9 @@ public class KeyguardStatusBarView extends RelativeLayout mSystemIconsContainer = findViewById(R.id.system_icons_container); mMultiUserSwitch = (MultiUserSwitch) findViewById(R.id.multi_user_switch); mMultiUserAvatar = (ImageView) findViewById(R.id.multi_user_avatar); - mBatteryLevel = (TextView) findViewById(R.id.battery_level); mCarrierLabel = (TextView) findViewById(R.id.keyguard_carrier_text); + mBatteryView = (BatteryMeterView) mSystemIconsContainer.findViewById(R.id.battery); + loadDimens(); updateUserSwitcher(); mBatteryController = Dependency.get(BatteryController.class); @@ -115,17 +115,6 @@ public class KeyguardStatusBarView extends RelativeLayout R.dimen.status_bar_height); mSystemIconsContainer.setLayoutParams(lp); - lp = (MarginLayoutParams) mBatteryLevel.getLayoutParams(); - lp.setMarginStart( - getResources().getDimensionPixelSize(R.dimen.header_battery_margin_keyguard)); - mBatteryLevel.setLayoutParams(lp); - mBatteryLevel.setPaddingRelative(mBatteryLevel.getPaddingStart(), - mBatteryLevel.getPaddingTop(), - getResources().getDimensionPixelSize(R.dimen.battery_level_padding_end), - mBatteryLevel.getPaddingBottom()); - mBatteryLevel.setTextSize(TypedValue.COMPLEX_UNIT_PX, - getResources().getDimensionPixelSize(R.dimen.battery_level_text_size)); - // Respect font size setting. mCarrierLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize( @@ -168,7 +157,7 @@ public class KeyguardStatusBarView extends RelativeLayout mMultiUserSwitch.setVisibility(View.GONE); } } - mBatteryLevel.setVisibility(mBatteryCharging ? View.VISIBLE : View.GONE); + mBatteryView.setForceShowPercent(mBatteryCharging); } private void updateSystemIconsLayoutParams() { @@ -233,11 +222,8 @@ public class KeyguardStatusBarView extends RelativeLayout @Override public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) { - String percentage = NumberFormat.getPercentInstance().format((double) level / 100.0); - mBatteryLevel.setText(percentage); - boolean changed = mBatteryCharging != charging; - mBatteryCharging = charging; - if (changed) { + if (mBatteryCharging != charging) { + mBatteryCharging = charging; updateVisibilities(); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java index ade1b0b6844e..0e7b2f31cba2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java @@ -176,7 +176,7 @@ public class QuickStatusBarHeader extends BaseStatusBarHeader implements cluster.onDarkChanged(new Rect(0, 0, 0, 0), intensity, colorForeground); BatteryMeterView battery = (BatteryMeterView) findViewById(R.id.battery); - battery.forceShowPercent(); + battery.setForceShowPercent(true); int colorSecondary = Utils.getColorAttr(getContext(), android.R.attr.textColorSecondary); battery.setRawColors(colorForeground, colorSecondary); |