mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-05 19:08:23 +00:00
Show the option to never close the app when using bunker
This commit is contained in:
@@ -139,6 +139,7 @@ fun sendResult(
|
||||
appName: String? = null,
|
||||
signPolicy: Int? = null,
|
||||
onRemoveIntentData: (List<IntentData>, IntentResultType) -> Unit,
|
||||
shouldCloseApplication: Boolean? = null,
|
||||
) {
|
||||
onLoading(true)
|
||||
NostrSigner.instance.applicationIOScope.launch {
|
||||
@@ -193,7 +194,7 @@ fun sendResult(
|
||||
intentData.bunkerRequest?.secret ?: "",
|
||||
intentData.bunkerRequest?.secret != null,
|
||||
account.signPolicy,
|
||||
intentData.bunkerRequest?.closeApplication ?: true,
|
||||
shouldCloseApplication ?: intentData.bunkerRequest?.closeApplication ?: true,
|
||||
),
|
||||
permissions = mutableListOf(),
|
||||
)
|
||||
@@ -258,6 +259,9 @@ fun sendResult(
|
||||
}
|
||||
if ((intentData.bunkerRequest == null && intentData.type == SignerType.GET_PUBLIC_KEY) || (intentData.bunkerRequest != null && intentData.type == SignerType.CONNECT)) {
|
||||
application.application.isConnected = true
|
||||
shouldCloseApplication?.let {
|
||||
application.application.closeApplication = it
|
||||
}
|
||||
if (!application.permissions.any { it.type == SignerType.GET_PUBLIC_KEY.toString() }) {
|
||||
application.permissions.add(
|
||||
ApplicationPermissionsEntity(
|
||||
|
||||
@@ -29,6 +29,7 @@ import androidx.compose.material3.Checkbox
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.RadioButton
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -122,6 +123,7 @@ fun ProfilePicture(account: Account) {
|
||||
|
||||
@Composable
|
||||
fun LoginWithPubKey(
|
||||
shouldCloseApp: Boolean,
|
||||
paddingValues: PaddingValues,
|
||||
remember: MutableState<Boolean>,
|
||||
isBunkerRequest: Boolean,
|
||||
@@ -130,7 +132,7 @@ fun LoginWithPubKey(
|
||||
appName: String,
|
||||
applicationName: String?,
|
||||
permissions: List<Permission>?,
|
||||
onAccept: (List<Permission>?, Int) -> Unit,
|
||||
onAccept: (List<Permission>?, Int, Boolean?) -> Unit,
|
||||
onReject: () -> Unit,
|
||||
) {
|
||||
val localPermissions = remember {
|
||||
@@ -201,7 +203,7 @@ fun LoginWithPubKey(
|
||||
AmberButton(
|
||||
modifier = Modifier.padding(vertical = 20.dp),
|
||||
onClick = {
|
||||
onAccept(localPermissions, 1)
|
||||
onAccept(localPermissions, 1, null)
|
||||
},
|
||||
text = stringResource(R.string.grant_permissions),
|
||||
)
|
||||
@@ -272,6 +274,30 @@ fun LoginWithPubKey(
|
||||
|
||||
Spacer(modifier = Modifier.size(8.dp))
|
||||
|
||||
var closeApp by remember { mutableStateOf(shouldCloseApp) }
|
||||
if (packageName == null) {
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier
|
||||
.padding(vertical = 8.dp)
|
||||
.clickable {
|
||||
closeApp = !closeApp
|
||||
},
|
||||
) {
|
||||
Text(
|
||||
modifier = Modifier.weight(1f),
|
||||
text = stringResource(R.string.close_application),
|
||||
)
|
||||
Switch(
|
||||
checked = closeApp,
|
||||
onCheckedChange = {
|
||||
closeApp = it
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
radioOptions.forEachIndexed { index, option ->
|
||||
Row(
|
||||
Modifier
|
||||
@@ -379,7 +405,7 @@ fun LoginWithPubKey(
|
||||
AmberButton(
|
||||
modifier = Modifier.padding(vertical = 20.dp),
|
||||
onClick = {
|
||||
onAccept(localPermissions, selectedOption)
|
||||
onAccept(localPermissions, selectedOption, closeApp)
|
||||
},
|
||||
text = stringResource(R.string.grant_permissions),
|
||||
)
|
||||
|
||||
+3
-1
@@ -96,6 +96,7 @@ fun SingleEventHomeScreen(
|
||||
}
|
||||
|
||||
LoginWithPubKey(
|
||||
applicationEntity?.application?.closeApplication ?: intentData.bunkerRequest?.closeApplication ?: false,
|
||||
paddingValues,
|
||||
remember,
|
||||
intentData.bunkerRequest != null && intentData.type == SignerType.GET_PUBLIC_KEY,
|
||||
@@ -104,7 +105,7 @@ fun SingleEventHomeScreen(
|
||||
appName,
|
||||
applicationName,
|
||||
intentData.permissions,
|
||||
{ permissions, signPolicy ->
|
||||
{ permissions, signPolicy, closeApplication ->
|
||||
val sig =
|
||||
if (intentData.type == SignerType.CONNECT) {
|
||||
intentData.bunkerRequest!!.nostrConnectSecret.ifBlank { "ack" }
|
||||
@@ -132,6 +133,7 @@ fun SingleEventHomeScreen(
|
||||
onLoading = onLoading,
|
||||
signPolicy = signPolicy,
|
||||
onRemoveIntentData = onRemoveIntentData,
|
||||
shouldCloseApplication = closeApplication,
|
||||
)
|
||||
|
||||
return@LoginWithPubKey
|
||||
|
||||
Reference in New Issue
Block a user