Merge pull request #93 from esensar/fix/67-direct-call-widget-migration

Add migration for changes made to shortcuts
This commit is contained in:
Tibor Kaputa 2023-07-26 21:03:20 +02:00 committed by GitHub
commit 8d6c839c15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 6 additions and 14 deletions

View File

@ -146,7 +146,6 @@ class MainActivity : SimpleActivity(), FlingListener {
ITEM_TYPE_SHORTCUT, ITEM_TYPE_SHORTCUT,
"", "",
-1, -1,
"",
shortcutId, shortcutId,
icon.toBitmap(), icon.toBitmap(),
false, false,
@ -780,7 +779,6 @@ class MainActivity : SimpleActivity(), FlingListener {
"", "",
-1, -1,
"", "",
"",
null, null,
true true
) )
@ -807,7 +805,6 @@ class MainActivity : SimpleActivity(), FlingListener {
"", "",
-1, -1,
"", "",
"",
null, null,
true true
) )
@ -836,7 +833,6 @@ class MainActivity : SimpleActivity(), FlingListener {
"", "",
-1, -1,
"", "",
"",
null, null,
true true
) )
@ -864,7 +860,6 @@ class MainActivity : SimpleActivity(), FlingListener {
"", "",
-1, -1,
"", "",
"",
null, null,
true true
) )
@ -894,7 +889,6 @@ class MainActivity : SimpleActivity(), FlingListener {
"", "",
-1, -1,
"", "",
"",
null, null,
true true
) )

View File

@ -68,9 +68,11 @@ abstract class AppsDatabase : RoomDatabase() {
private val MIGRATION_4_5 = object : Migration(4, 5) { private val MIGRATION_4_5 = object : Migration(4, 5) {
override fun migrate(database: SupportSQLiteDatabase) { override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE home_screen_grid_items ADD COLUMN page INTEGER NOT NULL DEFAULT 0") database.execSQL("CREATE TABLE `home_screen_grid_items_new` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `left` INTEGER NOT NULL, `top` INTEGER NOT NULL, `right` INTEGER NOT NULL, `bottom` INTEGER NOT NULL, `page` INTEGER NOT NULL, `package_name` TEXT NOT NULL, `activity_name` TEXT NOT NULL, `title` TEXT NOT NULL, `type` INTEGER NOT NULL, `class_name` TEXT NOT NULL, `widget_id` INTEGER NOT NULL, `shortcut_id` TEXT NOT NULL, `icon` BLOB, `docked` INTEGER NOT NULL DEFAULT 0)")
database.execSQL("ALTER TABLE home_screen_grid_items ADD COLUMN docked INTEGER NOT NULL DEFAULT 0") database.execSQL("INSERT INTO `home_screen_grid_items_new` (`id`, `left`, `top`, `right`, `bottom`, `page`, `package_name`, `activity_name`, `title`, `type`, `class_name`, `widget_id`, `shortcut_id`, `icon`, `docked`) SELECT `id`, `left`, `top`, `right`, `bottom`, 0 as `page`, `package_name`, `activity_name`, `title`, `type`, `class_name`, `widget_id`, `shortcut_id`, `icon`, CASE WHEN `type` != 1 AND `top` = 5 THEN 1 ELSE 0 END AS `docked` FROM `home_screen_grid_items` WHERE `intent` IS NULL OR `intent` = ''")
database.execSQL("UPDATE home_screen_grid_items SET docked = 1 WHERE page = 0 AND type != 1 AND top = 5") database.execSQL("DROP TABLE `home_screen_grid_items`")
database.execSQL("ALTER TABLE `home_screen_grid_items_new` RENAME TO `home_screen_grid_items`")
database.execSQL("CREATE UNIQUE INDEX `index_home_screen_grid_items_id` ON `home_screen_grid_items` (`id`)")
} }
} }
} }

View File

@ -206,7 +206,6 @@ class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
"", "",
-1, -1,
"", "",
"",
null, null,
false, false,
appLauncher.drawable appLauncher.drawable

View File

@ -264,7 +264,6 @@ class WidgetsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
appWidget.className, appWidget.className,
-1, -1,
"", "",
"",
null, null,
false, false,
appWidget.widgetPreviewImage, appWidget.widgetPreviewImage,

View File

@ -22,7 +22,6 @@ data class HomeScreenGridItem(
@ColumnInfo(name = "type") var type: Int, @ColumnInfo(name = "type") var type: Int,
@ColumnInfo(name = "class_name") var className: String, @ColumnInfo(name = "class_name") var className: String,
@ColumnInfo(name = "widget_id") var widgetId: Int, @ColumnInfo(name = "widget_id") var widgetId: Int,
@ColumnInfo(name = "intent") var intent: String, // used at static and dynamic shortcuts on click
@ColumnInfo(name = "shortcut_id") var shortcutId: String, // used at pinned shortcuts at startLauncher call @ColumnInfo(name = "shortcut_id") var shortcutId: String, // used at pinned shortcuts at startLauncher call
@ColumnInfo(name = "icon") var icon: Bitmap? = null, // store images of pinned shortcuts, those cannot be retrieved after creating @ColumnInfo(name = "icon") var icon: Bitmap? = null, // store images of pinned shortcuts, those cannot be retrieved after creating
@ColumnInfo(name = "docked") var docked: Boolean = false, // special flag, meaning that page, top and bottom don't matter for this item, it is always at the bottom of the screen @ColumnInfo(name = "docked") var docked: Boolean = false, // special flag, meaning that page, top and bottom don't matter for this item, it is always at the bottom of the screen
@ -33,7 +32,7 @@ data class HomeScreenGridItem(
@Ignore var widthCells: Int = 1, @Ignore var widthCells: Int = 1,
@Ignore var heightCells: Int = 1 @Ignore var heightCells: Int = 1
) { ) {
constructor() : this(null, -1, -1, -1, -1, 0, "", "", "", ITEM_TYPE_ICON, "", -1, "", "", null, false, null, null, null, 1, 1) constructor() : this(null, -1, -1, -1, -1, 0, "", "", "", ITEM_TYPE_ICON, "", -1, "", null, false, null, null, null, 1, 1)
fun getWidthInCells() = if (right == -1 || left == -1) { fun getWidthInCells() = if (right == -1 || left == -1) {
widthCells widthCells

View File

@ -414,7 +414,6 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
"", "",
-1, -1,
"", "",
"",
draggedItem!!.icon, draggedItem!!.icon,
yIndex == rowCount - 1, yIndex == rowCount - 1,
draggedItem!!.drawable, draggedItem!!.drawable,