summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard MacGregor <rmacgregor@cyngn.com>2015-05-19 15:58:56 -0700
committerRichard MacGregor <rmacgregor@cyngn.com>2015-05-26 16:04:20 +0000
commitbb432a101f6329a543f3be3b0cb4067f07ff2d70 (patch)
tree712579930376e52fc9fd65714e78d27841dd2aae /src
parentd19fe5d00c4711e4f9774f2cb752bcb2ba3c22f3 (diff)
downloadandroid_packages_providers_ThemesProvider-bb432a101f6329a543f3be3b0cb4067f07ff2d70.tar.gz
android_packages_providers_ThemesProvider-bb432a101f6329a543f3be3b0cb4067f07ff2d70.tar.bz2
android_packages_providers_ThemesProvider-bb432a101f6329a543f3be3b0cb4067f07ff2d70.zip
[2/2] Themes: Multiwallpaper support
Implement PreviewColumns.COMPONENTS_URI Be able to show all (multiple if present) wallpapers from installed themes. Update Themes DB to version 17: Add Component ID column to mix n match There can be more than one wallpaper in a theme now. So we need to track that in the mix n match table. Depends on: http://review.cyanogenmod.org/#/c/98951/ Change-Id: I3c4e5998288d4b98ccd180e827464d77195fce9f
Diffstat (limited to 'src')
-rw-r--r--src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java16
-rw-r--r--src/org/cyanogenmod/themes/provider/ThemesProvider.java3
2 files changed, 17 insertions, 2 deletions
diff --git a/src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java b/src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java
index 9bc3459..bcd8f04 100644
--- a/src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java
+++ b/src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java
@@ -36,7 +36,7 @@ import android.util.Log;
public class ThemesOpenHelper extends SQLiteOpenHelper {
private static final String TAG = ThemesOpenHelper.class.getName();
- private static final int DATABASE_VERSION = 16;
+ private static final int DATABASE_VERSION = 17;
private static final String DATABASE_NAME = "themes.db";
private static final String SYSTEM_THEME_PKG_NAME = ThemeConfig.SYSTEM_DEFAULT;
private static final String OLD_SYSTEM_THEME_PKG_NAME = "holo";
@@ -120,6 +120,10 @@ public class ThemesOpenHelper extends SQLiteOpenHelper {
upgradeToVersion16(db);
oldVersion = 16;
}
+ if (oldVersion == 16) {
+ upgradeToVersion17(db);
+ oldVersion = 17;
+ }
if (oldVersion != DATABASE_VERSION) {
Log.e(TAG, "Recreating db because unknown database version: " + oldVersion);
dropTables(db);
@@ -429,6 +433,13 @@ public class ThemesOpenHelper extends SQLiteOpenHelper {
}
}
+ private void upgradeToVersion17(SQLiteDatabase db) {
+ // add componentId column to mixnmatch db
+ String sql = String.format("ALTER TABLE %s ADD COLUMN %s INTEGER DEFAULT 0",
+ MixnMatchTable.TABLE_NAME, MixnMatchColumns.COL_COMPONENT_ID);
+ db.execSQL(sql);
+ }
+
private void dropTables(SQLiteDatabase db) {
db.execSQL("DROP TABLE IF EXISTS " + ThemesTable.TABLE_NAME);
db.execSQL("DROP TABLE IF EXISTS " + MixnMatchTable.TABLE_NAME);
@@ -513,7 +524,8 @@ public class ThemesOpenHelper extends SQLiteOpenHelper {
MixnMatchColumns.COL_KEY + " TEXT PRIMARY KEY," +
MixnMatchColumns.COL_VALUE + " TEXT," +
MixnMatchColumns.COL_PREV_VALUE + " TEXT," +
- MixnMatchColumns.COL_UPDATE_TIME + " INTEGER DEFAULT 0" +
+ MixnMatchColumns.COL_UPDATE_TIME + " INTEGER DEFAULT 0," +
+ MixnMatchColumns.COL_COMPONENT_ID + " INTEGER DEFAULT 0" +
")";
public static void insertDefaults(SQLiteDatabase db) {
diff --git a/src/org/cyanogenmod/themes/provider/ThemesProvider.java b/src/org/cyanogenmod/themes/provider/ThemesProvider.java
index 1fdc69b..384d814 100644
--- a/src/org/cyanogenmod/themes/provider/ThemesProvider.java
+++ b/src/org/cyanogenmod/themes/provider/ThemesProvider.java
@@ -236,6 +236,9 @@ public class ThemesProvider extends ContentProvider {
queryBuilder.appendWhere(MixnMatchColumns.COL_KEY + "=" + uri.getLastPathSegment());
break;
case COMPONENTS_PREVIEWS:
+ projection = ProviderUtils.modifyPreviewsProjection(projection);
+ selection = ProviderUtils.modifyPreviewsSelection(selection, projection);
+ selectionArgs = ProviderUtils.modifyPreviewsSelectionArgs(selectionArgs, projection);
groupBy = PreviewColumns.THEME_ID + "," + PreviewColumns.COMPONENT_ID;
queryBuilder.setTables(THEMES_PREVIEWS_INNER_JOIN);
break;