diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevInternalSettings.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevInternalSettings.java index 4e18237ef7ca03..123b728d7cba50 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevInternalSettings.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevInternalSettings.java @@ -88,6 +88,10 @@ public boolean isJSDevModeEnabled() { return mPreferences.getBoolean(PREFS_JS_DEV_MODE_DEBUG_KEY, true); } + public void setJSDevModeEnabled(boolean value) { + mPreferences.edit().putBoolean(PREFS_JS_DEV_MODE_DEBUG_KEY, value).apply(); + } + @Override public boolean isJSMinifyEnabled() { return mPreferences.getBoolean(PREFS_JS_MINIFY_DEBUG_KEY, false); diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java index 2d58c949ff3579..b3643e77b74ad2 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java @@ -459,6 +459,10 @@ public void showDevOptionsDialog() { 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(); } }); @@ -509,6 +513,10 @@ public void onOptionSelected() { 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(); } diff --git a/ReactAndroid/src/main/res/devsupport/xml/rn_dev_preferences.xml b/ReactAndroid/src/main/res/devsupport/xml/rn_dev_preferences.xml index c9b1e616ee6e36..6208e4e88020c0 100644 --- a/ReactAndroid/src/main/res/devsupport/xml/rn_dev_preferences.xml +++ b/ReactAndroid/src/main/res/devsupport/xml/rn_dev_preferences.xml @@ -10,7 +10,7 @@