diff options
author | John Reck <jreck@google.com> | 2010-11-11 17:15:55 -0800 |
---|---|---|
committer | John Reck <jreck@google.com> | 2010-11-11 17:15:55 -0800 |
commit | 1097e3d7533fda2437da0fb98f6b08c63d9f2b03 (patch) | |
tree | 2eaaa3dc699aa8730034d8f2f6c3996048861a8d /src/com | |
parent | e222fe87a6a582b283cbad0f6967e908c4bfe85e (diff) | |
download | packages_apps_Browser-1097e3d7533fda2437da0fb98f6b08c63d9f2b03.zip packages_apps_Browser-1097e3d7533fda2437da0fb98f6b08c63d9f2b03.tar.gz packages_apps_Browser-1097e3d7533fda2437da0fb98f6b08c63d9f2b03.tar.bz2 |
Fixes bookmark sort order
Bug: 3185357
Changes the default sort behavior of bookmarks. If the browser is not
sync'd, then folders are sorted before bookmarks. If the browser is
sync'd, then the user-specified position takes absolute priority.
Change-Id: Ie27938a59714b0cd27c4419a66aab5076df69104
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/browser/provider/BrowserProvider2.java | 22 | ||||
-rw-r--r-- | src/com/android/browser/widget/BookmarkListWidgetService.java | 6 |
2 files changed, 19 insertions, 9 deletions
diff --git a/src/com/android/browser/provider/BrowserProvider2.java b/src/com/android/browser/provider/BrowserProvider2.java index 5b87d0f..8d9f1fe 100644 --- a/src/com/android/browser/provider/BrowserProvider2.java +++ b/src/com/android/browser/provider/BrowserProvider2.java @@ -99,8 +99,12 @@ public class BrowserProvider2 extends SQLiteContentProvider { public static final long FIXED_ID_ROOT = 1; - // BookmarkListWidgetService.ORDER_BY_CLAUSE has a copy of this default sort order - static final String DEFAULT_BOOKMARKS_SORT_ORDER = "position ASC, _id ASC"; + // Default sort order for unsync'd bookmarks + static final String DEFAULT_BOOKMARKS_SORT_ORDER = + Bookmarks.IS_FOLDER + " DESC, position ASC, _id ASC"; + + // Default sort order for sync'd bookmarks + static final String DEFAULT_BOOKMARKS_SORT_ORDER_SYNC = "position ASC, _id ASC"; static final UriMatcher URI_MATCHER = new UriMatcher(UriMatcher.NO_MATCH); @@ -604,7 +608,12 @@ public class BrowserProvider2 extends SQLiteContentProvider { // Set a default sort order if one isn't specified if (TextUtils.isEmpty(sortOrder)) { - sortOrder = DEFAULT_BOOKMARKS_SORT_ORDER; + if (!TextUtils.isEmpty(accountType) + && !TextUtils.isEmpty(accountName)) { + sortOrder = DEFAULT_BOOKMARKS_SORT_ORDER_SYNC; + } else { + sortOrder = DEFAULT_BOOKMARKS_SORT_ORDER; + } } qb.setProjectionMap(BOOKMARKS_PROJECTION_MAP); @@ -630,8 +639,13 @@ public class BrowserProvider2 extends SQLiteContentProvider { qb.setTables(TABLE_BOOKMARKS_JOIN_IMAGES); String[] args; String query; + // Set a default sort order if one isn't specified if (TextUtils.isEmpty(sortOrder)) { - sortOrder = DEFAULT_BOOKMARKS_SORT_ORDER; + if (useAccount) { + sortOrder = DEFAULT_BOOKMARKS_SORT_ORDER_SYNC; + } else { + sortOrder = DEFAULT_BOOKMARKS_SORT_ORDER; + } } if (!useAccount) { qb.setProjectionMap(BOOKMARKS_PROJECTION_MAP); diff --git a/src/com/android/browser/widget/BookmarkListWidgetService.java b/src/com/android/browser/widget/BookmarkListWidgetService.java index 893d3f5..1120536 100644 --- a/src/com/android/browser/widget/BookmarkListWidgetService.java +++ b/src/com/android/browser/widget/BookmarkListWidgetService.java @@ -67,10 +67,6 @@ public class BookmarkListWidgetService extends RemoteViewsService { BrowserContract.Bookmarks.PARENT, BrowserContract.Bookmarks.POSITION}; - // Ordering merged with DEFAULT_BOOKMARK_SORT_ORDER from BrowserProvider2 - private static final String ORDER_BY_CLAUSE = - Bookmarks.IS_FOLDER + " DESC, position ASC, _id ASC"; - private Map<Integer, BookmarkFactory> mFactories; private Handler mUiHandler; private BookmarksObserver mBookmarksObserver; @@ -310,7 +306,7 @@ public class BookmarkListWidgetService extends RemoteViewsService { Cursor c = null; try { c = mContext.getContentResolver().query(uri, PROJECTION, - where, null, ORDER_BY_CLAUSE); + where, null, null); if (c != null) { mBookmarks = new ArrayList<RenderResult>(c.getCount() + 1); if (folder != null) { |