diff --git a/android/src/main/java/com/reactnativekeyboardcontroller/extensions/WindowInsetsAnimationCompat.kt b/android/src/main/java/com/reactnativekeyboardcontroller/extensions/WindowInsetsAnimationCompat.kt new file mode 100644 index 000000000..9be782732 --- /dev/null +++ b/android/src/main/java/com/reactnativekeyboardcontroller/extensions/WindowInsetsAnimationCompat.kt @@ -0,0 +1,7 @@ +package com.reactnativekeyboardcontroller.extensions + +import androidx.core.view.WindowInsetsAnimationCompat +import androidx.core.view.WindowInsetsCompat + +val WindowInsetsAnimationCompat.isKeyboardAnimation: Boolean + get() = typeMask and WindowInsetsCompat.Type.ime() != 0 diff --git a/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt b/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt index 1bb4f0101..7451cb5e5 100644 --- a/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +++ b/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt @@ -22,6 +22,7 @@ import com.reactnativekeyboardcontroller.InteractiveKeyboardProvider import com.reactnativekeyboardcontroller.events.KeyboardTransitionEvent import com.reactnativekeyboardcontroller.extensions.dispatchEvent import com.reactnativekeyboardcontroller.extensions.dp +import com.reactnativekeyboardcontroller.extensions.isKeyboardAnimation import kotlin.math.abs private val TAG = KeyboardAnimationCallback::class.qualifiedName @@ -142,6 +143,10 @@ class KeyboardAnimationCallback( animation: WindowInsetsAnimationCompat, bounds: WindowInsetsAnimationCompat.BoundsCompat, ): WindowInsetsAnimationCompat.BoundsCompat { + if (!animation.isKeyboardAnimation) { + return bounds + } + isTransitioning = true isKeyboardVisible = isKeyboardVisible() duration = animation.durationMillis.toInt() @@ -181,6 +186,9 @@ class KeyboardAnimationCallback( ): WindowInsetsCompat { // onProgress() is called when any of the running animations progress... + // ignore non-keyboard animation + runningAnimations.find { it.isKeyboardAnimation } ?: return insets + // First we get the insets which are potentially deferred val typesInset = insets.getInsets(deferredInsetTypes) // Then we get the persistent inset types which are applied as padding during layout @@ -226,6 +234,10 @@ class KeyboardAnimationCallback( override fun onEnd(animation: WindowInsetsAnimationCompat) { super.onEnd(animation) + if (!animation.isKeyboardAnimation) { + return + } + isTransitioning = false duration = animation.durationMillis.toInt()