Loading res/values-zh-rCN/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -3143,4 +3143,6 @@ <string name="profiles_settings_title">情景模式</string> <string name="mbn_version">MBN 版本</string> <string name="show_battery_percentage">显示电池电量百分比</string> <string name="show_battery_percentage_summary">在状态栏中显示电池电量百分比</string> </resources> res/values/customize.xml +3 −0 Original line number Diff line number Diff line Loading @@ -33,4 +33,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. <!-- Whether to show_kernel version name --> <bool name="def_hide_kernel_version_name">false</bool> <!-- Whether to show a preference item for battery percentage in ("Battery") for India RJIL --> <bool name="config_show_battery_percentage">false</bool> </resources> res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -7590,4 +7590,6 @@ <string name="lte_data_service_enabled">LTE data service enabled </string> <string name="turn_off_wifi_dialog_title">Turn off Wi-Fi</string> <string name="turn_off_wifi_dialog_text">Wi-Fi is turned off when Mobile HotSpot is active. To turn on Wi-Fi, please turn off Mobile HotSpot.</string> <string name="show_battery_percentage">Show battery percentage</string> <string name="show_battery_percentage_summary">Show battery level percentage inside the status bar</string> </resources> res/xml/power_usage_summary.xml +6 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,12 @@ android:title="@string/battery_saver" android:fragment="com.android.settings.fuelgauge.BatterySaverSettings" /> <SwitchPreference android:key="battery_pct" android:title="@string/show_battery_percentage" android:summary="@string/show_battery_percentage_summary" android:persistent="false" /> <com.android.settings.fuelgauge.BatteryHistoryPreference android:key="battery_history" /> Loading src/com/android/settings/fuelgauge/PowerUsageSummary.java +34 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ import android.os.Process; import android.os.UserHandle; import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceGroup; import android.support.v14.preference.SwitchPreference; import android.provider.Settings; import android.text.TextUtils; import android.util.SparseArray; import android.util.TypedValue; Loading Loading @@ -56,6 +58,7 @@ import java.util.List; */ public class PowerUsageSummary extends PowerUsageBase { public static final String SHOW_PERCENT_SETTING = "status_bar_show_battery_percent"; private static final boolean DEBUG = false; private static final boolean USE_FAKE_DATA = false; Loading @@ -64,6 +67,7 @@ public class PowerUsageSummary extends PowerUsageBase { private static final String KEY_APP_LIST = "app_list"; private static final String KEY_BATTERY_HISTORY = "battery_history"; private static final String KEY_BATTERY_PCT = "battery_pct"; private static final int MENU_STATS_TYPE = Menu.FIRST; private static final int MENU_HIGH_POWER_APPS = Menu.FIRST + 3; Loading @@ -71,8 +75,10 @@ public class PowerUsageSummary extends PowerUsageBase { private BatteryHistoryPreference mHistPref; private PreferenceGroup mAppListGroup; private SwitchPreference mBatteryPct; private int mStatsType = BatteryStats.STATS_SINCE_CHARGED; private boolean isShowBatteryPct; private static final int MIN_POWER_THRESHOLD_MILLI_AMP = 5; private static final int MAX_ITEMS_TO_LIST = USE_FAKE_DATA ? 30 : 10; Loading @@ -87,6 +93,11 @@ public class PowerUsageSummary extends PowerUsageBase { addPreferencesFromResource(R.xml.power_usage_summary); mHistPref = (BatteryHistoryPreference) findPreference(KEY_BATTERY_HISTORY); mAppListGroup = (PreferenceGroup) findPreference(KEY_APP_LIST); mBatteryPct = (SwitchPreference) findPreference(KEY_BATTERY_PCT); isShowBatteryPct = getResources().getBoolean(R.bool.config_show_battery_percentage); if (!isShowBatteryPct) { getPreferenceScreen().removePreference(mBatteryPct); } } @Override Loading @@ -97,6 +108,9 @@ public class PowerUsageSummary extends PowerUsageBase { @Override public void onResume() { super.onResume(); if (isShowBatteryPct) { updateBatteryPct(); } refreshStats(); } Loading Loading @@ -479,4 +493,24 @@ public class PowerUsageSummary extends PowerUsageBase { return new SummaryProvider(activity, summaryLoader); } }; private void updateBatteryPct() { if (mBatteryPct != null) { mBatteryPct.setChecked( Settings.System.getInt(getContext().getContentResolver(), SHOW_PERCENT_SETTING, 0) != 0); mBatteryPct.setOnPreferenceChangeListener(mBatteryPctChange); } } private final Preference.OnPreferenceChangeListener mBatteryPctChange = new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { final boolean v = (Boolean) newValue; Settings.System.putInt(getContext().getContentResolver(), SHOW_PERCENT_SETTING, v ? 1 : 0); return true; } }; } Loading
res/values-zh-rCN/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -3143,4 +3143,6 @@ <string name="profiles_settings_title">情景模式</string> <string name="mbn_version">MBN 版本</string> <string name="show_battery_percentage">显示电池电量百分比</string> <string name="show_battery_percentage_summary">在状态栏中显示电池电量百分比</string> </resources>
res/values/customize.xml +3 −0 Original line number Diff line number Diff line Loading @@ -33,4 +33,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. <!-- Whether to show_kernel version name --> <bool name="def_hide_kernel_version_name">false</bool> <!-- Whether to show a preference item for battery percentage in ("Battery") for India RJIL --> <bool name="config_show_battery_percentage">false</bool> </resources>
res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -7590,4 +7590,6 @@ <string name="lte_data_service_enabled">LTE data service enabled </string> <string name="turn_off_wifi_dialog_title">Turn off Wi-Fi</string> <string name="turn_off_wifi_dialog_text">Wi-Fi is turned off when Mobile HotSpot is active. To turn on Wi-Fi, please turn off Mobile HotSpot.</string> <string name="show_battery_percentage">Show battery percentage</string> <string name="show_battery_percentage_summary">Show battery level percentage inside the status bar</string> </resources>
res/xml/power_usage_summary.xml +6 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,12 @@ android:title="@string/battery_saver" android:fragment="com.android.settings.fuelgauge.BatterySaverSettings" /> <SwitchPreference android:key="battery_pct" android:title="@string/show_battery_percentage" android:summary="@string/show_battery_percentage_summary" android:persistent="false" /> <com.android.settings.fuelgauge.BatteryHistoryPreference android:key="battery_history" /> Loading
src/com/android/settings/fuelgauge/PowerUsageSummary.java +34 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ import android.os.Process; import android.os.UserHandle; import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceGroup; import android.support.v14.preference.SwitchPreference; import android.provider.Settings; import android.text.TextUtils; import android.util.SparseArray; import android.util.TypedValue; Loading Loading @@ -56,6 +58,7 @@ import java.util.List; */ public class PowerUsageSummary extends PowerUsageBase { public static final String SHOW_PERCENT_SETTING = "status_bar_show_battery_percent"; private static final boolean DEBUG = false; private static final boolean USE_FAKE_DATA = false; Loading @@ -64,6 +67,7 @@ public class PowerUsageSummary extends PowerUsageBase { private static final String KEY_APP_LIST = "app_list"; private static final String KEY_BATTERY_HISTORY = "battery_history"; private static final String KEY_BATTERY_PCT = "battery_pct"; private static final int MENU_STATS_TYPE = Menu.FIRST; private static final int MENU_HIGH_POWER_APPS = Menu.FIRST + 3; Loading @@ -71,8 +75,10 @@ public class PowerUsageSummary extends PowerUsageBase { private BatteryHistoryPreference mHistPref; private PreferenceGroup mAppListGroup; private SwitchPreference mBatteryPct; private int mStatsType = BatteryStats.STATS_SINCE_CHARGED; private boolean isShowBatteryPct; private static final int MIN_POWER_THRESHOLD_MILLI_AMP = 5; private static final int MAX_ITEMS_TO_LIST = USE_FAKE_DATA ? 30 : 10; Loading @@ -87,6 +93,11 @@ public class PowerUsageSummary extends PowerUsageBase { addPreferencesFromResource(R.xml.power_usage_summary); mHistPref = (BatteryHistoryPreference) findPreference(KEY_BATTERY_HISTORY); mAppListGroup = (PreferenceGroup) findPreference(KEY_APP_LIST); mBatteryPct = (SwitchPreference) findPreference(KEY_BATTERY_PCT); isShowBatteryPct = getResources().getBoolean(R.bool.config_show_battery_percentage); if (!isShowBatteryPct) { getPreferenceScreen().removePreference(mBatteryPct); } } @Override Loading @@ -97,6 +108,9 @@ public class PowerUsageSummary extends PowerUsageBase { @Override public void onResume() { super.onResume(); if (isShowBatteryPct) { updateBatteryPct(); } refreshStats(); } Loading Loading @@ -479,4 +493,24 @@ public class PowerUsageSummary extends PowerUsageBase { return new SummaryProvider(activity, summaryLoader); } }; private void updateBatteryPct() { if (mBatteryPct != null) { mBatteryPct.setChecked( Settings.System.getInt(getContext().getContentResolver(), SHOW_PERCENT_SETTING, 0) != 0); mBatteryPct.setOnPreferenceChangeListener(mBatteryPctChange); } } private final Preference.OnPreferenceChangeListener mBatteryPctChange = new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { final boolean v = (Boolean) newValue; Settings.System.putInt(getContext().getContentResolver(), SHOW_PERCENT_SETTING, v ? 1 : 0); return true; } }; }