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 facebook-github-bot committed Mar 14, 2024
1 parent b14f7d5 commit f345fcf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 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 @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit f345fcf

Please sign in to comment.