mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-20 18:51:12 +02:00
fix zap splits and show message if user uninstall amber
This commit is contained in:
@@ -450,7 +450,8 @@ class Account(
|
|||||||
userProfile().latestContactList?.relays()?.keys?.ifEmpty { null }
|
userProfile().latestContactList?.relays()?.keys?.ifEmpty { null }
|
||||||
?: localRelays.map { it.url }.toSet(),
|
?: localRelays.map { it.url }.toSet(),
|
||||||
pollOption,
|
pollOption,
|
||||||
message
|
message,
|
||||||
|
toUser?.pubkeyHex
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
LnZapEvent.ZapType.PUBLIC -> {
|
LnZapEvent.ZapType.PUBLIC -> {
|
||||||
@@ -460,7 +461,8 @@ class Account(
|
|||||||
?: localRelays.map { it.url }.toSet(),
|
?: localRelays.map { it.url }.toSet(),
|
||||||
keyPair.pubKey.toHexKey(),
|
keyPair.pubKey.toHexKey(),
|
||||||
pollOption,
|
pollOption,
|
||||||
message
|
message,
|
||||||
|
toUser?.pubkeyHex
|
||||||
)
|
)
|
||||||
AmberUtils.openAmber(unsignedEvent)
|
AmberUtils.openAmber(unsignedEvent)
|
||||||
val content = AmberUtils.content[unsignedEvent.id] ?: ""
|
val content = AmberUtils.content[unsignedEvent.id] ?: ""
|
||||||
@@ -479,7 +481,8 @@ class Account(
|
|||||||
?: localRelays.map { it.url }.toSet(),
|
?: localRelays.map { it.url }.toSet(),
|
||||||
keyPair.pubKey.toHexKey(),
|
keyPair.pubKey.toHexKey(),
|
||||||
pollOption,
|
pollOption,
|
||||||
message
|
message,
|
||||||
|
toUser?.pubkeyHex
|
||||||
)
|
)
|
||||||
AmberUtils.openAmber(unsignedEvent, "event")
|
AmberUtils.openAmber(unsignedEvent, "event")
|
||||||
val content = AmberUtils.content[unsignedEvent.id] ?: ""
|
val content = AmberUtils.content[unsignedEvent.id] ?: ""
|
||||||
|
@@ -3,11 +3,13 @@ package com.vitorpamplona.amethyst.service
|
|||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.util.Log
|
||||||
import android.util.LruCache
|
import android.util.LruCache
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.activity.result.ActivityResultLauncher
|
import androidx.activity.result.ActivityResultLauncher
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import com.vitorpamplona.amethyst.Amethyst
|
import com.vitorpamplona.amethyst.Amethyst
|
||||||
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.ServiceManager
|
import com.vitorpamplona.amethyst.ServiceManager
|
||||||
import com.vitorpamplona.amethyst.model.Account
|
import com.vitorpamplona.amethyst.model.Account
|
||||||
import com.vitorpamplona.amethyst.model.LocalCache
|
import com.vitorpamplona.amethyst.model.LocalCache
|
||||||
@@ -49,7 +51,7 @@ object AmberUtils {
|
|||||||
GlobalScope.launch(Dispatchers.Main) {
|
GlobalScope.launch(Dispatchers.Main) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
Amethyst.instance,
|
Amethyst.instance,
|
||||||
"Sign request rejected",
|
Amethyst.instance.getString(R.string.sign_request_rejected),
|
||||||
Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
@@ -133,6 +135,7 @@ object AmberUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
fun openAmber(
|
fun openAmber(
|
||||||
data: String,
|
data: String,
|
||||||
type: SignerType,
|
type: SignerType,
|
||||||
@@ -140,6 +143,7 @@ object AmberUtils {
|
|||||||
pubKey: HexKey,
|
pubKey: HexKey,
|
||||||
id: String
|
id: String
|
||||||
) {
|
) {
|
||||||
|
try {
|
||||||
ServiceManager.shouldPauseService = false
|
ServiceManager.shouldPauseService = false
|
||||||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:$data"))
|
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:$data"))
|
||||||
val signerType = when (type) {
|
val signerType = when (type) {
|
||||||
@@ -159,6 +163,16 @@ object AmberUtils {
|
|||||||
}
|
}
|
||||||
intent.`package` = "com.greenart7c3.nostrsigner"
|
intent.`package` = "com.greenart7c3.nostrsigner"
|
||||||
intentResult.launch(intent)
|
intentResult.launch(intent)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("Amber", "Error opening amber", e)
|
||||||
|
GlobalScope.launch(Dispatchers.Main) {
|
||||||
|
Toast.makeText(
|
||||||
|
Amethyst.instance,
|
||||||
|
Amethyst.instance.getString(R.string.error_opening_amber),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun openAmber(event: EventInterface, columnName: String = "signature") {
|
fun openAmber(event: EventInterface, columnName: String = "signature") {
|
||||||
|
@@ -14,11 +14,7 @@ import androidx.compose.ui.text.input.TextFieldValue
|
|||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.fonfon.kgeohash.toGeoHash
|
import com.fonfon.kgeohash.toGeoHash
|
||||||
import com.vitorpamplona.amethyst.model.Account
|
import com.vitorpamplona.amethyst.model.*
|
||||||
import com.vitorpamplona.amethyst.model.LocalCache
|
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
|
||||||
import com.vitorpamplona.amethyst.model.ServersAvailable
|
|
||||||
import com.vitorpamplona.amethyst.model.User
|
|
||||||
import com.vitorpamplona.amethyst.service.FileHeader
|
import com.vitorpamplona.amethyst.service.FileHeader
|
||||||
import com.vitorpamplona.amethyst.service.LocationUtil
|
import com.vitorpamplona.amethyst.service.LocationUtil
|
||||||
import com.vitorpamplona.amethyst.service.NostrSearchEventOrUserDataSource
|
import com.vitorpamplona.amethyst.service.NostrSearchEventOrUserDataSource
|
||||||
@@ -168,7 +164,6 @@ open class NewPostViewModel() : ViewModel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun sendPost(relayList: List<Relay>? = null) {
|
fun sendPost(relayList: List<Relay>? = null) {
|
||||||
try {
|
|
||||||
val tagger = NewMessageTagger(message.text, mentions, replyTos, originalNote?.channelHex())
|
val tagger = NewMessageTagger(message.text, mentions, replyTos, originalNote?.channelHex())
|
||||||
tagger.run()
|
tagger.run()
|
||||||
|
|
||||||
@@ -185,6 +180,9 @@ open class NewPostViewModel() : ViewModel() {
|
|||||||
isLnAddress = false
|
isLnAddress = false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
val geoLocation = locUtil?.locationStateFlow?.value
|
val geoLocation = locUtil?.locationStateFlow?.value
|
||||||
val geoHash = if (wantsToAddGeoHash && geoLocation != null) {
|
val geoHash = if (wantsToAddGeoHash && geoLocation != null) {
|
||||||
@@ -283,19 +281,11 @@ open class NewPostViewModel() : ViewModel() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
cancel()
|
cancel()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fun upload(
|
fun upload(galleryUri: Uri, description: String, sensitiveContent: Boolean, server: ServersAvailable, context: Context, relayList: List<Relay>? = null) {
|
||||||
galleryUri: Uri,
|
|
||||||
description: String,
|
|
||||||
sensitiveContent: Boolean,
|
|
||||||
server: ServersAvailable,
|
|
||||||
context: Context,
|
|
||||||
relayList: List<Relay>? = null
|
|
||||||
) {
|
|
||||||
isUploadingImage = true
|
isUploadingImage = true
|
||||||
contentToAddUrl = null
|
contentToAddUrl = null
|
||||||
|
|
||||||
@@ -313,7 +303,6 @@ open class NewPostViewModel() : ViewModel() {
|
|||||||
createNIP95Record(it.readBytes(), contentType, description, sensitiveContent, relayList = relayList)
|
createNIP95Record(it.readBytes(), contentType, description, sensitiveContent, relayList = relayList)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
|
||||||
ImageUploader.uploadImage(
|
ImageUploader.uploadImage(
|
||||||
uri = fileUri,
|
uri = fileUri,
|
||||||
contentType = contentType,
|
contentType = contentType,
|
||||||
@@ -322,12 +311,7 @@ open class NewPostViewModel() : ViewModel() {
|
|||||||
contentResolver = contentResolver,
|
contentResolver = contentResolver,
|
||||||
onSuccess = { imageUrl, mimeType ->
|
onSuccess = { imageUrl, mimeType ->
|
||||||
if (isNIP94Server(server)) {
|
if (isNIP94Server(server)) {
|
||||||
createNIP94Record(
|
createNIP94Record(imageUrl, mimeType, description, sensitiveContent)
|
||||||
imageUrl,
|
|
||||||
mimeType,
|
|
||||||
description,
|
|
||||||
sensitiveContent
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
isUploadingImage = false
|
isUploadingImage = false
|
||||||
message = TextFieldValue(message.text + "\n\n" + imageUrl)
|
message = TextFieldValue(message.text + "\n\n" + imageUrl)
|
||||||
@@ -342,7 +326,6 @@ open class NewPostViewModel() : ViewModel() {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onError = {
|
onError = {
|
||||||
isUploadingImage = false
|
isUploadingImage = false
|
||||||
|
@@ -588,4 +588,6 @@
|
|||||||
<string name="lightning_wallets_not_found2">Lightning wallets not found</string>
|
<string name="lightning_wallets_not_found2">Lightning wallets not found</string>
|
||||||
<string name="paid">Paid</string>
|
<string name="paid">Paid</string>
|
||||||
<string name="wallet_number">Wallet %1$s</string>
|
<string name="wallet_number">Wallet %1$s</string>
|
||||||
|
<string name="error_opening_amber">Error opening Amber</string>
|
||||||
|
<string name="sign_request_rejected">Sign request rejected</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -113,11 +113,12 @@ class LnZapRequestEvent(
|
|||||||
pubKey: HexKey,
|
pubKey: HexKey,
|
||||||
pollOption: Int?,
|
pollOption: Int?,
|
||||||
message: String,
|
message: String,
|
||||||
|
toUserPubHex: String?, // Overrides in case of Zap Splits
|
||||||
createdAt: Long = TimeUtils.now()
|
createdAt: Long = TimeUtils.now()
|
||||||
): LnZapRequestEvent {
|
): LnZapRequestEvent {
|
||||||
var tags = listOf(
|
var tags = listOf(
|
||||||
listOf("e", originalNote.id()),
|
listOf("e", originalNote.id()),
|
||||||
listOf("p", originalNote.pubKey()),
|
listOf("p", toUserPubHex ?: originalNote.pubKey()),
|
||||||
listOf("relays") + relays
|
listOf("relays") + relays
|
||||||
)
|
)
|
||||||
if (originalNote is AddressableEvent) {
|
if (originalNote is AddressableEvent) {
|
||||||
@@ -137,12 +138,13 @@ class LnZapRequestEvent(
|
|||||||
pubKey: HexKey,
|
pubKey: HexKey,
|
||||||
pollOption: Int?,
|
pollOption: Int?,
|
||||||
message: String,
|
message: String,
|
||||||
|
toUserPubHex: String?,
|
||||||
createdAt: Long = TimeUtils.now()
|
createdAt: Long = TimeUtils.now()
|
||||||
): LnZapRequestEvent {
|
): LnZapRequestEvent {
|
||||||
val content = message
|
val content = message
|
||||||
var tags = listOf(
|
var tags = listOf(
|
||||||
listOf("e", originalNote.id()),
|
listOf("e", originalNote.id()),
|
||||||
listOf("p", originalNote.pubKey()),
|
listOf("p", toUserPubHex ?: originalNote.pubKey()),
|
||||||
listOf("relays") + relays
|
listOf("relays") + relays
|
||||||
)
|
)
|
||||||
if (originalNote is AddressableEvent) {
|
if (originalNote is AddressableEvent) {
|
||||||
@@ -162,11 +164,12 @@ class LnZapRequestEvent(
|
|||||||
relays: Set<String>,
|
relays: Set<String>,
|
||||||
pollOption: Int?,
|
pollOption: Int?,
|
||||||
message: String,
|
message: String,
|
||||||
|
toUserPubHex: String?, // Overrides in case of Zap Splits
|
||||||
createdAt: Long = TimeUtils.now()
|
createdAt: Long = TimeUtils.now()
|
||||||
): LnZapRequestEvent {
|
): LnZapRequestEvent {
|
||||||
var tags = listOf(
|
var tags = listOf(
|
||||||
listOf("e", originalNote.id()),
|
listOf("e", originalNote.id()),
|
||||||
listOf("p", originalNote.pubKey()),
|
listOf("p", toUserPubHex ?: originalNote.pubKey()),
|
||||||
listOf("relays") + relays
|
listOf("relays") + relays
|
||||||
)
|
)
|
||||||
if (originalNote is AddressableEvent) {
|
if (originalNote is AddressableEvent) {
|
||||||
|
Reference in New Issue
Block a user