From 9d4cd67fdc2a519e01fc4ac2cdcb77687e1477f5 Mon Sep 17 00:00:00 2001 From: Rasheed Lewis Date: Tue, 26 Apr 2022 13:28:21 +0000 Subject: [PATCH] Replaced QS Microphone Access Icons w/ Animations Test: Unit and manually tested Fixes: 230350263 Change-Id: I0712e1b7db05d90321a01625d2c426c418b1140d --- .../res/drawable/qs_mic_access_off.xml | 212 ++++++++++++++++++ .../res/drawable/qs_mic_access_on.xml | 212 ++++++++++++++++++ .../qs/tiles/MicrophoneToggleTile.java | 4 +- .../qs/tiles/MicrophoneToggleTileTest.kt | 110 +++++++++ 4 files changed, 536 insertions(+), 2 deletions(-) create mode 100644 packages/SystemUI/res/drawable/qs_mic_access_off.xml create mode 100644 packages/SystemUI/res/drawable/qs_mic_access_on.xml create mode 100644 packages/SystemUI/tests/src/com/android/systemui/qs/tiles/MicrophoneToggleTileTest.kt diff --git a/packages/SystemUI/res/drawable/qs_mic_access_off.xml b/packages/SystemUI/res/drawable/qs_mic_access_off.xml new file mode 100644 index 0000000000000..63a94443c2559 --- /dev/null +++ b/packages/SystemUI/res/drawable/qs_mic_access_off.xml @@ -0,0 +1,212 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/SystemUI/res/drawable/qs_mic_access_on.xml b/packages/SystemUI/res/drawable/qs_mic_access_on.xml new file mode 100644 index 0000000000000..b485f06d1bf28 --- /dev/null +++ b/packages/SystemUI/res/drawable/qs_mic_access_on.xml @@ -0,0 +1,212 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/MicrophoneToggleTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/MicrophoneToggleTile.java index f4f0b2cdc432a..e54709562c101 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/MicrophoneToggleTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/MicrophoneToggleTile.java @@ -72,9 +72,9 @@ public class MicrophoneToggleTile extends SensorPrivacyToggleTile { @Override public @DrawableRes int getIconRes(boolean isBlocked) { if (isBlocked) { - return com.android.internal.R.drawable.ic_mic_blocked; + return R.drawable.qs_mic_access_off; } else { - return com.android.internal.R.drawable.ic_mic_allowed; + return R.drawable.qs_mic_access_on; } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/MicrophoneToggleTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/MicrophoneToggleTileTest.kt new file mode 100644 index 0000000000000..1ab601ce3ebee --- /dev/null +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/MicrophoneToggleTileTest.kt @@ -0,0 +1,110 @@ +/* + * 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.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.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.IndividualSensorPrivacyController +import com.android.systemui.statusbar.policy.KeyguardStateController +import com.google.common.truth.Truth.assertThat +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.Mock +import org.mockito.MockitoAnnotations +import org.mockito.Mockito.`when` as whenever + +@RunWith(AndroidTestingRunner::class) +@TestableLooper.RunWithLooper(setAsMainLooper = true) +@SmallTest +class MicrophoneToggleTileTest : SysuiTestCase() { + companion object { + /* isBlocked */ + const val MICROPHONE_TOGGLE_ENABLED: Boolean = false + const val MICROPHONE_TOGGLE_DISABLED: Boolean = true + } + + @Mock + private lateinit var host: QSHost + @Mock + private lateinit var metricsLogger: MetricsLogger + @Mock + private lateinit var statusBarStateController: StatusBarStateController + @Mock + private lateinit var activityStarter: ActivityStarter + @Mock + private lateinit var qsLogger: QSLogger + @Mock + private lateinit var privacyController: IndividualSensorPrivacyController + @Mock + private lateinit var keyguardStateController: KeyguardStateController + + private lateinit var testableLooper: TestableLooper + private lateinit var tile: MicrophoneToggleTile + private val uiEventLogger: UiEventLogger = UiEventLoggerFake() + + @Before + fun setUp() { + MockitoAnnotations.initMocks(this) + testableLooper = TestableLooper.get(this) + whenever(host.context).thenReturn(mContext) + whenever(host.uiEventLogger).thenReturn(uiEventLogger) + + tile = MicrophoneToggleTile(host, + testableLooper.looper, + Handler(testableLooper.looper), + metricsLogger, + FalsingManagerFake(), + statusBarStateController, + activityStarter, + qsLogger, + privacyController, + keyguardStateController) + } + + @Test + fun testIcon_whenMicrophoneAccessEnabled_isOnState() { + val state = QSTile.BooleanState() + + tile.handleUpdateState(state, MICROPHONE_TOGGLE_ENABLED) + + assertThat(state.icon).isEqualTo(QSTileImpl.ResourceIcon.get(R.drawable.qs_mic_access_on)) + } + + @Test + fun testIcon_whenMicrophoneAccessDisabled_isOffState() { + val state = QSTile.BooleanState() + + tile.handleUpdateState(state, MICROPHONE_TOGGLE_DISABLED) + + assertThat(state.icon).isEqualTo(QSTileImpl.ResourceIcon.get(R.drawable.qs_mic_access_off)) + } +}