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:
@@ -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
|
||||
|
||||
@@ -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(", "),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user