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

Commit 86ceb7ba authored by Ricardo Cerqueira's avatar Ricardo Cerqueira Committed by Gerrit Code Review
Browse files

Merge "Forward port "Display options: allow configuration of wake on plug behavior"" into cm-11.0

parents 6655086c ad11248f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -178,6 +178,10 @@
    <string name="adaptive_backlight_title">Adaptive backlight</string>
    <string name="adaptive_backlight_summary">Intelligently vary the backlight brightness of the display and help maximize battery life</string>

    <!-- Turn on display when power connected; turn off display when power disconnected -->
    <string name="wake_when_plugged_or_unplugged_title">Wake on plug</string>
    <string name="wake_when_plugged_or_unplugged_summary">Turn the screen on when connecting or disconnecting the charger</string>

    <!-- Notification light dialogs -->
    <string name="edit_light_settings">Edit light settings</string>
    <string name="pulse_speed_title">Pulse length and speed</string>
+6 −0
Original line number Diff line number Diff line
@@ -71,6 +71,12 @@
                android:targetClass="com.cyanogenmod.settings.device.DisplaySettings" />
        </Preference>

        <CheckBoxPreference
            android:key="wake_when_plugged_or_unplugged"
            android:title="@string/wake_when_plugged_or_unplugged_title"
            android:summary="@string/wake_when_plugged_or_unplugged_summary"
            android:defaultValue="false" />

        <PreferenceCategory
            android:key="lights_prefs"
            android:title="@string/lights_category_title">
+20 −0
Original line number Diff line number Diff line
@@ -65,11 +65,13 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
    private static final String CATEGORY_LIGHTS = "lights_prefs";
    private static final String KEY_NOTIFICATION_PULSE = "notification_pulse";
    private static final String KEY_BATTERY_LIGHT = "battery_light";
    private static final String KEY_WAKE_WHEN_PLUGGED_OR_UNPLUGGED = "wake_when_plugged_or_unplugged";

    private static final int DLG_GLOBAL_CHANGE_WARNING = 1;

    private CheckBoxPreference mAccelerometer;
    private FontDialogPreference mFontSizePref;
    private CheckBoxPreference mWakeWhenPluggedOrUnplugged;

    private PreferenceScreen mNotificationPulse;
    private PreferenceScreen mBatteryPulse;
@@ -135,6 +137,9 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
        Utils.updatePreferenceToSpecificActivityFromMetaDataOrRemove(getActivity(),
                getPreferenceScreen(), KEY_ADVANCED_DISPLAY_SETTINGS);

        mWakeWhenPluggedOrUnplugged =
                (CheckBoxPreference) findPreference(KEY_WAKE_WHEN_PLUGGED_OR_UNPLUGGED);

        boolean hasNotificationLed = res.getBoolean(
                com.android.internal.R.bool.config_intrusiveNotificationLed);
        boolean hasBatteryLed = res.getBoolean(
@@ -234,10 +239,20 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
        RotationPolicy.registerRotationPolicyListener(getActivity(),
                mRotationPolicyListener);

        final ContentResolver resolver = getContentResolver();

        if (mAdaptiveBacklight != null) {
            mAdaptiveBacklight.setChecked(AdaptiveBacklight.isEnabled());
        }

        // Default value for wake-on-plug behavior from config.xml
        boolean wakeUpWhenPluggedOrUnpluggedConfig = getResources().getBoolean(
                com.android.internal.R.bool.config_unplugTurnsOnScreen);

        mWakeWhenPluggedOrUnplugged.setChecked(Settings.Global.getInt(resolver,
                Settings.Global.WAKE_WHEN_PLUGGED_OR_UNPLUGGED,
                (wakeUpWhenPluggedOrUnpluggedConfig ? 1 : 0)) == 1);

        updateState();
    }

@@ -338,6 +353,11 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
                    getActivity(), !mAccelerometer.isChecked());
        } else if (preference == mAdaptiveBacklight) {
            return AdaptiveBacklight.setEnabled(mAdaptiveBacklight.isChecked());
        } else if (preference == mWakeWhenPluggedOrUnplugged) {
            Settings.Global.putInt(getContentResolver(),
                    Settings.Global.WAKE_WHEN_PLUGGED_OR_UNPLUGGED,
                    mWakeWhenPluggedOrUnplugged.isChecked() ? 1 : 0);
            return true;
        }
        return super.onPreferenceTreeClick(preferenceScreen, preference);
    }