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

Commit 97c6c11e authored by Noeljunior's avatar Noeljunior Committed by Gerrit Code Review
Browse files

QS: Add Ambient Display Tile (1/2)

Change-Id: I31ffd7d83a65db294759374900da0fca1c760549
parent 98db0d13
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ public class QSConstants {
    public static final String TILE_LIVE_DISPLAY = "live_display";
    public static final String TILE_USB_TETHER = "usb_tether";
    public static final String TILE_HEADS_UP = "heads_up";
    public static final String TILE_AMBIENT_DISPLAY = "ambient_display";

    // Order matters
    protected static final ArrayList<String> TILES_DEFAULT = new ArrayList<String>();
@@ -86,5 +87,6 @@ public class QSConstants {
        TILES_AVAILABLE.add(TILE_LIVE_DISPLAY);
        TILES_AVAILABLE.add(TILE_USB_TETHER);
        TILES_AVAILABLE.add(TILE_HEADS_UP);
        TILES_AVAILABLE.add(TILE_AMBIENT_DISPLAY);
    }
}
+58 −0
Original line number Diff line number Diff line
<!--
Copyright (C) 2014 The Android Open Source 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="64dp"
    android:height="64dp"
    android:viewportWidth="64"
    android:viewportHeight="64">

    <group
        android:translateY="-988.583">
        <path
            android:fillColor="#4DFFFFFF"
            android:pathData="M14.9929
1051.24c-0.860426-0.1558-1.60181-0.6484-2.08043-1.3823-0.191527-0.2937-0.318133-0.5822-0.424976-0.9684l-0.07925-0.2865-0.0077-21.1653-0.0077-21.1652-5.65481-5.6547c-3.75978-3.75965-5.65481-5.67485-5.65481-5.71485
0-0.039 0.455164-0.5152 1.31263-1.3725 1.14594-1.1458 1.32404-1.3124
1.40251-1.3124 0.07978 0 3.23905 3.1492 28.1024 28.0124 22.4142 22.4142 28.0125
28.0275 28.0125 28.0876 0 0.1096-2.59052 2.6999-2.70019 2.6999-0.0594
0-0.66925-0.5944-2.93987-2.8651l-2.86494-2.8651-0.0162 1.6726-0.0162
1.6726-0.0793 0.2911c-0.30675 1.127-1.135 1.9557-2.26722 2.2684l-0.29117
0.08-16.755 0.01c-14.361
0-16.7886-0.001-16.9903-0.038zm29.8303-12.2447v-0.2925l-5.22747-5.2275-5.22747-5.2275h-6.00753-6.00753l-0.00079-0.6975-0.00078-0.6975
1.09505-1.08 1.09504-1.08 0.0351-2.175c0.0201-1.2482 0.0254-2.5792
0.0124-3.1234l-0.0227-0.9485-2.86164-2.8615-2.86164-2.8615v13.2824 13.2825h12.99
12.99v-0.2925zm-13.44-7.2523c-0.53478-0.1072-1.03604-0.424-1.36654-0.8636-0.30042-0.3997-0.45617-0.8284-0.48472-1.3341l-0.0174-0.3075h1.93454c1.06399
0 2.13918 0.01 2.38931 0.02l0.45477 0.02v0.1413c0 0.222-0.0844 0.6501-0.17092
0.8667-0.30319 0.7593-0.93372 1.2975-1.70726 1.4573-0.26299 0.054-0.76232
0.055-1.03182
0.0006zm16.6574-0.5628-3.21745-3.2175v-13.5675-13.5674h-12.99-12.99v0.51c0
0.509-0.00012 0.51-0.0675 0.51-0.0496
0-0.90464-0.8371-3.225-3.15755l-3.15745-3.1575v-1.4258c0-0.7988 0.01359-1.5341
0.03091-1.6722 0.161018-1.2841 1.06546-2.3221
2.32624-2.6698l0.297859-0.082h16.845 16.845l0.29117 0.08c1.13269 0.3129 1.95549
1.1357 2.26839 2.2684l0.0804 0.2912 0.008 21.0374 0.008 21.0375h-0.0677c-0.0498
0-0.91619-0.8486-3.28515-3.2176zm-14.04-14.0399c-3.73959-3.7397-5.07747-5.0954-5.07747-5.145
0-0.037 0.004-0.067 0.008-0.067s0.27081-0.095 0.59194-0.21c0.32114-0.1155
0.58578-0.21 0.5881-0.21 0.002 0 0.0113-0.1857 0.02-0.4125 0.0255-0.6681
0.17539-1.0612 0.54652-1.4337 0.34072-0.342 0.70204-0.4938 1.17524-0.4938
0.48816 0 0.81887 0.1266 1.1524 0.4412 0.24603 0.2321 0.38341 0.4468 0.49534
0.774 0.0706 0.2064 0.0839 0.3013 0.0959 0.6823 0.0107 0.3401 0.0231 0.4425
0.0537 0.4425 0.0218 0 0.30704 0.096 0.63378 0.2132 1.18372 0.4249 2.01459
0.9295 2.74561 1.6675 0.50334 0.5081 0.83969 0.9774 1.15692 1.6143 0.51647
1.0368 0.81228 2.2666 0.93638 3.8931 0.0267 0.35 0.0876 2.4717 0.0896 3.1193
0.00057 0.1902-0.004 0.2025-0.0669 0.2025-0.0498 0-1.40242-1.3349-5.145-5.0775z" />
    </group>
</vector>
+51 −0
Original line number Diff line number Diff line
<!--
Copyright (C) 2014 The Android Open Source 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="64dp"
    android:height="64dp"
    android:viewportWidth="64"
    android:viewportHeight="64">

    <group
        android:translateY="-988.583">
        <path
            android:fillColor="#FFFFFFFF"
            android:pathData="M15.0133
1051.24c-1.3615-0.2479-2.37425-1.2789-2.57968-2.6262-0.06554-0.4298-0.06571-55.8484-0.00018-56.28
0.09875-0.65024 0.367851-1.20544 0.812983-1.6773 0.402211-0.42637
0.920053-0.7356 1.49909-0.8952l0.299302-0.0825h16.845 16.845l0.291174
0.0804c1.24697 0.34447 2.13039 1.32473 2.32019 2.57456 0.06515 0.42898 0.06541
55.8484 0.0003 56.28-0.188067 1.2461-1.07608 2.2305-2.32306 2.5752l-0.288567
0.08h-16.755c-13.5267 0-16.7958
0-16.9665-0.034zm29.8065-31.1862v-19.23h-12.99-12.99v19.23 19.23h12.99
12.99v-19.23zm-13.459
11.687c-1.03547-0.2354-1.77837-1.1208-1.83292-2.1845l-0.01654-0.3225h1.87175c1.02946
0 2.10645 0.01 2.3933 0.02l0.521553 0.02-0.01945 0.253c-0.02847 0.3705-0.09559
0.6134-0.267159 0.9672-0.135477 0.2794-0.18522 0.3474-0.439626 0.6013-0.31197
0.3114-0.571617 0.4707-0.976866 0.5995-0.269196 0.085-0.949163 0.111-1.23404
0.046zm-9.04096-4.1842v-0.6872l1.10534-1.0831 1.10534-1.0831
0.02483-1.2072c0.01366-0.664 0.02781-2.213 0.03145-3.4422 0.007-2.3727
0.01776-2.5909 0.162279-3.3 0.234013-1.1483 0.861931-2.2993 1.7263-3.1643
0.762874-0.7634 1.91951-1.4813 3.00204-1.8633 0.262572-0.093 0.512691-0.1813
0.555819-0.1969l0.07842-0.029 0.01577-0.426c0.01284-0.3469 0.03018-0.4706
0.09332-0.666 0.197394-0.6109 0.642609-1.0525 1.21018-1.2004 0.365688-0.095
0.860153-0.043 1.2089 0.1282 0.234414 0.1149 0.589851 0.4783 0.725931 0.7422
0.171483 0.3325 0.207933 0.491 0.225975 0.9825 0.01148 0.3126 0.02671 0.4425
0.0519 0.4425 0.01961 0 0.2844 0.088 0.588423 0.1954 2.74734 0.9715 4.21726
2.7794 4.71985 5.805 0.171696 1.0336 0.211308 1.7926 0.259098 4.9646l0.03345
2.22 1.10911 1.095 1.1091 1.095-0.0014 0.6825-0.0014 0.6825h-9.57-9.57v-0.6872z" />
    </group>
</vector>
+12 −0
Original line number Diff line number Diff line
@@ -54,6 +54,17 @@
    <!-- Announcement made when heads up changes to on (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_heads_up_changed_on">Heads up turned on.</string>

    <!-- Content description of the ambient display tile in quick settings when off (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_ambient_display_off">Ambient Display off.</string>
    <!-- Content description of the ambient display tile in quick settings when on (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_ambient_display_on">Ambient Display on.</string>

    <!-- Announcement made when ambient display changes to off (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_ambient_display_changed_off">Ambient Display turned off.</string>
    <!-- Announcement made when ambient display changes to on (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_ambient_display_changed_on">Ambient Display turned on.</string>


    <string name="accessibility_dpad_left">Cursor left</string>
    <string name="accessibility_dpad_right">Cursor right</string>

@@ -92,6 +103,7 @@
    <string name="quick_settings_screen_timeout_detail_title">Screen timeout</string>
    <string name="quick_settings_usb_tether_label">USB tethering</string>
    <string name="quick_settings_heads_up_label">Heads up</string>
    <string name="quick_settings_ambient_display_label">Ambient Display</string>

    <!-- Weather string format in expanded statusbar header -->
    <string name="status_bar_expanded_header_weather_format"><xliff:g id="temp">%1$s</xliff:g> - <xliff:g id="condition">%2$s</xliff:g></string>
+99 −0
Original line number Diff line number Diff line
/*
 * 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.
 */

package com.android.systemui.qs.tiles;

import android.content.Context;
import android.content.Intent;
import android.provider.Settings;
import android.provider.Settings.Secure;

import com.android.systemui.qs.SecureSetting;
import com.android.systemui.qs.QSTile;
import com.android.systemui.R;

/** Quick settings tile: Ambient Display **/
public class AmbientDisplayTile extends QSTile<QSTile.BooleanState> {

    private static final Intent DISPLAY_SETTINGS = new Intent("android.settings.DISPLAY_SETTINGS");

    private final SecureSetting mSetting;

    public AmbientDisplayTile(Host host) {
        super(host);

        mSetting = new SecureSetting(mContext, mHandler, Secure.DOZE_ENABLED) {
            @Override
            protected void handleValueChanged(int value, boolean observedChange) {
                handleRefreshState(value);
            }
        };
    }

    @Override
    protected BooleanState newTileState() {
        return new BooleanState();
    }

    @Override
    protected void handleClick() {
        setEnabled(!mState.value);
        refreshState();
    }

    @Override
    protected void handleLongClick() {
        mHost.startSettingsActivity(DISPLAY_SETTINGS);
    }

    private void setEnabled(boolean enabled) {
        Settings.Secure.putInt(mContext.getContentResolver(),
                Settings.Secure.DOZE_ENABLED,
                enabled ? 1 : 0);
    }

    @Override
    protected void handleUpdateState(BooleanState state, Object arg) {
        final int value = arg instanceof Integer ? (Integer)arg : mSetting.getValue();
        final boolean enable = value != 0;
        state.value = enable;
        state.visible = true;
        state.label = mContext.getString(R.string.quick_settings_ambient_display_label);
        if (enable) {
            state.icon = ResourceIcon.get(R.drawable.ic_qs_ambientdisplay_on);
            state.contentDescription =  mContext.getString(
                    R.string.accessibility_quick_settings_ambient_display_on);
        } else {
            state.icon = ResourceIcon.get(R.drawable.ic_qs_ambientdisplay_off);
            state.contentDescription =  mContext.getString(
                    R.string.accessibility_quick_settings_ambient_display_off);
        }
    }

    @Override
    protected String composeChangeAnnouncement() {
        if (mState.value) {
            return mContext.getString(R.string.accessibility_quick_settings_ambient_display_changed_on);
        } else {
            return mContext.getString(R.string.accessibility_quick_settings_ambient_display_changed_off);
        }
    }

    @Override
    public void setListening(boolean listening) {
        // Do nothing
    }
}
Loading