Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support onKeyDown in Bridgeless #43466

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -138,7 +138,7 @@ public boolean onBackPressed() {
}

public boolean onNewIntent(Intent intent) {
if (ReactFeatureFlags.enableBridgelessArchitecture) {
if (ReactFeatureFlags.enableBridgelessArchitecture && mReactHost != null) {
mReactHost.onNewIntent(intent);
return true;
} else {
Expand All @@ -152,7 +152,7 @@ public boolean onNewIntent(Intent intent) {

public void onActivityResult(
int requestCode, int resultCode, Intent data, boolean shouldForwardToReactInstance) {
if (ReactFeatureFlags.enableBridgelessArchitecture) {
if (ReactFeatureFlags.enableBridgelessArchitecture && mReactHost != null) {
mReactHost.onActivityResult(mActivity, requestCode, resultCode, data);
} else {
if (getReactNativeHost().hasInstance() && shouldForwardToReactInstance) {
Expand All @@ -164,7 +164,7 @@ public void onActivityResult(
}

public void onWindowFocusChanged(boolean hasFocus) {
if (ReactFeatureFlags.enableBridgelessArchitecture) {
if (ReactFeatureFlags.enableBridgelessArchitecture && mReactHost != null) {
mReactHost.onWindowFocusChange(hasFocus);
} else {
if (getReactNativeHost().hasInstance()) {
Expand All @@ -174,7 +174,7 @@ public void onWindowFocusChanged(boolean hasFocus) {
}

public void onConfigurationChanged(Configuration newConfig) {
if (ReactFeatureFlags.enableBridgelessArchitecture) {
if (ReactFeatureFlags.enableBridgelessArchitecture && mReactHost != null) {
mReactHost.onConfigurationChanged(Assertions.assertNotNull(mActivity));
} else {
if (getReactNativeHost().hasInstance()) {
Expand All @@ -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
Loading