Make some strings in LocalSource translatable (closes #5178)

This commit is contained in:
arkon 2021-05-24 16:50:07 -04:00
parent 47f865aa72
commit 179cb8eb50
2 changed files with 20 additions and 13 deletions

View File

@ -32,8 +32,6 @@ class LocalSource(private val context: Context) : CatalogueSource {
private const val COVER_NAME = "cover.jpg"
private val SUPPORTED_ARCHIVE_TYPES = setOf("zip", "rar", "cbr", "cbz", "epub")
private val POPULAR_FILTERS = FilterList(OrderBy())
private val LATEST_FILTERS = FilterList(OrderBy().apply { state = Filter.Sort.Selection(1, false) })
private val LATEST_THRESHOLD = TimeUnit.MILLISECONDS.convert(7, TimeUnit.DAYS)
fun updateCover(context: Context, manga: SManga, input: InputStream): File? {
@ -192,12 +190,10 @@ class LocalSource(private val context: Context) : CatalogueSource {
ChapterRecognition.parseChapterNumber(this, manga)
}
}
.sortedWith(
Comparator { c1, c2 ->
val c = c2.chapter_number.compareTo(c1.chapter_number)
if (c == 0) c2.name.compareToCaseInsensitiveNaturalOrder(c1.name) else c
}
)
.sortedWith { c1, c2 ->
val c = c2.chapter_number.compareTo(c1.chapter_number)
if (c == 0) c2.name.compareToCaseInsensitiveNaturalOrder(c1.name) else c
}
.toList()
return Observable.just(chapters)
@ -242,7 +238,7 @@ class LocalSource(private val context: Context) : CatalogueSource {
}
private fun isSupportedFile(extension: String): Boolean {
return extension.toLowerCase() in SUPPORTED_ARCHIVE_TYPES
return extension.toLowerCase(Locale.ROOT) in SUPPORTED_ARCHIVE_TYPES
}
fun getFormat(chapter: SChapter): Format {
@ -254,7 +250,7 @@ class LocalSource(private val context: Context) : CatalogueSource {
return getFormat(chapFile)
}
throw Exception("Chapter not found")
throw Exception(context.getString(R.string.chapter_not_found))
}
private fun getFormat(file: File): Format {
@ -268,7 +264,7 @@ class LocalSource(private val context: Context) : CatalogueSource {
} else if (extension.equals("epub", true)) {
Format.Epub(file)
} else {
throw Exception("Invalid chapter format")
throw Exception(context.getString(R.string.local_invalid_format))
}
}
@ -311,9 +307,16 @@ class LocalSource(private val context: Context) : CatalogueSource {
}
}
private class OrderBy : Filter.Sort("Order by", arrayOf("Title", "Date"), Selection(0, true))
override fun getFilterList() = POPULAR_FILTERS
override fun getFilterList() = FilterList(OrderBy())
private val POPULAR_FILTERS = FilterList(OrderBy(context))
private val LATEST_FILTERS = FilterList(OrderBy(context).apply { state = Filter.Sort.Selection(1, false) })
private class OrderBy(context: Context) : Filter.Sort(
context.getString(R.string.local_filter_order_by),
arrayOf(context.getString(R.string.title), context.getString(R.string.date)),
Selection(0, true)
)
sealed class Format {
data class Directory(val file: File) : Format()

View File

@ -519,6 +519,10 @@
<string name="browse">Browse</string>
<string name="local_source_help_guide">Local source guide</string>
<string name="no_pinned_sources">You have no pinned sources</string>
<string name="chapter_not_found">Chapter not found</string>
<string name="local_invalid_format">Invalid chapter format</string>
<string name="local_filter_order_by">Order by</string>
<string name="date">Date</string>
<!-- Manga activity -->
<string name="manga_not_in_db">This manga has been removed from the database.</string>