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

Commit 86d1c80c authored by Beverly's avatar Beverly
Browse files

Introduce new config for device entry icon longpress

So UDFPS devices don't need to manually override
config_lockIconLongPress.

Fixes: 290595381
Flag: ACONFIG com.android.systemui.device_entry_udfps_refactor NEXTFOOD
Test: manually see that UDFPS devices use a 100ms
longpress on the lock icon vs non UDFPS devices use 200ms

Change-Id: I4dabb5f4214084120562307498626b6c9e63b15c
parent 929ab9fd
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -635,9 +635,13 @@
        58.0001 29.2229,56.9551 26.8945,55.195
    </string>

    <!-- The time (in ms) needed to trigger the lock icon view's long-press affordance -->
    <!-- The time (in ms) needed to trigger the device entry icon view's long-press affordance -->
    <integer name="config_lockIconLongPress" translatable="false">200</integer>

    <!-- The time (in ms) needed to trigger the device entry icon view's long-press affordance
         when the device supports an under-display fingerprint sensor -->
    <integer name="config_udfpsDeviceEntryIconLongPress" translatable="false">100</integer>

    <!-- package name of a built-in camera app to use to restrict implicit intent resolution
         when the double-press power gesture is used. Ignored if empty. -->
    <string translatable="false" name="config_cameraGesturePackage"></string>
+7 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ import kotlinx.coroutines.DisposableHandle
class LongPressHandlingView(
    context: Context,
    attrs: AttributeSet?,
    private val longPressDuration: () -> Long,
    longPressDuration: () -> Long,
) :
    View(
        context,
@@ -89,6 +89,12 @@ class LongPressHandlingView(
        )
    }

    var longPressDuration: () -> Long
        get() = interactionHandler.longPressDuration
        set(longPressDuration) {
            interactionHandler.longPressDuration = longPressDuration
        }

    fun setLongPressHandlingEnabled(isEnabled: Boolean) {
        interactionHandler.isLongPressHandlingEnabled = isEnabled
    }
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ class LongPressHandlingViewInteractionHandler(
    /** Callback reporting the a single tap gesture was detected at the given coordinates. */
    private val onSingleTapDetected: () -> Unit,
    /** Time for the touch to be considered a long-press in ms */
    private val longPressDuration: () -> Long,
    var longPressDuration: () -> Long,
) {
    sealed class MotionEventModel {
        object Other : MotionEventModel()
+19 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import com.android.systemui.keyguard.ui.viewmodel.DeviceEntryForegroundViewModel
import com.android.systemui.keyguard.ui.viewmodel.DeviceEntryIconViewModel
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.plugins.FalsingManager
import com.android.systemui.res.R
import com.android.systemui.statusbar.VibratorHelper
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -94,6 +95,24 @@ object DeviceEntryIconViewBinder {
                        longPressHandlingView.setLongPressHandlingEnabled(isEnabled)
                    }
                }
                launch("$TAG#viewModel.isUdfpsSupported") {
                    viewModel.isUdfpsSupported.collect { udfpsSupported ->
                        longPressHandlingView.longPressDuration =
                            if (udfpsSupported) {
                                {
                                    view.resources
                                        .getInteger(R.integer.config_udfpsDeviceEntryIconLongPress)
                                        .toLong()
                                }
                            } else {
                                {
                                    view.resources
                                        .getInteger(R.integer.config_lockIconLongPress)
                                        .toLong()
                                }
                            }
                    }
                }
                launch("$TAG#viewModel.accessibilityDelegateHint") {
                    viewModel.accessibilityDelegateHint.collect { hint ->
                        view.accessibilityHintType = hint
+1 −4
Original line number Diff line number Diff line
@@ -40,10 +40,7 @@ constructor(
    attrs: AttributeSet?,
    defStyleAttrs: Int = 0,
) : FrameLayout(context, attrs, defStyleAttrs) {
    val longPressHandlingView: LongPressHandlingView =
        LongPressHandlingView(context, attrs) {
            context.resources.getInteger(R.integer.config_lockIconLongPress).toLong()
        }
    val longPressHandlingView: LongPressHandlingView = LongPressHandlingView(context, attrs)
    val iconView: ImageView = ImageView(context, attrs).apply { id = R.id.device_entry_icon_fg }
    val bgView: ImageView = ImageView(context, attrs).apply { id = R.id.device_entry_icon_bg }
    val aodFpDrawable: LottieDrawable = LottieDrawable()