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

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

Merge "Added new battery saver QS icons" into tm-qpr-dev am: 1f147b48 am: 68dd12ed

parents bcfbfc51 68dd12ed
Loading
Loading
Loading
Loading
+67 −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="time_group">
        <aapt:attr name="android:animation">
            <set android:ordering="together">
                <objectAnimator
                    android:duration="183"
                    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"
                    android:translateX="12"
                    android:translateY="12">
                    <path
                        android:name="_R_G_L_0_G_D_0_P_0"
                        android:pathData=" M3.67 -8 C3.67,-8 2,-8 2,-8 C2,-8 2,-10 2,-10 C2,-10 -2,-10 -2,-10 C-2,-10 -2,-8 -2,-8 C-2,-8 -3.67,-8 -3.67,-8 C-4.4,-8 -5,-7.4 -5,-6.67 C-5,-6.67 -5,8.66 -5,8.66 C-5,9.4 -4.4,10 -3.67,10 C-3.67,10 3.66,10 3.66,10 C4.4,10 5,9.4 5,8.67 C5,8.67 5,-6.67 5,-6.67 C5,-7.4 4.4,-8 3.67,-8c "
                        android:strokeAlpha="1"
                        android:strokeColor="#ffffff"
                        android:strokeLineCap="round"
                        android:strokeLineJoin="round"
                        android:strokeWidth="2" />
                    <path
                        android:name="_R_G_L_0_G_D_1_P_0"
                        android:fillAlpha="1"
                        android:fillColor="#ffffff"
                        android:fillType="nonZero"
                        android:pathData=" M2 -10 C2,-10 2,-7 2,-7 C2,-7 -2,-7 -2,-7 C-2,-7 -2,-10 -2,-10 C-2,-10 2,-10 2,-10c " />
                    <path
                        android:name="_R_G_L_0_G_D_2_P_0"
                        android:fillAlpha="1"
                        android:fillColor="#ffffff"
                        android:fillType="nonZero"
                        android:pathData=" M3 2 C3,2 1,2 1,2 C1,2 1,4 1,4 C1,4 -1,4 -1,4 C-1,4 -1,2 -1,2 C-1,2 -3,2 -3,2 C-3,2 -3,0 -3,0 C-3,0 -1,0 -1,0 C-1,0 -1,-2 -1,-2 C-1,-2 1,-2 1,-2 C1,-2 1,0 1,0 C1,0 3,0 3,0 C3,0 3,2 3,2c " />
                </group>
            </group>
            <group android:name="time_group" />
        </vector>
    </aapt:attr>
</animated-vector>
+636 −0

File added.

Preview size limit exceeded, changes collapsed.

+3 −3
Original line number Original line Diff line number Diff line
@@ -57,8 +57,6 @@ public class BatterySaverTile extends QSTileImpl<BooleanState> implements
    private boolean mCharging;
    private boolean mCharging;
    private boolean mPluggedIn;
    private boolean mPluggedIn;


    private Icon mIcon = ResourceIcon.get(com.android.internal.R.drawable.ic_qs_battery_saver);

    @Inject
    @Inject
    public BatterySaverTile(
    public BatterySaverTile(
            QSHost host,
            QSHost host,
@@ -145,7 +143,9 @@ public class BatterySaverTile extends QSTileImpl<BooleanState> implements
    protected void handleUpdateState(BooleanState state, Object arg) {
    protected void handleUpdateState(BooleanState state, Object arg) {
        state.state = mPluggedIn ? Tile.STATE_UNAVAILABLE
        state.state = mPluggedIn ? Tile.STATE_UNAVAILABLE
                : mPowerSave ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;
                : mPowerSave ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;
        state.icon = mIcon;
        state.icon = ResourceIcon.get(mPowerSave
                ? R.drawable.qs_battery_saver_icon_on
                : R.drawable.qs_battery_saver_icon_off);
        state.label = mContext.getString(R.string.battery_detail_switch_title);
        state.label = mContext.getString(R.string.battery_detail_switch_title);
        state.secondaryLabel = "";
        state.secondaryLabel = "";
        state.contentDescription = state.label;
        state.contentDescription = state.label;
+27 −0
Original line number Original line Diff line number Diff line
@@ -24,15 +24,19 @@ import android.testing.TestableLooper.RunWithLooper
import android.view.View
import android.view.View
import androidx.test.filters.SmallTest
import androidx.test.filters.SmallTest
import com.android.internal.logging.MetricsLogger
import com.android.internal.logging.MetricsLogger
import com.android.systemui.R
import com.android.systemui.SysuiTestCase
import com.android.systemui.SysuiTestCase
import com.android.systemui.classifier.FalsingManagerFake
import com.android.systemui.classifier.FalsingManagerFake
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.plugins.qs.QSTile
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.qs.QSHost
import com.android.systemui.qs.QSHost
import com.android.systemui.qs.logging.QSLogger
import com.android.systemui.qs.logging.QSLogger
import com.android.systemui.qs.tileimpl.QSTileImpl
import com.android.systemui.statusbar.policy.BatteryController
import com.android.systemui.statusbar.policy.BatteryController
import com.android.systemui.util.settings.FakeSettings
import com.android.systemui.util.settings.FakeSettings
import com.android.systemui.util.settings.SecureSettings
import com.android.systemui.util.settings.SecureSettings
import com.google.common.truth.Truth.assertThat
import org.junit.Assert.assertEquals
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Before
import org.junit.Test
import org.junit.Test
@@ -77,6 +81,7 @@ class BatterySaverTileTest : SysuiTestCase() {
    fun setUp() {
    fun setUp() {
        MockitoAnnotations.initMocks(this)
        MockitoAnnotations.initMocks(this)
        testableLooper = TestableLooper.get(this)
        testableLooper = TestableLooper.get(this)
        `when`(qsHost.context).thenReturn(mContext)
        `when`(qsHost.userContext).thenReturn(userContext)
        `when`(qsHost.userContext).thenReturn(userContext)
        `when`(userContext.userId).thenReturn(USER)
        `when`(userContext.userId).thenReturn(USER)


@@ -133,4 +138,26 @@ class BatterySaverTileTest : SysuiTestCase() {
        tile.handleSetListening(false)
        tile.handleSetListening(false)
        verify(batteryController).clearLastPowerSaverStartView()
        verify(batteryController).clearLastPowerSaverStartView()
    }
    }

    @Test
    fun testIcon_whenBatterySaverDisabled_isOffState() {
        val state = QSTile.BooleanState()
        tile.onPowerSaveChanged(false)

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

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

    @Test
    fun testIcon_whenBatterySaverEnabled_isOnState() {
        val state = QSTile.BooleanState()
        tile.onPowerSaveChanged(true)

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

        assertThat(state.icon)
                .isEqualTo(QSTileImpl.ResourceIcon.get(R.drawable.qs_battery_saver_icon_on))
    }
}
}
 No newline at end of file