Permalink
Browse files

Don't require a DevSupportManager to create a DevInternalSettings

Summary: It should be possible to use the latter without using the former.

Reviewed By: ashwinb

Differential Revision: D4321776

fbshipit-source-id: 935fbb3fdb47369e18992aca0497d312ad6023bc
  • Loading branch information...
devknoll authored and facebook-github-bot committed Jan 27, 2017
1 parent a1cd5e0 commit fc2936cea90faebbea8cf350b6b16da8634c0d84
@@ -39,12 +39,12 @@
private static final String PREFS_REMOTE_JS_DEBUG_KEY = "remote_js_debug";
private final SharedPreferences mPreferences;
private final DevSupportManager mDebugManager;
private final Listener mListener;
public DevInternalSettings(
Context applicationContext,
DevSupportManager debugManager) {
mDebugManager = debugManager;
Listener listener) {
mListener = listener;
mPreferences = PreferenceManager.getDefaultSharedPreferences(applicationContext);
mPreferences.registerOnSharedPreferenceChangeListener(this);
}
@@ -78,11 +78,13 @@ public boolean isJSMinifyEnabled() {
}
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (PREFS_FPS_DEBUG_KEY.equals(key) ||
PREFS_RELOAD_ON_JS_CHANGE_KEY.equals(key) ||
PREFS_JS_DEV_MODE_DEBUG_KEY.equals(key) ||
PREFS_JS_MINIFY_DEBUG_KEY.equals(key)) {
mDebugManager.reloadSettings();
if (mListener != null) {
if (PREFS_FPS_DEBUG_KEY.equals(key) ||
PREFS_RELOAD_ON_JS_CHANGE_KEY.equals(key) ||
PREFS_JS_DEV_MODE_DEBUG_KEY.equals(key) ||
PREFS_JS_MINIFY_DEBUG_KEY.equals(key)) {
mListener.onInternalSettingsChanged();
}
}
}
@@ -119,4 +121,8 @@ public boolean isRemoteJSDebugEnabled() {
public void setRemoteJSDebugEnabled(boolean remoteJSDebugEnabled) {
mPreferences.edit().putBoolean(PREFS_REMOTE_JS_DEBUG_KEY, remoteJSDebugEnabled).apply();
}
public interface Listener {
void onInternalSettingsChanged();
}
}
@@ -86,7 +86,10 @@
* {@code <activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/>}
* {@code <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>}
*/
public class DevSupportManagerImpl implements DevSupportManager, PackagerCommandListener {
public class DevSupportManagerImpl implements
DevSupportManager,
PackagerCommandListener,
DevInternalSettings.Listener {
private static final int JAVA_ERROR_COOKIE = -1;
private static final int JSEXCEPTION_ERROR_COOKIE = -1;
@@ -623,6 +626,8 @@ public void reloadSettings() {
reload();
}
public void onInternalSettingsChanged() { reloadSettings(); }
@Override
public void handleReloadJS() {
UiThreadUtil.assertOnUiThread();

0 comments on commit fc2936c

Please sign in to comment.