Cherish:Battery light customization [2/2]
This commit is contained in:
@@ -109,4 +109,15 @@
|
||||
<!--ThemePicker-->
|
||||
<string name="theme_select_title">Styles and Wallpapers</string>
|
||||
<string name="theme_select_summary">Browse and select installed themes</string>
|
||||
|
||||
<!-- Battery light -->
|
||||
<string name="battery_light_settings">Battery charging light</string>
|
||||
<string name="battery_light_enable">Enable</string>
|
||||
<string name="battery_light_allow_on_dnd_title">Battery light in Do Not Disturb mode</string>
|
||||
<string name="battery_light_low_blinking_title">Blinking light on low battery</string>
|
||||
<string name="battery_light_cat">Battery light color when charging</string>
|
||||
<string name="battery_light_low_color">Low battery</string>
|
||||
<string name="battery_light_medium_color">Medium battery</string>
|
||||
<string name="battery_light_full_color">Almost full battery</string>
|
||||
<string name="battery_light_reallyfull_color">Full (100) battery</string>
|
||||
</resources>
|
||||
|
||||
@@ -16,5 +16,51 @@
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||
android:key="battery_light_enabled"
|
||||
android:icon="@drawable/ic_battery_full"
|
||||
android:title="@string/battery_light_enable"
|
||||
android:defaultValue="true" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||
android:key="battery_light_allow_on_dnd"
|
||||
android:icon="@drawable/ic_dnd"
|
||||
android:title="@string/battery_light_allow_on_dnd_title"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||
android:key="battery_light_low_blinking"
|
||||
android:icon="@drawable/ic_blinking"
|
||||
android:title="@string/battery_light_low_blinking_title"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="battery_light_cat"
|
||||
android:title="@string/battery_light_cat">
|
||||
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
||||
android:key="battery_light_low_color"
|
||||
android:icon="@drawable/ic_battery_low"
|
||||
android:title="@string/battery_light_low_color"
|
||||
android:defaultValue="0xFFFF0000" />
|
||||
|
||||
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
||||
android:key="battery_light_medium_color"
|
||||
android:icon="@drawable/ic_battery_medium"
|
||||
android:title="@string/battery_light_medium_color"
|
||||
android:defaultValue="0xFFFFFF00" />
|
||||
|
||||
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
||||
android:key="battery_light_full_color"
|
||||
android:icon="@drawable/ic_battery_almostfull"
|
||||
android:title="@string/battery_light_full_color"
|
||||
android:defaultValue="0xFFFFFF00" />
|
||||
|
||||
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
||||
android:key="battery_light_reallyfull_color"
|
||||
android:icon="@drawable/ic_battery_full"
|
||||
android:title="@string/battery_light_reallyfull_color"
|
||||
android:defaultValue="0xFF00FF00" />
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
@@ -18,4 +18,10 @@
|
||||
android:title="@string/notifications_title"
|
||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
|
||||
|
||||
<Preference
|
||||
android:key="charging_light"
|
||||
android:icon="@drawable/ic_battery_almostfull"
|
||||
android:fragment="com.cherish.settings.fragments.BatteryLightSettings"
|
||||
android:title="@string/battery_light_settings" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
@@ -36,12 +36,67 @@ import net.margaritov.preference.colorpicker.ColorPickerPreference;
|
||||
public class BatteryLightSettings extends SettingsPreferenceFragment implements
|
||||
Preference.OnPreferenceChangeListener {
|
||||
|
||||
private ColorPickerPreference mLowColor;
|
||||
private ColorPickerPreference mMediumColor;
|
||||
private ColorPickerPreference mFullColor;
|
||||
private ColorPickerPreference mReallyFullColor;
|
||||
private SystemSettingSwitchPreference mLowBatteryBlinking;
|
||||
|
||||
private PreferenceCategory mColorCategory;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.battery_light_settings);
|
||||
|
||||
PreferenceScreen prefSet = getPreferenceScreen();
|
||||
mColorCategory = (PreferenceCategory) findPreference("battery_light_cat");
|
||||
|
||||
mLowBatteryBlinking = (SystemSettingSwitchPreference)prefSet.findPreference("battery_light_low_blinking");
|
||||
if (getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_ledCanPulse)) {
|
||||
mLowBatteryBlinking.setChecked(Settings.System.getIntForUser(getContentResolver(),
|
||||
Settings.System.BATTERY_LIGHT_LOW_BLINKING, 0, UserHandle.USER_CURRENT) == 1);
|
||||
mLowBatteryBlinking.setOnPreferenceChangeListener(this);
|
||||
} else {
|
||||
prefSet.removePreference(mLowBatteryBlinking);
|
||||
}
|
||||
|
||||
if (getResources().getBoolean(com.android.internal.R.bool.config_multiColorBatteryLed)) {
|
||||
int color = Settings.System.getIntForUser(getContentResolver(),
|
||||
Settings.System.BATTERY_LIGHT_LOW_COLOR, 0xFFFF0000,
|
||||
UserHandle.USER_CURRENT);
|
||||
mLowColor = (ColorPickerPreference) findPreference("battery_light_low_color");
|
||||
mLowColor.setAlphaSliderEnabled(true);
|
||||
mLowColor.setNewPreviewColor(color);
|
||||
mLowColor.setOnPreferenceChangeListener(this);
|
||||
|
||||
color = Settings.System.getIntForUser(getContentResolver(),
|
||||
Settings.System.BATTERY_LIGHT_MEDIUM_COLOR, 0xFFFFFF00,
|
||||
UserHandle.USER_CURRENT);
|
||||
mMediumColor = (ColorPickerPreference) findPreference("battery_light_medium_color");
|
||||
mMediumColor.setAlphaSliderEnabled(true);
|
||||
mMediumColor.setNewPreviewColor(color);
|
||||
mMediumColor.setOnPreferenceChangeListener(this);
|
||||
|
||||
color = Settings.System.getIntForUser(getContentResolver(),
|
||||
Settings.System.BATTERY_LIGHT_FULL_COLOR, 0xFFFFFF00,
|
||||
UserHandle.USER_CURRENT);
|
||||
mFullColor = (ColorPickerPreference) findPreference("battery_light_full_color");
|
||||
mFullColor.setAlphaSliderEnabled(true);
|
||||
mFullColor.setNewPreviewColor(color);
|
||||
mFullColor.setOnPreferenceChangeListener(this);
|
||||
|
||||
color = Settings.System.getIntForUser(getContentResolver(),
|
||||
Settings.System.BATTERY_LIGHT_REALLYFULL_COLOR, 0xFF00FF00,
|
||||
UserHandle.USER_CURRENT);
|
||||
mReallyFullColor = (ColorPickerPreference) findPreference("battery_light_reallyfull_color");
|
||||
mReallyFullColor.setAlphaSliderEnabled(true);
|
||||
mReallyFullColor.setNewPreviewColor(color);
|
||||
mReallyFullColor.setOnPreferenceChangeListener(this);
|
||||
} else {
|
||||
prefSet.removePreference(mColorCategory);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -50,7 +105,38 @@ public class BatteryLightSettings extends SettingsPreferenceFragment implements
|
||||
}
|
||||
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
|
||||
if (preference.equals(mLowColor)) {
|
||||
int color = ((Integer) newValue).intValue();
|
||||
Settings.System.putIntForUser(getContentResolver(),
|
||||
Settings.System.BATTERY_LIGHT_LOW_COLOR, color,
|
||||
UserHandle.USER_CURRENT);
|
||||
return true;
|
||||
} else if (preference.equals(mMediumColor)) {
|
||||
int color = ((Integer) newValue).intValue();
|
||||
Settings.System.putIntForUser(getContentResolver(),
|
||||
Settings.System.BATTERY_LIGHT_MEDIUM_COLOR, color,
|
||||
UserHandle.USER_CURRENT);
|
||||
return true;
|
||||
} else if (preference.equals(mFullColor)) {
|
||||
int color = ((Integer) newValue).intValue();
|
||||
Settings.System.putIntForUser(getContentResolver(),
|
||||
Settings.System.BATTERY_LIGHT_FULL_COLOR, color,
|
||||
UserHandle.USER_CURRENT);
|
||||
return true;
|
||||
} else if (preference.equals(mReallyFullColor)) {
|
||||
int color = ((Integer) newValue).intValue();
|
||||
Settings.System.putIntForUser(getContentResolver(),
|
||||
Settings.System.BATTERY_LIGHT_REALLYFULL_COLOR, color,
|
||||
UserHandle.USER_CURRENT);
|
||||
return true;
|
||||
} else if (preference == mLowBatteryBlinking) {
|
||||
boolean value = (Boolean) newValue;
|
||||
Settings.System.putIntForUser(getActivity().getContentResolver(),
|
||||
Settings.System.BATTERY_LIGHT_LOW_BLINKING, value ? 1 : 0,
|
||||
UserHandle.USER_CURRENT);
|
||||
mLowBatteryBlinking.setChecked(value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ import net.margaritov.preference.colorpicker.ColorPickerPreference;
|
||||
|
||||
public class NotificationSettings extends SettingsPreferenceFragment implements Preference.OnPreferenceChangeListener{
|
||||
|
||||
private Preference mChargingLeds;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
@@ -28,6 +30,13 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
||||
addPreferencesFromResource(R.xml.cherish_settings_notifications);
|
||||
PreferenceScreen prefScreen = getPreferenceScreen();
|
||||
ContentResolver resolver = getActivity().getContentResolver();
|
||||
|
||||
mChargingLeds = (Preference) findPreference("charging_light");
|
||||
if (mChargingLeds != null
|
||||
&& !getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_intrusiveBatteryLed)) {
|
||||
prefScreen.removePreference(mChargingLeds);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user