mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-06 11:28:22 +00:00
add a paste from clipboard option, fix reject buttons when using bunker
This commit is contained in:
@@ -31,6 +31,7 @@ import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.material.icons.filled.Close
|
||||
import androidx.compose.material.icons.filled.ContentPaste
|
||||
import androidx.compose.material.icons.filled.ExpandMore
|
||||
import androidx.compose.material.icons.filled.Hub
|
||||
import androidx.compose.material.icons.filled.QrCode
|
||||
@@ -392,6 +393,61 @@ fun PermissionsFloatingActionButton(
|
||||
Column(
|
||||
horizontalAlignment = Alignment.End,
|
||||
) {
|
||||
Row(
|
||||
Modifier
|
||||
.padding(end = 10.dp)
|
||||
.clickable {
|
||||
dialogOpen = true
|
||||
expanded = false
|
||||
},
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
val clipboardManager = LocalClipboardManager.current
|
||||
RichTooltip {
|
||||
Text(stringResource(R.string.paste_from_clipboard))
|
||||
}
|
||||
Spacer(modifier = Modifier.size(4.dp))
|
||||
FloatingActionButton(
|
||||
onClick = {
|
||||
clipboardManager.getText()?.let {
|
||||
if (it.text.isBlank()) {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.invalid_nostr_connect_uri),
|
||||
Toast.LENGTH_SHORT,
|
||||
).show()
|
||||
return@let
|
||||
}
|
||||
if (!it.text.startsWith("nostrconnect://")) {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.invalid_nostr_connect_uri),
|
||||
Toast.LENGTH_SHORT,
|
||||
).show()
|
||||
return@let
|
||||
}
|
||||
|
||||
val intent = Intent(Intent.ACTION_VIEW)
|
||||
intent.data = Uri.parse(it.text)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
context.getAppCompatActivity()?.startActivity(intent)
|
||||
accountStateViewModel.switchUser(account.keyPair.pubKey.toNpub(), Route.Home.route)
|
||||
}
|
||||
expanded = false
|
||||
},
|
||||
modifier = Modifier.size(35.dp),
|
||||
shape = CircleShape,
|
||||
) {
|
||||
Icon(
|
||||
Icons.Default.ContentPaste,
|
||||
contentDescription = stringResource(R.string.paste_from_clipboard),
|
||||
tint = Color.White,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(20.dp))
|
||||
|
||||
Row(
|
||||
Modifier
|
||||
.padding(end = 10.dp)
|
||||
|
||||
+71
-34
@@ -131,13 +131,28 @@ fun SingleEventHomeScreen(
|
||||
},
|
||||
{
|
||||
if (intentData.bunkerRequest != null) {
|
||||
AmberUtils.sendBunkerError(
|
||||
account,
|
||||
intentData.bunkerRequest,
|
||||
applicationEntity?.application?.relays ?: emptyList(),
|
||||
context,
|
||||
onLoading = onLoading,
|
||||
)
|
||||
coroutineScope.launch(Dispatchers.IO) {
|
||||
val defaultRelays = NostrSigner.getInstance().settings.defaultRelays
|
||||
val savedApplication = database.applicationDao().getByKey(key)
|
||||
val relays = if (savedApplication != null) {
|
||||
savedApplication.application.relays.ifEmpty { defaultRelays }
|
||||
} else {
|
||||
intentData.bunkerRequest.relays.ifEmpty { defaultRelays }
|
||||
}
|
||||
|
||||
NostrSigner.getInstance().checkForNewRelays(
|
||||
NostrSigner.getInstance().settings.notificationType != NotificationType.DIRECT,
|
||||
relays.toSet(),
|
||||
)
|
||||
|
||||
AmberUtils.sendBunkerError(
|
||||
account,
|
||||
intentData.bunkerRequest,
|
||||
applicationEntity?.application?.relays ?: intentData.bunkerRequest.relays,
|
||||
context,
|
||||
onLoading = onLoading,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
context.getAppCompatActivity()?.intent = null
|
||||
context.getAppCompatActivity()?.finish()
|
||||
@@ -208,8 +223,19 @@ fun SingleEventHomeScreen(
|
||||
)
|
||||
}
|
||||
|
||||
val defaultRelays = NostrSigner.getInstance().settings.defaultRelays
|
||||
val savedApplication = database.applicationDao().getByKey(key)
|
||||
val relays = intentData.bunkerRequest?.relays ?: listOf()
|
||||
val relays = if (savedApplication != null) {
|
||||
savedApplication.application.relays.ifEmpty { defaultRelays }
|
||||
} else {
|
||||
intentData.bunkerRequest?.relays?.ifEmpty { defaultRelays } ?: defaultRelays
|
||||
}
|
||||
if (intentData.bunkerRequest != null) {
|
||||
NostrSigner.getInstance().checkForNewRelays(
|
||||
NostrSigner.getInstance().settings.notificationType != NotificationType.DIRECT,
|
||||
relays.toSet(),
|
||||
)
|
||||
}
|
||||
val application =
|
||||
savedApplication ?: ApplicationWithPermissions(
|
||||
application = ApplicationEntity(
|
||||
@@ -240,19 +266,19 @@ fun SingleEventHomeScreen(
|
||||
false,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
if (intentData.bunkerRequest != null) {
|
||||
AmberUtils.sendBunkerError(
|
||||
account,
|
||||
intentData.bunkerRequest,
|
||||
applicationEntity?.application?.relays ?: emptyList(),
|
||||
context,
|
||||
onLoading,
|
||||
)
|
||||
} else {
|
||||
context.getAppCompatActivity()?.intent = null
|
||||
context.getAppCompatActivity()?.finish()
|
||||
if (intentData.bunkerRequest != null) {
|
||||
AmberUtils.sendBunkerError(
|
||||
account,
|
||||
intentData.bunkerRequest,
|
||||
relays,
|
||||
context,
|
||||
onLoading,
|
||||
)
|
||||
} else {
|
||||
context.getAppCompatActivity()?.intent = null
|
||||
context.getAppCompatActivity()?.finish()
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
@@ -337,9 +363,20 @@ fun SingleEventHomeScreen(
|
||||
database,
|
||||
)
|
||||
}
|
||||
|
||||
val defaultRelays = NostrSigner.getInstance().settings.defaultRelays
|
||||
val savedApplication = database.applicationDao().getByKey(key)
|
||||
val relays = intentData.bunkerRequest?.relays ?: listOf()
|
||||
val relays = if (savedApplication != null) {
|
||||
savedApplication.application.relays.ifEmpty { defaultRelays }
|
||||
} else {
|
||||
intentData.bunkerRequest?.relays?.ifEmpty { defaultRelays } ?: defaultRelays
|
||||
}
|
||||
if (intentData.bunkerRequest != null) {
|
||||
NostrSigner.getInstance().checkForNewRelays(
|
||||
NostrSigner.getInstance().settings.notificationType != NotificationType.DIRECT,
|
||||
relays.toSet(),
|
||||
)
|
||||
}
|
||||
|
||||
val application =
|
||||
savedApplication ?: ApplicationWithPermissions(
|
||||
application = ApplicationEntity(
|
||||
@@ -370,19 +407,19 @@ fun SingleEventHomeScreen(
|
||||
false,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
if (intentData.bunkerRequest != null) {
|
||||
AmberUtils.sendBunkerError(
|
||||
account,
|
||||
intentData.bunkerRequest,
|
||||
applicationEntity?.application?.relays ?: emptyList(),
|
||||
context,
|
||||
onLoading,
|
||||
)
|
||||
} else {
|
||||
context.getAppCompatActivity()?.intent = null
|
||||
context.getAppCompatActivity()?.finish()
|
||||
if (intentData.bunkerRequest != null) {
|
||||
AmberUtils.sendBunkerError(
|
||||
account,
|
||||
intentData.bunkerRequest,
|
||||
relays,
|
||||
context,
|
||||
onLoading,
|
||||
)
|
||||
} else {
|
||||
context.getAppCompatActivity()?.intent = null
|
||||
context.getAppCompatActivity()?.finish()
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
@@ -355,4 +355,6 @@
|
||||
<string name="sign_policy_fully">I fully trust this application</string>
|
||||
<string name="sign_policy_fully_explainer">Sign automatically every request</string>
|
||||
<string name="event_kind_10050">DM relays</string>
|
||||
<string name="paste_from_clipboard">Paste from clipboard</string>
|
||||
<string name="invalid_nostr_connect_uri">Invalid nostr connect URI</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user