diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/MyWidgetProvider.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/MyWidgetProvider.kt index 261b566c..965456b3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/MyWidgetProvider.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/MyWidgetProvider.kt @@ -48,4 +48,13 @@ class MyWidgetProvider : AppWidgetProvider() { } }.start() } + + override fun onDeleted(context: Context, appWidgetIds: IntArray) { + super.onDeleted(context, appWidgetIds) + Thread { + appWidgetIds.forEach { + context.widgetsDB.deleteWidgetId(it) + } + }.start() + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/interfaces/WidgetsDao.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/interfaces/WidgetsDao.kt index 33d1a5b4..c3a6f9cc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/interfaces/WidgetsDao.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/interfaces/WidgetsDao.kt @@ -16,4 +16,7 @@ interface WidgetsDao { @Query("DELETE FROM widgets WHERE note_id = :noteId") fun deleteNoteWidgets(noteId: Long) + + @Query("DELETE FROM widgets WHERE widget_id = :widgetId") + fun deleteWidgetId(widgetId: Int) } diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/models/Widget.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/models/Widget.kt index 9578cb35..59b733ab 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/models/Widget.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/models/Widget.kt @@ -7,6 +7,6 @@ import androidx.room.PrimaryKey @Entity(tableName = "widgets", indices = [(Index(value = ["widget_id"], unique = true))]) data class Widget( - @PrimaryKey(autoGenerate = true) var id: Int?, + @PrimaryKey(autoGenerate = true) var id: Long?, @ColumnInfo(name = "widget_id") var widgetId: Int, @ColumnInfo(name = "note_id") var noteId: Long)