From 5d4b2270f26952b7b6e241c492d669500ba570f5 Mon Sep 17 00:00:00 2001 From: QichenZhu <57348009+QichenZhu@users.noreply.github.com> Date: Wed, 23 Oct 2024 19:47:56 +1300 Subject: [PATCH 1/2] Fix KeyboardAvoidingView padding on Android --- ...2+018+android-keyboard-avoiding-view.patch | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 patches/react-native+0.75.2+018+android-keyboard-avoiding-view.patch diff --git a/patches/react-native+0.75.2+018+android-keyboard-avoiding-view.patch b/patches/react-native+0.75.2+018+android-keyboard-avoiding-view.patch new file mode 100644 index 000000000000..8da56667d8ed --- /dev/null +++ b/patches/react-native+0.75.2+018+android-keyboard-avoiding-view.patch @@ -0,0 +1,26 @@ +diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +index ed1aba8..0a9284f 100644 +--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java ++++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +@@ -891,7 +891,9 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot { + sendEvent( + "keyboardDidHide", + createKeyboardEventPayload( +- PixelUtil.toDIPFromPixel(mVisibleViewArea.height()), ++ // Use mLastHeight to account for the translucent status bar, and fall back to mVisibleViewArea.height() in case mLastHeight hasn't been measured yet. ++ // Remove this patch once the upstream fix for https://github.com/facebook/react-native/issues/47140 is released. ++ PixelUtil.toDIPFromPixel(mWasMeasured ? mLastHeight : mVisibleViewArea.height()), + 0, + PixelUtil.toDIPFromPixel(mVisibleViewArea.width()), + 0)); +@@ -940,7 +942,9 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot { + sendEvent( + "keyboardDidHide", + createKeyboardEventPayload( +- PixelUtil.toDIPFromPixel(mVisibleViewArea.height()), ++ // Use mLastHeight to account for the translucent status bar, and fall back to mVisibleViewArea.height() in case mLastHeight hasn't been measured yet. ++ // Remove this patch once the upstream fix for https://github.com/facebook/react-native/issues/47140 is released. ++ PixelUtil.toDIPFromPixel(mWasMeasured ? mLastHeight : mVisibleViewArea.height()), + 0, + PixelUtil.toDIPFromPixel(mVisibleViewArea.width()), + 0)); From 65ef887e85018a0043c0aa70c70203b4a28d2919 Mon Sep 17 00:00:00 2001 From: QichenZhu <57348009+QichenZhu@users.noreply.github.com> Date: Wed, 23 Oct 2024 21:24:08 +1300 Subject: [PATCH 2/2] Support Bridgeless mode --- ...native+0.75.2+018+android-keyboard-avoiding-view.patch | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/patches/react-native+0.75.2+018+android-keyboard-avoiding-view.patch b/patches/react-native+0.75.2+018+android-keyboard-avoiding-view.patch index 8da56667d8ed..27fa6074e6ce 100644 --- a/patches/react-native+0.75.2+018+android-keyboard-avoiding-view.patch +++ b/patches/react-native+0.75.2+018+android-keyboard-avoiding-view.patch @@ -7,9 +7,9 @@ index ed1aba8..0a9284f 100644 "keyboardDidHide", createKeyboardEventPayload( - PixelUtil.toDIPFromPixel(mVisibleViewArea.height()), -+ // Use mLastHeight to account for the translucent status bar, and fall back to mVisibleViewArea.height() in case mLastHeight hasn't been measured yet. ++ // Use mLastHeight to account for the translucent status bar, and fall back to getMeasuredHeight() on Bridgeless mode. + // Remove this patch once the upstream fix for https://github.com/facebook/react-native/issues/47140 is released. -+ PixelUtil.toDIPFromPixel(mWasMeasured ? mLastHeight : mVisibleViewArea.height()), ++ PixelUtil.toDIPFromPixel(mWasMeasured ? mLastHeight : getMeasuredHeight()), 0, PixelUtil.toDIPFromPixel(mVisibleViewArea.width()), 0)); @@ -18,9 +18,9 @@ index ed1aba8..0a9284f 100644 "keyboardDidHide", createKeyboardEventPayload( - PixelUtil.toDIPFromPixel(mVisibleViewArea.height()), -+ // Use mLastHeight to account for the translucent status bar, and fall back to mVisibleViewArea.height() in case mLastHeight hasn't been measured yet. ++ // Use mLastHeight to account for the translucent status bar, and fall back to getMeasuredHeight() on Bridgeless mode. + // Remove this patch once the upstream fix for https://github.com/facebook/react-native/issues/47140 is released. -+ PixelUtil.toDIPFromPixel(mWasMeasured ? mLastHeight : mVisibleViewArea.height()), ++ PixelUtil.toDIPFromPixel(mWasMeasured ? mLastHeight : getMeasuredHeight()), 0, PixelUtil.toDIPFromPixel(mVisibleViewArea.width()), 0));