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

Commit e5dff358 authored by Rasheed Lewis's avatar Rasheed Lewis Committed by Automerger Merge Worker
Browse files

Merge "Added Animated Nightlight QS Tile Icons" into tm-qpr-dev am: 5669430c

parents 95385f38 5669430c
Loading
Loading
Loading
Loading
+94 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!--
    Copyright (C) 2022 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.
-->
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:aapt="http://schemas.android.com/aapt">
    <target android:name="_R_G_L_0_G_T_1">
        <aapt:attr name="android:animation">
            <set android:ordering="together">
                <objectAnimator
                    android:duration="283"
                    android:propertyName="translateY"
                    android:startOffset="0"
                    android:valueFrom="12.125"
                    android:valueTo="12.312"
                    android:valueType="floatType">
                    <aapt:attr name="android:interpolator">
                        <pathInterpolator android:pathData="M 0.0,0.0 c0.3,0 0.1,1 1.0,1.0" />
                    </aapt:attr>
                </objectAnimator>
            </set>
        </aapt:attr>
    </target>
    <target android:name="_R_G_L_0_G_T_1">
        <aapt:attr name="android:animation">
            <set android:ordering="together">
                <objectAnimator
                    android:duration="283"
                    android:propertyName="rotation"
                    android:startOffset="0"
                    android:valueFrom="-45"
                    android:valueTo="0"
                    android:valueType="floatType">
                    <aapt:attr name="android:interpolator">
                        <pathInterpolator android:pathData="M 0.0,0.0 c0.3,0 0.1,1 1.0,1.0" />
                    </aapt:attr>
                </objectAnimator>
            </set>
        </aapt:attr>
    </target>
    <target android:name="time_group">
        <aapt:attr name="android:animation">
            <set android:ordering="together">
                <objectAnimator
                    android:duration="300"
                    android:propertyName="translateX"
                    android:startOffset="0"
                    android:valueFrom="0"
                    android:valueTo="1"
                    android:valueType="floatType" />
            </set>
        </aapt:attr>
    </target>
    <aapt:attr name="android:drawable">
        <vector
            android:width="24dp"
            android:height="24dp"
            android:viewportHeight="24"
            android:viewportWidth="24">
            <group android:name="_R_G">
                <group
                    android:name="_R_G_L_0_G_T_1"
                    android:rotation="-45"
                    android:translateX="12.875"
                    android:translateY="12.125">
                    <group
                        android:name="_R_G_L_0_G"
                        android:translateX="-2.375">
                        <path
                            android:name="_R_G_L_0_G_D_0_P_0"
                            android:pathData=" M3.33 8.62 C2.09,8.68 0.59,8.47 -0.64,7.95 C-1.65,7.53 -2.75,6.9 -3.59,6.09 C-4.38,5.32 -5.19,4.17 -5.61,3.08 C-6.04,1.99 -6.25,0.83 -6.25,-0.39 C-6.25,-1.72 -5.98,-2.85 -5.55,-3.94 C-5.13,-5.02 -4.37,-6 -3.59,-6.78 C-2.63,-7.75 -1.63,-8.28 -0.52,-8.77 C0.48,-9.2 2.04,-9.41 3.15,-9.38 C4.22,-9.35 4.94,-9.16 5.81,-8.79 C5.95,-8.73 6.28,-8.6 6.18,-8.55 C3.44,-6.63 1.83,-3.66 1.83,-0.39 C1.83,2.53 3.47,5.72 6.15,7.86 C6.16,7.9 6.03,7.97 5.91,8.04 C5.12,8.44 4.31,8.56 3.33,8.62c "
                            android:strokeAlpha="1"
                            android:strokeColor="#ffffff"
                            android:strokeLineCap="round"
                            android:strokeLineJoin="round"
                            android:strokeWidth="2" />
                    </group>
                </group>
            </group>
            <group android:name="time_group" />
        </vector>
    </aapt:attr>
</animated-vector>
+94 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!--
    Copyright (C) 2022 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.
-->
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:aapt="http://schemas.android.com/aapt">
    <target android:name="_R_G_L_0_G_T_1">
        <aapt:attr name="android:animation">
            <set android:ordering="together">
                <objectAnimator
                    android:duration="400"
                    android:propertyName="translateY"
                    android:startOffset="0"
                    android:valueFrom="12.312"
                    android:valueTo="12.125"
                    android:valueType="floatType">
                    <aapt:attr name="android:interpolator">
                        <pathInterpolator android:pathData="M 0.0,0.0 c0.3,0 0.1,1 1.0,1.0" />
                    </aapt:attr>
                </objectAnimator>
            </set>
        </aapt:attr>
    </target>
    <target android:name="_R_G_L_0_G_T_1">
        <aapt:attr name="android:animation">
            <set android:ordering="together">
                <objectAnimator
                    android:duration="400"
                    android:propertyName="rotation"
                    android:startOffset="0"
                    android:valueFrom="0"
                    android:valueTo="-45"
                    android:valueType="floatType">
                    <aapt:attr name="android:interpolator">
                        <pathInterpolator android:pathData="M 0.0,0.0 c0.3,0 0.1,1 1.0,1.0" />
                    </aapt:attr>
                </objectAnimator>
            </set>
        </aapt:attr>
    </target>
    <target android:name="time_group">
        <aapt:attr name="android:animation">
            <set android:ordering="together">
                <objectAnimator
                    android:duration="417"
                    android:propertyName="translateX"
                    android:startOffset="0"
                    android:valueFrom="0"
                    android:valueTo="1"
                    android:valueType="floatType" />
            </set>
        </aapt:attr>
    </target>
    <aapt:attr name="android:drawable">
        <vector
            android:width="24dp"
            android:height="24dp"
            android:viewportHeight="24"
            android:viewportWidth="24">
            <group android:name="_R_G">
                <group
                    android:name="_R_G_L_0_G_T_1"
                    android:rotation="0"
                    android:translateX="12.875"
                    android:translateY="12.312">
                    <group
                        android:name="_R_G_L_0_G"
                        android:translateX="-2.375">
                        <path
                            android:name="_R_G_L_0_G_D_0_P_0"
                            android:pathData=" M3.33 8.62 C2.09,8.68 0.59,8.47 -0.64,7.95 C-1.65,7.53 -2.75,6.9 -3.59,6.09 C-4.38,5.32 -5.19,4.17 -5.61,3.08 C-6.04,1.99 -6.25,0.83 -6.25,-0.39 C-6.25,-1.72 -5.98,-2.85 -5.55,-3.94 C-5.13,-5.02 -4.37,-6 -3.6,-6.78 C-2.63,-7.75 -1.63,-8.28 -0.52,-8.77 C0.48,-9.2 2.04,-9.41 3.14,-9.38 C4.22,-9.35 4.94,-9.16 5.81,-8.79 C5.94,-8.73 6.28,-8.6 6.18,-8.55 C3.44,-6.63 1.83,-3.66 1.83,-0.39 C1.83,2.53 3.47,5.72 6.15,7.86 C6.16,7.9 6.03,7.97 5.91,8.04 C5.13,8.43 4.31,8.56 3.33,8.62c "
                            android:strokeAlpha="1"
                            android:strokeColor="#ffffff"
                            android:strokeLineCap="round"
                            android:strokeLineJoin="round"
                            android:strokeWidth="2" />
                    </group>
                </group>
            </group>
            <group android:name="time_group" />
        </vector>
    </aapt:attr>
</animated-vector>
+2 −1
Original line number Original line Diff line number Diff line
@@ -144,9 +144,10 @@ public class NightDisplayTile extends QSTileImpl<BooleanState> implements
    protected void handleUpdateState(BooleanState state, Object arg) {
    protected void handleUpdateState(BooleanState state, Object arg) {
        state.value = mManager.isNightDisplayActivated();
        state.value = mManager.isNightDisplayActivated();
        state.label = mContext.getString(R.string.quick_settings_night_display_label);
        state.label = mContext.getString(R.string.quick_settings_night_display_label);
        state.icon = ResourceIcon.get(com.android.internal.R.drawable.ic_qs_night_display_on);
        state.expandedAccessibilityClassName = Switch.class.getName();
        state.expandedAccessibilityClassName = Switch.class.getName();
        state.state = state.value ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;
        state.state = state.value ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;
        state.icon = ResourceIcon.get(state.value ? R.drawable.qs_nightlight_icon_on
                : R.drawable.qs_nightlight_icon_off);
        state.secondaryLabel = getSecondaryLabel(state.value);
        state.secondaryLabel = getSecondaryLabel(state.value);
        state.contentDescription = TextUtils.isEmpty(state.secondaryLabel)
        state.contentDescription = TextUtils.isEmpty(state.secondaryLabel)
                ? state.label
                ? state.label
+132 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2022 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.
 */

package com.android.systemui.qs.tiles

import android.hardware.display.ColorDisplayManager
import android.hardware.display.NightDisplayListener
import android.os.Handler
import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import androidx.test.filters.SmallTest
import com.android.internal.logging.MetricsLogger
import com.android.internal.logging.UiEventLogger
import com.android.internal.logging.testing.UiEventLoggerFake
import com.android.systemui.R
import com.android.systemui.SysuiTestCase
import com.android.systemui.classifier.FalsingManagerFake
import com.android.systemui.dagger.NightDisplayListenerModule
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.plugins.qs.QSTile
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.qs.QSHost
import com.android.systemui.qs.logging.QSLogger
import com.android.systemui.qs.tileimpl.QSTileImpl
import com.android.systemui.statusbar.policy.LocationController
import com.google.common.truth.Truth
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock
import org.mockito.Mockito.anyInt
import org.mockito.Mockito.`when` as whenever
import org.mockito.MockitoAnnotations

@RunWith(AndroidTestingRunner::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
@SmallTest
class NightDisplayTileTest : SysuiTestCase() {
    @Mock
    private lateinit var mHost: QSHost

    @Mock
    private lateinit var mMetricsLogger: MetricsLogger

    @Mock
    private lateinit var mStatusBarStateController: StatusBarStateController

    @Mock
    private lateinit var mActivityStarter: ActivityStarter

    @Mock
    private lateinit var mQsLogger: QSLogger

    @Mock
    private lateinit var mLocationController: LocationController

    @Mock
    private lateinit var mColorDisplayManager: ColorDisplayManager

    @Mock
    private lateinit var mNightDisplayListenerBuilder: NightDisplayListenerModule.Builder

    @Mock
    private lateinit var mNightDisplayListener: NightDisplayListener

    private lateinit var mTestableLooper: TestableLooper
    private lateinit var mTile: NightDisplayTile

    private val mUiEventLogger: UiEventLogger = UiEventLoggerFake()

    @Before
    fun setUp() {
        MockitoAnnotations.initMocks(this)
        mTestableLooper = TestableLooper.get(this)
        whenever(mHost.context).thenReturn(mContext)
        whenever(mHost.uiEventLogger).thenReturn(mUiEventLogger)
        whenever(mHost.userContext).thenReturn(mContext)
        whenever(mNightDisplayListenerBuilder.setUser(anyInt())).thenReturn(
            mNightDisplayListenerBuilder
        )
        whenever(mNightDisplayListenerBuilder.build()).thenReturn(mNightDisplayListener)

        mTile = NightDisplayTile(
            mHost,
            mTestableLooper.looper,
            Handler(mTestableLooper.looper),
            FalsingManagerFake(),
            mMetricsLogger,
            mStatusBarStateController,
            mActivityStarter,
            mQsLogger,
            mLocationController,
            mColorDisplayManager,
            mNightDisplayListenerBuilder
        )
    }

    @Test
    fun testIcon_whenDisabled_showsOffState() {
        whenever(mColorDisplayManager.isNightDisplayActivated).thenReturn(false)
        val state = QSTile.BooleanState()

        mTile.handleUpdateState(state, /* arg= */ null)

        Truth.assertThat(state.icon)
            .isEqualTo(QSTileImpl.ResourceIcon.get(R.drawable.qs_nightlight_icon_off))
    }

    @Test
    fun testIcon_whenEnabled_showsOnState() {
        whenever(mColorDisplayManager.isNightDisplayActivated).thenReturn(true)
        val state = QSTile.BooleanState()

        mTile.handleUpdateState(state, /* arg= */ null)

        Truth.assertThat(state.icon)
            .isEqualTo(QSTileImpl.ResourceIcon.get(R.drawable.qs_nightlight_icon_on))
    }
}