diff options
author | John Reck <jreck@google.com> | 2012-04-12 17:27:34 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2012-04-12 17:30:09 -0700 |
commit | d18ac4b36b057a6a403cb060dfc10761b7394548 (patch) | |
tree | 66e83cef9ad5a60bc1b1848daa22c46ae6417799 /src/com | |
parent | 80f750852edf43c6b09e5633f2c6ebdb2ed94a5b (diff) | |
download | packages_apps_Browser-d18ac4b36b057a6a403cb060dfc10761b7394548.zip packages_apps_Browser-d18ac4b36b057a6a403cb060dfc10761b7394548.tar.gz packages_apps_Browser-d18ac4b36b057a6a403cb060dfc10761b7394548.tar.bz2 |
Support BOOKMARK_TYPE
Bug: 6332869
Bug: 5494697
Bookmark type also gives us an easy way to localize Other Bookmarks
Change-Id: Iab208da0cb1b2af5d256990cdc4ab5c11821523b
Diffstat (limited to 'src/com')
4 files changed, 28 insertions, 7 deletions
diff --git a/src/com/android/browser/BookmarksLoader.java b/src/com/android/browser/BookmarksLoader.java index bc06497..80d4255 100644 --- a/src/com/android/browser/BookmarksLoader.java +++ b/src/com/android/browser/BookmarksLoader.java @@ -34,7 +34,7 @@ public class BookmarksLoader extends CursorLoader { public static final int COLUMN_INDEX_TOUCH_ICON = 5; public static final int COLUMN_INDEX_IS_FOLDER = 6; public static final int COLUMN_INDEX_PARENT = 8; - public static final int COLUMN_INDEX_SERVER_UNIQUE = 9; + public static final int COLUMN_INDEX_TYPE = 9; public static final String[] PROJECTION = new String[] { Bookmarks._ID, // 0 @@ -46,7 +46,7 @@ public class BookmarksLoader extends CursorLoader { Bookmarks.IS_FOLDER, // 6 Bookmarks.POSITION, // 7 Bookmarks.PARENT, // 8 - ChromeSyncColumns.SERVER_UNIQUE, // 9 + Bookmarks.TYPE, // 9 }; String mAccountType; diff --git a/src/com/android/browser/BrowserBookmarksAdapter.java b/src/com/android/browser/BrowserBookmarksAdapter.java index 2fd880c..fcc3f27 100644 --- a/src/com/android/browser/BrowserBookmarksAdapter.java +++ b/src/com/android/browser/BrowserBookmarksAdapter.java @@ -20,6 +20,7 @@ import android.content.Context; import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.provider.BrowserContract.Bookmarks; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -52,6 +53,15 @@ public class BrowserBookmarksAdapter extends CursorAdapter { } } + CharSequence getTitle(Cursor cursor, Context context) { + int type = cursor.getInt(BookmarksLoader.COLUMN_INDEX_TYPE); + switch (type) { + case Bookmarks.BOOKMARK_TYPE_OTHER_FOLDER: + return context.getText(R.string.other_bookmarks); + } + return cursor.getString(BookmarksLoader.COLUMN_INDEX_TITLE); + } + void bindGridView(View view, Context context, Cursor cursor) { // We need to set this to handle rotation and other configuration change // events. If the padding didn't change, this is a no op. @@ -62,7 +72,7 @@ public class BrowserBookmarksAdapter extends CursorAdapter { ImageView thumb = (ImageView) view.findViewById(R.id.thumb); TextView tv = (TextView) view.findViewById(R.id.label); - tv.setText(cursor.getString(BookmarksLoader.COLUMN_INDEX_TITLE)); + tv.setText(getTitle(cursor, context)); if (cursor.getInt(BookmarksLoader.COLUMN_INDEX_IS_FOLDER) != 0) { // folder thumb.setImageResource(R.drawable.thumb_bookmark_widget_folder_holo); @@ -89,7 +99,7 @@ public class BrowserBookmarksAdapter extends CursorAdapter { ImageView favicon = (ImageView) view.findViewById(R.id.favicon); TextView tv = (TextView) view.findViewById(R.id.label); - tv.setText(cursor.getString(BookmarksLoader.COLUMN_INDEX_TITLE)); + tv.setText(getTitle(cursor, context)); if (cursor.getInt(BookmarksLoader.COLUMN_INDEX_IS_FOLDER) != 0) { // folder favicon.setImageResource(R.drawable.ic_folder_holo_dark); diff --git a/src/com/android/browser/BrowserBookmarksPage.java b/src/com/android/browser/BrowserBookmarksPage.java index da60fda..2c8a27a 100644 --- a/src/com/android/browser/BrowserBookmarksPage.java +++ b/src/com/android/browser/BrowserBookmarksPage.java @@ -37,7 +37,6 @@ import android.os.AsyncTask; import android.os.Bundle; import android.provider.BrowserContract; import android.provider.BrowserContract.Accounts; -import android.provider.BrowserContract.ChromeSyncColumns; import android.view.ActionMode; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; @@ -285,8 +284,9 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte } boolean canEdit(Cursor c) { - String unique = c.getString(BookmarksLoader.COLUMN_INDEX_SERVER_UNIQUE); - return !ChromeSyncColumns.FOLDER_NAME_OTHER_BOOKMARKS.equals(unique); + int type = c.getInt(BookmarksLoader.COLUMN_INDEX_TYPE); + return type == BrowserContract.Bookmarks.BOOKMARK_TYPE_BOOKMARK + || type == BrowserContract.Bookmarks.BOOKMARK_TYPE_FOLDER; } private void populateBookmarkItem(Cursor cursor, BookmarkItem item, boolean isFolder) { diff --git a/src/com/android/browser/provider/BrowserProvider2.java b/src/com/android/browser/provider/BrowserProvider2.java index 6121abc..a66c333 100644 --- a/src/com/android/browser/provider/BrowserProvider2.java +++ b/src/com/android/browser/provider/BrowserProvider2.java @@ -284,6 +284,17 @@ public class BrowserProvider2 extends SQLiteContentProvider { " FROM " + TABLE_BOOKMARKS + " A WHERE " + "A." + Bookmarks._ID + "=" + TABLE_BOOKMARKS + "." + Bookmarks.INSERT_AFTER + ") AS " + Bookmarks.INSERT_AFTER_SOURCE_ID); + map.put(Bookmarks.TYPE, "CASE " + + " WHEN " + Bookmarks.IS_FOLDER + "=0 THEN " + + Bookmarks.BOOKMARK_TYPE_BOOKMARK + + " WHEN " + ChromeSyncColumns.SERVER_UNIQUE + "='" + + ChromeSyncColumns.FOLDER_NAME_BOOKMARKS_BAR + "' THEN " + + Bookmarks.BOOKMARK_TYPE_BOOKMARK_BAR_FOLDER + + " WHEN " + ChromeSyncColumns.SERVER_UNIQUE + "='" + + ChromeSyncColumns.FOLDER_NAME_OTHER_BOOKMARKS + "' THEN " + + Bookmarks.BOOKMARK_TYPE_OTHER_FOLDER + + " ELSE " + Bookmarks.BOOKMARK_TYPE_FOLDER + + " END AS " + Bookmarks.TYPE); // Other bookmarks OTHER_BOOKMARKS_PROJECTION_MAP.putAll(BOOKMARKS_PROJECTION_MAP); |