Skip to content

Commit

Permalink
Support onKeyDown in Bridgeless (facebook#43466)
Browse files Browse the repository at this point in the history
Summary:

Implement `onKeyDown` in Bridgeless by adding it to ReactHostImpl

Changelog:
[Android][Breaking] Implement `onKeyDown` in Bridgeless

Differential Revision: D54870966
  • Loading branch information
arushikesarwani94 authored and facebook-github-bot committed Mar 14, 2024
1 parent b976be7 commit f06dbd4
Show file tree
Hide file tree
Showing 3 changed files with 15 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 @@ -154,6 +154,7 @@ public class com/facebook/react/ReactDelegate {
public fun onHostDestroy ()V
public fun onHostPause ()V
public fun onHostResume ()V
public fun onKeyDown (ILandroid/view/KeyEvent;)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 @@ -147,17 +147,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
}

public boolean onKeyDown(int keyCode, KeyEvent event) {
if (ReactFeatureFlags.enableBridgelessArchitecture) {
// TODO T156475655: support onKeyDown
} else {
if (getReactNativeHost().hasInstance()
&& getReactNativeHost().getUseDeveloperSupport()
&& keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) {
event.startTracking();
return true;
}
}
return false;
return mReactDelegate.onKeyDown(keyCode, event);
}

public boolean onKeyUp(int keyCode, KeyEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,19 @@ public void onConfigurationChanged(Configuration newConfig) {
}
}

public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD
&& ((ReactFeatureFlags.enableBridgelessArchitecture
&& mReactHost != null
&& mReactHost.getDevSupportManager() != null)
|| (getReactNativeHost().hasInstance()
&& getReactNativeHost().getUseDeveloperSupport()))) {
event.startTracking();
return true;
}
return false;
}

public void loadApp() {
loadApp(mMainComponentName);
}
Expand Down

0 comments on commit f06dbd4

Please sign in to comment.