mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-05 10:58:23 +00:00
Add option to not close amber
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 5,
|
||||
"identityHash": "ffb55f8c910a34676fa829322921d260",
|
||||
"identityHash": "3d67ebb3b84f49af6a6823444e1a28e9",
|
||||
"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, PRIMARY KEY(`key`))",
|
||||
"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",
|
||||
@@ -73,6 +73,12 @@
|
||||
"columnName": "signPolicy",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "closeApplication",
|
||||
"columnName": "closeApplication",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
@@ -341,7 +347,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, 'ffb55f8c910a34676fa829322921d260')"
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '3d67ebb3b84f49af6a6823444e1a28e9')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,353 @@
|
||||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 6,
|
||||
"identityHash": "3d67ebb3b84f49af6a6823444e1a28e9",
|
||||
"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": [],
|
||||
"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": []
|
||||
}
|
||||
],
|
||||
"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, '3d67ebb3b84f49af6a6823444e1a28e9')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -396,6 +396,7 @@ object LocalPreferences {
|
||||
"",
|
||||
false,
|
||||
1,
|
||||
closeApplication = true,
|
||||
),
|
||||
)
|
||||
database.applicationDao().insertPermissions(
|
||||
|
||||
@@ -40,6 +40,13 @@ val MIGRATION_4_5 =
|
||||
}
|
||||
}
|
||||
|
||||
val MIGRATION_5_6 =
|
||||
object : Migration(5, 6) {
|
||||
override fun migrate(db: SupportSQLiteDatabase) {
|
||||
db.execSQL("ALTER TABLE `application` ADD COLUMN `closeApplication` INTEGER NOT NULL DEFAULT 1")
|
||||
}
|
||||
}
|
||||
|
||||
@Database(
|
||||
entities = [
|
||||
ApplicationEntity::class,
|
||||
@@ -48,7 +55,7 @@ val MIGRATION_4_5 =
|
||||
HistoryEntity::class,
|
||||
LogEntity::class,
|
||||
],
|
||||
version = 5,
|
||||
version = 6,
|
||||
)
|
||||
@TypeConverters(Converters::class)
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
@@ -70,6 +77,7 @@ abstract class AppDatabase : RoomDatabase() {
|
||||
.addMigrations(MIGRATION_2_3)
|
||||
.addMigrations(MIGRATION_3_4)
|
||||
.addMigrations(MIGRATION_4_5)
|
||||
.addMigrations(MIGRATION_5_6)
|
||||
.build()
|
||||
instance
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ data class ApplicationEntity(
|
||||
val secret: String,
|
||||
val useSecret: Boolean,
|
||||
var signPolicy: Int,
|
||||
var closeApplication: Boolean,
|
||||
) {
|
||||
companion object {
|
||||
fun empty() = ApplicationEntity(
|
||||
@@ -51,6 +52,7 @@ data class ApplicationEntity(
|
||||
secret = "",
|
||||
useSecret = false,
|
||||
signPolicy = 0,
|
||||
closeApplication = true,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ data class BunkerRequest(
|
||||
var currentAccount: String,
|
||||
var encryptionType: EncryptionType,
|
||||
var nostrConnectSecret: String,
|
||||
var closeApplication: Boolean,
|
||||
) {
|
||||
fun toJson(): String {
|
||||
return mapper.writeValueAsString(this)
|
||||
@@ -94,6 +95,7 @@ data class BunkerRequest(
|
||||
currentAccount = jsonObject.get("currentAccount")?.asText()?.intern() ?: "",
|
||||
encryptionType = encryptionType,
|
||||
nostrConnectSecret = jsonObject.get("nostrConnectSecret")?.asText()?.intern() ?: "",
|
||||
closeApplication = jsonObject.get("closeApplication")?.asBoolean() ?: false,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -130,6 +132,7 @@ data class BunkerRequest(
|
||||
gen.writeStringField("currentAccount", value.currentAccount)
|
||||
gen.writeStringField("encryptionType", value.encryptionType.toString())
|
||||
gen.writeStringField("nostrConnectSecret", value.nostrConnectSecret)
|
||||
gen.writeBooleanField("closeApplication", value.closeApplication)
|
||||
gen.writeEndObject()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +126,7 @@ object AmberUtils {
|
||||
bunkerRequest: BunkerRequest,
|
||||
relays: List<RelaySetupInfo>,
|
||||
context: Context,
|
||||
closeApplication: Boolean,
|
||||
onRemoveIntentData: (IntentData) -> Unit,
|
||||
onLoading: (Boolean) -> Unit,
|
||||
) {
|
||||
@@ -139,7 +140,9 @@ object AmberUtils {
|
||||
onDone = {
|
||||
onRemoveIntentData(intentData)
|
||||
context.getAppCompatActivity()?.intent = null
|
||||
context.getAppCompatActivity()?.finish()
|
||||
if (closeApplication) {
|
||||
context.getAppCompatActivity()?.finish()
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -897,6 +897,7 @@ object IntentUtils {
|
||||
account.signer.keyPair.pubKey.toNpub(),
|
||||
EncryptionType.NIP04,
|
||||
nostrConnectSecret,
|
||||
intent.getBooleanExtra("closeApplication", true),
|
||||
),
|
||||
route,
|
||||
null,
|
||||
|
||||
@@ -73,7 +73,7 @@ fun EditPermission(
|
||||
mutableStateListOf<ApplicationPermissionsEntity>()
|
||||
}
|
||||
var applicationData by remember {
|
||||
mutableStateOf(ApplicationEntity(selectedPackage, "", emptyList(), "", "", "", "", true, "", false, 1))
|
||||
mutableStateOf(ApplicationEntity.empty())
|
||||
}
|
||||
|
||||
var wantsToRemovePermissions by remember { mutableStateOf(false) }
|
||||
|
||||
@@ -173,6 +173,7 @@ fun sendResult(
|
||||
intentData.bunkerRequest?.secret ?: "",
|
||||
intentData.bunkerRequest?.secret != null,
|
||||
account.signPolicy,
|
||||
intentData.bunkerRequest?.closeApplication ?: true,
|
||||
),
|
||||
permissions = mutableListOf(),
|
||||
)
|
||||
@@ -278,7 +279,9 @@ fun sendResult(
|
||||
EventNotificationConsumer(context).notificationManager().cancelAll()
|
||||
onRemoveIntentData(intentData)
|
||||
activity?.intent = null
|
||||
activity?.finish()
|
||||
if (application.application.closeApplication || intentData.bunkerRequest.closeApplication) {
|
||||
activity?.finish()
|
||||
}
|
||||
},
|
||||
)
|
||||
} else if (packageName != null) {
|
||||
|
||||
@@ -42,6 +42,7 @@ fun NewApplicationScreen(
|
||||
val intent = Intent(Intent.ACTION_VIEW)
|
||||
intent.data = Uri.parse(it)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
intent.putExtra("closeApplication", false)
|
||||
context.getAppCompatActivity()?.startActivity(intent)
|
||||
accountStateViewModel.switchUser(account.signer.keyPair.pubKey.toNpub(), Route.IncomingRequest.route)
|
||||
}
|
||||
|
||||
@@ -223,6 +223,7 @@ fun NewNsecBunkerScreen(
|
||||
secret.value,
|
||||
true,
|
||||
account.signPolicy,
|
||||
true,
|
||||
)
|
||||
|
||||
database.applicationDao().insertApplication(
|
||||
|
||||
+61
-6
@@ -163,6 +163,7 @@ fun MultiEventHomeScreen(
|
||||
val activity = context.getAppCompatActivity()
|
||||
val results = mutableListOf<Result>()
|
||||
reconnectToRelays(intents)
|
||||
var closeApp = true
|
||||
|
||||
for (intentData in intents) {
|
||||
val localAccount =
|
||||
@@ -195,10 +196,15 @@ fun MultiEventHomeScreen(
|
||||
intentData.bunkerRequest?.secret ?: "",
|
||||
intentData.bunkerRequest?.secret != null,
|
||||
localAccount.signPolicy,
|
||||
intentData.bunkerRequest?.closeApplication ?: true,
|
||||
),
|
||||
permissions = mutableListOf(),
|
||||
)
|
||||
|
||||
if (!application.application.closeApplication) {
|
||||
closeApp = false
|
||||
}
|
||||
|
||||
if (intentData.type == SignerType.SIGN_EVENT) {
|
||||
val localEvent = intentData.event!!
|
||||
|
||||
@@ -246,6 +252,7 @@ fun MultiEventHomeScreen(
|
||||
intentData.bunkerRequest,
|
||||
relays = application.application.relays,
|
||||
context = context,
|
||||
closeApplication = application.application.closeApplication,
|
||||
onRemoveIntentData = onRemoveIntentData,
|
||||
onLoading = {},
|
||||
)
|
||||
@@ -324,6 +331,7 @@ fun MultiEventHomeScreen(
|
||||
intentData.bunkerRequest,
|
||||
relays = application.application.relays,
|
||||
context = context,
|
||||
closeApplication = application.application.closeApplication,
|
||||
onRemoveIntentData = onRemoveIntentData,
|
||||
onLoading = {},
|
||||
)
|
||||
@@ -387,6 +395,7 @@ fun MultiEventHomeScreen(
|
||||
intentData.bunkerRequest,
|
||||
relays = application.application.relays,
|
||||
context = context,
|
||||
closeApplication = application.application.closeApplication,
|
||||
onRemoveIntentData = onRemoveIntentData,
|
||||
onLoading = {},
|
||||
)
|
||||
@@ -411,9 +420,9 @@ fun MultiEventHomeScreen(
|
||||
}
|
||||
if (intents.any { it.bunkerRequest != null }) {
|
||||
EventNotificationConsumer(context).notificationManager().cancelAll()
|
||||
finishActivity(activity)
|
||||
finishActivity(activity, closeApp)
|
||||
} else {
|
||||
finishActivity(activity)
|
||||
finishActivity(activity, closeApp)
|
||||
}
|
||||
} finally {
|
||||
onLoading(false)
|
||||
@@ -428,12 +437,56 @@ fun MultiEventHomeScreen(
|
||||
containerColor = orange,
|
||||
),
|
||||
onClick = {
|
||||
var closeApp = true
|
||||
|
||||
for (intentData in intents) {
|
||||
val localAccount =
|
||||
if (intentData.currentAccount.isNotBlank()) {
|
||||
LocalPreferences.loadFromEncryptedStorage(
|
||||
context,
|
||||
intentData.currentAccount,
|
||||
)
|
||||
} else {
|
||||
accountParam
|
||||
} ?: continue
|
||||
|
||||
val key = intentData.bunkerRequest?.localKey ?: packageName ?: continue
|
||||
|
||||
val database = NostrSigner.getInstance().getDatabase(localAccount.signer.keyPair.pubKey.toNpub())
|
||||
|
||||
val application =
|
||||
database
|
||||
.applicationDao()
|
||||
.getByKey(key) ?: ApplicationWithPermissions(
|
||||
application = ApplicationEntity(
|
||||
key,
|
||||
"",
|
||||
listOf(),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
localAccount.signer.keyPair.pubKey.toHexKey(),
|
||||
true,
|
||||
intentData.bunkerRequest?.secret ?: "",
|
||||
intentData.bunkerRequest?.secret != null,
|
||||
localAccount.signPolicy,
|
||||
intentData.bunkerRequest?.closeApplication ?: true,
|
||||
),
|
||||
permissions = mutableListOf(),
|
||||
)
|
||||
|
||||
if (!application.application.closeApplication) {
|
||||
closeApp = false
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
val activity = context.getAppCompatActivity()
|
||||
if (intents.any { it.bunkerRequest != null }) {
|
||||
EventNotificationConsumer(context).notificationManager().cancelAll()
|
||||
finishActivity(activity)
|
||||
finishActivity(activity, closeApp)
|
||||
} else {
|
||||
finishActivity(activity)
|
||||
finishActivity(activity, closeApp)
|
||||
}
|
||||
},
|
||||
text = stringResource(R.string.discard_all_requests),
|
||||
@@ -441,9 +494,11 @@ fun MultiEventHomeScreen(
|
||||
}
|
||||
}
|
||||
|
||||
private fun finishActivity(activity: AppCompatActivity?) {
|
||||
private fun finishActivity(activity: AppCompatActivity?, closeApp: Boolean) {
|
||||
activity?.intent = null
|
||||
activity?.finish()
|
||||
if (closeApp) {
|
||||
activity?.finish()
|
||||
}
|
||||
}
|
||||
|
||||
private fun sendResultIntent(
|
||||
|
||||
+16
-3
@@ -153,6 +153,7 @@ fun SingleEventHomeScreen(
|
||||
intentData.bunkerRequest,
|
||||
applicationEntity?.application?.relays ?: intentData.bunkerRequest.relays,
|
||||
context,
|
||||
closeApplication = intentData.bunkerRequest.closeApplication,
|
||||
onLoading = onLoading,
|
||||
onRemoveIntentData = onRemoveIntentData,
|
||||
)
|
||||
@@ -237,6 +238,7 @@ fun SingleEventHomeScreen(
|
||||
intentData.bunkerRequest?.secret ?: "",
|
||||
intentData.bunkerRequest?.secret != null,
|
||||
account.signPolicy,
|
||||
intentData.bunkerRequest?.closeApplication ?: true,
|
||||
),
|
||||
permissions = mutableListOf(),
|
||||
)
|
||||
@@ -278,13 +280,16 @@ fun SingleEventHomeScreen(
|
||||
intentData.bunkerRequest,
|
||||
relays,
|
||||
context,
|
||||
closeApplication = application.application.closeApplication,
|
||||
onLoading = onLoading,
|
||||
onRemoveIntentData = onRemoveIntentData,
|
||||
)
|
||||
} else {
|
||||
onRemoveIntentData(intentData)
|
||||
context.getAppCompatActivity()?.intent = null
|
||||
context.getAppCompatActivity()?.finish()
|
||||
if (application.application.closeApplication) {
|
||||
context.getAppCompatActivity()?.finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -378,6 +383,7 @@ fun SingleEventHomeScreen(
|
||||
intentData.bunkerRequest?.secret ?: "",
|
||||
intentData.bunkerRequest?.secret != null,
|
||||
account.signPolicy,
|
||||
intentData.bunkerRequest?.closeApplication ?: true,
|
||||
),
|
||||
permissions = mutableListOf(),
|
||||
)
|
||||
@@ -418,13 +424,16 @@ fun SingleEventHomeScreen(
|
||||
intentData.bunkerRequest,
|
||||
relays,
|
||||
context,
|
||||
closeApplication = application.application.closeApplication,
|
||||
onRemoveIntentData = onRemoveIntentData,
|
||||
onLoading,
|
||||
)
|
||||
} else {
|
||||
onRemoveIntentData(intentData)
|
||||
context.getAppCompatActivity()?.intent = null
|
||||
context.getAppCompatActivity()?.finish()
|
||||
if (application.application.closeApplication) {
|
||||
context.getAppCompatActivity()?.finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -542,6 +551,7 @@ fun SingleEventHomeScreen(
|
||||
intentData.bunkerRequest?.secret ?: "",
|
||||
intentData.bunkerRequest?.secret != null,
|
||||
account.signPolicy,
|
||||
intentData.bunkerRequest?.closeApplication ?: true,
|
||||
),
|
||||
permissions = mutableListOf(),
|
||||
)
|
||||
@@ -583,13 +593,16 @@ fun SingleEventHomeScreen(
|
||||
intentData.bunkerRequest,
|
||||
relays,
|
||||
context,
|
||||
closeApplication = application.application.closeApplication,
|
||||
onLoading = onLoading,
|
||||
onRemoveIntentData = onRemoveIntentData,
|
||||
)
|
||||
} else {
|
||||
onRemoveIntentData(intentData)
|
||||
context.getAppCompatActivity()?.intent = null
|
||||
context.getAppCompatActivity()?.finish()
|
||||
if (application.application.closeApplication) {
|
||||
context.getAppCompatActivity()?.finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user