[SQUASH]DerpQuest: Add Battery Bar [2/2]

AquariOS:
    Fixed color preferences to stick - @calebcabob

I'd like to thank and show respect to the following contributors for this
fantastic feature

Lokesh Chamane <lokesh.chamane@pac-rom.com>
SpiritCroc <spiritcroc@gmail.com>
westcripp <korukaltan@gmail.com>

commit fe5fa0cb0b74348d5e0e8172b17ab0f2d272dbf3
Author: Lokesh Chamane <lokesh.chamane@pac-rom.com>
Date:   Thu Aug 4 23:37:17 2016 -0600

    BatteryBar: Gradient Color [2/2]

    Change-Id: If85baf2e724f9c6cdef868af323be039b47e49ad
    Signed-off-by: mydongistiny <jaysonedson@gmail.com>

commit 0f046e9887f547ff130a925d02d75d0a74b369f4
Author: SpiritCroc <spiritcroc@gmail.com>
Date:   Mon May 2 02:52:00 2016 -0700

    Battery bar enhancements [2/2]

    Add color settings for charging & low battery
    Add reversed alignment setting

    Change-Id: I51f7e0499971ed344d8faa6e63d4f89558946cb7
    Signed-off-by: mydongistiny <jaysonedson@gmail.com>

commit be722a66ed4243831c48f45997a4cf1c442bc335
Author: westcripp <korukaltan@gmail.com>
Date:   Sat Jan 10 04:14:45 2015 +0200

    Settings: Add back batterybar [2/2]

    Change-Id: I67b0a971fe9f0b6f5443d8ca7336d5e28e86bccd
    Signed-off-by: mydongistiny <jaysonedson@gmail.com>

Change-Id: I4ad46c0e294b8fcf443926b5bb6d11930d981f91

@idoybh (DerpFest) edits:
    * Improved and simplified the code
    * Converted to a MasterSwitchPreference
    * Added to settings search index

Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
bigrushdog
2019-02-23 13:01:23 -08:00
committed by Hưng Phan
parent fad857d2ba
commit f9657adfb8
8 changed files with 412 additions and 0 deletions

View File

@@ -45,6 +45,7 @@ public class StatusBarSettings extends SettingsPreferenceFragment implements
private static final String STATUS_BAR_BATTERY_CHARGING_BOLT = "status_bar_battery_charging_bolt";
private static final String BATTERY_PERCENTAGE_HIDDEN = "0";
private static final String STATUS_BAR_BATTERY_STYLE = "status_bar_battery_style";
private static final String BATTERY_BAR = "battery_bar_settings";
private static final int BATTERY_STYLE_Q = 0;
private static final int BATTERY_STYLE_DOTTED_CIRCLE = 1;
@@ -59,6 +60,7 @@ public class StatusBarSettings extends SettingsPreferenceFragment implements
private CustomSeekBarPreference mThreshold;
private SystemSettingSwitchPreference mNetMonitor;
private SwitchPreference mBatteryBolt;
private SystemSettingMasterSwitchPreference mBatteryBar;
@Override
public void onCreate(Bundle icicle) {
@@ -101,6 +103,13 @@ public class StatusBarSettings extends SettingsPreferenceFragment implements
mThreshold.setValue(value);
mThreshold.setOnPreferenceChangeListener(this);
mThreshold.setEnabled(isNetMonitorEnabled);
mBatteryBar = (SystemSettingMasterSwitchPreference)
findPreference(BATTERY_BAR);
mBatteryBar.setOnPreferenceChangeListener(this);
boolean enabled = Settings.System.getInt(resolver,
Settings.System.BATTERY_BAR_LOCATION, 0) != 0;
mBatteryBar.setChecked(enabled);
}
@Override
@@ -141,6 +150,11 @@ public class StatusBarSettings extends SettingsPreferenceFragment implements
Settings.System.STATUS_BAR_BATTERY_CHARGING_BOLT,
enabled ? 1 : 0);
return true;
} else if (preference == mBatteryBar) {
boolean enabled = (boolean) objValue;
Settings.System.putInt(getActivity().getContentResolver(),
Settings.System.BATTERY_BAR_LOCATION, enabled ? 1 : 0);
return true;
}
return false;