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 12, 2025
1 parent 0da904d commit 3c9b3c8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,28 +260,28 @@ fun SettingsScreen(
.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Text("Database size: $sizeInMBFormatted MB", color = Color.Gray)
Text(stringResource(R.string.database_size_mb, sizeInMBFormatted), color = Color.Gray)
AmberButton(
modifier = Modifier.fillMaxWidth(),
text = "Clear logs and activity",
text = stringResource(R.string.clear_logs_and_activity),
onClick = {
NostrSigner.getInstance().applicationIOScope.launch {
NotificationDataSource.stopSync()
isLoading = true
LocalPreferences.allSavedAccounts(NostrSigner.getInstance()).forEach {
NostrSigner.getInstance().getDatabase(it.npub).let { database ->
try {
status = "Deleting old log entries from ${it.npub}"
status = context.getString(R.string.deleting_old_log_entries_from, it.npub)
val oneWeek = System.currentTimeMillis() - ONE_WEEK
val oneWeekAgo = TimeUtils.oneWeekAgo()
val countHistory = database.applicationDao().countOldHistory(oneWeekAgo)
if (countHistory > 0) {
status = "Deleting $countHistory old history entries"
status = context.getString(R.string.deleting_old_history_entries, countHistory)
var logs = database.applicationDao().getOldHistory(oneWeekAgo)
var count = 0
while (logs.isNotEmpty()) {
count++
status = "Deleting ${100 * count}/$countHistory old history entries"
status = context.getString(R.string.deleting_old_history_entries_2, 100 * count, countHistory)
logs.forEach { history ->
database.applicationDao().deleteHistory(history)
}
Expand All @@ -291,12 +291,12 @@ fun SettingsScreen(

val countNotification = database.applicationDao().countOldNotification(oneWeekAgo)
if (countNotification > 0) {
status = "Deleting $countNotification old notification entries"
status = context.getString(R.string.deleting_old_notification_entries, countNotification)
var logs = database.applicationDao().getOldNotification(oneWeekAgo)
var count = 0
while (logs.isNotEmpty()) {
count++
status = "Deleting ${100 * count}/$countNotification old notification entries"
status = context.getString(R.string.deleting_old_notification_entries_2, 100 * count, countNotification)
logs.forEach { history ->
database.applicationDao().deleteNotification(history)
}
Expand All @@ -306,12 +306,12 @@ fun SettingsScreen(

val countLog = database.applicationDao().countOldLog(oneWeek)
if (countLog > 0) {
status = "Deleting $countLog old log entries"
status = context.getString(R.string.deleting_old_log_entries, countLog)
var logs = database.applicationDao().getOldLog(oneWeek)
var count = 0
while (logs.isNotEmpty()) {
count++
status = "Deleting ${100 * count}/$countLog old log entries"
status = context.getString(R.string.deleting_old_log_entries_2, 100 * count, countLog)
logs.forEach { history ->
database.applicationDao().deleteLog(history)
}
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -468,4 +468,13 @@
<string name="service">Service</string>
<string name="service_description">Service background notification</string>
<string name="close_application">Close application when accepting or rejecting a permission</string>
<string name="clear_logs_and_activity">Clear logs and activity</string>
<string name="deleting_old_log_entries_from">Deleting old log entries from %1$s</string>
<string name="deleting_old_history_entries">Deleting %1$d old history entries</string>
<string name="deleting_old_history_entries_2">Deleting %1$d/%2$d old history entries</string>
<string name="deleting_old_notification_entries">Deleting %1$d old notification entries</string>
<string name="deleting_old_notification_entries_2">Deleting %1$d/%2$d old notification entries</string>
<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>
</resources>

0 comments on commit 3c9b3c8

Please sign in to comment.