Permalink
Browse files

Battery tile: allow to disable custom battery style [2/2]

- Disable battery tile toggle when style is enabled for portrait, text
or hidden.

Change-Id: I4e6f7c1bb5f3dd35919d59f9b7b4cf828854125b
  • Loading branch information...
ezio84 authored and xlxfoxxlx committed Nov 23, 2016
1 parent 0292da6 commit 992bdba3bd72c18c970c695b96d7460d25cc8e9d
Showing with 23 additions and 0 deletions.
  1. +2 −0 res/values/strings.xml
  2. +5 −0 res/xml/aosip_battery.xml
  3. +16 −0 src/com/aosip/owlsnest/statusbar/BatteryCategory.java
View
@@ -171,6 +171,8 @@
<string name="status_bar_battery_percentage_default">Hidden</string>
<string name="status_bar_battery_percentage_text_inside">Inside the icon</string>
<string name="status_bar_battery_percentage_text_next">Next to the icon</string>
<string name="status_bar_battery_style_tile_title">Custom battery tile style</string>
<string name="status_bar_battery_style_tile_summary">Allow to set the same icon style chosen for the statusbar battery</string>
<!--Custom logos-->
<string name="sb_custom_logos">Custom Icons</string>
@@ -39,5 +39,10 @@
android:entryValues="@array/status_bar_battery_percentage_values"
android:defaultValue="0" />
<com.dirtyunicorns.dutweaks.preference.SecureSettingSwitchPreference
android:key="status_bar_battery_style_tile"
android:title="@string/status_bar_battery_style_tile_title"
android:summary="@string/status_bar_battery_style_tile_summary"
android:defaultValue="true" />
</PreferenceScreen>
@@ -43,14 +43,17 @@
private static final String STATUS_BAR_BATTERY_STYLE = "status_bar_battery_style";
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 int STATUS_BAR_BATTERY_STYLE_PORTRAIT = 0;
private static final int STATUS_BAR_BATTERY_STYLE_HIDDEN = 4;
private static final int STATUS_BAR_BATTERY_STYLE_TEXT = 6;
private int mStatusBarBatteryValue;
private int mStatusBarBatteryShowPercentValue;
private ListPreference mStatusBarBattery;
private ListPreference mStatusBarBatteryShowPercent;
private SwitchPreference mQsBatteryTitle;
@Override
protected int getMetricsCategory() {
@@ -69,6 +72,11 @@ public void onCreate(Bundle savedInstanceState) {
int intColor;
String hexColor;
mQsBatteryTitle = (SwitchPreference) findPreference(STATUS_BAR_BATTERY_STYLE_TILE);
mQsBatteryTitle.setChecked((Settings.Secure.getInt(resolver,
Settings.Secure.STATUS_BAR_BATTERY_STYLE_TILE, 1) == 1));
mQsBatteryTitle.setOnPreferenceChangeListener(this);
mStatusBarBattery = (ListPreference) findPreference(STATUS_BAR_BATTERY_STYLE);
mStatusBarBatteryValue = Settings.Secure.getInt(resolver,
Settings.Secure.STATUS_BAR_BATTERY_STYLE, 0);
@@ -117,6 +125,10 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
mStatusBarBatteryShowPercent.getEntries()[index]);
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.STATUS_BAR_SHOW_BATTERY_PERCENT, mStatusBarBatteryShowPercentValue);
} else if (preference == mQsBatteryTitle) {
boolean checked = ((SwitchPreference)preference).isChecked();
Settings.Secure.putInt(getActivity().getContentResolver(),
Settings.Secure.STATUS_BAR_BATTERY_STYLE_TILE, checked ? 1:0);
}
return true;
}
@@ -125,8 +137,12 @@ private void enableStatusBarBatteryDependents(int batteryIconStyle) {
if (batteryIconStyle == STATUS_BAR_BATTERY_STYLE_HIDDEN ||
batteryIconStyle == STATUS_BAR_BATTERY_STYLE_TEXT) {
mStatusBarBatteryShowPercent.setEnabled(false);
mQsBatteryTitle.setEnabled(false);
} else if (batteryIconStyle == STATUS_BAR_BATTERY_STYLE_PORTRAIT) {
mQsBatteryTitle.setEnabled(false);
} else {
mStatusBarBatteryShowPercent.setEnabled(true);
mQsBatteryTitle.setEnabled(true);
}
}

0 comments on commit 992bdba

Please sign in to comment.