Bug 904741 - Change session restore pref to have two states. r=mfinkle

This commit is contained in:
Brian Nicholson 2013-08-23 12:32:19 -07:00
parent 22f5e009f3
commit e43a59734a
8 changed files with 19 additions and 33 deletions

View File

@ -1664,12 +1664,11 @@ abstract public class GeckoApp
protected int getSessionRestoreState(Bundle savedInstanceState) {
final SharedPreferences prefs = GeckoApp.getAppSharedPreferences();
int restoreMode = RESTORE_NONE;
boolean allowCrashRestore = true;
// If the version has changed, the user has done an upgrade, so restore
// previous tabs.
final int versionCode = getVersionCode();
if (prefs.getInt(PREFS_VERSION_CODE, 0) != versionCode) {
// If the version has changed, the user has done an upgrade, so restore
// previous tabs.
ThreadUtils.postToBackgroundThread(new Runnable() {
@Override
public void run() {
@ -1680,19 +1679,12 @@ abstract public class GeckoApp
});
restoreMode = RESTORE_NORMAL;
} else if (savedInstanceState != null) {
} else if (savedInstanceState != null || PreferenceManager.getDefaultSharedPreferences(this)
.getString(GeckoPreferences.PREFS_RESTORE_SESSION, "quit")
.equals("always")) {
// We're coming back from a background kill by the OS or the user
// has chosen to always restore, so restore.
restoreMode = RESTORE_NORMAL;
} else {
String restorePref = PreferenceManager.getDefaultSharedPreferences(this)
.getString(GeckoPreferences.PREFS_RESTORE_SESSION, "crash");
if ("always".equals(restorePref)) {
restoreMode = RESTORE_NORMAL;
} else {
restoreMode = RESTORE_NONE;
if ("never".equals(restorePref)) {
allowCrashRestore = false;
}
}
}
// We record crashes in the crash reporter. If sessionstore.js
@ -1709,9 +1701,7 @@ abstract public class GeckoApp
}
});
if (allowCrashRestore) {
restoreMode = RESTORE_CRASH;
}
restoreMode = RESTORE_CRASH;
}
return restoreMode;

View File

@ -77,7 +77,7 @@ public class GeckoPreferences
private static String PREFS_HEALTHREPORT_LINK = NON_PREF_PREFIX + "healthreport.link";
private static String PREFS_DEVTOOLS_REMOTE_ENABLED = "devtools.debugger.remote-enabled";
public static String PREFS_RESTORE_SESSION = NON_PREF_PREFIX + "restoreSession2";
public static String PREFS_RESTORE_SESSION = NON_PREF_PREFIX + "restoreSession3";
// These values are chosen to be distinct from other Activity constants.
private static int REQUEST_CODE_PREF_SCREEN = 5;

View File

@ -112,8 +112,7 @@
<!ENTITY pref_reflow_on_zoom4 "Text reflow">
<!ENTITY pref_restore "Tabs">
<!ENTITY pref_restore_always "Always restore">
<!ENTITY pref_restore_crash "Restore after a crash">
<!ENTITY pref_restore_never "Never restore">
<!ENTITY pref_restore_quit "Don\'t restore after quitting &brandShortName;">
<!ENTITY pref_font_size_tiny "Tiny">
<!ENTITY pref_font_size_small "Small">
<!ENTITY pref_font_size_medium "Medium">

View File

@ -101,13 +101,11 @@
</string-array>
<string-array name="pref_restore_entries">
<item>@string/pref_restore_always</item>
<item>@string/pref_restore_crash</item>
<item>@string/pref_restore_never</item>
<item>@string/pref_restore_quit</item>
</string-array>
<string-array name="pref_restore_values">
<item>always</item>
<item>crash</item>
<item>never</item>
<item>quit</item>
</string-array>
<string-array name="pref_update_autodownload_entries">
<item>@string/pref_update_autodownload_enabled</item>

View File

@ -25,9 +25,9 @@
android:negativeButtonText="@string/button_cancel"
android:persistent="false" />
<ListPreference android:key="android.not_a_preference.restoreSession2"
<ListPreference android:key="android.not_a_preference.restoreSession3"
android:title="@string/pref_restore"
android:defaultValue="crash"
android:defaultValue="quit"
android:entries="@array/pref_restore_entries"
android:entryValues="@array/pref_restore_values"
android:persistent="true" />

View File

@ -31,9 +31,9 @@
android:negativeButtonText="@string/button_cancel"
android:persistent="false" />
<ListPreference android:key="android.not_a_preference.restoreSession2"
<ListPreference android:key="android.not_a_preference.restoreSession3"
android:title="@string/pref_restore"
android:defaultValue="crash"
android:defaultValue="quit"
android:entries="@array/pref_restore_entries"
android:entryValues="@array/pref_restore_values"
android:persistent="true" />

View File

@ -27,9 +27,9 @@
android:negativeButtonText="@string/button_cancel"
android:persistent="false" />
<ListPreference android:key="android.not_a_preference.restoreSession2"
<ListPreference android:key="android.not_a_preference.restoreSession3"
android:title="@string/pref_restore"
android:defaultValue="crash"
android:defaultValue="quit"
android:entries="@array/pref_restore_entries"
android:entryValues="@array/pref_restore_values"
android:persistent="true" />

View File

@ -129,8 +129,7 @@
<string name="pref_reflow_on_zoom">&pref_reflow_on_zoom4;</string>
<string name="pref_restore">&pref_restore;</string>
<string name="pref_restore_always">&pref_restore_always;</string>
<string name="pref_restore_crash">&pref_restore_crash;</string>
<string name="pref_restore_never">&pref_restore_never;</string>
<string name="pref_restore_quit">&pref_restore_quit;</string>
<string name="pref_show_product_announcements">&pref_show_product_announcements;</string>
<string name="pref_sync">&pref_sync;</string>
<string name="pref_search_suggestions">&pref_search_suggestions;</string>