Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0fdd542d authored by AdrianDC's avatar AdrianDC Committed by Gerrit Code Review
Browse files

Lights with Screen On [2/2]: Optional allowment of lights



Implement a setting allowing lights to be activated
for new notifications even if the screen is on.

Lights with screen on and Custom values are separated
in an advanced section for a cleaner overview.

This setting gives the user an oportunity to activate lights
with the screen on and also during DayDream screensaver.
The option is not activated by default.

Changes include :
  frameworks/base
  packages/apps/Settings

Change-Id: I3650a014554ce50eb9030cc41e5ce1780bcc2dfe
Signed-off-by: default avatarAdrianDC <radian.dc@gmail.com>
parent ce8cce02
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -302,12 +302,14 @@
    <!-- Lights settings screen, notification light settings -->
    <string name="notification_light_title">Notification light</string>
    <string name="notification_light_general_title">General</string>
    <string name="notification_light_advanced_title">Advanced</string>
    <string name="notification_light_applist_title">Apps</string>
    <string name="notification_light_phonelist_title">Phone</string>
    <string name="notification_light_use_custom">Use custom values</string>
    <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">Lights with screen on</string>

    <!-- Lights settings, LED notification -->
    <string name="led_notification_title">Light settings</string>
+11 −0
Original line number Diff line number Diff line
@@ -31,6 +31,17 @@
            android:persistent="false"
            android:dependency="notification_light_pulse" />

    </PreferenceCategory>

    <PreferenceCategory
        android:key="advanced_section"
        android:title="@string/notification_light_advanced_title">

        <com.android.settings.cyanogenmod.CMSystemSettingSwitchPreference
            android:key="notification_light_screen_on_enable"
            android:title="@string/notification_light_screen_on"
            android:dependency="notification_light_pulse" />

        <com.android.settings.cyanogenmod.CMSystemSettingSwitchPreference
            android:key="notification_light_pulse_custom_enable"
            android:title="@string/notification_light_use_custom"
+13 −5
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem
    private PreferenceGroup mApplicationPrefList;
    private SystemSettingSwitchPreference mEnabledPref;
    private CMSystemSettingSwitchPreference mCustomEnabledPref;
    private CMSystemSettingSwitchPreference mScreenOnLightsPref;
    private ApplicationLightPreference mDefaultPref;
    private ApplicationLightPreference mCallPref;
    private ApplicationLightPreference mVoicemailPref;
@@ -92,6 +93,7 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem
        Resources resources = getResources();

        PreferenceGroup mGeneralPrefs = (PreferenceGroup) prefSet.findPreference("general_section");
        PreferenceGroup mAdvancedPrefs = (PreferenceGroup) prefSet.findPreference("advanced_section");
        PreferenceGroup mPhonePrefs = (PreferenceGroup) prefSet.findPreference("phone_list");

        mMultiColorNotificationLed = resources.getBoolean(
@@ -112,13 +114,18 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem
        mEnabledPref = (SystemSettingSwitchPreference)
                findPreference(Settings.System.NOTIFICATION_LIGHT_PULSE);
        mEnabledPref.setOnPreferenceChangeListener(this);
        mCustomEnabledPref = (CMSystemSettingSwitchPreference)
                findPreference(CMSettings.System.NOTIFICATION_LIGHT_PULSE_CUSTOM_ENABLE);
        mCustomEnabledPref.setOnPreferenceChangeListener(this);

        mDefaultPref = (ApplicationLightPreference) findPreference(DEFAULT_PREF);
        mDefaultPref.setOnPreferenceChangeListener(this);

        // Advanced light settings
        mScreenOnLightsPref = (CMSystemSettingSwitchPreference)
                findPreference(CMSettings.System.NOTIFICATION_LIGHT_SCREEN_ON);
        mScreenOnLightsPref.setOnPreferenceChangeListener(this);
        mCustomEnabledPref = (CMSystemSettingSwitchPreference)
                findPreference(CMSettings.System.NOTIFICATION_LIGHT_PULSE_CUSTOM_ENABLE);
        mCustomEnabledPref.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) {
@@ -143,7 +150,7 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem
        if (mMultiColorNotificationLed) {
            setHasOptionsMenu(true);
        } else {
            mGeneralPrefs.removePreference(mCustomEnabledPref);
            mAdvancedPrefs.removePreference(mCustomEnabledPref);
            prefSet.removePreference(mPhonePrefs);
            prefSet.removePreference(mApplicationPrefList);
            resetColors();
@@ -405,7 +412,8 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem
    }

    public boolean onPreferenceChange(Preference preference, Object objValue) {
        if (preference == mEnabledPref || preference == mCustomEnabledPref) {
        if (preference == mEnabledPref || preference == mCustomEnabledPref ||
                preference == mScreenOnLightsPref) {
            getActivity().invalidateOptionsMenu();
        } else {
            ApplicationLightPreference lightPref = (ApplicationLightPreference) preference;