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

Commit 306c2881 authored by Sam Mortimer's avatar Sam Mortimer Committed by Adnan Begovic
Browse files

Remove lights settings unless intrusive LED bools are true

com.android.internal.R.bool.config_intrusiveNotificationLed
com.android.internal.R.bool.config_intrusiveBatteryLed

Change-Id: I8883d68bc7e82d295a1d47b3ca3777525350d854
parent e5f5e3ac
Loading
Loading
Loading
Loading
+10 −19
Original line number Diff line number Diff line
@@ -82,6 +82,8 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
    private static final String KEY_LOCK_SCREEN_NOTIFICATIONS = "lock_screen_notifications";
    private static final String KEY_NOTIFICATION_ACCESS = "manage_notification_access";
    private static final String KEY_INCREASING_RING_VOLUME = "increasing_ring_volume";
    private static final String KEY_NOTIFICATION_LIGHT = "notification_light";
    private static final String KEY_BATTERY_LIGHT = "battery_light";
    private static final String KEY_ZEN_ACCESS = "manage_zen_access";
    private static final String KEY_ZEN_MODE = "zen_mode";

@@ -443,25 +445,14 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
    // === Pulse notification light ===

    private void initPulse(PreferenceCategory parent) {
        mNotificationPulse = (TwoStatePreference) parent.findPreference(KEY_NOTIFICATION_PULSE);
        if (mNotificationPulse == null) {
            Log.i(TAG, "Preference not found: " + KEY_NOTIFICATION_PULSE);
            return;
        }
        if (!getResources()
                .getBoolean(com.android.internal.R.bool.config_intrusiveNotificationLed)) {
            parent.removePreference(mNotificationPulse);
        } else {
            updatePulse();
            mNotificationPulse.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
                @Override
                public boolean onPreferenceChange(Preference preference, Object newValue) {
                    final boolean val = (Boolean)newValue;
                    return Settings.System.putInt(getContentResolver(),
                            Settings.System.NOTIFICATION_LIGHT_PULSE,
                            val ? 1 : 0);
                }
            });
        if (!getResources().getBoolean(
                com.android.internal.R.bool.config_intrusiveNotificationLed)) {
            parent.removePreference(parent.findPreference(KEY_NOTIFICATION_LIGHT));
        }
        if (!getResources().getBoolean(
                com.android.internal.R.bool.config_intrusiveBatteryLed)
                || UserHandle.myUserId() != UserHandle.USER_OWNER) {
            parent.removePreference(parent.findPreference(KEY_BATTERY_LIGHT));
        }
    }