Merge "Use public types to setup InsetsFrameProviders of taskbar" into udc-dev
This commit is contained in:
@@ -17,18 +17,18 @@ package com.android.launcher3.taskbar
|
|||||||
|
|
||||||
import android.graphics.Insets
|
import android.graphics.Insets
|
||||||
import android.graphics.Region
|
import android.graphics.Region
|
||||||
|
import android.os.Binder
|
||||||
|
import android.os.IBinder
|
||||||
import android.view.InsetsFrameProvider
|
import android.view.InsetsFrameProvider
|
||||||
import android.view.InsetsFrameProvider.SOURCE_DISPLAY
|
import android.view.InsetsFrameProvider.SOURCE_DISPLAY
|
||||||
import android.view.InsetsFrameProvider.SOURCE_FRAME
|
|
||||||
import android.view.InsetsState
|
|
||||||
import android.view.InsetsState.ITYPE_BOTTOM_MANDATORY_GESTURES
|
|
||||||
import android.view.InsetsState.ITYPE_BOTTOM_TAPPABLE_ELEMENT
|
|
||||||
import android.view.InsetsState.ITYPE_EXTRA_NAVIGATION_BAR
|
|
||||||
import android.view.InsetsState.ITYPE_LEFT_GESTURES
|
|
||||||
import android.view.InsetsState.ITYPE_RIGHT_GESTURES
|
|
||||||
import android.view.ViewTreeObserver
|
import android.view.ViewTreeObserver
|
||||||
import android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME
|
import android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME
|
||||||
import android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION
|
import android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION
|
||||||
|
import android.view.WindowInsets
|
||||||
|
import android.view.WindowInsets.Type.mandatorySystemGestures
|
||||||
|
import android.view.WindowInsets.Type.navigationBars
|
||||||
|
import android.view.WindowInsets.Type.systemGestures
|
||||||
|
import android.view.WindowInsets.Type.tappableElement
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD
|
import android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD
|
||||||
import android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION
|
import android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION
|
||||||
@@ -44,9 +44,15 @@ import java.io.PrintWriter
|
|||||||
/** Handles the insets that Taskbar provides to underlying apps and the IME. */
|
/** Handles the insets that Taskbar provides to underlying apps and the IME. */
|
||||||
class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTaskbarController {
|
class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTaskbarController {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val INDEX_LEFT = 0
|
||||||
|
private const val INDEX_RIGHT = 1
|
||||||
|
}
|
||||||
|
|
||||||
/** The bottom insets taskbar provides to the IME when IME is visible. */
|
/** The bottom insets taskbar provides to the IME when IME is visible. */
|
||||||
val taskbarHeightForIme: Int = context.resources.getDimensionPixelSize(R.dimen.taskbar_ime_size)
|
val taskbarHeightForIme: Int = context.resources.getDimensionPixelSize(R.dimen.taskbar_ime_size)
|
||||||
private val touchableRegion: Region = Region()
|
private val touchableRegion: Region = Region()
|
||||||
|
private val insetsOwner: IBinder = Binder()
|
||||||
private val deviceProfileChangeListener = { _: DeviceProfile ->
|
private val deviceProfileChangeListener = { _: DeviceProfile ->
|
||||||
onTaskbarWindowHeightOrInsetsChanged()
|
onTaskbarWindowHeightOrInsetsChanged()
|
||||||
}
|
}
|
||||||
@@ -64,17 +70,15 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
|
|||||||
fun init(controllers: TaskbarControllers) {
|
fun init(controllers: TaskbarControllers) {
|
||||||
this.controllers = controllers
|
this.controllers = controllers
|
||||||
windowLayoutParams = context.windowLayoutParams
|
windowLayoutParams = context.windowLayoutParams
|
||||||
|
windowLayoutParams.providedInsets =
|
||||||
setProvidesInsetsTypes(
|
arrayOf(
|
||||||
windowLayoutParams,
|
InsetsFrameProvider(insetsOwner, 0, navigationBars()),
|
||||||
intArrayOf(
|
InsetsFrameProvider(insetsOwner, 0, tappableElement()),
|
||||||
ITYPE_EXTRA_NAVIGATION_BAR,
|
InsetsFrameProvider(insetsOwner, 0, mandatorySystemGestures()),
|
||||||
ITYPE_BOTTOM_TAPPABLE_ELEMENT,
|
InsetsFrameProvider(insetsOwner, INDEX_LEFT, systemGestures())
|
||||||
ITYPE_BOTTOM_MANDATORY_GESTURES,
|
.setSource(SOURCE_DISPLAY),
|
||||||
ITYPE_LEFT_GESTURES,
|
InsetsFrameProvider(insetsOwner, INDEX_RIGHT, systemGestures())
|
||||||
ITYPE_RIGHT_GESTURES,
|
.setSource(SOURCE_DISPLAY)
|
||||||
),
|
|
||||||
intArrayOf(SOURCE_FRAME, SOURCE_FRAME, SOURCE_FRAME, SOURCE_DISPLAY, SOURCE_DISPLAY)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
onTaskbarWindowHeightOrInsetsChanged()
|
onTaskbarWindowHeightOrInsetsChanged()
|
||||||
@@ -101,14 +105,11 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
|
|||||||
val tappableHeight = controllers.taskbarStashController.tappableHeightToReportToApps
|
val tappableHeight = controllers.taskbarStashController.tappableHeightToReportToApps
|
||||||
val res = context.resources
|
val res = context.resources
|
||||||
for (provider in windowLayoutParams.providedInsets) {
|
for (provider in windowLayoutParams.providedInsets) {
|
||||||
if (
|
if (provider.type == navigationBars() || provider.type == mandatorySystemGestures()) {
|
||||||
provider.type == ITYPE_EXTRA_NAVIGATION_BAR ||
|
|
||||||
provider.type == ITYPE_BOTTOM_MANDATORY_GESTURES
|
|
||||||
) {
|
|
||||||
provider.insetsSize = getInsetsByNavMode(contentHeight)
|
provider.insetsSize = getInsetsByNavMode(contentHeight)
|
||||||
} else if (provider.type == ITYPE_BOTTOM_TAPPABLE_ELEMENT) {
|
} else if (provider.type == tappableElement()) {
|
||||||
provider.insetsSize = getInsetsByNavMode(tappableHeight)
|
provider.insetsSize = getInsetsByNavMode(tappableHeight)
|
||||||
} else if (provider.type == ITYPE_LEFT_GESTURES) {
|
} else if (provider.type == systemGestures() && provider.index == INDEX_LEFT) {
|
||||||
provider.insetsSize =
|
provider.insetsSize =
|
||||||
Insets.of(
|
Insets.of(
|
||||||
gestureNavSettingsObserver.getLeftSensitivityForCallingUser(res),
|
gestureNavSettingsObserver.getLeftSensitivityForCallingUser(res),
|
||||||
@@ -116,7 +117,7 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
|
|||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
} else if (provider.type == ITYPE_RIGHT_GESTURES) {
|
} else if (provider.type == systemGestures() && provider.index == INDEX_RIGHT) {
|
||||||
provider.insetsSize =
|
provider.insetsSize =
|
||||||
Insets.of(
|
Insets.of(
|
||||||
0,
|
0,
|
||||||
@@ -143,7 +144,7 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
for (provider in windowLayoutParams.providedInsets) {
|
for (provider in windowLayoutParams.providedInsets) {
|
||||||
if (context.isGestureNav && provider.type == ITYPE_BOTTOM_TAPPABLE_ELEMENT) {
|
if (context.isGestureNav && provider.type == tappableElement()) {
|
||||||
provider.insetsSizeOverrides = insetsSizeOverrideForGestureNavTappableElement
|
provider.insetsSizeOverrides = insetsSizeOverrideForGestureNavTappableElement
|
||||||
} else {
|
} else {
|
||||||
provider.insetsSizeOverrides = insetsSizeOverride
|
provider.insetsSizeOverrides = insetsSizeOverride
|
||||||
@@ -170,24 +171,6 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
|
|||||||
return Insets.of(0, 0, bottomInset, 0)
|
return Insets.of(0, 0, bottomInset, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets {@param providesInsetsTypes} as the inset types provided by {@param params}.
|
|
||||||
*
|
|
||||||
* @param params The window layout params.
|
|
||||||
* @param providesInsetsTypes The inset types we would like this layout params to provide.
|
|
||||||
*/
|
|
||||||
fun setProvidesInsetsTypes(
|
|
||||||
params: WindowManager.LayoutParams,
|
|
||||||
providesInsetsTypes: IntArray,
|
|
||||||
providesInsetsSources: IntArray
|
|
||||||
) {
|
|
||||||
params.providedInsets = arrayOfNulls<InsetsFrameProvider>(providesInsetsTypes.size)
|
|
||||||
for (i in providesInsetsTypes.indices) {
|
|
||||||
params.providedInsets[i] =
|
|
||||||
InsetsFrameProvider(providesInsetsTypes[i], providesInsetsSources[i], null, null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called to update the touchable insets.
|
* Called to update the touchable insets.
|
||||||
*
|
*
|
||||||
@@ -248,7 +231,7 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
|
|||||||
for (provider in windowLayoutParams.providedInsets) {
|
for (provider in windowLayoutParams.providedInsets) {
|
||||||
pw.print(
|
pw.print(
|
||||||
"$prefix\tprovidedInsets: (type=" +
|
"$prefix\tprovidedInsets: (type=" +
|
||||||
InsetsState.typeToString(provider.type) +
|
WindowInsets.Type.toString(provider.type) +
|
||||||
" insetsSize=" +
|
" insetsSize=" +
|
||||||
provider.insetsSize
|
provider.insetsSize
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user