From 402518d36b0ab06e6b7b5d84a03077f8b4ab9356 Mon Sep 17 00:00:00 2001 From: Felipe Martinez Date: Sat, 23 Mar 2024 00:27:05 +0100 Subject: [PATCH] Remove watch send notifications permission --- .../12.json | 13 +- .../13.json | 135 ++++++++++++++++++ .../pipe01/pinepartner/data/AppDatabase.kt | 7 +- .../java/net/pipe01/pinepartner/data/Watch.kt | 1 - .../net/pipe01/pinepartner/data/WatchDao.kt | 6 - .../pinepartner/pages/devices/DevicePage.kt | 14 -- 6 files changed, 139 insertions(+), 37 deletions(-) create mode 100644 app/schemas/net.pipe01.pinepartner.data.AppDatabase/13.json diff --git a/app/schemas/net.pipe01.pinepartner.data.AppDatabase/12.json b/app/schemas/net.pipe01.pinepartner.data.AppDatabase/12.json index 5e4b5d9..d6f7442 100644 --- a/app/schemas/net.pipe01.pinepartner.data.AppDatabase/12.json +++ b/app/schemas/net.pipe01.pinepartner.data.AppDatabase/12.json @@ -2,11 +2,11 @@ "formatVersion": 1, "database": { "version": 12, - "identityHash": "b815ce88c3ea8236624d0101b912ad79", + "identityHash": "7373061d995feb6177a83d4ddeb71134", "entities": [ { "tableName": "Watch", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`address` TEXT NOT NULL, `name` TEXT NOT NULL, `autoConnect` INTEGER NOT NULL DEFAULT true, `sendNotifications` INTEGER NOT NULL DEFAULT false, PRIMARY KEY(`address`))", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`address` TEXT NOT NULL, `name` TEXT NOT NULL, `autoConnect` INTEGER NOT NULL DEFAULT true, PRIMARY KEY(`address`))", "fields": [ { "fieldPath": "address", @@ -26,13 +26,6 @@ "affinity": "INTEGER", "notNull": true, "defaultValue": "true" - }, - { - "fieldPath": "sendNotifications", - "columnName": "sendNotifications", - "affinity": "INTEGER", - "notNull": true, - "defaultValue": "false" } ], "primaryKey": { @@ -136,7 +129,7 @@ "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, 'b815ce88c3ea8236624d0101b912ad79')" + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '7373061d995feb6177a83d4ddeb71134')" ] } } \ No newline at end of file diff --git a/app/schemas/net.pipe01.pinepartner.data.AppDatabase/13.json b/app/schemas/net.pipe01.pinepartner.data.AppDatabase/13.json new file mode 100644 index 0000000..9e11f83 --- /dev/null +++ b/app/schemas/net.pipe01.pinepartner.data.AppDatabase/13.json @@ -0,0 +1,135 @@ +{ + "formatVersion": 1, + "database": { + "version": 13, + "identityHash": "7373061d995feb6177a83d4ddeb71134", + "entities": [ + { + "tableName": "Watch", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`address` TEXT NOT NULL, `name` TEXT NOT NULL, `autoConnect` INTEGER NOT NULL DEFAULT true, PRIMARY KEY(`address`))", + "fields": [ + { + "fieldPath": "address", + "columnName": "address", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "autoConnect", + "columnName": "autoConnect", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "true" + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "address" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "AllowedNotifApp", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`packageName` TEXT NOT NULL, PRIMARY KEY(`packageName`))", + "fields": [ + { + "fieldPath": "packageName", + "columnName": "packageName", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "packageName" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "Plugin", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `name` TEXT NOT NULL, `description` TEXT, `author` TEXT, `sourceCode` TEXT NOT NULL, `checksum` TEXT NOT NULL, `permissions` TEXT NOT NULL, `downloadUrl` TEXT, `enabled` INTEGER NOT NULL, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "description", + "columnName": "description", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "author", + "columnName": "author", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "sourceCode", + "columnName": "sourceCode", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "checksum", + "columnName": "checksum", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "permissions", + "columnName": "permissions", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "downloadUrl", + "columnName": "downloadUrl", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "enabled", + "columnName": "enabled", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "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, '7373061d995feb6177a83d4ddeb71134')" + ] + } +} \ No newline at end of file diff --git a/app/src/main/java/net/pipe01/pinepartner/data/AppDatabase.kt b/app/src/main/java/net/pipe01/pinepartner/data/AppDatabase.kt index 0b8e32f..3329eb0 100644 --- a/app/src/main/java/net/pipe01/pinepartner/data/AppDatabase.kt +++ b/app/src/main/java/net/pipe01/pinepartner/data/AppDatabase.kt @@ -1,7 +1,6 @@ package net.pipe01.pinepartner.data import android.content.Context -import androidx.room.AutoMigration import androidx.room.Database import androidx.room.Room import androidx.room.RoomDatabase @@ -13,12 +12,8 @@ import androidx.room.TypeConverters AllowedNotifApp::class, Plugin::class, ], - version = 12, + version = 13, exportSchema = true, - autoMigrations = [ - AutoMigration(from = 9, to = 10), - AutoMigration(from = 10, to = 11), - ], ) @TypeConverters(Converters::class) abstract class AppDatabase : RoomDatabase() { diff --git a/app/src/main/java/net/pipe01/pinepartner/data/Watch.kt b/app/src/main/java/net/pipe01/pinepartner/data/Watch.kt index 7840207..2177d9e 100644 --- a/app/src/main/java/net/pipe01/pinepartner/data/Watch.kt +++ b/app/src/main/java/net/pipe01/pinepartner/data/Watch.kt @@ -9,5 +9,4 @@ data class Watch( @PrimaryKey val address: String, val name: String, @ColumnInfo(defaultValue = "true") val autoConnect: Boolean, - @ColumnInfo(defaultValue = "false") val sendNotifications: Boolean, ) diff --git a/app/src/main/java/net/pipe01/pinepartner/data/WatchDao.kt b/app/src/main/java/net/pipe01/pinepartner/data/WatchDao.kt index c13f5ef..c6031d7 100644 --- a/app/src/main/java/net/pipe01/pinepartner/data/WatchDao.kt +++ b/app/src/main/java/net/pipe01/pinepartner/data/WatchDao.kt @@ -20,12 +20,6 @@ interface WatchDao { @Query("DELETE FROM watch WHERE address = :address") suspend fun delete(address: String) - @Query("SELECT sendNotifications FROM watch WHERE address = :address") - suspend fun getSendNotifications(address: String): Boolean - @Query("UPDATE watch SET autoConnect = :autoConnect WHERE address = :address") suspend fun setAutoConnect(address: String, autoConnect: Boolean) - - @Query("UPDATE watch SET sendNotifications = :sendNotifications WHERE address = :address") - suspend fun setSendNotifications(address: String, sendNotifications: Boolean) } \ No newline at end of file diff --git a/app/src/main/java/net/pipe01/pinepartner/pages/devices/DevicePage.kt b/app/src/main/java/net/pipe01/pinepartner/pages/devices/DevicePage.kt index cab802d..20e2d1d 100644 --- a/app/src/main/java/net/pipe01/pinepartner/pages/devices/DevicePage.kt +++ b/app/src/main/java/net/pipe01/pinepartner/pages/devices/DevicePage.kt @@ -35,8 +35,6 @@ fun DevicePage(db: AppDatabase, deviceAddress: String) { val context = LocalContext.current val coroutineScope = rememberCoroutineScope() - var isConnected by remember { mutableStateOf(false) } - var watch by remember { mutableStateOf(null) } var state by remember { mutableStateOf(null) } @@ -87,18 +85,6 @@ fun DevicePage(db: AppDatabase, deviceAddress: String) { } } ) - - Setting( - name = "Send notifications", - value = watch!!.sendNotifications, - onValueChange = { - watch = watch!!.copy(sendNotifications = it) - - coroutineScope.launch { - db.watchDao().setSendNotifications(deviceAddress, it) - } - } - ) } } }