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

Commit 1d81d282 authored by Matt Pietal's avatar Matt Pietal
Browse files

Shortcuts a11y - Simplify access with double-tap

Previously, double-tap would do nothing and just tell the user
to double-tap and hold to long press to activate. This isn't
necessary. Long press was only added for falsing, and is not
required when using talkback.

Fixes: 383245582
Test: atest KeyguardQuickAffordanceInteractorTest
Flag: EXEMPT bugfix
Change-Id: I0df3cc7424e145935dc2665f98b37bc5a972b102
parent 554eab73
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.keyguard.domain.interactor

import android.app.admin.DevicePolicyManager
import android.os.UserHandle
import android.view.accessibility.AccessibilityManager
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.widget.LockPatternUtils
@@ -96,6 +97,7 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() {
    @Mock private lateinit var shadeInteractor: ShadeInteractor
    @Mock private lateinit var logger: KeyguardQuickAffordancesLogger
    @Mock private lateinit var metricsLogger: KeyguardQuickAffordancesMetricsLogger
    @Mock private lateinit var accessibilityManager: AccessibilityManager

    private lateinit var underTest: KeyguardQuickAffordanceInteractor

@@ -199,11 +201,13 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() {
                backgroundDispatcher = kosmos.testDispatcher,
                appContext = context,
                communalSettingsInteractor = kosmos.communalSettingsInteractor,
                accessibilityManager = accessibilityManager,
                sceneInteractor = { kosmos.sceneInteractor },
            )
        kosmos.keyguardQuickAffordanceInteractor = underTest

        whenever(shadeInteractor.anyExpansion).thenReturn(MutableStateFlow(0f))
        whenever(accessibilityManager.isEnabled()).thenReturn(false)
    }

    @Test
@@ -671,6 +675,22 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() {
                )
        }

    @Test
    fun useLongPress_withA11yEnabled_isFalse() =
        testScope.runTest {
            whenever(accessibilityManager.isEnabled()).thenReturn(true)
            val useLongPress by collectLastValue(underTest.useLongPress())
            assertThat(useLongPress).isFalse()
        }

    @Test
    fun useLongPress_withA11yDisabled_isFalse() =
        testScope.runTest {
            whenever(accessibilityManager.isEnabled()).thenReturn(false)
            val useLongPress by collectLastValue(underTest.useLongPress())
            assertThat(useLongPress).isTrue()
        }

    @Test
    fun useLongPress_whenDocked_isFalse() =
        testScope.runTest {
+8 −0
Original line number Diff line number Diff line
@@ -68,3 +68,11 @@ fun View.onTouchListener(listener: View.OnTouchListener): DisposableHandle {
    setOnTouchListener(listener)
    return DisposableHandle { setOnTouchListener(null) }
}

/** A null listener should also set the longClickable property to false */
fun View.updateLongClickListener(listener: View.OnLongClickListener?) {
    setOnLongClickListener(listener)
    if (listener == null) {
        setLongClickable(false)
    }
}
+6 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.app.admin.DevicePolicyManager
import android.content.Context
import android.content.Intent
import android.util.Log
import android.view.accessibility.AccessibilityManager
import com.android.app.tracing.coroutines.withContextTraced as withContext
import com.android.compose.animation.scene.ObservableTransitionState
import com.android.internal.widget.LockPatternUtils
@@ -92,6 +93,7 @@ constructor(
    private val dockManager: DockManager,
    private val biometricSettingsRepository: BiometricSettingsRepository,
    private val communalSettingsInteractor: CommunalSettingsInteractor,
    private val accessibilityManager: AccessibilityManager,
    @Background private val backgroundDispatcher: CoroutineDispatcher,
    @ShadeDisplayAware private val appContext: Context,
    private val sceneInteractor: Lazy<SceneInteractor>,
@@ -115,7 +117,10 @@ constructor(
     *
     * If `false`, the UI goes back to using single taps.
     */
    fun useLongPress(): Flow<Boolean> = dockManager.retrieveIsDocked().map { !it }
    fun useLongPress(): Flow<Boolean> =
        dockManager.retrieveIsDocked().map { isDocked ->
            !isDocked && !accessibilityManager.isEnabled()
        }

    /** Returns an observable for the quick affordance at the given position. */
    suspend fun quickAffordance(
+2 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import com.android.systemui.animation.Expandable
import com.android.systemui.animation.view.LaunchableImageView
import com.android.systemui.common.shared.model.Icon
import com.android.systemui.common.ui.binder.IconViewBinder
import com.android.systemui.common.ui.view.updateLongClickListener
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.ui.viewmodel.KeyguardQuickAffordanceHapticViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardQuickAffordanceViewModel
@@ -275,6 +276,7 @@ constructor(
                    )
            } else {
                view.setOnClickListener(OnClickListener(viewModel, checkNotNull(falsingManager)))
                view.updateLongClickListener(null)
            }
        } else {
            view.onLongClickListener = null
+1 −0
Original line number Diff line number Diff line
@@ -205,6 +205,7 @@ class CustomizationProviderTest : SysuiTestCase() {
                biometricSettingsRepository = biometricSettingsRepository,
                backgroundDispatcher = testDispatcher,
                appContext = mContext,
                accessibilityManager = mock(),
                communalSettingsInteractor = kosmos.communalSettingsInteractor,
                sceneInteractor = { kosmos.sceneInteractor },
            )
Loading