diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index e0c37c31a24e8f..8f4375ad29e1b1 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -923,38 +923,40 @@ public void onGlobalLayout() { private void checkForKeyboardEvents() { getRootView().getWindowVisibleDisplayFrame(mVisibleViewArea); WindowInsets rootInsets = getRootView().getRootWindowInsets(); - WindowInsetsCompat compatRootInsets = WindowInsetsCompat.toWindowInsetsCompat(rootInsets); - - boolean keyboardIsVisible = compatRootInsets.isVisible(WindowInsetsCompat.Type.ime()); - if (keyboardIsVisible != mKeyboardIsVisible) { - mKeyboardIsVisible = keyboardIsVisible; - - if (keyboardIsVisible) { - Insets imeInsets = compatRootInsets.getInsets(WindowInsetsCompat.Type.ime()); - Insets barInsets = compatRootInsets.getInsets(WindowInsetsCompat.Type.systemBars()); - int height = imeInsets.bottom - barInsets.bottom; - - int softInputMode = ((Activity) getContext()).getWindow().getAttributes().softInputMode; - int screenY = - softInputMode == WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING - ? mVisibleViewArea.bottom - height - : mVisibleViewArea.bottom; - - sendEvent( - "keyboardDidShow", - createKeyboardEventPayload( - PixelUtil.toDIPFromPixel(screenY), - PixelUtil.toDIPFromPixel(mVisibleViewArea.left), - PixelUtil.toDIPFromPixel(mVisibleViewArea.width()), - PixelUtil.toDIPFromPixel(height))); - } else { - sendEvent( - "keyboardDidHide", - createKeyboardEventPayload( - PixelUtil.toDIPFromPixel(mLastHeight), - 0, - PixelUtil.toDIPFromPixel(mVisibleViewArea.width()), - 0)); + if (rootInsets != null) { + WindowInsetsCompat compatRootInsets = WindowInsetsCompat.toWindowInsetsCompat(rootInsets); + + boolean keyboardIsVisible = compatRootInsets.isVisible(WindowInsetsCompat.Type.ime()); + if (keyboardIsVisible != mKeyboardIsVisible) { + mKeyboardIsVisible = keyboardIsVisible; + + if (keyboardIsVisible) { + Insets imeInsets = compatRootInsets.getInsets(WindowInsetsCompat.Type.ime()); + Insets barInsets = compatRootInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + int height = imeInsets.bottom - barInsets.bottom; + + int softInputMode = ((Activity) getContext()).getWindow().getAttributes().softInputMode; + int screenY = + softInputMode == WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING + ? mVisibleViewArea.bottom - height + : mVisibleViewArea.bottom; + + sendEvent( + "keyboardDidShow", + createKeyboardEventPayload( + PixelUtil.toDIPFromPixel(screenY), + PixelUtil.toDIPFromPixel(mVisibleViewArea.left), + PixelUtil.toDIPFromPixel(mVisibleViewArea.width()), + PixelUtil.toDIPFromPixel(height))); + } else { + sendEvent( + "keyboardDidHide", + createKeyboardEventPayload( + PixelUtil.toDIPFromPixel(mLastHeight), + 0, + PixelUtil.toDIPFromPixel(mVisibleViewArea.width()), + 0)); + } } } } diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt index 94ccb2bc14bf63..30bad252fd823b 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt @@ -22,14 +22,16 @@ internal fun Project.configureReactTasks(variant: Variant, config: ReactExtensio val targetName = variant.name.replaceFirstChar { it.uppercase() } val targetPath = variant.name - // React js bundle directories + // Resources: generated/assets/react//index.android.bundle val resourcesDir = File(buildDir, "generated/res/react/$targetPath") - // Bundle: generated/assets/react/path/index.android.bundle + // Bundle: generated/assets/react//index.android.bundle val jsBundleDir = File(buildDir, "generated/assets/react/$targetPath") - // Sourcemap: generated/sourcemaps/react/path/index.android.bundle.map + // Sourcemap: generated/sourcemaps/react//index.android.bundle.map val jsSourceMapsDir = File(buildDir, "generated/sourcemaps/react/$targetPath") - // Intermediate packager: intermediates/sourcemaps/react/path/index.android.bundle.packager.map - // Intermediate compiler: intermediates/sourcemaps/react/path/index.android.bundle.compiler.map + // Intermediate packager: + // intermediates/sourcemaps/react//index.android.bundle.packager.map + // Intermediate compiler: + // intermediates/sourcemaps/react//index.android.bundle.compiler.map val jsIntermediateSourceMapsDir = File(buildDir, "intermediates/sourcemaps/react/$targetPath") // The location of the cli.js file for React Native