Replace remaining Android-specific strings

Also renaming the helper composables so it's a bit easier to find/replace everything
in forks.
This commit is contained in:
arkon
2023-11-18 19:41:33 -05:00
parent 46e734fc8e
commit 0d1bced122
165 changed files with 1179 additions and 1167 deletions

View File

@@ -37,7 +37,7 @@ import logcat.LogPriority
import okio.buffer
import okio.gzip
import okio.sink
import tachiyomi.core.i18n.localize
import tachiyomi.core.i18n.stringResource
import tachiyomi.core.preference.Preference
import tachiyomi.core.preference.PreferenceStore
import tachiyomi.core.util.system.logcat
@@ -76,7 +76,7 @@ class BackupCreator(
*/
suspend fun createBackup(uri: Uri, flags: Int, isAutoBackup: Boolean): String {
if (!context.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
throw IllegalStateException(context.localize(MR.strings.missing_storage_permission))
throw IllegalStateException(context.stringResource(MR.strings.missing_storage_permission))
}
val databaseManga = getFavorites.await()
@@ -111,7 +111,7 @@ class BackupCreator(
UniFile.fromUri(context, uri)
}
)
?: throw Exception(context.localize(MR.strings.create_backup_file_error))
?: throw Exception(context.stringResource(MR.strings.create_backup_file_error))
if (!file.isFile) {
throw IllegalStateException("Failed to get handle on a backup file")
@@ -119,7 +119,7 @@ class BackupCreator(
val byteArray = parser.encodeToByteArray(BackupSerializer, backup)
if (byteArray.isEmpty()) {
throw IllegalStateException(context.localize(MR.strings.empty_backup_error))
throw IllegalStateException(context.stringResource(MR.strings.empty_backup_error))
}
file.openOutputStream().also {

View File

@@ -4,7 +4,7 @@ import android.content.Context
import android.net.Uri
import eu.kanade.tachiyomi.data.track.TrackerManager
import eu.kanade.tachiyomi.util.BackupUtil
import tachiyomi.core.i18n.localize
import tachiyomi.core.i18n.stringResource
import tachiyomi.domain.source.service.SourceManager
import tachiyomi.i18n.MR
import uy.kohesive.injekt.Injekt
@@ -29,7 +29,7 @@ class BackupFileValidator(
}
if (backup.backupManga.isEmpty()) {
throw IllegalStateException(context.localize(MR.strings.invalid_backup_file_missing_manga))
throw IllegalStateException(context.stringResource(MR.strings.invalid_backup_file_missing_manga))
}
val sources = backup.backupSources.associate { it.sourceId to it.name }

View File

@@ -12,8 +12,8 @@ import eu.kanade.tachiyomi.util.storage.getUriCompat
import eu.kanade.tachiyomi.util.system.cancelNotification
import eu.kanade.tachiyomi.util.system.notificationBuilder
import eu.kanade.tachiyomi.util.system.notify
import tachiyomi.core.i18n.localize
import tachiyomi.core.i18n.localizePlural
import tachiyomi.core.i18n.pluralStringResource
import tachiyomi.core.i18n.stringResource
import tachiyomi.i18n.MR
import uy.kohesive.injekt.injectLazy
import java.io.File
@@ -47,7 +47,7 @@ class BackupNotifier(private val context: Context) {
fun showBackupProgress(): NotificationCompat.Builder {
val builder = with(progressNotificationBuilder) {
setContentTitle(context.localize(MR.strings.creating_backup))
setContentTitle(context.stringResource(MR.strings.creating_backup))
setProgress(0, 0, true)
}
@@ -61,7 +61,7 @@ class BackupNotifier(private val context: Context) {
context.cancelNotification(Notifications.ID_BACKUP_PROGRESS)
with(completeNotificationBuilder) {
setContentTitle(context.localize(MR.strings.creating_backup_error))
setContentTitle(context.stringResource(MR.strings.creating_backup_error))
setContentText(error)
show(Notifications.ID_BACKUP_COMPLETE)
@@ -72,13 +72,13 @@ class BackupNotifier(private val context: Context) {
context.cancelNotification(Notifications.ID_BACKUP_PROGRESS)
with(completeNotificationBuilder) {
setContentTitle(context.localize(MR.strings.backup_created))
setContentTitle(context.stringResource(MR.strings.backup_created))
setContentText(unifile.filePath ?: unifile.name)
clearActions()
addAction(
R.drawable.ic_share_24dp,
context.localize(MR.strings.action_share),
context.stringResource(MR.strings.action_share),
NotificationReceiver.shareBackupPendingBroadcast(
context,
unifile.uri,
@@ -92,7 +92,7 @@ class BackupNotifier(private val context: Context) {
fun showRestoreProgress(
content: String = "",
contentTitle: String = context.localize(
contentTitle: String = context.stringResource(
MR.strings.restoring_backup,
),
progress: Int = 0,
@@ -111,7 +111,7 @@ class BackupNotifier(private val context: Context) {
clearActions()
addAction(
R.drawable.ic_close_24dp,
context.localize(MR.strings.action_cancel),
context.stringResource(MR.strings.action_cancel),
NotificationReceiver.cancelRestorePendingBroadcast(context, Notifications.ID_RESTORE_PROGRESS),
)
}
@@ -125,7 +125,7 @@ class BackupNotifier(private val context: Context) {
context.cancelNotification(Notifications.ID_RESTORE_PROGRESS)
with(completeNotificationBuilder) {
setContentTitle(context.localize(MR.strings.restoring_backup_error))
setContentTitle(context.stringResource(MR.strings.restoring_backup_error))
setContentText(error)
show(Notifications.ID_RESTORE_COMPLETE)
@@ -137,13 +137,13 @@ class BackupNotifier(private val context: Context) {
errorCount: Int,
path: String?,
file: String?,
contentTitle: String = context.localize(
contentTitle: String = context.stringResource(
MR.strings.restore_completed,
),
) {
context.cancelNotification(Notifications.ID_RESTORE_PROGRESS)
val timeString = context.localize(
val timeString = context.stringResource(
MR.strings.restore_duration,
TimeUnit.MILLISECONDS.toMinutes(time),
TimeUnit.MILLISECONDS.toSeconds(time) - TimeUnit.MINUTES.toSeconds(
@@ -154,7 +154,7 @@ class BackupNotifier(private val context: Context) {
with(completeNotificationBuilder) {
setContentTitle(contentTitle)
setContentText(
context.localizePlural(
context.pluralStringResource(
MR.plurals.restore_completed_message,
errorCount,
timeString,
@@ -171,7 +171,7 @@ class BackupNotifier(private val context: Context) {
setContentIntent(errorLogIntent)
addAction(
R.drawable.ic_folder_24dp,
context.localize(MR.strings.action_show_errors),
context.stringResource(MR.strings.action_show_errors),
errorLogIntent,
)
}

View File

@@ -15,7 +15,7 @@ import eu.kanade.tachiyomi.util.system.isRunning
import eu.kanade.tachiyomi.util.system.workManager
import kotlinx.coroutines.CancellationException
import logcat.LogPriority
import tachiyomi.core.i18n.localize
import tachiyomi.core.i18n.stringResource
import tachiyomi.core.util.system.logcat
import tachiyomi.i18n.MR
@@ -41,7 +41,7 @@ class BackupRestoreJob(private val context: Context, workerParams: WorkerParamet
Result.success()
} catch (e: Exception) {
if (e is CancellationException) {
notifier.showRestoreError(context.localize(MR.strings.restoring_backup_canceled))
notifier.showRestoreError(context.stringResource(MR.strings.restoring_backup_canceled))
Result.success()
} else {
logcat(LogPriority.ERROR, e)

View File

@@ -22,7 +22,7 @@ import eu.kanade.tachiyomi.util.BackupUtil
import eu.kanade.tachiyomi.util.system.createFileInCacheDir
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.isActive
import tachiyomi.core.i18n.localize
import tachiyomi.core.i18n.stringResource
import tachiyomi.core.preference.AndroidPreferenceStore
import tachiyomi.core.preference.PreferenceStore
import tachiyomi.data.DatabaseHandler
@@ -94,7 +94,7 @@ class BackupRestorer(
errors.size,
logFile.parent,
logFile.name,
contentTitle = context.localize(MR.strings.library_sync_complete),
contentTitle = context.stringResource(MR.strings.library_sync_complete),
)
} else {
notifier.showRestoreComplete(time, errors.size, logFile.parent, logFile.name)
@@ -193,8 +193,8 @@ class BackupRestorer(
showRestoreProgress(
restoreProgress,
restoreAmount,
context.localize(MR.strings.categories),
context.localize(MR.strings.restoring_backup),
context.stringResource(MR.strings.categories),
context.stringResource(MR.strings.restoring_backup),
)
}
@@ -230,14 +230,14 @@ class BackupRestorer(
restoreProgress,
restoreAmount,
manga.title,
context.localize(MR.strings.syncing_library),
context.stringResource(MR.strings.syncing_library),
)
} else {
showRestoreProgress(
restoreProgress,
restoreAmount,
manga.title,
context.localize(MR.strings.restoring_backup),
context.stringResource(MR.strings.restoring_backup),
)
}
}
@@ -634,8 +634,8 @@ class BackupRestorer(
showRestoreProgress(
restoreProgress,
restoreAmount,
context.localize(MR.strings.app_settings),
context.localize(MR.strings.restoring_backup),
context.stringResource(MR.strings.app_settings),
context.stringResource(MR.strings.restoring_backup),
)
}
@@ -649,8 +649,8 @@ class BackupRestorer(
showRestoreProgress(
restoreProgress,
restoreAmount,
context.localize(MR.strings.source_settings),
context.localize(MR.strings.restoring_backup),
context.stringResource(MR.strings.source_settings),
context.stringResource(MR.strings.restoring_backup),
)
}

View File

@@ -14,7 +14,7 @@ import kotlinx.coroutines.flow.merge
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.runBlocking
import logcat.LogPriority
import tachiyomi.core.i18n.localize
import tachiyomi.core.i18n.stringResource
import tachiyomi.core.util.lang.launchIO
import tachiyomi.core.util.system.logcat
import tachiyomi.domain.category.interactor.GetCategories
@@ -159,7 +159,7 @@ class DownloadManager(
.filter { "image" in it.type.orEmpty() }
if (files.isEmpty()) {
throw Exception(context.localize(MR.strings.page_list_empty_error))
throw Exception(context.stringResource(MR.strings.page_list_empty_error))
}
return files.sortedBy { it.name }

View File

@@ -14,7 +14,7 @@ import eu.kanade.tachiyomi.util.lang.chop
import eu.kanade.tachiyomi.util.system.cancelNotification
import eu.kanade.tachiyomi.util.system.notificationBuilder
import eu.kanade.tachiyomi.util.system.notify
import tachiyomi.core.i18n.localize
import tachiyomi.core.i18n.stringResource
import tachiyomi.i18n.MR
import uy.kohesive.injekt.injectLazy
import java.util.regex.Pattern
@@ -80,12 +80,12 @@ internal class DownloadNotifier(private val context: Context) {
// Pause action
addAction(
R.drawable.ic_pause_24dp,
context.localize(MR.strings.action_pause),
context.stringResource(MR.strings.action_pause),
NotificationReceiver.pauseDownloadsPendingBroadcast(context),
)
}
val downloadingProgressText = context.localize(
val downloadingProgressText = context.stringResource(
MR.strings.chapter_downloading_progress,
download.downloadedImages,
download.pages!!.size,
@@ -117,8 +117,8 @@ internal class DownloadNotifier(private val context: Context) {
*/
fun onPaused() {
with(progressNotificationBuilder) {
setContentTitle(context.localize(MR.strings.chapter_paused))
setContentText(context.localize(MR.strings.download_notifier_download_paused))
setContentTitle(context.stringResource(MR.strings.chapter_paused))
setContentText(context.stringResource(MR.strings.download_notifier_download_paused))
setSmallIcon(R.drawable.ic_pause_24dp)
setProgress(0, 0, false)
setOngoing(false)
@@ -128,13 +128,13 @@ internal class DownloadNotifier(private val context: Context) {
// Resume action
addAction(
R.drawable.ic_play_arrow_24dp,
context.localize(MR.strings.action_resume),
context.stringResource(MR.strings.action_resume),
NotificationReceiver.resumeDownloadsPendingBroadcast(context),
)
// Clear action
addAction(
R.drawable.ic_close_24dp,
context.localize(MR.strings.action_cancel_all),
context.stringResource(MR.strings.action_cancel_all),
NotificationReceiver.clearDownloadsPendingBroadcast(context),
)
@@ -164,7 +164,7 @@ internal class DownloadNotifier(private val context: Context) {
*/
fun onWarning(reason: String, timeout: Long? = null, contentIntent: PendingIntent? = null) {
with(errorNotificationBuilder) {
setContentTitle(context.localize(MR.strings.download_notifier_downloader_title))
setContentTitle(context.stringResource(MR.strings.download_notifier_downloader_title))
setStyle(NotificationCompat.BigTextStyle().bigText(reason))
setSmallIcon(R.drawable.ic_warning_white_24dp)
setAutoCancel(true)
@@ -192,9 +192,9 @@ internal class DownloadNotifier(private val context: Context) {
// Create notification
with(errorNotificationBuilder) {
setContentTitle(
mangaTitle?.plus(": $chapter") ?: context.localize(MR.strings.download_notifier_downloader_title),
mangaTitle?.plus(": $chapter") ?: context.stringResource(MR.strings.download_notifier_downloader_title),
)
setContentText(error ?: context.localize(MR.strings.download_notifier_unknown_error))
setContentText(error ?: context.stringResource(MR.strings.download_notifier_unknown_error))
setSmallIcon(R.drawable.ic_warning_white_24dp)
clearActions()
setContentIntent(NotificationHandler.openDownloadManagerPendingActivity(context))

View File

@@ -9,7 +9,7 @@ import kotlinx.coroutines.MainScope
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import logcat.LogPriority
import tachiyomi.core.i18n.localize
import tachiyomi.core.i18n.stringResource
import tachiyomi.core.util.system.logcat
import tachiyomi.domain.chapter.model.Chapter
import tachiyomi.domain.download.service.DownloadPreferences
@@ -59,7 +59,7 @@ class DownloadProvider(
.createDirectory(getMangaDirName(mangaTitle))
} catch (e: Throwable) {
logcat(LogPriority.ERROR, e) { "Invalid download directory" }
throw Exception(context.localize(MR.strings.invalid_location, downloadsDir))
throw Exception(context.stringResource(MR.strings.invalid_location, downloadsDir))
}
}

View File

@@ -26,7 +26,7 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import logcat.LogPriority
import ru.beryukhov.reactivenetwork.ReactiveNetwork
import tachiyomi.core.i18n.localize
import tachiyomi.core.i18n.stringResource
import tachiyomi.core.util.lang.withUIContext
import tachiyomi.core.util.system.logcat
import tachiyomi.domain.download.service.DownloadPreferences
@@ -113,7 +113,7 @@ class DownloadService : Service() {
}
private fun downloaderStop(string: StringResource) {
downloadManager.downloaderStop(localize(string))
downloadManager.downloaderStop(stringResource(string))
}
private fun listenNetworkChanges() {
@@ -145,7 +145,7 @@ class DownloadService : Service() {
private fun getPlaceholderNotification(): Notification {
return notificationBuilder(Notifications.CHANNEL_DOWNLOADER_PROGRESS) {
setContentTitle(localize(MR.strings.download_notifier_downloader_title))
setContentTitle(stringResource(MR.strings.download_notifier_downloader_title))
}.build()
}
}

View File

@@ -40,7 +40,7 @@ import kotlinx.coroutines.supervisorScope
import logcat.LogPriority
import nl.adaptivity.xmlutil.serialization.XML
import okhttp3.Response
import tachiyomi.core.i18n.localize
import tachiyomi.core.i18n.stringResource
import tachiyomi.core.metadata.comicinfo.COMIC_INFO_FILE
import tachiyomi.core.metadata.comicinfo.ComicInfo
import tachiyomi.core.util.lang.launchIO
@@ -303,7 +303,7 @@ class Downloader(
) {
withUIContext {
notifier.onWarning(
context.localize(MR.strings.download_queue_size_warning),
context.stringResource(MR.strings.download_queue_size_warning),
WARNING_NOTIF_TIMEOUT_MS,
NotificationHandler.openUrl(context, LibraryUpdateNotifier.HELP_WARNING_URL),
)
@@ -326,7 +326,7 @@ class Downloader(
if (availSpace != -1L && availSpace < MIN_DISK_SPACE) {
download.status = Download.State.ERROR
notifier.onError(
context.localize(MR.strings.download_insufficient_space),
context.stringResource(MR.strings.download_insufficient_space),
download.chapter.name,
download.manga.title,
)
@@ -343,7 +343,7 @@ class Downloader(
val pages = download.source.getPageList(download.chapter.toSChapter())
if (pages.isEmpty()) {
throw Exception(context.localize(MR.strings.page_list_empty_error))
throw Exception(context.stringResource(MR.strings.page_list_empty_error))
}
// Don't trust index from source
val reIndexedPages = pages.mapIndexed { index, page -> Page(index, page.url, page.imageUrl, page.uri) }
@@ -547,7 +547,7 @@ class Downloader(
try {
val filenamePrefix = String.format("%03d", page.number)
val imageFile = tmpDir.listFiles()?.firstOrNull { it.name.orEmpty().startsWith(filenamePrefix) }
?: error(context.localize(MR.strings.download_notifier_split_page_not_found, page.number))
?: error(context.stringResource(MR.strings.download_notifier_split_page_not_found, page.number))
// If the original page was previously split, then skip
if (imageFile.name.orEmpty().startsWith("${filenamePrefix}__")) return

View File

@@ -38,7 +38,7 @@ import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.sync.Semaphore
import kotlinx.coroutines.sync.withPermit
import logcat.LogPriority
import tachiyomi.core.i18n.localize
import tachiyomi.core.i18n.stringResource
import tachiyomi.core.preference.getAndSet
import tachiyomi.core.util.lang.withIOContext
import tachiyomi.core.util.system.logcat
@@ -181,28 +181,30 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
.filter {
when {
it.manga.updateStrategy != UpdateStrategy.ALWAYS_UPDATE -> {
skippedUpdates.add(it.manga to context.localize(MR.strings.skipped_reason_not_always_update))
skippedUpdates.add(
it.manga to context.stringResource(MR.strings.skipped_reason_not_always_update),
)
false
}
MANGA_NON_COMPLETED in restrictions && it.manga.status.toInt() == SManga.COMPLETED -> {
skippedUpdates.add(it.manga to context.localize(MR.strings.skipped_reason_completed))
skippedUpdates.add(it.manga to context.stringResource(MR.strings.skipped_reason_completed))
false
}
MANGA_HAS_UNREAD in restrictions && it.unreadCount != 0L -> {
skippedUpdates.add(it.manga to context.localize(MR.strings.skipped_reason_not_caught_up))
skippedUpdates.add(it.manga to context.stringResource(MR.strings.skipped_reason_not_caught_up))
false
}
MANGA_NON_READ in restrictions && it.totalChapters > 0L && !it.hasStarted -> {
skippedUpdates.add(it.manga to context.localize(MR.strings.skipped_reason_not_started))
skippedUpdates.add(it.manga to context.stringResource(MR.strings.skipped_reason_not_started))
false
}
MANGA_OUTSIDE_RELEASE_PERIOD in restrictions && it.manga.nextUpdate > fetchWindow.second -> {
skippedUpdates.add(
it.manga to context.localize(MR.strings.skipped_reason_not_in_release_period),
it.manga to context.stringResource(MR.strings.skipped_reason_not_in_release_period),
)
false
}
@@ -287,9 +289,11 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
}
} catch (e: Throwable) {
val errorMessage = when (e) {
is NoChaptersException -> context.localize(MR.strings.no_chapters_error)
is NoChaptersException -> context.stringResource(
MR.strings.no_chapters_error,
)
// failedUpdates will already have the source, don't need to copy it into the message
is SourceNotInstalledException -> context.localize(
is SourceNotInstalledException -> context.stringResource(
MR.strings.loader_not_implemented_error,
)
else -> e.message
@@ -388,7 +392,7 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
if (errors.isNotEmpty()) {
val file = context.createFileInCacheDir("tachiyomi_update_errors.txt")
file.bufferedWriter().use { out ->
out.write(context.localize(MR.strings.library_errors_help, ERROR_LOG_HELP_URL) + "\n\n")
out.write(context.stringResource(MR.strings.library_errors_help, ERROR_LOG_HELP_URL) + "\n\n")
// Error file format:
// ! Error
// # Source

View File

@@ -26,8 +26,8 @@ import eu.kanade.tachiyomi.util.system.getBitmapOrNull
import eu.kanade.tachiyomi.util.system.notificationBuilder
import eu.kanade.tachiyomi.util.system.notify
import tachiyomi.core.Constants
import tachiyomi.core.i18n.localize
import tachiyomi.core.i18n.localizePlural
import tachiyomi.core.i18n.pluralStringResource
import tachiyomi.core.i18n.stringResource
import tachiyomi.core.util.lang.launchUI
import tachiyomi.domain.chapter.model.Chapter
import tachiyomi.domain.manga.model.Manga
@@ -61,12 +61,12 @@ class LibraryUpdateNotifier(private val context: Context) {
*/
val progressNotificationBuilder by lazy {
context.notificationBuilder(Notifications.CHANNEL_LIBRARY_PROGRESS) {
setContentTitle(context.localize(MR.strings.app_name))
setContentTitle(context.stringResource(MR.strings.app_name))
setSmallIcon(R.drawable.ic_refresh_24dp)
setLargeIcon(notificationBitmap)
setOngoing(true)
setOnlyAlertOnce(true)
addAction(R.drawable.ic_close_24dp, context.localize(MR.strings.action_cancel), cancelIntent)
addAction(R.drawable.ic_close_24dp, context.stringResource(MR.strings.action_cancel), cancelIntent)
}
}
@@ -80,13 +80,13 @@ class LibraryUpdateNotifier(private val context: Context) {
fun showProgressNotification(manga: List<Manga>, current: Int, total: Int) {
if (preferences.hideNotificationContent().get()) {
progressNotificationBuilder
.setContentTitle(context.localize(MR.strings.notification_check_updates))
.setContentTitle(context.stringResource(MR.strings.notification_check_updates))
.setContentText("($current/$total)")
} else {
val updatingText = manga.joinToString("\n") { it.title.chop(40) }
progressNotificationBuilder
.setContentTitle(
context.localize(
context.stringResource(
MR.strings.notification_updating_progress,
percentFormatter.format(current.toFloat() / total),
),
@@ -107,8 +107,10 @@ class LibraryUpdateNotifier(private val context: Context) {
Notifications.ID_LIBRARY_SIZE_WARNING,
Notifications.CHANNEL_LIBRARY_PROGRESS,
) {
setContentTitle(context.localize(MR.strings.label_warning))
setStyle(NotificationCompat.BigTextStyle().bigText(context.localize(MR.strings.notification_size_warning)))
setContentTitle(context.stringResource(MR.strings.label_warning))
setStyle(
NotificationCompat.BigTextStyle().bigText(context.stringResource(MR.strings.notification_size_warning)),
)
setSmallIcon(R.drawable.ic_warning_white_24dp)
setTimeoutAfter(Downloader.WARNING_NOTIF_TIMEOUT_MS)
setContentIntent(NotificationHandler.openUrl(context, HELP_WARNING_URL))
@@ -130,8 +132,8 @@ class LibraryUpdateNotifier(private val context: Context) {
Notifications.ID_LIBRARY_ERROR,
Notifications.CHANNEL_LIBRARY_ERROR,
) {
setContentTitle(context.localize(MR.strings.notification_update_error, failed))
setContentText(context.localize(MR.strings.action_show_errors))
setContentTitle(context.stringResource(MR.strings.notification_update_error, failed))
setContentText(context.stringResource(MR.strings.action_show_errors))
setSmallIcon(R.drawable.ic_tachi)
setContentIntent(NotificationReceiver.openErrorLogPendingActivity(context, uri))
@@ -152,8 +154,8 @@ class LibraryUpdateNotifier(private val context: Context) {
Notifications.ID_LIBRARY_SKIPPED,
Notifications.CHANNEL_LIBRARY_SKIPPED,
) {
setContentTitle(context.localize(MR.strings.notification_update_skipped, skipped))
setContentText(context.localize(MR.strings.learn_more))
setContentTitle(context.stringResource(MR.strings.notification_update_skipped, skipped))
setContentText(context.stringResource(MR.strings.learn_more))
setSmallIcon(R.drawable.ic_tachi)
setContentIntent(NotificationHandler.openUrl(context, HELP_SKIPPED_URL))
}
@@ -170,12 +172,12 @@ class LibraryUpdateNotifier(private val context: Context) {
Notifications.ID_NEW_CHAPTERS,
Notifications.CHANNEL_NEW_CHAPTERS,
) {
setContentTitle(context.localize(MR.strings.notification_new_chapters))
setContentTitle(context.stringResource(MR.strings.notification_new_chapters))
if (updates.size == 1 && !preferences.hideNotificationContent().get()) {
setContentText(updates.first().first.title.chop(NOTIF_TITLE_MAX_LEN))
} else {
setContentText(
context.localizePlural(
context.pluralStringResource(
MR.plurals.notification_new_chapters_summary,
updates.size,
updates.size,
@@ -246,7 +248,7 @@ class LibraryUpdateNotifier(private val context: Context) {
// Mark chapters as read action
addAction(
R.drawable.ic_glasses_24dp,
context.localize(MR.strings.action_mark_as_read),
context.stringResource(MR.strings.action_mark_as_read),
NotificationReceiver.markAsReadPendingBroadcast(
context,
manga,
@@ -257,7 +259,7 @@ class LibraryUpdateNotifier(private val context: Context) {
// View chapters action
addAction(
R.drawable.ic_book_24dp,
context.localize(MR.strings.action_view_chapters),
context.stringResource(MR.strings.action_view_chapters),
NotificationReceiver.openChapterPendingActivity(
context,
manga,
@@ -269,7 +271,7 @@ class LibraryUpdateNotifier(private val context: Context) {
if (chapters.size <= Downloader.CHAPTERS_PER_SOURCE_QUEUE_WARNING_THRESHOLD) {
addAction(
android.R.drawable.stat_sys_download_done,
context.localize(MR.strings.action_download),
context.stringResource(MR.strings.action_download),
NotificationReceiver.downloadChaptersPendingBroadcast(
context,
manga,
@@ -309,7 +311,7 @@ class LibraryUpdateNotifier(private val context: Context) {
// No sensible chapter numbers to show (i.e. no chapters have parsed chapter number)
0 -> {
// "1 new chapter" or "5 new chapters"
context.localizePlural(
context.pluralStringResource(
MR.plurals.notification_chapters_generic,
chapters.size,
chapters.size,
@@ -320,13 +322,13 @@ class LibraryUpdateNotifier(private val context: Context) {
val remaining = chapters.size - displayableChapterNumbers.size
if (remaining == 0) {
// "Chapter 2.5"
context.localize(
context.stringResource(
MR.strings.notification_chapters_single,
displayableChapterNumbers.first(),
)
} else {
// "Chapter 2.5 and 10 more"
context.localize(
context.stringResource(
MR.strings.notification_chapters_single_and_more,
displayableChapterNumbers.first(),
remaining,
@@ -342,7 +344,7 @@ class LibraryUpdateNotifier(private val context: Context) {
val joinedChapterNumbers = displayableChapterNumbers
.take(NOTIF_MAX_CHAPTERS)
.joinToString(", ")
context.localizePlural(
context.pluralStringResource(
MR.plurals.notification_chapters_multiple_and_more,
remaining,
joinedChapterNumbers,
@@ -350,7 +352,7 @@ class LibraryUpdateNotifier(private val context: Context) {
)
} else {
// "Chapters 1, 2.5, 3"
context.localize(
context.stringResource(
MR.strings.notification_chapters_multiple,
displayableChapterNumbers.joinToString(", "),
)

View File

@@ -7,7 +7,7 @@ import androidx.core.app.NotificationManagerCompat.IMPORTANCE_HIGH
import androidx.core.app.NotificationManagerCompat.IMPORTANCE_LOW
import eu.kanade.tachiyomi.util.system.buildNotificationChannel
import eu.kanade.tachiyomi.util.system.buildNotificationChannelGroup
import tachiyomi.core.i18n.localize
import tachiyomi.core.i18n.stringResource
import tachiyomi.i18n.MR
/**
@@ -103,16 +103,16 @@ object Notifications {
notificationManager.createNotificationChannelGroupsCompat(
listOf(
buildNotificationChannelGroup(GROUP_BACKUP_RESTORE) {
setName(context.localize(MR.strings.label_backup))
setName(context.stringResource(MR.strings.label_backup))
},
buildNotificationChannelGroup(GROUP_DOWNLOADER) {
setName(context.localize(MR.strings.download_notifier_downloader_title))
setName(context.stringResource(MR.strings.download_notifier_downloader_title))
},
buildNotificationChannelGroup(GROUP_LIBRARY) {
setName(context.localize(MR.strings.label_library))
setName(context.stringResource(MR.strings.label_library))
},
buildNotificationChannelGroup(GROUP_APK_UPDATES) {
setName(context.localize(MR.strings.label_recent_updates))
setName(context.stringResource(MR.strings.label_recent_updates))
},
),
)
@@ -120,57 +120,57 @@ object Notifications {
notificationManager.createNotificationChannelsCompat(
listOf(
buildNotificationChannel(CHANNEL_COMMON, IMPORTANCE_LOW) {
setName(context.localize(MR.strings.channel_common))
setName(context.stringResource(MR.strings.channel_common))
},
buildNotificationChannel(CHANNEL_LIBRARY_PROGRESS, IMPORTANCE_LOW) {
setName(context.localize(MR.strings.channel_progress))
setName(context.stringResource(MR.strings.channel_progress))
setGroup(GROUP_LIBRARY)
setShowBadge(false)
},
buildNotificationChannel(CHANNEL_LIBRARY_ERROR, IMPORTANCE_LOW) {
setName(context.localize(MR.strings.channel_errors))
setName(context.stringResource(MR.strings.channel_errors))
setGroup(GROUP_LIBRARY)
setShowBadge(false)
},
buildNotificationChannel(CHANNEL_LIBRARY_SKIPPED, IMPORTANCE_LOW) {
setName(context.localize(MR.strings.channel_skipped))
setName(context.stringResource(MR.strings.channel_skipped))
setGroup(GROUP_LIBRARY)
setShowBadge(false)
},
buildNotificationChannel(CHANNEL_NEW_CHAPTERS, IMPORTANCE_DEFAULT) {
setName(context.localize(MR.strings.channel_new_chapters))
setName(context.stringResource(MR.strings.channel_new_chapters))
},
buildNotificationChannel(CHANNEL_DOWNLOADER_PROGRESS, IMPORTANCE_LOW) {
setName(context.localize(MR.strings.channel_progress))
setName(context.stringResource(MR.strings.channel_progress))
setGroup(GROUP_DOWNLOADER)
setShowBadge(false)
},
buildNotificationChannel(CHANNEL_DOWNLOADER_ERROR, IMPORTANCE_LOW) {
setName(context.localize(MR.strings.channel_errors))
setName(context.stringResource(MR.strings.channel_errors))
setGroup(GROUP_DOWNLOADER)
setShowBadge(false)
},
buildNotificationChannel(CHANNEL_BACKUP_RESTORE_PROGRESS, IMPORTANCE_LOW) {
setName(context.localize(MR.strings.channel_progress))
setName(context.stringResource(MR.strings.channel_progress))
setGroup(GROUP_BACKUP_RESTORE)
setShowBadge(false)
},
buildNotificationChannel(CHANNEL_BACKUP_RESTORE_COMPLETE, IMPORTANCE_HIGH) {
setName(context.localize(MR.strings.channel_complete))
setName(context.stringResource(MR.strings.channel_complete))
setGroup(GROUP_BACKUP_RESTORE)
setShowBadge(false)
setSound(null, null)
},
buildNotificationChannel(CHANNEL_INCOGNITO_MODE, IMPORTANCE_LOW) {
setName(context.localize(MR.strings.pref_incognito_mode))
setName(context.stringResource(MR.strings.pref_incognito_mode))
},
buildNotificationChannel(CHANNEL_APP_UPDATE, IMPORTANCE_DEFAULT) {
setGroup(GROUP_APK_UPDATES)
setName(context.localize(MR.strings.channel_app_updates))
setName(context.stringResource(MR.strings.channel_app_updates))
},
buildNotificationChannel(CHANNEL_EXTENSIONS_UPDATE, IMPORTANCE_DEFAULT) {
setGroup(GROUP_APK_UPDATES)
setName(context.localize(MR.strings.channel_ext_updates))
setName(context.stringResource(MR.strings.channel_ext_updates))
},
),
)

View File

@@ -15,7 +15,7 @@ import eu.kanade.tachiyomi.util.storage.cacheImageDir
import eu.kanade.tachiyomi.util.storage.getUriCompat
import logcat.LogPriority
import okio.IOException
import tachiyomi.core.i18n.localize
import tachiyomi.core.i18n.stringResource
import tachiyomi.core.util.system.ImageUtil
import tachiyomi.core.util.system.logcat
import tachiyomi.i18n.MR
@@ -71,7 +71,7 @@ class ImageSaver(
val imageLocation = (image.location as Location.Pictures).relativePath
val relativePath = listOf(
Environment.DIRECTORY_PICTURES,
context.localize(MR.strings.app_name),
context.stringResource(MR.strings.app_name),
imageLocation,
).joinToString(File.separator)
@@ -86,7 +86,7 @@ class ImageSaver(
context.contentResolver.insert(
pictureDir,
contentValues,
) ?: throw IOException(context.localize(MR.strings.error_saving_picture))
) ?: throw IOException(context.stringResource(MR.strings.error_saving_picture))
}
try {
@@ -97,7 +97,7 @@ class ImageSaver(
}
} catch (e: Exception) {
logcat(LogPriority.ERROR, e)
throw IOException(context.localize(MR.strings.error_saving_picture))
throw IOException(context.stringResource(MR.strings.error_saving_picture))
}
DiskUtil.scanMedia(context, picture)
@@ -185,7 +185,7 @@ sealed interface Location {
is Pictures -> {
val file = File(
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
context.localize(MR.strings.app_name),
context.stringResource(MR.strings.app_name),
)
if (relativePath.isNotEmpty()) {
return File(

View File

@@ -21,7 +21,7 @@ import eu.kanade.tachiyomi.util.system.workManager
import logcat.LogPriority
import okhttp3.internal.http2.ErrorCode
import okhttp3.internal.http2.StreamResetException
import tachiyomi.core.i18n.localize
import tachiyomi.core.i18n.stringResource
import tachiyomi.core.util.lang.withIOContext
import tachiyomi.core.util.system.logcat
import tachiyomi.i18n.MR
@@ -37,7 +37,7 @@ class AppUpdateDownloadJob(private val context: Context, workerParams: WorkerPar
override suspend fun doWork(): Result {
val url = inputData.getString(EXTRA_DOWNLOAD_URL)
val title = inputData.getString(EXTRA_DOWNLOAD_TITLE) ?: context.localize(MR.strings.app_name)
val title = inputData.getString(EXTRA_DOWNLOAD_TITLE) ?: context.stringResource(MR.strings.app_name)
if (url.isNullOrEmpty()) {
return Result.failure()

View File

@@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.data.notification.NotificationReceiver
import eu.kanade.tachiyomi.data.notification.Notifications
import eu.kanade.tachiyomi.util.system.notificationBuilder
import eu.kanade.tachiyomi.util.system.notify
import tachiyomi.core.i18n.localize
import tachiyomi.core.i18n.stringResource
import tachiyomi.domain.release.model.Release
import tachiyomi.i18n.MR
@@ -53,7 +53,7 @@ internal class AppUpdateNotifier(private val context: Context) {
}
with(notificationBuilder) {
setContentTitle(context.localize(MR.strings.update_check_notification_update_available))
setContentTitle(context.stringResource(MR.strings.update_check_notification_update_available))
setContentText(release.version)
setSmallIcon(android.R.drawable.stat_sys_download_done)
setContentIntent(updateIntent)
@@ -61,12 +61,12 @@ internal class AppUpdateNotifier(private val context: Context) {
clearActions()
addAction(
android.R.drawable.stat_sys_download_done,
context.localize(MR.strings.action_download),
context.stringResource(MR.strings.action_download),
updateIntent,
)
addAction(
R.drawable.ic_info_24dp,
context.localize(MR.strings.whats_new),
context.stringResource(MR.strings.whats_new),
releaseIntent,
)
}
@@ -81,14 +81,14 @@ internal class AppUpdateNotifier(private val context: Context) {
fun onDownloadStarted(title: String? = null): NotificationCompat.Builder {
with(notificationBuilder) {
title?.let { setContentTitle(title) }
setContentText(context.localize(MR.strings.update_check_notification_download_in_progress))
setContentText(context.stringResource(MR.strings.update_check_notification_download_in_progress))
setSmallIcon(android.R.drawable.stat_sys_download)
setOngoing(true)
clearActions()
addAction(
R.drawable.ic_close_24dp,
context.localize(MR.strings.action_cancel),
context.stringResource(MR.strings.action_cancel),
NotificationReceiver.cancelDownloadAppUpdatePendingBroadcast(context),
)
}
@@ -117,7 +117,7 @@ internal class AppUpdateNotifier(private val context: Context) {
fun promptInstall(uri: Uri) {
val installIntent = NotificationHandler.installApkPendingActivity(context, uri)
with(notificationBuilder) {
setContentText(context.localize(MR.strings.update_check_notification_download_complete))
setContentText(context.stringResource(MR.strings.update_check_notification_download_complete))
setSmallIcon(android.R.drawable.stat_sys_download_done)
setOnlyAlertOnce(false)
setProgress(0, 0, false)
@@ -127,12 +127,12 @@ internal class AppUpdateNotifier(private val context: Context) {
clearActions()
addAction(
R.drawable.ic_system_update_alt_white_24dp,
context.localize(MR.strings.action_install),
context.stringResource(MR.strings.action_install),
installIntent,
)
addAction(
R.drawable.ic_close_24dp,
context.localize(MR.strings.action_cancel),
context.stringResource(MR.strings.action_cancel),
NotificationReceiver.dismissNotificationPendingBroadcast(context, Notifications.ID_APP_UPDATE_PROMPT),
)
}
@@ -147,8 +147,8 @@ internal class AppUpdateNotifier(private val context: Context) {
*/
fun promptFdroidUpdate() {
with(notificationBuilder) {
setContentTitle(context.localize(MR.strings.update_check_notification_update_available))
setContentText(context.localize(MR.strings.update_check_fdroid_migration_info))
setContentTitle(context.stringResource(MR.strings.update_check_notification_update_available))
setContentText(context.stringResource(MR.strings.update_check_fdroid_migration_info))
setSmallIcon(R.drawable.ic_tachi)
setContentIntent(
NotificationHandler.openUrl(
@@ -167,7 +167,7 @@ internal class AppUpdateNotifier(private val context: Context) {
*/
fun onDownloadError(url: String) {
with(notificationBuilder) {
setContentText(context.localize(MR.strings.update_check_notification_download_error))
setContentText(context.stringResource(MR.strings.update_check_notification_download_error))
setSmallIcon(R.drawable.ic_warning_white_24dp)
setOnlyAlertOnce(false)
setProgress(0, 0, false)
@@ -175,12 +175,12 @@ internal class AppUpdateNotifier(private val context: Context) {
clearActions()
addAction(
R.drawable.ic_refresh_24dp,
context.localize(MR.strings.action_retry),
context.stringResource(MR.strings.action_retry),
NotificationReceiver.downloadAppUpdatePendingBroadcast(context, url),
)
addAction(
R.drawable.ic_close_24dp,
context.localize(MR.strings.action_cancel),
context.stringResource(MR.strings.action_cancel),
NotificationReceiver.dismissNotificationPendingBroadcast(context, Notifications.ID_APP_UPDATER),
)
}