Battery light customization [2/2]
This commit is contained in:
8
res/drawable/ic_battery_almostfull.xml
Normal file
8
res/drawable/ic_battery_almostfull.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:tint="?android:attr/colorControlNormal"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path android:fillColor="?android:attr/colorControlNormal" android:pathData="M23,11H20V4L15,14H18V22M12,8H4V6H12M12.67,4H11V2H5V4H3.33A1.33,1.33 0 0,0 2,5.33V20.67C2,21.4 2.6,22 3.33,22H12.67C13.4,22 14,21.4 14,20.67V5.33A1.33,1.33 0 0,0 12.67,4Z" />
|
||||
</vector>
|
||||
8
res/drawable/ic_battery_full.xml
Normal file
8
res/drawable/ic_battery_full.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:tint="?android:attr/colorControlNormal"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path android:fillColor="?android:attr/colorControlNormal" android:pathData="M23,11H20V4L15,14H18V22M12.67,4H11V2H5V4H3.33A1.33,1.33 0 0,0 2,5.33V20.67C2,21.4 2.6,22 3.33,22H12.67C13.4,22 14,21.4 14,20.67V5.33A1.33,1.33 0 0,0 12.67,4Z" />
|
||||
</vector>
|
||||
8
res/drawable/ic_battery_low.xml
Normal file
8
res/drawable/ic_battery_low.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:tint="?android:attr/colorControlNormal"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path android:fillColor="?android:attr/colorControlNormal" android:pathData="M23.05,11H20.05V4L15.05,14H18.05V22M12,18H4L4.05,6H12.05M12.72,4H11.05V2H5.05V4H3.38A1.33,1.33 0 0,0 2.05,5.33V20.67C2.05,21.4 2.65,22 3.38,22H12.72C13.45,22 14.05,21.4 14.05,20.67V5.33A1.33,1.33 0 0,0 12.72,4Z" />
|
||||
</vector>
|
||||
8
res/drawable/ic_battery_medium.xml
Normal file
8
res/drawable/ic_battery_medium.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:tint="?android:attr/colorControlNormal"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path android:fillColor="?android:attr/colorControlNormal" android:pathData="M23,11H20V4L15,14H18V22M12,13H4V6H12M12.67,4H11V2H5V4H3.33A1.33,1.33 0 0,0 2,5.33V20.67C2,21.4 2.6,22 3.33,22H12.67C13.4,22 14,21.4 14,20.67V5.33A1.33,1.33 0 0,0 12.67,4Z" />
|
||||
</vector>
|
||||
8
res/drawable/ic_blinking.xml
Normal file
8
res/drawable/ic_blinking.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:tint="?android:attr/colorControlNormal"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path android:fillColor="?android:attr/colorControlNormal" android:pathData="M6,6.9L3.87,4.78L5.28,3.37L7.4,5.5L6,6.9M13,1V4H11V1H13M20.13,4.78L18,6.9L16.6,5.5L18.72,3.37L20.13,4.78M4.5,10.5V12.5H1.5V10.5H4.5M19.5,10.5H22.5V12.5H19.5V10.5M6,20H18A2,2 0 0,1 20,22H4A2,2 0 0,1 6,20M12,5A6,6 0 0,1 18,11V19H6V11A6,6 0 0,1 12,5Z" />
|
||||
</vector>
|
||||
8
res/drawable/ic_dnd.xml
Normal file
8
res/drawable/ic_dnd.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:tint="?android:attr/colorControlNormal"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path android:fillColor="?android:attr/colorControlNormal" android:pathData="M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M17,13H7V11H17V13Z" />
|
||||
</vector>
|
||||
@@ -52,5 +52,4 @@
|
||||
<!-- QS category -->
|
||||
<string name="enable_clear_all_button">Thay thế xóa tất cả văn bản bằng nút đẹp</string>
|
||||
<string name="enable_clear_all_button_summary">Hiển thị xóa tất cả nút thông báo trong cài đặt nhanh thay vì văn bản mặc định</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -244,4 +244,15 @@
|
||||
<string name="advanced_reboot_title">Advanced restart</string>
|
||||
<string name="advanced_reboot_summary">When unlocked, include options in the power menu for restarting into recovery or bootloader</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>
|
||||
|
||||
66
res/xml/battery_light_settings.xml
Normal file
66
res/xml/battery_light_settings.xml
Normal file
@@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2017 The ABC rom
|
||||
|
||||
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">
|
||||
|
||||
<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,9 @@
|
||||
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>
|
||||
|
||||
142
src/com/cherish/settings/fragments/BatteryLightSettings.java
Normal file
142
src/com/cherish/settings/fragments/BatteryLightSettings.java
Normal file
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The ABC rom
|
||||
*
|
||||
* 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.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
|
||||
import com.cherish.settings.preferences.SystemSettingSwitchPreference;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
|
||||
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
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.CHERISH_SETTINGS;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -4,16 +4,41 @@ import com.android.internal.logging.nano.MetricsProto;
|
||||
|
||||
import android.os.Bundle;
|
||||
import com.android.settings.R;
|
||||
import android.content.res.Resources;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.Preference.OnPreferenceChangeListener;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import net.margaritov.preference.colorpicker.ColorPickerPreference;
|
||||
|
||||
public class NotificationSettings extends SettingsPreferenceFragment {
|
||||
public class NotificationSettings extends SettingsPreferenceFragment implements Preference.OnPreferenceChangeListener{
|
||||
|
||||
private ColorPickerPreference mEdgeLightColorPreference;
|
||||
|
||||
private Preference mChargingLeds;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
||||
addPreferencesFromResource(R.xml.cherish_settings_notifications);
|
||||
PreferenceScreen prefScreen = getPreferenceScreen();
|
||||
|
||||
mChargingLeds = (Preference) findPreference("charging_light");
|
||||
if (mChargingLeds != null
|
||||
&& !getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_intrusiveBatteryLed)) {
|
||||
prefScreen.removePreference(mChargingLeds);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user