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

Commit d222ae55 authored by AdrianDC's avatar AdrianDC Committed by Michael Bestas
Browse files

LEDs Brightness [1/2]: Lights notifications brightness support



Implement the support of an overall brightness control for the LEDs.

The setting is deactivated by default
and will be ignored by the unimplemented phones.
Current LibLights will simply not use the new variable.

Changes includes :
  frameworks/base
  packages/Apps/Settings

Change-Id: I6ff14ee0de8200f211302a868c5b43e3ec6f9f3a
Signed-off-by: default avatarAdrianDC <radian.dc@gmail.com>
parent 822fe6db
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -471,7 +471,9 @@
    <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_brightness" translatable="false">@string/brightness</string>
    <string name="notification_light_screen_on">Lights with screen on</string>
    <string name="keywords_lights_brightness_level">dim leds brightness</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>
+8 −0
Original line number Diff line number Diff line
@@ -37,6 +37,14 @@
        android:key="advanced_section"
        android:title="@string/advanced">

        <PreferenceScreen
            android:key="notification_light_brightness_level"
            android:title="@string/notification_light_brightness"
            android:dependency="notification_light_pulse"
            settings:keywords="@string/keywords_lights_brightness_level">
            <intent android:action="android.intent.action.SHOW_NOTIFICATION_BRIGHTNESS_DIALOG" />
        </PreferenceScreen>

        <com.android.settings.cyanogenmod.SystemSettingSwitchPreference
            android:key="notification_light_screen_on_enable"
            android:title="@string/notification_light_screen_on"
+12 −0
Original line number Diff line number Diff line
@@ -72,12 +72,14 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem
    private static final int MENU_ADD = 0;
    private static final int DIALOG_APPS = 0;

    private boolean mAdjustableNotificationLedBrightness;
    private boolean mMultiColorNotificationLed;
    private int mDefaultColor;
    private int mDefaultLedOn;
    private int mDefaultLedOff;
    private PackageManager mPackageManager;
    private PreferenceGroup mApplicationPrefList;
    private PreferenceScreen mNotificationLedBrightnessPref;
    private SystemSettingSwitchPreference mEnabledPref;
    private SystemSettingSwitchPreference mCustomEnabledPref;
    private SystemSettingSwitchPreference mScreenOnLightsPref;
@@ -101,6 +103,8 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem
        PreferenceGroup mAdvancedPrefs = (PreferenceGroup) prefSet.findPreference("advanced_section");
        PreferenceGroup mPhonePrefs = (PreferenceGroup) prefSet.findPreference("phone_list");

        mAdjustableNotificationLedBrightness = resources.getBoolean(
                com.android.internal.R.bool.config_adjustableNotificationLedBrightness);
        mMultiColorNotificationLed = resources.getBoolean(
                com.android.internal.R.bool.config_multiColorNotificationLed);

@@ -121,12 +125,19 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem
        mDefaultPref.setOnPreferenceChangeListener(this);

        // Advanced light settings
        mNotificationLedBrightnessPref = (PreferenceScreen)
                findPreference(Settings.System.NOTIFICATION_LIGHT_BRIGHTNESS_LEVEL);
        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);
        if (!mAdjustableNotificationLedBrightness) {
            mAdvancedPrefs.removePreference(mNotificationLedBrightnessPref);
        } else {
            mNotificationLedBrightnessPref.setOnPreferenceChangeListener(this);
        }

        // Missed call and Voicemail preferences should only show on devices with a voice capabilities
        TelephonyManager tm = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
@@ -410,6 +421,7 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem

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