mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
RN: Debug Menu Cleanup (Android)
Summary: Addresses a number of pieces of feedback regarding the debug menu. - Simplify labels for the debugger actions (e.g. no "remote", no emoji). - Reorder actions so that modal items are generally lower. - Renamed "Live Reloading" to "Reload-on-Save". - Renamed "Dev Settings" to "Settings". Changelog: [Android] [Changed] - Cleaned up debug menu. Reviewed By: cpojer Differential Revision: D15553883 fbshipit-source-id: d30e8cd0804e010985c0cf40d443defc7c0710ac
This commit is contained in:
committed by
Facebook Github Bot
parent
796e9b0e37
commit
dac037d371
+1
-1
@@ -81,7 +81,7 @@ public class DevLoadingViewController {
|
||||
return;
|
||||
}
|
||||
|
||||
showMessage(context.getString(R.string.catalyst_remotedbg_message));
|
||||
showMessage(context.getString(R.string.catalyst_debug_connecting));
|
||||
}
|
||||
|
||||
public void updateProgress(final @Nullable String status, final @Nullable Integer done, final @Nullable Integer total) {
|
||||
|
||||
@@ -275,7 +275,7 @@ public class DevServerHelper {
|
||||
@Override
|
||||
protected void onPostExecute(Boolean result) {
|
||||
if (!result) {
|
||||
String message = context.getString(R.string.catalyst_debugjs_nuclide_failure);
|
||||
String message = context.getString(R.string.catalyst_debug_nuclide_error);
|
||||
Toast.makeText(context, message, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
+67
-60
@@ -422,69 +422,48 @@ public class DevSupportManagerImpl implements
|
||||
LinkedHashMap<String, DevOptionHandler> options = new LinkedHashMap<>();
|
||||
/* register standard options */
|
||||
options.put(
|
||||
mApplicationContext.getString(R.string.catalyst_reloadjs),
|
||||
new DevOptionHandler() {
|
||||
@Override
|
||||
public void onOptionSelected() {
|
||||
if (!mDevSettings.isJSDevModeEnabled() && mDevSettings.isHotModuleReplacementEnabled()) {
|
||||
Toast.makeText(mApplicationContext, "HMR cannot be enabled when Dev mode is off. Disabling HMR...", Toast.LENGTH_LONG).show();
|
||||
mDevSettings.setHotModuleReplacementEnabled(false);
|
||||
}
|
||||
handleReloadJS();
|
||||
}
|
||||
});
|
||||
if (mDevSettings.isNuclideJSDebugEnabled()) {
|
||||
String nuclideJsDebugMenuItemTitle =
|
||||
mApplicationContext.getString(R.string.catalyst_debugjs_nuclide);
|
||||
options.put(
|
||||
nuclideJsDebugMenuItemTitle,
|
||||
new DevOptionHandler() {
|
||||
@Override
|
||||
public void onOptionSelected() {
|
||||
mDevServerHelper.attachDebugger(mApplicationContext, "ReactNative");
|
||||
}
|
||||
});
|
||||
}
|
||||
String remoteJsDebugMenuItemTitle =
|
||||
mDevSettings.isRemoteJSDebugEnabled()
|
||||
? mApplicationContext.getString(R.string.catalyst_debugjs_off)
|
||||
: mApplicationContext.getString(R.string.catalyst_debugjs);
|
||||
options.put(
|
||||
remoteJsDebugMenuItemTitle,
|
||||
new DevOptionHandler() {
|
||||
@Override
|
||||
public void onOptionSelected() {
|
||||
mDevSettings.setRemoteJSDebugEnabled(!mDevSettings.isRemoteJSDebugEnabled());
|
||||
handleReloadJS();
|
||||
}
|
||||
});
|
||||
options.put(
|
||||
mDevSettings.isReloadOnJSChangeEnabled()
|
||||
? mApplicationContext.getString(R.string.catalyst_live_reload_off)
|
||||
: mApplicationContext.getString(R.string.catalyst_live_reload),
|
||||
mApplicationContext.getString(R.string.catalyst_reload),
|
||||
new DevOptionHandler() {
|
||||
@Override
|
||||
public void onOptionSelected() {
|
||||
mDevSettings.setReloadOnJSChangeEnabled(!mDevSettings.isReloadOnJSChangeEnabled());
|
||||
if (!mDevSettings.isJSDevModeEnabled() && mDevSettings.isHotModuleReplacementEnabled()) {
|
||||
Toast.makeText(
|
||||
mApplicationContext,
|
||||
mApplicationContext.getString(R.string.catalyst_hot_reloading_auto_disable),
|
||||
Toast.LENGTH_LONG).show();
|
||||
mDevSettings.setHotModuleReplacementEnabled(false);
|
||||
}
|
||||
handleReloadJS();
|
||||
}
|
||||
});
|
||||
options.put(
|
||||
mDevSettings.isHotModuleReplacementEnabled()
|
||||
? mApplicationContext.getString(R.string.catalyst_hot_module_replacement_off)
|
||||
: mApplicationContext.getString(R.string.catalyst_hot_module_replacement),
|
||||
new DevOptionHandler() {
|
||||
@Override
|
||||
public void onOptionSelected() {
|
||||
if (!mDevSettings.isHotModuleReplacementEnabled() && !mDevSettings.isJSDevModeEnabled()) {
|
||||
Toast.makeText(mApplicationContext, "You're trying to enable HMR while Dev mode is off. Turning both HMR and the Dev mode on...", Toast.LENGTH_LONG).show();
|
||||
mDevSettings.setJSDevModeEnabled(true);
|
||||
}
|
||||
mDevSettings.setHotModuleReplacementEnabled(!mDevSettings.isHotModuleReplacementEnabled());
|
||||
handleReloadJS();
|
||||
}
|
||||
});
|
||||
mDevSettings.isNuclideJSDebugEnabled()
|
||||
? mDevSettings.isRemoteJSDebugEnabled()
|
||||
? mApplicationContext.getString(R.string.catalyst_debug_chrome_stop)
|
||||
: mApplicationContext.getString(R.string.catalyst_debug_chrome)
|
||||
: 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();
|
||||
}
|
||||
});
|
||||
if (mDevSettings.isNuclideJSDebugEnabled()) {
|
||||
options.put(
|
||||
mApplicationContext.getString(R.string.catalyst_debug_nuclide),
|
||||
new DevOptionHandler() {
|
||||
@Override
|
||||
public void onOptionSelected() {
|
||||
mDevServerHelper.attachDebugger(mApplicationContext, "ReactNative");
|
||||
}
|
||||
});
|
||||
}
|
||||
options.put(
|
||||
mApplicationContext.getString(R.string.catalyst_element_inspector),
|
||||
// NOTE: `isElementInspectorEnabled` is not guaranteed to be accurate.
|
||||
mApplicationContext.getString(R.string.catalyst_inspector),
|
||||
new DevOptionHandler() {
|
||||
@Override
|
||||
public void onOptionSelected() {
|
||||
@@ -492,9 +471,37 @@ public class DevSupportManagerImpl implements
|
||||
mReactInstanceManagerHelper.toggleElementInspector();
|
||||
}
|
||||
});
|
||||
options.put(
|
||||
mDevSettings.isReloadOnJSChangeEnabled()
|
||||
? mApplicationContext.getString(R.string.catalyst_reload_on_save_stop)
|
||||
: mApplicationContext.getString(R.string.catalyst_reload_on_save),
|
||||
new DevOptionHandler() {
|
||||
@Override
|
||||
public void onOptionSelected() {
|
||||
mDevSettings.setReloadOnJSChangeEnabled(!mDevSettings.isReloadOnJSChangeEnabled());
|
||||
}
|
||||
});
|
||||
options.put(
|
||||
mDevSettings.isHotModuleReplacementEnabled()
|
||||
? mApplicationContext.getString(R.string.catalyst_hot_reloading_stop)
|
||||
: mApplicationContext.getString(R.string.catalyst_hot_reloading),
|
||||
new DevOptionHandler() {
|
||||
@Override
|
||||
public void onOptionSelected() {
|
||||
if (!mDevSettings.isHotModuleReplacementEnabled() && !mDevSettings.isJSDevModeEnabled()) {
|
||||
Toast.makeText(
|
||||
mApplicationContext,
|
||||
mApplicationContext.getString(R.string.catalyst_hot_reloading_auto_enable),
|
||||
Toast.LENGTH_LONG).show();
|
||||
mDevSettings.setJSDevModeEnabled(true);
|
||||
}
|
||||
mDevSettings.setHotModuleReplacementEnabled(!mDevSettings.isHotModuleReplacementEnabled());
|
||||
handleReloadJS();
|
||||
}
|
||||
});
|
||||
options.put(
|
||||
mDevSettings.isFpsDebugEnabled()
|
||||
? mApplicationContext.getString(R.string.catalyst_perf_monitor_off)
|
||||
? mApplicationContext.getString(R.string.catalyst_perf_monitor_stop)
|
||||
: mApplicationContext.getString(R.string.catalyst_perf_monitor),
|
||||
new DevOptionHandler() {
|
||||
@Override
|
||||
@@ -884,10 +891,10 @@ public class DevSupportManagerImpl implements
|
||||
public void onFailure(final Throwable cause) {
|
||||
mDevLoadingViewController.hide();
|
||||
mDevLoadingViewVisible = false;
|
||||
FLog.e(ReactConstants.TAG, "Unable to connect to remote debugger", cause);
|
||||
FLog.e(ReactConstants.TAG, "Failed to connect to debugger!", cause);
|
||||
future.setException(
|
||||
new IOException(
|
||||
mApplicationContext.getString(R.string.catalyst_remotedbg_error), cause));
|
||||
mApplicationContext.getString(R.string.catalyst_debug_error), cause));
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -951,7 +958,7 @@ public class DevSupportManagerImpl implements
|
||||
showNewJavaError(debugServerException.getMessage(), cause);
|
||||
} else {
|
||||
showNewJavaError(
|
||||
mApplicationContext.getString(R.string.catalyst_jsload_error),
|
||||
mApplicationContext.getString(R.string.catalyst_reload_error),
|
||||
cause);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="catalyst_reloadjs" project="catalyst" translatable="false">Reload</string>
|
||||
<string name="catalyst_debugjs_nuclide" project="catalyst" translatable="false">Debug JS in Nuclide</string>
|
||||
<string name="catalyst_debugjs_nuclide_failure" project="catalyst" translatable="false">The request to attach Nuclide could not reach Metro Bundler!</string>
|
||||
<string name="catalyst_debugjs" project="catalyst" translatable="false">Debug JS Remotely</string>
|
||||
<string name="catalyst_debugjs_off" project="catalyst" translatable="false">Stop Remote JS Debugging</string>
|
||||
<string name="catalyst_hot_module_replacement" project="catalyst" translatable="false">Enable Hot Reloading</string>
|
||||
<string name="catalyst_hot_module_replacement_off" project="catalyst" translatable="false">Disable Hot Reloading</string>
|
||||
<string name="catalyst_live_reload" project="catalyst" translatable="false">Enable Live Reload</string>
|
||||
<string name="catalyst_live_reload_off" project="catalyst" translatable="false">Disable Live Reload</string>
|
||||
<string name="catalyst_reload" project="catalyst" translatable="false">Reload</string>
|
||||
<string name="catalyst_reload_error" project="catalyst" translatable="false">Failed to load bundle. Try restarting the bundler or reconnecting your device.</string>
|
||||
<string name="catalyst_debug" project="catalyst" translatable="false">Debug</string>
|
||||
<string name="catalyst_debug_stop" project="catalyst" translatable="false">Stop Debugging</string>
|
||||
<string name="catalyst_debug_connecting" project="catalyst" translatable="false">Connecting to debugger...</string>
|
||||
<string name="catalyst_debug_error" project="catalyst" translatable="false">Failed to connect to debugger!</string>
|
||||
<string name="catalyst_debug_chrome" project="catalyst" translatable="false">Debug with Chrome</string>
|
||||
<string name="catalyst_debug_chrome_stop" project="catalyst" translatable="false">Stop Chrome Debugging</string>
|
||||
<string name="catalyst_debug_nuclide" project="catalyst" translatable="false">Debug with Nuclide</string>
|
||||
<string name="catalyst_debug_nuclide_error" project="catalyst" translatable="false">Failed to communicate with the bundler to enabling debugging with Nuclide.</string>
|
||||
<string name="catalyst_reload_on_save" project="catalyst" translatable="false">Enable Reload-on-Save</string>
|
||||
<string name="catalyst_reload_on_save_stop" project="catalyst" translatable="false">Disable Reload-on-Save</string>
|
||||
<string name="catalyst_hot_reloading" project="catalyst" translatable="false">Enable Hot Reloading</string>
|
||||
<string name="catalyst_hot_reloading_stop" project="catalyst" translatable="false">Disable Hot Reloading</string>
|
||||
<string name="catalyst_hot_reloading_auto_disable" project="catalyst" translatable="false">Disabling hot reloading because it requires a development bundle.</string>
|
||||
<string name="catalyst_hot_reloading_auto_enable" project="catalyst" translatable="false">Switching to development bundle in order to enable hot reloading.</string>
|
||||
<string name="catalyst_inspector" project="catalyst" translatable="false">Toggle Inspector</string>
|
||||
<string name="catalyst_perf_monitor" project="catalyst" translatable="false">Show Perf Monitor</string>
|
||||
<string name="catalyst_perf_monitor_off" project="catalyst" translatable="false">Hide Perf Monitor</string>
|
||||
<string name="catalyst_settings" project="catalyst" translatable="false">Dev Settings</string>
|
||||
<string name="catalyst_settings_title" project="catalyst" translatable="false">Catalyst Dev Settings</string>
|
||||
<string name="catalyst_jsload_error" project="catalyst" translatable="false">Unable to download JS bundle. Did you forget to start the development server or connect your device?</string>
|
||||
<string name="catalyst_remotedbg_message" project="catalyst" translatable="false">Connecting to remote debugger</string>
|
||||
<string name="catalyst_remotedbg_error" project="catalyst" translatable="false">Unable to connect with remote debugger</string>
|
||||
<string name="catalyst_element_inspector" project="catalyst" translatable="false">Toggle Inspector</string>
|
||||
<string name="catalyst_perf_monitor_stop" project="catalyst" translatable="false">Hide Perf Monitor</string>
|
||||
<string name="catalyst_settings" project="catalyst" translatable="false">Settings</string>
|
||||
<string name="catalyst_settings_title" project="catalyst" translatable="false">Debug Settings</string>
|
||||
<string name="catalyst_heap_capture" project="catalyst" translatable="false">Capture Heap</string>
|
||||
<string name="catalyst_dismiss_button" project="catalyst" translatable="false">Dismiss\n(ESC)</string>
|
||||
<string name="catalyst_reload_button" project="catalyst" translatable="false">Reload\n(R,\u00A0R)</string>
|
||||
|
||||
Reference in New Issue
Block a user