OmniControl: add battery lights settings

Change-Id: I2716104ea927096fc010eaef776ae838eb1c6294
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 4a39a00..2821f80 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -29,6 +29,7 @@
         <entry key="app/src/main/res/drawable/ic_launcher_foreground.xml" value="0.2869791666666667" />
         <entry key="app/src/main/res/drawable/ic_lockscreen_tile.xml" value="0.5130208333333334" />
         <entry key="app/src/main/res/drawable/ic_settings_buttons.xml" value="0.3078125" />
+        <entry key="app/src/main/res/drawable/ic_settings_leds.xml" value="4979166666666667" />
         <entry key="app/src/main/res/drawable/ic_settings_more.xml" value="0.30885416666666665" />
         <entry key="app/src/main/res/drawable/ic_settings_omnigears.xml" value="0.3098958333333333" />
         <entry key="app/src/main/res/drawable/ic_settings_overlays.xml" value="0.3078125" />
@@ -60,6 +61,7 @@
         <entry key="app/src/main/res/menu/bottom_navigation.xml" value="0.2375" />
         <entry key="app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml" value="0.3067708333333333" />
         <entry key="app/src/main/res/xml/applist_preferences.xml" value="0.4979166666666667" />
+        <entry key="app/src/main/res/xml/battery_light_settings_preferences.xml" value="0.4979166666666667" />
         <entry key="app/src/main/res/xml/bars_settings_preferences.xml" value="0.3098958333333333" />
         <entry key="app/src/main/res/xml/bottom_navigation.xml" value="0.2375" />
         <entry key="app/src/main/res/xml/button_settings_preferences.xml" value="0.4979166666666667" />
diff --git a/app/src/main/java/org/omnirom/control/BatteryLightSettingsFragment.java b/app/src/main/java/org/omnirom/control/BatteryLightSettingsFragment.java
new file mode 100644
index 0000000..8d19dff
--- /dev/null
+++ b/app/src/main/java/org/omnirom/control/BatteryLightSettingsFragment.java
@@ -0,0 +1,312 @@
+/*
+ * Copyright (C) 2012 The CyanogenMod Project
+ * Copyright (C) 2021 The OmniROM 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 org.omnirom.control;
+
+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 androidx.preference.Preference;
+import androidx.preference.PreferenceGroup;
+import androidx.preference.PreferenceScreen;
+
+import org.omnirom.control.R;
+import org.omnirom.omnilib.preference.ColorSelectPreference;
+import org.omnirom.omnilib.preference.SystemSettingSwitchPreference;
+
+public class BatteryLightSettingsFragment extends AbstractSettingsFragment implements
+                    Preference.OnPreferenceChangeListener {
+
+    private static final String DEFAULT_VALUES = "reset_to_default_key";
+    private static final String LOW_COLOR_PREF = "low_color";
+    private static final String MEDIUM_COLOR_PREF = "medium_color";
+    private static final String FULL_COLOR_PREF = "full_color";
+    private static final String REALLY_FULL_COLOR_PREF = "really_full_color";
+    private static final String KEY_CATEGORY_GENERAL = "general_section";
+    private static final String FAST_COLOR_PREF = "fast_color";
+    private static final String FAST_CHARGING_LED_PREF = "fast_charging_led_enabled";
+    private static final String BATTERY_DND_PREF = "battery_light_allow_on_dnd";
+    private static final String BATTERY_LIGHT_PREF = "battery_light_enabled";
+    private static final String BATTERY_PULSE_PREF = "battery_light_pulse";
+    private static final String BATTERY_LIGHT_ONLY_FULL_PREF = "battery_light_only_fully_charged";
+    private static final String KEY_CATEGORY_FAST_CHARGE = "fast_color_cat";
+    private static final String KEY_CATEGORY_CHARGE_COLORS = "colors_list";
+
+    private ColorSelectPreference mLowColorPref;
+    private ColorSelectPreference mMediumColorPref;
+    private ColorSelectPreference mFullColorPref;
+    private ColorSelectPreference mReallyFullColorPref;
+    private ColorSelectPreference mFastColorPref;
+    private Preference mDefaultValues;
+    private SystemSettingSwitchPreference mDndPref;
+    private SystemSettingSwitchPreference mEnabledPref;
+    private SystemSettingSwitchPreference mPulsePref;
+    private SystemSettingSwitchPreference mOnlyFullPref;
+    private SystemSettingSwitchPreference mFastBatteryLightEnabledPref;
+
+    @Override
+    public String getFragmentTitle() {
+        return getString(R.string.batterylight_title);
+    }
+
+    @Override
+    public String getFragmentSummary() {
+        return getString(R.string.batterylight_summary);
+    }
+
+    @Override
+    public int getFragmentIcon() {
+        return R.drawable.ic_settings_leds;
+    }
+
+    @Override
+    public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
+        setPreferencesFromResource(R.xml.battery_light_settings_preferences, rootKey);
+
+        PreferenceScreen prefSet = getPreferenceScreen();
+        ContentResolver resolver = getContext().getContentResolver();
+
+        mDefaultValues = (Preference) findPreference(DEFAULT_VALUES);
+        mDefaultValues.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
+            @Override
+            public boolean onPreferenceClick(Preference preference) {
+                resetToDefaults();
+                return true;
+            }
+        });
+
+        mDndPref = (SystemSettingSwitchPreference) findPreference(BATTERY_DND_PREF);
+        mDndPref.setChecked(Settings.System.getInt(resolver,
+                        Settings.System.OMNI_BATTERY_LIGHT_ALLOW_ON_DND, 1) != 0);
+        mDndPref.setOnPreferenceChangeListener(this);
+
+        mEnabledPref = (SystemSettingSwitchPreference) findPreference(BATTERY_LIGHT_PREF);
+        mEnabledPref.setChecked(Settings.System.getInt(resolver,
+                        Settings.System.OMNI_BATTERY_LIGHT_ENABLED, 1) != 0);
+        mEnabledPref.setOnPreferenceChangeListener(this);
+
+        mPulsePref = (SystemSettingSwitchPreference) findPreference(BATTERY_PULSE_PREF);
+        mPulsePref.setChecked(Settings.System.getInt(resolver,
+                        Settings.System.OMNI_BATTERY_LIGHT_LOW_BLINKING, 1) != 0);
+        mPulsePref.setOnPreferenceChangeListener(this);
+
+        mOnlyFullPref = (SystemSettingSwitchPreference) findPreference(BATTERY_LIGHT_ONLY_FULL_PREF);
+        mOnlyFullPref.setOnPreferenceChangeListener(this);
+
+        // Does the Device support changing battery LED colors?
+        if (getResources().getBoolean(com.android.internal.R.bool.config_multiColorBatteryLed)) {
+
+            mFastBatteryLightEnabledPref = (SystemSettingSwitchPreference) findPreference(FAST_CHARGING_LED_PREF);
+
+            // Low, Medium and full color preferences
+            mLowColorPref = (ColorSelectPreference) findPreference(LOW_COLOR_PREF);
+            mLowColorPref.setOnPreferenceChangeListener(this);
+
+            mMediumColorPref = (ColorSelectPreference) findPreference(MEDIUM_COLOR_PREF);
+            mMediumColorPref.setOnPreferenceChangeListener(this);
+
+            mFullColorPref = (ColorSelectPreference) findPreference(FULL_COLOR_PREF);
+            mFullColorPref.setOnPreferenceChangeListener(this);
+
+            mReallyFullColorPref = (ColorSelectPreference) findPreference(REALLY_FULL_COLOR_PREF);
+            mReallyFullColorPref.setOnPreferenceChangeListener(this);
+
+            mFastColorPref = (ColorSelectPreference) findPreference(FAST_COLOR_PREF);
+            mFastColorPref.setOnPreferenceChangeListener(this);
+
+            // Does the Device support fast charge ?
+            if (!getResources().getBoolean(com.android.internal.R.bool.config_FastChargingLedSupported)) {
+                prefSet.removePreference(prefSet.findPreference(KEY_CATEGORY_FAST_CHARGE));
+            }
+        } else {
+            prefSet.removePreference(prefSet.findPreference(KEY_CATEGORY_CHARGE_COLORS));
+            // not multi color cant have fast charge
+            prefSet.removePreference(prefSet.findPreference(KEY_CATEGORY_FAST_CHARGE));
+        }
+        boolean showOnlyWhenFull = Settings.System.getInt(resolver,
+                Settings.System.OMNI_BATTERY_LIGHT_ONLY_FULLY_CHARGED, 1) != 0;
+        updateEnablement(showOnlyWhenFull);
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+        refreshDefault();
+    }
+
+    @Override
+    public boolean onPreferenceChange(Preference preference, Object objValue) {
+        if (preference == mDndPref) {
+            boolean value = (Boolean) objValue;
+            Settings.System.putInt(getContext().getContentResolver(),
+                    Settings.System.OMNI_BATTERY_LIGHT_ALLOW_ON_DND,
+                    value ? 1 : 0);
+        } else if (preference == mEnabledPref) {
+            boolean value = (Boolean) objValue;
+            Settings.System.putInt(getContext().getContentResolver(),
+                    Settings.System.OMNI_BATTERY_LIGHT_ENABLED,
+                    value ? 1 : 0);
+        } else if (preference == mPulsePref) {
+            boolean value = (Boolean) objValue;
+            Settings.System.putInt(getContext().getContentResolver(),
+                    Settings.System.OMNI_BATTERY_LIGHT_LOW_BLINKING,
+                    value ? 1 : 0);
+        } else if (preference == mOnlyFullPref) {
+            boolean value = (Boolean) objValue;
+            // If enabled, disable all but really full color preference.
+            updateEnablement(value);
+        } else {
+            ColorSelectPreference lightPref = (ColorSelectPreference) preference;
+            updateValues(lightPref.getKey(), lightPref.getColor());
+        }
+        return true;
+    }
+
+    private void updateEnablement(boolean showOnlyWhenFull) {
+        // If enabled, disable all but really full color preference.
+        if (mLowColorPref != null) {
+            mLowColorPref.setEnabled(!showOnlyWhenFull);
+        }
+        if (mMediumColorPref != null) {
+            mMediumColorPref.setEnabled(!showOnlyWhenFull);
+        }
+        if (mFullColorPref != null) {
+            mFullColorPref.setEnabled(!showOnlyWhenFull);
+        }
+        if (mFastColorPref != null) {
+            mFastColorPref.setEnabled(!showOnlyWhenFull);
+        }
+        if (mFastBatteryLightEnabledPref != null) {
+            mFastBatteryLightEnabledPref.setEnabled(!showOnlyWhenFull);
+        }
+    }
+
+    protected void resetToDefaults() {
+        if (mDndPref != null) {
+            Settings.System.putInt(getContext().getContentResolver(),
+                    Settings.System.OMNI_BATTERY_LIGHT_ALLOW_ON_DND, 0);
+            mDndPref.setChecked(false);
+        }
+        if (mEnabledPref != null) {
+            Settings.System.putInt(getContext().getContentResolver(),
+                    Settings.System.OMNI_BATTERY_LIGHT_ENABLED, 1);
+            mEnabledPref.setChecked(true);
+        }
+        if (mPulsePref != null) {
+            Settings.System.putInt(getContext().getContentResolver(),
+                    Settings.System.OMNI_BATTERY_LIGHT_LOW_BLINKING, 0);
+            mPulsePref.setChecked(false);
+        }
+        if (mOnlyFullPref != null) {
+            Settings.System.putInt(getContext().getContentResolver(),
+                    Settings.System.OMNI_BATTERY_LIGHT_ONLY_FULLY_CHARGED, 0);
+            mOnlyFullPref.setChecked(false);
+        }
+        if (mFastBatteryLightEnabledPref != null) {
+            Settings.System.putInt(getContext().getContentResolver(),
+                    Settings.System.OMNI_FAST_CHARGING_LED_ENABLED, 0);
+            mFastBatteryLightEnabledPref.setChecked(false);
+        }
+        resetColors();
+        boolean showOnlyWhenFull = Settings.System.getInt(getContext().getContentResolver(),
+                Settings.System.OMNI_BATTERY_LIGHT_ONLY_FULLY_CHARGED, 1) != 0;
+        updateEnablement(showOnlyWhenFull);
+    }
+
+    protected void resetColors() {
+        ContentResolver resolver = getContext().getContentResolver();
+        Resources res = getResources();
+
+        // Reset to the framework default colors
+        Settings.System.putInt(resolver, Settings.System.OMNI_BATTERY_LIGHT_LOW_COLOR,
+                res.getInteger(com.android.internal.R.integer.config_notificationsBatteryLowARGB));
+        Settings.System.putInt(resolver, Settings.System.OMNI_BATTERY_LIGHT_MEDIUM_COLOR,
+                res.getInteger(com.android.internal.R.integer.config_notificationsBatteryMediumARGB));
+        Settings.System.putInt(resolver, Settings.System.OMNI_BATTERY_LIGHT_FULL_COLOR,
+                res.getInteger(com.android.internal.R.integer.config_notificationsBatteryFullARGB));
+        Settings.System.putInt(resolver, Settings.System.OMNI_BATTERY_LIGHT_REALLY_FULL_COLOR,
+                res.getInteger(com.android.internal.R.integer.config_notificationsBatteryFullARGB));
+        Settings.System.putInt(resolver, Settings.System.OMNI_FAST_BATTERY_LIGHT_COLOR,
+                res.getInteger(com.android.internal.R.integer.config_notificationsFastBatteryARGB));
+        refreshDefault();
+    }
+
+    private void refreshDefault() {
+        ContentResolver resolver = getContext().getContentResolver();
+        Resources res = getResources();
+
+        if (mLowColorPref != null) {
+            int lowColor = Settings.System.getInt(resolver, Settings.System.OMNI_BATTERY_LIGHT_LOW_COLOR,
+                    res.getInteger(com.android.internal.R.integer.config_notificationsBatteryLowARGB));
+            mLowColorPref.setColor(lowColor);
+        }
+
+        if (mMediumColorPref != null) {
+            int mediumColor = Settings.System.getInt(resolver, Settings.System.OMNI_BATTERY_LIGHT_MEDIUM_COLOR,
+                    res.getInteger(com.android.internal.R.integer.config_notificationsBatteryMediumARGB));
+            mMediumColorPref.setColor(mediumColor);
+        }
+
+        if (mFullColorPref != null) {
+            int fullColor = Settings.System.getInt(resolver, Settings.System.OMNI_BATTERY_LIGHT_FULL_COLOR,
+                    res.getInteger(com.android.internal.R.integer.config_notificationsBatteryFullARGB));
+            mFullColorPref.setColor(fullColor);
+        }
+
+        if (mReallyFullColorPref != null) {
+            int reallyFullColor = Settings.System.getInt(resolver, Settings.System.OMNI_BATTERY_LIGHT_REALLY_FULL_COLOR,
+                    res.getInteger(com.android.internal.R.integer.config_notificationsBatteryFullARGB));
+            mReallyFullColorPref.setColor(reallyFullColor);
+        }
+
+        if (mFastColorPref != null) {
+            int fastColor = Settings.System.getInt(resolver, Settings.System.OMNI_FAST_BATTERY_LIGHT_COLOR,
+                    res.getInteger(com.android.internal.R.integer.config_notificationsFastBatteryARGB));
+            mFastColorPref.setColor(fastColor);
+        }
+    }
+
+    /**
+     * Updates the default or application specific notification settings.
+     *
+     * @param key of the specific setting to update
+     * @param color
+     */
+    protected void updateValues(String key, Integer color) {
+        ContentResolver resolver = getContext().getContentResolver();
+
+        if (key.equals(LOW_COLOR_PREF)) {
+            Settings.System.putInt(resolver, Settings.System.OMNI_BATTERY_LIGHT_LOW_COLOR,
+                    color);
+        } else if (key.equals(MEDIUM_COLOR_PREF)) {
+            Settings.System.putInt(resolver, Settings.System.OMNI_BATTERY_LIGHT_MEDIUM_COLOR,
+                    color);
+        } else if (key.equals(FULL_COLOR_PREF)) {
+            Settings.System.putInt(resolver, Settings.System.OMNI_BATTERY_LIGHT_FULL_COLOR,
+                    color);
+        } else if (key.equals(REALLY_FULL_COLOR_PREF)) {
+            Settings.System.putInt(resolver, Settings.System.OMNI_BATTERY_LIGHT_REALLY_FULL_COLOR,
+                    color);
+        } else if (key.equals(FAST_COLOR_PREF)) {
+            Settings.System.putInt(resolver, Settings.System.OMNI_FAST_BATTERY_LIGHT_COLOR,
+                    color);
+        }
+    }
+}
\ No newline at end of file
diff --git a/app/src/main/java/org/omnirom/control/GridViewFragment.kt b/app/src/main/java/org/omnirom/control/GridViewFragment.kt
index c7e9764..ca9a7f4 100644
--- a/app/src/main/java/org/omnirom/control/GridViewFragment.kt
+++ b/app/src/main/java/org/omnirom/control/GridViewFragment.kt
@@ -84,6 +84,16 @@
                 AppListFragment()
             )
         )
+        if (getResources().getBoolean(com.android.internal.R.bool.config_intrusiveBatteryLed)) {
+            gridItems.add(
+                FragmentGridItem(
+                    R.string.batterylight_title,
+                    R.string.batterylight_summary,
+                    R.drawable.ic_settings_leds,
+                    BatteryLightSettingsFragment()
+                )
+            )
+        }
         gridItems.add(
             FragmentGridItem(
                 R.string.bars_settings_title,
diff --git a/app/src/main/res/drawable/ic_settings_backup_restore.xml b/app/src/main/res/drawable/ic_settings_backup_restore.xml
new file mode 100644
index 0000000..1276fda
--- /dev/null
+++ b/app/src/main/res/drawable/ic_settings_backup_restore.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:height="24dp"
+    android:width="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24"
+    android:tint="?android:attr/colorControlNormal">
+    <path android:fillColor="@android:color/white"
+    android:pathData="M12,3A9,9 0 0,0 3,12H0L4,16L8,12H5A7,7 0 0,1 12,5A7,7 0 0,1 19,12A7,7 0 0,1 12,19C10.5,19 9.09,18.5 7.94,17.7L6.5,19.14C8.04,20.3 9.94,21 12,21A9,9 0 0,0 21,12A9,9 0 0,0 12,3M14,12A2,2 0 0,0 12,10A2,2 0 0,0 10,12A2,2 0 0,0 12,14A2,2 0 0,0 14,12Z" />
+</vector>
diff --git a/app/src/main/res/drawable/ic_settings_leds.xml b/app/src/main/res/drawable/ic_settings_leds.xml
new file mode 100644
index 0000000..b165663
--- /dev/null
+++ b/app/src/main/res/drawable/ic_settings_leds.xml
@@ -0,0 +1,22 @@
+<!--
+    Copyright (C) 2016 The Android Open Source 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:tint="?android:textColorPrimary"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+    <path
+        android:fillColor="?android:attr/colorPrimary"
+        android:pathData="M11,0V4H13V0H11M18.3,2.29L15.24,5.29L16.64,6.71L19.7,3.71L18.3,2.29M5.71,2.29L4.29,3.71L7.29,6.71L8.71,5.29L5.71,2.29M12,6A4,4 0 0,0 8,10V16H6V18H9V23H11V18H13V23H15V18H18V16H16V10A4,4 0 0,0 12,6M2,9V11H6V9H2M18,9V11H22V9H18Z" />
+</vector>
diff --git a/app/src/main/res/layout/reset_default.xml b/app/src/main/res/layout/reset_default.xml
new file mode 100644
index 0000000..aecd02e
--- /dev/null
+++ b/app/src/main/res/layout/reset_default.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ImageView android:layout_height="wrap_content"
+           android:layout_width="wrap_content"
+           android:layout_marginRight="10.0dip"
+           android:src="@drawable/ic_settings_backup_restore"
+           xmlns:android="http://schemas.android.com/apk/res/android" />
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 7810bf8..4496ad7 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -76,4 +76,25 @@
 
     <string name="navigation_bar_menu_arrow_keys_title">Arrow keys while typing</string>
     <string name="navigation_bar_menu_arrow_keys_summary">Display left and right cursor buttons while typing</string>
+
+    <!-- Battery light settings  -->
+    <string name="batterylight_title">Battery LED settings</string>
+    <string name="batterylight_summary">Customize your battery led</string>
+    <string name="battery_light_enable">Enable</string>
+    <string name="battery_low_pulse_title">Pulse if battery low</string>
+    <string name="battery_light_only_full_charge_title">Only light up when fully charged</string>
+    <string name="battery_light_list_title">Colors</string>
+    <string name="battery_light_low_color_title">Battery low</string>
+    <string name="battery_light_medium_color_title">Charging</string>
+    <string name="battery_light_full_color_title">Charged (90%)</string>
+    <string name="battery_light_really_full_color_title">Charged (100%)</string>
+    <string name="edit_battery_settings">Edit battery settings</string>
+    <string name="fast_color_cat_title">Fast charging</string>
+    <string name="fast_charging_led_enabled_title">Enable fast charging color</string>
+    <string name="fast_charging_led_enabled_summary">When fast charging, use different color till 90% charged</string>
+    <string name="fast_charging_light_color_title">Color</string>
+    <string name="fast_charging_light_color_summary"></string>
+    <string name="notification_light_general_title">General</string>
+    <string name="notification_light_zen_mode">Lights in Do Not Disturb mode</string>
+    <string name="reset_to_default">Reset to the default values</string>
 </resources>
\ No newline at end of file
diff --git a/app/src/main/res/xml/battery_light_settings_preferences.xml b/app/src/main/res/xml/battery_light_settings_preferences.xml
new file mode 100644
index 0000000..b12756c
--- /dev/null
+++ b/app/src/main/res/xml/battery_light_settings_preferences.xml
@@ -0,0 +1,87 @@
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:omnilib="http://schemas.android.com/apk/res-auto"
+    android:key="battery_led_settings"
+    android:title="@string/batterylight_title" >
+
+    <Preference
+        android:title="@string/reset_to_default"
+        android:widgetLayout="@layout/reset_default"
+        android:key="reset_to_default_key" />
+
+    <org.omnirom.omnilib.preference.SystemSettingSwitchPreference
+        android:key="battery_light_enabled"
+        android:title="@string/battery_light_enable"
+        android:defaultValue="false"/>
+
+    <PreferenceCategory
+        android:key="general_section"
+        android:title="@string/notification_light_general_title">
+
+        <org.omnirom.omnilib.preference.SystemSettingSwitchPreference
+            android:key="battery_light_pulse"
+            android:title="@string/battery_low_pulse_title"
+            android:dependency="battery_light_enabled"
+            android:defaultValue="false" />
+
+        <org.omnirom.omnilib.preference.SystemSettingSwitchPreference
+            android:key="battery_light_only_fully_charged"
+            android:title="@string/battery_light_only_full_charge_title"
+            android:dependency="battery_light_enabled"
+            android:defaultValue="false" />
+
+        <org.omnirom.omnilib.preference.SystemSettingSwitchPreference
+            android:key="battery_light_allow_on_dnd"
+            android:title="@string/notification_light_zen_mode"
+            android:dependency="battery_light_enabled"
+            android:defaultValue="false" />
+
+    </PreferenceCategory>
+
+    <PreferenceCategory
+        android:key="colors_list"
+        android:title="@string/battery_light_list_title"
+        android:dependency="battery_light_enabled" >
+
+        <org.omnirom.omnilib.preference.ColorSelectPreference
+            android:key="low_color"
+            omnilib:ledPreview="true"
+            android:title="@string/battery_light_low_color_title" />
+
+        <org.omnirom.omnilib.preference.ColorSelectPreference
+            android:key="medium_color"
+            omnilib:ledPreview="true"
+            android:title="@string/battery_light_medium_color_title" />
+
+        <org.omnirom.omnilib.preference.ColorSelectPreference
+            android:key="full_color"
+            omnilib:ledPreview="true"
+            android:title="@string/battery_light_full_color_title" />
+
+        <org.omnirom.omnilib.preference.ColorSelectPreference
+            android:key="really_full_color"
+            omnilib:ledPreview="true"
+            android:title="@string/battery_light_really_full_color_title" />
+
+    </PreferenceCategory>
+
+    <PreferenceCategory
+        android:key="fast_color_cat"
+        android:title="@string/fast_color_cat_title"
+        android:dependency="battery_light_enabled" >
+
+        <org.omnirom.omnilib.preference.SystemSettingSwitchPreference
+            android:key="fast_charging_led_enabled"
+            android:title="@string/fast_charging_led_enabled_title"
+            android:summary="@string/fast_charging_led_enabled_summary"
+            android:defaultValue="false" />
+
+        <org.omnirom.omnilib.preference.ColorSelectPreference
+            android:key="fast_color"
+            omnilib:ledPreview="true"
+            android:title="@string/fast_charging_light_color_title"
+            android:summary="@string/fast_charging_light_color_summary"
+            android:dependency="fast_charging_led_enabled" />
+
+    </PreferenceCategory>
+
+</PreferenceScreen>