summaryrefslogtreecommitdiffstats
path: root/src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java')
-rw-r--r--src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java95
1 files changed, 49 insertions, 46 deletions
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) {