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

Commit 822fe6db authored by AdrianDC's avatar AdrianDC Committed by Michael Bestas
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

Screenshot of the Settings :
  http://i1285.photobucket.com/albums/a583/adriandc/Screenshot_2015-07-20-23-47-13_zpstpmemwwn.png~original



Change-Id: I3650a014554ce50eb9030cc41e5ce1780bcc2dfe
Signed-off-by: default avatarAdrianDC <radian.dc@gmail.com>
parent 0508802c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -471,6 +471,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">Lights with screen on</string>

    <!-- Sound & notification > Sound section: Title for the option defining the default notification ringtone. [CHAR LIMIT=30] -->
    <string name="notification_ringtone_title_cm">Notification tone</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/advanced">

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

        <com.android.settings.cyanogenmod.SystemSettingSwitchPreference
            android:key="notification_light_pulse_custom_enable"
            android:title="@string/notification_light_use_custom"
+13 −5
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem
    private PreferenceGroup mApplicationPrefList;
    private SystemSettingSwitchPreference mEnabledPref;
    private SystemSettingSwitchPreference mCustomEnabledPref;
    private SystemSettingSwitchPreference mScreenOnLightsPref;
    private ApplicationLightPreference mDefaultPref;
    private ApplicationLightPreference mCallPref;
    private ApplicationLightPreference mVoicemailPref;
@@ -97,6 +98,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(
@@ -114,13 +116,18 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem
        mEnabledPref = (SystemSettingSwitchPreference)
                findPreference(Settings.System.NOTIFICATION_LIGHT_PULSE);
        mEnabledPref.setOnPreferenceChangeListener(this);
        mCustomEnabledPref = (SystemSettingSwitchPreference)
                findPreference(Settings.System.NOTIFICATION_LIGHT_PULSE_CUSTOM_ENABLE);
        mCustomEnabledPref.setOnPreferenceChangeListener(this);

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

        // Advanced light settings
        mScreenOnLightsPref = (SystemSettingSwitchPreference)
                findPreference(Settings.System.NOTIFICATION_LIGHT_SCREEN_ON);
        mScreenOnLightsPref.setOnPreferenceChangeListener(this);
        mCustomEnabledPref = (SystemSettingSwitchPreference)
                findPreference(Settings.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) {
@@ -145,7 +152,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();
@@ -402,7 +409,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;