BatteryPercent: Allow disabling percent inside circle
Change-Id: I832264a74f89968b304ef09bf437f225af5d94d9
diff --git a/res/values/custom_arrays.xml b/res/values/custom_arrays.xml
index 340d3e3..e1d79dc 100644
--- a/res/values/custom_arrays.xml
+++ b/res/values/custom_arrays.xml
@@ -516,6 +516,18 @@
<item>8</item>
</string-array>
+ <!-- Battery circle percent -->
+ <string-array name="battery_percent_entries" translatable="false">
+ <item>@string/battery_percent_none</item>
+ <item>@string/battery_percent_outside</item>
+ <item>@string/battery_percent_inside</item>
+ </string-array>
+ <string-array name="battery_percent_values" translatable="false">
+ <item>0</item>
+ <item>1</item>
+ <item>2</item>
+ </string-array>
+
<string-array name="battery_percent_enable_entries" translatable="false">
<item>@string/battery_percent_none</item>
<item>@string/battery_percent_always</item>
diff --git a/res/values/custom_strings.xml b/res/values/custom_strings.xml
index 585bd2b..a75b527 100644
--- a/res/values/custom_strings.xml
+++ b/res/values/custom_strings.xml
@@ -181,8 +181,7 @@
<string name="statusbar_battery_summary">Set style of status bar battery display</string>
<string name="clock_title">Clock and Date</string>
<string name="statusbar_clock_summary">Set style of status bar clock display</string>
- <string name="battery_style_title">Style</string>
- <string name="statusbar_percent_inside_title">Percent overlay</string>
+ <string name="statusbar_percent_inside_title">Percent overlay</string>
<string name="statusbar_percent_inside_summary">Display battery percentage on top of the the battery image</string>
<string name="statusbar_charging_image_title">Charging indicator</string>
<string name="statusbar_category_charging_title">Charging</string>
@@ -648,6 +647,13 @@
<string name="battery_style_square">Square</string>
<string name="battery_style_dotted_square">Dotted square</string>
<string name="battery_style_text">Text</string>
+ <string name="show_battery_percent_title">Show percentage</string>
+ <string name="battery_percent_none">Don\'t show</string>
+ <string name="battery_percent_outside">Show near icon</string>
+ <string name="battery_percent_inside">Show inside icon</string>
+
+ <string name="battery_percent_always">Always</string>
+ <string name="battery_percent_expanded">Only when expanded</string>
<string name="status_bar_clock">Clock & Date</string>
<string name="clock_title_enable">Alignment</string>
diff --git a/res/xml/bars_settings.xml b/res/xml/bars_settings.xml
index 604eeda..32d0cde 100644
--- a/res/xml/bars_settings.xml
+++ b/res/xml/bars_settings.xml
@@ -36,7 +36,7 @@
<PreferenceCategory
android:key="battery_settings"
- android:title="@string/battery_style_category"/>
+ android:title="@string/battery_style_category">
<ListPreference
android:key="status_bar_battery_style"
android:title="@string/battery_style_title"
@@ -45,6 +45,13 @@
android:entries="@array/status_bar_battery_style_entries"
android:entryValues="@array/status_bar_battery_style_values"
android:defaultValue="0" />
+
+ <ListPreference
+ android:key="show_battery_percent"
+ android:title="@string/show_battery_percent_title"
+ android:entries="@array/battery_percent_entries"
+ android:entryValues="@array/battery_percent_values" />
+
</PreferenceCategory>
<PreferenceCategory
diff --git a/res/xml/lockscreenitems.xml b/res/xml/lockscreenitems.xml
index 1c5288e..43eb498 100644
--- a/res/xml/lockscreenitems.xml
+++ b/res/xml/lockscreenitems.xml
@@ -16,13 +16,14 @@
-->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
android:title="@string/lockscreen_item_title"
android:key="lockscreen_item">
<org.omnirom.omnilib.preference.SecureSettingSwitchPreference
android:key="lockscreen_visualizer_enabled"
- android:title="@string/lockscreen_visualizer_title"
- android:summary="@string/lockscreen_visualizer_summary"
+ android:title="@string/lockscreen_visualizer_enable"
+ android:summary="@string/lockscreen_visualizer_enable_summary"
android:defaultValue="false" />
<org.omnirom.omnilib.preference.SystemSettingSwitchPreference
@@ -34,8 +35,10 @@
<org.omnirom.omnilib.preference.ColorSelectPreference
android:key="lock_screen_visualizer_custom_color"
- android:title="@string/battery_bar_color"
+ android:title="@string/lockscreen_visualizer_custom_color"
android:dependency="lock_screen_visualizer_use_custom_color"
+ settings:multiColor="true"
+ settings:withAlpha="true"
android:defaultValue="0xffffffff"
android:dialogTitle="@string/lockscreen_visualizer_custom_color" />
diff --git a/src/org/omnirom/omnigears/interfacesettings/BarsSettings.java b/src/org/omnirom/omnigears/interfacesettings/BarsSettings.java
index c9ce483..704982a 100644
--- a/src/org/omnirom/omnigears/interfacesettings/BarsSettings.java
+++ b/src/org/omnirom/omnigears/interfacesettings/BarsSettings.java
@@ -55,12 +55,14 @@
private static final String KEY_ASPECT_RATIO_APPS_LIST_SCROLLER = "aspect_ratio_apps_list_scroller";
private static final String KEY_QS_PANEL_ALPHA = "qs_panel_alpha";
private static final String STATUS_BAR_BATTERY_STYLE = "status_bar_battery_style";
+ private static final String BATTERY_PERCENT = "show_battery_percent";
private AppMultiSelectListPreference mAspectRatioAppsSelect;
private ScrollAppsViewPreference mAspectRatioApps;
private SeekBarPreference mQsPanelAlpha;
private ListPreference mStatusBarBattery;
+ private ListPreference mBatteryPercentage;
@Override
public int getMetricsCategory() {
@@ -88,6 +90,16 @@
mStatusBarBattery.setSummary(mStatusBarBattery.getEntry());
mStatusBarBattery.setOnPreferenceChangeListener(this);
+ mBatteryPercentage = (ListPreference) findPreference(BATTERY_PERCENT);
+ int showPercent = Settings.System.getInt(getContentResolver(),
+ Settings.System.SHOW_BATTERY_PERCENT, 1);
+ mBatteryPercentage.setValue(Integer.toString(showPercent));
+ int valueIndex = mBatteryPercentage.findIndexOfValue(String.valueOf(showPercent));
+ mBatteryPercentage.setSummary(mBatteryPercentage.getEntries()[valueIndex]);
+ mBatteryPercentage.setOnPreferenceChangeListener(this);
+ boolean hideForcePercentage = batteryStyle == 8; /*text*/
+ mBatteryPercentage.setEnabled(!hideForcePercentage);
+
final PreferenceCategory aspectRatioCategory =
(PreferenceCategory) getPreferenceScreen().findPreference(KEY_ASPECT_RATIO_CATEGORY);
final boolean supportMaxAspectRatio = getResources().getBoolean(com.android.internal.R.bool.config_haveHigherAspectRatioScreen);
@@ -142,6 +154,13 @@
Settings.Secure.STATUS_BAR_BATTERY_STYLE, clockStyle);
mStatusBarBattery.setSummary(mStatusBarBattery.getEntries()[index]);
return true;
+ } else if (preference == mBatteryPercentage) {
+ int showPercent = Integer.valueOf((String) newValue);
+ int index = mBatteryPercentage.findIndexOfValue((String) newValue);
+ Settings.System.putInt(getActivity().getContentResolver(),
+ Settings.System.SHOW_BATTERY_PERCENT, showPercent);
+ mBatteryPercentage.setSummary(mBatteryPercentage.getEntries()[index]);
+ return true;
}
return false;
}
diff --git a/src/org/omnirom/omnigears/interfacesettings/LockscreenItemSettings.java b/src/org/omnirom/omnigears/interfacesettings/LockscreenItemSettings.java
index 3881121..d099512 100644
--- a/src/org/omnirom/omnigears/interfacesettings/LockscreenItemSettings.java
+++ b/src/org/omnirom/omnigears/interfacesettings/LockscreenItemSettings.java
@@ -62,9 +62,7 @@
int visColor = Settings.System.getInt(resolver,
Settings.System.LOCK_SCREEN_VISUALIZER_CUSTOM_COLOR, 0xff1976D2);
String hexColor = String.format("#%08X", visColor);
- mVisualizerColor.setSummary(visColorHex);
- mVisualizerColor.setNewPreviewColor(visColor);
- mVisualizerColor.setAlphaSliderEnabled(true);
+ mVisualizerColor.setSummary(hexColor);
mVisualizerColor.setOnPreferenceChangeListener(this);
}