[2/2] OmniGears : Add new light category
Change-Id: Iec2396d5d71daabcb4bfae6a043de37ad2b15dee
diff --git a/res/values/custom_strings.xml b/res/values/custom_strings.xml
index 3e884aa..d75e773 100644
--- a/res/values/custom_strings.xml
+++ b/res/values/custom_strings.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2013 The OmniROM Project
+<!-- Copyright (C) 2017 The OmniROM Project
Parts Copyright (C) 2012-2013 The CyanogenMod Project
@@ -384,6 +384,10 @@
<string name="pulse_speed_slow">Slow</string>
<string name="pulse_speed_very_slow">Very slow</string>
<!-- Lights settings screen, notification light settings -->
+ <string name="omni_battery_light_settings">Battery charging</string>
+ <string name="omni_notification_light_settings">Applications LED notifications</string>
+ <string name="omni_leds">LED Lights</string>
+ <string name="omni_lights_title">Notification LED</string>
<string name="notification_light_title">Notification light</string>
<string name="notificationlight_title">Notification LED settings</string>
<string name="notification_light_general_title">General</string>
@@ -418,6 +422,9 @@
<string name="lockscreen_hide_media_title">Disable media wallpaper</string>
<string name="lockscreen_hide_media_summary">Do not show media metadata as lock screen wallpaper</string>
+ <string name="omni_notification_light_settings_summary">Customization of notification led lights for applications</string>
+ <string name="omni_battery_light_settings_summary">Customization of notification led lights for battery</string>
+
<string name="night_mode_title">Theme</string>
<string name="night_mode_summary">%s</string>
<string name="night_mode_no">Light</string>
diff --git a/res/xml/lights_settings.xml b/res/xml/lights_settings.xml
new file mode 100644
index 0000000..b302404
--- /dev/null
+++ b/res/xml/lights_settings.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 The OmniROM Project
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ -->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ android:key="ligths_settings"
+ android:title="@string/omni_lights_title">
+
+ <PreferenceCategory
+ android:key="leds"
+ android:title="@string/omni_leds" >
+
+ <PreferenceScreen
+ android:key="notification_light"
+ android:title="@string/omni_notification_light_settings"
+ android:summary="@string/omni_notification_light_settings_summary"
+ android:fragment="org.omnirom.omnigears.batterylight.NotificationLightSettings" />
+
+ <PreferenceScreen
+ android:key="charging_light"
+ android:title="@string/omni_battery_light_settings"
+ android:summary="@string/omni_battery_light_settings_summary"
+ android:fragment="org.omnirom.omnigears.batterylight.BatteryLightSettings" />
+ </PreferenceCategory>
+</PreferenceScreen>
diff --git a/src/org/omnirom/omnigears/lightssettings/LightsSettings.java b/src/org/omnirom/omnigears/lightssettings/LightsSettings.java
new file mode 100644
index 0000000..3cc14d1
--- /dev/null
+++ b/src/org/omnirom/omnigears/lightssettings/LightsSettings.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2017 The OmniROM Project
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+*/
+
+package org.omnirom.omnigears.lightssettings;
+
+import android.os.Bundle;
+import android.support.v7.preference.Preference;
+import android.preference.PreferenceActivity;
+import android.support.v7.preference.PreferenceCategory;
+import android.preference.PreferenceScreen;
+
+import com.android.internal.logging.MetricsProto.MetricsEvent;
+
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.Utils;
+
+public class LightsSettings extends SettingsPreferenceFragment implements
+ Preference.OnPreferenceChangeListener {
+ private static final String TAG = "ligths_settings";
+
+ private boolean mChargingLedsEnabled;
+ private boolean mNotificationLedsEnabled;
+
+ private PreferenceCategory mChargingLedsCategory;
+ private Preference mChargingLeds;
+ private Preference mNotificationLeds;
+
+ @Override
+ protected int getMetricsCategory() {
+ return MetricsEvent.OMNI_SETTINGS;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.lights_settings);
+
+ mChargingLedsEnabled = (getResources().getBoolean(
+ com.android.internal.R.bool.config_intrusiveBatteryLed));
+ mNotificationLedsEnabled = (getResources().getBoolean(
+ com.android.internal.R.bool.config_intrusiveNotificationLed));
+ mChargingLedsCategory = (PreferenceCategory) findPreference("leds");
+ mChargingLeds = (Preference) findPreference("charging_light");
+ mNotificationLeds = (Preference) findPreference("notification_light");
+ if (mChargingLeds != null && mNotificationLeds != null) {
+ if (!mChargingLedsEnabled) {
+ mChargingLedsCategory.removePreference(mChargingLeds);
+ } else if (!mNotificationLedsEnabled) {
+ mChargingLedsCategory.removePreference(mNotificationLeds);
+ } else if (!mChargingLedsEnabled && !mNotificationLedsEnabled) {
+ getPreferenceScreen().removePreference(mChargingLedsCategory);
+ }
+ }
+ }
+
+ public boolean onPreferenceChange(Preference preference, Object objValue) {
+ return true;
+ }
+}