Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class DevInternalSettings implements
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 static final String PREFS_HOT_MODULE_REPLACEMENT_KEY = "hot_module_replacement";
private static final String PREFS_USE_CACHED_BUNDLE = "use_cached_bundle";

private final SharedPreferences mPreferences;
private final DevSupportManager mDebugManager;
Expand Down Expand Up @@ -66,14 +67,20 @@ public boolean isJSDevModeEnabled() {
return mPreferences.getBoolean(PREFS_JS_DEV_MODE_DEBUG_KEY, true);
}

@Override
public boolean getShouldUseCachedBundle() {
return mPreferences.getBoolean(PREFS_USE_CACHED_BUNDLE, true);
}

public @Nullable String getDebugServerHost() {
return mPreferences.getString(PREFS_DEBUG_SERVER_HOST_KEY, null);
}

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_DEV_MODE_DEBUG_KEY.equals(key) ||
PREFS_USE_CACHED_BUNDLE.equals(key)) {
mDebugManager.reloadSettings();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ private boolean getHMR() {
return mSettings.isHotModuleReplacementEnabled();
}

/**
* @return whether we should use cached JS bundles.
*/
public boolean getShouldUseCachedBundle() {
return mSettings.getShouldUseCachedBundle();
}

/**
* @return the host to use when connecting to the bundle server.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ public String getDownloadedJSBundleFile() {
*/
@Override
public boolean hasUpToDateJSBundleInCache() {
if (mIsDevSupportEnabled && mJSBundleTempFile.exists()) {
if (mIsDevSupportEnabled && mDevServerHelper.getShouldUseCachedBundle() && mJSBundleTempFile.exists()) {
try {
String packageName = mApplicationContext.getPackageName();
PackageInfo thisPackage = mApplicationContext.getPackageManager()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,10 @@ public interface DeveloperSettings {
* @return Whether element inspector is enabled.
*/
boolean isElementInspectorEnabled();

/**
* @return Whether an cached bundle file should be used.
*/
boolean getShouldUseCachedBundle();

}
6 changes: 6 additions & 0 deletions ReactAndroid/src/main/res/devsupport/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
android:summary="At the end of animations, Toasts and logs to logcat debug information about the FPS during that transition. Currently only supported for transitions (animated navigations)."
android:defaultValue="false"
/>
<CheckBoxPreference
android:key="use_cached_bundle"
android:title="Use Cached Bundle"
android:summary="Use the last JS bundle downloaded from the packager if the packager cannot be reached."
android:defaultValue="true"
/>
</PreferenceCategory>
<PreferenceCategory
android:key="pref_key_catalyst_debug"
Expand Down