diff --git a/res/values/cherish_arrays.xml b/res/values/cherish_arrays.xml
index 587b2e8..f87ebc6 100644
--- a/res/values/cherish_arrays.xml
+++ b/res/values/cherish_arrays.xml
@@ -101,5 +101,67 @@
- 23
- 24
+
+
+
+ - @string/status_bar_battery_percentage_default
+ - @string/status_bar_battery_percentage_text_inside
+ - @string/status_bar_battery_percent_text_next_right
+ - @string/status_bar_battery_percent_text_next_left
+
+
+
+ - 0
+ - 1
+ - 2
+ - 3
+
+
+
+ - @string/status_bar_battery_style_icon_portrait
+ - @string/status_bar_battery_style_circle
+ - @string/status_bar_battery_style_dotted_circle
+ - @string/status_bar_battery_style_filled_circle
+ - @string/status_bar_battery_style_big_circle
+ - @string/status_bar_battery_style_big_dotted_circle
+ - @string/status_bar_battery_style_text
+ - @string/status_bar_battery_style_hidden
+
+
+
+ - 0
+ - 1
+ - 2
+ - 3
+ - 6
+ - 7
+ - 4
+ - 5
+
+
+
+
+ - @string/qs_use_status_bar_battery_style
+ - @string/status_bar_battery_style_icon_portrait
+ - @string/status_bar_battery_style_circle
+ - @string/status_bar_battery_style_dotted_circle
+ - @string/status_bar_battery_style_filled_circle
+ - @string/status_bar_battery_style_big_circle
+ - @string/status_bar_battery_style_big_dotted_circle
+ - @string/status_bar_battery_style_text
+ - @string/status_bar_battery_style_hidden
+
+
+
+ - -1
+ - 0
+ - 1
+ - 2
+ - 3
+ - 6
+ - 7
+ - 4
+ - 5
+
diff --git a/res/values/cherish_strings.xml b/res/values/cherish_strings.xml
index c6d8664..97db634 100644
--- a/res/values/cherish_strings.xml
+++ b/res/values/cherish_strings.xml
@@ -267,5 +267,32 @@
Vimeo Icon
Volit Icon
Ziroc Icon
+
+
+ Battery icon style
+ Customize battery icons, hide or show percentage
+ Battery icon
+ In Status Bar
+ Battery percentage
+ Battery style
+ Icon portrait (default)
+ Circle
+ Circle (Dotted)
+ Circle (Filled)
+ Big circle
+ Big dotted circle
+ Text
+ Hidden
+ Hidden (default)
+ Inside the icon
+ Next to the icon (right)
+ Next to the icon (left)
+ Battery percentage when charging
+ Always display battery percentage when charging
+
+
+ In QS Panel
+ @string/status_bar_battery_percent_title
+ Follow status bar style
diff --git a/res/xml/cherish_settings_statusbar.xml b/res/xml/cherish_settings_statusbar.xml
index 0997408..690bc20 100644
--- a/res/xml/cherish_settings_statusbar.xml
+++ b/res/xml/cherish_settings_statusbar.xml
@@ -21,6 +21,12 @@
android:summary="@string/network_traffic_summary"
android:fragment="com.cherish.settings.fragments.NetworkTrafficSettings" />
+
+
diff --git a/res/xml/statusbar_battery.xml b/res/xml/statusbar_battery.xml
new file mode 100644
index 0000000..44e561b
--- /dev/null
+++ b/res/xml/statusbar_battery.xml
@@ -0,0 +1,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/com/cherish/settings/fragments/StatusBarBattery.java b/src/com/cherish/settings/fragments/StatusBarBattery.java
new file mode 100644
index 0000000..d64d193
--- /dev/null
+++ b/src/com/cherish/settings/fragments/StatusBarBattery.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2017-2019 The Dirty Unicorns Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.cherish.settings.fragments;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.os.Bundle;
+import android.os.UserHandle;
+import android.provider.Settings;
+
+import androidx.preference.PreferenceCategory;
+import androidx.preference.ListPreference;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.Preference.OnPreferenceChangeListener;
+import androidx.preference.SwitchPreference;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.Utils;
+
+import com.cherish.settings.preferences.SystemSettingListPreference;
+import com.cherish.settings.preferences.SystemSettingSwitchPreference;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class StatusBarBattery extends SettingsPreferenceFragment
+ implements Preference.OnPreferenceChangeListener {
+ private static final String STATUS_BAR_SHOW_BATTERY_PERCENT = "status_bar_show_battery_percent";
+ private static final String STATUS_BAR_BATTERY_STYLE = "status_bar_battery_style";
+ private static final String STATUS_BAR_BATTERY_TEXT_CHARGING = "status_bar_battery_text_charging";
+
+ private SwitchPreference mBatteryTextCharging;
+
+ private SystemSettingListPreference mBatteryPercent;
+ private SystemSettingListPreference mBatteryStyle;
+
+ private static final int BATTERY_STYLE_PORTRAIT = 0;
+ private static final int BATTERY_STYLE_TEXT = 4;
+ private static final int BATTERY_STYLE_HIDDEN = 5;
+ private static final int BATTERY_PERCENT_HIDDEN = 0;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.statusbar_battery);
+
+ int batterystyle = Settings.System.getIntForUser(getContentResolver(),
+ Settings.System.STATUS_BAR_BATTERY_STYLE, BATTERY_STYLE_PORTRAIT, UserHandle.USER_CURRENT);
+ int batterypercent = Settings.System.getIntForUser(getContentResolver(),
+ Settings.System.STATUS_BAR_SHOW_BATTERY_PERCENT, 0, UserHandle.USER_CURRENT);
+
+ mBatteryStyle = (SystemSettingListPreference) findPreference(STATUS_BAR_BATTERY_STYLE);
+ mBatteryStyle.setOnPreferenceChangeListener(this);
+
+ mBatteryPercent = (SystemSettingListPreference) findPreference(STATUS_BAR_SHOW_BATTERY_PERCENT);
+ mBatteryPercent.setEnabled(
+ batterystyle != BATTERY_STYLE_TEXT && batterystyle != BATTERY_STYLE_HIDDEN);
+ mBatteryPercent.setOnPreferenceChangeListener(this);
+
+ mBatteryTextCharging = (SwitchPreference) findPreference(STATUS_BAR_BATTERY_TEXT_CHARGING);
+ mBatteryTextCharging.setEnabled(batterystyle == BATTERY_STYLE_HIDDEN ||
+ (batterystyle != BATTERY_STYLE_TEXT && batterypercent != 2));
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ ContentResolver resolver = getActivity().getContentResolver();
+ if (preference == mBatteryStyle) {
+ int value = Integer.parseInt((String) newValue);
+ int batterypercent = Settings.System.getIntForUser(getContentResolver(),
+ Settings.System.STATUS_BAR_SHOW_BATTERY_PERCENT, 0, UserHandle.USER_CURRENT);
+ mBatteryPercent.setEnabled(
+ value != BATTERY_STYLE_TEXT && value != BATTERY_STYLE_HIDDEN);
+ mBatteryTextCharging.setEnabled(value == BATTERY_STYLE_HIDDEN ||
+ (value != BATTERY_STYLE_TEXT && batterypercent != 2));
+ return true;
+ } else if (preference == mBatteryPercent) {
+ int value = Integer.parseInt((String) newValue);
+ int batterystyle = Settings.System.getIntForUser(getContentResolver(),
+ Settings.System.STATUS_BAR_BATTERY_STYLE, BATTERY_STYLE_PORTRAIT, UserHandle.USER_CURRENT);
+ mBatteryTextCharging.setEnabled(batterystyle == BATTERY_STYLE_HIDDEN ||
+ (batterystyle != BATTERY_STYLE_TEXT && value != 2));
+ return true;
+ }
+ return false;
+ }
+
+ public static void reset(Context mContext) {
+ ContentResolver resolver = mContext.getContentResolver();
+ Settings.System.putIntForUser(resolver,
+ Settings.System.STATUS_BAR_BATTERY_STYLE, BATTERY_STYLE_PORTRAIT, UserHandle.USER_CURRENT);
+ Settings.System.putIntForUser(resolver,
+ Settings.System.STATUS_BAR_SHOW_BATTERY_PERCENT, 0, UserHandle.USER_CURRENT);
+ Settings.System.putIntForUser(resolver,
+ Settings.System.STATUS_BAR_BATTERY_TEXT_CHARGING, 1, UserHandle.USER_CURRENT);
+ Settings.System.putIntForUser(resolver,
+ Settings.System.QS_BATTERY_STYLE, -1, UserHandle.USER_CURRENT);
+ Settings.System.putIntForUser(resolver,
+ Settings.System.QS_SHOW_BATTERY_PERCENT, 2, UserHandle.USER_CURRENT);
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return MetricsProto.MetricsEvent.CHERISH_SETTINGS;
+ }
+}
\ No newline at end of file