summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard MacGregor <rmacgregor@cyngn.com>2015-05-05 00:07:52 (GMT)
committerRichard MacGregor <rmacgregor@cyngn.com>2015-05-15 22:04:15 (GMT)
commitc16990420bc1b6377edc4523d80fc71edf32d55d (patch)
tree52a23caefa2089e1de68ecec7355365d45cadd0a /src
parent3b2e3e3cff4d94daa2b2819fff0f0e574eecd02e (diff)
downloadandroid_packages_providers_ThemesProvider-c16990420bc1b6377edc4523d80fc71edf32d55d.zip
android_packages_providers_ThemesProvider-c16990420bc1b6377edc4523d80fc71edf32d55d.tar.gz
android_packages_providers_ThemesProvider-c16990420bc1b6377edc4523d80fc71edf32d55d.tar.bz2
[2/3] Improve PreviewsColumns Implementation
Previews columns now uses a key/value pair structure to allow for easier future support of multiple components per theme pack. Depends on: http://review.cyanogenmod.org/#/c/96836/ Change-Id: I37a44558d3c52f8fe910b4773495ee1fac71fbbd
Diffstat (limited to 'src')
-rw-r--r--src/org/cyanogenmod/themes/provider/PreviewGenerationService.java136
-rw-r--r--src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java95
-rw-r--r--src/org/cyanogenmod/themes/provider/ThemesProvider.java70
3 files changed, 196 insertions, 105 deletions
diff --git a/src/org/cyanogenmod/themes/provider/PreviewGenerationService.java b/src/org/cyanogenmod/themes/provider/PreviewGenerationService.java
index 3281038..db67775 100644
--- a/src/org/cyanogenmod/themes/provider/PreviewGenerationService.java
+++ b/src/org/cyanogenmod/themes/provider/PreviewGenerationService.java
@@ -41,6 +41,8 @@ import org.cyanogenmod.themes.provider.util.WallpaperPreviewGenerator;
import org.cyanogenmod.themes.provider.util.WallpaperPreviewGenerator.WallpaperItems;
import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.List;
/*
* Copies images from the theme APK to the local provider's cache
@@ -165,67 +167,139 @@ public class PreviewGenerationService extends IntentService {
int id = cursor.getInt(cursor.getColumnIndexOrThrow(ThemesColumns._ID));
cursor.close();
- ContentValues values = new ContentValues();
- values.put(PreviewColumns.THEME_ID, id);
+ List<ContentValues> themeValues = new ArrayList<ContentValues>();
+ ContentValues values = null;
if (items != null) {
- values.put(PreviewColumns.STATUSBAR_BACKGROUND,
+ values = createPreviewEntryBlob(id, PreviewColumns.KEY_STATUSBAR_BACKGROUND,
getBitmapBlobPng(items.statusbarBackground));
- values.put(PreviewColumns.STATUSBAR_BLUETOOTH_ICON,
+ themeValues.add(values);
+
+ values = createPreviewEntryBlob(id, PreviewColumns.KEY_STATUSBAR_BLUETOOTH_ICON,
getBitmapBlobPng(items.bluetoothIcon));
- values.put(PreviewColumns.STATUSBAR_WIFI_ICON,
+ themeValues.add(values);
+
+ values = createPreviewEntryBlob(id, PreviewColumns.KEY_STATUSBAR_WIFI_ICON,
getBitmapBlobPng(items.wifiIcon));
- values.put(PreviewColumns.STATUSBAR_SIGNAL_ICON,
+ themeValues.add(values);
+
+ values = createPreviewEntryBlob(id, PreviewColumns.KEY_STATUSBAR_SIGNAL_ICON,
getBitmapBlobPng(items.signalIcon));
- values.put(PreviewColumns.STATUSBAR_BATTERY_PORTRAIT,
+ themeValues.add(values);
+
+ values = createPreviewEntryBlob(id, PreviewColumns.KEY_STATUSBAR_BATTERY_PORTRAIT,
getBitmapBlobPng(items.batteryPortrait));
- values.put(PreviewColumns.STATUSBAR_BATTERY_LANDSCAPE,
+ themeValues.add(values);
+
+ values = createPreviewEntryBlob(id, PreviewColumns.KEY_STATUSBAR_BATTERY_LANDSCAPE,
getBitmapBlobPng(items.batteryLandscape));
- values.put(PreviewColumns.STATUSBAR_BATTERY_CIRCLE,
+ themeValues.add(values);
+
+ values = createPreviewEntryBlob(id, PreviewColumns.KEY_STATUSBAR_BATTERY_CIRCLE,
getBitmapBlobPng(items.batteryCircle));
- values.put(PreviewColumns.STATUSBAR_CLOCK_TEXT_COLOR, items.clockColor);
- values.put(PreviewColumns.STATUSBAR_WIFI_COMBO_MARGIN_END, items.wifiMarginEnd);
- values.put(PreviewColumns.NAVBAR_BACKGROUND,
+ themeValues.add(values);
+
+ values = createPreviewEntryInt(id, PreviewColumns.KEY_STATUSBAR_CLOCK_TEXT_COLOR,
+ items.clockColor);
+ themeValues.add(values);
+
+ values = createPreviewEntryInt(id,
+ PreviewColumns.KEY_STATUSBAR_WIFI_COMBO_MARGIN_END, items.wifiMarginEnd);
+ themeValues.add(values);
+
+ values = createPreviewEntryBlob(id, PreviewColumns.KEY_NAVBAR_BACKGROUND,
getBitmapBlobPng(items.navbarBackground));
- values.put(PreviewColumns.NAVBAR_BACK_BUTTON,
+ themeValues.add(values);
+
+ values = createPreviewEntryBlob(id, PreviewColumns.KEY_NAVBAR_BACK_BUTTON,
getBitmapBlobPng(items.navbarBack));
- values.put(PreviewColumns.NAVBAR_HOME_BUTTON,
+ themeValues.add(values);
+
+ values = createPreviewEntryBlob(id, PreviewColumns.KEY_NAVBAR_HOME_BUTTON,
getBitmapBlobPng(items.navbarHome));
- values.put(PreviewColumns.NAVBAR_RECENT_BUTTON,
+ themeValues.add(values);
+
+ values = createPreviewEntryBlob(id, PreviewColumns.KEY_NAVBAR_RECENT_BUTTON,
getBitmapBlobPng(items.navbarRecent));
+ themeValues.add(values);
}
if (icons != null) {
- values.put(PreviewColumns.ICON_PREVIEW_1, getBitmapBlobPng(icons.icon1));
- values.put(PreviewColumns.ICON_PREVIEW_2, getBitmapBlobPng(icons.icon2));
- values.put(PreviewColumns.ICON_PREVIEW_3, getBitmapBlobPng(icons.icon3));
+ values = createPreviewEntryBlob(id, PreviewColumns.KEY_ICON_PREVIEW_1,
+ getBitmapBlobPng(icons.icon1));
+ themeValues.add(values);
+
+ values = createPreviewEntryBlob(id, PreviewColumns.KEY_ICON_PREVIEW_2,
+ getBitmapBlobPng(icons.icon2));
+ themeValues.add(values);
+
+ values = createPreviewEntryBlob(id, PreviewColumns.KEY_ICON_PREVIEW_3,
+ getBitmapBlobPng(icons.icon3));
+ themeValues.add(values);
}
if (wallpaperItems != null) {
- values.put(PreviewColumns.WALLPAPER_PREVIEW,
+ values = createPreviewEntryBlob(id, PreviewColumns.KEY_WALLPAPER_PREVIEW,
getBitmapBlobJpg(wallpaperItems.wpPreview));
- values.put(PreviewColumns.WALLPAPER_THUMBNAIL,
+ themeValues.add(values);
+
+ values = createPreviewEntryBlob(id, PreviewColumns.KEY_WALLPAPER_THUMBNAIL,
getBitmapBlobPng(wallpaperItems.wpThumbnail));
- values.put(PreviewColumns.LOCK_WALLPAPER_PREVIEW,
+ themeValues.add(values);
+
+ values = createPreviewEntryBlob(id, PreviewColumns.KEY_LOCK_WALLPAPER_PREVIEW,
getBitmapBlobJpg(wallpaperItems.lsPreview));
- values.put(PreviewColumns.LOCK_WALLPAPER_THUMBNAIL,
+ themeValues.add(values);
+
+ values = createPreviewEntryBlob(id, PreviewColumns.KEY_LOCK_WALLPAPER_THUMBNAIL,
getBitmapBlobPng(wallpaperItems.lsThumbnail));
+ themeValues.add(values);
}
if (styleItems != null) {
- values.put(PreviewColumns.STYLE_THUMBNAIL, getBitmapBlobPng(styleItems.thumbnail));
- values.put(PreviewColumns.STYLE_PREVIEW, getBitmapBlobPng(styleItems.preview));
+ values = createPreviewEntryBlob(id, PreviewColumns.KEY_STYLE_THUMBNAIL,
+ getBitmapBlobPng(styleItems.thumbnail));
+ themeValues.add(values);
+
+ values = createPreviewEntryBlob(id, PreviewColumns.KEY_STYLE_PREVIEW,
+ getBitmapBlobPng(styleItems.preview));
+ themeValues.add(values);
}
if (bootAnim != null) {
- values.put(PreviewColumns.BOOTANIMATION_THUMBNAIL, getBitmapBlobPng(bootAnim));
+ values = createPreviewEntryBlob(id, PreviewColumns.KEY_BOOTANIMATION_THUMBNAIL,
+ getBitmapBlobPng(bootAnim));
+ themeValues.add(values);
}
- selection = PreviewColumns.THEME_ID + "=?";
- selectionArgs = new String[] { String.valueOf(id) };
- // Try an update first, if that returns 0 then we need to insert these values
- if (resolver.update(
- PreviewColumns.CONTENT_URI, values, selection, selectionArgs) == 0) {
- resolver.insert(PreviewColumns.CONTENT_URI, values);
+ if (!themeValues.isEmpty()) {
+ selection = PreviewColumns.THEME_ID + "=? AND " + PreviewColumns.COL_KEY + "=?";
+ for (ContentValues contentValues : themeValues) {
+ selectionArgs = new String[]{String.valueOf(id),
+ contentValues.getAsString(PreviewColumns.COL_KEY)};
+ // Try an update first, if that returns 0 then we need to insert these values
+ if (resolver.update(PreviewColumns.CONTENT_URI, contentValues, selection,
+ selectionArgs) == 0) {
+ resolver.insert(PreviewColumns.CONTENT_URI, contentValues);
+ }
+ }
}
}
}
+ private static ContentValues createPreviewEntryBlob(int id, String key, byte[] value) {
+ ContentValues values = new ContentValues();
+ values.put(PreviewColumns.THEME_ID, id);
+ values.put(PreviewColumns.COL_KEY, key);
+ values.put(PreviewColumns.COL_VALUE, value);
+
+ return values;
+ }
+
+ private static ContentValues createPreviewEntryInt(int id, String key, int value) {
+ ContentValues values = new ContentValues();
+ values.put(PreviewColumns.THEME_ID, id);
+ values.put(PreviewColumns.COL_KEY, key);
+ values.put(PreviewColumns.COL_VALUE, value);
+
+ return values;
+ }
+
private static byte[] getBitmapBlobPng(Bitmap bmp) {
return getBitmapBlob(bmp, CompressFormat.PNG, 100);
}
diff --git a/src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java b/src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java
index c3a966c..3d02621 100644
--- a/src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java
+++ b/src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java
@@ -31,12 +31,13 @@ import android.provider.ThemesContract;
import android.provider.ThemesContract.ThemesColumns;
import android.provider.ThemesContract.MixnMatchColumns;
import android.provider.ThemesContract.PreviewColumns;
+import android.provider.ThemesContract.LegacyPreviewColumns;
import android.util.Log;
public class ThemesOpenHelper extends SQLiteOpenHelper {
private static final String TAG = ThemesOpenHelper.class.getName();
- private static final int DATABASE_VERSION = 14;
+ private static final int DATABASE_VERSION = 15;
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";
@@ -115,6 +116,10 @@ public class ThemesOpenHelper extends SQLiteOpenHelper {
upgradeToVersion14(db);
oldVersion = 14;
}
+ if (oldVersion == 14) {
+ upgradeToVersion15(db);
+ oldVersion = 15;
+ }
if (oldVersion != DATABASE_VERSION) {
Log.e(TAG, "Recreating db because unknown database version: " + oldVersion);
dropTables(db);
@@ -248,7 +253,7 @@ public class ThemesOpenHelper extends SQLiteOpenHelper {
private void upgradeToVersion8(SQLiteDatabase db) {
String addNavBar = String.format("ALTER TABLE %s ADD COLUMN %s BLOB",
- PreviewsTable.TABLE_NAME, PreviewColumns.NAVBAR_BACKGROUND);
+ PreviewsTable.TABLE_NAME, LegacyPreviewColumns.NAVBAR_BACKGROUND);
db.execSQL(addNavBar);
// we need to update any existing themes with the new NAVBAR_BACKGROUND
@@ -403,6 +408,26 @@ public class ThemesOpenHelper extends SQLiteOpenHelper {
db.execSQL(sql);
}
+ private void upgradeToVersion15(SQLiteDatabase db) {
+ // Previews table upgraded
+ db.execSQL("DROP TABLE IF EXISTS " + PreviewsTable.TABLE_NAME);
+ db.execSQL(PreviewsTable.PREVIEWS_TABLE_CREATE);
+
+ // we need to update any existing themes
+ final String[] projection = { ThemesColumns.PKG_NAME };
+ final Cursor c = db.query(ThemesTable.TABLE_NAME, projection, null, null,
+ null, null, null);
+ if (c != null) {
+ while(c.moveToNext()) {
+ Intent intent = new Intent(mContext, PreviewGenerationService.class);
+ intent.setAction(PreviewGenerationService.ACTION_INSERT);
+ intent.putExtra(PreviewGenerationService.EXTRA_PKG_NAME, c.getString(0));
+ mContext.startService(intent);
+ }
+ c.close();
+ }
+ }
+
private void dropTables(SQLiteDatabase db) {
db.execSQL("DROP TABLE IF EXISTS " + ThemesTable.TABLE_NAME);
db.execSQL("DROP TABLE IF EXISTS " + MixnMatchTable.TABLE_NAME);
@@ -508,56 +533,34 @@ public class ThemesOpenHelper extends SQLiteOpenHelper {
"CREATE TABLE " + TABLE_NAME + " (" +
PreviewColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
PreviewColumns.THEME_ID + " INTEGER, " +
- PreviewColumns.STATUSBAR_BACKGROUND + " BLOB, " +
- PreviewColumns.STATUSBAR_BLUETOOTH_ICON + " BLOB, " +
- PreviewColumns.STATUSBAR_WIFI_ICON + " BLOB, " +
- PreviewColumns.STATUSBAR_SIGNAL_ICON + " BLOB, " +
- PreviewColumns.STATUSBAR_BATTERY_PORTRAIT + " BLOB, " +
- PreviewColumns.STATUSBAR_BATTERY_LANDSCAPE + " BLOB, " +
- PreviewColumns.STATUSBAR_BATTERY_CIRCLE + " BLOB, " +
- PreviewColumns.STATUSBAR_CLOCK_TEXT_COLOR + " INTEGER, " +
- PreviewColumns.STATUSBAR_WIFI_COMBO_MARGIN_END + " INTEGER, " +
- PreviewColumns.NAVBAR_BACKGROUND + " BLOB, " +
- PreviewColumns.NAVBAR_BACK_BUTTON + " BLOB, " +
- PreviewColumns.NAVBAR_HOME_BUTTON + " BLOB, " +
- PreviewColumns.NAVBAR_RECENT_BUTTON + " BLOB, " +
- PreviewColumns.ICON_PREVIEW_1 + " BLOB, " +
- PreviewColumns.ICON_PREVIEW_2 + " BLOB, " +
- PreviewColumns.ICON_PREVIEW_3 + " BLOB, " +
- PreviewColumns.ICON_PREVIEW_4 + " BLOB, " +
- PreviewColumns.STYLE_PREVIEW + " BLOB, " +
- PreviewColumns.STYLE_THUMBNAIL + " BLOB, " +
- PreviewColumns.WALLPAPER_PREVIEW + " BLOB, " +
- PreviewColumns.WALLPAPER_THUMBNAIL + " BLOB, " +
- PreviewColumns.LOCK_WALLPAPER_PREVIEW + " BLOB, " +
- PreviewColumns.LOCK_WALLPAPER_THUMBNAIL + " BLOB, " +
- PreviewColumns.BOOTANIMATION_THUMBNAIL + " BLOB, " +
+ PreviewColumns.COMPONENT_ID + " INTEGER DEFAULT 0, " +
+ PreviewColumns.COL_KEY + " TEXT," +
+ PreviewColumns.COL_VALUE + " TEXT, " +
"FOREIGN KEY (" + PreviewColumns.THEME_ID + ") REFERENCES " +
ThemesTable.TABLE_NAME + "(" + ThemesColumns._ID + ")" +
")";
- public static final String[] STATUS_BAR_PREVIEW_COLUMNS = {
- PreviewColumns.STATUSBAR_BACKGROUND,
- PreviewColumns.STATUSBAR_BLUETOOTH_ICON,
- PreviewColumns.STATUSBAR_WIFI_ICON,
- PreviewColumns.STATUSBAR_SIGNAL_ICON,
- PreviewColumns.STATUSBAR_BATTERY_PORTRAIT,
- PreviewColumns.STATUSBAR_BATTERY_LANDSCAPE,
- PreviewColumns.STATUSBAR_BATTERY_CIRCLE,
- PreviewColumns.STATUSBAR_WIFI_COMBO_MARGIN_END,
- PreviewColumns.STATUSBAR_CLOCK_TEXT_COLOR
+ public static final String[] STATUS_BAR_PREVIEW_KEYS = {
+ PreviewColumns.KEY_STATUSBAR_BACKGROUND,
+ PreviewColumns.KEY_STATUSBAR_BLUETOOTH_ICON,
+ PreviewColumns.KEY_STATUSBAR_WIFI_ICON,
+ PreviewColumns.KEY_STATUSBAR_SIGNAL_ICON,
+ PreviewColumns.KEY_STATUSBAR_BATTERY_PORTRAIT,
+ PreviewColumns.KEY_STATUSBAR_BATTERY_LANDSCAPE,
+ PreviewColumns.KEY_STATUSBAR_BATTERY_CIRCLE,
+ PreviewColumns.KEY_STATUSBAR_WIFI_COMBO_MARGIN_END,
+ PreviewColumns.KEY_STATUSBAR_CLOCK_TEXT_COLOR
};
- public static final String[] NAVIGATION_BAR_PREVIEW_COLUMNS = {
- PreviewColumns.NAVBAR_BACK_BUTTON,
- PreviewColumns.NAVBAR_HOME_BUTTON,
- PreviewColumns.NAVBAR_RECENT_BUTTON,
- PreviewColumns.NAVBAR_BACKGROUND
+ public static final String[] NAVIGATION_BAR_PREVIEW_KEYS = {
+ PreviewColumns.KEY_NAVBAR_BACK_BUTTON,
+ PreviewColumns.KEY_NAVBAR_HOME_BUTTON,
+ PreviewColumns.KEY_NAVBAR_RECENT_BUTTON,
+ PreviewColumns.KEY_NAVBAR_BACKGROUND
};
- public static final String[] ICON_PREVIEW_COLUMNS = {
- PreviewColumns.ICON_PREVIEW_1,
- PreviewColumns.ICON_PREVIEW_2,
- PreviewColumns.ICON_PREVIEW_3,
- PreviewColumns.ICON_PREVIEW_4
+ public static final String[] ICON_PREVIEW_KEYS = {
+ PreviewColumns.KEY_ICON_PREVIEW_1,
+ PreviewColumns.KEY_ICON_PREVIEW_2,
+ PreviewColumns.KEY_ICON_PREVIEW_3
};
public static void insertDefaults(Context context) {
diff --git a/src/org/cyanogenmod/themes/provider/ThemesProvider.java b/src/org/cyanogenmod/themes/provider/ThemesProvider.java
index 2d57f73..c9eecce 100644
--- a/src/org/cyanogenmod/themes/provider/ThemesProvider.java
+++ b/src/org/cyanogenmod/themes/provider/ThemesProvider.java
@@ -40,7 +40,6 @@ import android.provider.ThemesContract;
import android.provider.ThemesContract.MixnMatchColumns;
import android.provider.ThemesContract.PreviewColumns;
import android.provider.ThemesContract.ThemesColumns;
-import android.text.TextUtils;
import android.util.Log;
import org.cyanogenmod.themes.provider.ThemesOpenHelper.MixnMatchTable;
@@ -67,6 +66,7 @@ public class ThemesProvider extends ContentProvider {
private static final int PREVIEWS = 5;
private static final int PREVIEWS_ID = 6;
private static final int APPLIED_PREVIEWS = 7;
+ private static final int COMPONENTS_PREVIEWS = 8;
private static final UriMatcher sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
@@ -83,6 +83,7 @@ public class ThemesProvider extends ContentProvider {
sUriMatcher.addURI(ThemesContract.AUTHORITY, "previews/", PREVIEWS);
sUriMatcher.addURI(ThemesContract.AUTHORITY, "previews/#", PREVIEWS_ID);
sUriMatcher.addURI(ThemesContract.AUTHORITY, "applied_previews/", APPLIED_PREVIEWS);
+ sUriMatcher.addURI(ThemesContract.AUTHORITY, "components_previews/", COMPONENTS_PREVIEWS);
}
public static void setActiveTheme(Context context, String pkgName) {
@@ -203,7 +204,7 @@ public class ThemesProvider extends ContentProvider {
SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
SQLiteDatabase db = mDatabase.getReadableDatabase();
-
+ String groupBy = null;
/*
* Choose the table to query and a sort order based on the code returned for the incoming
* URI. Here, too, only the statements for table 3 are shown.
@@ -223,6 +224,10 @@ public class ThemesProvider extends ContentProvider {
queryBuilder.setTables(THEMES_MIXNMATCH_INNER_JOIN);
queryBuilder.appendWhere(MixnMatchColumns.COL_KEY + "=" + uri.getLastPathSegment());
break;
+ case COMPONENTS_PREVIEWS:
+ // COMPONENT_PREVIEWS has the same query behavior as PREVIEWS, however, it requires a
+ // groupBy parameter to be defined before doing so. Let it fall through after this.
+ groupBy = PreviewColumns.THEME_ID;
case PREVIEWS:
queryBuilder.setTables(THEMES_PREVIEWS_INNER_JOIN);
break;
@@ -236,7 +241,7 @@ public class ThemesProvider extends ContentProvider {
return null;
}
- Cursor cursor = queryBuilder.query(db, projection, selection, selectionArgs, null, null,
+ Cursor cursor = queryBuilder.query(db, projection, selection, selectionArgs, groupBy, null,
sortOrder);
if (cursor != null) {
cursor.setNotificationUri(getContext().getContentResolver(), uri);
@@ -331,36 +336,45 @@ public class ThemesProvider extends ContentProvider {
}
if (id >= 0) {
if (ThemesColumns.MODIFIES_STATUS_BAR.equals(component)) {
- sb.append(delimeter).append("(SELECT ");
- sb.append(TextUtils.join(",",
- PreviewsTable.STATUS_BAR_PREVIEW_COLUMNS));
- sb.append(String.format(" FROM previews WHERE %s=%d)",
- PreviewColumns.THEME_ID, id));
- delimeter = ",";
+ for (String previewKey : PreviewsTable.STATUS_BAR_PREVIEW_KEYS) {
+ sb.append(delimeter).append(String.format(
+ "(SELECT %s AS %s FROM previews WHERE %s=%d AND %s='%s')",
+ PreviewColumns.COL_VALUE, previewKey,
+ PreviewColumns.THEME_ID, id, PreviewColumns.COL_KEY,
+ previewKey));
+ delimeter = ",";
+ }
} else if (ThemesColumns.MODIFIES_ICONS.equals(component)) {
- sb.append(delimeter).append("(SELECT ");
- sb.append(TextUtils.join(",", PreviewsTable.ICON_PREVIEW_COLUMNS));
- sb.append(String.format(" FROM previews WHERE %s=%d)",
- PreviewColumns.THEME_ID, id));
- delimeter = ",";
+ for (String previewKey : PreviewsTable.ICON_PREVIEW_KEYS) {
+ sb.append(delimeter).append(String.format(
+ "(SELECT %s AS %s FROM previews WHERE %s=%d AND %s='%s')",
+ PreviewColumns.COL_VALUE, previewKey,
+ PreviewColumns.THEME_ID, id, PreviewColumns.COL_KEY,
+ previewKey));
+ delimeter = ",";
+ }
} else if (ThemesColumns.MODIFIES_LAUNCHER.equals(component)) {
- sb.append(delimeter).append("(SELECT ");
- sb.append(String.format("%s", PreviewColumns.WALLPAPER_PREVIEW));
- sb.append(String.format(" FROM previews WHERE %s=%d)",
- PreviewColumns.THEME_ID, id));
+ String previewKey = PreviewColumns.KEY_WALLPAPER_PREVIEW;
+ sb.append(delimeter).append(String.format(
+ "(SELECT %s AS %s FROM previews WHERE %s=%d AND %s='%s')",
+ PreviewColumns.COL_VALUE, previewKey, PreviewColumns.THEME_ID,
+ id, PreviewColumns.COL_KEY, previewKey));
delimeter = ",";
} else if (ThemesColumns.MODIFIES_NAVIGATION_BAR.equals(component)) {
- sb.append(delimeter).append("(SELECT ");
- sb.append(TextUtils.join(",",
- PreviewsTable.NAVIGATION_BAR_PREVIEW_COLUMNS));
- sb.append(String.format(" FROM previews WHERE %s=%d)",
- PreviewColumns.THEME_ID, id));
- delimeter = ",";
+ for (String previewKey : PreviewsTable.NAVIGATION_BAR_PREVIEW_KEYS) {
+ sb.append(delimeter).append(String.format(
+ "(SELECT %s AS %s FROM previews WHERE %s=%d AND %s='%s')",
+ PreviewColumns.COL_VALUE, previewKey,
+ PreviewColumns.THEME_ID, id, PreviewColumns.COL_KEY,
+ previewKey));
+ delimeter = ",";
+ }
} else if (ThemesColumns.MODIFIES_OVERLAYS.equals(component)) {
- sb.append(delimeter).append("(SELECT ");
- sb.append(PreviewColumns.STYLE_PREVIEW);
- sb.append(String.format(" FROM previews WHERE %s=%d)",
- PreviewColumns.THEME_ID, id));
+ String previewKey = PreviewColumns.KEY_STYLE_PREVIEW;
+ sb.append(delimeter).append(String.format(
+ "(SELECT %s AS %s FROM previews WHERE %s=%d AND %s='%s')",
+ PreviewColumns.COL_VALUE, previewKey, PreviewColumns.THEME_ID,
+ id, PreviewColumns.COL_KEY, previewKey));
delimeter = ",";
}
}