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

Commit b1303024 authored by Alejandro Nijamkin's avatar Alejandro Nijamkin Committed by Ale Nijamkin
Browse files

Adds LongPressHandlingView to KeyguardRootView.

- The settings popup was previously migrated to KeyguardRootView but the
  long-press handling view that handles the long-press to show the
  settings popup was not.
- The reason is was working is by accident: the KeyguardRootView was
  rendering on top (z order) of the NotificationPanelView and the
  NotificaitonPanelView did contain the original LongPressHandlingView.
  Hence, long-press touches were passing through KeyguardRootView and
  did in fact work to show the settings popup menu.
- This CL moves the LongPressHandlingView into KeyguardRootView and
  removes it from the NotificationPanelView based on the feature flag.

In addition:
- Adding the LongPressHandlingView to KeyguardRootView meant adding an
  additional ConstraintLayout "section":
  DefaultLongPressHandlingSection.
- The interface for KeyguardSection was moved to the shared.model
  package because it was previously in the data layer but referenced
  from the UI layer, which breaks the Clean Architecture Dependnecy Rule.
- The long-press handling view binder was updtes to also monitor for
  interactions on the same view that need to dismiss the settings popup
  menu, greatly simplifying what external invocations need to do to
  connect the long-press to the settings popup bindings.

Fix: 278057014
Test: manually verified that long-pressing empty space on the lock
screen brings up the settings popup with and without the "split bottom
area" feature flag being enabled.
Test: manually verified that tapping/touching outside the popup menu
once it shows up, hides it. Again, with the flag on and off.

Change-Id: I59bb4d54fb92c55266fed71dfa652c8025a6dd6c
Merged-In: I59bb4d54fb92c55266fed71dfa652c8025a6dd6c
parent 211eeaa2
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -89,8 +89,9 @@ class LongPressHandlingView(
    }
    }


    @SuppressLint("ClickableViewAccessibility")
    @SuppressLint("ClickableViewAccessibility")
    override fun onTouchEvent(event: MotionEvent?): Boolean {
    override fun onTouchEvent(event: MotionEvent): Boolean {
        return interactionHandler.onTouchEvent(event?.toModel())
        super.onTouchEvent(event)
        return interactionHandler.onTouchEvent(event.toModel())
    }
    }
}
}


+33 −3
Original line number Original line Diff line number Diff line
@@ -24,12 +24,15 @@ import com.android.keyguard.KeyguardStatusViewController
import com.android.keyguard.dagger.KeyguardStatusViewComponent
import com.android.keyguard.dagger.KeyguardStatusViewComponent
import com.android.systemui.CoreStartable
import com.android.systemui.CoreStartable
import com.android.systemui.R
import com.android.systemui.R
import com.android.systemui.animation.view.LaunchableLinearLayout
import com.android.systemui.common.ui.view.LongPressHandlingView
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.flags.Flags
import com.android.systemui.keyguard.ui.binder.KeyguardAmbientIndicationAreaViewBinder
import com.android.systemui.keyguard.ui.binder.KeyguardAmbientIndicationAreaViewBinder
import com.android.systemui.keyguard.ui.binder.KeyguardBlueprintViewBinder
import com.android.systemui.keyguard.ui.binder.KeyguardBlueprintViewBinder
import com.android.systemui.keyguard.ui.binder.KeyguardIndicationAreaBinder
import com.android.systemui.keyguard.ui.binder.KeyguardIndicationAreaBinder
import com.android.systemui.keyguard.ui.binder.KeyguardLongPressViewBinder
import com.android.systemui.keyguard.ui.binder.KeyguardQuickAffordanceViewBinder
import com.android.systemui.keyguard.ui.binder.KeyguardQuickAffordanceViewBinder
import com.android.systemui.keyguard.ui.binder.KeyguardRootViewBinder
import com.android.systemui.keyguard.ui.binder.KeyguardRootViewBinder
import com.android.systemui.keyguard.ui.binder.KeyguardSettingsViewBinder
import com.android.systemui.keyguard.ui.binder.KeyguardSettingsViewBinder
@@ -38,6 +41,7 @@ import com.android.systemui.keyguard.ui.view.layout.KeyguardBlueprintCommandList
import com.android.systemui.keyguard.ui.viewmodel.KeyguardAmbientIndicationViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardAmbientIndicationViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardBlueprintViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardBlueprintViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardIndicationAreaViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardIndicationAreaViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardLongPressViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardQuickAffordancesCombinedViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardQuickAffordancesCombinedViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardRootViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardRootViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardSettingsMenuViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardSettingsMenuViewModel
@@ -76,6 +80,7 @@ constructor(
    private val falsingManager: FalsingManager,
    private val falsingManager: FalsingManager,
    private val vibratorHelper: VibratorHelper,
    private val vibratorHelper: VibratorHelper,
    private val keyguardStateController: KeyguardStateController,
    private val keyguardStateController: KeyguardStateController,
    private val keyguardLongPressViewModel: KeyguardLongPressViewModel,
    private val keyguardSettingsMenuViewModel: KeyguardSettingsMenuViewModel,
    private val keyguardSettingsMenuViewModel: KeyguardSettingsMenuViewModel,
    private val activityStarter: ActivityStarter,
    private val activityStarter: ActivityStarter,
    private val occludingAppDeviceEntryMessageViewModel: OccludingAppDeviceEntryMessageViewModel,
    private val occludingAppDeviceEntryMessageViewModel: OccludingAppDeviceEntryMessageViewModel,
@@ -105,7 +110,7 @@ constructor(
        bindLeftShortcut()
        bindLeftShortcut()
        bindRightShortcut()
        bindRightShortcut()
        bindAmbientIndicationArea()
        bindAmbientIndicationArea()
        bindSettingsPopupMenu()
        bindSettingsPopupMenu(notificationPanel)


        KeyguardBlueprintViewBinder.bind(keyguardRootView, keyguardBlueprintViewModel)
        KeyguardBlueprintViewBinder.bind(keyguardRootView, keyguardBlueprintViewModel)
        keyguardBlueprintCommandListener.start()
        keyguardBlueprintCommandListener.start()
@@ -194,12 +199,34 @@ constructor(
        }
        }
    }
    }


    private fun bindSettingsPopupMenu() {
    private fun bindSettingsPopupMenu(legacyParent: ViewGroup) {
        if (featureFlags.isEnabled(Flags.MIGRATE_SPLIT_KEYGUARD_BOTTOM_AREA)) {
        if (featureFlags.isEnabled(Flags.MIGRATE_SPLIT_KEYGUARD_BOTTOM_AREA)) {
            // Remove the legacy long-press view from the NotificationPanelView where it used to be
            // before this refactor such that we only have one long-press view at the bottom of
            // KeyguardRootView.
            val legacyLongPressView = legacyParent.requireViewById<View>(R.id.keyguard_long_press)
            legacyParent.removeView(legacyLongPressView)

            val longPressView: LongPressHandlingView =
                keyguardRootView.requireViewById(R.id.keyguard_long_press)
            val settingsMenuView: LaunchableLinearLayout =
                keyguardRootView.requireViewById(R.id.keyguard_settings_button)

            // Bind the long-press view that (1) triggers the showing of the settings popup menu and
            // (2) captures touch events outside of the shown settings popup menu to hide it.
            KeyguardLongPressViewBinder.bind(
                view = longPressView,
                viewModel = keyguardLongPressViewModel,
                onSingleTap = {},
                falsingManager = falsingManager,
                settingsMenuView = settingsMenuView,
            )

            // Bind the settings popup menu.
            settingsPopupMenuHandle?.dispose()
            settingsPopupMenuHandle?.dispose()
            settingsPopupMenuHandle =
            settingsPopupMenuHandle =
                KeyguardSettingsViewBinder.bind(
                KeyguardSettingsViewBinder.bind(
                    keyguardRootView,
                    settingsMenuView,
                    keyguardSettingsMenuViewModel,
                    keyguardSettingsMenuViewModel,
                    vibratorHelper,
                    vibratorHelper,
                    activityStarter,
                    activityStarter,
@@ -208,6 +235,9 @@ constructor(
            keyguardRootView.findViewById<View?>(R.id.keyguard_settings_button)?.let {
            keyguardRootView.findViewById<View?>(R.id.keyguard_settings_button)?.let {
                keyguardRootView.removeView(it)
                keyguardRootView.removeView(it)
            }
            }
            keyguardRootView.findViewById<View?>(R.id.keyguard_long_press)?.let {
                keyguardRootView.removeView(it)
            }
        }
        }
    }
    }


+0 −8
Original line number Original line Diff line number Diff line
@@ -99,11 +99,3 @@ interface KeyguardBlueprint {


    fun apply(constraintSet: ConstraintSet)
    fun apply(constraintSet: ConstraintSet)
}
}

/**
 * Lower level modules that determine constraints for a particular section in the lockscreen root
 * view.
 */
interface KeyguardSection {
    fun apply(constraintSet: ConstraintSet)
}
+27 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright 2023 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.keyguard.shared.model

import androidx.constraintlayout.widget.ConstraintSet

/**
 * Lower level modules that determine constraints for a particular section in the lockscreen root
 * view.
 */
interface KeyguardSection {
    fun apply(constraintSet: ConstraintSet)
}
+18 −29
Original line number Original line Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.systemui.keyguard.ui.binder


import android.annotation.SuppressLint
import android.annotation.SuppressLint
import android.content.Intent
import android.content.Intent
import android.graphics.Rect
import android.graphics.drawable.Animatable2
import android.graphics.drawable.Animatable2
import android.util.Size
import android.util.Size
import android.view.View
import android.view.View
@@ -119,17 +118,6 @@ object KeyguardBottomAreaViewBinder {


        view.clipChildren = false
        view.clipChildren = false
        view.clipToPadding = false
        view.clipToPadding = false
        view.setOnTouchListener { _, event ->
            if (settingsMenu.isVisible) {
                val hitRect = Rect()
                settingsMenu.getHitRect(hitRect)
                if (!hitRect.contains(event.x.toInt(), event.y.toInt())) {
                    viewModel.onTouchedOutsideLockScreenSettingsMenu()
                }
            }

            false
        }


        val configurationBasedDimensions = MutableStateFlow(loadFromResources(view))
        val configurationBasedDimensions = MutableStateFlow(loadFromResources(view))


@@ -385,7 +373,8 @@ object KeyguardBottomAreaViewBinder {
        view.isClickable = viewModel.isClickable
        view.isClickable = viewModel.isClickable
        if (viewModel.isClickable) {
        if (viewModel.isClickable) {
            if (viewModel.useLongPress) {
            if (viewModel.useLongPress) {
                val onTouchListener = KeyguardQuickAffordanceOnTouchListener(
                val onTouchListener =
                    KeyguardQuickAffordanceOnTouchListener(
                        view,
                        view,
                        viewModel,
                        viewModel,
                        messageDisplayer,
                        messageDisplayer,
Loading