diff --git a/app/schemas/com.nextcloud.talk.data.source.local.TalkDatabase/9.json b/app/schemas/com.nextcloud.talk.data.source.local.TalkDatabase/9.json new file mode 100644 index 000000000..4b966b37e --- /dev/null +++ b/app/schemas/com.nextcloud.talk.data.source.local.TalkDatabase/9.json @@ -0,0 +1,139 @@ +{ + "formatVersion": 1, + "database": { + "version": 9, + "identityHash": "666fcc4bbbdf3ff121b8f1ace8fcbcb8", + "entities": [ + { + "tableName": "User", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `userId` TEXT, `username` TEXT, `baseUrl` TEXT, `token` TEXT, `displayName` TEXT, `pushConfigurationState` TEXT, `capabilities` TEXT, `clientCertificate` TEXT, `externalSignalingServer` TEXT, `current` INTEGER NOT NULL, `scheduledForDeletion` INTEGER NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "userId", + "columnName": "userId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "username", + "columnName": "username", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "baseUrl", + "columnName": "baseUrl", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "token", + "columnName": "token", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "displayName", + "columnName": "displayName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "pushConfigurationState", + "columnName": "pushConfigurationState", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "capabilities", + "columnName": "capabilities", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "clientCertificate", + "columnName": "clientCertificate", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "externalSignalingServer", + "columnName": "externalSignalingServer", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "current", + "columnName": "current", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "scheduledForDeletion", + "columnName": "scheduledForDeletion", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "ArbitraryStorage", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`accountIdentifier` INTEGER NOT NULL, `key` TEXT NOT NULL, `object` TEXT, `value` TEXT, PRIMARY KEY(`accountIdentifier`, `key`))", + "fields": [ + { + "fieldPath": "accountIdentifier", + "columnName": "accountIdentifier", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "key", + "columnName": "key", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "storageObject", + "columnName": "object", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "value", + "columnName": "value", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "accountIdentifier", + "key" + ] + }, + "indices": [], + "foreignKeys": [] + } + ], + "views": [], + "setupQueries": [ + "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '666fcc4bbbdf3ff121b8f1ace8fcbcb8')" + ] + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nextcloud/talk/arbitrarystorage/ArbitraryStorageManager.kt b/app/src/main/java/com/nextcloud/talk/arbitrarystorage/ArbitraryStorageManager.kt index 7ef4c5242..1ca21c094 100644 --- a/app/src/main/java/com/nextcloud/talk/arbitrarystorage/ArbitraryStorageManager.kt +++ b/app/src/main/java/com/nextcloud/talk/arbitrarystorage/ArbitraryStorageManager.kt @@ -22,10 +22,11 @@ package com.nextcloud.talk.arbitrarystorage import com.nextcloud.talk.data.storage.ArbitraryStoragesRepository import com.nextcloud.talk.data.storage.model.ArbitraryStorage +import com.nextcloud.talk.data.storage.model.ArbitraryStorageEntity import io.reactivex.Maybe class ArbitraryStorageManager(private val arbitraryStoragesRepository: ArbitraryStoragesRepository) { - fun storeStorageSetting(accountIdentifier: Long, key: String?, value: String?, objectString: String?) { + fun storeStorageSetting(accountIdentifier: Long, key: String, value: String?, objectString: String?) { arbitraryStoragesRepository.saveArbitraryStorage(ArbitraryStorage(accountIdentifier, key, objectString, value)) } @@ -36,4 +37,8 @@ class ArbitraryStorageManager(private val arbitraryStoragesRepository: Arbitrary fun deleteAllEntriesForAccountIdentifier(accountIdentifier: Long): Int { return arbitraryStoragesRepository.deleteArbitraryStorage(accountIdentifier) } + + fun getAll() : Maybe> { + return arbitraryStoragesRepository.getAll() + } } diff --git a/app/src/main/java/com/nextcloud/talk/data/source/local/TalkDatabase.kt b/app/src/main/java/com/nextcloud/talk/data/source/local/TalkDatabase.kt index de64a74d3..7ab112075 100644 --- a/app/src/main/java/com/nextcloud/talk/data/source/local/TalkDatabase.kt +++ b/app/src/main/java/com/nextcloud/talk/data/source/local/TalkDatabase.kt @@ -22,6 +22,7 @@ package com.nextcloud.talk.data.source.local import android.content.Context import android.util.Log +import androidx.room.AutoMigration import androidx.room.Database import androidx.room.Room import androidx.room.RoomDatabase @@ -45,7 +46,7 @@ import java.util.Locale @Database( entities = [UserEntity::class, ArbitraryStorageEntity::class], - version = 8, + version = 9, exportSchema = true ) @TypeConverters( diff --git a/app/src/main/java/com/nextcloud/talk/data/storage/ArbitraryStoragesDao.kt b/app/src/main/java/com/nextcloud/talk/data/storage/ArbitraryStoragesDao.kt index a5d0d08b9..9e728cf35 100644 --- a/app/src/main/java/com/nextcloud/talk/data/storage/ArbitraryStoragesDao.kt +++ b/app/src/main/java/com/nextcloud/talk/data/storage/ArbitraryStoragesDao.kt @@ -41,6 +41,12 @@ abstract class ArbitraryStoragesDao { objectString: String ): Maybe + + @Query( + "SELECT * FROM ArbitraryStorage" + ) + abstract fun getAll() : Maybe> + @Query("DELETE FROM ArbitraryStorage WHERE accountIdentifier = :accountIdentifier") abstract fun deleteArbitraryStorage(accountIdentifier: Long): Int diff --git a/app/src/main/java/com/nextcloud/talk/data/storage/ArbitraryStoragesRepository.kt b/app/src/main/java/com/nextcloud/talk/data/storage/ArbitraryStoragesRepository.kt index 8086c4d2a..ea5c3c9f8 100644 --- a/app/src/main/java/com/nextcloud/talk/data/storage/ArbitraryStoragesRepository.kt +++ b/app/src/main/java/com/nextcloud/talk/data/storage/ArbitraryStoragesRepository.kt @@ -21,10 +21,12 @@ package com.nextcloud.talk.data.storage import com.nextcloud.talk.data.storage.model.ArbitraryStorage +import com.nextcloud.talk.data.storage.model.ArbitraryStorageEntity import io.reactivex.Maybe interface ArbitraryStoragesRepository { fun getStorageSetting(accountIdentifier: Long, key: String, objectString: String): Maybe fun deleteArbitraryStorage(accountIdentifier: Long): Int fun saveArbitraryStorage(arbitraryStorage: ArbitraryStorage): Long + fun getAll(): Maybe> } diff --git a/app/src/main/java/com/nextcloud/talk/data/storage/ArbitraryStoragesRepositoryImpl.kt b/app/src/main/java/com/nextcloud/talk/data/storage/ArbitraryStoragesRepositoryImpl.kt index 9f04bfbd4..6eb07cf76 100644 --- a/app/src/main/java/com/nextcloud/talk/data/storage/ArbitraryStoragesRepositoryImpl.kt +++ b/app/src/main/java/com/nextcloud/talk/data/storage/ArbitraryStoragesRepositoryImpl.kt @@ -21,6 +21,7 @@ package com.nextcloud.talk.data.storage import com.nextcloud.talk.data.storage.model.ArbitraryStorage +import com.nextcloud.talk.data.storage.model.ArbitraryStorageEntity import io.reactivex.Maybe class ArbitraryStoragesRepositoryImpl(private val arbitraryStoragesDao: ArbitraryStoragesDao) : @@ -35,6 +36,10 @@ class ArbitraryStoragesRepositoryImpl(private val arbitraryStoragesDao: Arbitrar .map { ArbitraryStorageMapper.toModel(it) } } + override fun getAll(): Maybe> { + return arbitraryStoragesDao.getAll() + } + override fun deleteArbitraryStorage(accountIdentifier: Long): Int { return arbitraryStoragesDao.deleteArbitraryStorage(accountIdentifier) } diff --git a/app/src/main/java/com/nextcloud/talk/data/storage/model/ArbitraryStorage.kt b/app/src/main/java/com/nextcloud/talk/data/storage/model/ArbitraryStorage.kt index baf5e9678..56b93b38b 100644 --- a/app/src/main/java/com/nextcloud/talk/data/storage/model/ArbitraryStorage.kt +++ b/app/src/main/java/com/nextcloud/talk/data/storage/model/ArbitraryStorage.kt @@ -25,8 +25,8 @@ import kotlinx.parcelize.Parcelize @Parcelize data class ArbitraryStorage( - var accountIdentifier: Long = 0, - var key: String? = null, + var accountIdentifier: Long, + var key: String, var storageObject: String? = null, var value: String? = null ) : Parcelable diff --git a/app/src/main/java/com/nextcloud/talk/data/storage/model/ArbitraryStorageEntity.kt b/app/src/main/java/com/nextcloud/talk/data/storage/model/ArbitraryStorageEntity.kt index 45e66e1f4..6f09eb818 100644 --- a/app/src/main/java/com/nextcloud/talk/data/storage/model/ArbitraryStorageEntity.kt +++ b/app/src/main/java/com/nextcloud/talk/data/storage/model/ArbitraryStorageEntity.kt @@ -27,14 +27,13 @@ import androidx.room.PrimaryKey import kotlinx.parcelize.Parcelize @Parcelize -@Entity(tableName = "ArbitraryStorage") +@Entity(tableName = "ArbitraryStorage", primaryKeys = ["accountIdentifier", "key"]) data class ArbitraryStorageEntity( - @PrimaryKey @ColumnInfo(name = "accountIdentifier") var accountIdentifier: Long = 0, @ColumnInfo(name = "key") - var key: String? = null, + var key: String = "", @ColumnInfo(name = "object") var storageObject: String? = null, diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/FilterConversationFragment.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/FilterConversationFragment.kt index 5906a1c28..062116aa8 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/FilterConversationFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/FilterConversationFragment.kt @@ -125,9 +125,6 @@ class FilterConversationFragment( arbitraryStorageManager.storeStorageSetting(accountId, MENTION, mentionValue.toString(), "") arbitraryStorageManager.storeStorageSetting(accountId, UNREAD, unreadValue.toString(), "") - val m = arbitraryStorageManager.getStorageSetting(accountId, MENTION, "") - val u = arbitraryStorageManager.getStorageSetting(accountId, UNREAD, "") - conversationsList.filterConversation() }