mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-12-18 06:32:08 +03:00
primary key
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
e926feabc7
commit
3c20251047
9 changed files with 164 additions and 10 deletions
|
@ -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')"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,10 +22,11 @@ package com.nextcloud.talk.arbitrarystorage
|
||||||
|
|
||||||
import com.nextcloud.talk.data.storage.ArbitraryStoragesRepository
|
import com.nextcloud.talk.data.storage.ArbitraryStoragesRepository
|
||||||
import com.nextcloud.talk.data.storage.model.ArbitraryStorage
|
import com.nextcloud.talk.data.storage.model.ArbitraryStorage
|
||||||
|
import com.nextcloud.talk.data.storage.model.ArbitraryStorageEntity
|
||||||
import io.reactivex.Maybe
|
import io.reactivex.Maybe
|
||||||
|
|
||||||
class ArbitraryStorageManager(private val arbitraryStoragesRepository: ArbitraryStoragesRepository) {
|
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))
|
arbitraryStoragesRepository.saveArbitraryStorage(ArbitraryStorage(accountIdentifier, key, objectString, value))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,4 +37,8 @@ class ArbitraryStorageManager(private val arbitraryStoragesRepository: Arbitrary
|
||||||
fun deleteAllEntriesForAccountIdentifier(accountIdentifier: Long): Int {
|
fun deleteAllEntriesForAccountIdentifier(accountIdentifier: Long): Int {
|
||||||
return arbitraryStoragesRepository.deleteArbitraryStorage(accountIdentifier)
|
return arbitraryStoragesRepository.deleteArbitraryStorage(accountIdentifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getAll() : Maybe<List<ArbitraryStorageEntity>> {
|
||||||
|
return arbitraryStoragesRepository.getAll()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ package com.nextcloud.talk.data.source.local
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import androidx.room.AutoMigration
|
||||||
import androidx.room.Database
|
import androidx.room.Database
|
||||||
import androidx.room.Room
|
import androidx.room.Room
|
||||||
import androidx.room.RoomDatabase
|
import androidx.room.RoomDatabase
|
||||||
|
@ -45,7 +46,7 @@ import java.util.Locale
|
||||||
|
|
||||||
@Database(
|
@Database(
|
||||||
entities = [UserEntity::class, ArbitraryStorageEntity::class],
|
entities = [UserEntity::class, ArbitraryStorageEntity::class],
|
||||||
version = 8,
|
version = 9,
|
||||||
exportSchema = true
|
exportSchema = true
|
||||||
)
|
)
|
||||||
@TypeConverters(
|
@TypeConverters(
|
||||||
|
|
|
@ -41,6 +41,12 @@ abstract class ArbitraryStoragesDao {
|
||||||
objectString: String
|
objectString: String
|
||||||
): Maybe<ArbitraryStorageEntity>
|
): Maybe<ArbitraryStorageEntity>
|
||||||
|
|
||||||
|
|
||||||
|
@Query(
|
||||||
|
"SELECT * FROM ArbitraryStorage"
|
||||||
|
)
|
||||||
|
abstract fun getAll() : Maybe<List<ArbitraryStorageEntity>>
|
||||||
|
|
||||||
@Query("DELETE FROM ArbitraryStorage WHERE accountIdentifier = :accountIdentifier")
|
@Query("DELETE FROM ArbitraryStorage WHERE accountIdentifier = :accountIdentifier")
|
||||||
abstract fun deleteArbitraryStorage(accountIdentifier: Long): Int
|
abstract fun deleteArbitraryStorage(accountIdentifier: Long): Int
|
||||||
|
|
||||||
|
|
|
@ -21,10 +21,12 @@
|
||||||
package com.nextcloud.talk.data.storage
|
package com.nextcloud.talk.data.storage
|
||||||
|
|
||||||
import com.nextcloud.talk.data.storage.model.ArbitraryStorage
|
import com.nextcloud.talk.data.storage.model.ArbitraryStorage
|
||||||
|
import com.nextcloud.talk.data.storage.model.ArbitraryStorageEntity
|
||||||
import io.reactivex.Maybe
|
import io.reactivex.Maybe
|
||||||
|
|
||||||
interface ArbitraryStoragesRepository {
|
interface ArbitraryStoragesRepository {
|
||||||
fun getStorageSetting(accountIdentifier: Long, key: String, objectString: String): Maybe<ArbitraryStorage>
|
fun getStorageSetting(accountIdentifier: Long, key: String, objectString: String): Maybe<ArbitraryStorage>
|
||||||
fun deleteArbitraryStorage(accountIdentifier: Long): Int
|
fun deleteArbitraryStorage(accountIdentifier: Long): Int
|
||||||
fun saveArbitraryStorage(arbitraryStorage: ArbitraryStorage): Long
|
fun saveArbitraryStorage(arbitraryStorage: ArbitraryStorage): Long
|
||||||
|
fun getAll(): Maybe<List<ArbitraryStorageEntity>>
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
package com.nextcloud.talk.data.storage
|
package com.nextcloud.talk.data.storage
|
||||||
|
|
||||||
import com.nextcloud.talk.data.storage.model.ArbitraryStorage
|
import com.nextcloud.talk.data.storage.model.ArbitraryStorage
|
||||||
|
import com.nextcloud.talk.data.storage.model.ArbitraryStorageEntity
|
||||||
import io.reactivex.Maybe
|
import io.reactivex.Maybe
|
||||||
|
|
||||||
class ArbitraryStoragesRepositoryImpl(private val arbitraryStoragesDao: ArbitraryStoragesDao) :
|
class ArbitraryStoragesRepositoryImpl(private val arbitraryStoragesDao: ArbitraryStoragesDao) :
|
||||||
|
@ -35,6 +36,10 @@ class ArbitraryStoragesRepositoryImpl(private val arbitraryStoragesDao: Arbitrar
|
||||||
.map { ArbitraryStorageMapper.toModel(it) }
|
.map { ArbitraryStorageMapper.toModel(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getAll(): Maybe<List<ArbitraryStorageEntity>> {
|
||||||
|
return arbitraryStoragesDao.getAll()
|
||||||
|
}
|
||||||
|
|
||||||
override fun deleteArbitraryStorage(accountIdentifier: Long): Int {
|
override fun deleteArbitraryStorage(accountIdentifier: Long): Int {
|
||||||
return arbitraryStoragesDao.deleteArbitraryStorage(accountIdentifier)
|
return arbitraryStoragesDao.deleteArbitraryStorage(accountIdentifier)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,8 @@ import kotlinx.parcelize.Parcelize
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
data class ArbitraryStorage(
|
data class ArbitraryStorage(
|
||||||
var accountIdentifier: Long = 0,
|
var accountIdentifier: Long,
|
||||||
var key: String? = null,
|
var key: String,
|
||||||
var storageObject: String? = null,
|
var storageObject: String? = null,
|
||||||
var value: String? = null
|
var value: String? = null
|
||||||
) : Parcelable
|
) : Parcelable
|
||||||
|
|
|
@ -27,14 +27,13 @@ import androidx.room.PrimaryKey
|
||||||
import kotlinx.parcelize.Parcelize
|
import kotlinx.parcelize.Parcelize
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
@Entity(tableName = "ArbitraryStorage")
|
@Entity(tableName = "ArbitraryStorage", primaryKeys = ["accountIdentifier", "key"])
|
||||||
data class ArbitraryStorageEntity(
|
data class ArbitraryStorageEntity(
|
||||||
@PrimaryKey
|
|
||||||
@ColumnInfo(name = "accountIdentifier")
|
@ColumnInfo(name = "accountIdentifier")
|
||||||
var accountIdentifier: Long = 0,
|
var accountIdentifier: Long = 0,
|
||||||
|
|
||||||
@ColumnInfo(name = "key")
|
@ColumnInfo(name = "key")
|
||||||
var key: String? = null,
|
var key: String = "",
|
||||||
|
|
||||||
@ColumnInfo(name = "object")
|
@ColumnInfo(name = "object")
|
||||||
var storageObject: String? = null,
|
var storageObject: String? = null,
|
||||||
|
|
|
@ -125,9 +125,6 @@ class FilterConversationFragment(
|
||||||
arbitraryStorageManager.storeStorageSetting(accountId, MENTION, mentionValue.toString(), "")
|
arbitraryStorageManager.storeStorageSetting(accountId, MENTION, mentionValue.toString(), "")
|
||||||
arbitraryStorageManager.storeStorageSetting(accountId, UNREAD, unreadValue.toString(), "")
|
arbitraryStorageManager.storeStorageSetting(accountId, UNREAD, unreadValue.toString(), "")
|
||||||
|
|
||||||
val m = arbitraryStorageManager.getStorageSetting(accountId, MENTION, "")
|
|
||||||
val u = arbitraryStorageManager.getStorageSetting(accountId, UNREAD, "")
|
|
||||||
|
|
||||||
conversationsList.filterConversation()
|
conversationsList.filterConversation()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue