1. 程式人生 > >android鎖屏介面電量百分比顯示與主桌面同步

android鎖屏介面電量百分比顯示與主桌面同步

路徑 frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\phone\KeyguardStatusBarView.java

前提是在設定中新增電量百分比控制 (有空在寫)

--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
@@ -56
,7 +56,7 @@ public class KeyguardStatusBarView extends RelativeLayout private View mSystemIconsSuperContainer; private MultiUserSwitch mMultiUserSwitch; private ImageView mMultiUserAvatar; - private TextView mBatteryLevel; + public TextView mBatteryLevel; private BatteryController mBatteryController; private
KeyguardUserSwitcher mKeyguardUserSwitcher; @@ -109,7 +109,7 @@ public class KeyguardStatusBarView extends RelativeLayout } else if (mMultiUserSwitch.getParent() == this && mKeyguardUserSwitcherShowing) { removeView(mMultiUserSwitch); } - mBatteryLevel.setVisibility(mBatteryCharging ? View.VISIBLE : View.GONE); + } private
void updateSystemIconsLayoutParams() { @@ -166,9 +166,10 @@ public class KeyguardStatusBarView extends RelativeLayout mBatteryLevel.setText(percentage); boolean changed = mBatteryCharging != charging; mBatteryCharging = charging; - if (changed) { - updateVisibilities(); - } + + updateVisibilities(); + mBatteryLevel.setVisibility(mBatteryCharging|| mBatteryController.mShouldShowBatteryPercentage ? View.VISIBLE : View.GO + }