Skip to content

Commit

Permalink
Properly handle RR and CMD+M in Bridgeless Mode (#43460)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #43460

Currently pressing the menu button (or CMD+M) is broken on Bridgeless mode.
Also pressing RR is not reloading the App.
That's because some Bridgeless API haven't been reimplemented correctly on Android. I'm fixing them here.

Fixes #43451

Changelog:
[Android] [Fixed] - Properly handle RR and CMD+M in Bridgeless Mode

Reviewed By: huntie

Differential Revision: D54852959

fbshipit-source-id: 8fbbdab6818da9177e6db40e45d35258c7f5e236
  • Loading branch information
cortinico authored and facebook-github-bot committed Mar 13, 2024
1 parent 98f0893 commit e9f66d9
Showing 1 changed file with 21 additions and 14 deletions.
Expand Up @@ -15,6 +15,7 @@
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.devsupport.DoubleTapReloadRecognizer;
import com.facebook.react.devsupport.interfaces.DevSupportManager;
import com.facebook.react.interfaces.fabric.ReactSurface;
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;

Expand Down Expand Up @@ -218,22 +219,28 @@ protected ReactRootView createRootView() {
* application.
*/
public boolean shouldShowDevMenuOrReload(int keyCode, KeyEvent event) {
if (ReactFeatureFlags.enableBridgelessArchitecture) {
// TODO T156475655: Implement shouldShowDevMenuOrReload for Bridgeless
return false;
DevSupportManager devSupportManager = null;
if (ReactFeatureFlags.enableBridgelessArchitecture
&& mReactHost != null
&& mReactHost.getDevSupportManager() != null) {
devSupportManager = mReactHost.getDevSupportManager();
} else if (getReactNativeHost().hasInstance()
&& getReactNativeHost().getUseDeveloperSupport()) {
if (keyCode == KeyEvent.KEYCODE_MENU) {
getReactNativeHost().getReactInstanceManager().showDevOptionsDialog();
return true;
}
boolean didDoubleTapR =
Assertions.assertNotNull(mDoubleTapReloadRecognizer)
.didDoubleTapR(keyCode, mActivity.getCurrentFocus());
if (didDoubleTapR) {
getReactNativeHost().getReactInstanceManager().getDevSupportManager().handleReloadJS();
return true;
}
devSupportManager = getReactNativeHost().getReactInstanceManager().getDevSupportManager();
} else {
return false;
}

if (keyCode == KeyEvent.KEYCODE_MENU) {
devSupportManager.showDevOptionsDialog();
return true;
}
boolean didDoubleTapR =
Assertions.assertNotNull(mDoubleTapReloadRecognizer)
.didDoubleTapR(keyCode, mActivity.getCurrentFocus());
if (didDoubleTapR) {
devSupportManager.handleReloadJS();
return true;
}
return false;
}
Expand Down

0 comments on commit e9f66d9

Please sign in to comment.