@@ -2357,7 +2357,7 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection,
23572357 dispatchInkMotionEvent(
23582358 event = event,
23592359 sourceRoot = mainView.root,
2360- targetContainer = mainView.keyboardBackgroundContainer ,
2360+ targetContainer = mainView.keyboardTouchEffectContainer ,
23612361 inkView = mainView.suminagashiInkView
23622362 )
23632363 }
@@ -2368,7 +2368,7 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection,
23682368 dispatchLiquidRippleMotionEvent(
23692369 event = event,
23702370 sourceRoot = mainView.root,
2371- targetContainer = mainView.keyboardBackgroundContainer ,
2371+ targetContainer = mainView.keyboardTouchEffectContainer ,
23722372 rippleView = mainView.liquidRippleEffectView
23732373 )
23742374 }
@@ -2379,7 +2379,7 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection,
23792379 dispatchSprayPaintMotionEvent(
23802380 event = event,
23812381 sourceRoot = mainView.root,
2382- targetContainer = mainView.keyboardBackgroundContainer ,
2382+ targetContainer = mainView.keyboardTouchEffectContainer ,
23832383 sprayView = mainView.sprayPaintEffectView
23842384 )
23852385 }
@@ -2455,7 +2455,7 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection,
24552455 dispatchInkMotionEvent(
24562456 event = event,
24572457 sourceRoot = floatingView.root,
2458- targetContainer = floatingView.floatingKeyboardBackgroundContainer ,
2458+ targetContainer = floatingView.floatingKeyboardTouchEffectContainer ,
24592459 inkView = floatingView.floatingSuminagashiInkView
24602460 )
24612461 }
@@ -2466,7 +2466,7 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection,
24662466 dispatchLiquidRippleMotionEvent(
24672467 event = event,
24682468 sourceRoot = floatingView.root,
2469- targetContainer = floatingView.floatingKeyboardBackgroundContainer ,
2469+ targetContainer = floatingView.floatingKeyboardTouchEffectContainer ,
24702470 rippleView = floatingView.floatingLiquidRippleEffectView
24712471 )
24722472 }
@@ -2477,7 +2477,7 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection,
24772477 dispatchSprayPaintMotionEvent(
24782478 event = event,
24792479 sourceRoot = floatingView.root,
2480- targetContainer = floatingView.floatingKeyboardBackgroundContainer ,
2480+ targetContainer = floatingView.floatingKeyboardTouchEffectContainer ,
24812481 sprayView = floatingView.floatingSprayPaintEffectView
24822482 )
24832483 }
@@ -2772,8 +2772,10 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection,
27722772 )
27732773 applyHeight(floatingView.floatingKeyboardContent.height.takeIf { it > 0 } ?: fallbackHeight
27742774 ?: 0)
2775+ updateFloatingKeyboardTouchEffectBounds(floatingView)
27752776 floatingView.root.post {
27762777 applyHeight(floatingView.floatingKeyboardContent.height)
2778+ updateFloatingKeyboardTouchEffectBounds(floatingView)
27772779 updateLuminousBlobEffectBounds(
27782780 blobView = floatingView.floatingLuminousBlobEffectView,
27792781 heightPx = resolveFloatingLuminousBlobKeyboardAreaHeight(
@@ -2784,6 +2786,62 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection,
27842786 }
27852787 }
27862788
2789+ private fun updateFloatingKeyboardTouchEffectBounds(
2790+ floatingView: FloatingKeyboardLayoutBinding
2791+ ) {
2792+ val target = when {
2793+ floatingView.floatingSymbolKeyboard.isVisible -> floatingView.floatingSymbolKeyboard
2794+ floatingView.candidatesRowView.isVisible -> floatingView.candidatesRowView
2795+ else -> floatingView.floatingKeyboardContainer
2796+ }
2797+
2798+ fun applyBounds() {
2799+ if (target.width <= 0 || target.height <= 0) return
2800+
2801+ val rootLocation = IntArray(2)
2802+ val targetLocation = IntArray(2)
2803+ floatingView.root.getLocationInWindow(rootLocation)
2804+ target.getLocationInWindow(targetLocation)
2805+
2806+ val params =
2807+ floatingView.floatingKeyboardTouchEffectContainer.layoutParams as? FrameLayout.LayoutParams
2808+ ?: return
2809+ var changed = false
2810+ val left = targetLocation[0] - rootLocation[0]
2811+ val top = targetLocation[1] - rootLocation[1]
2812+
2813+ if (params.width != target.width) {
2814+ params.width = target.width
2815+ changed = true
2816+ }
2817+ if (params.height != target.height) {
2818+ params.height = target.height
2819+ changed = true
2820+ }
2821+ if (params.leftMargin != left) {
2822+ params.leftMargin = left
2823+ changed = true
2824+ }
2825+ if (params.topMargin != top) {
2826+ params.topMargin = top
2827+ changed = true
2828+ }
2829+
2830+ val expectedGravity = Gravity.TOP or Gravity.START
2831+ if (params.gravity != expectedGravity) {
2832+ params.gravity = expectedGravity
2833+ changed = true
2834+ }
2835+
2836+ if (changed) {
2837+ floatingView.floatingKeyboardTouchEffectContainer.layoutParams = params
2838+ }
2839+ }
2840+
2841+ applyBounds()
2842+ floatingView.root.post { applyBounds() }
2843+ }
2844+
27872845 private fun updateLuminousBlobEffectBounds(
27882846 blobView: LuminousBlobEffectView,
27892847 heightPx: Int
@@ -4275,6 +4333,7 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection,
42754333 }
42764334 updateFloatingKeyboardBackgroundBounds(floatingKeyboardLayoutBinding, heightPx)
42774335 updateFloatingFullCandidatesHeight(floatingKeyboardLayoutBinding, heightPx)
4336+ updateFloatingKeyboardTouchEffectBounds(floatingKeyboardLayoutBinding)
42784337 }
42794338
42804339 keyboardContainer?.let { container ->
@@ -13282,6 +13341,7 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection,
1328213341 floatingKeyboardLayoutBinding.floatingSymbolKeyboard.isVisible = false
1328313342 renderCurrentKeyboardStateOnActiveSurface()
1328413343 }
13344+ updateFloatingKeyboardTouchEffectBounds(floatingKeyboardLayoutBinding)
1328513345 }
1328613346 } else {
1328713347 setKeyboardSizeForHeightSymbol(mainView, isSymbolKeyboardShow.isShown)
@@ -14410,6 +14470,31 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection,
1441014470 }
1441114471 }
1441214472
14473+ private fun updateNormalKeyboardTouchEffectBounds(
14474+ mainView: MainLayoutBinding,
14475+ keyboardBodyHeightPx: Int
14476+ ) {
14477+ if (keyboardBodyHeightPx <= 0) return
14478+
14479+ val container = mainView.keyboardTouchEffectContainer
14480+ val params = container.layoutParams as? FrameLayout.LayoutParams ?: return
14481+ var changed = false
14482+
14483+ if (params.height != keyboardBodyHeightPx) {
14484+ params.height = keyboardBodyHeightPx
14485+ changed = true
14486+ }
14487+
14488+ if (params.gravity != Gravity.BOTTOM) {
14489+ params.gravity = Gravity.BOTTOM
14490+ changed = true
14491+ }
14492+
14493+ if (changed) {
14494+ container.layoutParams = params
14495+ }
14496+ }
14497+
1441314498 private fun applyKeyboardLayoutParameters(
1441414499 mainView: MainLayoutBinding,
1441514500 heightPx: Int,
@@ -14460,6 +14545,10 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection,
1446014545 mainView = mainView,
1446114546 heightPx = backgroundSurfaceHeight
1446214547 )
14548+ updateNormalKeyboardTouchEffectBounds(
14549+ mainView = mainView,
14550+ keyboardBodyHeightPx = heightPx
14551+ )
1446314552 updateLuminousBlobEffectBounds(
1446414553 blobView = mainView.luminousBlobEffectView,
1446514554 heightPx = heightPx
@@ -14633,6 +14722,10 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection,
1463314722 mainView = mainView,
1463414723 heightPx = backgroundSurfaceHeight
1463514724 )
14725+ updateNormalKeyboardTouchEffectBounds(
14726+ mainView = mainView,
14727+ keyboardBodyHeightPx = heightPx
14728+ )
1463614729 updateLuminousBlobEffectBounds(
1463714730 blobView = mainView.luminousBlobEffectView,
1463814731 heightPx = heightPx
@@ -14711,6 +14804,11 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection,
1471114804 floatingKeyboardLayoutBinding.suggestionVisibility.apply {
1471214805 this.setImageDrawable(if (isVisible) cachedArrowDropDownDrawable else cachedArrowDropUpDrawable)
1471314806 }
14807+ updateFloatingKeyboardTouchEffectBounds(floatingKeyboardLayoutBinding)
14808+ floatingKeyboardLayoutBinding.root.postDelayed(
14809+ { updateFloatingKeyboardTouchEffectBounds(floatingKeyboardLayoutBinding) },
14810+ 240L
14811+ )
1471414812 }
1471514813 }
1471614814 animateViewVisibility(mainView.candidatesRowView, !isVisible)
@@ -16917,7 +17015,10 @@ class IMEService : InputMethodService(), LifecycleOwner, InputConnection,
1691717015 if (keyboardSymbolViewState.value.isShown) {
1691817016 _keyboardSymbolViewState.value = SymbolKeyboardState()
1691917017 }
16920- floatingKeyboardBinding?.floatingSymbolKeyboard?.isVisible = false
17018+ floatingKeyboardBinding?.let { floatingView ->
17019+ floatingView.floatingSymbolKeyboard.isVisible = false
17020+ updateFloatingKeyboardTouchEffectBounds(floatingView)
17021+ }
1692117022 }
1692217023
1692317024 private fun currentKeyboardLayoutEditOrientation(): KeyboardLayoutEditOrientation {
0 commit comments