From 411b18d3372f6f3587874d4c86a1a8e77e943051 Mon Sep 17 00:00:00 2001 From: greenart7c3 Date: Fri, 11 Apr 2025 12:37:02 -0300 Subject: [PATCH] Fix application activity --- .../7.json | 20 +- .../8.json | 441 ++++++++++++++++++ .../greenart7c3/nostrsigner/SignerProvider.kt | 20 +- .../nostrsigner/database/AppDatabase.kt | 15 +- .../nostrsigner/database/ApplicationDao.kt | 18 +- .../nostrsigner/database/HistoryEntity.kt | 23 + .../service/EventNotificationConsumer.kt | 4 +- .../greenart7c3/nostrsigner/ui/MainScreen.kt | 9 +- .../nostrsigner/ui/actions/ActivityScreen.kt | 8 +- .../ui/components/MultiEventHomeScreen.kt | 10 +- .../ui/components/SingleEventHomeScreen.kt | 8 +- 11 files changed, 523 insertions(+), 53 deletions(-) create mode 100644 app/schemas/com.greenart7c3.nostrsigner.database.AppDatabase/8.json diff --git a/app/schemas/com.greenart7c3.nostrsigner.database.AppDatabase/7.json b/app/schemas/com.greenart7c3.nostrsigner.database.AppDatabase/7.json index ea1b9f85..d5cd3ffa 100644 --- a/app/schemas/com.greenart7c3.nostrsigner.database.AppDatabase/7.json +++ b/app/schemas/com.greenart7c3.nostrsigner.database.AppDatabase/7.json @@ -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')" ] } } \ No newline at end of file diff --git a/app/schemas/com.greenart7c3.nostrsigner.database.AppDatabase/8.json b/app/schemas/com.greenart7c3.nostrsigner.database.AppDatabase/8.json new file mode 100644 index 00000000..4043886c --- /dev/null +++ b/app/schemas/com.greenart7c3.nostrsigner.database.AppDatabase/8.json @@ -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')" + ] + } +} \ No newline at end of file diff --git a/app/src/main/java/com/greenart7c3/nostrsigner/SignerProvider.kt b/app/src/main/java/com/greenart7c3/nostrsigner/SignerProvider.kt index d3fb6055..9d715f77 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/SignerProvider.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/SignerProvider.kt @@ -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.", ""), diff --git a/app/src/main/java/com/greenart7c3/nostrsigner/database/AppDatabase.kt b/app/src/main/java/com/greenart7c3/nostrsigner/database/AppDatabase.kt index b3d56971..4f337bc7 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/database/AppDatabase.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/database/AppDatabase.kt @@ -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 diff --git a/app/src/main/java/com/greenart7c3/nostrsigner/database/ApplicationDao.kt b/app/src/main/java/com/greenart7c3/nostrsigner/database/ApplicationDao.kt index 04056351..a66b7fb9 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/database/ApplicationDao.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/database/ApplicationDao.kt @@ -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> + @Query("SELECT * FROM history2 where pkKey = :pk ORDER BY time DESC") + fun getAllHistory(pk: String): Flow> @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 + suspend fun getOldHistory(time: Long): List @Delete @Transaction - suspend fun deleteHistory(historyEntity: HistoryEntity) + suspend fun deleteHistory(historyEntity: HistoryEntity2) @Query("SELECT COUNT(*) FROM notification WHERE time < :time") @Transaction diff --git a/app/src/main/java/com/greenart7c3/nostrsigner/database/HistoryEntity.kt b/app/src/main/java/com/greenart7c3/nostrsigner/database/HistoryEntity.kt index 0131d6ff..4c9f226e 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/database/HistoryEntity.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/database/HistoryEntity.kt @@ -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, +) diff --git a/app/src/main/java/com/greenart7c3/nostrsigner/service/EventNotificationConsumer.kt b/app/src/main/java/com/greenart7c3/nostrsigner/service/EventNotificationConsumer.kt index a5255dc3..c4b14430 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/service/EventNotificationConsumer.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/service/EventNotificationConsumer.kt @@ -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), diff --git a/app/src/main/java/com/greenart7c3/nostrsigner/ui/MainScreen.kt b/app/src/main/java/com/greenart7c3/nostrsigner/ui/MainScreen.kt index ce35de62..9e519e34 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/ui/MainScreen.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/ui/MainScreen.kt @@ -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(), ) } }, diff --git a/app/src/main/java/com/greenart7c3/nostrsigner/ui/actions/ActivityScreen.kt b/app/src/main/java/com/greenart7c3/nostrsigner/ui/actions/ActivityScreen.kt index 6762936c..9427b0b5 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/ui/actions/ActivityScreen.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/ui/actions/ActivityScreen.kt @@ -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)) } diff --git a/app/src/main/java/com/greenart7c3/nostrsigner/ui/components/MultiEventHomeScreen.kt b/app/src/main/java/com/greenart7c3/nostrsigner/ui/components/MultiEventHomeScreen.kt index 83e038db..b5d6ab2b 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/ui/components/MultiEventHomeScreen.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/ui/components/MultiEventHomeScreen.kt @@ -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(), diff --git a/app/src/main/java/com/greenart7c3/nostrsigner/ui/components/SingleEventHomeScreen.kt b/app/src/main/java/com/greenart7c3/nostrsigner/ui/components/SingleEventHomeScreen.kt index dfe10230..92c79609 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/ui/components/SingleEventHomeScreen.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/ui/components/SingleEventHomeScreen.kt @@ -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(),