diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 000000000..103e00cbe
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt b/app/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt
index ae385c310..678602bbd 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt
@@ -36,7 +36,7 @@ private const val DEBUG_PREFERENCES_NAME = "debug_prefs"
data class AccountInfo(
val npub: String,
val hasPrivKey: Boolean,
- val loggedInWithAmber: Boolean
+ val loggedInWithExternalSigner: Boolean
)
private object PrefKeys {
@@ -75,7 +75,7 @@ private object PrefKeys {
const val THEME = "theme"
const val PREFERRED_LANGUAGE = "preferred_Language"
const val AUTOMATICALLY_LOAD_URL_PREVIEW = "automatically_load_url_preview"
- const val LOGIN_WITH_AMBER = "login_with_amber"
+ const val LOGIN_WITH_EXTERNAL_SIGNER = "login_with_external_signer"
val LAST_READ: (String) -> String = { route -> "last_read_route_$route" }
}
@@ -206,7 +206,7 @@ object LocalPreferences {
AccountInfo(
npub,
hasPrivKey(npub),
- getLoggedInWithAmber(npub)
+ getLoggedInWithExternalSigner(npub)
)
}
}
@@ -251,7 +251,7 @@ object LocalPreferences {
} else {
putBoolean(PrefKeys.SHOW_SENSITIVE_CONTENT, account.showSensitiveContent!!)
}
- putBoolean(PrefKeys.LOGIN_WITH_AMBER, account.loginWithAmber)
+ putBoolean(PrefKeys.LOGIN_WITH_EXTERNAL_SIGNER, account.loginWithExternalSigner)
}.apply()
val globalPrefs = encryptedPreferences()
@@ -283,33 +283,19 @@ object LocalPreferences {
}
fun getTheme(): Int {
- encryptedPreferences().apply {
- return getInt(PrefKeys.THEME, 0)
- }
+ return encryptedPreferences().getInt(PrefKeys.THEME, 0)
}
fun getPreferredLanguage(): String {
- var language = ""
- encryptedPreferences().apply {
- language = getString(PrefKeys.PREFERRED_LANGUAGE, "") ?: ""
- }
- return language
+ return encryptedPreferences().getString(PrefKeys.PREFERRED_LANGUAGE, "") ?: ""
}
- private fun getLoggedInWithAmber(npub: String): Boolean {
- var loggedInWithAmber: Boolean
- encryptedPreferences(npub).apply {
- loggedInWithAmber = getBoolean(PrefKeys.LOGIN_WITH_AMBER, false)
- }
- return loggedInWithAmber
+ private fun getLoggedInWithExternalSigner(npub: String): Boolean {
+ return encryptedPreferences(npub).getBoolean(PrefKeys.LOGIN_WITH_EXTERNAL_SIGNER, false)
}
private fun hasPrivKey(npub: String): Boolean {
- var hasPrivKey: Boolean
- encryptedPreferences(npub).apply {
- hasPrivKey = (getString(PrefKeys.NOSTR_PRIVKEY, "") ?: "").isNotBlank()
- }
- return hasPrivKey
+ return (encryptedPreferences(npub).getString(PrefKeys.NOSTR_PRIVKEY, "") ?: "").isNotBlank()
}
fun loadFromEncryptedStorage(): Account? {
@@ -386,7 +372,7 @@ object LocalPreferences {
val useProxy = getBoolean(PrefKeys.USE_PROXY, false)
val proxyPort = getInt(PrefKeys.PROXY_PORT, 9050)
val proxy = HttpClient.initProxy(useProxy, "127.0.0.1", proxyPort)
- val loginWithAmber = getBoolean(PrefKeys.LOGIN_WITH_AMBER, false)
+ val loginWithExternalSigner = getBoolean(PrefKeys.LOGIN_WITH_EXTERNAL_SIGNER, false)
val showSensitiveContent = if (contains(PrefKeys.SHOW_SENSITIVE_CONTENT)) {
getBoolean(PrefKeys.SHOW_SENSITIVE_CONTENT, false)
@@ -456,7 +442,7 @@ object LocalPreferences {
filterSpamFromStrangers = filterSpam,
lastReadPerRoute = lastReadPerRoute,
settings = settings,
- loginWithAmber = loginWithAmber
+ loginWithExternalSigner = loginWithExternalSigner
)
return a
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ServiceManager.kt b/app/src/main/java/com/vitorpamplona/amethyst/ServiceManager.kt
index 83275d591..3fccace90 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ServiceManager.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ServiceManager.kt
@@ -12,7 +12,7 @@ import coil.disk.DiskCache
import coil.util.DebugLogger
import com.vitorpamplona.amethyst.model.Account
import com.vitorpamplona.amethyst.model.LocalCache
-import com.vitorpamplona.amethyst.service.AmberUtils
+import com.vitorpamplona.amethyst.service.ExternalSignerUtils
import com.vitorpamplona.amethyst.service.HttpClient
import com.vitorpamplona.amethyst.service.NostrAccountDataSource
import com.vitorpamplona.amethyst.service.NostrChannelDataSource
@@ -42,7 +42,7 @@ object ServiceManager {
fun start(account: Account, context: Context) {
this.account = account
- AmberUtils.account = account
+ ExternalSignerUtils.account = account
start(context)
}
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/model/Account.kt b/app/src/main/java/com/vitorpamplona/amethyst/model/Account.kt
index 04a13ae20..15ca50074 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/model/Account.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/model/Account.kt
@@ -8,7 +8,7 @@ import androidx.core.os.ConfigurationCompat
import androidx.lifecycle.LiveData
import androidx.lifecycle.distinctUntilChanged
import com.vitorpamplona.amethyst.OptOutFromFilters
-import com.vitorpamplona.amethyst.service.AmberUtils
+import com.vitorpamplona.amethyst.service.ExternalSignerUtils
import com.vitorpamplona.amethyst.service.FileHeader
import com.vitorpamplona.amethyst.service.NostrLnZapPaymentResponseDataSource
import com.vitorpamplona.amethyst.service.SignerType
@@ -87,7 +87,7 @@ class Account(
var filterSpamFromStrangers: Boolean = true,
var lastReadPerRoute: Map = mapOf(),
var settings: Settings = Settings(),
- var loginWithAmber: Boolean = false
+ var loginWithExternalSigner: Boolean = false
) {
var transientHiddenUsers: ImmutableSet = persistentSetOf()
@@ -107,19 +107,19 @@ class Account(
val liveHiddenUsers: LiveData by lazy {
live.combineWith(getBlockListNote().live().metadata) { localLive, liveMuteListEvent ->
val blockList = liveMuteListEvent?.note?.event as? PeopleListEvent
- if (loginWithAmber) {
+ if (loginWithExternalSigner) {
val id = blockList?.id
if (id != null) {
if (blockList.decryptedContent == null) {
GlobalScope.launch(Dispatchers.IO) {
val content = blockList.content
if (content.isEmpty()) return@launch
- AmberUtils.decryptBlockList(
+ ExternalSignerUtils.decryptBlockList(
content,
keyPair.pubKey.toHexKey(),
blockList.id()
)
- blockList.decryptedContent = AmberUtils.cachedDecryptedContent[blockList.id]
+ blockList.decryptedContent = ExternalSignerUtils.cachedDecryptedContent[blockList.id]
live.invalidateData()
}
@@ -130,7 +130,7 @@ class Account(
showSensitiveContent = showSensitiveContent
)
} else {
- blockList.decryptedContent = AmberUtils.cachedDecryptedContent[blockList.id]
+ blockList.decryptedContent = ExternalSignerUtils.cachedDecryptedContent[blockList.id]
val liveBlockedUsers = blockList.publicAndPrivateUsers(blockList.decryptedContent ?: "")
LiveHiddenUsers(
hiddenUsers = liveBlockedUsers,
@@ -208,7 +208,7 @@ class Account(
}
fun sendNewRelayList(relays: Map) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
val contactList = userProfile().latestContactList
@@ -219,9 +219,9 @@ class Account(
keyPair = keyPair
)
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val content = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val content = ExternalSignerUtils.content[event.id] ?: ""
if (content.isBlank()) {
return
}
@@ -241,9 +241,9 @@ class Account(
keyPair = keyPair
)
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val content = AmberUtils.content[event.id]
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val content = ExternalSignerUtils.content[event.id]
if (content.isBlank()) {
return
}
@@ -257,11 +257,11 @@ class Account(
}
fun sendNewUserMetadata(toString: String, identities: List) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
var event = MetadataEvent.create(toString, identities, keyPair.pubKey.toHexKey(), keyPair.privKey)
- if (loginWithAmber) {
- val content = AmberUtils.content[event.id]
+ if (loginWithExternalSigner) {
+ val content = ExternalSignerUtils.content[event.id]
if (content.isBlank()) {
return
}
@@ -290,7 +290,7 @@ class Account(
}
fun reactTo(note: Note, reaction: String) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
if (hasReacted(note, reaction)) {
// has already liked this note
@@ -305,7 +305,7 @@ class Account(
val emojiUrl = EmojiUrl.decode(reaction)
if (emojiUrl != null) {
note.event?.let {
- if (loginWithAmber) {
+ if (loginWithExternalSigner) {
val senderPublicKey = keyPair.pubKey.toHexKey()
var senderReaction = ReactionEvent.create(
@@ -314,24 +314,24 @@ class Account(
keyPair
)
- AmberUtils.openAmber(senderReaction)
- val reactionContent = AmberUtils.content[event.id]
+ ExternalSignerUtils.openSigner(senderReaction)
+ val reactionContent = ExternalSignerUtils.content[event.id]
if (reactionContent.isBlank()) return
senderReaction = ReactionEvent.create(senderReaction, reactionContent)
val giftWraps = users.plus(senderPublicKey).map {
val gossip = Gossip.create(senderReaction)
val content = Gossip.toJson(gossip)
- AmberUtils.encrypt(content, it, gossip.id!!, SignerType.NIP44_ENCRYPT)
- val encryptedContent = AmberUtils.content[gossip.id]
+ ExternalSignerUtils.encrypt(content, it, gossip.id!!, SignerType.NIP44_ENCRYPT)
+ val encryptedContent = ExternalSignerUtils.content[gossip.id]
if (encryptedContent.isBlank()) return
var sealedEvent = SealedGossipEvent.create(
encryptedContent = encryptedContent,
pubKey = senderPublicKey
)
- AmberUtils.openAmber(sealedEvent)
- val eventContent = AmberUtils.content[sealedEvent.id] ?: ""
+ ExternalSignerUtils.openSigner(sealedEvent)
+ val eventContent = ExternalSignerUtils.content[sealedEvent.id] ?: ""
if (eventContent.isBlank()) return
sealedEvent = SealedGossipEvent.create(sealedEvent, eventContent)
@@ -358,7 +358,7 @@ class Account(
}
note.event?.let {
- if (loginWithAmber) {
+ if (loginWithExternalSigner) {
val senderPublicKey = keyPair.pubKey.toHexKey()
var senderReaction = ReactionEvent.create(
@@ -367,8 +367,8 @@ class Account(
keyPair
)
- AmberUtils.openAmber(senderReaction)
- val reactionContent = AmberUtils.content[senderReaction.id] ?: ""
+ ExternalSignerUtils.openSigner(senderReaction)
+ val reactionContent = ExternalSignerUtils.content[senderReaction.id] ?: ""
if (reactionContent.isBlank()) return
senderReaction = ReactionEvent.create(senderReaction, reactionContent)
@@ -376,16 +376,16 @@ class Account(
newUsers.forEach {
val gossip = Gossip.create(senderReaction)
val content = Gossip.toJson(gossip)
- AmberUtils.encrypt(content, it, gossip.id!!, SignerType.NIP44_ENCRYPT)
- val encryptedContent = AmberUtils.content[gossip.id]
+ ExternalSignerUtils.encrypt(content, it, gossip.id!!, SignerType.NIP44_ENCRYPT)
+ val encryptedContent = ExternalSignerUtils.content[gossip.id]
if (encryptedContent.isBlank()) return
var sealedEvent = SealedGossipEvent.create(
encryptedContent = encryptedContent,
pubKey = senderPublicKey
)
- AmberUtils.openAmber(sealedEvent)
- val sealedContent = AmberUtils.content[sealedEvent.id] ?: ""
+ ExternalSignerUtils.openSigner(sealedEvent)
+ val sealedContent = ExternalSignerUtils.content[sealedEvent.id] ?: ""
if (sealedContent.isBlank()) return
sealedEvent = SealedGossipEvent.create(sealedEvent, sealedContent)
@@ -414,9 +414,9 @@ class Account(
if (emojiUrl != null) {
note.event?.let {
var event = ReactionEvent.create(emojiUrl, it, keyPair)
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val content = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val content = ExternalSignerUtils.content[event.id] ?: ""
if (content.isBlank()) {
return
}
@@ -432,9 +432,9 @@ class Account(
note.event?.let {
var event = ReactionEvent.create(reaction, it, keyPair)
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val content = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val content = ExternalSignerUtils.content[event.id] ?: ""
if (content.isBlank()) {
return
}
@@ -447,10 +447,10 @@ class Account(
}
fun createZapRequestFor(note: Note, pollOption: Int?, message: String = "", zapType: LnZapEvent.ZapType, toUser: User?): LnZapRequestEvent? {
- if (!isWriteable() && !loginWithAmber) return null
+ if (!isWriteable() && !loginWithExternalSigner) return null
note.event?.let { event ->
- if (loginWithAmber) {
+ if (loginWithExternalSigner) {
when (zapType) {
LnZapEvent.ZapType.ANONYMOUS -> {
return LnZapRequestEvent.createAnonymous(
@@ -472,8 +472,8 @@ class Account(
message,
toUser?.pubkeyHex
)
- AmberUtils.openAmber(unsignedEvent)
- val content = AmberUtils.content[unsignedEvent.id] ?: ""
+ ExternalSignerUtils.openSigner(unsignedEvent)
+ val content = ExternalSignerUtils.content[unsignedEvent.id] ?: ""
if (content.isBlank()) return null
return LnZapRequestEvent.create(
@@ -492,8 +492,8 @@ class Account(
message,
toUser?.pubkeyHex
)
- AmberUtils.openAmber(unsignedEvent, "event")
- val content = AmberUtils.content[unsignedEvent.id] ?: ""
+ ExternalSignerUtils.openSigner(unsignedEvent, "event")
+ val content = ExternalSignerUtils.content[unsignedEvent.id] ?: ""
if (content.isBlank()) return null
return Event.fromJson(content) as LnZapRequestEvent
@@ -523,7 +523,7 @@ class Account(
fun isNIP47Author(pubkeyHex: String?): Boolean {
val privKey = zapPaymentRequest?.secret?.hexToByteArray() ?: keyPair.privKey
- if (privKey == null && !loginWithAmber) return false
+ if (privKey == null && !loginWithExternalSigner) return false
if (privKey != null) {
val pubKey = CryptoUtils.pubkeyCreate(privKey).toHexKey()
@@ -539,12 +539,12 @@ class Account(
val privKey = myNip47.secret?.hexToByteArray() ?: keyPair.privKey
val pubKey = myNip47.pubKeyHex.hexToByteArray()
- if (privKey == null && !loginWithAmber) return null
+ if (privKey == null && !loginWithExternalSigner) return null
if (privKey != null) return zapResponseEvent.response(privKey, pubKey)
- AmberUtils.decrypt(zapResponseEvent.content, pubKey.toHexKey(), zapResponseEvent.id)
- val decryptedContent = AmberUtils.content[zapResponseEvent.id] ?: ""
+ ExternalSignerUtils.decrypt(zapResponseEvent.content, pubKey.toHexKey(), zapResponseEvent.id)
+ val decryptedContent = ExternalSignerUtils.content[zapResponseEvent.id] ?: ""
if (decryptedContent.isBlank()) return null
return zapResponseEvent.response(decryptedContent)
}
@@ -560,10 +560,10 @@ class Account(
}
fun sendZapPaymentRequestFor(bolt11: String, zappedNote: Note?, onResponse: (Response?) -> Unit) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
zapPaymentRequest?.let { nip47 ->
- val privateKey = if (loginWithAmber) nip47.secret?.hexToByteArray() else nip47.secret?.hexToByteArray() ?: keyPair.privKey
+ val privateKey = if (loginWithExternalSigner) nip47.secret?.hexToByteArray() else nip47.secret?.hexToByteArray() ?: keyPair.privKey
if (privateKey == null) return
val event = LnZapPaymentRequestEvent.create(bolt11, nip47.pubKeyHex, privateKey)
@@ -594,8 +594,8 @@ class Account(
}
fun createZapRequestFor(userPubKeyHex: String, message: String = "", zapType: LnZapEvent.ZapType): LnZapRequestEvent? {
- if (!isWriteable() && !loginWithAmber) return null
- if (loginWithAmber) {
+ if (!isWriteable() && !loginWithExternalSigner) return null
+ if (loginWithExternalSigner) {
return when (zapType) {
LnZapEvent.ZapType.ANONYMOUS -> {
return LnZapRequestEvent.createAnonymous(
@@ -613,8 +613,8 @@ class Account(
keyPair.pubKey.toHexKey(),
message
)
- AmberUtils.openAmber(unsignedEvent)
- val content = AmberUtils.content[unsignedEvent.id] ?: ""
+ ExternalSignerUtils.openSigner(unsignedEvent)
+ val content = ExternalSignerUtils.content[unsignedEvent.id] ?: ""
if (content.isBlank()) return null
return LnZapRequestEvent.create(
@@ -631,8 +631,8 @@ class Account(
keyPair.pubKey.toHexKey(),
message
)
- AmberUtils.openAmber(unsignedEvent, "event")
- val content = AmberUtils.content[unsignedEvent.id] ?: ""
+ ExternalSignerUtils.openSigner(unsignedEvent, "event")
+ val content = ExternalSignerUtils.content[unsignedEvent.id] ?: ""
if (content.isBlank()) return null
return Event.fromJson(content) as LnZapRequestEvent
@@ -652,7 +652,7 @@ class Account(
}
fun report(note: Note, type: ReportEvent.ReportType, content: String = "") {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
if (note.hasReacted(userProfile(), "⚠️")) {
// has already liked this note
@@ -661,9 +661,9 @@ class Account(
note.event?.let {
var event = ReactionEvent.createWarning(it, keyPair)
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) return
event = ReactionEvent(
event.id,
@@ -680,9 +680,9 @@ class Account(
note.event?.let {
var event = ReportEvent.create(it, type, keyPair, content = content)
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) return
event = ReportEvent(
event.id,
@@ -699,7 +699,7 @@ class Account(
}
fun report(user: User, type: ReportEvent.ReportType) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
if (user.hasReport(userProfile(), type)) {
// has already reported this note
@@ -707,9 +707,9 @@ class Account(
}
var event = ReportEvent.create(user.pubkeyHex, type, keyPair)
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) return
event = ReportEvent(
event.id,
@@ -729,15 +729,15 @@ class Account(
}
fun delete(notes: List) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
val myNotes = notes.filter { it.author == userProfile() }.map { it.idHex }
if (myNotes.isNotEmpty()) {
var event = DeletionEvent.create(myNotes, keyPair)
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) return
event = DeletionEvent(
event.id,
@@ -754,12 +754,12 @@ class Account(
}
fun createHTTPAuthorization(url: String, method: String, body: String? = null): HTTPAuthorizationEvent? {
- if (!isWriteable() && !loginWithAmber) return null
+ if (!isWriteable() && !loginWithExternalSigner) return null
var event = HTTPAuthorizationEvent.create(url, method, body, keyPair)
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) {
return null
}
@@ -769,7 +769,7 @@ class Account(
}
fun boost(note: Note) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
if (note.hasBoostedInTheLast5Minutes(userProfile())) {
// has already bosted in the past 5mins
@@ -779,9 +779,9 @@ class Account(
note.event?.let {
if (it.kind() == 1) {
var event = RepostEvent.create(it, keyPair)
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) return
event = RepostEvent(
event.id,
@@ -796,9 +796,9 @@ class Account(
LocalCache.consume(event)
} else {
var event = GenericRepostEvent.create(it, keyPair)
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) return
event = GenericRepostEvent(
event.id,
@@ -835,14 +835,14 @@ class Account(
if (followingCommunities.isNotEmpty()) {
followingCommunities.forEach {
ATag.parse(it, null)?.let {
- if (loginWithAmber) {
+ if (loginWithExternalSigner) {
val unsignedEvent = ContactListEvent.followAddressableEvent(
returningContactList,
it,
keyPair
)
- AmberUtils.openAmber(unsignedEvent)
- val eventContent = AmberUtils.content[unsignedEvent.id] ?: ""
+ ExternalSignerUtils.openSigner(unsignedEvent)
+ val eventContent = ExternalSignerUtils.content[unsignedEvent.id] ?: ""
returningContactList = if (eventContent.isBlank()) {
latestContactList
} else {
@@ -871,7 +871,7 @@ class Account(
}
fun follow(user: User) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
val contactList = migrateCommunitiesAndChannelsIfNeeded(userProfile().latestContactList)
@@ -889,9 +889,9 @@ class Account(
)
}
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -903,7 +903,7 @@ class Account(
}
fun follow(channel: Channel) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
val contactList = migrateCommunitiesAndChannelsIfNeeded(userProfile().latestContactList)
@@ -921,9 +921,9 @@ class Account(
)
}
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -935,7 +935,7 @@ class Account(
}
fun follow(community: AddressableNote) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
val contactList = migrateCommunitiesAndChannelsIfNeeded(userProfile().latestContactList)
@@ -954,9 +954,9 @@ class Account(
)
}
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -968,7 +968,7 @@ class Account(
}
fun followHashtag(tag: String) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
val contactList = migrateCommunitiesAndChannelsIfNeeded(userProfile().latestContactList)
@@ -990,9 +990,9 @@ class Account(
)
}
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -1004,7 +1004,7 @@ class Account(
}
fun followGeohash(geohash: String) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
val contactList = migrateCommunitiesAndChannelsIfNeeded(userProfile().latestContactList)
@@ -1026,9 +1026,9 @@ class Account(
)
}
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -1040,7 +1040,7 @@ class Account(
}
fun unfollow(user: User) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
val contactList = migrateCommunitiesAndChannelsIfNeeded(userProfile().latestContactList)
@@ -1051,9 +1051,9 @@ class Account(
keyPair
)
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -1066,7 +1066,7 @@ class Account(
}
fun unfollowHashtag(tag: String) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
val contactList = migrateCommunitiesAndChannelsIfNeeded(userProfile().latestContactList)
@@ -1077,9 +1077,9 @@ class Account(
keyPair
)
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -1092,7 +1092,7 @@ class Account(
}
fun unfollowGeohash(geohash: String) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
val contactList = migrateCommunitiesAndChannelsIfNeeded(userProfile().latestContactList)
@@ -1103,9 +1103,9 @@ class Account(
keyPair
)
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -1118,7 +1118,7 @@ class Account(
}
fun unfollow(channel: Channel) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
val contactList = migrateCommunitiesAndChannelsIfNeeded(userProfile().latestContactList)
@@ -1129,9 +1129,9 @@ class Account(
keyPair
)
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -1144,7 +1144,7 @@ class Account(
}
fun unfollow(community: AddressableNote) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
val contactList = migrateCommunitiesAndChannelsIfNeeded(userProfile().latestContactList)
@@ -1155,9 +1155,9 @@ class Account(
keyPair
)
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -1170,17 +1170,17 @@ class Account(
}
fun createNip95(byteArray: ByteArray, headerInfo: FileHeader): Pair? {
- if (!isWriteable() && !loginWithAmber) return null
+ if (!isWriteable() && !loginWithExternalSigner) return null
- if (loginWithAmber) {
+ if (loginWithExternalSigner) {
val unsignedData = FileStorageEvent.create(
mimeType = headerInfo.mimeType ?: "",
data = byteArray,
pubKey = keyPair.pubKey.toHexKey()
)
- AmberUtils.openAmber(unsignedData)
- val eventContent = AmberUtils.content[unsignedData.id] ?: ""
+ ExternalSignerUtils.openSigner(unsignedData)
+ val eventContent = ExternalSignerUtils.content[unsignedData.id] ?: ""
if (eventContent.isBlank()) return null
val data = FileStorageEvent(
unsignedData.id,
@@ -1203,8 +1203,8 @@ class Account(
pubKey = keyPair.pubKey.toHexKey()
)
- AmberUtils.openAmber(unsignedEvent)
- val unsignedEventContent = AmberUtils.content[unsignedEvent.id] ?: ""
+ ExternalSignerUtils.openSigner(unsignedEvent)
+ val unsignedEventContent = ExternalSignerUtils.content[unsignedEvent.id] ?: ""
if (unsignedEventContent.isBlank()) return null
val signedEvent = FileStorageHeaderEvent(
unsignedEvent.id,
@@ -1240,7 +1240,7 @@ class Account(
}
fun sendNip95(data: FileStorageEvent, signedEvent: FileStorageHeaderEvent, relayList: List? = null): Note? {
- if (!isWriteable() && !loginWithAmber) return null
+ if (!isWriteable() && !loginWithExternalSigner) return null
Client.send(data, relayList = relayList)
LocalCache.consume(data, null)
@@ -1259,9 +1259,9 @@ class Account(
}
fun sendHeader(headerInfo: FileHeader, relayList: List? = null): Note? {
- if (!isWriteable() && !loginWithAmber) return null
+ if (!isWriteable() && !loginWithExternalSigner) return null
- if (loginWithAmber) {
+ if (loginWithExternalSigner) {
val unsignedEvent = FileHeaderEvent.create(
url = headerInfo.url,
mimeType = headerInfo.mimeType,
@@ -1273,8 +1273,8 @@ class Account(
sensitiveContent = headerInfo.sensitiveContent,
keyPair = keyPair
)
- AmberUtils.openAmber(unsignedEvent)
- val eventContent = AmberUtils.content[unsignedEvent.id] ?: ""
+ ExternalSignerUtils.openSigner(unsignedEvent)
+ val eventContent = ExternalSignerUtils.content[unsignedEvent.id] ?: ""
if (eventContent.isBlank()) return null
val signedEvent = FileHeaderEvent(
unsignedEvent.id,
@@ -1317,7 +1317,7 @@ class Account(
relayList: List? = null,
geohash: String? = null
) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
val repliesToHex = replyTo?.filter { it.address() == null }?.map { it.idHex }
val mentionsHex = mentions?.map { it.pubkeyHex }
@@ -1339,9 +1339,9 @@ class Account(
keyPair = keyPair
)
- if (loginWithAmber) {
- AmberUtils.openAmber(signedEvent)
- val eventContent = AmberUtils.content[signedEvent.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(signedEvent)
+ val eventContent = ExternalSignerUtils.content[signedEvent.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -1384,7 +1384,7 @@ class Account(
relayList: List? = null,
geohash: String? = null
) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
val repliesToHex = replyTo?.map { it.idHex }
val mentionsHex = mentions?.map { it.pubkeyHex }
@@ -1409,9 +1409,9 @@ class Account(
)
// println("Sending new PollNoteEvent: %s".format(signedEvent.toJson()))
- if (loginWithAmber) {
- AmberUtils.openAmber(signedEvent)
- val eventContent = AmberUtils.content[signedEvent.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(signedEvent)
+ val eventContent = ExternalSignerUtils.content[signedEvent.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -1434,7 +1434,7 @@ class Account(
}
fun sendChannelMessage(message: String, toChannel: String, replyTo: List?, mentions: List?, zapReceiver: List? = null, wantsToMarkAsSensitive: Boolean, zapRaiserAmount: Long? = null, geohash: String? = null) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
// val repliesToHex = listOfNotNull(replyingTo?.idHex).ifEmpty { null }
val repliesToHex = replyTo?.map { it.idHex }
@@ -1452,9 +1452,9 @@ class Account(
keyPair = keyPair
)
- if (loginWithAmber) {
- AmberUtils.openAmber(signedEvent)
- val eventContent = AmberUtils.content[signedEvent.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(signedEvent)
+ val eventContent = ExternalSignerUtils.content[signedEvent.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -1466,7 +1466,7 @@ class Account(
}
fun sendLiveMessage(message: String, toChannel: ATag, replyTo: List?, mentions: List?, zapReceiver: List? = null, wantsToMarkAsSensitive: Boolean, zapRaiserAmount: Long? = null, geohash: String? = null) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
// val repliesToHex = listOfNotNull(replyingTo?.idHex).ifEmpty { null }
val repliesToHex = replyTo?.map { it.idHex }
@@ -1484,9 +1484,9 @@ class Account(
keyPair = keyPair
)
- if (loginWithAmber) {
- AmberUtils.openAmber(signedEvent)
- val eventContent = AmberUtils.content[signedEvent.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(signedEvent)
+ val eventContent = ExternalSignerUtils.content[signedEvent.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -1502,18 +1502,18 @@ class Account(
}
fun sendPrivateMessage(message: String, toUser: HexKey, replyingTo: Note? = null, mentions: List?, zapReceiver: List? = null, wantsToMarkAsSensitive: Boolean, zapRaiserAmount: Long? = null, geohash: String? = null) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
val repliesToHex = listOfNotNull(replyingTo?.idHex).ifEmpty { null }
val mentionsHex = mentions?.map { it.pubkeyHex }
var localMessage = message
- if (loginWithAmber) {
- AmberUtils.encrypt(localMessage, toUser, "encrypt")
- val eventContent = AmberUtils.content["encrypt"] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.encrypt(localMessage, toUser, "encrypt")
+ val eventContent = ExternalSignerUtils.content["encrypt"] ?: ""
if (eventContent.isBlank()) return
localMessage = eventContent
- AmberUtils.content.remove("encrypt")
+ ExternalSignerUtils.content.remove("encrypt")
}
var signedEvent = PrivateDmEvent.create(
@@ -1530,9 +1530,9 @@ class Account(
advertiseNip18 = false
)
- if (loginWithAmber) {
- AmberUtils.openAmber(signedEvent)
- val eventContent = AmberUtils.content[signedEvent.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(signedEvent)
+ val eventContent = ExternalSignerUtils.content[signedEvent.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -1554,12 +1554,12 @@ class Account(
zapRaiserAmount: Long? = null,
geohash: String? = null
) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
val repliesToHex = listOfNotNull(replyingTo?.idHex).ifEmpty { null }
val mentionsHex = mentions?.map { it.pubkeyHex }
- if (loginWithAmber) {
+ if (loginWithExternalSigner) {
var chatMessageEvent = ChatMessageEvent.create(
msg = message,
to = toUsers,
@@ -1573,23 +1573,23 @@ class Account(
geohash = geohash
)
- AmberUtils.openAmber(chatMessageEvent)
- val eventContent = AmberUtils.content[chatMessageEvent.id] ?: ""
+ ExternalSignerUtils.openSigner(chatMessageEvent)
+ val eventContent = ExternalSignerUtils.content[chatMessageEvent.id] ?: ""
if (eventContent.isBlank()) return
chatMessageEvent = ChatMessageEvent.create(chatMessageEvent, eventContent)
val senderPublicKey = keyPair.pubKey.toHexKey()
toUsers.plus(senderPublicKey).toSet().forEach {
val gossip = Gossip.create(chatMessageEvent)
val content = Gossip.toJson(gossip)
- AmberUtils.encrypt(content, it, gossip.id!!, SignerType.NIP44_ENCRYPT)
- val gossipContent = AmberUtils.content[gossip.id] ?: ""
+ ExternalSignerUtils.encrypt(content, it, gossip.id!!, SignerType.NIP44_ENCRYPT)
+ val gossipContent = ExternalSignerUtils.content[gossip.id] ?: ""
if (gossipContent.isNotBlank()) {
var sealedEvent = SealedGossipEvent.create(
encryptedContent = gossipContent,
pubKey = senderPublicKey
)
- AmberUtils.openAmber(sealedEvent)
- val sealedEventContent = AmberUtils.content[sealedEvent.id] ?: ""
+ ExternalSignerUtils.openSigner(sealedEvent)
+ val sealedEventContent = ExternalSignerUtils.content[sealedEvent.id] ?: ""
if (sealedEventContent.isBlank()) return
sealedEvent = SealedGossipEvent.create(sealedEvent, sealedEventContent)
@@ -1624,14 +1624,14 @@ class Account(
// Only keep in cache the GiftWrap for the account.
if (it.recipientPubKey() == keyPair.pubKey.toHexKey()) {
- if (loginWithAmber) {
- AmberUtils.decrypt(it.content, it.pubKey, it.id, SignerType.NIP44_DECRYPT)
- val decryptedContent = AmberUtils.cachedDecryptedContent[it.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.decrypt(it.content, it.pubKey, it.id, SignerType.NIP44_DECRYPT)
+ val decryptedContent = ExternalSignerUtils.cachedDecryptedContent[it.id] ?: ""
if (decryptedContent.isEmpty()) return
it.cachedGift(keyPair.pubKey, decryptedContent)?.let { cached ->
if (cached is SealedGossipEvent) {
- AmberUtils.decrypt(cached.content, cached.pubKey, cached.id, SignerType.NIP44_DECRYPT)
- val localDecryptedContent = AmberUtils.cachedDecryptedContent[cached.id] ?: ""
+ ExternalSignerUtils.decrypt(cached.content, cached.pubKey, cached.id, SignerType.NIP44_DECRYPT)
+ val localDecryptedContent = ExternalSignerUtils.cachedDecryptedContent[cached.id] ?: ""
if (localDecryptedContent.isEmpty()) return
cached.cachedGossip(keyPair.pubKey, localDecryptedContent)?.let { gossip ->
LocalCache.justConsume(gossip, null)
@@ -1658,7 +1658,7 @@ class Account(
}
fun sendCreateNewChannel(name: String, about: String, picture: String) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
val metadata = ChannelCreateEvent.ChannelData(
name,
@@ -1671,9 +1671,9 @@ class Account(
keyPair = keyPair
)
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -1689,13 +1689,13 @@ class Account(
}
fun updateStatus(oldStatus: AddressableNote, newStatus: String) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
val oldEvent = oldStatus.event as? StatusEvent ?: return
var event = StatusEvent.update(oldEvent, newStatus, keyPair)
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -1706,12 +1706,12 @@ class Account(
}
fun createStatus(newStatus: String) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
var event = StatusEvent.create(newStatus, "general", expiration = null, keyPair)
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -1722,13 +1722,13 @@ class Account(
}
fun deleteStatus(oldStatus: AddressableNote) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
val oldEvent = oldStatus.event as? StatusEvent ?: return
var event = StatusEvent.clear(oldEvent, keyPair)
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -1738,9 +1738,9 @@ class Account(
LocalCache.consume(event, null)
var event2 = DeletionEvent.create(listOf(event.id), keyPair)
- if (loginWithAmber) {
- AmberUtils.openAmber(event2)
- val event2Content = AmberUtils.content[event2.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event2)
+ val event2Content = ExternalSignerUtils.content[event2.id] ?: ""
if (event2Content.isBlank()) {
return
}
@@ -1751,7 +1751,7 @@ class Account(
}
fun removeEmojiPack(usersEmojiList: Note, emojiList: Note) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
val noteEvent = usersEmojiList.event
if (noteEvent !is EmojiPackSelectionEvent) return
@@ -1763,9 +1763,9 @@ class Account(
keyPair
)
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -1777,7 +1777,7 @@ class Account(
}
fun addEmojiPack(usersEmojiList: Note, emojiList: Note) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
val emojiListEvent = emojiList.event
if (emojiListEvent !is EmojiPackEvent) return
@@ -1800,9 +1800,9 @@ class Account(
)
}
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -1840,9 +1840,9 @@ class Account(
}
val msg = Event.mapper.writeValueAsString(privTags)
- AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), "encrypt")
- val encryptedContent = AmberUtils.content["encrypt"] ?: ""
- AmberUtils.content.remove("encrypt")
+ ExternalSignerUtils.encrypt(msg, keyPair.pubKey.toHexKey(), "encrypt")
+ val encryptedContent = ExternalSignerUtils.content["encrypt"] ?: ""
+ ExternalSignerUtils.content.remove("encrypt")
if (encryptedContent.isBlank()) {
return
}
@@ -1858,8 +1858,8 @@ class Account(
keyPair.pubKey.toHexKey()
)
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -1896,9 +1896,9 @@ class Account(
}
val msg = Event.mapper.writeValueAsString(privTags)
- AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), "encrypt")
- val encryptedContent = AmberUtils.content["encrypt"] ?: ""
- AmberUtils.content.remove("encrypt")
+ ExternalSignerUtils.encrypt(msg, keyPair.pubKey.toHexKey(), "encrypt")
+ val encryptedContent = ExternalSignerUtils.content["encrypt"] ?: ""
+ ExternalSignerUtils.content.remove("encrypt")
if (encryptedContent.isBlank()) {
return
}
@@ -1914,8 +1914,8 @@ class Account(
keyPair.pubKey.toHexKey()
)
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -1982,9 +1982,9 @@ class Account(
}
val msg = Event.mapper.writeValueAsString(privTags)
- AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), "encrypt")
- val encryptedContent = AmberUtils.content["encrypt"] ?: ""
- AmberUtils.content.remove("encrypt")
+ ExternalSignerUtils.encrypt(msg, keyPair.pubKey.toHexKey(), "encrypt")
+ val encryptedContent = ExternalSignerUtils.content["encrypt"] ?: ""
+ ExternalSignerUtils.content.remove("encrypt")
if (encryptedContent.isBlank()) {
return
}
@@ -2008,8 +2008,8 @@ class Account(
keyPair.pubKey.toHexKey()
)
}
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -2094,12 +2094,12 @@ class Account(
}
fun createAuthEvent(relay: Relay, challenge: String): RelayAuthEvent? {
- if (!isWriteable() && !loginWithAmber) return null
+ if (!isWriteable() && !loginWithExternalSigner) return null
var event = RelayAuthEvent.create(relay.url, challenge, keyPair.pubKey.toHexKey(), keyPair.privKey)
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) {
return null
}
@@ -2166,9 +2166,9 @@ class Account(
}
val msg = Event.mapper.writeValueAsString(privTags)
- AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), "encrypt")
- val encryptedContent = AmberUtils.content["encrypt"] ?: ""
- AmberUtils.content.remove("encrypt")
+ ExternalSignerUtils.encrypt(msg, keyPair.pubKey.toHexKey(), "encrypt")
+ val encryptedContent = ExternalSignerUtils.content["encrypt"] ?: ""
+ ExternalSignerUtils.content.remove("encrypt")
if (encryptedContent.isBlank()) {
return
}
@@ -2193,8 +2193,8 @@ class Account(
)
}
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) {
return
}
@@ -2205,9 +2205,9 @@ class Account(
}
fun isInPrivateBookmarks(note: Note): Boolean {
- if (!isWriteable() && !loginWithAmber) return false
+ if (!isWriteable() && !loginWithExternalSigner) return false
- if (loginWithAmber) {
+ if (loginWithExternalSigner) {
return if (note is AddressableNote) {
userProfile().latestBookmarkList?.privateTaggedAddresses(userProfile().latestBookmarkList?.decryptedContent ?: "")
?.contains(note.address) == true
@@ -2227,7 +2227,7 @@ class Account(
}
fun isInPublicBookmarks(note: Note): Boolean {
- if (!isWriteable() && !loginWithAmber) return false
+ if (!isWriteable() && !loginWithExternalSigner) return false
if (note is AddressableNote) {
return userProfile().latestBookmarkList?.taggedAddresses()?.contains(note.address) == true
@@ -2265,30 +2265,30 @@ class Account(
fun hideUser(pubkeyHex: String) {
val blockList = migrateHiddenUsersIfNeeded(getBlockList())
- if (loginWithAmber) {
+ if (loginWithExternalSigner) {
val id = blockList?.id
val encryptedContent = if (id == null) {
val privateTags = listOf(listOf("p", pubkeyHex))
val msg = Event.mapper.writeValueAsString(privateTags)
- AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), "encrypt")
- val encryptedContent = AmberUtils.content["encrypted"] ?: ""
- AmberUtils.content.remove("encrypted")
+ ExternalSignerUtils.encrypt(msg, keyPair.pubKey.toHexKey(), "encrypt")
+ val encryptedContent = ExternalSignerUtils.content["encrypted"] ?: ""
+ ExternalSignerUtils.content.remove("encrypted")
if (encryptedContent.isBlank()) return
encryptedContent
} else {
- var decryptedContent = AmberUtils.cachedDecryptedContent[id]
+ var decryptedContent = ExternalSignerUtils.cachedDecryptedContent[id]
if (decryptedContent == null) {
- AmberUtils.decrypt(blockList.content, keyPair.pubKey.toHexKey(), id)
- val content = AmberUtils.content[id] ?: ""
+ ExternalSignerUtils.decrypt(blockList.content, keyPair.pubKey.toHexKey(), id)
+ val content = ExternalSignerUtils.content[id] ?: ""
if (content.isBlank()) return
decryptedContent = content
}
val privateTags = blockList.privateTagsOrEmpty(decryptedContent).plus(element = listOf("p", pubkeyHex))
val msg = Event.mapper.writeValueAsString(privateTags)
- AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), id)
- val eventContent = AmberUtils.content[id] ?: ""
+ ExternalSignerUtils.encrypt(msg, keyPair.pubKey.toHexKey(), id)
+ val eventContent = ExternalSignerUtils.content[id] ?: ""
if (eventContent.isBlank()) return
eventContent
}
@@ -2311,8 +2311,8 @@ class Account(
)
}
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) return
event = PeopleListEvent(
event.id,
@@ -2354,28 +2354,28 @@ class Account(
val blockList = migrateHiddenUsersIfNeeded(getBlockList())
if (blockList != null) {
- if (loginWithAmber) {
+ if (loginWithExternalSigner) {
val content = blockList.content
val encryptedContent = if (content.isBlank()) {
val privateTags = listOf(listOf("p", pubkeyHex))
val msg = Event.mapper.writeValueAsString(privateTags)
- AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), blockList.id)
- val eventContent = AmberUtils.content[blockList.id] ?: ""
+ ExternalSignerUtils.encrypt(msg, keyPair.pubKey.toHexKey(), blockList.id)
+ val eventContent = ExternalSignerUtils.content[blockList.id] ?: ""
if (eventContent.isBlank()) return
eventContent
} else {
- var decryptedContent = AmberUtils.cachedDecryptedContent[blockList.id]
+ var decryptedContent = ExternalSignerUtils.cachedDecryptedContent[blockList.id]
if (decryptedContent == null) {
- AmberUtils.decrypt(blockList.content, keyPair.pubKey.toHexKey(), blockList.id)
- val eventContent = AmberUtils.content[blockList.id] ?: ""
+ ExternalSignerUtils.decrypt(blockList.content, keyPair.pubKey.toHexKey(), blockList.id)
+ val eventContent = ExternalSignerUtils.content[blockList.id] ?: ""
if (eventContent.isBlank()) return
decryptedContent = eventContent
}
val privateTags = blockList.privateTagsOrEmpty(decryptedContent).minus(element = listOf("p", pubkeyHex))
val msg = Event.mapper.writeValueAsString(privateTags)
- AmberUtils.encrypt(msg, keyPair.pubKey.toHexKey(), blockList.id)
- val eventContent = AmberUtils.content[blockList.id] ?: ""
+ ExternalSignerUtils.encrypt(msg, keyPair.pubKey.toHexKey(), blockList.id)
+ val eventContent = ExternalSignerUtils.content[blockList.id] ?: ""
if (eventContent.isBlank()) return
eventContent
}
@@ -2388,8 +2388,8 @@ class Account(
encryptedContent
)
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) return
event = PeopleListEvent.create(event, eventContent)
@@ -2589,7 +2589,7 @@ class Account(
}
fun sendChangeChannel(name: String, about: String, picture: String, channel: Channel) {
- if (!isWriteable() && !loginWithAmber) return
+ if (!isWriteable() && !loginWithExternalSigner) return
val metadata = ChannelCreateEvent.ChannelData(
name,
@@ -2602,9 +2602,9 @@ class Account(
originalChannelIdHex = channel.idHex,
keyPair = keyPair
)
- if (loginWithAmber) {
- AmberUtils.openAmber(event)
- val eventContent = AmberUtils.content[event.id] ?: ""
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(event)
+ val eventContent = ExternalSignerUtils.content[event.id] ?: ""
if (eventContent.isBlank()) return
event = ChannelMetadataEvent.create(event, eventContent)
}
@@ -2616,14 +2616,14 @@ class Account(
}
fun unwrap(event: GiftWrapEvent): Event? {
- if (!isWriteable() && !loginWithAmber) return null
+ if (!isWriteable() && !loginWithExternalSigner) return null
- if (loginWithAmber) {
- var decryptedContent = AmberUtils.cachedDecryptedContent[event.id]
+ if (loginWithExternalSigner) {
+ var decryptedContent = ExternalSignerUtils.cachedDecryptedContent[event.id]
if (decryptedContent == null) {
- AmberUtils.decrypt(event.content, event.pubKey, event.id, SignerType.NIP44_DECRYPT)
+ ExternalSignerUtils.decrypt(event.content, event.pubKey, event.id, SignerType.NIP44_DECRYPT)
}
- decryptedContent = AmberUtils.cachedDecryptedContent[event.id] ?: ""
+ decryptedContent = ExternalSignerUtils.cachedDecryptedContent[event.id] ?: ""
if (decryptedContent.isEmpty()) return null
return event.cachedGift(keyPair.pubKey, decryptedContent)
}
@@ -2632,14 +2632,14 @@ class Account(
}
fun unseal(event: SealedGossipEvent): Event? {
- if (!isWriteable() && !loginWithAmber) return null
+ if (!isWriteable() && !loginWithExternalSigner) return null
- if (loginWithAmber) {
- var decryptedContent = AmberUtils.cachedDecryptedContent[event.id]
+ if (loginWithExternalSigner) {
+ var decryptedContent = ExternalSignerUtils.cachedDecryptedContent[event.id]
if (decryptedContent == null) {
- AmberUtils.decrypt(event.content, event.pubKey, event.id, SignerType.NIP44_DECRYPT)
+ ExternalSignerUtils.decrypt(event.content, event.pubKey, event.id, SignerType.NIP44_DECRYPT)
}
- decryptedContent = AmberUtils.cachedDecryptedContent[event.id] ?: ""
+ decryptedContent = ExternalSignerUtils.cachedDecryptedContent[event.id] ?: ""
if (decryptedContent.isEmpty()) return null
return event.cachedGossip(keyPair.pubKey, decryptedContent)
}
@@ -2648,6 +2648,14 @@ class Account(
}
fun decryptContent(note: Note): String? {
+ return if (loginWithExternalSigner) {
+ decryptContentWithExternalSigner(note)
+ } else {
+ decryptContentInternalSigner(note)
+ }
+ }
+
+ fun decryptContentInternalSigner(note: Note): String? {
val privKey = keyPair.privKey
val event = note.event
return if (event is PrivateDmEvent && privKey != null) {
@@ -2659,19 +2667,19 @@ class Account(
}
}
- fun decryptContentWithAmber(note: Note): String? = with(Dispatchers.IO) {
+ fun decryptContentWithExternalSigner(note: Note): String? = with(Dispatchers.IO) {
val event = note.event
return when (event) {
is PrivateDmEvent -> {
- if (AmberUtils.cachedDecryptedContent[event.id] == null) {
- AmberUtils.decryptDM(
+ if (ExternalSignerUtils.cachedDecryptedContent[event.id] == null) {
+ ExternalSignerUtils.decryptDM(
event.content,
event.talkingWith(userProfile().pubkeyHex),
event.id
)
- AmberUtils.cachedDecryptedContent[event.id]
+ ExternalSignerUtils.cachedDecryptedContent[event.id]
} else {
- AmberUtils.cachedDecryptedContent[event.id]
+ ExternalSignerUtils.cachedDecryptedContent[event.id]
}
}
is LnZapRequestEvent -> {
@@ -2687,8 +2695,8 @@ class Account(
val event = note.event
val loggedInPrivateKey = keyPair.privKey
- if (loginWithAmber && event is LnZapRequestEvent && event.isPrivateZap()) {
- val decryptedContent = AmberUtils.cachedDecryptedContent[event.id]
+ if (loginWithExternalSigner && event is LnZapRequestEvent && event.isPrivateZap()) {
+ val decryptedContent = ExternalSignerUtils.cachedDecryptedContent[event.id]
if (decryptedContent != null) {
return try {
Event.fromJson(decryptedContent)
@@ -2696,7 +2704,7 @@ class Account(
null
}
}
- AmberUtils.decryptZapEvent(event)
+ ExternalSignerUtils.decryptZapEvent(event)
return null
}
@@ -2852,7 +2860,7 @@ class Account(
val blockList = getBlockList()
val decryptedContent = blockList?.decryptedContent ?: ""
- if (loginWithAmber) {
+ if (loginWithExternalSigner) {
if (decryptedContent.isBlank()) return false
return (blockList?.publicAndPrivateUsers(decryptedContent)?.contains(userHex) ?: false) || userHex in transientHiddenUsers
}
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt b/app/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt
index a5e7914ae..0d6f2c697 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/model/LocalCache.kt
@@ -4,7 +4,7 @@ import android.util.Log
import androidx.compose.runtime.Stable
import com.vitorpamplona.amethyst.Amethyst
import com.vitorpamplona.amethyst.LocalPreferences
-import com.vitorpamplona.amethyst.service.AmberUtils
+import com.vitorpamplona.amethyst.service.ExternalSignerUtils
import com.vitorpamplona.amethyst.service.checkNotInMainThread
import com.vitorpamplona.amethyst.service.relays.Relay
import com.vitorpamplona.amethyst.ui.components.BundledInsert
@@ -214,7 +214,7 @@ object LocalCache {
if (hexKey != null) {
val pubKey = Hex.encode(hexKey)
if (pubKey == event.pubKey) {
- AmberUtils.content.remove(event.id)
+ ExternalSignerUtils.content.remove(event.id)
}
}
user.updateBookmark(event)
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/service/AmberUtils.kt b/app/src/main/java/com/vitorpamplona/amethyst/service/ExternalSignerUtils.kt
similarity index 96%
rename from app/src/main/java/com/vitorpamplona/amethyst/service/AmberUtils.kt
rename to app/src/main/java/com/vitorpamplona/amethyst/service/ExternalSignerUtils.kt
index 58238e71d..7ea96967f 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/service/AmberUtils.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/service/ExternalSignerUtils.kt
@@ -32,7 +32,7 @@ enum class SignerType {
DECRYPT_ZAP_EVENT
}
-object AmberUtils {
+object ExternalSignerUtils {
val content = LruCache(10)
var isActivityRunning: Boolean = false
val cachedDecryptedContent = mutableMapOf()
@@ -113,7 +113,7 @@ object AmberUtils {
}
@OptIn(DelicateCoroutinesApi::class)
- fun openAmber(
+ fun openSigner(
data: String,
type: SignerType,
intentResult: ActivityResultLauncher,
@@ -141,18 +141,18 @@ object AmberUtils {
intent.`package` = "com.greenart7c3.nostrsigner"
intentResult.launch(intent)
} catch (e: Exception) {
- Log.e("Amber", "Error opening amber", e)
+ Log.e("Signer", "Error opening Signer app", e)
GlobalScope.launch(Dispatchers.Main) {
Toast.makeText(
Amethyst.instance,
- Amethyst.instance.getString(R.string.error_opening_amber),
+ Amethyst.instance.getString(R.string.error_opening_external_signer),
Toast.LENGTH_SHORT
).show()
}
}
}
- fun openAmber(event: EventInterface, columnName: String = "signature") {
+ fun openSigner(event: EventInterface, columnName: String = "signature") {
checkNotInMainThread()
val result = getDataFromResolver(SignerType.SIGN_EVENT, arrayOf(event.toJson(), event.pubKey()), columnName)
@@ -163,7 +163,7 @@ object AmberUtils {
ServiceManager.shouldPauseService = false
isActivityRunning = true
- openAmber(
+ openSigner(
event.toJson(),
SignerType.SIGN_EVENT,
activityResultLauncher,
@@ -183,7 +183,7 @@ object AmberUtils {
return
}
isActivityRunning = true
- openAmber(
+ openSigner(
encryptedContent,
signerType,
blockListResultLauncher,
@@ -225,7 +225,7 @@ object AmberUtils {
}
isActivityRunning = true
- openAmber(
+ openSigner(
encryptedContent,
signerType,
decryptResultLauncher,
@@ -244,7 +244,7 @@ object AmberUtils {
cachedDecryptedContent[id] = result
return
}
- openAmber(
+ openSigner(
encryptedContent,
signerType,
decryptResultLauncher,
@@ -260,7 +260,7 @@ object AmberUtils {
cachedDecryptedContent[id] = result
return
}
- openAmber(
+ openSigner(
encryptedContent,
signerType,
decryptResultLauncher,
@@ -277,7 +277,7 @@ object AmberUtils {
}
isActivityRunning = true
- openAmber(
+ openSigner(
decryptedContent,
signerType,
activityResultLauncher,
@@ -296,7 +296,7 @@ object AmberUtils {
cachedDecryptedContent[event.id] = result
return
}
- openAmber(
+ openSigner(
event.toJson(),
SignerType.DECRYPT_ZAP_EVENT,
decryptResultLauncher,
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/service/NostrAccountDataSource.kt b/app/src/main/java/com/vitorpamplona/amethyst/service/NostrAccountDataSource.kt
index a536fbca5..df3e1f2cb 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/service/NostrAccountDataSource.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/service/NostrAccountDataSource.kt
@@ -152,16 +152,16 @@ object NostrAccountDataSource : NostrDataSource("AccountData") {
event.cachedGift(privateKey)?.let {
this.consume(it, relay)
}
- } else if (account.loginWithAmber) {
- var cached = AmberUtils.cachedDecryptedContent[event.id]
+ } else if (account.loginWithExternalSigner) {
+ var cached = ExternalSignerUtils.cachedDecryptedContent[event.id]
if (cached == null) {
- AmberUtils.decrypt(
+ ExternalSignerUtils.decrypt(
event.content,
event.pubKey,
event.id,
SignerType.NIP44_DECRYPT
)
- cached = AmberUtils.cachedDecryptedContent[event.id] ?: ""
+ cached = ExternalSignerUtils.cachedDecryptedContent[event.id] ?: ""
}
event.cachedGift(account.keyPair.pubKey, cached)?.let {
this.consume(it, relay)
@@ -175,16 +175,16 @@ object NostrAccountDataSource : NostrDataSource("AccountData") {
event.cachedGossip(privateKey)?.let {
LocalCache.justConsume(it, relay)
}
- } else if (account.loginWithAmber) {
- var cached = AmberUtils.cachedDecryptedContent[event.id]
+ } else if (account.loginWithExternalSigner) {
+ var cached = ExternalSignerUtils.cachedDecryptedContent[event.id]
if (cached == null) {
- AmberUtils.decrypt(
+ ExternalSignerUtils.decrypt(
event.content,
event.pubKey,
event.id,
SignerType.NIP44_DECRYPT
)
- cached = AmberUtils.cachedDecryptedContent[event.id] ?: ""
+ cached = ExternalSignerUtils.cachedDecryptedContent[event.id] ?: ""
}
event.cachedGossip(account.keyPair.pubKey, cached)?.let {
LocalCache.justConsume(it, relay)
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/service/notifications/EventNotificationConsumer.kt b/app/src/main/java/com/vitorpamplona/amethyst/service/notifications/EventNotificationConsumer.kt
index 9b5936a2c..be6db3e55 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/service/notifications/EventNotificationConsumer.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/service/notifications/EventNotificationConsumer.kt
@@ -7,7 +7,7 @@ import com.vitorpamplona.amethyst.LocalPreferences
import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.model.Account
import com.vitorpamplona.amethyst.model.LocalCache
-import com.vitorpamplona.amethyst.service.AmberUtils
+import com.vitorpamplona.amethyst.service.ExternalSignerUtils
import com.vitorpamplona.amethyst.service.SignerType
import com.vitorpamplona.amethyst.service.notifications.NotificationUtils.sendDMNotification
import com.vitorpamplona.amethyst.service.notifications.NotificationUtils.sendZapNotification
@@ -34,7 +34,7 @@ class EventNotificationConsumer(private val applicationContext: Context) {
// Test with all logged in accounts
LocalPreferences.allSavedAccounts().forEach {
val acc = LocalPreferences.loadFromEncryptedStorage(it.npub)
- if (acc != null && (acc.keyPair.privKey != null || acc.loginWithAmber)) {
+ if (acc != null && (acc.keyPair.privKey != null || acc.loginWithExternalSigner)) {
consumeIfMatchesAccount(event, acc)
}
}
@@ -42,16 +42,16 @@ class EventNotificationConsumer(private val applicationContext: Context) {
private suspend fun consumeIfMatchesAccount(pushWrappedEvent: GiftWrapEvent, account: Account) {
val key = account.keyPair.privKey
- if (account.loginWithAmber) {
- var cached = AmberUtils.cachedDecryptedContent[pushWrappedEvent.id]
+ if (account.loginWithExternalSigner) {
+ var cached = ExternalSignerUtils.cachedDecryptedContent[pushWrappedEvent.id]
if (cached == null) {
- AmberUtils.decrypt(
+ ExternalSignerUtils.decrypt(
pushWrappedEvent.content,
pushWrappedEvent.pubKey,
pushWrappedEvent.id,
SignerType.NIP44_DECRYPT
)
- cached = AmberUtils.cachedDecryptedContent[pushWrappedEvent.id] ?: ""
+ cached = ExternalSignerUtils.cachedDecryptedContent[pushWrappedEvent.id] ?: ""
}
pushWrappedEvent.unwrap(cached)?.let { notificationEvent ->
if (!LocalCache.justVerify(notificationEvent)) return // invalid event
@@ -99,16 +99,16 @@ class EventNotificationConsumer(private val applicationContext: Context) {
event.cachedGift(key)?.let {
unwrapAndConsume(it, account)
}
- } else if (account.loginWithAmber) {
- var cached = AmberUtils.cachedDecryptedContent[event.id]
+ } else if (account.loginWithExternalSigner) {
+ var cached = ExternalSignerUtils.cachedDecryptedContent[event.id]
if (cached == null) {
- AmberUtils.decrypt(
+ ExternalSignerUtils.decrypt(
event.content,
event.pubKey,
event.id,
SignerType.NIP44_DECRYPT
)
- cached = AmberUtils.cachedDecryptedContent[event.id] ?: ""
+ cached = ExternalSignerUtils.cachedDecryptedContent[event.id] ?: ""
}
event.cachedGift(account.keyPair.pubKey, cached)?.let {
unwrapAndConsume(it, account)
@@ -125,16 +125,16 @@ class EventNotificationConsumer(private val applicationContext: Context) {
LocalCache.justConsume(it, null)
it
}
- } else if (account.loginWithAmber) {
- var cached = AmberUtils.cachedDecryptedContent[event.id]
+ } else if (account.loginWithExternalSigner) {
+ var cached = ExternalSignerUtils.cachedDecryptedContent[event.id]
if (cached == null) {
- AmberUtils.decrypt(
+ ExternalSignerUtils.decrypt(
event.content,
event.pubKey,
event.id,
SignerType.NIP44_DECRYPT
)
- cached = AmberUtils.cachedDecryptedContent[event.id] ?: ""
+ cached = ExternalSignerUtils.cachedDecryptedContent[event.id] ?: ""
}
event.cachedGossip(account.keyPair.pubKey, cached)?.let {
LocalCache.justConsume(it, null)
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt
index 8fa9659b9..32c79e7f1 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt
@@ -23,7 +23,7 @@ import androidx.core.os.LocaleListCompat
import androidx.lifecycle.viewmodel.compose.viewModel
import com.vitorpamplona.amethyst.LocalPreferences
import com.vitorpamplona.amethyst.ServiceManager
-import com.vitorpamplona.amethyst.service.AmberUtils
+import com.vitorpamplona.amethyst.service.ExternalSignerUtils
import com.vitorpamplona.amethyst.service.connectivitystatus.ConnectivityStatus
import com.vitorpamplona.amethyst.service.notifications.PushNotificationUtils
import com.vitorpamplona.amethyst.ui.components.DefaultMutedSetting
@@ -52,7 +52,7 @@ import java.nio.charset.StandardCharsets
class MainActivity : AppCompatActivity() {
@RequiresApi(Build.VERSION_CODES.R)
override fun onCreate(savedInstanceState: Bundle?) {
- AmberUtils.start(this)
+ ExternalSignerUtils.start(this)
super.onCreate(savedInstanceState)
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/dal/BookmarkPrivateFeedFilter.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/dal/BookmarkPrivateFeedFilter.kt
index 940dccb55..5abbb7041 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/dal/BookmarkPrivateFeedFilter.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/dal/BookmarkPrivateFeedFilter.kt
@@ -3,7 +3,7 @@ package com.vitorpamplona.amethyst.ui.dal
import com.vitorpamplona.amethyst.model.Account
import com.vitorpamplona.amethyst.model.LocalCache
import com.vitorpamplona.amethyst.model.Note
-import com.vitorpamplona.amethyst.service.AmberUtils
+import com.vitorpamplona.amethyst.service.ExternalSignerUtils
import com.vitorpamplona.quartz.encoders.toHexKey
object BookmarkPrivateFeedFilter : FeedFilter() {
@@ -16,12 +16,12 @@ object BookmarkPrivateFeedFilter : FeedFilter() {
override fun feed(): List {
val bookmarks = account.userProfile().latestBookmarkList
- if (account.loginWithAmber) {
+ if (account.loginWithExternalSigner) {
val id = bookmarks?.id
if (id != null) {
- val decryptedContent = AmberUtils.cachedDecryptedContent[id]
+ val decryptedContent = ExternalSignerUtils.cachedDecryptedContent[id]
if (decryptedContent == null) {
- AmberUtils.decryptBookmark(
+ ExternalSignerUtils.decryptBookmark(
bookmarks.content,
account.keyPair.pubKey.toHexKey(),
id
@@ -30,7 +30,7 @@ object BookmarkPrivateFeedFilter : FeedFilter() {
bookmarks.decryptedContent = decryptedContent
}
}
- val decryptedContent = AmberUtils.cachedDecryptedContent[id] ?: ""
+ val decryptedContent = ExternalSignerUtils.cachedDecryptedContent[id] ?: ""
val notes = bookmarks?.privateTaggedEvents(decryptedContent)
?.mapNotNull { LocalCache.checkGetOrCreateNote(it) } ?: emptyList()
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/dal/HiddenAccountsFeedFilter.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/dal/HiddenAccountsFeedFilter.kt
index 608eb1384..2cd19a956 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/dal/HiddenAccountsFeedFilter.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/dal/HiddenAccountsFeedFilter.kt
@@ -16,7 +16,7 @@ class HiddenAccountsFeedFilter(val account: Account) : FeedFilter() {
override fun feed(): List {
val blockList = account.getBlockList()
val decryptedContent = blockList?.decryptedContent ?: ""
- if (account.loginWithAmber) {
+ if (account.loginWithExternalSigner) {
if (decryptedContent.isEmpty()) return emptyList()
return blockList
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/PollNote.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/PollNote.kt
index 68c0e2599..a573fb13b 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/PollNote.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/PollNote.kt
@@ -307,7 +307,7 @@ fun ZapVote(
// interactionSource = remember { MutableInteractionSource() },
// indication = rememberRipple(bounded = false, radius = 24.dp),
onClick = {
- if (!accountViewModel.isWriteable() && !accountViewModel.loggedInWithAmber()) {
+ if (!accountViewModel.isWriteable() && !accountViewModel.loggedInWithExternalSigner()) {
scope.launch {
Toast
.makeText(
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt
index 710cf4390..e0d3e6835 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt
@@ -546,7 +546,7 @@ fun ReplyReaction(
if (accountViewModel.isWriteable()) {
onPress()
} else {
- if (accountViewModel.loggedInWithAmber()) {
+ if (accountViewModel.loggedInWithExternalSigner()) {
onPress()
} else {
scope.launch {
@@ -659,7 +659,7 @@ fun BoostReaction(
wantsToBoost = true
}
} else {
- if (accountViewModel.loggedInWithAmber()) {
+ if (accountViewModel.loggedInWithExternalSigner()) {
if (accountViewModel.hasBoosted(baseNote)) {
scope.launch(Dispatchers.IO) {
accountViewModel.deleteBoostsTo(baseNote)
@@ -907,7 +907,7 @@ private fun likeClick(
.show()
}
} else if (!accountViewModel.isWriteable()) {
- if (accountViewModel.loggedInWithAmber()) {
+ if (accountViewModel.loggedInWithExternalSigner()) {
onWantsToSignReaction()
} else {
scope.launch {
@@ -1122,7 +1122,7 @@ private fun zapClick(
)
.show()
}
- } else if (!accountViewModel.isWriteable() && !accountViewModel.loggedInWithAmber()) {
+ } else if (!accountViewModel.isWriteable() && !accountViewModel.loggedInWithExternalSigner()) {
scope.launch {
Toast
.makeText(
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt
index 3df652787..56e7c58fb 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt
@@ -43,7 +43,7 @@ import androidx.lifecycle.map
import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.model.Note
import com.vitorpamplona.amethyst.model.User
-import com.vitorpamplona.amethyst.service.AmberUtils
+import com.vitorpamplona.amethyst.service.ExternalSignerUtils
import com.vitorpamplona.amethyst.ui.components.RobohashAsyncImage
import com.vitorpamplona.amethyst.ui.components.RobohashAsyncImageProxy
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
@@ -478,14 +478,14 @@ fun NoteDropDownMenu(note: Note, popupExpanded: MutableState, accountVi
DropdownMenuItem(
onClick = {
scope.launch(Dispatchers.IO) {
- if (accountViewModel.loggedInWithAmber()) {
+ if (accountViewModel.loggedInWithExternalSigner()) {
val bookmarks = accountViewModel.userProfile().latestBookmarkList
- AmberUtils.decrypt(
+ ExternalSignerUtils.decrypt(
bookmarks?.content ?: "",
accountViewModel.account.keyPair.pubKey.toHexKey(),
bookmarks?.id ?: ""
)
- bookmarks?.decryptedContent = AmberUtils.cachedDecryptedContent[bookmarks?.id ?: ""] ?: ""
+ bookmarks?.decryptedContent = ExternalSignerUtils.cachedDecryptedContent[bookmarks?.id ?: ""] ?: ""
accountViewModel.removePrivateBookmark(note, bookmarks?.decryptedContent ?: "")
} else {
accountViewModel.removePrivateBookmark(note)
@@ -500,14 +500,14 @@ fun NoteDropDownMenu(note: Note, popupExpanded: MutableState, accountVi
DropdownMenuItem(
onClick = {
scope.launch(Dispatchers.IO) {
- if (accountViewModel.loggedInWithAmber()) {
+ if (accountViewModel.loggedInWithExternalSigner()) {
val bookmarks = accountViewModel.userProfile().latestBookmarkList
- AmberUtils.decrypt(
+ ExternalSignerUtils.decrypt(
bookmarks?.content ?: "",
accountViewModel.account.keyPair.pubKey.toHexKey(),
bookmarks?.id ?: ""
)
- bookmarks?.decryptedContent = AmberUtils.cachedDecryptedContent[bookmarks?.id ?: ""] ?: ""
+ bookmarks?.decryptedContent = ExternalSignerUtils.cachedDecryptedContent[bookmarks?.id ?: ""] ?: ""
accountViewModel.addPrivateBookmark(note, bookmarks?.decryptedContent ?: "")
} else {
accountViewModel.addPrivateBookmark(note)
@@ -523,14 +523,14 @@ fun NoteDropDownMenu(note: Note, popupExpanded: MutableState, accountVi
DropdownMenuItem(
onClick = {
scope.launch(Dispatchers.IO) {
- if (accountViewModel.loggedInWithAmber()) {
+ if (accountViewModel.loggedInWithExternalSigner()) {
val bookmarks = accountViewModel.userProfile().latestBookmarkList
- AmberUtils.decrypt(
+ ExternalSignerUtils.decrypt(
bookmarks?.content ?: "",
accountViewModel.account.keyPair.pubKey.toHexKey(),
bookmarks?.id ?: ""
)
- bookmarks?.decryptedContent = AmberUtils.cachedDecryptedContent[bookmarks?.id ?: ""] ?: ""
+ bookmarks?.decryptedContent = ExternalSignerUtils.cachedDecryptedContent[bookmarks?.id ?: ""] ?: ""
accountViewModel.removePublicBookmark(
note,
bookmarks?.decryptedContent ?: ""
@@ -548,14 +548,14 @@ fun NoteDropDownMenu(note: Note, popupExpanded: MutableState, accountVi
DropdownMenuItem(
onClick = {
scope.launch(Dispatchers.IO) {
- if (accountViewModel.loggedInWithAmber()) {
+ if (accountViewModel.loggedInWithExternalSigner()) {
val bookmarks = accountViewModel.userProfile().latestBookmarkList
- AmberUtils.decrypt(
+ ExternalSignerUtils.decrypt(
bookmarks?.content ?: "",
accountViewModel.account.keyPair.pubKey.toHexKey(),
bookmarks?.id ?: ""
)
- bookmarks?.decryptedContent = AmberUtils.cachedDecryptedContent[bookmarks?.id ?: ""] ?: ""
+ bookmarks?.decryptedContent = ExternalSignerUtils.cachedDecryptedContent[bookmarks?.id ?: ""] ?: ""
accountViewModel.addPublicBookmark(
note,
bookmarks?.decryptedContent ?: ""
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapNoteCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapNoteCompose.kt
index 3e5bfa716..5326a3bc8 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapNoteCompose.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapNoteCompose.kt
@@ -211,7 +211,7 @@ fun ShowFollowingOrUnfollowingButton(
if (isFollowing) {
UnfollowButton {
if (!accountViewModel.isWriteable()) {
- if (accountViewModel.loggedInWithAmber()) {
+ if (accountViewModel.loggedInWithExternalSigner()) {
scope.launch(Dispatchers.IO) {
accountViewModel.unfollow(baseAuthor)
}
@@ -235,7 +235,7 @@ fun ShowFollowingOrUnfollowingButton(
} else {
FollowButton {
if (!accountViewModel.isWriteable()) {
- if (accountViewModel.loggedInWithAmber()) {
+ if (accountViewModel.loggedInWithExternalSigner()) {
scope.launch(Dispatchers.IO) {
accountViewModel.account.follow(baseAuthor)
}
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountStateViewModel.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountStateViewModel.kt
index 4aa530171..a140c9dae 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountStateViewModel.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountStateViewModel.kt
@@ -45,21 +45,21 @@ class AccountStateViewModel(val context: Context) : ViewModel() {
}
}
- fun startUI(key: String, useProxy: Boolean, proxyPort: Int, loginWithAmber: Boolean = false) {
+ fun startUI(key: String, useProxy: Boolean, proxyPort: Int, loginWithExternalSigner: Boolean = false) {
val parsed = Nip19.uriToRoute(key)
val pubKeyParsed = parsed?.hex?.hexToByteArray()
val proxy = HttpClient.initProxy(useProxy, "127.0.0.1", proxyPort)
val account =
if (key.startsWith("nsec")) {
- Account(KeyPair(privKey = key.bechToBytes()), proxy = proxy, proxyPort = proxyPort, loginWithAmber = loginWithAmber)
+ Account(KeyPair(privKey = key.bechToBytes()), proxy = proxy, proxyPort = proxyPort, loginWithExternalSigner = loginWithExternalSigner)
} else if (pubKeyParsed != null) {
- Account(KeyPair(pubKey = pubKeyParsed), proxy = proxy, proxyPort = proxyPort, loginWithAmber = loginWithAmber)
+ Account(KeyPair(pubKey = pubKeyParsed), proxy = proxy, proxyPort = proxyPort, loginWithExternalSigner = loginWithExternalSigner)
} else if (EMAIL_PATTERN.matcher(key).matches()) {
// Evaluate NIP-5
- Account(KeyPair(), proxy = proxy, proxyPort = proxyPort, loginWithAmber = loginWithAmber)
+ Account(KeyPair(), proxy = proxy, proxyPort = proxyPort, loginWithExternalSigner = loginWithExternalSigner)
} else {
- Account(KeyPair(Hex.decode(key)), proxy = proxy, proxyPort = proxyPort, loginWithAmber = loginWithAmber)
+ Account(KeyPair(Hex.decode(key)), proxy = proxy, proxyPort = proxyPort, loginWithExternalSigner = loginWithExternalSigner)
}
LocalPreferences.updatePrefsForLogin(account)
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt
index 33756e6e3..7abf1adff 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt
@@ -97,8 +97,8 @@ class AccountViewModel(val account: Account) : ViewModel() {
return account.isWriteable()
}
- fun loggedInWithAmber(): Boolean {
- return account.loginWithAmber
+ fun loggedInWithExternalSigner(): Boolean {
+ return account.loginWithExternalSigner
}
fun userProfile(): User {
@@ -300,9 +300,6 @@ class AccountViewModel(val account: Account) : ViewModel() {
}
fun decrypt(note: Note): String? {
- if (loggedInWithAmber()) {
- return account.decryptContentWithAmber(note)
- }
return account.decryptContent(note)
}
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/GeoHashScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/GeoHashScreen.kt
index 3a35787f8..8de031058 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/GeoHashScreen.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/GeoHashScreen.kt
@@ -171,7 +171,7 @@ fun GeoHashActionOptions(
if (isFollowingTag) {
UnfollowButton {
if (!accountViewModel.isWriteable()) {
- if (accountViewModel.loggedInWithAmber()) {
+ if (accountViewModel.loggedInWithExternalSigner()) {
scope.launch(Dispatchers.IO) {
accountViewModel.account.unfollowGeohash(tag)
}
@@ -195,7 +195,7 @@ fun GeoHashActionOptions(
} else {
FollowButton {
if (!accountViewModel.isWriteable()) {
- if (accountViewModel.loggedInWithAmber()) {
+ if (accountViewModel.loggedInWithExternalSigner()) {
scope.launch(Dispatchers.IO) {
accountViewModel.account.followGeohash(tag)
}
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HashtagScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HashtagScreen.kt
index 4d609eef9..f0c8d3411 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HashtagScreen.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HashtagScreen.kt
@@ -147,7 +147,7 @@ fun HashtagActionOptions(
if (isFollowingTag) {
UnfollowButton {
if (!accountViewModel.isWriteable()) {
- if (accountViewModel.loggedInWithAmber()) {
+ if (accountViewModel.loggedInWithExternalSigner()) {
scope.launch(Dispatchers.IO) {
accountViewModel.account.unfollowHashtag(tag)
}
@@ -171,7 +171,7 @@ fun HashtagActionOptions(
} else {
FollowButton {
if (!accountViewModel.isWriteable()) {
- if (accountViewModel.loggedInWithAmber()) {
+ if (accountViewModel.loggedInWithExternalSigner()) {
scope.launch(Dispatchers.IO) {
accountViewModel.account.followHashtag(tag)
}
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt
index 15d5b6267..fe7215f31 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt
@@ -242,7 +242,7 @@ fun FloatingButtons(
Crossfade(targetState = accountState, animationSpec = tween(durationMillis = 100)) { state ->
when (state) {
is AccountState.LoggedInViewOnly -> {
- if (accountViewModel.loggedInWithAmber()) {
+ if (accountViewModel.loggedInWithExternalSigner()) {
WritePermissionButtons(navEntryState, accountViewModel, nav, navScrollToTop)
}
}
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt
index 67e507246..a34b48251 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt
@@ -748,7 +748,7 @@ private fun DisplayFollowUnfollowButton(
if (isLoggedInFollowingUser) {
UnfollowButton {
if (!accountViewModel.isWriteable()) {
- if (accountViewModel.loggedInWithAmber()) {
+ if (accountViewModel.loggedInWithExternalSigner()) {
scope.launch(Dispatchers.IO) {
accountViewModel.account.unfollow(baseUser)
}
@@ -773,7 +773,7 @@ private fun DisplayFollowUnfollowButton(
if (isUserFollowingLoggedIn) {
FollowButton(R.string.follow_back) {
if (!accountViewModel.isWriteable()) {
- if (accountViewModel.loggedInWithAmber()) {
+ if (accountViewModel.loggedInWithExternalSigner()) {
scope.launch(Dispatchers.IO) {
accountViewModel.account.follow(baseUser)
}
@@ -797,7 +797,7 @@ private fun DisplayFollowUnfollowButton(
} else {
FollowButton(R.string.follow) {
if (!accountViewModel.isWriteable()) {
- if (accountViewModel.loggedInWithAmber()) {
+ if (accountViewModel.loggedInWithExternalSigner()) {
scope.launch(Dispatchers.IO) {
accountViewModel.account.follow(baseUser)
}
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/LoginScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/LoginScreen.kt
index 8614e56fc..cc98c7e58 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/LoginScreen.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/LoginScreen.kt
@@ -42,7 +42,7 @@ import androidx.compose.ui.unit.dp
import com.vitorpamplona.amethyst.Amethyst
import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.ServiceManager
-import com.vitorpamplona.amethyst.service.AmberUtils
+import com.vitorpamplona.amethyst.service.ExternalSignerUtils
import com.vitorpamplona.amethyst.service.PackageUtils
import com.vitorpamplona.amethyst.service.SignerType
import com.vitorpamplona.amethyst.ui.qrcode.SimpleQrCodeScanner
@@ -74,12 +74,12 @@ fun LoginPage(
val proxyPort = remember { mutableStateOf("9050") }
var connectOrbotDialogOpen by remember { mutableStateOf(false) }
val scope = rememberCoroutineScope()
- var loginWithAmber by remember { mutableStateOf(false) }
+ var loginWithExternalSigner by remember { mutableStateOf(false) }
val activity = rememberLauncherForActivityResult(
contract = ActivityResultContracts.StartActivityForResult(),
onResult = {
- loginWithAmber = false
- AmberUtils.isActivityRunning = false
+ loginWithExternalSigner = false
+ ExternalSignerUtils.isActivityRunning = false
ServiceManager.shouldPauseService = true
if (it.resultCode != Activity.RESULT_OK) {
scope.launch(Dispatchers.Main) {
@@ -114,9 +114,9 @@ fun LoginPage(
}
)
- LaunchedEffect(loginWithAmber) {
- if (loginWithAmber) {
- AmberUtils.openAmber(
+ LaunchedEffect(loginWithExternalSigner) {
+ if (loginWithExternalSigner) {
+ ExternalSignerUtils.openSigner(
"",
SignerType.GET_PUBLIC_KEY,
activity,
@@ -357,9 +357,9 @@ fun LoginPage(
Box(modifier = Modifier.padding(40.dp, 40.dp, 40.dp, 0.dp)) {
Button(
onClick = {
- val result = AmberUtils.getDataFromResolver(SignerType.GET_PUBLIC_KEY, arrayOf("login"), "")
+ val result = ExternalSignerUtils.getDataFromResolver(SignerType.GET_PUBLIC_KEY, arrayOf("login"), "")
if (result == null) {
- loginWithAmber = true
+ loginWithExternalSigner = true
return@Button
}
key.value = TextFieldValue(result)
@@ -395,7 +395,7 @@ fun LoginPage(
backgroundColor = if (acceptedTerms.value) MaterialTheme.colors.primary else Color.Gray
)
) {
- Text(text = stringResource(R.string.login_with_amber))
+ Text(text = stringResource(R.string.login_with_external_signer))
}
}
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index b37888884..7e05854cd 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -552,7 +552,7 @@
Created at
Rules
- Login with Amber
+ Login with Amber
Update your status
@@ -588,6 +588,6 @@
Lightning wallets not found
Paid
Wallet %1$s
- Error opening Amber
+ Error opening signer app
Sign request rejected