Skip to content

Commit

Permalink
Add string resources
Browse files Browse the repository at this point in the history
  • Loading branch information
greenart7c3 committed Jan 15, 2025
1 parent 5e9bd9d commit 51b30ae
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,26 @@ object AmberRelayStats {
notificationManager.createNotificationChannel(channel)

val message = NostrSigner.getInstance().client.getAll().joinToString("\n") {
"${it.url} ${if (it.isConnected()) "connected" else "disconnected"}\n" +
"Ping: ${RelayStats.get(it.url).pingInMs}ms" +
if (get(it.url).sent > 0) {
" Sent: ${get(it.url).sent}"
} else {
"" +
if (get(it.url).received > 0) {
" Received: ${get(it.url).received}"
} else {
"" +
if (get(it.url).failed > 0) {
" Rejected by relay: ${get(it.url).failed}"
} else {
"" +
if (RelayStats.get(it.url).errorCounter > 0) " Error: ${RelayStats.get(it.url).errorCounter}" else ""
}
}
}
val connected = "${it.url} ${if (it.isConnected()) NostrSigner.getInstance().getString(R.string.connected) else NostrSigner.getInstance().getString(R.string.disconnected)}\n"
val ping = NostrSigner.getInstance().getString(R.string.ping_ms, RelayStats.get(it.url).pingInMs)
val sent = if (get(it.url).sent > 0) {
NostrSigner.getInstance().getString(R.string.sent, get(it.url).sent)
} else {
""
}
val received = if (get(it.url).received > 0) {
NostrSigner.getInstance().getString(R.string.received, get(it.url).received)
} else {
""
}
val failed = if (get(it.url).failed > 0) {
NostrSigner.getInstance().getString(R.string.rejected_by_relay, get(it.url).failed)
} else {
""
}
val error = if (RelayStats.get(it.url).errorCounter > 0) NostrSigner.getInstance().getString(R.string.error, RelayStats.get(it.url).errorCounter) else ""

connected + ping + sent + received + failed + error
}

val notificationBuilder =
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -477,4 +477,11 @@
<string name="deleting_old_log_entries">Deleting %1$d old log entries</string>
<string name="deleting_old_log_entries_2">Deleting %1$d/%2$d old log entries</string>
<string name="database_size_mb">Database size: %1$s MB</string>
<string name="connected">connected</string>
<string name="disconnected">disconnected</string>
<string name="ping_ms">Ping: %1$dms</string>
<string name="sent">" Sent: %1$d"</string>
<string name="received">" Received: %1$d"</string>
<string name="rejected_by_relay">" Rejected by relay: %1$d"</string>
<string name="error">" Error: %1$d"</string>
</resources>

0 comments on commit 51b30ae

Please sign in to comment.