Cherish: Add BatteryBar customizations [2/2]
Change-Id: I6ffcb245db5479e8d818cc31ceb573e17e38f0bb Signed-off-by: Shubham Singh <coolsks94@gmail.com> Signed-off-by: SagarMakhar <sagarmakhar@gmail.com> Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
@@ -767,4 +767,41 @@
|
|||||||
<item>0</item>
|
<item>0</item>
|
||||||
<item>1</item>
|
<item>1</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Battery bar -->
|
||||||
|
<string-array name="battery_bar_entries">
|
||||||
|
<item>@string/battery_bar_location_hide</item>
|
||||||
|
<item>@string/battery_bar_location_statusbar</item>
|
||||||
|
<item>@string/battery_bar_location_top_navbar</item>
|
||||||
|
<item>@string/battery_bar_location_bottom_navbar</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="battery_bar_values" translatable="false">
|
||||||
|
<item>0</item>
|
||||||
|
<item>1</item>
|
||||||
|
<item>2</item>
|
||||||
|
<item>3</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="battery_bar_no_navbar_entries">
|
||||||
|
<item>@string/battery_bar_location_hide</item>
|
||||||
|
<item>@string/battery_bar_location_statusbar</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="battery_bar_no_navbar_values" translatable="false">
|
||||||
|
<item>0</item>
|
||||||
|
<item>1</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="battery_bar_style_entries" translatable="false">
|
||||||
|
<item>@string/battery_bar_style_regular</item>
|
||||||
|
<item>@string/battery_bar_style_center_mirrored</item>
|
||||||
|
<item>@string/battery_bar_style_reversed</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="battery_bar_style_values" translatable="false">
|
||||||
|
<item>0</item>
|
||||||
|
<item>1</item>
|
||||||
|
<item>2</item>
|
||||||
|
</string-array>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -787,4 +787,30 @@
|
|||||||
<string name="clock_date_left">Left of time</string>
|
<string name="clock_date_left">Left of time</string>
|
||||||
<string name="clock_date_position">Date position</string>
|
<string name="clock_date_position">Date position</string>
|
||||||
|
|
||||||
|
<!-- Battery Bar -->
|
||||||
|
<string name="battery_bar_title">Battery bar</string>
|
||||||
|
<string name="battery_bar_summary">Display and customize battery bar near status bar or navigation bar</string>
|
||||||
|
<string name="battery_bar">Battery bar location</string>
|
||||||
|
<string name="battery_bar_no_navbar">Battery bar location</string>
|
||||||
|
<string name="battery_bar_location_hide">Hide</string>
|
||||||
|
<string name="battery_bar_location_statusbar">Statusbar</string>
|
||||||
|
<string name="battery_bar_location_top_navbar">Top of navbar</string>
|
||||||
|
<string name="battery_bar_location_bottom_navbar">Bottom of navbar</string>
|
||||||
|
<string name="battery_bar_color">Battery bar color</string>
|
||||||
|
<string name="battery_bar_charging_color">Battery bar charging color</string>
|
||||||
|
<string name="battery_bar_battery_low_color">Battery bar low battery color</string>
|
||||||
|
<string name="battery_bar_cat">Battery bar style</string>
|
||||||
|
<string name="battery_bar_style_title">Battery bar alignment</string>
|
||||||
|
<string name="battery_bar_thickness_title">Battery bar thickness</string>
|
||||||
|
<string name="battery_bar_animate_title">Charging animation</string>
|
||||||
|
<string name="battery_bar_style_regular">Regular</string>
|
||||||
|
<string name="battery_bar_style_center_mirrored">Center-mirrored</string>
|
||||||
|
<string name="battery_bar_style_reversed">Reversed</string>
|
||||||
|
<string name="battery_bar_use_charging_color">Custom charging color</string>
|
||||||
|
<string name="battery_bar_blend_color_title">Blend colors</string>
|
||||||
|
<string name="battery_bar_blend_color_summary">Blend full/empty colors corresponding to battery percentage</string>
|
||||||
|
<string name="battery_bar_blend_color_reverse_title">Reverse color direction</string>
|
||||||
|
<string name="battery_bar_blend_color_reverse_summary_off">Full → empty: red ← green ← blue ← red</string>
|
||||||
|
<string name="battery_bar_blend_color_reverse_summary_on">Full → empty: red → green → blue → red</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
88
res/xml/battery_bar.xml
Normal file
88
res/xml/battery_bar.xml
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2019-2020 The Evolution X 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
|
||||||
|
android:title="@string/battery_bar_title">
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
android:key="statusbar_battery_bar_list"
|
||||||
|
android:title="@string/battery_bar"
|
||||||
|
android:entries="@array/battery_bar_entries"
|
||||||
|
android:entryValues="@array/battery_bar_values" />
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
android:key="statusbar_battery_bar_no_navbar_list"
|
||||||
|
android:title="@string/battery_bar_no_navbar"
|
||||||
|
android:entries="@array/battery_bar_no_navbar_entries"
|
||||||
|
android:entryValues="@array/battery_bar_no_navbar_values" />
|
||||||
|
|
||||||
|
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
||||||
|
android:key="statusbar_battery_bar_color"
|
||||||
|
android:title="@string/battery_bar_color"
|
||||||
|
android:defaultValue="0xffffff" />
|
||||||
|
|
||||||
|
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
||||||
|
android:key="statusbar_battery_bar_battery_low_color"
|
||||||
|
android:title="@string/battery_bar_battery_low_color"
|
||||||
|
android:defaultValue="0xffffff" />
|
||||||
|
|
||||||
|
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||||
|
android:key="statusbar_battery_bar_enable_charging_color"
|
||||||
|
android:title="@string/battery_bar_use_charging_color"
|
||||||
|
android:defaultValue="true" />
|
||||||
|
|
||||||
|
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
||||||
|
android:key="statusbar_battery_bar_charging_color"
|
||||||
|
android:title="@string/battery_bar_charging_color"
|
||||||
|
android:defaultValue="0xffffff"
|
||||||
|
android:dependency="statusbar_battery_bar_enable_charging_color" />
|
||||||
|
|
||||||
|
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||||
|
android:key="statusbar_battery_bar_blend_color"
|
||||||
|
android:title="@string/battery_bar_blend_color_title"
|
||||||
|
android:summary="@string/battery_bar_blend_color_summary"
|
||||||
|
android:defaultValue="false" />
|
||||||
|
|
||||||
|
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||||
|
android:key="statusbar_battery_bar_blend_color_reverse"
|
||||||
|
android:title="@string/battery_bar_blend_color_reverse_title"
|
||||||
|
android:summaryOn="@string/battery_bar_blend_color_reverse_summary_on"
|
||||||
|
android:summaryOff="@string/battery_bar_blend_color_reverse_summary_off"
|
||||||
|
android:dependency="statusbar_battery_bar_blend_color"
|
||||||
|
android:defaultValue="false" />
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
android:key="statusbar_battery_bar_style"
|
||||||
|
android:title="@string/battery_bar_style_title"
|
||||||
|
android:entries="@array/battery_bar_style_entries"
|
||||||
|
android:entryValues="@array/battery_bar_style_values" />
|
||||||
|
|
||||||
|
<com.cherish.settings.preferences.CustomSeekBarPreference
|
||||||
|
android:key="statusbar_battery_bar_thickness"
|
||||||
|
android:title="@string/battery_bar_thickness_title"
|
||||||
|
android:max="4"
|
||||||
|
settings:min="1"
|
||||||
|
settings:units="dp"
|
||||||
|
android:persistent="false" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="statusbar_battery_bar_animate"
|
||||||
|
android:title="@string/battery_bar_animate_title" />
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
||||||
@@ -130,5 +130,12 @@
|
|||||||
android:summary="@string/status_bar_battery_text_charging_summary"
|
android:summary="@string/status_bar_battery_text_charging_summary"
|
||||||
android:defaultValue="true" />
|
android:defaultValue="true" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="battery_bar_category"
|
||||||
|
android:title="@string/battery_bar_title"
|
||||||
|
android:icon="@drawable/ic_battery_bar"
|
||||||
|
android:summary="@string/battery_bar_summary"
|
||||||
|
android:fragment="com.cherish.settings.fragments.BatteryBarSettings" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|||||||
274
src/com/cherish/settings/fragments/BatteryBarSettings.java
Normal file
274
src/com/cherish/settings/fragments/BatteryBarSettings.java
Normal file
@@ -0,0 +1,274 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019-2020 The Evolution X 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.content.res.Resources;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.UserHandle;
|
||||||
|
import android.provider.SearchIndexableResource;
|
||||||
|
import android.provider.Settings;
|
||||||
|
|
||||||
|
import androidx.preference.ListPreference;
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.Preference.OnPreferenceChangeListener;
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
import androidx.preference.SwitchPreference;
|
||||||
|
|
||||||
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
|
import com.android.settingslib.search.SearchIndexable;
|
||||||
|
|
||||||
|
import com.cherish.settings.preferences.CustomSeekBarPreference;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.margaritov.preference.colorpicker.ColorPickerPreference;
|
||||||
|
|
||||||
|
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||||
|
public class BatteryBarSettings extends SettingsPreferenceFragment
|
||||||
|
implements Preference.OnPreferenceChangeListener {
|
||||||
|
|
||||||
|
private static final String PREF_BATT_BAR = "statusbar_battery_bar_list";
|
||||||
|
private static final String PREF_BATT_BAR_NO_NAVBAR = "statusbar_battery_bar_no_navbar_list";
|
||||||
|
private static final String PREF_BATT_BAR_STYLE = "statusbar_battery_bar_style";
|
||||||
|
private static final String PREF_BATT_BAR_COLOR = "statusbar_battery_bar_color";
|
||||||
|
private static final String PREF_BATT_BAR_CHARGING_COLOR = "statusbar_battery_bar_charging_color";
|
||||||
|
private static final String PREF_BATT_BAR_BATTERY_LOW_COLOR = "statusbar_battery_bar_battery_low_color";
|
||||||
|
private static final String PREF_BATT_BAR_WIDTH = "statusbar_battery_bar_thickness";
|
||||||
|
private static final String PREF_BATT_ANIMATE = "statusbar_battery_bar_animate";
|
||||||
|
private static final String PREF_BATT_USE_CHARGING_COLOR = "statusbar_battery_bar_enable_charging_color";
|
||||||
|
private static final String PREF_BATT_BLEND_COLOR = "statusbar_battery_bar_blend_color";
|
||||||
|
private static final String PREF_BATT_BLEND_COLOR_REVERSE = "statusbar_battery_bar_blend_color_reverse";
|
||||||
|
|
||||||
|
private ListPreference mBatteryBar;
|
||||||
|
private ListPreference mBatteryBarNoNavbar;
|
||||||
|
private ListPreference mBatteryBarStyle;
|
||||||
|
private CustomSeekBarPreference mBatteryBarThickness;
|
||||||
|
private SwitchPreference mBatteryBarChargingAnimation;
|
||||||
|
private SwitchPreference mBatteryBarUseChargingColor;
|
||||||
|
private SwitchPreference mBatteryBarBlendColor;
|
||||||
|
private SwitchPreference mBatteryBarBlendColorReverse;
|
||||||
|
private ColorPickerPreference mBatteryBarColor;
|
||||||
|
private ColorPickerPreference mBatteryBarChargingColor;
|
||||||
|
private ColorPickerPreference mBatteryBarBatteryLowColor;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
addPreferencesFromResource(R.xml.battery_bar);
|
||||||
|
|
||||||
|
PreferenceScreen prefSet = getPreferenceScreen();
|
||||||
|
ContentResolver resolver = getActivity().getContentResolver();
|
||||||
|
|
||||||
|
int intColor;
|
||||||
|
String hexColor;
|
||||||
|
|
||||||
|
mBatteryBar = (ListPreference) prefSet.findPreference(PREF_BATT_BAR);
|
||||||
|
mBatteryBar.setValue((Settings.System.getInt(resolver, Settings.System.STATUSBAR_BATTERY_BAR, 0)) + "");
|
||||||
|
mBatteryBar.setSummary(mBatteryBar.getEntry());
|
||||||
|
mBatteryBar.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
|
mBatteryBarNoNavbar = (ListPreference) prefSet.findPreference(PREF_BATT_BAR_NO_NAVBAR);
|
||||||
|
mBatteryBarNoNavbar.setValue((Settings.System.getInt(resolver, Settings.System.STATUSBAR_BATTERY_BAR, 0)) + "");
|
||||||
|
mBatteryBarNoNavbar.setSummary(mBatteryBarNoNavbar.getEntry());
|
||||||
|
mBatteryBarNoNavbar.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
|
mBatteryBarStyle = (ListPreference) prefSet.findPreference(PREF_BATT_BAR_STYLE);
|
||||||
|
mBatteryBarStyle.setValue((Settings.System.getInt(resolver,
|
||||||
|
Settings.System.STATUSBAR_BATTERY_BAR_STYLE, 0)) + "");
|
||||||
|
mBatteryBarStyle.setSummary(mBatteryBarStyle.getEntry());
|
||||||
|
mBatteryBarStyle.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
|
mBatteryBarColor = (ColorPickerPreference) prefSet.findPreference(PREF_BATT_BAR_COLOR);
|
||||||
|
intColor = Settings.System.getInt(resolver, Settings.System.STATUSBAR_BATTERY_BAR_COLOR, Color.WHITE);
|
||||||
|
hexColor = String.format("#%08x", (0xffffff & intColor));
|
||||||
|
mBatteryBarColor.setNewPreviewColor(intColor);
|
||||||
|
mBatteryBarColor.setSummary(hexColor);
|
||||||
|
mBatteryBarColor.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
|
mBatteryBarChargingColor = (ColorPickerPreference) prefSet.findPreference(PREF_BATT_BAR_CHARGING_COLOR);
|
||||||
|
intColor = Settings.System.getInt(resolver, Settings.System.STATUSBAR_BATTERY_BAR_CHARGING_COLOR, Color.WHITE);
|
||||||
|
hexColor = String.format("#%08x", (0xffffff & intColor));
|
||||||
|
mBatteryBarChargingColor.setNewPreviewColor(intColor);
|
||||||
|
mBatteryBarChargingColor.setSummary(hexColor);
|
||||||
|
mBatteryBarChargingColor.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
|
mBatteryBarBatteryLowColor = (ColorPickerPreference) prefSet.findPreference(PREF_BATT_BAR_BATTERY_LOW_COLOR);
|
||||||
|
intColor = Settings.System.getInt(resolver, Settings.System.STATUSBAR_BATTERY_BAR_BATTERY_LOW_COLOR, Color.WHITE);
|
||||||
|
hexColor = String.format("#%08x", (0xffffff & intColor));
|
||||||
|
mBatteryBarBatteryLowColor.setNewPreviewColor(intColor);
|
||||||
|
mBatteryBarBatteryLowColor.setSummary(hexColor);
|
||||||
|
mBatteryBarBatteryLowColor.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
|
mBatteryBarChargingAnimation = (SwitchPreference) prefSet.findPreference(PREF_BATT_ANIMATE);
|
||||||
|
mBatteryBarChargingAnimation.setChecked(Settings.System.getInt(resolver,
|
||||||
|
Settings.System.STATUSBAR_BATTERY_BAR_ANIMATE, 0) == 1);
|
||||||
|
mBatteryBarChargingAnimation.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
|
mBatteryBarThickness = (CustomSeekBarPreference) prefSet.findPreference(PREF_BATT_BAR_WIDTH);
|
||||||
|
mBatteryBarThickness.setValue(Settings.System.getInt(resolver,
|
||||||
|
Settings.System.STATUSBAR_BATTERY_BAR_THICKNESS, 1));
|
||||||
|
mBatteryBarThickness.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
|
mBatteryBarUseChargingColor = (SwitchPreference) findPreference(PREF_BATT_USE_CHARGING_COLOR);
|
||||||
|
mBatteryBarBlendColor = (SwitchPreference) findPreference(PREF_BATT_BLEND_COLOR);
|
||||||
|
mBatteryBarBlendColorReverse = (SwitchPreference) findPreference(PREF_BATT_BLEND_COLOR_REVERSE);
|
||||||
|
|
||||||
|
/*
|
||||||
|
boolean hasNavBarByDefault = getResources().getBoolean(
|
||||||
|
com.android.internal.R.bool.config_showNavigationBar);
|
||||||
|
boolean enableNavigationBar = Settings.Secure.getInt(resolver,
|
||||||
|
Settings.Secure.NAVIGATION_BAR_VISIBLE, hasNavBarByDefault ? 1 : 0) == 1;
|
||||||
|
boolean batteryBarSupported = Settings.Secure.getInt(resolver,
|
||||||
|
Settings.Secure.NAVIGATION_BAR_MODE, 0) == 0;
|
||||||
|
if (!enableNavigationBar || !batteryBarSupported) {
|
||||||
|
*/
|
||||||
|
prefSet.removePreference(mBatteryBar);
|
||||||
|
/*
|
||||||
|
} else {
|
||||||
|
prefSet.removePreference(mBatteryBarNoNavbar);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
updateBatteryBarOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
ContentResolver resolver = getActivity().getContentResolver();
|
||||||
|
if (preference == mBatteryBarColor) {
|
||||||
|
String hex = ColorPickerPreference.convertToARGB(Integer
|
||||||
|
.parseInt(String.valueOf(newValue)));
|
||||||
|
preference.setSummary(hex);
|
||||||
|
int intHex = ColorPickerPreference.convertToColorInt(hex);
|
||||||
|
Settings.System.putInt(resolver,
|
||||||
|
Settings.System.STATUSBAR_BATTERY_BAR_COLOR, intHex);
|
||||||
|
return true;
|
||||||
|
} else if (preference == mBatteryBarChargingColor) {
|
||||||
|
String hex = ColorPickerPreference.convertToARGB(Integer
|
||||||
|
.parseInt(String.valueOf(newValue)));
|
||||||
|
preference.setSummary(hex);
|
||||||
|
int intHex = ColorPickerPreference.convertToColorInt(hex);
|
||||||
|
Settings.System.putInt(resolver,
|
||||||
|
Settings.System.STATUSBAR_BATTERY_BAR_CHARGING_COLOR, intHex);
|
||||||
|
return true;
|
||||||
|
} else if (preference == mBatteryBarBatteryLowColor) {
|
||||||
|
String hex = ColorPickerPreference.convertToARGB(Integer
|
||||||
|
.parseInt(String.valueOf(newValue)));
|
||||||
|
preference.setSummary(hex);
|
||||||
|
int intHex = ColorPickerPreference.convertToColorInt(hex);
|
||||||
|
Settings.System.putInt(resolver,
|
||||||
|
Settings.System.STATUSBAR_BATTERY_BAR_BATTERY_LOW_COLOR, intHex);
|
||||||
|
return true;
|
||||||
|
} else if (preference == mBatteryBar) {
|
||||||
|
int val = Integer.parseInt((String) newValue);
|
||||||
|
int index = mBatteryBar.findIndexOfValue((String) newValue);
|
||||||
|
Settings.System.putInt(resolver,
|
||||||
|
Settings.System.STATUSBAR_BATTERY_BAR, val);
|
||||||
|
mBatteryBar.setSummary(mBatteryBar.getEntries()[index]);
|
||||||
|
updateBatteryBarOptions();
|
||||||
|
} else if (preference == mBatteryBarNoNavbar) {
|
||||||
|
int val = Integer.parseInt((String) newValue);
|
||||||
|
int index = mBatteryBarNoNavbar.findIndexOfValue((String) newValue);
|
||||||
|
Settings.System.putInt(resolver,
|
||||||
|
Settings.System.STATUSBAR_BATTERY_BAR, val);
|
||||||
|
mBatteryBarNoNavbar.setSummary(mBatteryBarNoNavbar.getEntries()[index]);
|
||||||
|
updateBatteryBarOptions();
|
||||||
|
return true;
|
||||||
|
} else if (preference == mBatteryBarStyle) {
|
||||||
|
int val = Integer.parseInt((String) newValue);
|
||||||
|
int index = mBatteryBarStyle.findIndexOfValue((String) newValue);
|
||||||
|
Settings.System.putInt(resolver,
|
||||||
|
Settings.System.STATUSBAR_BATTERY_BAR_STYLE, val);
|
||||||
|
mBatteryBarStyle.setSummary(mBatteryBarStyle.getEntries()[index]);
|
||||||
|
return true;
|
||||||
|
} else if (preference == mBatteryBarThickness) {
|
||||||
|
int val = (Integer) newValue;
|
||||||
|
Settings.System.putInt(resolver,
|
||||||
|
Settings.System.STATUSBAR_BATTERY_BAR_THICKNESS, val);
|
||||||
|
return true;
|
||||||
|
} else if (preference == mBatteryBarChargingAnimation) {
|
||||||
|
int val = ((Boolean) newValue) ? 1 : 0;
|
||||||
|
Settings.System.putInt(resolver, Settings.System.STATUSBAR_BATTERY_BAR_ANIMATE, val);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateBatteryBarOptions() {
|
||||||
|
if (Settings.System.getInt(getActivity().getContentResolver(),
|
||||||
|
Settings.System.STATUSBAR_BATTERY_BAR, 0) == 0) {
|
||||||
|
mBatteryBarStyle.setEnabled(false);
|
||||||
|
mBatteryBarThickness.setEnabled(false);
|
||||||
|
mBatteryBarChargingAnimation.setEnabled(false);
|
||||||
|
mBatteryBarColor.setEnabled(false);
|
||||||
|
mBatteryBarChargingColor.setEnabled(false);
|
||||||
|
mBatteryBarBatteryLowColor.setEnabled(false);
|
||||||
|
mBatteryBarUseChargingColor.setEnabled(false);
|
||||||
|
mBatteryBarBlendColor.setEnabled(false);
|
||||||
|
mBatteryBarBlendColorReverse.setEnabled(false);
|
||||||
|
} else {
|
||||||
|
mBatteryBarStyle.setEnabled(true);
|
||||||
|
mBatteryBarThickness.setEnabled(true);
|
||||||
|
mBatteryBarChargingAnimation.setEnabled(true);
|
||||||
|
mBatteryBarColor.setEnabled(true);
|
||||||
|
mBatteryBarChargingColor.setEnabled(true);
|
||||||
|
mBatteryBarBatteryLowColor.setEnabled(true);
|
||||||
|
mBatteryBarUseChargingColor.setEnabled(true);
|
||||||
|
mBatteryBarBlendColor.setEnabled(true);
|
||||||
|
mBatteryBarBlendColorReverse.setEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetricsCategory() {
|
||||||
|
return MetricsEvent.CHERISH_SETTINGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For Search.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||||
|
new BaseSearchIndexProvider() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||||
|
boolean enabled) {
|
||||||
|
ArrayList<SearchIndexableResource> result =
|
||||||
|
new ArrayList<SearchIndexableResource>();
|
||||||
|
SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||||
|
sir.xmlResId = R.xml.battery_bar;
|
||||||
|
result.add(sir);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getNonIndexableKeys(Context context) {
|
||||||
|
List<String> keys = super.getNonIndexableKeys(context);
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user