Rename NostrSigner.kt to Amber.kt

This commit is contained in:
greenart7c3
2025-04-30 07:09:52 -03:00
parent 0f319e9532
commit aff1e9a240
42 changed files with 333 additions and 329 deletions
+1 -1
View File
@@ -13,7 +13,7 @@
</queries>
<application
android:name=".NostrSigner">
android:name=".Amber">
<service
android:name=".service.ConnectivityService"
+1 -1
View File
@@ -14,7 +14,7 @@
<application
android:largeHeap="true"
android:name=".NostrSigner"
android:name=".Amber"
android:allowBackup="false"
android:configChanges="orientation|screenSize|screenLayout"
android:dataExtractionRules="@xml/data_extraction_rules"
@@ -44,7 +44,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
class NostrSigner : Application() {
class Amber : Application() {
val factory = OkHttpWebSocket.BuilderFactory { _, useProxy ->
HttpClientManager.getHttpClient(useProxy)
}
@@ -90,7 +90,7 @@ class NostrSigner : Application() {
val alarmManager = this.getSystemService(ALARM_SERVICE) as AlarmManager
val intent = Intent(this, BootReceiver::class.java)
intent.action = "CLEAR_LOGS"
intent.action = BootReceiver.CLEAR_LOGS_ACTION
val pendingIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT + PendingIntent.FLAG_MUTABLE)
// Set up the alarm to trigger every 24 hours
@@ -121,7 +121,7 @@ class NostrSigner : Application() {
}
runBlocking(Dispatchers.IO) {
LocalPreferences.migrateTorSettings(this@NostrSigner)
LocalPreferences.migrateTorSettings(this@Amber)
settings = LocalPreferences.loadSettingsFromEncryptedStorage()
}
@@ -321,10 +321,10 @@ class NostrSigner : Application() {
companion object {
@Volatile
private var _instance: NostrSigner? = null
val instance: NostrSigner get() =
private var _instance: Amber? = null
val instance: Amber get() =
_instance ?: synchronized(this) {
_instance ?: NostrSigner().also { _instance = it }
_instance ?: Amber().also { _instance = it }
}
}
}
@@ -108,7 +108,7 @@ object LocalPreferences {
}
fun saveSettingsToEncryptedStorage(settings: AmberSettings) {
val context = NostrSigner.instance
val context = Amber.instance
encryptedPreferences(context).edit {
apply {
putStringSet(SettingsKeys.DEFAULT_RELAYS, settings.defaultRelays.map { it.url }.toSet())
@@ -148,17 +148,17 @@ object LocalPreferences {
}
fun loadPinFromEncryptedStorage(): String? {
val context = NostrSigner.instance
val context = Amber.instance
return encryptedPreferences(context).getString(SettingsKeys.PIN, null)
}
fun loadProfileUrlFromEncryptedStorage(npub: String): String? {
val context = NostrSigner.instance
val context = Amber.instance
return encryptedPreferences(context, npub).getString(PrefKeys.PROFILE_URL, null)
}
fun saveProfileUrlToEncryptedStorage(profileUrl: String?, npub: String) {
val context = NostrSigner.instance
val context = Amber.instance
encryptedPreferences(context, npub).edit {
apply {
if (profileUrl == null) {
@@ -171,7 +171,7 @@ object LocalPreferences {
}
fun savePinToEncryptedStorage(pin: String?) {
val context = NostrSigner.instance
val context = Amber.instance
encryptedPreferences(context).edit {
apply {
if (pin == null) {
@@ -183,7 +183,7 @@ object LocalPreferences {
}
}
fun loadSettingsFromEncryptedStorage(context: Context = NostrSigner.instance): AmberSettings {
fun loadSettingsFromEncryptedStorage(context: Context = Amber.instance): AmberSettings {
checkNotInMainThread()
encryptedPreferences(context).apply {
val proxyPort = getInt(SettingsKeys.PROXY_PORT, 9050)
@@ -375,7 +375,7 @@ object LocalPreferences {
putInt(SettingsKeys.PROXY_PORT, port)
}
}
NostrSigner.instance.settings = loadSettingsFromEncryptedStorage()
Amber.instance.settings = loadSettingsFromEncryptedStorage()
HttpClientManager.setDefaultProxyOnPort(port)
}
@@ -103,7 +103,7 @@ class MainActivity : AppCompatActivity() {
LaunchedEffect(Unit) {
launch(Dispatchers.IO) {
val settings = NostrSigner.instance.settings
val settings = Amber.instance.settings
val lastAuthTime = settings.lastBiometricsTime
val whenToAsk = settings.biometricsTimeType
val isTimeToAsk = when (whenToAsk) {
@@ -126,11 +126,11 @@ class MainActivity : AppCompatActivity() {
this@MainActivity,
keyguardLauncher,
{
NostrSigner.instance.settings = NostrSigner.instance.settings.copy(
Amber.instance.settings = Amber.instance.settings.copy(
lastBiometricsTime = System.currentTimeMillis(),
)
LocalPreferences.saveSettingsToEncryptedStorage(NostrSigner.instance.settings)
LocalPreferences.saveSettingsToEncryptedStorage(Amber.instance.settings)
isAuthenticated = true
},
{ _, message ->
@@ -183,11 +183,11 @@ class MainActivity : AppCompatActivity() {
onPinEntered = {
val pin = LocalPreferences.loadPinFromEncryptedStorage()
if (it == pin) {
NostrSigner.instance.settings = NostrSigner.instance.settings.copy(
Amber.instance.settings = Amber.instance.settings.copy(
lastBiometricsTime = System.currentTimeMillis(),
)
LocalPreferences.saveSettingsToEncryptedStorage(NostrSigner.instance.settings)
LocalPreferences.saveSettingsToEncryptedStorage(Amber.instance.settings)
isAuthenticated = true
showPinDialog = false
} else {
@@ -261,7 +261,7 @@ class MainActivity : AppCompatActivity() {
val connectivityManager =
(getSystemService(ConnectivityManager::class.java) as ConnectivityManager)
connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork)?.let {
NostrSigner.instance.updateNetworkCapabilities(it)
Amber.instance.updateNetworkCapabilities(it)
}
}
super.onResume()
@@ -98,7 +98,7 @@ class MainViewModel(val context: Context) : ViewModel() {
account?.let { acc ->
requests.forEach {
val contentIntent =
Intent(NostrSigner.instance, MainActivity::class.java).apply {
Intent(Amber.instance, MainActivity::class.java).apply {
data = "nostrsigner:".toUri()
}
contentIntent.putExtra("bunker", it.toJson())
@@ -64,7 +64,7 @@ class SignerProvider : ContentProvider() {
val npub = IntentUtils.parsePubKey(projection[2]) ?: return null
if (!LocalPreferences.containsAccount(context!!, npub)) return null
val account = LocalPreferences.loadFromEncryptedStorage(context!!, npub) ?: return null
val database = NostrSigner.instance.getDatabase(account.npub)
val database = Amber.instance.getDatabase(account.npub)
val signPolicy = database.applicationDao().getSignPolicy(sortOrder ?: packageName)
val permission =
database
@@ -128,7 +128,7 @@ class SignerProvider : ContentProvider() {
return null
}
val database = NostrSigner.instance.getDatabase(account.npub)
val database = Amber.instance.getDatabase(account.npub)
var permission =
database
.applicationDao()
@@ -240,7 +240,7 @@ class SignerProvider : ContentProvider() {
val stringType = uri.toString().replace("content://$appId.", "")
val pubkey = projection[1]
val account = LocalPreferences.loadFromEncryptedStorage(context!!, npub) ?: return null
val database = NostrSigner.instance.getDatabase(account.npub)
val database = Amber.instance.getDatabase(account.npub)
var permission =
database
.applicationDao()
@@ -346,7 +346,7 @@ class SignerProvider : ContentProvider() {
"content://$appId.GET_PUBLIC_KEY" -> {
val packageName = callingPackage ?: return null
val account = LocalPreferences.loadFromEncryptedStorage(context!!) ?: return null
val database = NostrSigner.instance.getDatabase(account.npub)
val database = Amber.instance.getDatabase(account.npub)
val permission =
database
.applicationDao()
@@ -11,7 +11,7 @@ import com.fasterxml.jackson.databind.deser.std.StdDeserializer
import com.fasterxml.jackson.databind.module.SimpleModule
import com.fasterxml.jackson.databind.ser.std.StdSerializer
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.Amber
import com.vitorpamplona.ammolite.relays.COMMON_FEED_TYPES
import com.vitorpamplona.ammolite.relays.RelaySetupInfo
@@ -90,7 +90,7 @@ data class BunkerRequest(
var relayUrl = it.asText().intern()
if (relayUrl.endsWith("/")) relayUrl = relayUrl.dropLast(1)
RelaySetupInfo(relayUrl, read = true, write = true, feedTypes = COMMON_FEED_TYPES)
} ?: NostrSigner.instance.getSavedRelays().toList(),
} ?: Amber.instance.getSavedRelays().toList(),
secret = jsonObject.get("secret")?.asText()?.intern() ?: "",
currentAccount = jsonObject.get("currentAccount")?.asText()?.intern() ?: "",
encryptionType = encryptionType,
@@ -2,8 +2,8 @@ package com.greenart7c3.nostrsigner.relays
import android.annotation.SuppressLint
import android.content.Context
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.LocalPreferences
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.database.LogEntity
import com.greenart7c3.nostrsigner.ui.AccountStateViewModel
import com.vitorpamplona.ammolite.relays.NostrClient
@@ -47,7 +47,7 @@ class AmberClientListener(
override fun onAuth(relay: Relay, challenge: String) {
scope.launch {
LocalPreferences.currentAccount(context)?.let { account ->
NostrSigner.instance.getDatabase(account).applicationDao().insertLog(
Amber.instance.getDatabase(account).applicationDao().insertLog(
LogEntity(
id = 0,
url = relay.url,
@@ -63,7 +63,7 @@ class AmberClientListener(
override fun onBeforeSend(relay: Relay, event: Event) {
scope.launch {
LocalPreferences.currentAccount(context)?.let { account ->
NostrSigner.instance.getDatabase(account).applicationDao().insertLog(
Amber.instance.getDatabase(account).applicationDao().insertLog(
LogEntity(
id = 0,
url = relay.url,
@@ -79,7 +79,7 @@ class AmberClientListener(
override fun onSend(relay: Relay, msg: String, success: Boolean) {
scope.launch {
LocalPreferences.currentAccount(context)?.let { account ->
NostrSigner.instance.getDatabase(account).applicationDao().insertLog(
Amber.instance.getDatabase(account).applicationDao().insertLog(
LogEntity(
id = 0,
url = relay.url,
@@ -102,7 +102,7 @@ class AmberClientListener(
override fun onSendResponse(eventId: String, success: Boolean, message: String, relay: Relay) {
scope.launch {
LocalPreferences.currentAccount(context)?.let { account ->
NostrSigner.instance.getDatabase(account).applicationDao().insertLog(
Amber.instance.getDatabase(account).applicationDao().insertLog(
LogEntity(
id = 0,
url = relay.url,
@@ -123,7 +123,7 @@ class AmberClientListener(
if (error.message?.trim()?.equals("Relay sent notice:") == true) return
scope.launch {
LocalPreferences.currentAccount(context)?.let { account ->
NostrSigner.instance.getDatabase(account).applicationDao().insertLog(
Amber.instance.getDatabase(account).applicationDao().insertLog(
LogEntity(
id = 0,
url = relay.url,
@@ -134,7 +134,7 @@ class AmberClientListener(
)
}
}
if (NostrSigner.instance.settings.useProxy && error.message?.contains("(port ${NostrSigner.instance.settings.proxyPort})") == true) {
if (Amber.instance.settings.useProxy && error.message?.contains("(port ${Amber.instance.settings.proxyPort})") == true) {
AmberListenerSingleton.latestErrorMessages.add("Failed to connect to Tor/Orbot")
} else {
AmberListenerSingleton.latestErrorMessages.add(error.message ?: "Unknown error")
@@ -144,7 +144,7 @@ class AmberClientListener(
override fun onEvent(event: Event, subscriptionId: String, relay: Relay, afterEOSE: Boolean) {
scope.launch {
LocalPreferences.currentAccount(context)?.let { account ->
NostrSigner.instance.getDatabase(account).applicationDao().insertLog(
Amber.instance.getDatabase(account).applicationDao().insertLog(
LogEntity(
id = 0,
url = relay.url,
@@ -160,7 +160,7 @@ class AmberClientListener(
override fun onNotify(relay: Relay, description: String) {
scope.launch {
LocalPreferences.currentAccount(context)?.let { account ->
NostrSigner.instance.getDatabase(account).applicationDao().insertLog(
Amber.instance.getDatabase(account).applicationDao().insertLog(
LogEntity(
id = 0,
url = relay.url,
@@ -176,7 +176,7 @@ class AmberClientListener(
override fun onRelayStateChange(type: RelayState, relay: Relay) {
scope.launch {
LocalPreferences.currentAccount(context)?.let { account ->
NostrSigner.instance.getDatabase(account).applicationDao().insertLog(
Amber.instance.getDatabase(account).applicationDao().insertLog(
LogEntity(
id = 0,
url = relay.url,
@@ -12,8 +12,8 @@ import androidx.core.app.NotificationChannelCompat
import androidx.core.app.NotificationChannelGroupCompat
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.MainActivity
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.R
import com.vitorpamplona.ammolite.relays.RelayStats
import kotlinx.coroutines.launch
@@ -22,8 +22,8 @@ object AmberRelayStats {
var connected = 0
var available = 0
init {
NostrSigner.instance.applicationIOScope.launch {
NostrSigner.instance.client.relayStatusFlow().collect {
Amber.instance.applicationIOScope.launch {
Amber.instance.client.relayStatusFlow().collect {
connected = it.connected
available = it.available
}
@@ -34,62 +34,62 @@ object AmberRelayStats {
fun createNotification(): Notification {
val channelId = "ServiceChannel"
val group = NotificationChannelGroupCompat.Builder("ServiceGroup")
.setName(NostrSigner.instance.getString(R.string.service))
.setDescription(NostrSigner.instance.getString(R.string.service_description))
.setName(Amber.instance.getString(R.string.service))
.setDescription(Amber.instance.getString(R.string.service_description))
.build()
val channel = NotificationChannelCompat.Builder(channelId, NotificationManager.IMPORTANCE_DEFAULT)
.setName(NostrSigner.instance.getString(R.string.service))
.setDescription(NostrSigner.instance.getString(R.string.amber_is_running_in_background))
.setName(Amber.instance.getString(R.string.service))
.setDescription(Amber.instance.getString(R.string.amber_is_running_in_background))
.setSound(null, null)
.setGroup(group.id)
.build()
val notificationManager = NotificationManagerCompat.from(NostrSigner.instance)
val notificationManager = NotificationManagerCompat.from(Amber.instance)
notificationManager.createNotificationChannelGroup(group)
notificationManager.createNotificationChannel(channel)
val localConnected = NostrSigner.instance.client.connectedRelays()
val localAvailable = NostrSigner.instance.client.getAll().size
val localConnected = Amber.instance.client.connectedRelays()
val localAvailable = Amber.instance.client.getAll().size
if (localAvailable != available || localConnected != connected) {
available = localAvailable
connected = localConnected
}
val message = NostrSigner.instance.client.getAll().joinToString("\n") {
val connected = "${it.url} ${if (it.isConnected()) NostrSigner.instance.getString(R.string.connected) else NostrSigner.instance.getString(R.string.disconnected)}\n"
val ping = NostrSigner.instance.getString(R.string.ping_ms, RelayStats.get(it.url).pingInMs)
val message = Amber.instance.client.getAll().joinToString("\n") {
val connected = "${it.url} ${if (it.isConnected()) Amber.instance.getString(R.string.connected) else Amber.instance.getString(R.string.disconnected)}\n"
val ping = Amber.instance.getString(R.string.ping_ms, RelayStats.get(it.url).pingInMs)
val sent = if (get(it.url).sent > 0) {
NostrSigner.instance.getString(R.string.sent, get(it.url).sent)
Amber.instance.getString(R.string.sent, get(it.url).sent)
} else {
""
}
val received = if (get(it.url).received > 0) {
NostrSigner.instance.getString(R.string.received, get(it.url).received)
Amber.instance.getString(R.string.received, get(it.url).received)
} else {
""
}
val failed = if (get(it.url).failed > 0) {
NostrSigner.instance.getString(R.string.rejected_by_relay, get(it.url).failed)
Amber.instance.getString(R.string.rejected_by_relay, get(it.url).failed)
} else {
""
}
val error = if (RelayStats.get(it.url).errorCounter > 0) NostrSigner.instance.getString(R.string.error, RelayStats.get(it.url).errorCounter) else ""
val error = if (RelayStats.get(it.url).errorCounter > 0) Amber.instance.getString(R.string.error, RelayStats.get(it.url).errorCounter) else ""
connected + ping + sent + received + failed + error
}
val contentIntent = Intent(NostrSigner.instance, MainActivity::class.java)
val contentIntent = Intent(Amber.instance, MainActivity::class.java)
contentIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP)
val contentPendingIntent =
PendingIntent.getActivity(
NostrSigner.instance,
Amber.instance,
0,
contentIntent,
PendingIntent.FLAG_MUTABLE,
)
val notificationBuilder =
NotificationCompat.Builder(NostrSigner.instance, channelId)
NotificationCompat.Builder(Amber.instance, channelId)
.setGroup(group.id)
.setContentTitle("$connected of $available connected relays")
.setStyle(
@@ -105,8 +105,8 @@ object AmberRelayStats {
fun updateNotification() {
Log.d("ConnectivityService", "updateNotification")
val notificationManager = NotificationManagerCompat.from(NostrSigner.instance)
if (ActivityCompat.checkSelfPermission(NostrSigner.instance, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) {
val notificationManager = NotificationManagerCompat.from(Amber.instance)
if (ActivityCompat.checkSelfPermission(Amber.instance, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) {
notificationManager.notify(1, createNotification())
}
}
@@ -2,7 +2,7 @@ package com.greenart7c3.nostrsigner.service
import android.content.Context
import android.util.Log
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.database.ApplicationPermissionsEntity
import com.greenart7c3.nostrsigner.database.ApplicationWithPermissions
import com.greenart7c3.nostrsigner.models.Account
@@ -178,7 +178,7 @@ object AmberUtils {
),
)
NostrSigner.instance.getDatabase(account.npub)
Amber.instance.getDatabase(account.npub)
.applicationDao()
.insertApplicationWithPermissions(application)
}
@@ -5,9 +5,9 @@ import android.content.Context
import android.content.Intent
import android.os.Build
import android.util.Log
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.BuildConfig
import com.greenart7c3.nostrsigner.LocalPreferences
import com.greenart7c3.nostrsigner.NostrSigner
import com.vitorpamplona.quartz.utils.TimeUtils
import com.vitorpamplona.quartz.utils.TimeUtils.ONE_WEEK
import kotlin.coroutines.cancellation.CancellationException
@@ -15,6 +15,10 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
class BootReceiver : BroadcastReceiver() {
companion object {
const val CLEAR_LOGS_ACTION = "CLEAR_AMBER_LOGS"
}
override fun onReceive(context: Context, intent: Intent) {
@Suppress("KotlinConstantConditions")
if (BuildConfig.FLAVOR == "offline") return
@@ -46,10 +50,10 @@ class BootReceiver : BroadcastReceiver() {
),
)
}
"CLEAR_LOGS" -> {
NostrSigner.instance.applicationIOScope.launch(Dispatchers.IO) {
LocalPreferences.allSavedAccounts(NostrSigner.instance).forEach {
NostrSigner.instance.getDatabase(it.npub).let { database ->
CLEAR_LOGS_ACTION -> {
Amber.instance.applicationIOScope.launch(Dispatchers.IO) {
LocalPreferences.allSavedAccounts(Amber.instance).forEach {
Amber.instance.getDatabase(it.npub).let { database ->
try {
val oneWeek = System.currentTimeMillis() - ONE_WEEK
val oneWeekAgo = TimeUtils.oneWeekAgo()
@@ -4,8 +4,8 @@ import android.content.Context
import android.content.Intent
import android.util.Log
import androidx.compose.runtime.mutableStateOf
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.LocalPreferences
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.database.LogEntity
import com.greenart7c3.nostrsigner.models.Account
import com.greenart7c3.nostrsigner.models.BunkerRequest
@@ -64,8 +64,8 @@ object BunkerRequestUtils {
if (relays.isEmpty()) {
onDone(true)
onLoading(false)
NostrSigner.instance.applicationIOScope.launch {
NostrSigner.instance.getDatabase(account.npub).applicationDao().insertLog(
Amber.instance.applicationIOScope.launch {
Amber.instance.getDatabase(account.npub).applicationDao().insertLog(
LogEntity(
id = 0,
url = bunkerRequest.localKey,
@@ -80,18 +80,18 @@ object BunkerRequestUtils {
}
AmberListenerSingleton.getListener()?.let {
NostrSigner.instance.client.unsubscribe(it)
Amber.instance.client.unsubscribe(it)
}
AmberListenerSingleton.setListener(
context,
)
NostrSigner.instance.client.subscribe(
Amber.instance.client.subscribe(
AmberListenerSingleton.getListener()!!,
)
NostrSigner.instance.applicationIOScope.launch {
Amber.instance.applicationIOScope.launch {
relays.forEach { relay ->
NostrSigner.instance.getDatabase(account.npub).applicationDao().insertLog(
Amber.instance.getDatabase(account.npub).applicationDao().insertLog(
LogEntity(
id = 0,
url = relay.url,
@@ -114,7 +114,7 @@ object BunkerRequestUtils {
account = account,
localKey = bunkerRequest.localKey,
encryptedContent = encryptedContent,
relays = relays.ifEmpty { NostrSigner.instance.getSavedRelays().toList() },
relays = relays.ifEmpty { Amber.instance.getSavedRelays().toList() },
onLoading = onLoading,
onDone = onDone,
)
@@ -130,7 +130,7 @@ object BunkerRequestUtils {
account = account,
localKey = bunkerRequest.localKey,
encryptedContent = encryptedContent,
relays = relays.ifEmpty { NostrSigner.instance.getSavedRelays().toList() },
relays = relays.ifEmpty { Amber.instance.getSavedRelays().toList() },
onLoading = onLoading,
onDone = onDone,
)
@@ -154,11 +154,11 @@ object BunkerRequestUtils {
arrayOf(arrayOf("p", localKey)),
encryptedContent,
) {
NostrSigner.instance.applicationIOScope.launch {
Amber.instance.applicationIOScope.launch {
Log.d("IntentUtils", "Sending response to relays ${relays.map { it.url }} type ${bunkerRequest?.method}")
if (NostrSigner.instance.client.getAll().any { !it.isConnected() }) {
NostrSigner.instance.checkForNewRelays(
if (Amber.instance.client.getAll().any { !it.isConnected() }) {
Amber.instance.checkForNewRelays(
newRelays = relays.toSet(),
)
}
@@ -166,12 +166,12 @@ object BunkerRequestUtils {
var success = false
var errorCount = 0
while (!success && errorCount < 3) {
success = NostrSigner.instance.client.sendAndWaitForResponse(it, relayList = relays)
success = Amber.instance.client.sendAndWaitForResponse(it, relayList = relays)
if (!success) {
errorCount++
relays.forEach {
if (NostrSigner.instance.client.getRelay(it.url)?.isConnected() == false) {
NostrSigner.instance.client.getRelay(it.url)?.connect()
if (Amber.instance.client.getRelay(it.url)?.isConnected() == false) {
Amber.instance.client.getRelay(it.url)?.connect()
}
}
delay(1000)
@@ -186,7 +186,7 @@ object BunkerRequestUtils {
Log.d("IntentUtils", "Failed response to relays ${relays.map { it.url }} type ${bunkerRequest?.method}")
}
AmberListenerSingleton.getListener()?.let {
NostrSigner.instance.client.unsubscribe(it)
Amber.instance.client.unsubscribe(it)
}
onLoading(false)
}
@@ -335,8 +335,8 @@ object BunkerRequestUtils {
pubKey,
) ?: "Could not decrypt the message"
} catch (e: Exception) {
NostrSigner.instance.applicationIOScope.launch {
val database = NostrSigner.instance.getDatabase(account.npub)
Amber.instance.applicationIOScope.launch {
val database = Amber.instance.getDatabase(account.npub)
database.applicationDao().insertLog(
LogEntity(
0,
@@ -7,8 +7,8 @@ import android.net.Network
import android.net.NetworkCapabilities
import android.os.IBinder
import android.util.Log
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.BuildConfig
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.relays.AmberRelayStats
import java.util.Timer
import java.util.TimerTask
@@ -31,11 +31,11 @@ class ConnectivityService : Service() {
@Suppress("KotlinConstantConditions")
if (BuildConfig.FLAVOR == "offline") return
val hasAnyRelayDisconnected = NostrSigner.instance.client.getAll().any { !it.isConnected() }
val hasAnyRelayDisconnected = Amber.instance.client.getAll().any { !it.isConnected() }
if (lastNetwork != null && lastNetwork != network && hasAnyRelayDisconnected) {
scope.launch(Dispatchers.IO) {
NostrSigner.instance.client.getAll().forEach {
Amber.instance.client.getAll().forEach {
if (!it.isConnected()) {
Log.d(
"ConnectivityService",
@@ -63,13 +63,13 @@ class ConnectivityService : Service() {
scope.launch(Dispatchers.IO) {
Log.d(
"ServiceManager NetworkCallback",
"onCapabilitiesChanged: ${network.networkHandle} hasMobileData ${NostrSigner.instance.isOnMobileDataState.value} hasWifi ${NostrSigner.instance.isOnWifiDataState.value}",
"onCapabilitiesChanged: ${network.networkHandle} hasMobileData ${Amber.instance.isOnMobileDataState.value} hasWifi ${Amber.instance.isOnWifiDataState.value}",
)
val hasAnyRelayDisconnected = NostrSigner.instance.client.getAll().any { !it.isConnected() }
val hasAnyRelayDisconnected = Amber.instance.client.getAll().any { !it.isConnected() }
if (NostrSigner.instance.updateNetworkCapabilities(networkCapabilities) && hasAnyRelayDisconnected) {
NostrSigner.instance.client.getAll().forEach {
if (Amber.instance.updateNetworkCapabilities(networkCapabilities) && hasAnyRelayDisconnected) {
Amber.instance.client.getAll().forEach {
if (!it.isConnected()) {
Log.d(
"ConnectivityService",
@@ -95,9 +95,9 @@ class ConnectivityService : Service() {
isStarted = true
@Suppress("KotlinConstantConditions")
if (BuildConfig.FLAVOR != "offline" && NostrSigner.instance.client.getAll().isEmpty()) {
NostrSigner.instance.applicationIOScope.launch {
NostrSigner.instance.checkForNewRelays()
if (BuildConfig.FLAVOR != "offline" && Amber.instance.client.getAll().isEmpty()) {
Amber.instance.applicationIOScope.launch {
Amber.instance.checkForNewRelays()
NotificationDataSource.start()
}
}
@@ -110,7 +110,7 @@ class ConnectivityService : Service() {
(getSystemService(ConnectivityManager::class.java) as ConnectivityManager)
connectivityManager.registerDefaultNetworkCallback(networkCallback)
connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork)?.let {
NostrSigner.instance.updateNetworkCapabilities(it)
Amber.instance.updateNetworkCapabilities(it)
}
}
@@ -122,7 +122,7 @@ class ConnectivityService : Service() {
return
}
NostrSigner.instance.client.getAll().forEach {
Amber.instance.client.getAll().forEach {
if (!it.isConnected()) {
Log.d(
"ConnectivityService",
@@ -27,9 +27,9 @@ import androidx.compose.ui.text.intl.Locale
import androidx.compose.ui.text.toLowerCase
import androidx.core.content.ContextCompat
import androidx.core.net.toUri
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.BuildConfig
import com.greenart7c3.nostrsigner.LocalPreferences
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.R
import com.greenart7c3.nostrsigner.database.ApplicationWithPermissions
import com.greenart7c3.nostrsigner.database.HistoryEntity2
@@ -56,11 +56,11 @@ import kotlinx.coroutines.launch
class EventNotificationConsumer(private val applicationContext: Context) {
private fun saveLog(text: String) {
Log.d("EventNotificationConsumer", text)
NostrSigner.instance.applicationIOScope.launch {
Amber.instance.applicationIOScope.launch {
val accounts = LocalPreferences.allSavedAccounts(applicationContext)
accounts.forEach {
LocalPreferences.loadFromEncryptedStorage(applicationContext, it.npub)?.let { acc ->
val dao = NostrSigner.instance.getDatabase(acc.npub).applicationDao()
val dao = Amber.instance.getDatabase(acc.npub).applicationDao()
dao.insertLog(
LogEntity(
0,
@@ -104,8 +104,8 @@ class EventNotificationConsumer(private val applicationContext: Context) {
) {
if (event.content.isEmpty()) return
val dao = NostrSigner.instance.getDatabase(acc.npub).applicationDao()
NostrSigner.instance.applicationIOScope.launch {
val dao = Amber.instance.getDatabase(acc.npub).applicationDao()
Amber.instance.applicationIOScope.launch {
dao.insertLog(
LogEntity(
0,
@@ -119,13 +119,13 @@ class EventNotificationConsumer(private val applicationContext: Context) {
if (EncryptedInfo.isNIP04(event.content)) {
acc.signer.nip04Decrypt(event.content, event.pubKey) {
NostrSigner.instance.applicationIOScope.launch {
Amber.instance.applicationIOScope.launch {
notify(event, acc, it, EncryptionType.NIP04, relay)
}
}
} else {
acc.signer.nip44Decrypt(event.content, event.pubKey) {
NostrSigner.instance.applicationIOScope.launch {
Amber.instance.applicationIOScope.launch {
notify(event, acc, it, EncryptionType.NIP44, relay)
}
}
@@ -140,7 +140,7 @@ class EventNotificationConsumer(private val applicationContext: Context) {
relay: Relay,
) {
val responseRelay = listOf(RelaySetupInfo(relay.url, read = true, write = true, feedTypes = COMMON_FEED_TYPES))
val dao = NostrSigner.instance.getDatabase(acc.npub).applicationDao()
val dao = Amber.instance.getDatabase(acc.npub).applicationDao()
val notification = dao.getNotification(event.id)
if (notification != null) return
dao.insertNotification(NotificationEntity(0, event.id, event.createdAt))
@@ -175,11 +175,11 @@ class EventNotificationConsumer(private val applicationContext: Context) {
""
}
val database = NostrSigner.instance.getDatabase(acc.npub)
val database = Amber.instance.getDatabase(acc.npub)
val permission = database.applicationDao().getByKey(bunkerRequest.localKey)
if (permission != null && ((permission.application.secret != permission.application.key && permission.application.useSecret) || permission.application.isConnected) && type == SignerType.CONNECT) {
NostrSigner.instance.applicationIOScope.launch {
Amber.instance.applicationIOScope.launch {
database.applicationDao()
.addHistory(
HistoryEntity2(
@@ -9,8 +9,8 @@ import androidx.compose.ui.text.toLowerCase
import androidx.core.net.toUri
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.LocalPreferences
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.database.LogEntity
import com.greenart7c3.nostrsigner.models.Account
import com.greenart7c3.nostrsigner.models.BunkerRequest
@@ -159,8 +159,8 @@ object IntentUtils {
pubKey,
) ?: "Could not decrypt the message"
} catch (e: Exception) {
NostrSigner.instance.applicationIOScope.launch {
val database = NostrSigner.instance.getDatabase(account.npub)
Amber.instance.applicationIOScope.launch {
val database = Amber.instance.getDatabase(account.npub)
database.applicationDao().insertLog(
LogEntity(
0,
@@ -348,8 +348,8 @@ object IntentUtils {
pubKey,
) ?: "Could not decrypt the message"
} catch (e: Exception) {
NostrSigner.instance.applicationIOScope.launch {
val database = NostrSigner.instance.getDatabase(account.npub)
Amber.instance.applicationIOScope.launch {
val database = Amber.instance.getDatabase(account.npub)
database.applicationDao().insertLog(
LogEntity(
0,
@@ -509,9 +509,9 @@ object IntentUtils {
getIntentDataWithoutExtras(context, intent.data?.toString() ?: "", intent, packageName, route, localAccount, onReady)
}
} catch (e: Exception) {
NostrSigner.instance.applicationIOScope.launch {
LocalPreferences.allSavedAccounts(NostrSigner.instance).forEach {
NostrSigner.instance.getDatabase(it.npub).applicationDao().insertLog(
Amber.instance.applicationIOScope.launch {
LocalPreferences.allSavedAccounts(Amber.instance).forEach {
Amber.instance.getDatabase(it.npub).applicationDao().insertLog(
LogEntity(
id = 0,
url = "IntentUtils",
@@ -3,7 +3,7 @@ package com.greenart7c3.nostrsigner.service
import android.content.Intent
import android.util.Log
import androidx.compose.runtime.mutableStateOf
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.database.LogEntity
import com.greenart7c3.nostrsigner.models.Account
import com.greenart7c3.nostrsigner.models.BunkerMetadata
@@ -133,7 +133,7 @@ object NostrConnectUtils {
"connect",
arrayOf(pubKey),
pubKey,
relays.ifEmpty { NostrSigner.instance.getSavedRelays().toList() },
relays.ifEmpty { Amber.instance.getSavedRelays().toList() },
"",
account.npub,
EncryptionType.NIP04,
@@ -147,8 +147,8 @@ object NostrConnectUtils {
)
} catch (e: Exception) {
Log.e("nostrconnect", e.message, e)
NostrSigner.instance.applicationIOScope.launch {
NostrSigner.instance.getDatabase(account.npub).applicationDao().insertLog(
Amber.instance.applicationIOScope.launch {
Amber.instance.getDatabase(account.npub).applicationDao().insertLog(
LogEntity(
0,
"nostrconnect",
@@ -21,8 +21,8 @@
package com.greenart7c3.nostrsigner.service
import android.util.Log
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.LocalPreferences
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.checkNotInMainThread
import com.greenart7c3.nostrsigner.database.LogEntity
import com.greenart7c3.nostrsigner.relays.AmberRelayStats
@@ -42,8 +42,8 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch
object NotificationDataSource : NostrDataSource(NostrSigner.instance.client) {
private val eventNotificationConsumer = EventNotificationConsumer(NostrSigner.instance)
object NotificationDataSource : NostrDataSource(Amber.instance.client) {
private val eventNotificationConsumer = EventNotificationConsumer(Amber.instance)
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
private val clientListener =
@@ -55,8 +55,8 @@ object NotificationDataSource : NostrDataSource(NostrSigner.instance.client) {
afterEOSE: Boolean,
) {
scope.launch {
LocalPreferences.currentAccount(NostrSigner.instance)?.let { account ->
NostrSigner.instance.getDatabase(account).applicationDao().insertLog(
LocalPreferences.currentAccount(Amber.instance)?.let { account ->
Amber.instance.getDatabase(account).applicationDao().insertLog(
LogEntity(
id = 0,
url = relay.url,
@@ -73,8 +73,8 @@ object NotificationDataSource : NostrDataSource(NostrSigner.instance.client) {
Log.d("NotificationDataSource", "onRelayStateChange: $type")
AmberRelayStats.updateNotification()
scope.launch {
LocalPreferences.currentAccount(NostrSigner.instance)?.let { account ->
NostrSigner.instance.getDatabase(account).applicationDao().insertLog(
LocalPreferences.currentAccount(Amber.instance)?.let { account ->
Amber.instance.getDatabase(account).applicationDao().insertLog(
LogEntity(
id = 0,
url = relay.url,
@@ -89,8 +89,8 @@ object NotificationDataSource : NostrDataSource(NostrSigner.instance.client) {
override fun onError(error: Error, subscriptionId: String, relay: Relay) {
scope.launch {
LocalPreferences.currentAccount(NostrSigner.instance)?.let { account ->
NostrSigner.instance.getDatabase(account).applicationDao().insertLog(
LocalPreferences.currentAccount(Amber.instance)?.let { account ->
Amber.instance.getDatabase(account).applicationDao().insertLog(
LogEntity(
id = 0,
url = relay.url,
@@ -109,8 +109,8 @@ object NotificationDataSource : NostrDataSource(NostrSigner.instance.client) {
challenge: String,
) {
scope.launch {
LocalPreferences.currentAccount(NostrSigner.instance)?.let { account ->
NostrSigner.instance.getDatabase(account).applicationDao().insertLog(
LocalPreferences.currentAccount(Amber.instance)?.let { account ->
Amber.instance.getDatabase(account).applicationDao().insertLog(
LogEntity(
id = 0,
url = relay.url,
@@ -129,8 +129,8 @@ object NotificationDataSource : NostrDataSource(NostrSigner.instance.client) {
description: String,
) {
scope.launch {
LocalPreferences.currentAccount(NostrSigner.instance)?.let { account ->
NostrSigner.instance.getDatabase(account).applicationDao().insertLog(
LocalPreferences.currentAccount(Amber.instance)?.let { account ->
Amber.instance.getDatabase(account).applicationDao().insertLog(
LogEntity(
id = 0,
url = relay.url,
@@ -174,10 +174,10 @@ object NotificationDataSource : NostrDataSource(NostrSigner.instance.client) {
private fun createNotificationsFilter(): TypedFilter {
var since = TimeUtils.now()
val accounts = LocalPreferences.allSavedAccounts(NostrSigner.instance)
val accounts = LocalPreferences.allSavedAccounts(Amber.instance)
var localLatest = 0L
accounts.forEach {
val latest = NostrSigner.instance.getDatabase(it.npub).applicationDao().getLatestNotification()
val latest = Amber.instance.getDatabase(it.npub).applicationDao().getLatestNotification()
if (latest != null && latest > localLatest) {
localLatest = latest + 1
}
@@ -188,11 +188,11 @@ object NotificationDataSource : NostrDataSource(NostrSigner.instance.client) {
val pubKeys =
accounts.mapNotNull {
LocalPreferences.loadFromEncryptedStorage(NostrSigner.instance, it.npub)?.signer?.keyPair?.pubKey?.toHexKey()
LocalPreferences.loadFromEncryptedStorage(Amber.instance, it.npub)?.signer?.keyPair?.pubKey?.toHexKey()
}
val eoses =
NostrSigner.instance.client.getAll().associate {
Amber.instance.client.getAll().associate {
Pair(it.url, EOSETime(since))
}
@@ -212,7 +212,7 @@ object NotificationDataSource : NostrDataSource(NostrSigner.instance.client) {
relay: Relay,
) {
checkNotInMainThread()
NotificationUtils.getOrCreateDMChannel(NostrSigner.instance.applicationContext)
NotificationUtils.getOrCreateDMChannel(Amber.instance.applicationContext)
AmberRelayStats.addReceived(relay.url)
eventNotificationConsumer.consume(event, relay)
}
@@ -228,10 +228,10 @@ object NotificationDataSource : NostrDataSource(NostrSigner.instance.client) {
) {
super.auth(relay, challenge)
LocalPreferences.allSavedAccounts(NostrSigner.instance).forEach {
val account = LocalPreferences.loadFromEncryptedStorage(NostrSigner.instance, it.npub) ?: return@forEach
LocalPreferences.allSavedAccounts(Amber.instance).forEach {
val account = LocalPreferences.loadFromEncryptedStorage(Amber.instance, it.npub) ?: return@forEach
account.createAuthEvent(relay.url, challenge) { authEvent ->
NostrSigner.instance.client.sendIfExists(authEvent, relay)
Amber.instance.client.sendIfExists(authEvent, relay)
}
}
}
@@ -3,8 +3,8 @@ package com.greenart7c3.nostrsigner.service
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.LocalPreferences
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.database.LogEntity
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -22,10 +22,10 @@ class RelayDisconnectService(ctx: Context, params: WorkerParameters) : Worker(ct
val url = inputData.getString("relay")
delay(60000)
url?.let {
val relay = NostrSigner.instance.client.getRelay(it)
val relay = Amber.instance.client.getRelay(it)
if (relay != null && relay.isConnected()) {
LocalPreferences.currentAccount(applicationContext)?.let { npub ->
NostrSigner.instance.getDatabase(npub).applicationDao().insertLog(
Amber.instance.getDatabase(npub).applicationDao().insertLog(
LogEntity(
id = 0,
url = relay.url,
@@ -4,8 +4,8 @@ import androidx.compose.runtime.Immutable
import androidx.compose.runtime.Stable
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.LocalPreferences
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.models.Account
import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair
import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal
@@ -83,15 +83,15 @@ class AccountStateViewModel(npub: String?) : ViewModel() {
npub: String?,
forceLogout: Boolean = false,
) {
var currentUser = npub ?: LocalPreferences.currentAccount(NostrSigner.instance)
val allAccounts = LocalPreferences.allSavedAccounts(NostrSigner.instance)
if (currentUser != null && !LocalPreferences.containsAccount(NostrSigner.instance, currentUser) && allAccounts.any { it.npub == currentUser }) {
currentUser = LocalPreferences.currentAccount(NostrSigner.instance)
var currentUser = npub ?: LocalPreferences.currentAccount(Amber.instance)
val allAccounts = LocalPreferences.allSavedAccounts(Amber.instance)
if (currentUser != null && !LocalPreferences.containsAccount(Amber.instance, currentUser) && allAccounts.any { it.npub == currentUser }) {
currentUser = LocalPreferences.currentAccount(Amber.instance)
}
if (forceLogout) {
currentUser = null
}
LocalPreferences.loadFromEncryptedStorage(NostrSigner.instance, currentUser)?.let {
LocalPreferences.loadFromEncryptedStorage(Amber.instance, currentUser)?.let {
startUI(it, route)
}
if (currentUser == null) {
@@ -102,7 +102,7 @@ class AccountStateViewModel(npub: String?) : ViewModel() {
private fun prepareLogoutOrSwitch() {
when (val state = accountContent.value) {
is AccountState.LoggedIn -> {
NostrSigner.instance.applicationIOScope.launch(Dispatchers.Main) {
Amber.instance.applicationIOScope.launch(Dispatchers.Main) {
state.account.saveable.removeObserver(saveListener)
}
}
@@ -114,7 +114,7 @@ class AccountStateViewModel(npub: String?) : ViewModel() {
fun logOff(npub: String) {
prepareLogoutOrSwitch()
val shouldLogout = LocalPreferences.updatePrefsForLogout(npub, NostrSigner.instance)
val shouldLogout = LocalPreferences.updatePrefsForLogout(npub, Amber.instance)
tryLoginExistingAccount(null, null, forceLogout = shouldLogout)
}
@@ -123,7 +123,7 @@ class AccountStateViewModel(npub: String?) : ViewModel() {
route: String?,
) {
prepareLogoutOrSwitch()
LocalPreferences.switchToAccount(NostrSigner.instance, npub)
LocalPreferences.switchToAccount(Amber.instance, npub)
tryLoginExistingAccount(route, npub)
}
@@ -232,16 +232,16 @@ class AccountStateViewModel(npub: String?) : ViewModel() {
didBackup = true,
)
}
if (LocalPreferences.allSavedAccounts(NostrSigner.instance).isEmpty()) {
NostrSigner.instance.settings = NostrSigner.instance.settings.copy(
if (LocalPreferences.allSavedAccounts(Amber.instance).isEmpty()) {
Amber.instance.settings = Amber.instance.settings.copy(
useProxy = useProxy,
proxyPort = proxyPort,
)
LocalPreferences.saveSettingsToEncryptedStorage(
NostrSigner.instance.settings,
Amber.instance.settings,
)
}
LocalPreferences.updatePrefsForLogin(NostrSigner.instance, account)
LocalPreferences.updatePrefsForLogin(Amber.instance, account)
startUI(account, route)
}
@@ -263,16 +263,16 @@ class AccountStateViewModel(npub: String?) : ViewModel() {
seedWords = seedWords,
didBackup = false,
)
if (LocalPreferences.allSavedAccounts(NostrSigner.instance).isEmpty()) {
NostrSigner.instance.settings = NostrSigner.instance.settings.copy(
if (LocalPreferences.allSavedAccounts(Amber.instance).isEmpty()) {
Amber.instance.settings = Amber.instance.settings.copy(
useProxy = useProxy,
proxyPort = proxyPort,
)
LocalPreferences.saveSettingsToEncryptedStorage(
NostrSigner.instance.settings,
Amber.instance.settings,
)
}
LocalPreferences.updatePrefsForLogin(NostrSigner.instance, account)
LocalPreferences.updatePrefsForLogin(Amber.instance, account)
startUI(account, null)
}
@@ -282,14 +282,14 @@ class AccountStateViewModel(npub: String?) : ViewModel() {
) {
_accountContent.update { AccountState.LoggedIn(account, route) }
NostrSigner.instance.applicationIOScope.launch(Dispatchers.Main) {
Amber.instance.applicationIOScope.launch(Dispatchers.Main) {
account.saveable.observeForever(saveListener)
}
}
private val saveListener: (com.greenart7c3.nostrsigner.models.AccountState) -> Unit = {
NostrSigner.instance.applicationIOScope.launch(Dispatchers.Main) {
LocalPreferences.saveToEncryptedStorage(NostrSigner.instance, it.account)
Amber.instance.applicationIOScope.launch(Dispatchers.Main) {
LocalPreferences.saveToEncryptedStorage(Amber.instance, it.account)
}
}
}
@@ -24,9 +24,9 @@ import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardCapitalization
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.unit.dp
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.BuildConfig
import com.greenart7c3.nostrsigner.LocalPreferences
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.R
import com.greenart7c3.nostrsigner.models.Account
import com.greenart7c3.nostrsigner.service.NotificationDataSource
@@ -54,7 +54,7 @@ fun DefaultProfileRelaysScreen(
val relays2 =
remember {
val localRelays = mutableStateListOf<RelaySetupInfo>()
NostrSigner.instance.settings.defaultProfileRelays.forEach {
Amber.instance.settings.defaultProfileRelays.forEach {
localRelays.add(
it.copy(),
)
@@ -107,14 +107,14 @@ fun DefaultProfileRelaysScreen(
account,
context,
onDone = {
NostrSigner.instance.settings = NostrSigner.instance.settings.copy(
Amber.instance.settings = Amber.instance.settings.copy(
defaultProfileRelays = relays2,
)
LocalPreferences.saveSettingsToEncryptedStorage(NostrSigner.instance.settings)
LocalPreferences.saveSettingsToEncryptedStorage(Amber.instance.settings)
scope.launch(Dispatchers.IO) {
@Suppress("KotlinConstantConditions")
if (BuildConfig.FLAVOR != "offline") {
NostrSigner.instance.checkForNewRelays()
Amber.instance.checkForNewRelays()
NotificationDataSource.stop()
delay(2000)
NotificationDataSource.start()
@@ -148,14 +148,14 @@ fun DefaultProfileRelaysScreen(
context,
onDone = {
isLoading.value = true
NostrSigner.instance.settings = NostrSigner.instance.settings.copy(
Amber.instance.settings = Amber.instance.settings.copy(
defaultProfileRelays = relays2,
)
LocalPreferences.saveSettingsToEncryptedStorage(NostrSigner.instance.settings)
LocalPreferences.saveSettingsToEncryptedStorage(Amber.instance.settings)
scope.launch(Dispatchers.IO) {
@Suppress("KotlinConstantConditions")
if (BuildConfig.FLAVOR != "offline") {
NostrSigner.instance.checkForNewRelays()
Amber.instance.checkForNewRelays()
NotificationDataSource.stop()
delay(2000)
NotificationDataSource.start()
@@ -181,14 +181,14 @@ fun DefaultProfileRelaysScreen(
onClick = {
isLoading.value = true
relays2.removeAt(it)
NostrSigner.instance.settings = NostrSigner.instance.settings.copy(
Amber.instance.settings = Amber.instance.settings.copy(
defaultProfileRelays = relays2,
)
LocalPreferences.saveSettingsToEncryptedStorage(NostrSigner.instance.settings)
LocalPreferences.saveSettingsToEncryptedStorage(Amber.instance.settings)
scope.launch(Dispatchers.IO) {
@Suppress("KotlinConstantConditions")
if (BuildConfig.FLAVOR != "offline") {
NostrSigner.instance.checkForNewRelays()
Amber.instance.checkForNewRelays()
NotificationDataSource.stop()
delay(2000)
NotificationDataSource.start()
@@ -46,7 +46,7 @@ import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.R
import com.greenart7c3.nostrsigner.database.ApplicationWithPermissions
import com.greenart7c3.nostrsigner.models.Account
@@ -77,7 +77,7 @@ fun EditConfigurationScreen(
var closeApp by remember { mutableStateOf(false) }
LaunchedEffect(Unit) {
launch(Dispatchers.IO) {
application = NostrSigner.instance.getDatabase(account.npub).applicationDao().getByKey(key)
application = Amber.instance.getDatabase(account.npub).applicationDao().getByKey(key)
name = TextFieldValue(AnnotatedString(application?.application?.name?.ifBlank { application?.application?.key?.toShortenHex() } ?: ""))
closeApp = application?.application?.closeApplication != false
@@ -290,14 +290,14 @@ fun EditConfigurationScreen(
relays = relays,
closeApplication = closeApp,
)
NostrSigner.instance.getDatabase(account.npub).applicationDao().delete(it.application)
NostrSigner.instance.getDatabase(account.npub).applicationDao().insertApplicationWithPermissions(
Amber.instance.getDatabase(account.npub).applicationDao().delete(it.application)
Amber.instance.getDatabase(account.npub).applicationDao().insertApplicationWithPermissions(
ApplicationWithPermissions(
localApplicationData,
it.permissions,
),
)
NostrSigner.instance.checkForNewRelays()
Amber.instance.checkForNewRelays()
scope.launch(Dispatchers.Main) {
navController.navigate(Route.Applications.route) {
@@ -319,9 +319,9 @@ fun EditConfigurationScreen(
onClick = {
application?.let {
scope.launch(Dispatchers.IO) {
NostrSigner.instance.getDatabase(account.npub).applicationDao().delete(it.application)
Amber.instance.getDatabase(account.npub).applicationDao().delete(it.application)
NostrSigner.instance.checkForNewRelays()
Amber.instance.checkForNewRelays()
scope.launch(Dispatchers.Main) {
navController.navigate(Route.Applications.route) {
@@ -45,7 +45,7 @@ import androidx.compose.ui.text.toLowerCase
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavController
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.R
import com.greenart7c3.nostrsigner.database.ApplicationEntity
import com.greenart7c3.nostrsigner.database.ApplicationPermissionsEntity
@@ -82,14 +82,14 @@ fun EditPermission(
}
val secret = if (checked) "&secret=${applicationData.secret}" else ""
var bunkerUri by remember {
val relayString = NostrSigner.instance.settings.defaultRelays.joinToString(separator = "&") { "relay=${it.url}" }
val relayString = Amber.instance.settings.defaultRelays.joinToString(separator = "&") { "relay=${it.url}" }
mutableStateOf("bunker://${account.hexKey}?$relayString$secret")
}
LaunchedEffect(Unit) {
launch(Dispatchers.IO) {
permissions.addAll(NostrSigner.instance.getDatabase(account.npub).applicationDao().getAllByKey(selectedPackage).sortedBy { "${it.type}-${it.kind}" })
applicationData = NostrSigner.instance.getDatabase(account.npub).applicationDao().getByKey(selectedPackage)!!.application
permissions.addAll(Amber.instance.getDatabase(account.npub).applicationDao().getAllByKey(selectedPackage).sortedBy { "${it.type}-${it.kind}" })
applicationData = Amber.instance.getDatabase(account.npub).applicationDao().getByKey(selectedPackage)!!.application
checked = applicationData.useSecret
val relays = applicationData.relays.joinToString(separator = "&") { "relay=${it.url}" }
val localSecret = if (checked) "&secret=${applicationData.secret}" else ""
@@ -104,7 +104,7 @@ fun EditPermission(
},
) {
scope.launch(Dispatchers.IO) {
NostrSigner.instance.getDatabase(account.npub)
Amber.instance.getDatabase(account.npub)
.applicationDao()
.deletePermissions(applicationData.key)
@@ -219,7 +219,7 @@ fun EditPermission(
}
permissions.clear()
permissions.addAll(localPermissions)
NostrSigner.instance.getDatabase(account.npub)
Amber.instance.getDatabase(account.npub)
.applicationDao()
.insertPermissions(localPermissions)
}
@@ -242,7 +242,7 @@ fun EditPermission(
}
permissions.clear()
permissions.addAll(localPermissions)
NostrSigner.instance.getDatabase(account.npub).applicationDao().insertPermissions(localPermissions)
Amber.instance.getDatabase(account.npub).applicationDao().insertPermissions(localPermissions)
}
},
)
@@ -265,7 +265,7 @@ fun EditPermission(
onClick = {
scope.launch(Dispatchers.IO) {
permissions.remove(permission)
NostrSigner.instance.getDatabase(account.npub).applicationDao().deletePermission(permission)
Amber.instance.getDatabase(account.npub).applicationDao().deletePermission(permission)
}
},
)
@@ -22,8 +22,8 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavController
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.LocalPreferences
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.R
import com.greenart7c3.nostrsigner.models.Account
import com.greenart7c3.nostrsigner.models.IntentData
@@ -54,7 +54,7 @@ fun IncomingRequestScreen(
loading = true
try {
LocalPreferences.allSavedAccounts(context).forEach { account ->
NostrSigner.instance.getDatabase(account.npub).applicationDao().getAllApplications().forEach {
Amber.instance.getDatabase(account.npub).applicationDao().getAllApplications().forEach {
if (it.application.name.isNotBlank()) {
ApplicationNameCache.names["${account.npub.toShortenHex()}-${it.application.key}"] = it.application.name
}
@@ -22,7 +22,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.R
import com.greenart7c3.nostrsigner.models.Account
import com.greenart7c3.nostrsigner.models.TimeUtils
@@ -36,7 +36,7 @@ fun LogsScreen(
account: Account,
) {
val scope = rememberCoroutineScope()
val logsFlow = NostrSigner.instance.getDatabase(account.npub).applicationDao().getLogs()
val logsFlow = Amber.instance.getDatabase(account.npub).applicationDao().getLogs()
val logs = logsFlow.collectAsStateWithLifecycle(initialValue = emptyList())
val state = rememberLazyListState()
@@ -51,7 +51,7 @@ fun LogsScreen(
modifier = Modifier.padding(bottom = 8.dp),
onClick = {
scope.launch(Dispatchers.IO) {
NostrSigner.instance.getDatabase(account.npub).applicationDao().clearLogs()
Amber.instance.getDatabase(account.npub).applicationDao().clearLogs()
}
},
text = stringResource(R.string.clear_logs),
@@ -85,9 +85,9 @@ import androidx.navigation.compose.composable
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.navArgument
import coil3.compose.SubcomposeAsyncImage
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.BuildConfig
import com.greenart7c3.nostrsigner.LocalPreferences
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.R
import com.greenart7c3.nostrsigner.database.ApplicationEntity
import com.greenart7c3.nostrsigner.database.ApplicationPermissionsEntity
@@ -144,9 +144,9 @@ fun sendResult(
shouldCloseApplication: Boolean? = null,
) {
onLoading(true)
NostrSigner.instance.applicationIOScope.launch {
val database = NostrSigner.instance.getDatabase(account.npub)
val defaultRelays = NostrSigner.instance.settings.defaultRelays
Amber.instance.applicationIOScope.launch {
val database = Amber.instance.getDatabase(account.npub)
val defaultRelays = Amber.instance.settings.defaultRelays
var savedApplication = database.applicationDao().getByKey(key)
if (savedApplication == null && intentData.bunkerRequest?.secret != null) {
savedApplication = database.applicationDao().getByKey(intentData.bunkerRequest.secret)
@@ -168,7 +168,7 @@ fun sendResult(
savedApplication = database.applicationDao().getByKey(key)
val relays = savedApplication?.application?.relays?.ifEmpty { defaultRelays } ?: (intentData.bunkerRequest?.relays?.ifEmpty { defaultRelays } ?: defaultRelays)
if (intentData.bunkerRequest != null) {
NostrSigner.instance.checkForNewRelays(
Amber.instance.checkForNewRelays(
newRelays = relays.toSet(),
)
}
@@ -307,7 +307,7 @@ fun sendResult(
application.application.relays.ifEmpty { relays },
onLoading,
onDone = {
NostrSigner.instance.applicationIOScope.launch {
Amber.instance.applicationIOScope.launch {
if (!it) {
if (rememberChoice) {
if (intentData.type == SignerType.SIGN_EVENT) {
@@ -397,7 +397,7 @@ fun sendResult(
context.getString(R.string.event_copied_to_the_clipboard)
}
NostrSigner.instance.applicationIOScope.launch(Dispatchers.Main) {
Amber.instance.applicationIOScope.launch(Dispatchers.Main) {
clipboardManager.setClipEntry(
ClipEntry(
ClipData.newPlainText("", result),
@@ -532,7 +532,7 @@ fun MainScreen(
},
)
NostrSigner.instance.fetchProfileData(
Amber.instance.fetchProfileData(
account = account,
onPictureFound = {
profileUrl = it
@@ -625,7 +625,7 @@ fun MainScreen(
title = Route.QrCode.title
}
navBackStackEntry?.arguments?.getString("packageName")?.let { packageName ->
val application = NostrSigner.instance.getDatabase(account.npub).applicationDao().getByKey(packageName)?.application
val application = Amber.instance.getDatabase(account.npub).applicationDao().getByKey(packageName)?.application
title = if (destinationRoute.startsWith("Activity/")) {
"${application?.name?.ifBlank { application.key.toShortenHex() } ?: packageName} - ${routes.find { it.route.startsWith(destinationRoute) }?.title}"
} else {
@@ -633,7 +633,7 @@ fun MainScreen(
}
}
navBackStackEntry?.arguments?.getString("key")?.let { packageName ->
val application = NostrSigner.instance.getDatabase(account.npub).applicationDao().getByKey(packageName)?.application
val application = Amber.instance.getDatabase(account.npub).applicationDao().getByKey(packageName)?.application
title = if (destinationRoute.startsWith("Activity/")) {
"${application?.name?.ifBlank { application.key.toShortenHex() } ?: packageName} - ${routes.find { it.route.startsWith(destinationRoute) }?.title}"
} else {
@@ -648,7 +648,7 @@ fun MainScreen(
} else {
launch(Dispatchers.IO) {
if (destinationRoute == Route.IncomingRequest.route && intents.isNotEmpty()) {
val application = NostrSigner.instance.getDatabase(account.npub).applicationDao().getByKey(intents.first().bunkerRequest?.localKey ?: packageName ?: "")?.application
val application = Amber.instance.getDatabase(account.npub).applicationDao().getByKey(intents.first().bunkerRequest?.localKey ?: packageName ?: "")?.application
val titleTemp = application?.name?.ifBlank { application.key.toShortenHex() } ?: packageName ?: ""
title = if (titleTemp.isBlank()) {
routes.find { it.route == destinationRoute }?.title ?: ""
@@ -1315,7 +1315,7 @@ fun MainScreen(
scope.launch(Dispatchers.IO) {
LocalPreferences.updateProxy(context, true, it)
NotificationDataSource.stop()
NostrSigner.instance.checkForNewRelays()
Amber.instance.checkForNewRelays()
NotificationDataSource.start()
scope.launch {
navController.navigate(Route.Settings.route) {
@@ -24,7 +24,7 @@ import androidx.compose.ui.text.withLink
import androidx.compose.ui.unit.dp
import androidx.core.net.toUri
import androidx.navigation.NavController
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.R
import com.greenart7c3.nostrsigner.models.Account
import com.greenart7c3.nostrsigner.service.getAppCompatActivity
@@ -154,7 +154,7 @@ fun NewApplicationScreen(
append(" or ")
withLink(
LinkAnnotation.Url(
if (NostrSigner.instance.isZapstoreInstalled()) "zapstore://" else stringResource(R.string.zapstore_website),
if (Amber.instance.isZapstoreInstalled()) "zapstore://" else stringResource(R.string.zapstore_website),
styles = TextLinkStyles(
style = SpanStyle(
textDecoration = TextDecoration.Underline,
@@ -45,7 +45,7 @@ import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavController
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.R
import com.greenart7c3.nostrsigner.database.ApplicationEntity
import com.greenart7c3.nostrsigner.models.Account
@@ -72,7 +72,7 @@ fun NewNsecBunkerScreen(
val relays =
remember {
val localRelays = mutableStateListOf<RelaySetupInfo>()
NostrSigner.instance.settings.defaultRelays.forEach {
Amber.instance.settings.defaultRelays.forEach {
localRelays.add(
it.copy(),
)
@@ -240,7 +240,7 @@ fun NewNsecBunkerScreen(
true,
)
NostrSigner.instance.getDatabase(account.npub).applicationDao().insertApplication(
Amber.instance.getDatabase(account.npub).applicationDao().insertApplication(
application,
)
scope.launch(Dispatchers.Main) {
@@ -267,7 +267,7 @@ fun NewNsecBunkerCreatedScreen(
LaunchedEffect(Unit) {
isLoading.value = true
launch(Dispatchers.IO) {
application = NostrSigner.instance.getDatabase(account.npub).applicationDao().getByKey(key)?.application ?: ApplicationEntity.empty()
application = Amber.instance.getDatabase(account.npub).applicationDao().getByKey(key)?.application ?: ApplicationEntity.empty()
isLoading.value = false
}
}
@@ -282,8 +282,8 @@ fun NewNsecBunkerCreatedScreen(
val bunkerUri = "bunker://${account.hexKey}?$relays$localSecret"
LaunchedEffect(Unit) {
NostrSigner.instance.applicationIOScope.launch(Dispatchers.IO) {
NostrSigner.instance.checkForNewRelays(shouldReconnect = true)
Amber.instance.applicationIOScope.launch(Dispatchers.IO) {
Amber.instance.checkForNewRelays(shouldReconnect = true)
NotificationDataSource.stop()
delay(2000)
NotificationDataSource.start()
@@ -34,7 +34,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.NavController
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.R
import com.greenart7c3.nostrsigner.models.Account
import com.greenart7c3.nostrsigner.models.TimeUtils
@@ -47,7 +47,7 @@ fun PermissionsScreen(
account: Account,
navController: NavController,
) {
val applications = NostrSigner.instance.getDatabase(account.npub).applicationDao().getAllFlow(account.hexKey).collectAsStateWithLifecycle(emptyList())
val applications = Amber.instance.getDatabase(account.npub).applicationDao().getAllFlow(account.hexKey).collectAsStateWithLifecycle(emptyList())
Column(
modifier,
@@ -112,7 +112,7 @@ fun PermissionsScreen(
append(" or ")
withLink(
LinkAnnotation.Url(
if (NostrSigner.instance.isZapstoreInstalled()) "zapstore://" else stringResource(R.string.zapstore_website),
if (Amber.instance.isZapstoreInstalled()) "zapstore://" else stringResource(R.string.zapstore_website),
styles = TextLinkStyles(
style = SpanStyle(
textDecoration = TextDecoration.Underline,
@@ -23,8 +23,8 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.LocalPreferences
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.R
import com.greenart7c3.nostrsigner.ui.components.AmberButton
import com.greenart7c3.nostrsigner.ui.components.TitleExplainer
@@ -45,10 +45,10 @@ fun SecurityScreen(
TitleExplainer(stringResource(BiometricsTimeType.FIVE_MINUTES.resourceId)),
TitleExplainer(stringResource(BiometricsTimeType.TEN_MINUTES.resourceId)),
)
var enableBiometrics by remember { mutableStateOf(NostrSigner.instance.settings.useAuth) }
val setupPin by remember { mutableStateOf(NostrSigner.instance.settings.usePin) }
var enableBiometrics by remember { mutableStateOf(Amber.instance.settings.useAuth) }
val setupPin by remember { mutableStateOf(Amber.instance.settings.usePin) }
var biometricsIndex by remember {
mutableIntStateOf(NostrSigner.instance.settings.biometricsTimeType.screenCode)
mutableIntStateOf(Amber.instance.settings.biometricsTimeType.screenCode)
}
val scope = rememberCoroutineScope()
Surface(
@@ -132,11 +132,11 @@ fun SecurityScreen(
AmberButton(
onClick = {
scope.launch(Dispatchers.IO) {
NostrSigner.instance.settings = NostrSigner.instance.settings.copy(
Amber.instance.settings = Amber.instance.settings.copy(
useAuth = enableBiometrics,
biometricsTimeType = parseBiometricsTimeType(biometricsIndex),
)
LocalPreferences.saveSettingsToEncryptedStorage(NostrSigner.instance.settings)
LocalPreferences.saveSettingsToEncryptedStorage(Amber.instance.settings)
scope.launch(Dispatchers.Main) {
navController.navigateUp()
}
@@ -50,9 +50,9 @@ import androidx.compose.ui.text.withStyle
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavController
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.BuildConfig
import com.greenart7c3.nostrsigner.LocalPreferences
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.R
import com.greenart7c3.nostrsigner.models.Account
import com.greenart7c3.nostrsigner.service.NotificationDataSource
@@ -79,9 +79,9 @@ fun SettingsScreen(
) {
var logoutDialog by remember { mutableStateOf(false) }
val context = LocalContext.current
var checked by remember { mutableStateOf(NostrSigner.instance.settings.useProxy) }
var checked by remember { mutableStateOf(Amber.instance.settings.useProxy) }
var disconnectTorDialog by remember { mutableStateOf(false) }
val proxyPort = remember { mutableStateOf(NostrSigner.instance.settings.proxyPort.toString()) }
val proxyPort = remember { mutableStateOf(Amber.instance.settings.proxyPort.toString()) }
var allowNewConnections by remember { mutableStateOf(account.allowNewConnections) }
val scope = rememberCoroutineScope()
var isLoading by remember { mutableStateOf(false) }
@@ -265,11 +265,11 @@ fun SettingsScreen(
modifier = Modifier.fillMaxWidth(),
text = stringResource(R.string.clear_logs_and_activity),
onClick = {
NostrSigner.instance.applicationIOScope.launch {
Amber.instance.applicationIOScope.launch {
NotificationDataSource.stop()
isLoading = true
LocalPreferences.allSavedAccounts(NostrSigner.instance).forEach {
NostrSigner.instance.getDatabase(it.npub).let { database ->
LocalPreferences.allSavedAccounts(Amber.instance).forEach {
Amber.instance.getDatabase(it.npub).let { database ->
try {
status = context.getString(R.string.deleting_old_log_entries_from, it.npub)
val oneWeek = System.currentTimeMillis() - ONE_WEEK
@@ -399,7 +399,7 @@ fun SettingsScreen(
scope.launch(Dispatchers.IO) {
LocalPreferences.updateProxy(context, false, proxyPort.value.toInt())
NotificationDataSource.stop()
NostrSigner.instance.checkForNewRelays()
Amber.instance.checkForNewRelays()
NotificationDataSource.start()
}
},
@@ -5,8 +5,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.navigation.NavController
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.LocalPreferences
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.R
import com.greenart7c3.nostrsigner.ui.components.RandomPinInput
import com.greenart7c3.nostrsigner.ui.navigation.Route
@@ -41,10 +41,10 @@ fun ConfirmPinScreen(
if (enteredPin != pin) {
accountStateViewModel.toast(context.getString(R.string.pin), context.getString(R.string.pin_does_not_match))
} else {
val usePin = NostrSigner.instance.settings.usePin
val usePin = Amber.instance.settings.usePin
if (usePin) {
NostrSigner.instance.settings = NostrSigner.instance.settings.copy(usePin = false)
LocalPreferences.saveSettingsToEncryptedStorage(NostrSigner.instance.settings)
Amber.instance.settings = Amber.instance.settings.copy(usePin = false)
LocalPreferences.saveSettingsToEncryptedStorage(Amber.instance.settings)
LocalPreferences.savePinToEncryptedStorage(null)
navController.navigate(Route.Security.route) {
popUpTo(Route.Security.route) {
@@ -52,8 +52,8 @@ fun ConfirmPinScreen(
}
}
} else {
NostrSigner.instance.settings = NostrSigner.instance.settings.copy(usePin = true)
LocalPreferences.saveSettingsToEncryptedStorage(NostrSigner.instance.settings)
Amber.instance.settings = Amber.instance.settings.copy(usePin = true)
LocalPreferences.saveSettingsToEncryptedStorage(Amber.instance.settings)
LocalPreferences.savePinToEncryptedStorage(pin)
navController.navigate(Route.Security.route) {
popUpTo(Route.Security.route) {
@@ -62,8 +62,8 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import androidx.navigation.NavHostController
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.LocalPreferences
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.R
import com.greenart7c3.nostrsigner.models.Account
import com.greenart7c3.nostrsigner.service.Biometrics.authenticate
@@ -236,7 +236,7 @@ fun AccountBackupScreen(
keyboardActions = KeyboardActions(
onDone = {
if (password.value.text.isBlank()) {
errorMessage = NostrSigner.instance.getString(R.string.password_is_required)
errorMessage = Amber.instance.getString(R.string.password_is_required)
}
keyboardController?.hide()
},
@@ -530,7 +530,7 @@ private fun EncryptNSecQRButton(
val ncryptsec = Nip49().encrypt(account.signer.keyPair.privKey!!.toHexKey(), password.value.text)
account.didBackup = true
LocalPreferences.saveToEncryptedStorage(context, account)
NostrSigner.instance.applicationIOScope.launch(Dispatchers.Main) {
Amber.instance.applicationIOScope.launch(Dispatchers.Main) {
navController.navigate(Route.QrCode.route.replace("{content}", ncryptsec))
}
onLoading(false)
@@ -550,7 +550,7 @@ private fun EncryptNSecQRButton(
val ncryptsec = Nip49().encrypt(account.signer.keyPair.privKey!!.toHexKey(), password.value.text)
account.didBackup = true
LocalPreferences.saveToEncryptedStorage(context, account)
NostrSigner.instance.applicationIOScope.launch(Dispatchers.Main) {
Amber.instance.applicationIOScope.launch(Dispatchers.Main) {
navController.navigate(Route.QrCode.route.replace("{content}", ncryptsec))
}
onLoading(false)
@@ -54,7 +54,7 @@ import androidx.compose.ui.unit.sp
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.R
import com.greenart7c3.nostrsigner.models.Account
import com.greenart7c3.nostrsigner.models.Permission
@@ -149,7 +149,7 @@ fun ActivityScreen(
account: Account,
key: String,
) {
val activities = NostrSigner.instance.getDatabase(account.npub).applicationDao().getAllHistory(key).collectAsStateWithLifecycle(emptyList())
val activities = Amber.instance.getDatabase(account.npub).applicationDao().getAllHistory(key).collectAsStateWithLifecycle(emptyList())
val context = LocalContext.current
// State for the search query
var searchQuery by remember { mutableStateOf("") }
@@ -42,7 +42,7 @@ import androidx.compose.ui.text.input.KeyboardCapitalization
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.unit.dp
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.R
import com.greenart7c3.nostrsigner.ui.components.AmberButton
import com.greenart7c3.nostrsigner.ui.theme.RichTextDefaults
@@ -58,7 +58,7 @@ fun ConnectOrbotScreen(
onPost: (Int) -> Unit,
onError: (String) -> Unit,
) {
val portNumber = remember { mutableStateOf(NostrSigner.instance.settings.proxyPort.toString()) }
val portNumber = remember { mutableStateOf(Amber.instance.settings.proxyPort.toString()) }
Column(
modifier = modifier,
@@ -41,9 +41,9 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.NavController
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.BuildConfig
import com.greenart7c3.nostrsigner.LocalPreferences
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.R
import com.greenart7c3.nostrsigner.checkNotInMainThread
import com.greenart7c3.nostrsigner.models.Account
@@ -97,7 +97,7 @@ fun DefaultRelaysScreen(
val relays2 =
remember {
val localRelays = mutableStateListOf<RelaySetupInfo>()
NostrSigner.instance.settings.defaultRelays.forEach {
Amber.instance.settings.defaultRelays.forEach {
localRelays.add(
it.copy(),
)
@@ -150,14 +150,14 @@ fun DefaultRelaysScreen(
account,
context,
onDone = {
NostrSigner.instance.settings = NostrSigner.instance.settings.copy(
Amber.instance.settings = Amber.instance.settings.copy(
defaultRelays = relays2,
)
LocalPreferences.saveSettingsToEncryptedStorage(NostrSigner.instance.settings)
LocalPreferences.saveSettingsToEncryptedStorage(Amber.instance.settings)
scope.launch(Dispatchers.IO) {
@Suppress("KotlinConstantConditions")
if (BuildConfig.FLAVOR != "offline") {
NostrSigner.instance.checkForNewRelays()
Amber.instance.checkForNewRelays()
NotificationDataSource.stop()
delay(2000)
NotificationDataSource.start()
@@ -191,14 +191,14 @@ fun DefaultRelaysScreen(
context,
onDone = {
isLoading.value = true
NostrSigner.instance.settings = NostrSigner.instance.settings.copy(
Amber.instance.settings = Amber.instance.settings.copy(
defaultRelays = relays2,
)
LocalPreferences.saveSettingsToEncryptedStorage(NostrSigner.instance.settings)
LocalPreferences.saveSettingsToEncryptedStorage(Amber.instance.settings)
scope.launch(Dispatchers.IO) {
@Suppress("KotlinConstantConditions")
if (BuildConfig.FLAVOR != "offline") {
NostrSigner.instance.checkForNewRelays()
Amber.instance.checkForNewRelays()
NotificationDataSource.stop()
delay(2000)
NotificationDataSource.start()
@@ -224,14 +224,14 @@ fun DefaultRelaysScreen(
onClick = {
isLoading.value = true
relays2.removeAt(it)
NostrSigner.instance.settings = NostrSigner.instance.settings.copy(
Amber.instance.settings = Amber.instance.settings.copy(
defaultRelays = relays2,
)
LocalPreferences.saveSettingsToEncryptedStorage(NostrSigner.instance.settings)
LocalPreferences.saveSettingsToEncryptedStorage(Amber.instance.settings)
scope.launch(Dispatchers.IO) {
@Suppress("KotlinConstantConditions")
if (BuildConfig.FLAVOR != "offline") {
NostrSigner.instance.checkForNewRelays()
Amber.instance.checkForNewRelays()
NotificationDataSource.stop()
delay(2000)
NotificationDataSource.start()
@@ -263,7 +263,7 @@ fun onAddRelay(
val url = textFieldRelay.value.text
if (url.isNotBlank() && url != "/") {
isLoading.value = true
val isPrivateIp = NostrSigner.instance.isPrivateIp(url)
val isPrivateIp = Amber.instance.isPrivateIp(url)
var addedWSS =
if (!url.startsWith("wss://") && !url.startsWith("ws://")) {
// TODO: How to identify relays on the local network?
@@ -287,7 +287,7 @@ fun onAddRelay(
retriever.loadRelayInfo(
httpsUrl,
addedWSS,
forceProxy = if (isPrivateIp) false else NostrSigner.instance.settings.useProxy,
forceProxy = if (isPrivateIp) false else Amber.instance.settings.useProxy,
onInfo = { info ->
scope.launch(Dispatchers.IO) secondLaunch@{
if (info.limitation?.payment_required == true) {
@@ -310,7 +310,7 @@ fun onAddRelay(
return@secondLaunch
}
val relays = NostrSigner.instance.getSavedRelays()
val relays = Amber.instance.getSavedRelays()
if (relays.any { it.url == addedWSS }) {
relays2.add(
RelaySetupInfo(
@@ -339,7 +339,7 @@ fun onAddRelay(
it,
)
val isPrivateIp = NostrSigner.instance.isPrivateIp(addedWSS)
val isPrivateIp = Amber.instance.isPrivateIp(addedWSS)
val factory = OkHttpWebSocket.BuilderFactory { _, useProxy ->
HttpClientManager.getHttpClient(useProxy)
}
@@ -360,7 +360,7 @@ fun onAddRelay(
read = true,
write = true,
feedTypes = COMMON_FEED_TYPES,
forceProxy = if (isPrivateIp) false else NostrSigner.instance.settings.useProxy,
forceProxy = if (isPrivateIp) false else Amber.instance.settings.useProxy,
),
),
)
@@ -498,7 +498,7 @@ fun RelayLogScreen(
val context = LocalContext.current
val flows = LocalPreferences.allSavedAccounts(context).map {
NostrSigner.instance.getDatabase(it.npub).applicationDao().getLogsByUrl(url)
Amber.instance.getDatabase(it.npub).applicationDao().getLogsByUrl(url)
}.merge()
val logs = flows.collectAsStateWithLifecycle(initialValue = emptyList())
@@ -557,7 +557,7 @@ fun ActiveRelaysScreen(
LaunchedEffect(Unit) {
withContext(Dispatchers.IO) {
relays2.addAll(NostrSigner.instance.getSavedRelays())
relays2.addAll(Amber.instance.getSavedRelays())
}
}
@@ -590,7 +590,7 @@ fun ActiveRelaysScreen(
fontSize = 24.sp,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
color = if (NostrSigner.instance.client.getRelay(relay.url)?.isConnected() == true) Color.Unspecified else Color.Gray,
color = if (Amber.instance.client.getRelay(relay.url)?.isConnected() == true) Color.Unspecified else Color.Gray,
)
Row(
modifier = Modifier.fillMaxWidth(),
@@ -598,11 +598,11 @@ fun ActiveRelaysScreen(
) {
Text(
modifier = Modifier.padding(top = 4.dp, bottom = 16.dp),
text = if (NostrSigner.instance.client.getRelay(relay.url)?.isConnected() == true) "${RelayStats.get(relay.url).pingInMs}ms ping" else "Unavailable",
text = if (Amber.instance.client.getRelay(relay.url)?.isConnected() == true) "${RelayStats.get(relay.url).pingInMs}ms ping" else "Unavailable",
fontSize = 16.sp,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
color = if (NostrSigner.instance.client.getRelay(relay.url)?.isConnected() == true) Color.Unspecified else Color.Gray,
color = if (Amber.instance.client.getRelay(relay.url)?.isConnected() == true) Color.Unspecified else Color.Gray,
)
}
@@ -14,8 +14,8 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import com.greenart7c3.nostrsigner.AccountInfo
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.LocalPreferences
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.R
import com.greenart7c3.nostrsigner.ui.AccountStateViewModel
import kotlinx.coroutines.Dispatchers
@@ -38,7 +38,7 @@ fun LogoutButton(
scope.launch(Dispatchers.IO) {
val account = LocalPreferences.loadFromEncryptedStorage(context, acc.npub)
account?.let {
val database = NostrSigner.instance.getDatabase(it.npub)
val database = Amber.instance.getDatabase(it.npub)
val permissions = database.applicationDao().getAll(it.hexKey)
permissions.forEach { app ->
database.applicationDao().delete(app)
@@ -53,8 +53,8 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.window.core.layout.WindowWidthSizeClass
import coil3.compose.AsyncImage
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.BuildConfig
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.R
import com.greenart7c3.nostrsigner.models.Account
import com.greenart7c3.nostrsigner.models.Permission
@@ -72,7 +72,7 @@ fun ProfilePicture(account: Account) {
var profileUrl by remember { mutableStateOf<String?>(null) }
LaunchedEffect(Unit) {
launch(Dispatchers.IO) {
NostrSigner.instance.fetchProfileData(
Amber.instance.fetchProfileData(
account = account,
onPictureFound = {
profileUrl = it
@@ -47,8 +47,8 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavController
import com.google.gson.GsonBuilder
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.LocalPreferences
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.R
import com.greenart7c3.nostrsigner.database.ApplicationEntity
import com.greenart7c3.nostrsigner.database.ApplicationWithPermissions
@@ -171,7 +171,7 @@ fun MultiEventHomeScreen(
text = stringResource(R.string.approve_selected),
onClick = {
onLoading(true)
NostrSigner.instance.applicationIOScope.launch(Dispatchers.IO) {
Amber.instance.applicationIOScope.launch(Dispatchers.IO) {
try {
val activity = context.getAppCompatActivity()
val results = mutableListOf<Result>()
@@ -194,7 +194,7 @@ fun MultiEventHomeScreen(
val localKey = intentData.bunkerRequest?.localKey ?: packageName ?: continue
val database = NostrSigner.instance.getDatabase(thisAccount.npub)
val database = Amber.instance.getDatabase(thisAccount.npub)
val savedApplication = database.applicationDao().getByKey(localKey)
val application =
@@ -523,7 +523,7 @@ fun MultiEventHomeScreen(
containerColor = orange,
),
onClick = {
NostrSigner.instance.applicationIOScope.launch {
Amber.instance.applicationIOScope.launch {
var closeApp = true
BunkerRequestUtils.clearRequests()
onRemoveIntentData(intents, IntentResultType.REMOVE)
@@ -540,7 +540,7 @@ fun MultiEventHomeScreen(
val localKey = intentData.bunkerRequest?.localKey ?: packageName ?: continue
val database = NostrSigner.instance.getDatabase(thisAccount.npub)
val database = Amber.instance.getDatabase(thisAccount.npub)
val application =
database
@@ -614,7 +614,7 @@ private fun sendResultIntent(
private suspend fun reconnectToRelays(intents: List<IntentData>) {
if (!intents.any { it.bunkerRequest != null }) return
NostrSigner.instance.checkForNewRelays()
Amber.instance.checkForNewRelays()
}
@Composable
@@ -22,8 +22,8 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.LocalPreferences
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.R
import com.greenart7c3.nostrsigner.database.ApplicationEntity
import com.greenart7c3.nostrsigner.database.ApplicationWithPermissions
@@ -71,9 +71,9 @@ fun SingleEventHomeScreen(
launch(Dispatchers.IO) {
applicationEntity =
if (intentData.bunkerRequest?.secret != null && intentData.bunkerRequest.secret.isNotBlank()) {
NostrSigner.instance.getDatabase(account.npub).applicationDao().getBySecret(intentData.bunkerRequest.secret)
Amber.instance.getDatabase(account.npub).applicationDao().getBySecret(intentData.bunkerRequest.secret)
} else {
NostrSigner.instance.getDatabase(account.npub).applicationDao().getByKey(key)
Amber.instance.getDatabase(account.npub).applicationDao().getByKey(key)
}
}
}
@@ -140,12 +140,12 @@ fun SingleEventHomeScreen(
},
{
if (intentData.bunkerRequest != null) {
NostrSigner.instance.applicationIOScope.launch(Dispatchers.IO) {
val defaultRelays = NostrSigner.instance.settings.defaultRelays
val savedApplication = NostrSigner.instance.getDatabase(account.npub).applicationDao().getByKey(key)
Amber.instance.applicationIOScope.launch(Dispatchers.IO) {
val defaultRelays = Amber.instance.settings.defaultRelays
val savedApplication = Amber.instance.getDatabase(account.npub).applicationDao().getByKey(key)
val relays = savedApplication?.application?.relays?.ifEmpty { defaultRelays } ?: intentData.bunkerRequest.relays.ifEmpty { defaultRelays }
NostrSigner.instance.checkForNewRelays(
Amber.instance.checkForNewRelays(
newRelays = relays.toSet(),
)
@@ -197,7 +197,7 @@ fun SingleEventHomeScreen(
appName,
intentData.type,
{
NostrSigner.instance.applicationIOScope.launch(Dispatchers.IO) {
Amber.instance.applicationIOScope.launch(Dispatchers.IO) {
val result = signString(intentData.data, account.signer.keyPair.privKey!!).toHexKey()
sendResult(
@@ -217,15 +217,15 @@ fun SingleEventHomeScreen(
}
},
{
NostrSigner.instance.applicationIOScope.launch(Dispatchers.IO) {
Amber.instance.applicationIOScope.launch(Dispatchers.IO) {
if (key == "null") {
context.getAppCompatActivity()?.intent = null
context.getAppCompatActivity()?.finish()
return@launch
}
val savedApplication = NostrSigner.instance.getDatabase(account.npub).applicationDao().getByKey(key)
val defaultRelays = NostrSigner.instance.settings.defaultRelays
val savedApplication = Amber.instance.getDatabase(account.npub).applicationDao().getByKey(key)
val defaultRelays = Amber.instance.settings.defaultRelays
val relays = savedApplication?.application?.relays?.ifEmpty { defaultRelays } ?: (intentData.bunkerRequest?.relays?.ifEmpty { defaultRelays } ?: defaultRelays)
val application =
savedApplication ?: ApplicationWithPermissions(
@@ -258,14 +258,14 @@ fun SingleEventHomeScreen(
}
if (intentData.bunkerRequest != null) {
NostrSigner.instance.checkForNewRelays(
Amber.instance.checkForNewRelays(
newRelays = relays.toSet(),
)
}
NostrSigner.instance.getDatabase(account.npub).applicationDao().insertApplicationWithPermissions(application)
Amber.instance.getDatabase(account.npub).applicationDao().insertApplicationWithPermissions(application)
NostrSigner.instance.getDatabase(account.npub).applicationDao().addHistory(
Amber.instance.getDatabase(account.npub).applicationDao().addHistory(
HistoryEntity2(
0,
key,
@@ -363,13 +363,13 @@ fun SingleEventHomeScreen(
)
},
{
NostrSigner.instance.applicationIOScope.launch(Dispatchers.IO) {
Amber.instance.applicationIOScope.launch(Dispatchers.IO) {
if (key == "null") {
return@launch
}
val defaultRelays = NostrSigner.instance.settings.defaultRelays
val savedApplication = NostrSigner.instance.getDatabase(account.npub).applicationDao().getByKey(key)
val defaultRelays = Amber.instance.settings.defaultRelays
val savedApplication = Amber.instance.getDatabase(account.npub).applicationDao().getByKey(key)
val relays = savedApplication?.application?.relays?.ifEmpty { defaultRelays } ?: (intentData.bunkerRequest?.relays?.ifEmpty { defaultRelays } ?: defaultRelays)
val application =
savedApplication ?: ApplicationWithPermissions(
@@ -401,14 +401,14 @@ fun SingleEventHomeScreen(
}
if (intentData.bunkerRequest != null) {
NostrSigner.instance.checkForNewRelays(
Amber.instance.checkForNewRelays(
newRelays = relays.toSet(),
)
}
NostrSigner.instance.getDatabase(account.npub).applicationDao().insertApplicationWithPermissions(application)
Amber.instance.getDatabase(account.npub).applicationDao().insertApplicationWithPermissions(application)
NostrSigner.instance.getDatabase(account.npub).applicationDao().addHistory(
Amber.instance.getDatabase(account.npub).applicationDao().addHistory(
HistoryEntity2(
0,
key,
@@ -534,13 +534,13 @@ fun SingleEventHomeScreen(
},
{
onLoading(true)
NostrSigner.instance.applicationIOScope.launch(Dispatchers.IO) {
Amber.instance.applicationIOScope.launch(Dispatchers.IO) {
if (key == "null") {
return@launch
}
val defaultRelays = NostrSigner.instance.settings.defaultRelays
val savedApplication = NostrSigner.instance.getDatabase(account.npub).applicationDao().getByKey(key)
val defaultRelays = Amber.instance.settings.defaultRelays
val savedApplication = Amber.instance.getDatabase(account.npub).applicationDao().getByKey(key)
val relays = savedApplication?.application?.relays?.ifEmpty { defaultRelays } ?: (intentData.bunkerRequest?.relays?.ifEmpty { defaultRelays } ?: defaultRelays)
val application =
@@ -563,7 +563,7 @@ fun SingleEventHomeScreen(
)
if (intentData.bunkerRequest != null) {
NostrSigner.instance.checkForNewRelays(
Amber.instance.checkForNewRelays(
newRelays = relays.toSet(),
)
}
@@ -579,9 +579,9 @@ fun SingleEventHomeScreen(
)
}
NostrSigner.instance.getDatabase(account.npub).applicationDao().insertApplicationWithPermissions(application)
Amber.instance.getDatabase(account.npub).applicationDao().insertApplicationWithPermissions(application)
NostrSigner.instance.getDatabase(account.npub).applicationDao().addHistory(
Amber.instance.getDatabase(account.npub).applicationDao().addHistory(
HistoryEntity2(
0,
key,
@@ -2,7 +2,7 @@ package com.greenart7c3.nostrsigner.ui.navigation
import androidx.annotation.DrawableRes
import androidx.compose.runtime.Immutable
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.Amber
import com.greenart7c3.nostrsigner.R
@Immutable
@@ -12,7 +12,7 @@ sealed class Route(
@DrawableRes val icon: Int,
) {
data object TorSettings : Route(
title = NostrSigner.instance.getString(R.string.connect_via_tor_short),
title = Amber.instance.getString(R.string.connect_via_tor_short),
route = "TorSettings",
icon = R.drawable.incoming_request,
)
@@ -24,151 +24,151 @@ sealed class Route(
)
data object IncomingRequest : Route(
title = NostrSigner.instance.getString(R.string.incoming_request),
title = Amber.instance.getString(R.string.incoming_request),
route = "IncomingRequest",
icon = R.drawable.incoming_request,
)
data object Applications : Route(
route = "Applications",
title = NostrSigner.instance.getString(R.string.applications),
title = Amber.instance.getString(R.string.applications),
icon = R.drawable.applications,
)
data object Settings : Route(
title = NostrSigner.instance.getString(R.string.settings),
title = Amber.instance.getString(R.string.settings),
route = "Settings",
icon = R.drawable.settings,
)
data object Permission : Route(
title = NostrSigner.instance.getString(R.string.permissions),
title = Amber.instance.getString(R.string.permissions),
route = "Permission/{packageName}",
icon = R.drawable.settings,
)
data object AccountBackup : Route(
title = NostrSigner.instance.getString(R.string.account_backup),
title = Amber.instance.getString(R.string.account_backup),
route = "AccountBackup",
icon = R.drawable.settings,
)
data object Logs : Route(
title = NostrSigner.instance.getString(R.string.logs),
title = Amber.instance.getString(R.string.logs),
route = "Logs",
icon = R.drawable.settings,
)
data object QrCode : Route(
title = NostrSigner.instance.getString(R.string.qrCode),
title = Amber.instance.getString(R.string.qrCode),
route = "qrcode/{content}",
icon = R.drawable.settings,
)
data object ActiveRelays : Route(
title = NostrSigner.instance.getString(R.string.relays),
title = Amber.instance.getString(R.string.relays),
route = "ActiveRelays",
icon = R.drawable.relays,
)
data object Language : Route(
title = NostrSigner.instance.getString(R.string.language),
title = Amber.instance.getString(R.string.language),
route = "Language",
icon = R.drawable.settings,
)
data object DefaultRelays : Route(
title = NostrSigner.instance.getString(R.string.default_relays),
title = Amber.instance.getString(R.string.default_relays),
route = "DefaultRelays",
icon = R.drawable.settings,
)
data object SignPolicy : Route(
title = NostrSigner.instance.getString(R.string.sign_policy),
title = Amber.instance.getString(R.string.sign_policy),
route = "SignPolicy",
icon = R.drawable.settings,
)
data object Security : Route(
title = NostrSigner.instance.getString(R.string.security),
title = Amber.instance.getString(R.string.security),
route = "Security",
icon = R.drawable.settings,
)
data object Accounts : Route(
title = NostrSigner.instance.getString(R.string.accounts),
title = Amber.instance.getString(R.string.accounts),
route = "Accounts",
icon = R.drawable.settings,
)
data object NewApplication : Route(
title = NostrSigner.instance.getString(R.string.add_a_new_application),
title = Amber.instance.getString(R.string.add_a_new_application),
route = "NewApplication",
icon = R.drawable.settings,
)
data object NewNsecBunker : Route(
title = NostrSigner.instance.getString(R.string.add_a_nsecbunker),
title = Amber.instance.getString(R.string.add_a_nsecbunker),
route = "NewNsecBunker",
icon = R.drawable.settings,
)
data object NSecBunkerCreated : Route(
title = NostrSigner.instance.getString(R.string.add_a_nsecbunker),
title = Amber.instance.getString(R.string.add_a_nsecbunker),
route = "NewNsecBunkerCreated/{key}",
icon = R.drawable.settings,
)
data object Activity : Route(
title = NostrSigner.instance.getString(R.string.activity_title),
title = Amber.instance.getString(R.string.activity_title),
route = "Activity/{key}",
icon = R.drawable.settings,
)
data object RelayLogScreen : Route(
title = NostrSigner.instance.getString(R.string.logs),
title = Amber.instance.getString(R.string.logs),
route = "RelayLogScreen/{url}",
icon = R.drawable.settings,
)
data object EditConfiguration : Route(
title = NostrSigner.instance.getString(R.string.edit_configuration),
title = Amber.instance.getString(R.string.edit_configuration),
route = "EditConfiguration/{key}",
icon = R.drawable.settings,
)
data object SetupPin : Route(
title = NostrSigner.instance.getString(R.string.setup_pin),
title = Amber.instance.getString(R.string.setup_pin),
route = "SetupPin",
icon = R.drawable.settings,
)
data object ConfirmPin : Route(
title = NostrSigner.instance.getString(R.string.confirm_pin),
title = Amber.instance.getString(R.string.confirm_pin),
route = "ConfirmPin/{pin}",
icon = R.drawable.settings,
)
data object SeeDetails : Route(
title = NostrSigner.instance.getString(R.string.incoming_request),
title = Amber.instance.getString(R.string.incoming_request),
route = "SeeDetails",
icon = R.drawable.settings,
)
data object RelaysScreen : Route(
title = NostrSigner.instance.getString(R.string.relays),
title = Amber.instance.getString(R.string.relays),
route = "RelaysScreen",
icon = R.drawable.settings,
)
data object DefaultProfileRelaysScreen : Route(
title = NostrSigner.instance.getString(R.string.default_profile_relays),
title = Amber.instance.getString(R.string.default_profile_relays),
route = "DefaultProfileRelaysScreen",
icon = R.drawable.settings,
)
data object EditProfile : Route(
title = NostrSigner.instance.getString(R.string.edit_profile),
title = Amber.instance.getString(R.string.edit_profile),
route = "EditProfile/{key}",
icon = R.drawable.settings,
)
+1 -1
View File
@@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools">
<application
android:name=".NostrSigner"
android:name=".Amber"
android:allowBackup="false"
android:configChanges="orientation|screenSize|screenLayout"
android:dataExtractionRules="@xml/data_extraction_rules"