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

Commit b7de9166 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Track falsing touches on UserSwitcherActivity" into tm-qpr-dev

parents 19da5219 b71ea18e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<androidx.constraintlayout.widget.ConstraintLayout
<com.android.systemui.user.UserSwitcherRootView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
@@ -68,4 +68,4 @@
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintHeight_min="48dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.android.systemui.user.UserSwitcherRootView>
+9 −2
Original line number Diff line number Diff line
@@ -20,6 +20,13 @@ import android.view.MotionEvent;

// ACHTUNG!
public interface Gefingerpoken {
    boolean onInterceptTouchEvent(MotionEvent ev);
    boolean onTouchEvent(MotionEvent ev);
    /** Called when a touch is being intercepted in a ViewGroup. */
    default boolean onInterceptTouchEvent(MotionEvent ev) {
        return false;
    }

    /** Called when a touch is being handled by a view. */
    default boolean onTouchEvent(MotionEvent ev) {
        return false;
    }
}
+14 −3
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.os.Bundle
import android.os.UserManager
import android.provider.Settings
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.widget.AdapterView
@@ -38,8 +39,10 @@ import androidx.constraintlayout.helper.widget.Flow
import com.android.internal.annotations.VisibleForTesting
import com.android.internal.util.UserIcons
import com.android.settingslib.Utils
import com.android.systemui.Gefingerpoken
import com.android.systemui.R
import com.android.systemui.broadcast.BroadcastDispatcher
import com.android.systemui.classifier.FalsingCollector
import com.android.systemui.plugins.FalsingManager
import com.android.systemui.plugins.FalsingManager.LOW_PENALTY
import com.android.systemui.settings.UserTracker
@@ -61,12 +64,13 @@ class UserSwitcherActivity @Inject constructor(
    private val userSwitcherController: UserSwitcherController,
    private val broadcastDispatcher: BroadcastDispatcher,
    private val layoutInflater: LayoutInflater,
    private val falsingCollector: FalsingCollector,
    private val falsingManager: FalsingManager,
    private val userManager: UserManager,
    private val userTracker: UserTracker
) : LifecycleActivity() {

    private lateinit var parent: ViewGroup
    private lateinit var parent: UserSwitcherRootView
    private lateinit var broadcastReceiver: BroadcastReceiver
    private var popupMenu: UserSwitcherPopupMenu? = null
    private lateinit var addButton: View
@@ -202,7 +206,14 @@ class UserSwitcherActivity @Inject constructor(
            or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION)

        parent = requireViewById<ViewGroup>(R.id.user_switcher_root)
        parent = requireViewById<UserSwitcherRootView>(R.id.user_switcher_root)

        parent.touchHandler = object : Gefingerpoken {
            override fun onTouchEvent(ev: MotionEvent?): Boolean {
                falsingCollector.onTouchEvent(ev)
                return false
            }
        }

        requireViewById<View>(R.id.cancel).apply {
            setOnClickListener {
@@ -241,7 +252,7 @@ class UserSwitcherActivity @Inject constructor(
        )
        popupMenuAdapter.addAll(items)

        popupMenu = UserSwitcherPopupMenu(this, falsingManager).apply {
        popupMenu = UserSwitcherPopupMenu(this).apply {
            setAnchorView(addButton)
            setAdapter(popupMenuAdapter)
            setOnItemClickListener {
+1 −4
Original line number Diff line number Diff line
@@ -23,16 +23,13 @@ import android.view.View.MeasureSpec
import android.widget.ListAdapter
import android.widget.ListPopupWindow
import android.widget.ListView

import com.android.systemui.R
import com.android.systemui.plugins.FalsingManager

/**
 * Popup menu for displaying items on the fullscreen user switcher.
 */
class UserSwitcherPopupMenu(
    private val context: Context,
    private val falsingManager: FalsingManager
    private val context: Context
) : ListPopupWindow(context) {

    private val res = context.resources
+38 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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.user

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import androidx.constraintlayout.widget.ConstraintLayout
import com.android.systemui.Gefingerpoken

/** A simple subclass that allows for observing touch events as they happen. */
class UserSwitcherRootView(
    context: Context,
    attrs: AttributeSet?
) : ConstraintLayout(context, attrs) {

    /** Assign this field to observer touch events. */
    var touchHandler: Gefingerpoken? = null

    override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
        touchHandler?.onTouchEvent(ev)
        return super.dispatchTouchEvent(ev)
    }
}
Loading