mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-06 11:28:22 +00:00
Use the same log tag for everything
This commit is contained in:
@@ -108,7 +108,7 @@ class Amber : Application() {
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
||||
Log.d("NostrSigner", "onCreate Amber")
|
||||
Log.d(TAG, "onCreate Amber")
|
||||
|
||||
startCleanLogsAlarm()
|
||||
|
||||
@@ -127,6 +127,11 @@ class Amber : Application() {
|
||||
}
|
||||
}
|
||||
|
||||
runMigrations()
|
||||
startService()
|
||||
}
|
||||
|
||||
fun runMigrations() {
|
||||
runBlocking(Dispatchers.IO) {
|
||||
LocalPreferences.allSavedAccounts(this@Amber).forEach {
|
||||
if (LocalPreferences.didMigrateFromLegacyStorage(this@Amber, it.npub)) {
|
||||
@@ -143,8 +148,6 @@ class Amber : Application() {
|
||||
LocalPreferences.migrateTorSettings(this@Amber)
|
||||
settings = LocalPreferences.loadSettingsFromEncryptedStorage()
|
||||
}
|
||||
|
||||
startService()
|
||||
}
|
||||
|
||||
fun startService() {
|
||||
@@ -167,7 +170,7 @@ class Amber : Application() {
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("NostrSigner", "Failed to start ConnectivityService", e)
|
||||
Log.e(TAG, "Failed to start ConnectivityService", e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,7 +252,7 @@ class Amber : Application() {
|
||||
}
|
||||
|
||||
private suspend fun checkIfRelaysAreConnected(tryAgain: Boolean = true) {
|
||||
Log.d("NostrSigner", "Checking if relays are connected")
|
||||
Log.d(TAG, "Checking if relays are connected")
|
||||
client.getAll().forEach { relay ->
|
||||
if (!relay.isConnected()) {
|
||||
relay.connectAndRunAfterSync {
|
||||
@@ -306,7 +309,7 @@ class Amber : Application() {
|
||||
val oneDayAgo = TimeUtils.oneDayAgo()
|
||||
val fifteenMinutesAgo = TimeUtils.fifteenMinutesAgo()
|
||||
if ((lastMetaData == 0L || oneDayAgo > lastMetaData) && (lastCheck == 0L || fifteenMinutesAgo > lastCheck)) {
|
||||
Log.d("NostrSigner", "Fetching profile data for ${account.npub}")
|
||||
Log.d(Amber.TAG, "Fetching profile data for ${account.npub}")
|
||||
LocalPreferences.setLastCheck(this, account.npub, TimeUtils.now())
|
||||
val listener = MetadataRelayListener(
|
||||
account = account,
|
||||
@@ -361,7 +364,7 @@ class Amber : Application() {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.d("NostrSigner", "Using cached profile data for ${account.npub}")
|
||||
Log.d(TAG, "Using cached profile data for ${account.npub}")
|
||||
LocalPreferences.loadProfileUrlFromEncryptedStorage(account.npub)?.let {
|
||||
onPictureFound(it)
|
||||
return
|
||||
@@ -370,6 +373,8 @@ class Amber : Application() {
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAG = "Amber"
|
||||
|
||||
@Volatile
|
||||
private var _instance: Amber? = null
|
||||
val instance: Amber get() =
|
||||
|
||||
@@ -292,9 +292,9 @@ object LocalPreferences {
|
||||
if (it.contains(npub)) {
|
||||
try {
|
||||
val result = File(prefsDir, it).delete()
|
||||
Log.d("delete", "deleted $it: $result")
|
||||
Log.d(Amber.TAG, "deleted $it: $result")
|
||||
} catch (e: Exception) {
|
||||
Log.d("delete", "failed to delete $it", e)
|
||||
Log.d(Amber.TAG, "failed to delete $it", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -306,9 +306,9 @@ object LocalPreferences {
|
||||
if (it.contains(npub) && it.startsWith("secret_keeper")) {
|
||||
try {
|
||||
val result = File(prefsDir, it).delete()
|
||||
Log.d("delete", "deleted $it: $result")
|
||||
Log.d(Amber.TAG, "deleted $it: $result")
|
||||
} catch (e: Exception) {
|
||||
Log.d("delete", "failed to delete $it", e)
|
||||
Log.d(Amber.TAG, "failed to delete $it", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -331,9 +331,9 @@ object LocalPreferences {
|
||||
if (it == "secret_keeper.xml") {
|
||||
try {
|
||||
val result = File(prefsDir, it).delete()
|
||||
Log.d("delete", "deleted $it: $result")
|
||||
Log.d(Amber.TAG, "deleted $it: $result")
|
||||
} catch (e: Exception) {
|
||||
Log.d("delete", "failed to delete $it", e)
|
||||
Log.d(Amber.TAG, "failed to delete $it", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -435,7 +435,7 @@ object LocalPreferences {
|
||||
|
||||
fun loadFromEncryptedStorageSync(context: Context, npub: String? = null): Account? {
|
||||
if (savedAccounts == null || accountCache.size() == 0 || savedAccounts?.size != accountCache.size()) {
|
||||
Log.d("SignerProvider", "accountCache is null loading accounts")
|
||||
Log.d(Amber.TAG, "accountCache is null loading accounts")
|
||||
runBlocking {
|
||||
allSavedAccounts(context).forEach {
|
||||
loadFromEncryptedStorage(context, it.npub)
|
||||
|
||||
@@ -68,7 +68,7 @@ class MainActivity : AppCompatActivity() {
|
||||
HttpClientManager.setDefaultUserAgent("Amber/${BuildConfig.VERSION_NAME}")
|
||||
setContent {
|
||||
if (intent.isLaunchFromHistory()) {
|
||||
Log.d("isLaunchFromHistory", "Cleared intent history")
|
||||
Log.d(Amber.TAG, "Cleared intent history")
|
||||
intent = Intent()
|
||||
}
|
||||
|
||||
@@ -224,13 +224,13 @@ class MainActivity : AppCompatActivity() {
|
||||
val currentAccount = LocalPreferences.currentAccount(context)
|
||||
if (currentAccount != null && npub != null && currentAccount != npub && npub.isNotBlank()) {
|
||||
if (npub.startsWith("npub")) {
|
||||
Log.d("Account", "Switching account to $npub")
|
||||
Log.d(Amber.TAG, "Switching account to $npub")
|
||||
if (LocalPreferences.containsAccount(context, npub)) {
|
||||
accountStateViewModel.switchUser(npub, Route.IncomingRequest.route)
|
||||
}
|
||||
} else {
|
||||
val localNpub = Hex.decode(npub).toNpub()
|
||||
Log.d("Account", "Switching account to $localNpub")
|
||||
Log.d(Amber.TAG, "Switching account to $localNpub")
|
||||
if (LocalPreferences.containsAccount(context, localNpub)) {
|
||||
accountStateViewModel.switchUser(localNpub, Route.IncomingRequest.route)
|
||||
}
|
||||
|
||||
@@ -33,13 +33,13 @@ class MainViewModel(val context: Context) : ViewModel() {
|
||||
if (!userFromIntent.isNullOrBlank()) {
|
||||
if (userFromIntent.startsWith("npub")) {
|
||||
if (LocalPreferences.containsAccount(context, userFromIntent)) {
|
||||
Log.d("MainViewModel", "getAccount: $userFromIntent")
|
||||
Log.d(Amber.TAG, "getAccount: $userFromIntent")
|
||||
return userFromIntent
|
||||
}
|
||||
} else {
|
||||
val localNpub = Hex.decode(userFromIntent).toNpub()
|
||||
if (LocalPreferences.containsAccount(context, localNpub)) {
|
||||
Log.d("MainViewModel", "getAccount: $localNpub")
|
||||
Log.d(Amber.TAG, "getAccount: $localNpub")
|
||||
return localNpub
|
||||
}
|
||||
}
|
||||
@@ -52,36 +52,36 @@ class MainViewModel(val context: Context) : ViewModel() {
|
||||
|
||||
if (pubKeys.isEmpty()) {
|
||||
if (currentAccount != null && LocalPreferences.containsAccount(context, currentAccount)) {
|
||||
Log.d("MainViewModel", "getAccount: $currentAccount")
|
||||
Log.d(Amber.TAG, "getAccount: $currentAccount")
|
||||
return currentAccount
|
||||
}
|
||||
|
||||
val acc = LocalPreferences.allSavedAccounts(context).firstOrNull()
|
||||
if (acc != null) {
|
||||
Log.d("MainViewModel", "getAccount: ${acc.npub}")
|
||||
Log.d(Amber.TAG, "getAccount: ${acc.npub}")
|
||||
return acc.npub
|
||||
} else {
|
||||
Log.d("MainViewModel", "getAccount: null")
|
||||
Log.d(Amber.TAG, "getAccount: null")
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
val npub = Hex.decode(pubKeys.first()).toNpub()
|
||||
Log.d("MainViewModel", "getAccount: $npub")
|
||||
Log.d(Amber.TAG, "getAccount: $npub")
|
||||
return npub
|
||||
} catch (e: Exception) {
|
||||
Log.e("MainViewModel", "Error getting account", e)
|
||||
Log.e(Amber.TAG, "Error getting account", e)
|
||||
if (currentAccount != null && LocalPreferences.containsAccount(context, currentAccount)) {
|
||||
Log.d("MainViewModel", "getAccount: $currentAccount")
|
||||
Log.d(Amber.TAG, "getAccount: $currentAccount")
|
||||
return currentAccount
|
||||
}
|
||||
|
||||
val acc = LocalPreferences.allSavedAccounts(context).firstOrNull()
|
||||
if (acc != null) {
|
||||
Log.d("MainViewModel", "getAccount: ${acc.npub}")
|
||||
Log.d(Amber.TAG, "getAccount: ${acc.npub}")
|
||||
return acc.npub
|
||||
} else {
|
||||
Log.d("MainViewModel", "getAccount: null")
|
||||
Log.d(Amber.TAG, "getAccount: null")
|
||||
return null
|
||||
}
|
||||
}
|
||||
@@ -119,13 +119,13 @@ class MainViewModel(val context: Context) : ViewModel() {
|
||||
val currentAccount = LocalPreferences.currentAccount(context)
|
||||
if (currentAccount != null && npub != null && currentAccount != npub && npub.isNotBlank()) {
|
||||
if (npub.startsWith("npub")) {
|
||||
Log.d("Account", "Switching account to $npub")
|
||||
Log.d(Amber.TAG, "Switching account to $npub")
|
||||
if (LocalPreferences.containsAccount(context, npub)) {
|
||||
accountStateViewModel?.switchUser(npub, Route.IncomingRequest.route)
|
||||
}
|
||||
} else {
|
||||
val localNpub = Hex.decode(npub).toNpub()
|
||||
Log.d("Account", "Switching account to $localNpub")
|
||||
Log.d(Amber.TAG, "Switching account to $localNpub")
|
||||
if (LocalPreferences.containsAccount(context, localNpub)) {
|
||||
accountStateViewModel?.switchUser(localNpub, Route.IncomingRequest.route)
|
||||
}
|
||||
@@ -165,7 +165,7 @@ class MainViewModel(val context: Context) : ViewModel() {
|
||||
}
|
||||
error = false
|
||||
} catch (e: Exception) {
|
||||
Log.e("MainViewModel", "Error showing bunker requests", e)
|
||||
Log.e(Amber.TAG, "Error showing bunker requests", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,33 +55,33 @@ class SignerProvider : ContentProvider() {
|
||||
selectionArgs: Array<String>?,
|
||||
sortOrder: String?,
|
||||
): Cursor? {
|
||||
Log.d("SignerProvider", "Querying $uri has context ${context != null}")
|
||||
Log.d(Amber.TAG, "Querying $uri has context ${context != null}")
|
||||
val appId = BuildConfig.APPLICATION_ID
|
||||
return try {
|
||||
when (uri.toString()) {
|
||||
"content://$appId.SIGN_MESSAGE" -> {
|
||||
val packageName = callingPackage
|
||||
if (packageName == null) {
|
||||
Log.d("SignerProvider", "No package name")
|
||||
Log.d(Amber.TAG, "No package name")
|
||||
return null
|
||||
}
|
||||
val message = projection?.first()
|
||||
if (message == null) {
|
||||
Log.d("SignerProvider", "No message")
|
||||
Log.d(Amber.TAG, "No message")
|
||||
return null
|
||||
}
|
||||
val npub = IntentUtils.parsePubKey(projection[2])
|
||||
if (npub == null) {
|
||||
Log.d("SignerProvider", "No npub")
|
||||
Log.d(Amber.TAG, "No npub")
|
||||
return null
|
||||
}
|
||||
if (!LocalPreferences.containsAccount(context!!, npub)) {
|
||||
Log.d("SignerProvider", "No account")
|
||||
Log.d(Amber.TAG, "No account")
|
||||
return null
|
||||
}
|
||||
val account = LocalPreferences.loadFromEncryptedStorageSync(context!!, npub)
|
||||
if (account == null) {
|
||||
Log.d("SignerProvider", "No account from storage")
|
||||
Log.d(Amber.TAG, "No account from storage")
|
||||
return null
|
||||
}
|
||||
val database = Amber.instance.getDatabase(account.npub)
|
||||
@@ -138,32 +138,32 @@ class SignerProvider : ContentProvider() {
|
||||
"content://$appId.SIGN_EVENT" -> {
|
||||
val packageName = callingPackage
|
||||
if (packageName == null) {
|
||||
Log.d("SignerProvider", "No package name")
|
||||
Log.d(Amber.TAG, "No package name")
|
||||
return null
|
||||
}
|
||||
val json = projection?.first()
|
||||
if (json == null) {
|
||||
Log.d("SignerProvider", "No json")
|
||||
Log.d(Amber.TAG, "No json")
|
||||
return null
|
||||
}
|
||||
val npub = IntentUtils.parsePubKey(projection[2])
|
||||
if (npub == null) {
|
||||
Log.d("SignerProvider", "No npub")
|
||||
Log.d(Amber.TAG, "No npub")
|
||||
return null
|
||||
}
|
||||
if (!LocalPreferences.containsAccount(context!!, npub)) {
|
||||
Log.d("SignerProvider", "No account")
|
||||
Log.d(Amber.TAG, "No account")
|
||||
return null
|
||||
}
|
||||
val account = LocalPreferences.loadFromEncryptedStorageSync(context!!, npub)
|
||||
if (account == null) {
|
||||
Log.d("SignerProvider", "No account from storage")
|
||||
Log.d(Amber.TAG, "No account from storage")
|
||||
return null
|
||||
}
|
||||
val event = try {
|
||||
IntentUtils.getUnsignedEvent(json, account)
|
||||
} catch (e: Exception) {
|
||||
Log.d("SignerProvider", "Failed to parse event from $packageName", e)
|
||||
Log.d(Amber.TAG, "Failed to parse event from $packageName", e)
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ class SignerProvider : ContentProvider() {
|
||||
val signedEvent = account.signer.signerSync.sign<Event>(event.createdAt, event.kind, event.tags, event.content)
|
||||
|
||||
if (signedEvent == null) {
|
||||
Log.d("SignerProvider", "Failed to sign event from $packageName")
|
||||
Log.d(Amber.TAG, "Failed to sign event from $packageName")
|
||||
scope.launch {
|
||||
database.applicationDao().addHistory(
|
||||
HistoryEntity2(
|
||||
@@ -440,7 +440,7 @@ class SignerProvider : ContentProvider() {
|
||||
else -> null
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("SignerProvider", "Error from $callingPackage $uri", e)
|
||||
Log.e(Amber.TAG, "Error from $callingPackage $uri", e)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import androidx.room.Transaction
|
||||
import com.greenart7c3.nostrsigner.Amber
|
||||
import com.vitorpamplona.quartz.utils.TimeUtils
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@@ -154,7 +155,7 @@ interface ApplicationDao {
|
||||
try {
|
||||
innerAddHistory(entity)
|
||||
} catch (e: Exception) {
|
||||
Log.e("ApplicationDao", "Error adding history", e)
|
||||
Log.e(Amber.TAG, "Error adding history", e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
package com.greenart7c3.nostrsigner.okhttp
|
||||
|
||||
import android.util.Log
|
||||
import com.greenart7c3.nostrsigner.Amber
|
||||
import java.net.InetSocketAddress
|
||||
import java.net.Proxy
|
||||
import java.time.Duration
|
||||
@@ -48,7 +49,7 @@ object HttpClientManager {
|
||||
|
||||
private fun setDefaultProxy(proxy: Proxy?) {
|
||||
if (currentProxy != proxy) {
|
||||
Log.d("HttpClient", "Changing proxy to: ${proxy != null}")
|
||||
Log.d(Amber.TAG, "Changing proxy to: ${proxy != null}")
|
||||
currentProxy = proxy
|
||||
|
||||
// recreates singleton
|
||||
@@ -57,7 +58,7 @@ object HttpClientManager {
|
||||
}
|
||||
|
||||
fun setDefaultTimeout(timeout: Duration) {
|
||||
Log.d("HttpClient", "Changing timeout to: $timeout")
|
||||
Log.d(Amber.TAG, "Changing timeout to: $timeout")
|
||||
if (defaultTimeout.seconds != timeout.seconds) {
|
||||
defaultTimeout = timeout
|
||||
|
||||
@@ -68,7 +69,7 @@ object HttpClientManager {
|
||||
}
|
||||
|
||||
fun setDefaultUserAgent(userAgentHeader: String) {
|
||||
Log.d("HttpClient", "Changing userAgent")
|
||||
Log.d(Amber.TAG, "Changing userAgent")
|
||||
if (userAgent != userAgentHeader) {
|
||||
userAgent = userAgentHeader
|
||||
defaultHttpClient = buildHttpClient(currentProxy, defaultTimeout)
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
package com.greenart7c3.nostrsigner.okhttp
|
||||
|
||||
import android.util.Log
|
||||
import com.greenart7c3.nostrsigner.Amber
|
||||
import java.net.InetSocketAddress
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.Request
|
||||
@@ -41,7 +42,7 @@ class LoggingInterceptor : Interceptor {
|
||||
val response: Response = chain.proceed(request)
|
||||
val t2 = System.nanoTime()
|
||||
|
||||
Log.d("OkHttpLog", "Req $port ${request.url} in ${(t2 - t1) / 1e6}ms")
|
||||
Log.d(Amber.TAG, "Req $port ${request.url} in ${(t2 - t1) / 1e6}ms")
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ object AmberRelayStats {
|
||||
}
|
||||
|
||||
fun updateNotification() {
|
||||
Log.d("ConnectivityService", "updateNotification")
|
||||
Log.d(Amber.TAG, "updateNotification")
|
||||
val notificationManager = NotificationManagerCompat.from(Amber.instance)
|
||||
if (ActivityCompat.checkSelfPermission(Amber.instance, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) {
|
||||
notificationManager.notify(1, createNotification())
|
||||
|
||||
+9
-8
@@ -1,6 +1,7 @@
|
||||
package com.greenart7c3.nostrsigner.relays
|
||||
|
||||
import android.util.Log
|
||||
import com.greenart7c3.nostrsigner.Amber
|
||||
import com.greenart7c3.nostrsigner.models.Account
|
||||
import com.vitorpamplona.ammolite.relays.NostrClient
|
||||
import com.vitorpamplona.ammolite.relays.Relay
|
||||
@@ -12,35 +13,35 @@ class BunkerValidationRelayListener(
|
||||
val onReceiveEvent: (relay: Relay, subscriptionId: String, event: Event) -> Unit,
|
||||
) : NostrClient.Listener {
|
||||
override fun onAuth(relay: Relay, challenge: String) {
|
||||
Log.d("RelayListener", "Received auth challenge $challenge from relay ${relay.url}")
|
||||
Log.d(Amber.TAG, "Received auth challenge $challenge from relay ${relay.url}")
|
||||
}
|
||||
|
||||
override fun onBeforeSend(relay: Relay, event: Event) {
|
||||
Log.d("RelayListener", "Sending event ${event.id} to relay ${relay.url}")
|
||||
Log.d(Amber.TAG, "Sending event ${event.id} to relay ${relay.url}")
|
||||
}
|
||||
|
||||
override fun onError(error: Error, subscriptionId: String, relay: Relay) {
|
||||
Log.d("RelayListener", "Received error $error from subscription $subscriptionId")
|
||||
Log.d(Amber.TAG, "Received error $error from subscription $subscriptionId")
|
||||
}
|
||||
|
||||
override fun onEvent(event: Event, subscriptionId: String, relay: Relay, afterEOSE: Boolean) {
|
||||
Log.d("RelayListener", "Received event ${event.toJson()} from subscription $subscriptionId afterEOSE: $afterEOSE")
|
||||
Log.d(Amber.TAG, "Received event ${event.toJson()} from subscription $subscriptionId afterEOSE: $afterEOSE")
|
||||
onReceiveEvent(relay, subscriptionId, event)
|
||||
}
|
||||
|
||||
override fun onNotify(relay: Relay, description: String) {
|
||||
Log.d("RelayListener", "Received notify $description from relay ${relay.url}")
|
||||
Log.d(Amber.TAG, "Received notify $description from relay ${relay.url}")
|
||||
}
|
||||
|
||||
override fun onRelayStateChange(type: RelayState, relay: Relay) {
|
||||
Log.d("RelayListener", "Relay ${relay.url} state changed to $type")
|
||||
Log.d(Amber.TAG, "Relay ${relay.url} state changed to $type")
|
||||
}
|
||||
|
||||
override fun onSend(relay: Relay, msg: String, success: Boolean) {
|
||||
Log.d("RelayListener", "Sent message $msg to relay ${relay.url} success: $success")
|
||||
Log.d(Amber.TAG, "Sent message $msg to relay ${relay.url} success: $success")
|
||||
}
|
||||
|
||||
override fun onSendResponse(eventId: String, success: Boolean, message: String, relay: Relay) {
|
||||
Log.d("RelayListener", "Sent response to event $eventId to relay ${relay.url} success: $success message: $message")
|
||||
Log.d(Amber.TAG, "Sent response to event $eventId to relay ${relay.url} success: $success message: $message")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.greenart7c3.nostrsigner.relays
|
||||
|
||||
import android.util.Log
|
||||
import com.greenart7c3.nostrsigner.Amber
|
||||
import com.greenart7c3.nostrsigner.models.Account
|
||||
import com.vitorpamplona.ammolite.relays.Relay
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||
@@ -11,42 +12,42 @@ class MetadataRelayListener(
|
||||
val onReceiveEvent: (relay: Relay, subscriptionId: String, event: Event) -> Unit,
|
||||
) : Relay.Listener {
|
||||
override fun onAuth(relay: Relay, challenge: String) {
|
||||
Log.d("RelayListener", "Received auth challenge $challenge from relay ${relay.url}")
|
||||
Log.d(Amber.TAG, "Received auth challenge $challenge from relay ${relay.url}")
|
||||
account.createAuthEvent(relay.url, challenge) { authEvent ->
|
||||
relay.send(authEvent)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBeforeSend(relay: Relay, event: Event) {
|
||||
Log.d("RelayListener", "Sending event ${event.id} to relay ${relay.url}")
|
||||
Log.d(Amber.TAG, "Sending event ${event.id} to relay ${relay.url}")
|
||||
}
|
||||
|
||||
override fun onError(relay: Relay, subscriptionId: String, error: Error) {
|
||||
Log.d("RelayListener", "Received error $error from subscription $subscriptionId")
|
||||
Log.d(Amber.TAG, "Received error $error from subscription $subscriptionId")
|
||||
}
|
||||
|
||||
override fun onEvent(relay: Relay, subscriptionId: String, event: Event, afterEOSE: Boolean) {
|
||||
Log.d("RelayListener", "Received event ${event.toJson()} from subscription $subscriptionId afterEOSE: $afterEOSE")
|
||||
Log.d(Amber.TAG, "Received event ${event.toJson()} from subscription $subscriptionId afterEOSE: $afterEOSE")
|
||||
onReceiveEvent(relay, subscriptionId, event)
|
||||
}
|
||||
|
||||
override fun onEOSE(relay: Relay, subscriptionId: String) {
|
||||
Log.d("RelayListener", "Received EOSE from subscription $subscriptionId")
|
||||
Log.d(Amber.TAG, "Received EOSE from subscription $subscriptionId")
|
||||
}
|
||||
|
||||
override fun onNotify(relay: Relay, description: String) {
|
||||
Log.d("RelayListener", "Received notify $description from relay ${relay.url}")
|
||||
Log.d(Amber.TAG, "Received notify $description from relay ${relay.url}")
|
||||
}
|
||||
|
||||
override fun onRelayStateChange(relay: Relay, type: RelayState) {
|
||||
Log.d("RelayListener", "Relay ${relay.url} state changed to $type")
|
||||
Log.d(Amber.TAG, "Relay ${relay.url} state changed to $type")
|
||||
}
|
||||
|
||||
override fun onSend(relay: Relay, msg: String, success: Boolean) {
|
||||
Log.d("RelayListener", "Sent message $msg to relay ${relay.url} success: $success")
|
||||
Log.d(Amber.TAG, "Sent message $msg to relay ${relay.url} success: $success")
|
||||
}
|
||||
|
||||
override fun onSendResponse(relay: Relay, eventId: String, success: Boolean, message: String) {
|
||||
Log.d("RelayListener", "Sent response to event $eventId to relay ${relay.url} success: $success message: $message")
|
||||
Log.d(Amber.TAG, "Sent response to event $eventId to relay ${relay.url} success: $success message: $message")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ object AmberUtils {
|
||||
null
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("Account", "Failed to create pubkey for ZapRequest ${event.id}", e)
|
||||
Log.e(Amber.TAG, "Failed to create pubkey for ZapRequest ${event.id}", e)
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class BootReceiver : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
@Suppress("KotlinConstantConditions")
|
||||
if (BuildConfig.FLAVOR == "offline") return
|
||||
Log.d("BootReceiver", "Received intent: ${intent.action}")
|
||||
Log.d(Amber.TAG, "Received intent: ${intent.action}")
|
||||
|
||||
when (intent.action) {
|
||||
Intent.ACTION_PACKAGE_REPLACED -> {
|
||||
@@ -44,7 +44,7 @@ class BootReceiver : BroadcastReceiver() {
|
||||
val oneWeek = System.currentTimeMillis() - (ONE_WEEK * 1000L)
|
||||
val oneWeekAgo = TimeUtils.oneWeekAgo()
|
||||
val countHistory = database.applicationDao().countOldHistory(oneWeekAgo)
|
||||
Log.d("NostrSigner", "Deleting $countHistory old history entries")
|
||||
Log.d(Amber.TAG, "Deleting $countHistory old history entries")
|
||||
if (countHistory > 0) {
|
||||
var logs = database.applicationDao().getOldHistory(oneWeekAgo)
|
||||
var count = 0
|
||||
@@ -58,7 +58,7 @@ class BootReceiver : BroadcastReceiver() {
|
||||
}
|
||||
|
||||
val countNotification = database.applicationDao().countOldNotification(oneWeekAgo)
|
||||
Log.d("NostrSigner", "Deleting $countNotification old notification entries")
|
||||
Log.d(Amber.TAG, "Deleting $countNotification old notification entries")
|
||||
if (countNotification > 0) {
|
||||
var logs = database.applicationDao().getOldNotification(oneWeekAgo)
|
||||
var count = 0
|
||||
@@ -72,14 +72,14 @@ class BootReceiver : BroadcastReceiver() {
|
||||
}
|
||||
|
||||
val countLog = database.applicationDao().countOldLog(oneWeek)
|
||||
Log.d("NostrSigner", "Deleting $countLog old log entries from ${com.greenart7c3.nostrsigner.models.TimeUtils.formatLongToCustomDateTimeWithSeconds(oneWeek)}")
|
||||
Log.d(Amber.TAG, "Deleting $countLog old log entries from ${com.greenart7c3.nostrsigner.models.TimeUtils.formatLongToCustomDateTimeWithSeconds(oneWeek)}")
|
||||
if (countLog > 0) {
|
||||
var logs = database.applicationDao().getOldLog(oneWeek)
|
||||
var count = 0
|
||||
while (logs.isNotEmpty()) {
|
||||
count++
|
||||
logs.forEach { history ->
|
||||
Log.d("NostrSigner", "Deleting log entry ${com.greenart7c3.nostrsigner.models.TimeUtils.formatLongToCustomDateTimeWithSeconds(history.time)}")
|
||||
Log.d(Amber.TAG, "Deleting log entry ${com.greenart7c3.nostrsigner.models.TimeUtils.formatLongToCustomDateTimeWithSeconds(history.time)}")
|
||||
database.applicationDao().deleteLog(history)
|
||||
}
|
||||
logs = database.applicationDao().getOldLog(oneWeek)
|
||||
@@ -87,7 +87,7 @@ class BootReceiver : BroadcastReceiver() {
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
if (e is CancellationException) throw e
|
||||
Log.e("NostrSigner", "Error deleting old log entries", e)
|
||||
Log.e(Amber.TAG, "Error deleting old log entries", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ object BunkerRequestUtils {
|
||||
encryptedContent,
|
||||
) {
|
||||
Amber.instance.applicationIOScope.launch {
|
||||
Log.d("IntentUtils", "Sending response to relays ${relays.map { it.url }} type ${bunkerRequest?.method}")
|
||||
Log.d(Amber.TAG, "Sending response to relays ${relays.map { it.url }} type ${bunkerRequest?.method}")
|
||||
|
||||
if (Amber.instance.client.getAll().any { !it.isConnected() }) {
|
||||
Amber.instance.checkForNewRelays(
|
||||
@@ -178,12 +178,12 @@ object BunkerRequestUtils {
|
||||
}
|
||||
}
|
||||
if (success) {
|
||||
Log.d("IntentUtils", "Success response to relays ${relays.map { it.url }} type ${bunkerRequest?.method}")
|
||||
Log.d(Amber.TAG, "Success response to relays ${relays.map { it.url }} type ${bunkerRequest?.method}")
|
||||
onDone(true)
|
||||
} else {
|
||||
onDone(false)
|
||||
AmberListenerSingleton.showErrorMessage()
|
||||
Log.d("IntentUtils", "Failed response to relays ${relays.map { it.url }} type ${bunkerRequest?.method}")
|
||||
Log.d(Amber.TAG, "Failed response to relays ${relays.map { it.url }} type ${bunkerRequest?.method}")
|
||||
}
|
||||
AmberListenerSingleton.getListener()?.let {
|
||||
Amber.instance.client.unsubscribe(it)
|
||||
@@ -229,7 +229,7 @@ object BunkerRequestUtils {
|
||||
) {
|
||||
val type = getTypeFromBunker(bunkerRequest)
|
||||
if (type == SignerType.INVALID) {
|
||||
Log.d("IntentUtils", "Invalid type ${bunkerRequest.method}")
|
||||
Log.d(Amber.TAG, "Invalid type ${bunkerRequest.method}")
|
||||
onReady(null)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ class ConnectivityService : Service() {
|
||||
override fun onCreate() {
|
||||
if (isStarted) return
|
||||
|
||||
Log.d("ConnectivityService", "onCreate ConnectivityService")
|
||||
Log.d(Amber.TAG, "onCreate ConnectivityService")
|
||||
|
||||
isStarted = true
|
||||
|
||||
@@ -125,7 +125,7 @@ class ConnectivityService : Service() {
|
||||
Amber.instance.client.getAll().forEach {
|
||||
if (!it.isConnected()) {
|
||||
Log.d(
|
||||
"ConnectivityService",
|
||||
Amber.TAG,
|
||||
"Relay ${it.url} is not connected, reconnecting...",
|
||||
)
|
||||
it.connectAndSendFiltersIfDisconnected()
|
||||
@@ -145,19 +145,19 @@ class ConnectivityService : Service() {
|
||||
@Suppress("KotlinConstantConditions")
|
||||
if (BuildConfig.FLAVOR != "offline") {
|
||||
try {
|
||||
Log.d("ConnectivityService", "unregisterNetworkCallback")
|
||||
Log.d(Amber.TAG, "unregisterNetworkCallback")
|
||||
val connectivityManager =
|
||||
(getSystemService(ConnectivityManager::class.java) as ConnectivityManager)
|
||||
connectivityManager.unregisterNetworkCallback(networkCallback)
|
||||
} catch (e: Exception) {
|
||||
Log.d("connectivityManager", "Failed to unregisterNetworkCallback", e)
|
||||
Log.d(Amber.TAG, "Failed to unregisterNetworkCallback", e)
|
||||
}
|
||||
}
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
Log.d("ConnectivityService", "onStartCommand")
|
||||
Log.d(Amber.TAG, "onStartCommand")
|
||||
return START_STICKY
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ import kotlinx.coroutines.launch
|
||||
|
||||
class EventNotificationConsumer(private val applicationContext: Context) {
|
||||
private fun saveLog(text: String) {
|
||||
Log.d("EventNotificationConsumer", text)
|
||||
Log.d(Amber.TAG, text)
|
||||
Amber.instance.applicationIOScope.launch {
|
||||
val accounts = LocalPreferences.allSavedAccounts(applicationContext)
|
||||
accounts.forEach {
|
||||
@@ -291,7 +291,7 @@ class EventNotificationConsumer(private val applicationContext: Context) {
|
||||
val relays = permission?.application?.relays ?: applicationWithSecret?.application?.relays ?: responseRelay
|
||||
|
||||
if (type == SignerType.INVALID) {
|
||||
Log.d("EventNotificationConsumer", "Invalid request method ${bunkerRequest.method}")
|
||||
Log.d(Amber.TAG, "Invalid request method ${bunkerRequest.method}")
|
||||
dao.insertLog(
|
||||
LogEntity(
|
||||
0,
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
package com.greenart7c3.nostrsigner.service
|
||||
|
||||
import android.util.Log
|
||||
import com.greenart7c3.nostrsigner.Amber
|
||||
import com.greenart7c3.nostrsigner.checkNotInMainThread
|
||||
import com.greenart7c3.nostrsigner.okhttp.HttpClientManager
|
||||
import com.vitorpamplona.quartz.nip11RelayInfo.Nip11RelayInformation
|
||||
@@ -77,7 +78,7 @@ class Nip11Retriever {
|
||||
} catch (e: Exception) {
|
||||
if (e is CancellationException) throw e
|
||||
Log.e(
|
||||
"RelayInfoFail",
|
||||
Amber.TAG,
|
||||
"Resulting Message from Relay $dirtyUrl in not parseable: $body",
|
||||
e,
|
||||
)
|
||||
@@ -90,14 +91,14 @@ class Nip11Retriever {
|
||||
call: Call,
|
||||
e: IOException,
|
||||
) {
|
||||
Log.e("RelayInfoFail", "$dirtyUrl unavailable", e)
|
||||
Log.e(Amber.TAG, "$dirtyUrl unavailable", e)
|
||||
onError(dirtyUrl, ErrorCode.FAIL_TO_REACH_SERVER, e.message)
|
||||
}
|
||||
},
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
if (e is CancellationException) throw e
|
||||
Log.e("RelayInfoFail", "Invalid URL $dirtyUrl", e)
|
||||
Log.e(Amber.TAG, "Invalid URL $dirtyUrl", e)
|
||||
onError(dirtyUrl, ErrorCode.FAIL_TO_ASSEMBLE_URL, e.message)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ object NostrConnectUtils {
|
||||
),
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
Log.e("nostrconnect", e.message, e)
|
||||
Log.e(Amber.TAG, e.message, e)
|
||||
Amber.instance.applicationIOScope.launch {
|
||||
Amber.instance.getDatabase(account.npub).applicationDao().insertLog(
|
||||
LogEntity(
|
||||
|
||||
@@ -70,7 +70,7 @@ object NotificationDataSource : NostrDataSource(Amber.instance.client) {
|
||||
}
|
||||
|
||||
override fun onRelayStateChange(type: RelayState, relay: Relay) {
|
||||
Log.d("NotificationDataSource", "onRelayStateChange: $type")
|
||||
Log.d(Amber.TAG, "onRelayStateChange: $type")
|
||||
AmberRelayStats.updateNotification()
|
||||
scope.launch {
|
||||
LocalPreferences.currentAccount(Amber.instance)?.let { account ->
|
||||
|
||||
@@ -474,7 +474,7 @@ private fun askNotificationPermission(
|
||||
fun Color.Companion.fromHex(colorString: String) = try {
|
||||
Color("#$colorString".toColorInt())
|
||||
} catch (e: Exception) {
|
||||
Log.e("Color", "Failed to parse color: $colorString", e)
|
||||
Log.e(Amber.TAG, "Failed to parse color: $colorString", e)
|
||||
Unspecified
|
||||
}
|
||||
|
||||
|
||||
@@ -329,7 +329,7 @@ fun SettingsScreen(
|
||||
} catch (e: Exception) {
|
||||
isLoading = false
|
||||
if (e is CancellationException) throw e
|
||||
Log.e("NostrSigner", "Error deleting old log entries", e)
|
||||
Log.e(Amber.TAG, "Error deleting old log entries", e)
|
||||
val dbFile = context.getDatabasePath("amber_db_${account.npub}")
|
||||
val df = DecimalFormat("#.###")
|
||||
sizeInMBFormatted = df.format(dbFile.length() / (1024.0 * 1024.0))
|
||||
|
||||
Reference in New Issue
Block a user