diff options
| author | Leon Scroggins <scroggo@google.com> | 2010-01-11 10:20:53 -0800 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2010-01-11 10:20:53 -0800 |
| commit | 87ec20cb906d9728de80471cf6b536c74237b0fc (patch) | |
| tree | a6039be1c77c109602d5537b8d4faf2060e1e6e9 /src/com/android | |
| parent | 15b8ec6b226f4d57307716e1f495e10a91f8cbf4 (diff) | |
| parent | 58c3d985682495d6563cafe21fa19a47ef349971 (diff) | |
| download | packages_apps_Browser-87ec20cb906d9728de80471cf6b536c74237b0fc.tar.gz packages_apps_Browser-87ec20cb906d9728de80471cf6b536c74237b0fc.tar.bz2 packages_apps_Browser-87ec20cb906d9728de80471cf6b536c74237b0fc.zip | |
am 58c3d985: am fde9746a: Clear parent/child tab relationships when clearing history.
Merge commit '58c3d985682495d6563cafe21fa19a47ef349971'
* commit '58c3d985682495d6563cafe21fa19a47ef349971':
Clear parent/child tab relationships when clearing history.
Diffstat (limited to 'src/com/android')
| -rw-r--r-- | src/com/android/browser/BrowserActivity.java | 9 | ||||
| -rw-r--r-- | src/com/android/browser/BrowserBookmarksPage.java | 17 | ||||
| -rw-r--r-- | src/com/android/browser/BrowserHistoryPage.java | 24 | ||||
| -rw-r--r-- | src/com/android/browser/BrowserPreferencesPage.java | 10 | ||||
| -rw-r--r-- | src/com/android/browser/CombinedBookmarkHistoryActivity.java | 45 | ||||
| -rw-r--r-- | src/com/android/browser/TabControl.java | 9 |
6 files changed, 98 insertions, 16 deletions
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java index 83ae6a0fb..ae1e41b63 100644 --- a/src/com/android/browser/BrowserActivity.java +++ b/src/com/android/browser/BrowserActivity.java @@ -3421,6 +3421,15 @@ public class BrowserActivity extends Activity } } } + // Deliberately fall through to PREFERENCES_PAGE, since the + // same extra may be attached to the COMBO_PAGE + case PREFERENCES_PAGE: + if (resultCode == RESULT_OK && intent != null) { + String action = intent.getStringExtra(Intent.EXTRA_TEXT); + if (BrowserSettings.PREF_CLEAR_HISTORY.equals(action)) { + mTabControl.removeParentChildRelationShips(); + } + } break; // Choose a file from the file picker. case FILE_SELECTED: diff --git a/src/com/android/browser/BrowserBookmarksPage.java b/src/com/android/browser/BrowserBookmarksPage.java index de4d11339..ca77e3caa 100644 --- a/src/com/android/browser/BrowserBookmarksPage.java +++ b/src/com/android/browser/BrowserBookmarksPage.java @@ -678,12 +678,17 @@ public class BrowserBookmarksPage extends Activity implements super.onBackPressed(); } - // This Activity is generally a sub-Activity of CombinedHistoryActivity. In - // that situation, we need to pass our result code up to our parent. - // However, if someone calls this Activity directly, then this has no - // parent, and it needs to set it on itself. + // This Activity is generally a sub-Activity of + // CombinedBookmarkHistoryActivity. In that situation, we need to pass our + // result code up to our parent. However, if someone calls this Activity + // directly, then this has no parent, and it needs to set it on itself. private void setResultToParent(int resultCode, Intent data) { - Activity a = getParent() == null ? this : getParent(); - a.setResult(resultCode, data); + Activity parent = getParent(); + if (parent == null) { + setResult(resultCode, data); + } else { + ((CombinedBookmarkHistoryActivity) parent).setResultFromChild( + resultCode, data); + } } } diff --git a/src/com/android/browser/BrowserHistoryPage.java b/src/com/android/browser/BrowserHistoryPage.java index 57ea87990..0c2bfae75 100644 --- a/src/com/android/browser/BrowserHistoryPage.java +++ b/src/com/android/browser/BrowserHistoryPage.java @@ -131,7 +131,12 @@ public class BrowserHistoryPage extends ExpandableListActivity { false); CombinedBookmarkHistoryActivity.getIconListenerSet() .addListener(mIconReceiver); - + Activity parent = getParent(); + if (null == parent + || !(parent instanceof CombinedBookmarkHistoryActivity)) { + throw new AssertionError("history page can only be viewed as a tab" + + "in CombinedBookmarkHistoryActivity"); + } // initialize the result to canceled, so that if the user just presses // back then it will have the correct result setResultToParent(RESULT_CANCELED, null); @@ -162,9 +167,11 @@ public class BrowserHistoryPage extends ExpandableListActivity { public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.clear_history_menu_id: - // FIXME: Need to clear the tab control in browserActivity - // as well Browser.clearHistory(getContentResolver()); + // BrowserHistoryPage is always a child of + // CombinedBookmarkHistoryActivity + ((CombinedBookmarkHistoryActivity) getParent()) + .removeParentChildRelationShips(); mAdapter.refreshData(); return true; @@ -272,13 +279,12 @@ public class BrowserHistoryPage extends ExpandableListActivity { return false; } - // This Activity is generally a sub-Activity of CombinedHistoryActivity. In - // that situation, we need to pass our result code up to our parent. - // However, if someone calls this Activity directly, then this has no - // parent, and it needs to set it on itself. + // This Activity is always a sub-Activity of + // CombinedBookmarkHistoryActivity. Therefore, we need to pass our + // result code up to our parent. private void setResultToParent(int resultCode, Intent data) { - Activity a = getParent() == null ? this : getParent(); - a.setResult(resultCode, data); + ((CombinedBookmarkHistoryActivity) getParent()).setResultFromChild( + resultCode, data); } private class ChangeObserver extends ContentObserver { diff --git a/src/com/android/browser/BrowserPreferencesPage.java b/src/com/android/browser/BrowserPreferencesPage.java index b636f9829..6426b99a7 100644 --- a/src/com/android/browser/BrowserPreferencesPage.java +++ b/src/com/android/browser/BrowserPreferencesPage.java @@ -73,6 +73,9 @@ public class BrowserPreferencesPage extends PreferenceActivity e = findPreference(BrowserSettings.PREF_DEFAULT_TEXT_ENCODING); e.setOnPreferenceChangeListener(this); + e = findPreference(BrowserSettings.PREF_CLEAR_HISTORY); + e.setOnPreferenceChangeListener(this); + if (BrowserSettings.getInstance().showDebugSettings()) { addPreferencesFromResource(R.xml.debug_preferences); } @@ -159,6 +162,13 @@ public class BrowserPreferencesPage extends PreferenceActivity BrowserSettings.PREF_DEFAULT_TEXT_ENCODING)) { pref.setSummary((String) objValue); return true; + } else if (pref.getKey().equals(BrowserSettings.PREF_CLEAR_HISTORY) + && ((Boolean) objValue).booleanValue() == true) { + // Need to tell the browser to remove the parent/child relationship + // between tabs + setResult(RESULT_OK, (new Intent()).putExtra(Intent.EXTRA_TEXT, + pref.getKey())); + return true; } return false; diff --git a/src/com/android/browser/CombinedBookmarkHistoryActivity.java b/src/com/android/browser/CombinedBookmarkHistoryActivity.java index a611d79c6..af968abdb 100644 --- a/src/com/android/browser/CombinedBookmarkHistoryActivity.java +++ b/src/com/android/browser/CombinedBookmarkHistoryActivity.java @@ -34,6 +34,21 @@ import java.util.Vector; public class CombinedBookmarkHistoryActivity extends TabActivity implements TabHost.OnTabChangeListener { + /** + * Used to inform BrowserActivity to remove the parent/child relationships + * from all the tabs. + */ + private String mExtraData; + /** + * Intent to be passed to calling Activity when finished. Keep a pointer to + * it locally so mExtraData can be added. + */ + private Intent mResultData; + /** + * Result code to pass back to calling Activity when finished. + */ + private int mResultCode; + /* package */ static String BOOKMARKS_TAB = "bookmark"; /* package */ static String VISITED_TAB = "visited"; /* package */ static String HISTORY_TAB = "history"; @@ -132,5 +147,33 @@ public class CombinedBookmarkHistoryActivity extends TabActivity } } - + /** + * Store extra data in the Intent to return to the calling Activity to tell + * it to clear the parent/child relationships from all tabs. + */ + /* package */ void removeParentChildRelationShips() { + mExtraData = BrowserSettings.PREF_CLEAR_HISTORY; + } + + /** + * Custom setResult() method so that the Intent can have extra data attached + * if necessary. + * @param resultCode Uses same codes as Activity.setResult + * @param data Intent returned to onActivityResult. + */ + /* package */ void setResultFromChild(int resultCode, Intent data) { + mResultCode = resultCode; + mResultData = data; + } + + @Override + public void finish() { + if (mExtraData != null) { + mResultCode = RESULT_OK; + if (mResultData == null) mResultData = new Intent(); + mResultData.putExtra(Intent.EXTRA_TEXT, mExtraData); + } + setResult(mResultCode, mResultData); + super.finish(); + } } diff --git a/src/com/android/browser/TabControl.java b/src/com/android/browser/TabControl.java index 07cf2ac62..5dc6b6d8f 100644 --- a/src/com/android/browser/TabControl.java +++ b/src/com/android/browser/TabControl.java @@ -174,6 +174,15 @@ class TabControl { } /** + * Remove the parent child relationships from all tabs. + */ + void removeParentChildRelationShips() { + for (Tab tab : mTabs) { + tab.removeFromTree(); + } + } + + /** * Remove the tab from the list. If the tab is the current tab shown, the * last created tab will be shown. * @param t The tab to be removed. |
