Skip to content

Commit

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

Implement `onKeyDown` in Bridgeless by adding it to ReactHostImpl

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

Reviewed By: cortinico

Differential Revision: D54870966

fbshipit-source-id: 0f8e48b29679f1bca92f6ac7b6ebf1592cdc5dac
  • Loading branch information
arushikesarwani94 authored and facebook-github-bot committed Mar 14, 2024
1 parent 9700540 commit b14f7d5
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 @@ -184,6 +184,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 b14f7d5

Please sign in to comment.