Skip to content

Commit

Permalink
Support onKeyLongPress in Bridgeless (#43472)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #43472

Implement `onKeyLongPress` in Bridgeless

Changelog:
[Android][Breaking] Implement onKeyLongPress in Bridgeless

Reviewed By: cortinico

Differential Revision: D54876052

fbshipit-source-id: 88d572eab087d913205bdfa02dba96b169066393
  • Loading branch information
arushikesarwani94 authored and cortinico committed Mar 25, 2024
1 parent 8bf509e commit 4fe26e3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
1 change: 1 addition & 0 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,7 @@ public boolean onKeyUp(int keyCode, KeyEvent event) {
}

public boolean onKeyLongPress(int keyCode, KeyEvent event) {
if (!ReactFeatureFlags.enableBridgelessArchitecture) {
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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,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);
}
Expand Down

0 comments on commit 4fe26e3

Please sign in to comment.