diff options
author | John Reck <jreck@google.com> | 2011-08-08 17:45:05 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2011-08-08 17:45:05 -0700 |
commit | 1e9815d4c4864790fde2ad1e216058f922060c92 (patch) | |
tree | 517138f7f52b174f85aebcc786160a03db7fd1d0 /src/com | |
parent | e28b347fcc1df6e6bd41cb294d521a4f1e7c5c75 (diff) | |
download | packages_apps_Browser-1e9815d4c4864790fde2ad1e216058f922060c92.zip packages_apps_Browser-1e9815d4c4864790fde2ad1e216058f922060c92.tar.gz packages_apps_Browser-1e9815d4c4864790fde2ad1e216058f922060c92.tar.bz2 |
Move local bookmarks to end of Bookmark page
Bug: 5136280
Also hide empty accounts in the bookmark page
Change-Id: I39067b5325d24c7ebf41df88c6231c411983fc57
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/browser/AddBookmarkPage.java | 3 | ||||
-rw-r--r-- | src/com/android/browser/BrowserBookmarksPage.java | 9 | ||||
-rw-r--r-- | src/com/android/browser/provider/BrowserProvider2.java | 27 |
3 files changed, 34 insertions, 5 deletions
diff --git a/src/com/android/browser/AddBookmarkPage.java b/src/com/android/browser/AddBookmarkPage.java index 2ac6fe6..903c363 100644 --- a/src/com/android/browser/AddBookmarkPage.java +++ b/src/com/android/browser/AddBookmarkPage.java @@ -1010,8 +1010,7 @@ public class AddBookmarkPage extends Activity static final int COLUMN_INDEX_ROOT_ID = 2; public AccountsLoader(Context context) { - super(context, Accounts.CONTENT_URI, PROJECTION, null, null, - Accounts.ACCOUNT_NAME + " ASC"); + super(context, Accounts.CONTENT_URI, PROJECTION, null, null, null); } } diff --git a/src/com/android/browser/BrowserBookmarksPage.java b/src/com/android/browser/BrowserBookmarksPage.java index 0c76a70..a03590b 100644 --- a/src/com/android/browser/BrowserBookmarksPage.java +++ b/src/com/android/browser/BrowserBookmarksPage.java @@ -41,7 +41,6 @@ import android.view.ActionMode; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; import android.view.LayoutInflater; -import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; @@ -54,6 +53,7 @@ import android.widget.Toast; import com.android.browser.BookmarkDragHandler.BookmarkDragController; import com.android.browser.BookmarkDragHandler.BookmarkDragState; +import com.android.browser.provider.BrowserProvider2; import com.android.browser.view.BookmarkExpandableView; import com.android.browser.view.BookmarkExpandableView.BookmarkContextMenuInfo; @@ -619,8 +619,11 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte }; public AccountsLoader(Context context) { - super(context, Accounts.CONTENT_URI, ACCOUNTS_PROJECTION, null, null, - Accounts.ACCOUNT_NAME + " ASC"); + super(context, Accounts.CONTENT_URI + .buildUpon() + .appendQueryParameter(BrowserProvider2.PARAM_ALLOW_EMPTY_ACCOUNTS, "false") + .build(), + ACCOUNTS_PROJECTION, null, null, null); } } diff --git a/src/com/android/browser/provider/BrowserProvider2.java b/src/com/android/browser/provider/BrowserProvider2.java index 0c1fd42..7e4ac0d 100644 --- a/src/com/android/browser/provider/BrowserProvider2.java +++ b/src/com/android/browser/provider/BrowserProvider2.java @@ -69,6 +69,7 @@ import java.util.HashMap; public class BrowserProvider2 extends SQLiteContentProvider { public static final String PARAM_GROUP_BY = "groupBy"; + public static final String PARAM_ALLOW_EMPTY_ACCOUNTS = "allowEmptyAccounts"; public static final String LEGACY_AUTHORITY = "browser"; static final Uri LEGACY_AUTHORITY_URI = new Uri.Builder() @@ -114,6 +115,9 @@ public class BrowserProvider2 extends SQLiteContentProvider { "ON history.url = images.url_key"; static final String DEFAULT_SORT_HISTORY = History.DATE_LAST_VISITED + " DESC"; + static final String DEFAULT_SORT_ACCOUNTS = + Accounts.ACCOUNT_NAME + " IS NOT NULL DESC, " + + Accounts.ACCOUNT_NAME + " ASC"; private static final String[] SUGGEST_PROJECTION = new String[] { Bookmarks._ID, @@ -844,6 +848,14 @@ public class BrowserProvider2 extends SQLiteContentProvider { case ACCOUNTS: { qb.setTables(VIEW_ACCOUNTS); qb.setProjectionMap(ACCOUNTS_PROJECTION_MAP); + String allowEmpty = uri.getQueryParameter(PARAM_ALLOW_EMPTY_ACCOUNTS); + if ("false".equals(allowEmpty)) { + selection = DatabaseUtils.concatenateWhere(selection, + SQL_WHERE_ACCOUNT_HAS_BOOKMARKS); + } + if (sortOrder == null) { + sortOrder = DEFAULT_SORT_ACCOUNTS; + } break; } @@ -2114,4 +2126,19 @@ public class BrowserProvider2 extends SQLiteContentProvider { + " WHERE url NOT IN (SELECT url FROM bookmarks" + " WHERE deleted = 0 AND folder = 0) " + " ORDER BY bookmark DESC, visits DESC, date DESC "; + + private static final String SQL_WHERE_ACCOUNT_HAS_BOOKMARKS = + "0 < ( " + + "SELECT count(*) " + + "FROM bookmarks " + + "WHERE deleted = 0 AND folder = 0 " + + " AND ( " + + " v_accounts.account_name = bookmarks.account_name " + + " OR (v_accounts.account_name IS NULL AND bookmarks.account_name IS NULL) " + + " ) " + + " AND ( " + + " v_accounts.account_type = bookmarks.account_type " + + " OR (v_accounts.account_type IS NULL AND bookmarks.account_type IS NULL) " + + " ) " + + ")"; } |