From 157c794e8a2500483383e6b764c3a1608672da28 Mon Sep 17 00:00:00 2001 From: Pranav Vashi Date: Fri, 17 May 2024 23:57:09 +0900 Subject: [PATCH] Evolver: Battery styles customizations [2/2] Signed-off-by: Pranav Vashi Signed-off-by: AnierinB --- res/values/evolution_arrays.xml | 117 ++++++++++++++++++ res/values/evolution_strings.xml | 32 +++++ res/xml/evolution_settings_quick_settings.xml | 21 ++++ res/xml/evolution_settings_status_bar.xml | 23 ++++ .../quicksettings/QuickSettings.java | 26 ++++ .../fragments/statusbar/StatusBar.java | 46 +++++++ 6 files changed, 265 insertions(+) diff --git a/res/values/evolution_arrays.xml b/res/values/evolution_arrays.xml index 009f227..e68f414 100644 --- a/res/values/evolution_arrays.xml +++ b/res/values/evolution_arrays.xml @@ -94,6 +94,123 @@ 3 + + + @string/status_bar_battery_style_icon_portrait + @string/status_bar_battery_style_icon_rlandscape + @string/status_bar_battery_style_icon_landscape + @string/status_bar_battery_style_icon_landscape_buddy + @string/status_bar_battery_style_icon_landscape_line + @string/status_bar_battery_style_icon_landscape_musku + @string/status_bar_battery_style_icon_landscape_pill + @string/status_bar_battery_style_icon_landscape_signal + @string/status_bar_battery_style_icon_rlandscape_style_a + @string/status_bar_battery_style_icon_landscape_style_a + @string/status_bar_battery_style_icon_rlandscape_style_b + @string/status_bar_battery_style_icon_landscape_style_b + @string/status_bar_battery_style_icon_landscape_ios15 + @string/status_bar_battery_style_icon_landscape_ios16 + @string/status_bar_battery_style_icon_landscape_origami + @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 + 6 + 7 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 1 + 2 + 3 + 8 + 9 + 4 + 5 + + + + @string/status_bar_battery_percent_hidden + @string/status_bar_battery_percent_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_follow_status_bar + @string/status_bar_battery_style_icon_portrait + @string/status_bar_battery_style_icon_rlandscape + @string/status_bar_battery_style_icon_landscape + @string/status_bar_battery_style_icon_landscape_buddy + @string/status_bar_battery_style_icon_landscape_line + @string/status_bar_battery_style_icon_landscape_musku + @string/status_bar_battery_style_icon_landscape_pill + @string/status_bar_battery_style_icon_landscape_signal + @string/status_bar_battery_style_icon_rlandscape_style_a + @string/status_bar_battery_style_icon_landscape_style_a + @string/status_bar_battery_style_icon_rlandscape_style_b + @string/status_bar_battery_style_icon_landscape_style_b + @string/status_bar_battery_style_icon_landscape_ios15 + @string/status_bar_battery_style_icon_landscape_ios16 + @string/status_bar_battery_style_icon_landscape_origami + @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 + 6 + 7 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 1 + 2 + 3 + 8 + 9 + 4 + 5 + + @string/quick_settings_show_brightness_slider_never diff --git a/res/values/evolution_strings.xml b/res/values/evolution_strings.xml index 3c9eace..2d19411 100644 --- a/res/values/evolution_strings.xml +++ b/res/values/evolution_strings.xml @@ -112,6 +112,37 @@ Icons Status bar tuner Choose which system icons can be shown + Battery style + Icon portrait + Icon landscape (Right) + Icon landscape (Left) + Landscape Capsule + Landscape Lorn + Portrait IOS + Portrait Mx + Landscape Airoo + Landscape R Style A + Landscape L Style A + Landscape R Style B + Landscape L Style B + Landscape iOS 15 + Landscape iOS 16 + Landscape Origami + Circle + Dotted circle + Filled circle + Big circle + Big dotted circle + Text + Hidden + Follow status bar style + Battery percent + Hidden + Inside the icon + Next to the icon (right) + Next to the icon (left) + Battery percentage when charging + Always display battery percentage when charging Data disabled indicator Display an indicator next to signal icon when data is disabled 4G icon @@ -133,6 +164,7 @@ Display an indicator when the screen is being projected + Interface Brightness slider Brightness slider Never show diff --git a/res/xml/evolution_settings_quick_settings.xml b/res/xml/evolution_settings_quick_settings.xml index 97d0859..ed6a6c5 100644 --- a/res/xml/evolution_settings_quick_settings.xml +++ b/res/xml/evolution_settings_quick_settings.xml @@ -44,6 +44,27 @@ android:defaultValue="true" /> + + + + + + + + + diff --git a/res/xml/evolution_settings_status_bar.xml b/res/xml/evolution_settings_status_bar.xml index 42b5721..4d00f41 100644 --- a/res/xml/evolution_settings_status_bar.xml +++ b/res/xml/evolution_settings_status_bar.xml @@ -41,6 +41,29 @@ + + + + + + + + + 0); return true; + } else if (preference == mBatteryStyle) { + int value = Integer.parseInt((String) newValue); + mBatteryPercent.setEnabled( + value != BATTERY_STYLE_TEXT && value != BATTERY_STYLE_HIDDEN); + return true; } return false; } diff --git a/src/org/evolution/settings/fragments/statusbar/StatusBar.java b/src/org/evolution/settings/fragments/statusbar/StatusBar.java index e489781..4223f0e 100644 --- a/src/org/evolution/settings/fragments/statusbar/StatusBar.java +++ b/src/org/evolution/settings/fragments/statusbar/StatusBar.java @@ -9,6 +9,8 @@ import android.content.ContentResolver; import android.content.Context; import android.content.res.Resources; import android.os.Bundle; +import android.os.UserHandle; +import android.provider.Settings; import android.view.View; import androidx.preference.Preference; @@ -26,6 +28,7 @@ import java.util.List; import lineageos.preference.LineageSystemSettingListPreference; +import org.evolution.settings.preferences.SystemSettingListPreference; import org.evolution.settings.preferences.SystemSettingSwitchPreference; import org.evolution.settings.utils.DeviceUtils; @@ -38,6 +41,9 @@ public class StatusBar extends SettingsPreferenceFragment implements private static final String KEY_QUICK_PULLDOWN = "qs_quick_pulldown"; private static final String KEY_ICONS_CATEGORY = "status_bar_icons_category"; + private static final String KEY_BATTERY_STYLE = "status_bar_battery_style"; + private static final String KEY_BATTERY_PERCENT = "status_bar_show_battery_percent"; + private static final String KEY_BATTERY_TEXT_CHARGING = "status_bar_battery_text_charging"; private static final String KEY_DATA_DISABLED_ICON = "data_disabled_icon"; private static final String KEY_BLUETOOTH_BATTERY_STATUS = "bluetooth_show_battery"; private static final String KEY_FOUR_G_ICON = "show_fourg_icon"; @@ -46,10 +52,16 @@ public class StatusBar extends SettingsPreferenceFragment implements private static final int PULLDOWN_DIR_RIGHT = 1; private static final int PULLDOWN_DIR_LEFT = 2; private static final int PULLDOWN_DIR_BOTH = 3; + 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 LineageSystemSettingListPreference mQuickPulldown; private PreferenceCategory mIconsCategory; + private SystemSettingListPreference mBatteryPercent; + private SystemSettingListPreference mBatteryStyle; + private SystemSettingSwitchPreference mBatteryTextCharging; private SystemSettingSwitchPreference mDataDisabledIcon; private SystemSettingSwitchPreference mFourgIcon; private SystemSettingSwitchPreference mBluetoothBatteryStatus; @@ -70,6 +82,10 @@ public class StatusBar extends SettingsPreferenceFragment implements updateQuickPulldownSummary(mQuickPulldown.getIntValue(0)); mIconsCategory = (PreferenceCategory) findPreference(KEY_ICONS_CATEGORY); + mBatteryStyle = (SystemSettingListPreference) findPreference(KEY_BATTERY_STYLE); + mBatteryPercent = (SystemSettingListPreference) findPreference(KEY_BATTERY_PERCENT); + mBatteryTextCharging = (SystemSettingSwitchPreference) findPreference(KEY_BATTERY_TEXT_CHARGING); + mBluetoothBatteryStatus = (SystemSettingSwitchPreference) findPreference(KEY_BLUETOOTH_BATTERY_STATUS); mDataDisabledIcon = (SystemSettingSwitchPreference) findPreference(KEY_DATA_DISABLED_ICON); mFourgIcon = (SystemSettingSwitchPreference) findPreference(KEY_FOUR_G_ICON); mBluetoothBatteryStatus = (SystemSettingSwitchPreference) findPreference(KEY_BLUETOOTH_BATTERY_STATUS); @@ -79,6 +95,20 @@ public class StatusBar extends SettingsPreferenceFragment implements mQuickPulldown.setEntryValues(R.array.status_bar_quick_pull_down_values_rtl); } + int batterystyle = Settings.System.getIntForUser(resolver, + Settings.System.STATUS_BAR_BATTERY_STYLE, BATTERY_STYLE_PORTRAIT, UserHandle.USER_CURRENT); + int batterypercent = Settings.System.getIntForUser(resolver, + Settings.System.STATUS_BAR_SHOW_BATTERY_PERCENT, 0, UserHandle.USER_CURRENT); + + mBatteryStyle.setOnPreferenceChangeListener(this); + + mBatteryPercent.setEnabled( + batterystyle != BATTERY_STYLE_TEXT && batterystyle != BATTERY_STYLE_HIDDEN); + mBatteryPercent.setOnPreferenceChangeListener(this); + + mBatteryTextCharging.setEnabled(batterystyle == BATTERY_STYLE_HIDDEN || + (batterystyle != BATTERY_STYLE_TEXT && batterypercent != 2)); + if (!DeviceUtils.deviceSupportsMobileData(context)) { mIconsCategory.removePreference(mDataDisabledIcon); mIconsCategory.removePreference(mFourgIcon); @@ -97,6 +127,22 @@ public class StatusBar extends SettingsPreferenceFragment implements int value = Integer.parseInt((String) newValue); updateQuickPulldownSummary(value); return true; + } else if (preference == mBatteryStyle) { + int value = Integer.parseInt((String) newValue); + int batterypercent = Settings.System.getIntForUser(resolver, + 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(resolver, + 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; }