From 5f2fae0c2d96d5ed56b7f77338e67d3a8b76cf8d Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Tue, 15 Jun 2021 12:14:23 -0700 Subject: [PATCH] Move Chrome debugging menu item to BridgeDevSupportManager Summary: Google Chrome debugging is only supported by the bridge. So, it makes sense to move it to BridgeDevSupportManager. Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D29031514 fbshipit-source-id: 4d6b6bb3bc298be5fe4d9f96c0d019676fe256db --- .../devsupport/BridgeDevSupportManager.java | 16 ++++++++++++++++ .../react/devsupport/DevSupportManagerBase.java | 17 +++-------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/BridgeDevSupportManager.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/BridgeDevSupportManager.java index b5a326c6d64..e9994ef138b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/BridgeDevSupportManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/BridgeDevSupportManager.java @@ -107,6 +107,22 @@ public final class BridgeDevSupportManager extends DevSupportManagerBase { toggleJSSamplingProfiler(); } }); + + if (!getDevSettings().isDeviceDebugEnabled()) { + // For remote debugging, we open up Chrome running the app in a web worker. + // Note that this requires async communication, which will not work for Turbo Modules. + addCustomDevOption( + getDevSettings().isRemoteJSDebugEnabled() + ? applicationContext.getString(com.facebook.react.R.string.catalyst_debug_stop) + : applicationContext.getString(com.facebook.react.R.string.catalyst_debug), + new DevOptionHandler() { + @Override + public void onOptionSelected() { + getDevSettings().setRemoteJSDebugEnabled(!getDevSettings().isRemoteJSDebugEnabled()); + handleReloadJS(); + } + }); + } } @Override diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java index fc7f45e4855..120a181a463 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java @@ -396,6 +396,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager { handleReloadJS(); } }); + if (mDevSettings.isDeviceDebugEnabled()) { // For on-device debugging we link out to Flipper. // Since we're assuming Flipper is available, also include the DevTools. @@ -428,21 +429,8 @@ public abstract class DevSupportManagerBase implements DevSupportManager { mApplicationContext.getString(R.string.catalyst_open_flipper_error)); } }); - } else { - // For remote debugging, we open up Chrome running the app in a web worker. - // Note that this requires async communication, which will not work for Turbo Modules. - options.put( - mDevSettings.isRemoteJSDebugEnabled() - ? mApplicationContext.getString(R.string.catalyst_debug_stop) - : mApplicationContext.getString(R.string.catalyst_debug), - new DevOptionHandler() { - @Override - public void onOptionSelected() { - mDevSettings.setRemoteJSDebugEnabled(!mDevSettings.isRemoteJSDebugEnabled()); - handleReloadJS(); - } - }); } + options.put( mApplicationContext.getString(R.string.catalyst_change_bundle_location), new DevOptionHandler() { @@ -478,6 +466,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager { bundleLocationDialog.show(); } }); + options.put( // NOTE: `isElementInspectorEnabled` is not guaranteed to be accurate. mApplicationContext.getString(R.string.catalyst_inspector),