summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2011-01-11 13:20:32 -0800
committerJohn Reck <jreck@google.com>2011-01-11 17:01:20 -0800
commit1b3c66ed83cb83ba1be775d5f108f698f0d4ee1f (patch)
tree1ce221a4efb0eba08569e45dd5a64af48cd76726
parent1605bef4e1f99805a801308f97ade622b907dc7a (diff)
downloadpackages_apps_Browser-1b3c66ed83cb83ba1be775d5f108f698f0d4ee1f.zip
packages_apps_Browser-1b3c66ed83cb83ba1be775d5f108f698f0d4ee1f.tar.gz
packages_apps_Browser-1b3c66ed83cb83ba1be775d5f108f698f0d4ee1f.tar.bz2
Adds a "open all in tabs" to folder context menu
In bookmarks, long pressing on a folder now has an "open all in new tabs" option that opens all of it's child bookmarks (not recursive) in new tabs. Change-Id: Ied4da5cd4f2cf83b58a6f1e618bdfce44b4f4a99
-rw-r--r--res/menu/bookmarkscontext.xml2
-rw-r--r--res/values-xlarge/strings.xml2
-rw-r--r--res/values/strings.xml2
-rw-r--r--src/com/android/browser/BrowserBookmarksPage.java35
4 files changed, 40 insertions, 1 deletions
diff --git a/res/menu/bookmarkscontext.xml b/res/menu/bookmarkscontext.xml
index 4d7ec7a..3a13b9a 100644
--- a/res/menu/bookmarkscontext.xml
+++ b/res/menu/bookmarkscontext.xml
@@ -36,6 +36,8 @@
</group>
<group android:id="@+id/FOLDER_CONTEXT_MENU"
android:visible="false">
+ <item android:id="@+id/new_window_context_menu_id"
+ android:title="@string/open_all_in_new_window"/>
<item android:id="@+id/edit_context_menu_id"
android:title="@string/edit_folder"/>
<item android:id="@+id/delete_context_menu_id"
diff --git a/res/values-xlarge/strings.xml b/res/values-xlarge/strings.xml
index 856b2b9..8dcabe2 100644
--- a/res/values-xlarge/strings.xml
+++ b/res/values-xlarge/strings.xml
@@ -25,4 +25,6 @@
<!-- Context Menu item to open the currently selected link in a new
window. [CHAR LIMIT=30] -->
<string name="contextmenu_openlink_newwindow">Open in new tab</string>
+ <!-- Context menu item to open every bookmark in a folder in new tabs [CHAR LIMIT=50] -->
+ <string name="open_all_in_new_window">Open all in new tabs</string>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index b8a45bf..e676bb3 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -204,6 +204,8 @@
<string name="delete_bookmark_warning">Bookmark \"<xliff:g id="bookmark">%s</xliff:g>\" will be deleted.</string>
<!-- Context Menu item to open the selected link in a new window -->
<string name="open_in_new_window">Open in new window</string>
+ <!-- Context menu item to open every bookmark in a folder in new windows [CHAR LIMIT=50] -->
+ <string name="open_all_in_new_window">Open all in new windows</string>
<!-- Menu item to open a dialog which allows the user to enter a url or do search-->
<string name="goto_dot">Go</string>
<!-- Menu item that opens up a new incognito tab. [CHAR LIMIT=30] -->
diff --git a/src/com/android/browser/BrowserBookmarksPage.java b/src/com/android/browser/BrowserBookmarksPage.java
index 825da33..ea97c29 100644
--- a/src/com/android/browser/BrowserBookmarksPage.java
+++ b/src/com/android/browser/BrowserBookmarksPage.java
@@ -566,8 +566,41 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte
private void openInNewWindow(int position) {
if (mCallbacks != null) {
- mCallbacks.onOpenInNewWindow(mAdapter.getItem(position));
+ Cursor c = mAdapter.getItem(position);
+ boolean isFolder = c.getInt(BookmarksLoader.COLUMN_INDEX_IS_FOLDER) == 1;
+ if (isFolder) {
+ long id = c.getLong(BookmarksLoader.COLUMN_INDEX_ID);
+ new OpenAllInTabsTask(id).execute();
+ } else {
+ mCallbacks.onOpenInNewWindow(c);
+ }
+ }
+ }
+
+ class OpenAllInTabsTask extends AsyncTask<Void, Void, Cursor> {
+ long mFolderId;
+ public OpenAllInTabsTask(long id) {
+ mFolderId = id;
+ }
+
+ @Override
+ protected Cursor doInBackground(Void... params) {
+ Context c = getActivity();
+ if (c == null) return null;
+ return c.getContentResolver().query(BookmarkUtils.getBookmarksUri(c),
+ BookmarksLoader.PROJECTION, BrowserContract.Bookmarks.PARENT + "=?",
+ new String[] { Long.toString(mFolderId) }, null);
}
+
+ @Override
+ protected void onPostExecute(Cursor result) {
+ if (mCallbacks != null) {
+ while (result.moveToNext()) {
+ mCallbacks.onOpenInNewWindow(result);
+ }
+ }
+ }
+
}
private void editBookmark(int position) {