[2/2] OmniGears: Option to enable Notification Light when screen is on
This makes it possible to let the Notification LED flash even when the screen is on
PS5
use this to change also
-align color pref
-disable battery light reset menu since no other page has this
Change-Id: I3f5b8f2136a833a4c651887f3c8c97d27246863e
diff --git a/res/layout/preference_application_light.xml b/res/layout/preference_application_light.xml
index f88038c..72b8e1b 100644
--- a/res/layout/preference_application_light.xml
+++ b/res/layout/preference_application_light.xml
@@ -4,6 +4,8 @@
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
+ android:paddingStart="5dp"
+ android:paddingEnd="?android:attr/scrollbarSize"
android:background="?android:attr/selectableItemBackground" >
<ImageView
diff --git a/res/layout/preference_battery_light.xml b/res/layout/preference_battery_light.xml
index 95d4e5a..a1d77c8 100644
--- a/res/layout/preference_battery_light.xml
+++ b/res/layout/preference_battery_light.xml
@@ -4,18 +4,10 @@
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
+ android:paddingStart="5dp"
+ android:paddingEnd="?android:attr/scrollbarSize"
android:background="?android:attr/selectableItemBackground" >
- <ImageView
- android:id="@+android:id/icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_margin="4dip"
- android:maxWidth="36dip"
- android:maxHeight="36dip"
- android:adjustViewBounds="true"
- android:layout_gravity="center" />
-
<RelativeLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
diff --git a/res/values/custom_strings.xml b/res/values/custom_strings.xml
index 36199a1..b773338 100644
--- a/res/values/custom_strings.xml
+++ b/res/values/custom_strings.xml
@@ -72,6 +72,7 @@
<string name="notification_light_default_value">Default</string>
<string name="notification_light_missed_call_title">Missed call</string>
<string name="notification_light_voicemail_title">Voicemail</string>
+ <string name="notification_light_screen_on_title">Show when screen is on</string>
<!-- Values for the notification light pulse spinners -->
<string name="pulse_length_always_on">Always on</string>
@@ -479,4 +480,5 @@
<string name="clock_date_style_normal">Normal</string>
<string name="clock_date_style_lowercase">Lowercase</string>
<string name="clock_date_style_uppercase">Uppercase</string>
+
</resources>
diff --git a/res/xml/notification_light_settings.xml b/res/xml/notification_light_settings.xml
index 65df028..f38f4f0 100644
--- a/res/xml/notification_light_settings.xml
+++ b/res/xml/notification_light_settings.xml
@@ -26,6 +26,11 @@
android:key="general_section"
android:title="@string/notification_light_general_title">
+ <CheckBoxPreference
+ android:key="notification_light_screen_on"
+ android:title="@string/notification_light_screen_on_title"
+ android:persistent="false" />
+
<org.omnirom.omnigears.notificationlight.ApplicationLightPreference
android:key="default"
android:title="@string/notification_light_default_value"
diff --git a/src/org/omnirom/omnigears/batterylight/BatteryLightSettings.java b/src/org/omnirom/omnigears/batterylight/BatteryLightSettings.java
index 45e60b1..0944568 100644
--- a/src/org/omnirom/omnigears/batterylight/BatteryLightSettings.java
+++ b/src/org/omnirom/omnigears/batterylight/BatteryLightSettings.java
@@ -153,7 +153,7 @@
}
}
- @Override
+ /*@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.add(0, MENU_RESET, 0, R.string.reset)
.setIcon(R.drawable.ic_settings_backup) // use the backup icon
@@ -185,7 +185,7 @@
Settings.System.putInt(resolver, Settings.System.BATTERY_LIGHT_REALLY_FULL_COLOR,
res.getInteger(com.android.internal.R.integer.config_notificationsBatteryFullARGB));
refreshDefault();
- }
+ }*/
@Override
public boolean onPreferenceChange(Preference preference, Object objValue) {
diff --git a/src/org/omnirom/omnigears/notificationlight/NotificationLightSettings.java b/src/org/omnirom/omnigears/notificationlight/NotificationLightSettings.java
index 2ade194..44031ba 100644
--- a/src/org/omnirom/omnigears/notificationlight/NotificationLightSettings.java
+++ b/src/org/omnirom/omnigears/notificationlight/NotificationLightSettings.java
@@ -78,6 +78,7 @@
private static final String NOTIFICATION_LIGHT_PULSE_VMAIL_COLOR = "notification_light_pulse_vmail_color";
private static final String NOTIFICATION_LIGHT_PULSE_VMAIL_LED_ON = "notification_light_pulse_vmail_led_on";
private static final String NOTIFICATION_LIGHT_PULSE_VMAIL_LED_OFF = "notification_light_pulse_vmail_led_off";
+ private static final String NOTIFICAIION_LIGHT_SCREEN_ON = "notification_light_screen_on";
private static final String PULSE_PREF = "pulse_enabled";
private static final String DEFAULT_PREF = "default";
private static final String CUSTOM_PREF = "custom_enabled";
@@ -95,6 +96,7 @@
private PreferenceGroup mApplicationPrefList;
private SwitchPreference mEnabledPref;
private SwitchPreference mCustomEnabledPref;
+ private CheckBoxPreference mScreenOnNotificationLed;
private ApplicationLightPreference mDefaultPref;
private ApplicationLightPreference mCallPref;
private ApplicationLightPreference mVoicemailPref;
@@ -132,6 +134,11 @@
mDefaultPref = (ApplicationLightPreference) findPreference(DEFAULT_PREF);
mDefaultPref.setOnPreferenceChangeListener(this);
+ mScreenOnNotificationLed = (CheckBoxPreference) findPreference(NOTIFICAIION_LIGHT_SCREEN_ON);
+ mScreenOnNotificationLed.setChecked(Settings.System.getInt(getContentResolver(),
+ Settings.System.SCREEN_ON_NOTIFICATION_LED, 0) == 1);
+ mScreenOnNotificationLed.setOnPreferenceChangeListener(this);
+
// Missed call and Voicemail preferences should only show on devices with a voice capabilities
TelephonyManager tm = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
if (tm.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE) {
@@ -371,6 +378,10 @@
Settings.System.NOTIFICATION_LIGHT_PULSE_CUSTOM_ENABLE, enabled?1:0);
mApplicationPrefList.setEnabled(enabled);
}
+ } else if (preference == mScreenOnNotificationLed) {
+ boolean value = (Boolean) objValue;
+ Settings.System.putInt(getContentResolver(),
+ Settings.System.SCREEN_ON_NOTIFICATION_LED, value ? 1 : 0);
} else {
ApplicationLightPreference lightPref = (ApplicationLightPreference) preference;
updateValues(lightPref.getKey(), lightPref.getColor(),