diff options
author | John Reck <jreck@google.com> | 2011-05-10 15:12:37 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2011-05-11 13:02:58 -0700 |
commit | 837ea5b1f5a7c2105cd5a6799918d23ac7b1a2b6 (patch) | |
tree | bedf29ea0566c2334d0fbbbe56e54f0a40bec7af | |
parent | 8075e388502f0abed3a7cc214188b44fcc453509 (diff) | |
download | packages_apps_Browser-837ea5b1f5a7c2105cd5a6799918d23ac7b1a2b6.zip packages_apps_Browser-837ea5b1f5a7c2105cd5a6799918d23ac7b1a2b6.tar.gz packages_apps_Browser-837ea5b1f5a7c2105cd5a6799918d23ac7b1a2b6.tar.bz2 |
Create accounts view
Change-Id: I2eb3c3566a74f208c02f1419ffa12d51619b83ef
-rw-r--r-- | src/com/android/browser/provider/BrowserProvider2.java | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/com/android/browser/provider/BrowserProvider2.java b/src/com/android/browser/provider/BrowserProvider2.java index 7d94c7a..7bb58b4 100644 --- a/src/com/android/browser/provider/BrowserProvider2.java +++ b/src/com/android/browser/provider/BrowserProvider2.java @@ -86,6 +86,8 @@ public class BrowserProvider2 extends SQLiteContentProvider { static final String TABLE_HISTORY_JOIN_IMAGES = "history LEFT OUTER JOIN images " + "ON history.url = images." + Images.URL; + static final String VIEW_ACCOUNTS = "v_accounts"; + static final String FORMAT_COMBINED_JOIN_SUBQUERY_JOIN_IMAGES = "history LEFT OUTER JOIN (%s) bookmarks " + "ON history.url = bookmarks.url LEFT OUTER JOIN images " + @@ -203,6 +205,7 @@ public class BrowserProvider2 extends SQLiteContentProvider { map = ACCOUNTS_PROJECTION_MAP; map.put(Accounts.ACCOUNT_TYPE, Accounts.ACCOUNT_TYPE); map.put(Accounts.ACCOUNT_NAME, Accounts.ACCOUNT_NAME); + map.put(Accounts.ROOT_ID, Accounts.ROOT_ID); // Bookmarks map = BOOKMARKS_PROJECTION_MAP; @@ -328,7 +331,7 @@ public class BrowserProvider2 extends SQLiteContentProvider { final class DatabaseHelper extends SQLiteOpenHelper { static final String DATABASE_NAME = "browser2.db"; - static final int DATABASE_VERSION = 26; + static final int DATABASE_VERSION = 27; public DatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @@ -390,15 +393,36 @@ public class BrowserProvider2 extends SQLiteContentProvider { Settings.VALUE + " TEXT NOT NULL" + ");"); + createAccountsView(db); + mSyncHelper.createDatabase(db); createDefaultBookmarks(db); } + void createAccountsView(SQLiteDatabase db) { + db.execSQL("CREATE VIEW IF NOT EXISTS v_accounts AS " + + "SELECT NULL AS " + Accounts.ACCOUNT_NAME + + ", NULL AS " + Accounts.ACCOUNT_TYPE + + ", " + FIXED_ID_ROOT + " AS " + Accounts.ROOT_ID + + " UNION ALL SELECT " + Accounts.ACCOUNT_NAME + + ", " + Accounts.ACCOUNT_TYPE + ", " + + Bookmarks._ID + " AS " + Accounts.ROOT_ID + + " FROM " + TABLE_BOOKMARKS + " WHERE " + + ChromeSyncColumns.SERVER_UNIQUE + " = \"" + + ChromeSyncColumns.FOLDER_NAME_BOOKMARKS_BAR + "\" AND " + + Bookmarks.IS_DELETED + " = 0"); + } + @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO write upgrade logic - db.execSQL("DROP VIEW IF EXISTS combined"); + if (oldVersion < 27) { + createAccountsView(db); + } + if (oldVersion < 26) { + db.execSQL("DROP VIEW IF EXISTS combined"); + } if (oldVersion < 25) { db.execSQL("DROP TABLE IF EXISTS " + TABLE_BOOKMARKS); db.execSQL("DROP TABLE IF EXISTS " + TABLE_HISTORY); @@ -650,10 +674,8 @@ public class BrowserProvider2 extends SQLiteContentProvider { String limit = uri.getQueryParameter(BrowserContract.PARAM_LIMIT); switch (match) { case ACCOUNTS: { - qb.setTables(TABLE_BOOKMARKS); + qb.setTables(VIEW_ACCOUNTS); qb.setProjectionMap(ACCOUNTS_PROJECTION_MAP); - qb.setDistinct(true); - qb.appendWhere(Bookmarks.IS_DELETED + "=0"); break; } |