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

Commit 00f10864 authored by Alejandro Nijamkin's avatar Alejandro 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.
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:a34dbc6eb406d416ebfb155d10f97344280be7a8)

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

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

+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ import androidx.constraintlayout.widget.ConstraintSet.BOTTOM
import androidx.constraintlayout.widget.ConstraintSet.END
import androidx.constraintlayout.widget.ConstraintSet.PARENT_ID
import com.android.systemui.R
import com.android.systemui.keyguard.data.repository.KeyguardSection
import com.android.systemui.keyguard.shared.model.KeyguardSection
import javax.inject.Inject

class DefaultCommunalWidgetSection @Inject constructor() : KeyguardSection {
+33 −3
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import com.android.keyguard.KeyguardStatusViewController
import com.android.keyguard.dagger.KeyguardStatusViewComponent
import com.android.systemui.CoreStartable
import com.android.systemui.R
import com.android.systemui.animation.view.LaunchableLinearLayout
import com.android.systemui.common.ui.view.LongPressHandlingView
import com.android.systemui.communal.ui.adapter.CommunalWidgetViewAdapter
import com.android.systemui.communal.ui.binder.CommunalWidgetViewBinder
import com.android.systemui.communal.ui.viewmodel.CommunalWidgetViewModel
@@ -34,6 +36,7 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardBlueprintInteract
import com.android.systemui.keyguard.ui.binder.KeyguardAmbientIndicationAreaViewBinder
import com.android.systemui.keyguard.ui.binder.KeyguardBlueprintViewBinder
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.KeyguardRootViewBinder
import com.android.systemui.keyguard.ui.binder.KeyguardSettingsViewBinder
@@ -42,6 +45,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.KeyguardBlueprintViewModel
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.KeyguardRootViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardSettingsMenuViewModel
@@ -80,6 +84,7 @@ constructor(
    private val falsingManager: FalsingManager,
    private val vibratorHelper: VibratorHelper,
    private val keyguardStateController: KeyguardStateController,
    private val keyguardLongPressViewModel: KeyguardLongPressViewModel,
    private val keyguardSettingsMenuViewModel: KeyguardSettingsMenuViewModel,
    private val activityStarter: ActivityStarter,
    private val occludingAppDeviceEntryMessageViewModel: OccludingAppDeviceEntryMessageViewModel,
@@ -112,7 +117,7 @@ constructor(
        bindLeftShortcut()
        bindRightShortcut()
        bindAmbientIndicationArea()
        bindSettingsPopupMenu()
        bindSettingsPopupMenu(notificationPanel)
        bindCommunalWidgetArea()

        KeyguardBlueprintViewBinder.bind(keyguardRootView, keyguardBlueprintViewModel)
@@ -202,12 +207,34 @@ constructor(
        }
    }

    private fun bindSettingsPopupMenu() {
    private fun bindSettingsPopupMenu(legacyParent: ViewGroup) {
        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 =
                KeyguardSettingsViewBinder.bind(
                    keyguardRootView,
                    settingsMenuView,
                    keyguardSettingsMenuViewModel,
                    vibratorHelper,
                    activityStarter,
@@ -216,6 +243,9 @@ constructor(
            keyguardRootView.findViewById<View?>(R.id.keyguard_settings_button)?.let {
                keyguardRootView.removeView(it)
            }
            keyguardRootView.findViewById<View?>(R.id.keyguard_long_press)?.let {
                keyguardRootView.removeView(it)
            }
        }
    }

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

    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 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)
}
Loading