diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index a65138321a8db8..28f012e0b2cacf 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -155,6 +155,7 @@ public class com/facebook/react/ReactDelegate { public fun onHostPause ()V public fun onHostResume ()V public fun onKeyDown (ILandroid/view/KeyEvent;)Z + public fun onKeyLongPress (I)Z public fun onNewIntent (Landroid/content/Intent;)Z public fun onWindowFocusChanged (Z)V public fun shouldShowDevMenuOrReload (ILandroid/view/KeyEvent;)Z diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java index 45d6877405a3e6..54022ed27d5918 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java @@ -155,17 +155,7 @@ public boolean onKeyUp(int keyCode, KeyEvent event) { } public boolean onKeyLongPress(int keyCode, KeyEvent event) { - if (ReactFeatureFlags.enableBridgelessArchitecture) { - // TODO T156475655: support onKeyLongPress - } else { - if (getReactNativeHost().hasInstance() - && getReactNativeHost().getUseDeveloperSupport() - && keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) { - getReactNativeHost().getReactInstanceManager().showDevOptionsDialog(); - return true; - } - } - return false; + return mReactDelegate.onKeyLongPress(keyCode); } public boolean onBackPressed() { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java index 78f34a177cdd60..0e4584f54222b8 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java @@ -197,6 +197,23 @@ && getReactNativeHost().getUseDeveloperSupport()))) { return false; } + public boolean onKeyLongPress(int keyCode) { + if (keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) { + if (ReactFeatureFlags.enableBridgelessArchitecture + && mReactHost != null + && mReactHost.getDevSupportManager() != null) { + mReactHost.getDevSupportManager().showDevOptionsDialog(); + return true; + } else { + if (getReactNativeHost().hasInstance() && getReactNativeHost().getUseDeveloperSupport()) { + getReactNativeHost().getReactInstanceManager().showDevOptionsDialog(); + return true; + } + } + } + return false; + } + public void loadApp() { loadApp(mMainComponentName); }