diff options
author | John Reck <jreck@google.com> | 2011-06-17 14:47:20 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2011-06-17 14:47:20 -0700 |
commit | 24f1826440334ba8a3d2453699c51c1a4b117c7b (patch) | |
tree | 831b9b3302b2111cc376cc73fbb688a582565f51 | |
parent | 7dc444b4c3b70a09a33c0892fb8677922bdf1ecc (diff) | |
download | packages_apps_Browser-24f1826440334ba8a3d2453699c51c1a4b117c7b.zip packages_apps_Browser-24f1826440334ba8a3d2453699c51c1a4b117c7b.tar.gz packages_apps_Browser-24f1826440334ba8a3d2453699c51c1a4b117c7b.tar.bz2 |
Clarify restore dialog, prevent spam
Bug: 4599646
State that it is the browser's windows/tabs to be restored and
show the browser's app icon in the dialog.
Also cut down on the frequency this prompt will appear by
ignoring tabs that haven't loaded anything except the home page.
Change-Id: I2c2cc03aa92da3199c47b455256145d392548930
-rw-r--r-- | res/values-sw600dp/strings.xml | 2 | ||||
-rw-r--r-- | res/values/strings.xml | 2 | ||||
-rw-r--r-- | src/com/android/browser/Controller.java | 6 | ||||
-rw-r--r-- | src/com/android/browser/CrashRecoveryHandler.java | 10 | ||||
-rw-r--r-- | src/com/android/browser/Tab.java | 7 | ||||
-rw-r--r-- | src/com/android/browser/TabControl.java | 17 |
6 files changed, 31 insertions, 13 deletions
diff --git a/res/values-sw600dp/strings.xml b/res/values-sw600dp/strings.xml index 82ba301..cb0d8a4 100644 --- a/res/values-sw600dp/strings.xml +++ b/res/values-sw600dp/strings.xml @@ -35,5 +35,5 @@ <!-- Recover tabs after a crash dialog title [CHAR LIMIT=32] --> <string name="recover_title">Restore tabs?</string> <!-- Recover tabs after a crash dialog prompt [CHAR LIMIT=none] --> - <string name="recover_prompt">Would you like to restore your tabs from last time?</string> + <string name="recover_prompt">Would you like to restore your browser tabs from last time?</string> </resources> diff --git a/res/values/strings.xml b/res/values/strings.xml index c846965..8df4642 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -994,7 +994,7 @@ <!-- Recover tabs after a crash dialog title [CHAR LIMIT=32] --> <string name="recover_title">Restore windows?</string> <!-- Recover tabs after a crash dialog prompt [CHAR LIMIT=none] --> - <string name="recover_prompt">Would you like to restore your windows from last time?</string> + <string name="recover_prompt">Would you like to restore your browser windows from last time?</string> <!-- Yes, recover windows from last time [CHAR LIMIT=10] --> <string name="recover_yes">Restore</string> <!-- No, don't recover windows from last time [CHAR LIMIT=10] --> diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java index 911f724..e3ca09a 100644 --- a/src/com/android/browser/Controller.java +++ b/src/com/android/browser/Controller.java @@ -640,8 +640,10 @@ public class Controller // Save all the tabs mTabControl.saveState(outState, saveImages); - // Save time so that we know how old incognito tabs (if any) are. - outState.putSerializable("lastActiveDate", Calendar.getInstance()); + if (!outState.isEmpty()) { + // Save time so that we know how old incognito tabs (if any) are. + outState.putSerializable("lastActiveDate", Calendar.getInstance()); + } } void onResume() { diff --git a/src/com/android/browser/CrashRecoveryHandler.java b/src/com/android/browser/CrashRecoveryHandler.java index 7ee9cee..acc2a30 100644 --- a/src/com/android/browser/CrashRecoveryHandler.java +++ b/src/com/android/browser/CrashRecoveryHandler.java @@ -103,6 +103,10 @@ public class CrashRecoveryHandler { @Override public void run() { + if (mState.isEmpty()) { + clearState(mContext); + return; + } Parcel p = Parcel.obtain(); try { mState.writeToParcel(p, 0); @@ -119,8 +123,7 @@ public class CrashRecoveryHandler { } - private void clearState() { - Context context = mController.getActivity(); + private static void clearState(Context context) { context.deleteFile(STATE_FILE); } @@ -128,6 +131,7 @@ public class CrashRecoveryHandler { new AlertDialog.Builder(mController.getActivity()) .setTitle(R.string.recover_title) .setMessage(R.string.recover_prompt) + .setIcon(R.mipmap.ic_launcher_browser) .setPositiveButton(R.string.recover_yes, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { @@ -137,7 +141,7 @@ public class CrashRecoveryHandler { .setNegativeButton(R.string.recover_no, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - clearState(); + clearState(mController.getActivity()); mController.doStart(null, intent); } }) diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java index bb200d8..58a7491 100644 --- a/src/com/android/browser/Tab.java +++ b/src/com/android/browser/Tab.java @@ -37,6 +37,7 @@ import android.os.SystemClock; import android.security.KeyChain; import android.security.KeyChainAliasCallback; import android.speech.RecognizerResultsIntent; +import android.text.TextUtils; import android.util.Log; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -1776,6 +1777,12 @@ class Tab { if (mMainView == null) { return mSavedState != null; } + // If the tab is the homepage or has no URL, don't save it + String homepage = BrowserSettings.getInstance().getHomePage(); + if (TextUtils.equals(homepage, mCurrentState.mUrl) + || TextUtils.isEmpty(mCurrentState.mUrl)) { + return false; + } mSavedState = new Bundle(); mMainView.saveState(mSavedState); diff --git a/src/com/android/browser/TabControl.java b/src/com/android/browser/TabControl.java index 6566ac8..1367ba2 100644 --- a/src/com/android/browser/TabControl.java +++ b/src/com/android/browser/TabControl.java @@ -288,6 +288,9 @@ class TabControl { */ void saveState(Bundle outState, boolean saveImages) { final int numTabs = getTabCount(); + if (numTabs == 0) { + return; + } long[] ids = new long[numTabs]; int i = 0; for (Tab tab : mTabs) { @@ -297,13 +300,15 @@ class TabControl { tab.getSavedState(saveImages)); } } - outState.putLongArray(POSITIONS, ids); - Tab current = getCurrentTab(); - long cid = -1; - if (current != null) { - cid = current.getId(); + if (!outState.isEmpty()) { + outState.putLongArray(POSITIONS, ids); + Tab current = getCurrentTab(); + long cid = -1; + if (current != null) { + cid = current.getId(); + } + outState.putLong(CURRENT, cid); } - outState.putLong(CURRENT, cid); } /** |