summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2011-08-09 10:23:13 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-08-09 10:23:13 -0700
commite94de5ea927be9fad644c3ff7f9c7719ec4174af (patch)
treee6c1de9ab2f2e70e6b192bcd1d7bea74fc4a58ba /src/com/android
parent2db901c0c9788d6317faa9149d272478a9979d99 (diff)
parent1e9815d4c4864790fde2ad1e216058f922060c92 (diff)
downloadpackages_apps_Browser-e94de5ea927be9fad644c3ff7f9c7719ec4174af.zip
packages_apps_Browser-e94de5ea927be9fad644c3ff7f9c7719ec4174af.tar.gz
packages_apps_Browser-e94de5ea927be9fad644c3ff7f9c7719ec4174af.tar.bz2
Merge "Move local bookmarks to end of Bookmark page"
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/browser/AddBookmarkPage.java3
-rw-r--r--src/com/android/browser/BrowserBookmarksPage.java9
-rw-r--r--src/com/android/browser/provider/BrowserProvider2.java27
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) "
+ + " ) "
+ + ")";
}