关于状态栏的电量百分比
时间:10-02
整理:3721RD
点击:
[DESCRIPTION]
关于状态栏中的电量百分比,包括显示或者隐藏电量百分比。
[SOLUTION]
一,KK之前:
通知栏电量百分比是CMCC定制的,只有TDD的项目才会有,如果要去掉,可以修改
mediate/operator/op01/packages/apps/plugins/res/vaules/default.xml
def_Battery_percentage_op01 修改为false
二,KK后:
目前KK,L上默认不显示百分比!在QS那里显示
三,L上添加显示电量百分比办法:
1, 添加view
Status_bar.xml
<com.android.keyguard.AlphaOptimizedLinearLayout android:id="@+id/system_icon_area"
android:layout_width="wrap_content"
android:layout_height="match_parent"
androidrientation="horizontal"
>
<include layout="@layout/system_icons" />
<!-- add mtk -->
<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:textSize="@dimen/battery_level_text_size"
android:importantForAccessibility="noHideDescendants"/>
<!-- add mtk end-->
<com.android.systemui.statusbar.policy.Clock
android:id="@+id/clock"
android:textAppearance="@style/TextAppearance.StatusBar.Clock"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:singleLine="true"
android:paddingStart="7dp"
android:gravity="center_vertical|start"
/>
</com.android.keyguard.AlphaOptimizedLinearLayout>
</LinearLayout>
2,修改PhoneStatusBar.Java 代码:
添加代码:
....................
import java.text.NumberFormat;//导入包
.....................
PhoneStatusBar.java
BatteryController mBatteryController;
private TextView mBatteryLevel;//add code
makeStatusBarView()方法:
.......................
...................
mBatteryController = new BatteryController(mContext);
mBatteryLevel = (TextView) mStatusBarView.findViewById(R.id.battery_level);//add code
mBatteryController.addStateChangedCallback(new BatteryStateChangeCallback() {
@Override
public void onpowerSaveChanged() {
mHandler.post(mCheckBARModes);
if (mDozeServiceHost != null) {
mDozeServiceHost.firePowerSaveChanged(mBatteryController.isPowerSave());
}
}
@Override
public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) {
// noop
//mtk add code
String percentage = NumberFormat.getPercentInstance().format((double) level / 100.0);//add code
mBatteryLevel.setText(percentage);
}
});
关于状态栏中的电量百分比,包括显示或者隐藏电量百分比。
[SOLUTION]
一,KK之前:
通知栏电量百分比是CMCC定制的,只有TDD的项目才会有,如果要去掉,可以修改
mediate/operator/op01/packages/apps/plugins/res/vaules/default.xml
def_Battery_percentage_op01 修改为false
二,KK后:
目前KK,L上默认不显示百分比!在QS那里显示
三,L上添加显示电量百分比办法:
1, 添加view
Status_bar.xml
<com.android.keyguard.AlphaOptimizedLinearLayout android:id="@+id/system_icon_area"
android:layout_width="wrap_content"
android:layout_height="match_parent"
androidrientation="horizontal"
>
<include layout="@layout/system_icons" />
<!-- add mtk -->
<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:textSize="@dimen/battery_level_text_size"
android:importantForAccessibility="noHideDescendants"/>
<!-- add mtk end-->
<com.android.systemui.statusbar.policy.Clock
android:id="@+id/clock"
android:textAppearance="@style/TextAppearance.StatusBar.Clock"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:singleLine="true"
android:paddingStart="7dp"
android:gravity="center_vertical|start"
/>
</com.android.keyguard.AlphaOptimizedLinearLayout>
</LinearLayout>
2,修改PhoneStatusBar.Java 代码:
添加代码:
....................
import java.text.NumberFormat;//导入包
.....................
PhoneStatusBar.java
BatteryController mBatteryController;
private TextView mBatteryLevel;//add code
makeStatusBarView()方法:
.......................
...................
mBatteryController = new BatteryController(mContext);
mBatteryLevel = (TextView) mStatusBarView.findViewById(R.id.battery_level);//add code
mBatteryController.addStateChangedCallback(new BatteryStateChangeCallback() {
@Override
public void onpowerSaveChanged() {
mHandler.post(mCheckBARModes);
if (mDozeServiceHost != null) {
mDozeServiceHost.firePowerSaveChanged(mBatteryController.isPowerSave());
}
}
@Override
public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) {
// noop
//mtk add code
String percentage = NumberFormat.getPercentInstance().format((double) level / 100.0);//add code
mBatteryLevel.setText(percentage);
}
});