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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user