Files
Lawnchair/quickstep/src/com/android/launcher3/taskbar/navbutton/AbstractNavButtonLayoutter.kt
T
Tracy Zhou 419140aede Make sure touch only goes to the nearest button when it makes sense
- In NearestTouchFrame, we can't use view bounds alone since the buttons do not have the same root (3 buttons are in the main container, while the contextual buttons are in the contextual button container). This currently caused the issue that contextual button region, when the contextual buttons are invisible, triggers overview
- Need to add an empty space in the left / top area of the button nav to prevent view clicks from going into back (that's how it works in navigationbar/)

Bug: 25768138
Test: left and right of 3 buttons don't trigger back or overview
Change-Id: Idc26c0c8ac0ecc000300a6db2e3e6251f678dada
2024-01-30 14:27:48 -08:00

90 lines
3.7 KiB
Kotlin

/*
* 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.launcher3.taskbar.navbutton
import android.content.res.Resources
import android.graphics.drawable.RotateDrawable
import android.view.Gravity
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.Space
import com.android.launcher3.R
import com.android.launcher3.Utilities
import com.android.launcher3.taskbar.navbutton.NavButtonLayoutFactory.NavButtonLayoutter
import com.android.systemui.shared.rotation.RotationButton
/**
* Meant to be a simple container for data subclasses will need
*
* Assumes that the 3 navigation buttons (back/home/recents) have already been added to
* [navButtonContainer]
*
* @property navButtonContainer ViewGroup that holds the 3 navigation buttons.
* @property endContextualContainer ViewGroup that holds the end contextual button (ex, IME
* dismiss).
* @property startContextualContainer ViewGroup that holds the start contextual button (ex, A11y).
*/
abstract class AbstractNavButtonLayoutter(
val resources: Resources,
val navButtonContainer: LinearLayout,
protected val endContextualContainer: ViewGroup,
protected val startContextualContainer: ViewGroup,
protected val imeSwitcher: ImageView?,
protected val rotationButton: RotationButton?,
protected val a11yButton: ImageView?,
protected val space: Space
) : NavButtonLayoutter {
protected val homeButton: ImageView? = navButtonContainer.findViewById(R.id.home)
protected val recentsButton: ImageView? = navButtonContainer.findViewById(R.id.recent_apps)
protected val backButton: ImageView? = navButtonContainer.findViewById(R.id.back)
init {
// setup back button drawable
if (backButton != null) {
val rotateDrawable = RotateDrawable()
rotateDrawable.drawable = backButton.context?.getDrawable(R.drawable.ic_sysbar_back)
rotateDrawable.fromDegrees = 0f
rotateDrawable.toDegrees = if (Utilities.isRtl(backButton.resources)) 90f else -90f
backButton.setImageDrawable(rotateDrawable)
}
}
fun getParamsToCenterView(): FrameLayout.LayoutParams {
val params = FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
params.gravity = Gravity.CENTER
return params;
}
open fun repositionContextualContainer(contextualContainer: ViewGroup, buttonSize: Int,
barAxisMarginStart: Int, barAxisMarginEnd: Int,
gravity: Int) {
val contextualContainerParams = FrameLayout.LayoutParams(
buttonSize, ViewGroup.LayoutParams.MATCH_PARENT)
contextualContainerParams.apply {
marginStart = barAxisMarginStart
marginEnd = barAxisMarginEnd
topMargin = 0
bottomMargin = 0
}
contextualContainerParams.gravity = gravity or Gravity.CENTER_VERTICAL
contextualContainer.layoutParams = contextualContainerParams
}
}