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
This commit is contained in:
@@ -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"
|
||||
/>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user