Render user's actual workspace in ThemePicker preview (Part 3)
go/grid-migration-preview
With this change, we can see actual grid migration in wallpaper preview.
The approach here: we use a tmp table (favorites_preview) here specifically for this preview (to write off the migration results), and load from this tmp table workspace items if migration is necessary and successful. Otherwise, we load from the current workspace.
UPDATED: this change should be completely compatible with the new multi-db grid migration algorithm. Here is why
1. In LauncherPreviewRender#renderScreenShot, I added a check to decide which grid migration preview method we should call. Once v2 preview method is implemented, it should be integrated with other parts of this change perfectly (the reason will be mentioned below).
2. While we have multiple DBs, mOpenHelper in LauncherProvider always points to the current db we are using. Queries using CONTENT_URI is routed to whatever DB mOpenHelper points to, so it works perfectly to directly operate on CONTENT_URI even when we use multi-db underneath the hood.
3. With 1 and 2 mentioned, I believe in order for this preview change to support multi-db, we only need to implement the V2 grid migration algorithm. Because most of what we are doing in this change is wrapped in GridSizeMigrationTask, it's perfectly safeguarded.
Bug: 144052839
Change-Id: Ie6d6048d77326f96546c8a180a7cd8f15b47e4c4
diff --git a/src/com/android/launcher3/LauncherSettings.java b/src/com/android/launcher3/LauncherSettings.java
index 49831f6..216c221 100644
--- a/src/com/android/launcher3/LauncherSettings.java
+++ b/src/com/android/launcher3/LauncherSettings.java
@@ -93,15 +93,26 @@
public static final String TABLE_NAME = "favorites";
/**
- * Backup table created when when the favorites table is modified during grid migration
+ * Backup table created when the favorites table is modified during grid migration
*/
public static final String BACKUP_TABLE_NAME = "favorites_bakup";
/**
- * The content:// style URL for this table
+ * Temporary table used specifically for grid migrations during wallpaper preview
*/
- public static final Uri CONTENT_URI = Uri.parse("content://" +
- LauncherProvider.AUTHORITY + "/" + TABLE_NAME);
+ public static final String PREVIEW_TABLE_NAME = "favorites_preview";
+
+ /**
+ * The content:// style URL for "favorites" table
+ */
+ public static final Uri CONTENT_URI = Uri.parse("content://"
+ + LauncherProvider.AUTHORITY + "/" + TABLE_NAME);
+
+ /**
+ * The content:// style URL for "favorites_preview" table
+ */
+ public static final Uri PREVIEW_CONTENT_URI = Uri.parse("content://"
+ + LauncherProvider.AUTHORITY + "/" + PREVIEW_TABLE_NAME);
/**
* The content:// style URL for a given row, identified by its id.
@@ -111,8 +122,8 @@
* @return The unique content URL for the specified row.
*/
public static Uri getContentUri(int id) {
- return Uri.parse("content://" + LauncherProvider.AUTHORITY +
- "/" + TABLE_NAME + "/" + id);
+ return Uri.parse("content://" + LauncherProvider.AUTHORITY
+ + "/" + TABLE_NAME + "/" + id);
}
/**