Permalink
Browse files

Battery icon: let disable force text outside icon when charging [2/2]

Change-Id: I531aa7f1a10b29691cd2171a82445b85eb4b3bc3
  • Loading branch information...
ezio84 authored and xlxfoxxlx committed Nov 25, 2016
1 parent 968a3db commit cd0e99f50f5af9a135ad346fb673dbabbd0e3cf7
Showing with 28 additions and 3 deletions.
  1. +3 −0 res/values/strings.xml
  2. +7 −0 res/xml/aosip_battery.xml
  3. +18 −3 src/com/aosip/owlsnest/statusbar/BatteryCategory.java
View
@@ -175,6 +175,9 @@
<string name="status_bar_battery_style_tile_summary">Allow to set the same icon style chosen for the statusbar battery</string>
<string name="status_bar_charge_color_title">Statusbar battery icon charging color</string>
<string name="status_bar_charge_color_summary">Set the color of the statusbar battery icon while charging</string>
<string name="force_charge_battery_text_title">Statusbar battery charging percent</string>
<string name="force_charge_battery_text_summary_on">Show the battery percentage outside the icon while charging</string>
<string name="force_charge_battery_text_summary_off">Show the battery percentage inside the icon while charging</string>
<!--Custom logos-->
<string name="sb_custom_logos">Custom Icons</string>
@@ -46,6 +46,13 @@
android:persistent="false"
android:defaultValue="0xffffff" />
<com.aosip.owlsnest.preference.SecureSettingSwitchPreference
android:key="force_charge_battery_text"
android:title="@string/force_charge_battery_text_title"
android:summaryOn="@string/force_charge_battery_text_summary_on"
android:summaryOff="@string/force_charge_battery_text_summary_off"
android:defaultValue="true" />
<com.aosip.owlsnest.preference.SecureSettingSwitchPreference
android:key="status_bar_battery_style_tile"
android:title="@string/status_bar_battery_style_tile_title"
@@ -49,6 +49,7 @@
private static final String STATUS_BAR_SHOW_BATTERY_PERCENT = "status_bar_show_battery_percent";
private static final String STATUS_BAR_BATTERY_STYLE_TILE = "status_bar_battery_style_tile";
private static final String STATUS_BAR_CHARGE_COLOR = "status_bar_charge_color";
private static final String FORCE_CHARGE_BATTERY_TEXT = "force_charge_battery_text";
private static final int STATUS_BAR_BATTERY_STYLE_PORTRAIT = 0;
@@ -61,6 +62,7 @@
private ListPreference mStatusBarBattery;
private ListPreference mStatusBarBatteryShowPercent;
private SwitchPreference mQsBatteryTitle;
private SwitchPreference mForceChargeBatteryText;
@Override
protected int getMetricsCategory() {
@@ -84,6 +86,11 @@ public void onCreate(Bundle savedInstanceState) {
Settings.Secure.STATUS_BAR_BATTERY_STYLE_TILE, 1) == 1));
mQsBatteryTitle.setOnPreferenceChangeListener(this);
mForceChargeBatteryText = (SwitchPreference) findPreference(FORCE_CHARGE_BATTERY_TEXT);
mForceChargeBatteryText.setChecked((Settings.Secure.getInt(resolver,
Settings.Secure.FORCE_CHARGE_BATTERY_TEXT, 1) == 1));
mForceChargeBatteryText.setOnPreferenceChangeListener(this);
mStatusBarBattery = (ListPreference) findPreference(STATUS_BAR_BATTERY_STYLE);
mStatusBarBatteryValue = Settings.Secure.getInt(resolver,
Settings.Secure.STATUS_BAR_BATTERY_STYLE, 0);
@@ -105,7 +112,7 @@ public void onCreate(Bundle savedInstanceState) {
mStatusBarBatteryShowPercent.setSummary(mStatusBarBatteryShowPercent.getEntry());
mStatusBarBatteryShowPercent.setOnPreferenceChangeListener(this);
enableStatusBarBatteryDependents(mStatusBarBatteryValue);
enableStatusBarBatteryDependents(mStatusBarBatteryValue, mStatusBarBatteryShowPercentValue);
}
@@ -130,7 +137,6 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
mStatusBarBattery.getEntries()[index]);
Settings.Secure.putInt(resolver,
Settings.Secure.STATUS_BAR_BATTERY_STYLE, mStatusBarBatteryValue);
enableStatusBarBatteryDependents(mStatusBarBatteryValue);
} else if (preference == mStatusBarBatteryShowPercent) {
mStatusBarBatteryShowPercentValue = Integer.valueOf((String) newValue);
int index = mStatusBarBatteryShowPercent.findIndexOfValue((String) newValue);
@@ -142,27 +148,36 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean checked = ((SwitchPreference)preference).isChecked();
Settings.Secure.putInt(resolver,
Settings.Secure.STATUS_BAR_BATTERY_STYLE_TILE, checked ? 1:0);
} else if (preference == mForceChargeBatteryText) {
boolean checked = ((SwitchPreference)preference).isChecked();
Settings.Secure.putInt(resolver,
Settings.Secure.FORCE_CHARGE_BATTERY_TEXT, checked ? 1:0);
} else if (preference.equals(mChargeColor)) {
int color = ((Integer) newValue).intValue();
Settings.Secure.putInt(resolver,
Settings.Secure.STATUS_BAR_CHARGE_COLOR, color);
return true;
}
enableStatusBarBatteryDependents(mStatusBarBatteryValue, mStatusBarBatteryShowPercentValue);
return true;
}
private void enableStatusBarBatteryDependents(int batteryIconStyle) {
private void enableStatusBarBatteryDependents(int batteryIconStyle, int showPercentMode) {
if (batteryIconStyle == STATUS_BAR_BATTERY_STYLE_HIDDEN ||
batteryIconStyle == STATUS_BAR_BATTERY_STYLE_TEXT) {
mStatusBarBatteryShowPercent.setEnabled(false);
mQsBatteryTitle.setEnabled(false);
mForceChargeBatteryText.setEnabled(false);
mChargeColor.setEnabled(false);
} else if (batteryIconStyle == STATUS_BAR_BATTERY_STYLE_PORTRAIT) {
mStatusBarBatteryShowPercent.setEnabled(true);
mQsBatteryTitle.setEnabled(false);
mChargeColor.setEnabled(true);
mForceChargeBatteryText.setEnabled(showPercentMode == 1 ? true : false);
} else {
mStatusBarBatteryShowPercent.setEnabled(true);
mQsBatteryTitle.setEnabled(true);
mForceChargeBatteryText.setEnabled(showPercentMode == 1 ? true : false);
mChargeColor.setEnabled(true);
}
}

0 comments on commit cd0e99f

Please sign in to comment.