mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-10 22:45:24 +08:00
Update dev menu to keep track of element inspector.
Summary: This PR makes the android dev menu consistent with iOS where toggling the inspector will update the button label accordingly. Closes https://github.com/facebook/react-native/pull/4628 Reviewed By: svcscm Differential Revision: D2740549 Pulled By: mkonicek fb-gh-sync-id: 02458d09b84e1592dcf245290ee2bbfb2863060d
This commit is contained in:
committed by
facebook-github-bot-3
parent
d0de0767e3
commit
c74d6403f5
@@ -33,6 +33,7 @@ public class DevInternalSettings implements
|
||||
private static final String PREFS_DEBUG_SERVER_HOST_KEY = "debug_http_host";
|
||||
private static final String PREFS_ANIMATIONS_DEBUG_KEY = "animations_debug";
|
||||
private static final String PREFS_RELOAD_ON_JS_CHANGE_KEY = "reload_on_js_change";
|
||||
private static final String PREFS_INSPECTOR_DEBUG_KEY = "inspector_debug";
|
||||
|
||||
private final SharedPreferences mPreferences;
|
||||
private final DevSupportManager mDebugManager;
|
||||
@@ -83,4 +84,12 @@ public class DevInternalSettings implements
|
||||
public void setReloadOnJSChangeEnabled(boolean enabled) {
|
||||
mPreferences.edit().putBoolean(PREFS_RELOAD_ON_JS_CHANGE_KEY, enabled).apply();
|
||||
}
|
||||
|
||||
public boolean isElementInspectorEnabled() {
|
||||
return mPreferences.getBoolean(PREFS_INSPECTOR_DEBUG_KEY, false);
|
||||
}
|
||||
|
||||
public void setElementInspectorEnabled(boolean enabled) {
|
||||
mPreferences.edit().putBoolean(PREFS_INSPECTOR_DEBUG_KEY, enabled).apply();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,10 +265,13 @@ public class DevSupportManager implements NativeModuleCallExceptionHandler {
|
||||
}
|
||||
});
|
||||
options.put(
|
||||
mApplicationContext.getString(R.string.catalyst_inspect_element),
|
||||
mDevSettings.isElementInspectorEnabled()
|
||||
? mApplicationContext.getString(R.string.catalyst_element_inspector_off)
|
||||
: mApplicationContext.getString(R.string.catalyst_element_inspector),
|
||||
new DevOptionHandler() {
|
||||
@Override
|
||||
public void onOptionSelected() {
|
||||
mDevSettings.setElementInspectorEnabled(!mDevSettings.isElementInspectorEnabled());
|
||||
mReactInstanceCommandsHandler.toggleElementInspector();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -28,4 +28,9 @@ public interface DeveloperSettings {
|
||||
* @return Whether dev mode should be enabled in JS bundles.
|
||||
*/
|
||||
boolean isJSDevModeEnabled();
|
||||
|
||||
/**
|
||||
* @return Whether element inspector is enabled.
|
||||
*/
|
||||
boolean isElementInspectorEnabled();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user