Skip to content

Commit

Permalink
Remove watch send notifications permission
Browse files Browse the repository at this point in the history
  • Loading branch information
pipe01 committed Mar 22, 2024
1 parent 8df75ee commit 402518d
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 37 deletions.
13 changes: 3 additions & 10 deletions app/schemas/net.pipe01.pinepartner.data.AppDatabase/12.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -26,13 +26,6 @@
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "true"
},
{
"fieldPath": "sendNotifications",
"columnName": "sendNotifications",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "false"
}
],
"primaryKey": {
Expand Down Expand Up @@ -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')"
]
}
}
135 changes: 135 additions & 0 deletions app/schemas/net.pipe01.pinepartner.data.AppDatabase/13.json
Original file line number Diff line number Diff line change
@@ -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')"
]
}
}
7 changes: 1 addition & 6 deletions app/src/main/java/net/pipe01/pinepartner/data/AppDatabase.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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() {
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/net/pipe01/pinepartner/data/Watch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
6 changes: 0 additions & 6 deletions app/src/main/java/net/pipe01/pinepartner/data/WatchDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Watch?>(null) }
var state by remember { mutableStateOf<WatchState?>(null) }

Expand Down Expand Up @@ -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)
}
}
)
}
}
}
Expand Down

0 comments on commit 402518d

Please sign in to comment.