mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-05 19:08:23 +00:00
Fix application activity
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 7,
|
||||
"identityHash": "e33ced3a06fb3f42b864b74040933487",
|
||||
"identityHash": "9dd67b37373a7835e977a442d8f67cc4",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "application",
|
||||
@@ -239,7 +239,7 @@
|
||||
},
|
||||
{
|
||||
"tableName": "history",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `pkKey` TEXT NOT NULL, `type` TEXT NOT NULL, `kind` INTEGER, `time` INTEGER NOT NULL, `accepted` INTEGER NOT NULL, FOREIGN KEY(`pkKey`) REFERENCES `application`(`key`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `pkKey` TEXT NOT NULL, `type` TEXT NOT NULL, `kind` INTEGER, `time` INTEGER NOT NULL, `accepted` INTEGER NOT NULL)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
@@ -304,19 +304,7 @@
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `history_by_id` ON `${TABLE_NAME}` (`id`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "application",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"pkKey"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"key"
|
||||
]
|
||||
}
|
||||
]
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "amber_log",
|
||||
@@ -366,7 +354,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, 'e33ced3a06fb3f42b864b74040933487')"
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '9dd67b37373a7835e977a442d8f67cc4')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,441 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 8,
|
||||
"identityHash": "cfdf9a16e23cb231083a71a03c572c39",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "application",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`key` TEXT NOT NULL, `name` TEXT NOT NULL, `relays` TEXT NOT NULL, `url` TEXT NOT NULL, `icon` TEXT NOT NULL, `description` TEXT NOT NULL, `pubKey` TEXT NOT NULL, `isConnected` INTEGER NOT NULL, `secret` TEXT NOT NULL, `useSecret` INTEGER NOT NULL, `signPolicy` INTEGER NOT NULL, `closeApplication` INTEGER NOT NULL, PRIMARY KEY(`key`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "key",
|
||||
"columnName": "key",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "name",
|
||||
"columnName": "name",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "relays",
|
||||
"columnName": "relays",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "url",
|
||||
"columnName": "url",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "icon",
|
||||
"columnName": "icon",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "description",
|
||||
"columnName": "description",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "pubKey",
|
||||
"columnName": "pubKey",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "isConnected",
|
||||
"columnName": "isConnected",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "secret",
|
||||
"columnName": "secret",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "useSecret",
|
||||
"columnName": "useSecret",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "signPolicy",
|
||||
"columnName": "signPolicy",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "closeApplication",
|
||||
"columnName": "closeApplication",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"autoGenerate": false,
|
||||
"columnNames": [
|
||||
"key"
|
||||
]
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_key",
|
||||
"unique": true,
|
||||
"columnNames": [
|
||||
"key"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_key` ON `${TABLE_NAME}` (`key`)"
|
||||
},
|
||||
{
|
||||
"name": "index_name",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"name"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_name` ON `${TABLE_NAME}` (`name`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "applicationPermission",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER, `pkKey` TEXT NOT NULL, `type` TEXT NOT NULL, `kind` INTEGER, `acceptable` INTEGER NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY(`pkKey`) REFERENCES `application`(`key`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "pkKey",
|
||||
"columnName": "pkKey",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "type",
|
||||
"columnName": "type",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "kind",
|
||||
"columnName": "kind",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "acceptable",
|
||||
"columnName": "acceptable",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"autoGenerate": false,
|
||||
"columnNames": [
|
||||
"id"
|
||||
]
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "permissions_by_pk_key",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"pkKey"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `permissions_by_pk_key` ON `${TABLE_NAME}` (`pkKey`)"
|
||||
},
|
||||
{
|
||||
"name": "permissions_unique",
|
||||
"unique": true,
|
||||
"columnNames": [
|
||||
"pkKey",
|
||||
"type",
|
||||
"kind"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `permissions_unique` ON `${TABLE_NAME}` (`pkKey`, `type`, `kind`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "application",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"pkKey"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"key"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "notification",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `eventId` TEXT NOT NULL, `time` INTEGER NOT NULL)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "eventId",
|
||||
"columnName": "eventId",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "time",
|
||||
"columnName": "time",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"autoGenerate": true,
|
||||
"columnNames": [
|
||||
"id"
|
||||
]
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_notification_eventId",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"eventId"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_notification_eventId` ON `${TABLE_NAME}` (`eventId`)"
|
||||
},
|
||||
{
|
||||
"name": "index_notification_time",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"time"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_notification_time` ON `${TABLE_NAME}` (`time`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "history",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `pkKey` TEXT NOT NULL, `type` TEXT NOT NULL, `kind` INTEGER, `time` INTEGER NOT NULL, `accepted` INTEGER NOT NULL, FOREIGN KEY(`pkKey`) REFERENCES `application`(`key`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "pkKey",
|
||||
"columnName": "pkKey",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "type",
|
||||
"columnName": "type",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "kind",
|
||||
"columnName": "kind",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "time",
|
||||
"columnName": "time",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "accepted",
|
||||
"columnName": "accepted",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"autoGenerate": true,
|
||||
"columnNames": [
|
||||
"id"
|
||||
]
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "history_by_pk_key",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"pkKey"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `history_by_pk_key` ON `${TABLE_NAME}` (`pkKey`)"
|
||||
},
|
||||
{
|
||||
"name": "history_by_id",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `history_by_id` ON `${TABLE_NAME}` (`id`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": [
|
||||
{
|
||||
"table": "application",
|
||||
"onDelete": "CASCADE",
|
||||
"onUpdate": "NO ACTION",
|
||||
"columns": [
|
||||
"pkKey"
|
||||
],
|
||||
"referencedColumns": [
|
||||
"key"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "amber_log",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `url` TEXT NOT NULL, `type` TEXT NOT NULL, `message` TEXT NOT NULL, `time` INTEGER NOT NULL)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "url",
|
||||
"columnName": "url",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "type",
|
||||
"columnName": "type",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "message",
|
||||
"columnName": "message",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "time",
|
||||
"columnName": "time",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"autoGenerate": true,
|
||||
"columnNames": [
|
||||
"id"
|
||||
]
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": []
|
||||
},
|
||||
{
|
||||
"tableName": "history2",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `pkKey` TEXT NOT NULL, `type` TEXT NOT NULL, `kind` INTEGER, `time` INTEGER NOT NULL, `accepted` INTEGER NOT NULL)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
"columnName": "id",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "pkKey",
|
||||
"columnName": "pkKey",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "type",
|
||||
"columnName": "type",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "kind",
|
||||
"columnName": "kind",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "time",
|
||||
"columnName": "time",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "accepted",
|
||||
"columnName": "accepted",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"autoGenerate": true,
|
||||
"columnNames": [
|
||||
"id"
|
||||
]
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "history_by_pk_key2",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"pkKey"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `history_by_pk_key2` ON `${TABLE_NAME}` (`pkKey`)"
|
||||
},
|
||||
{
|
||||
"name": "history_by_id2",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"id"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `history_by_id2` ON `${TABLE_NAME}` (`id`)"
|
||||
}
|
||||
],
|
||||
"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, 'cfdf9a16e23cb231083a71a03c572c39')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import android.database.Cursor
|
||||
import android.database.MatrixCursor
|
||||
import android.net.Uri
|
||||
import android.util.Log
|
||||
import com.greenart7c3.nostrsigner.database.HistoryEntity
|
||||
import com.greenart7c3.nostrsigner.database.HistoryEntity2
|
||||
import com.greenart7c3.nostrsigner.database.LogEntity
|
||||
import com.greenart7c3.nostrsigner.models.SignerType
|
||||
import com.greenart7c3.nostrsigner.models.kindToNip
|
||||
@@ -77,7 +77,7 @@ class SignerProvider : ContentProvider() {
|
||||
if (!isRemembered) {
|
||||
scope.launch {
|
||||
database.applicationDao().addHistory(
|
||||
HistoryEntity(
|
||||
HistoryEntity2(
|
||||
0,
|
||||
sortOrder ?: packageName,
|
||||
uri.toString().replace("content://$appId.", ""),
|
||||
@@ -98,7 +98,7 @@ class SignerProvider : ContentProvider() {
|
||||
val result = signString(message, account.signer.keyPair.privKey!!).toHexKey()
|
||||
scope.launch {
|
||||
database.applicationDao().addHistory(
|
||||
HistoryEntity(
|
||||
HistoryEntity2(
|
||||
0,
|
||||
sortOrder ?: packageName,
|
||||
"SIGN_MESSAGE",
|
||||
@@ -158,7 +158,7 @@ class SignerProvider : ContentProvider() {
|
||||
if (!isRemembered) {
|
||||
scope.launch {
|
||||
database.applicationDao().addHistory(
|
||||
HistoryEntity(
|
||||
HistoryEntity2(
|
||||
0,
|
||||
sortOrder ?: packageName,
|
||||
uri.toString().replace("content://$appId.", ""),
|
||||
@@ -183,7 +183,7 @@ class SignerProvider : ContentProvider() {
|
||||
Log.d("SignerProvider", "Failed to sign event from $packageName")
|
||||
scope.launch {
|
||||
database.applicationDao().addHistory(
|
||||
HistoryEntity(
|
||||
HistoryEntity2(
|
||||
0,
|
||||
sortOrder ?: packageName,
|
||||
"SIGN_EVENT",
|
||||
@@ -198,7 +198,7 @@ class SignerProvider : ContentProvider() {
|
||||
|
||||
scope.launch {
|
||||
database.applicationDao().addHistory(
|
||||
HistoryEntity(
|
||||
HistoryEntity2(
|
||||
0,
|
||||
sortOrder ?: packageName,
|
||||
"SIGN_EVENT",
|
||||
@@ -273,7 +273,7 @@ class SignerProvider : ContentProvider() {
|
||||
if (!isRemembered) {
|
||||
scope.launch {
|
||||
database.applicationDao().addHistory(
|
||||
HistoryEntity(
|
||||
HistoryEntity2(
|
||||
0,
|
||||
sortOrder ?: packageName,
|
||||
uri.toString().replace("content://$appId.", ""),
|
||||
@@ -327,7 +327,7 @@ class SignerProvider : ContentProvider() {
|
||||
|
||||
scope.launch {
|
||||
database.applicationDao().addHistory(
|
||||
HistoryEntity(
|
||||
HistoryEntity2(
|
||||
0,
|
||||
sortOrder ?: packageName,
|
||||
uri.toString().replace("content://$appId.", ""),
|
||||
@@ -360,7 +360,7 @@ class SignerProvider : ContentProvider() {
|
||||
if (!isRemembered) {
|
||||
scope.launch {
|
||||
database.applicationDao().addHistory(
|
||||
HistoryEntity(
|
||||
HistoryEntity2(
|
||||
0,
|
||||
sortOrder ?: packageName,
|
||||
uri.toString().replace("content://$appId.", ""),
|
||||
@@ -381,7 +381,7 @@ class SignerProvider : ContentProvider() {
|
||||
|
||||
scope.launch {
|
||||
database.applicationDao().addHistory(
|
||||
HistoryEntity(
|
||||
HistoryEntity2(
|
||||
0,
|
||||
sortOrder ?: packageName,
|
||||
uri.toString().replace("content://$appId.", ""),
|
||||
|
||||
@@ -56,6 +56,17 @@ val MIGRATION_6_7 =
|
||||
}
|
||||
}
|
||||
|
||||
val MIGRATION_7_8 =
|
||||
object : Migration(7, 8) {
|
||||
override fun migrate(db: SupportSQLiteDatabase) {
|
||||
db.execSQL("CREATE TABLE IF NOT EXISTS `history2` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `pkKey` TEXT NOT NULL, `type` TEXT NOT NULL, `kind` INTEGER, `time` INTEGER NOT NULL, `accepted` INTEGER NOT NULL)")
|
||||
db.execSQL("CREATE INDEX IF NOT EXISTS `history_by_pk_key2` ON `history2` (`pkKey`)")
|
||||
db.execSQL("CREATE INDEX IF NOT EXISTS `history_by_id2` ON `history2` (`id`)")
|
||||
db.execSQL("INSERT INTO history2 SELECT * FROM history")
|
||||
db.execSQL("DELETE FROM history")
|
||||
}
|
||||
}
|
||||
|
||||
@Database(
|
||||
entities = [
|
||||
ApplicationEntity::class,
|
||||
@@ -63,8 +74,9 @@ val MIGRATION_6_7 =
|
||||
NotificationEntity::class,
|
||||
HistoryEntity::class,
|
||||
LogEntity::class,
|
||||
HistoryEntity2::class,
|
||||
],
|
||||
version = 7,
|
||||
version = 8,
|
||||
)
|
||||
@TypeConverters(Converters::class)
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
@@ -93,6 +105,7 @@ abstract class AppDatabase : RoomDatabase() {
|
||||
.addMigrations(MIGRATION_4_5)
|
||||
.addMigrations(MIGRATION_5_6)
|
||||
.addMigrations(MIGRATION_6_7)
|
||||
.addMigrations(MIGRATION_7_8)
|
||||
.build()
|
||||
instance.openHelper.writableDatabase.execSQL("VACUUM")
|
||||
instance
|
||||
|
||||
@@ -47,7 +47,7 @@ interface ApplicationDao {
|
||||
"""
|
||||
SELECT a.*, MAX(h.time) as latestTime
|
||||
FROM application a
|
||||
LEFT JOIN history h ON a.`key` = h.pkKey
|
||||
LEFT JOIN history2 h ON a.`key` = h.pkKey
|
||||
AND a.pubKey = :pubKey
|
||||
GROUP BY a.`key`, a.description, a.icon, a.isConnected, a.name, a.pubKey, a.secret, a.signPolicy, a.url
|
||||
ORDER BY latestTime DESC
|
||||
@@ -146,11 +146,11 @@ interface ApplicationDao {
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
@Transaction
|
||||
suspend fun innerAddHistory(entity: HistoryEntity)
|
||||
suspend fun innerAddHistory(entity: HistoryEntity2)
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
||||
@Transaction
|
||||
suspend fun addHistory(entity: HistoryEntity) {
|
||||
suspend fun addHistory(entity: HistoryEntity2) {
|
||||
try {
|
||||
innerAddHistory(entity)
|
||||
} catch (e: Exception) {
|
||||
@@ -158,8 +158,8 @@ interface ApplicationDao {
|
||||
}
|
||||
}
|
||||
|
||||
@Query("SELECT * FROM history where pkKey = :pk ORDER BY time DESC")
|
||||
fun getAllHistory(pk: String): Flow<List<HistoryEntity>>
|
||||
@Query("SELECT * FROM history2 where pkKey = :pk ORDER BY time DESC")
|
||||
fun getAllHistory(pk: String): Flow<List<HistoryEntity2>>
|
||||
|
||||
@Insert
|
||||
@Transaction
|
||||
@@ -179,17 +179,17 @@ interface ApplicationDao {
|
||||
@Transaction
|
||||
suspend fun deletePermission(permission: ApplicationPermissionsEntity)
|
||||
|
||||
@Query("SELECT COUNT(*) FROM history WHERE time < :time")
|
||||
@Query("SELECT COUNT(*) FROM history2 WHERE time < :time")
|
||||
@Transaction
|
||||
suspend fun countOldHistory(time: Long): Long
|
||||
|
||||
@Query("SELECT * FROM history WHERE time < :time LIMIT 100")
|
||||
@Query("SELECT * FROM history2 WHERE time < :time LIMIT 100")
|
||||
@Transaction
|
||||
suspend fun getOldHistory(time: Long): List<HistoryEntity>
|
||||
suspend fun getOldHistory(time: Long): List<HistoryEntity2>
|
||||
|
||||
@Delete
|
||||
@Transaction
|
||||
suspend fun deleteHistory(historyEntity: HistoryEntity)
|
||||
suspend fun deleteHistory(historyEntity: HistoryEntity2)
|
||||
|
||||
@Query("SELECT COUNT(*) FROM notification WHERE time < :time")
|
||||
@Transaction
|
||||
|
||||
@@ -35,3 +35,26 @@ data class HistoryEntity(
|
||||
val time: Long,
|
||||
val accepted: Boolean,
|
||||
)
|
||||
|
||||
@Entity(
|
||||
tableName = "history2",
|
||||
indices = [
|
||||
Index(
|
||||
value = ["pkKey"],
|
||||
name = "history_by_pk_key2",
|
||||
),
|
||||
Index(
|
||||
value = ["id"],
|
||||
name = "history_by_id2",
|
||||
),
|
||||
],
|
||||
)
|
||||
data class HistoryEntity2(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
val id: Int,
|
||||
val pkKey: String,
|
||||
val type: String,
|
||||
val kind: Int?,
|
||||
val time: Long,
|
||||
val accepted: Boolean,
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ import com.greenart7c3.nostrsigner.LocalPreferences
|
||||
import com.greenart7c3.nostrsigner.NostrSigner
|
||||
import com.greenart7c3.nostrsigner.R
|
||||
import com.greenart7c3.nostrsigner.database.ApplicationWithPermissions
|
||||
import com.greenart7c3.nostrsigner.database.HistoryEntity
|
||||
import com.greenart7c3.nostrsigner.database.HistoryEntity2
|
||||
import com.greenart7c3.nostrsigner.database.LogEntity
|
||||
import com.greenart7c3.nostrsigner.database.NotificationEntity
|
||||
import com.greenart7c3.nostrsigner.models.Account
|
||||
@@ -182,7 +182,7 @@ class EventNotificationConsumer(private val applicationContext: Context) {
|
||||
NostrSigner.instance.applicationIOScope.launch {
|
||||
database.applicationDao()
|
||||
.addHistory(
|
||||
HistoryEntity(
|
||||
HistoryEntity2(
|
||||
0,
|
||||
permission.application.key,
|
||||
type.toString().toLowerCase(Locale.current),
|
||||
|
||||
@@ -90,7 +90,7 @@ import com.greenart7c3.nostrsigner.R
|
||||
import com.greenart7c3.nostrsigner.database.ApplicationEntity
|
||||
import com.greenart7c3.nostrsigner.database.ApplicationPermissionsEntity
|
||||
import com.greenart7c3.nostrsigner.database.ApplicationWithPermissions
|
||||
import com.greenart7c3.nostrsigner.database.HistoryEntity
|
||||
import com.greenart7c3.nostrsigner.database.HistoryEntity2
|
||||
import com.greenart7c3.nostrsigner.models.Account
|
||||
import com.greenart7c3.nostrsigner.models.CompressionType
|
||||
import com.greenart7c3.nostrsigner.models.IntentData
|
||||
@@ -284,7 +284,7 @@ fun sendResult(
|
||||
EventNotificationConsumer(context).notificationManager().cancelAll()
|
||||
database.applicationDao().insertApplicationWithPermissions(application)
|
||||
database.applicationDao().addHistory(
|
||||
HistoryEntity(
|
||||
HistoryEntity2(
|
||||
0,
|
||||
key,
|
||||
intentData.type.toString(),
|
||||
@@ -331,7 +331,7 @@ fun sendResult(
|
||||
} else if (packageName != null) {
|
||||
database.applicationDao().insertApplicationWithPermissions(application)
|
||||
database.applicationDao().addHistory(
|
||||
HistoryEntity(
|
||||
HistoryEntity2(
|
||||
0,
|
||||
key,
|
||||
intentData.type.toString(),
|
||||
@@ -1144,7 +1144,8 @@ fun MainScreen(
|
||||
topPadding = padding.calculateTopPadding() + (verticalPadding * 1.5f),
|
||||
modifier =
|
||||
Modifier
|
||||
.fillMaxSize(),
|
||||
.fillMaxSize()
|
||||
.imePadding(),
|
||||
)
|
||||
}
|
||||
},
|
||||
|
||||
@@ -156,8 +156,12 @@ fun ActivityScreen(
|
||||
|
||||
// Filtered activities based on the search query
|
||||
var filteredActivities = activities.value.filter { activity ->
|
||||
val permission = Permission(activity.type.toLowerCase(Locale.current), activity.kind)
|
||||
permission.toLocalizedString(context, true).contains(searchQuery, ignoreCase = true)
|
||||
if (searchQuery.isEmpty()) {
|
||||
true
|
||||
} else {
|
||||
val permission = Permission(activity.type.toLowerCase(Locale.current), activity.kind)
|
||||
permission.toLocalizedString(context, true).contains(searchQuery, ignoreCase = true)
|
||||
}
|
||||
}
|
||||
val textFieldState by remember { mutableStateOf(TextFieldState(initialText = searchQuery)) }
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ import com.greenart7c3.nostrsigner.NostrSigner
|
||||
import com.greenart7c3.nostrsigner.R
|
||||
import com.greenart7c3.nostrsigner.database.ApplicationEntity
|
||||
import com.greenart7c3.nostrsigner.database.ApplicationWithPermissions
|
||||
import com.greenart7c3.nostrsigner.database.HistoryEntity
|
||||
import com.greenart7c3.nostrsigner.database.HistoryEntity2
|
||||
import com.greenart7c3.nostrsigner.models.Account
|
||||
import com.greenart7c3.nostrsigner.models.IntentData
|
||||
import com.greenart7c3.nostrsigner.models.Permission
|
||||
@@ -237,7 +237,7 @@ fun MultiEventHomeScreen(
|
||||
database.applicationDao().insertApplicationWithPermissions(application)
|
||||
|
||||
database.applicationDao().addHistory(
|
||||
HistoryEntity(
|
||||
HistoryEntity2(
|
||||
0,
|
||||
localKey,
|
||||
intentData.type.toString(),
|
||||
@@ -319,7 +319,7 @@ fun MultiEventHomeScreen(
|
||||
|
||||
database.applicationDao().insertApplicationWithPermissions(application)
|
||||
database.applicationDao().addHistory(
|
||||
HistoryEntity(
|
||||
HistoryEntity2(
|
||||
0,
|
||||
localKey,
|
||||
intentData.type.toString(),
|
||||
@@ -378,7 +378,7 @@ fun MultiEventHomeScreen(
|
||||
database.applicationDao().insertApplicationWithPermissions(application)
|
||||
|
||||
database.applicationDao().addHistory(
|
||||
HistoryEntity(
|
||||
HistoryEntity2(
|
||||
0,
|
||||
localKey,
|
||||
intentData.type.toString(),
|
||||
@@ -445,7 +445,7 @@ fun MultiEventHomeScreen(
|
||||
database.applicationDao().insertApplicationWithPermissions(application)
|
||||
|
||||
database.applicationDao().addHistory(
|
||||
HistoryEntity(
|
||||
HistoryEntity2(
|
||||
0,
|
||||
localKey,
|
||||
intentData.type.toString(),
|
||||
|
||||
+4
-4
@@ -27,7 +27,7 @@ import com.greenart7c3.nostrsigner.NostrSigner
|
||||
import com.greenart7c3.nostrsigner.R
|
||||
import com.greenart7c3.nostrsigner.database.ApplicationEntity
|
||||
import com.greenart7c3.nostrsigner.database.ApplicationWithPermissions
|
||||
import com.greenart7c3.nostrsigner.database.HistoryEntity
|
||||
import com.greenart7c3.nostrsigner.database.HistoryEntity2
|
||||
import com.greenart7c3.nostrsigner.models.Account
|
||||
import com.greenart7c3.nostrsigner.models.IntentData
|
||||
import com.greenart7c3.nostrsigner.models.SignerType
|
||||
@@ -266,7 +266,7 @@ fun SingleEventHomeScreen(
|
||||
NostrSigner.instance.getDatabase(account.npub).applicationDao().insertApplicationWithPermissions(application)
|
||||
|
||||
NostrSigner.instance.getDatabase(account.npub).applicationDao().addHistory(
|
||||
HistoryEntity(
|
||||
HistoryEntity2(
|
||||
0,
|
||||
key,
|
||||
intentData.type.toString(),
|
||||
@@ -409,7 +409,7 @@ fun SingleEventHomeScreen(
|
||||
NostrSigner.instance.getDatabase(account.npub).applicationDao().insertApplicationWithPermissions(application)
|
||||
|
||||
NostrSigner.instance.getDatabase(account.npub).applicationDao().addHistory(
|
||||
HistoryEntity(
|
||||
HistoryEntity2(
|
||||
0,
|
||||
key,
|
||||
intentData.type.toString(),
|
||||
@@ -582,7 +582,7 @@ fun SingleEventHomeScreen(
|
||||
NostrSigner.instance.getDatabase(account.npub).applicationDao().insertApplicationWithPermissions(application)
|
||||
|
||||
NostrSigner.instance.getDatabase(account.npub).applicationDao().addHistory(
|
||||
HistoryEntity(
|
||||
HistoryEntity2(
|
||||
0,
|
||||
key,
|
||||
intentData.type.toString(),
|
||||
|
||||
Reference in New Issue
Block a user