Hide Quick Settings shade when the FontScalingDialog is opened

When the users try to modify the font size through the Quick Settings,
we would like to hide the QS shade so users could see the text content
upderlying when they are modifying the font scale.

We consider the following cases:
1. Screen unlocked: hide the shade and show the dialog
2. Screen locked: dismiss keyguard, hide the shade, and show the dialog

Bug: 282110776
Test: manually - attach video to the bug
Test: atest FontScalingTileTest
Change-Id: I66a1c6b5df903c671b4b9c0eab178c5b6de99d61
This commit is contained in:
Candice Lo
2023-05-15 04:10:00 +00:00
parent a0477eddc3
commit 40016bffce
2 changed files with 57 additions and 4 deletions

View File

@@ -40,6 +40,7 @@ import com.android.systemui.qs.logging.QSLogger
import com.android.systemui.qs.tileimpl.QSTileImpl
import com.android.systemui.settings.UserTracker
import com.android.systemui.statusbar.phone.SystemUIDialog
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.util.concurrency.DelayableExecutor
import com.android.systemui.util.settings.SecureSettings
import com.android.systemui.util.settings.SystemSettings
@@ -58,6 +59,7 @@ constructor(
statusBarStateController: StatusBarStateController,
activityStarter: ActivityStarter,
qsLogger: QSLogger,
private val keyguardStateController: KeyguardStateController,
private val dialogLaunchAnimator: DialogLaunchAnimator,
private val systemSettings: SystemSettings,
private val secureSettings: SecureSettings,
@@ -88,7 +90,10 @@ constructor(
}
override fun handleClick(view: View?) {
mUiHandler.post {
// We animate from the touched view only if we are not on the keyguard
val animateFromView: Boolean = view != null && !keyguardStateController.isShowing
val runnable = Runnable {
val dialog: SystemUIDialog =
FontScalingDialog(
mContext,
@@ -99,16 +104,26 @@ constructor(
mainHandler,
backgroundDelayableExecutor
)
if (view != null) {
if (animateFromView) {
dialogLaunchAnimator.showFromView(
dialog,
view,
view!!,
DialogCuj(InteractionJankMonitor.CUJ_SHADE_DIALOG_OPEN, INTERACTION_JANK_TAG)
)
} else {
dialog.show()
}
}
mainHandler.post {
mActivityStarter.executeRunnableDismissingKeyguard(
runnable,
/* cancelAction= */ null,
/* dismissShade= */ true,
/* afterKeyguardGone= */ true,
/* deferred= */ false
)
}
}
override fun handleUpdateState(state: QSTile.State?, arg: Any?) {

View File

@@ -34,6 +34,7 @@ import com.android.systemui.qs.QSHost
import com.android.systemui.qs.QsEventLogger
import com.android.systemui.qs.logging.QSLogger
import com.android.systemui.settings.UserTracker
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.util.concurrency.FakeExecutor
import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.eq
@@ -45,8 +46,11 @@ import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.Captor
import org.mockito.Mock
import org.mockito.Mockito.anyBoolean
import org.mockito.Mockito.never
import org.mockito.Mockito.verify
import org.mockito.Mockito.`when`
import org.mockito.MockitoAnnotations
@@ -63,6 +67,7 @@ class FontScalingTileTest : SysuiTestCase() {
@Mock private lateinit var dialogLaunchAnimator: DialogLaunchAnimator
@Mock private lateinit var uiEventLogger: QsEventLogger
@Mock private lateinit var userTracker: UserTracker
@Mock private lateinit var keyguardStateController: KeyguardStateController
private lateinit var testableLooper: TestableLooper
private lateinit var systemClock: FakeSystemClock
@@ -71,6 +76,8 @@ class FontScalingTileTest : SysuiTestCase() {
val featureFlags = FakeFeatureFlags()
@Captor private lateinit var argumentCaptor: ArgumentCaptor<Runnable>
@Before
fun setUp() {
MockitoAnnotations.initMocks(this)
@@ -90,6 +97,7 @@ class FontScalingTileTest : SysuiTestCase() {
statusBarStateController,
activityStarter,
qsLogger,
keyguardStateController,
dialogLaunchAnimator,
FakeSettings(),
FakeSettings(),
@@ -127,14 +135,44 @@ class FontScalingTileTest : SysuiTestCase() {
}
@Test
fun clickTile_showDialog() {
fun clickTile_screenUnlocked_showDialogAnimationFromView() {
`when`(keyguardStateController.isShowing).thenReturn(false)
val view = View(context)
fontScalingTile.click(view)
testableLooper.processAllMessages()
verify(activityStarter)
.executeRunnableDismissingKeyguard(
argumentCaptor.capture(),
eq(null),
eq(true),
eq(true),
eq(false)
)
argumentCaptor.value.run()
verify(dialogLaunchAnimator).showFromView(any(), eq(view), nullable(), anyBoolean())
}
@Test
fun clickTile_onLockScreen_neverShowDialogAnimationFromView() {
`when`(keyguardStateController.isShowing).thenReturn(true)
val view = View(context)
fontScalingTile.click(view)
testableLooper.processAllMessages()
verify(activityStarter)
.executeRunnableDismissingKeyguard(
argumentCaptor.capture(),
eq(null),
eq(true),
eq(true),
eq(false)
)
argumentCaptor.value.run()
verify(dialogLaunchAnimator, never())
.showFromView(any(), eq(view), nullable(), anyBoolean())
}
@Test
fun getLongClickIntent_getExpectedIntent() {
val intent: Intent? = fontScalingTile.getLongClickIntent()