Add block/archive notification actions, and block swipe action

Closes #1575, closes #943
This commit is contained in:
Moez Bhatti
2020-02-29 19:54:40 -05:00
parent 853acaa42c
commit e2f4b92609
20 changed files with 201 additions and 40 deletions
@@ -36,7 +36,7 @@ class QkRealmMigration @Inject constructor(
) : RealmMigration {
companion object {
const val SchemaVersion: Long = 9
const val SchemaVersion: Long = 10
}
@SuppressLint("ApplySharedPref")
@@ -193,6 +193,36 @@ class QkRealmMigration @Inject constructor(
version++
}
if (version == 9L) {
val migrateNotificationAction = { pref: Int ->
when (pref) {
1 -> Preferences.NOTIFICATION_ACTION_READ
2 -> Preferences.NOTIFICATION_ACTION_REPLY
3 -> Preferences.NOTIFICATION_ACTION_CALL
4 -> Preferences.NOTIFICATION_ACTION_DELETE
else -> pref
}
}
val migrateSwipeAction = { pref: Int ->
when (pref) {
2 -> Preferences.SWIPE_ACTION_DELETE
3 -> Preferences.SWIPE_ACTION_CALL
4 -> Preferences.SWIPE_ACTION_READ
5 -> Preferences.SWIPE_ACTION_UNREAD
else -> pref
}
}
if (prefs.notifAction1.isSet) prefs.notifAction1.set(migrateNotificationAction(prefs.notifAction1.get()))
if (prefs.notifAction2.isSet) prefs.notifAction2.set(migrateNotificationAction(prefs.notifAction2.get()))
if (prefs.notifAction3.isSet) prefs.notifAction3.set(migrateNotificationAction(prefs.notifAction3.get()))
if (prefs.swipeLeft.isSet) prefs.swipeLeft.set(migrateSwipeAction(prefs.swipeLeft.get()))
if (prefs.swipeRight.isSet) prefs.swipeRight.set(migrateSwipeAction(prefs.swipeRight.get()))
version++
}
check(version >= newVersion) { "Migration missing from v$oldVersion to v$newVersion" }
}