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

Commit 43f75a8d authored by Steve Kondik's avatar Steve Kondik
Browse files

livedisplay: Add "off" state and fix issues with QS tile

 * It was previously assumed that "day" was the default setting that
   would be used the same as "off" would, but this is confusing and
   also doesn't allow for a custom day temperature.
 * Add a new state for "off" to simplify this, and handle it
   appropriately. We won't show "day" in the QS tile if both "off" and
   "day" are set to 6500K.
 * Also fix bugs in the QS tile.

Change-Id: Ie8e6ebdd83c9275fb7707844b8f054dcbff48a0b
parent 78647ea9
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@

    <string-array name="live_display_entries" translatable="false">
        <item>@string/live_display_auto</item>
        <item>@string/live_display_off</item>
        <item>@string/live_display_day</item>
        <item>@string/live_display_night</item>
        <item>@string/live_display_outdoor</item>
@@ -128,6 +129,7 @@

    <string-array name="live_display_summaries" translatable="false">
        <item>@string/live_display_auto_summary</item>
        <item>@string/live_display_off_summary</item>
        <item>@string/live_display_day_summary</item>
        <item>@string/live_display_night_summary</item>
        <item>@string/live_display_outdoor_summary</item>
@@ -136,6 +138,7 @@
    <string-array name="live_display_values" translatable="false">
        <item>2</item>
        <item>0</item>
        <item>4</item>
        <item>1</item>
        <item>3</item>
    </string-array>
+3 −2
Original line number Diff line number Diff line
@@ -301,7 +301,9 @@
    <!-- LiveDisplay strings -->
    <string name="live_display_title" translatable="false">LiveDisplay</string>
    <string name="live_display_auto">Automatic</string>
    <string name="live_display_auto_summary">Automatically adjust screen for ambient conditions</string>
    <string name="live_display_auto_summary">Automatically adjust color temperature of screen after sunset and sunrise</string>
    <string name="live_display_off">Off</string>
    <string name="live_display_off_summary">Disable all adjustments</string>
    <string name="live_display_day">Day</string>
    <string name="live_display_day_summary">Use day settings only</string>
    <string name="live_display_night">Night</string>
@@ -309,5 +311,4 @@
    <string name="live_display_outdoor">Outdoor (bright sun)</string>
    <string name="live_display_outdoor_summary">Use outdoor settings only</string>
    <string name="live_display_hint">LiveDisplay can help reduce eyestrain and help you sleep at night. Click here to try it out!</string>

</resources>
+55 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (c) 2015 The CyanogenMod Project

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="32dp"
    android:height="24dp"
    android:viewportWidth="32"
    android:viewportHeight="24">

    <group>
        <path
            android:fillColor="#FFFFFF"
            android:pathData="M23,3H9C7.9,3,7,3.9,7,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C25,3.9,24.1,3,23,3z
M23,19H9V5h14V19z M18,12.3l-2.8,3.5l-2-2.4L10.5,17h11L18,12.3z" />
        <path
            android:fillColor="#FFFFFF"
            android:pathData="M23,5v14H9V5H23
M23,3H9C7.9,3,7,3.9,7,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C25,3.9,24.1,3,23,3
L23,3z M18,12c0,1.1-0.9,2-2,2s-2-0.9-2-2s0.9-2,2-2S18,10.9,18,12z
M20,13.7l1.7-1.7L20,10.3V8h-2.3L16,6.3L14.3,8H12v2.3L10.3,12
l1.7,1.7V16h2.3l1.7,1.7l1.7-1.7H20V13.7z" />
        <path
            android:fillColor="#FFFFFF"
            android:pathData="M19.5,15.5c0.4-0.4,0.7-0.8,0.9-1.2c-1.9,1-4.3,0.7-5.8-0.9s-1.9-4-0.9-5.8c-0.5,0.2-0.9,0.5-1.2,0.9
c-2,2-2,5.1,0,7.1S17.6,17.5,19.5,15.5z M23,5v14H9V5H23
M23,3H9C7.9,3,7,3.9,7,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5
C25,3.9,24.1,3,23,3L23,3z" />
        <path
            android:fillColor="#FFFFFF"
            android:pathData="M23,5v14H9V5H23
M23,3H9C7.9,3,7,3.9,7,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C25,3.9,24.1,3,23,3
L23,3z M14.7,13.3h2.6L16,9.2L14.7,13.3z
M18.6,17l-0.8-2.2h-3.6L13.4,17h-2.1l3.6-10h2.2l3.6,10H18.6z" />
        <path
            android:fillColor="#FFFFFF"
            android:pathData="M23.8,4.5v11.3l2,2V4.5c0-1.1-0.9-2-2-2H10.5l2,2H23.8z" />
        <path
            android:fillColor="#FFFFFF"
            android:pathData="M7.6,2.2L6.2,3.6l1.6,1.6v13.3c0,1.1,0.9,2,2,2h13.3l1.3,1.3l1.4-1.4L7.6,2.2z
M9.8,18.5V7.2l11.3,11.3H9.8z" />
    </group>
</vector>
+1 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@
    <!-- LiveDisplay drawables -->
    <string-array name="live_display_drawables" translatable="false">
        <item>@drawable/ic_livedisplay_auto</item>
        <item>@drawable/ic_livedisplay_off</item>
        <item>@drawable/ic_livedisplay_day</item>
        <item>@drawable/ic_livedisplay_night</item>
        <item>@drawable/ic_livedisplay_outdoor</item>
+35 −4
Original line number Diff line number Diff line
@@ -38,9 +38,15 @@ public class LiveDisplayTile extends QSTile<LiveDisplayTile.LiveDisplayState> {

    private boolean mListening;

    public static final int MODE_OUTDOOR = 3;
    private static final int MODE_OUTDOOR = 3;
    private static final int MODE_DAY = 4;

    private static final int OFF_TEMPERATURE = 6500;

    private int mDayTemperature;

    private final boolean mOutdoorModeAvailable;
    private final int mDefaultDayTemperature;

    public LiveDisplayTile(Host host) {
        super(host);
@@ -60,6 +66,9 @@ public class LiveDisplayTile extends QSTile<LiveDisplayTile.LiveDisplayState> {
                Settings.System.DISPLAY_AUTO_OUTDOOR_MODE,
                -1, UserHandle.USER_CURRENT) > -1;

        mDefaultDayTemperature = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_dayColorTemperature);

        mObserver = new LiveDisplayObserver(mHandler);
        mObserver.startObserving();
    }
@@ -108,12 +117,27 @@ public class LiveDisplayTile extends QSTile<LiveDisplayTile.LiveDisplayState> {

    private void changeToNextMode() {
        int next = getCurrentModeIndex() + 1;
        if (!mOutdoorModeAvailable && next == MODE_OUTDOOR) {
            next++;

        if (next >= mValues.length) {
            next = 0;
        }

        while (true) {
            // Skip outdoor mode if it's unsupported, and skip the day setting
            // if it's the same as the off setting
            if ((!mOutdoorModeAvailable &&
                    Integer.valueOf(mValues[next]) == MODE_OUTDOOR) ||
                    (mDayTemperature == OFF_TEMPERATURE &&
                    Integer.valueOf(mValues[next]) == MODE_DAY)) {
                next++;
                if (next >= mValues.length) {
                    next = 0;
                }
            } else {
                break;
            }
        }

        Settings.System.putIntForUser(mContext.getContentResolver(),
                Settings.System.DISPLAY_TEMPERATURE_MODE,
                Integer.valueOf(mValues[next]), UserHandle.USER_CURRENT);
@@ -126,6 +150,10 @@ public class LiveDisplayTile extends QSTile<LiveDisplayTile.LiveDisplayState> {

        @Override
        public void onChange(boolean selfChange) {
            mDayTemperature = Settings.System.getIntForUser(mContext.getContentResolver(),
                    Settings.System.DISPLAY_TEMPERATURE_DAY,
                    mDefaultDayTemperature,
                    UserHandle.USER_CURRENT);
            refreshState(getCurrentModeIndex());
        }

@@ -133,6 +161,9 @@ public class LiveDisplayTile extends QSTile<LiveDisplayTile.LiveDisplayState> {
            mContext.getContentResolver().registerContentObserver(
                    Settings.System.getUriFor(Settings.System.DISPLAY_TEMPERATURE_MODE),
                    false, this);
            mContext.getContentResolver().registerContentObserver(
                    Settings.System.getUriFor(Settings.System.DISPLAY_TEMPERATURE_DAY),
                    false, this);
        }

        public void endObserving() {
Loading