Using langauge name for default categories in settings

This commit is contained in:
Jay 2020-01-16 23:24:09 -08:00
parent a119f9e794
commit 1039601bc1
3 changed files with 8 additions and 5 deletions

View File

@ -27,8 +27,10 @@ interface Category : Serializable {
this.name = name
}
fun createDefault(): Category = create("Default").apply {
id = 0 }
fun createDefault(context: Context): Category = create(context.getString(R.string.default_columns))
.apply {
id =
0 }
}
}

View File

@ -200,7 +200,7 @@ class LibraryPresenter(
db.getTotalChapterManga().executeAsBlocking().associate { it.id!! to counter++ }
}
val catListing by lazy {
val default = Category.createDefault()
val default = Category.createDefault(context)
val defOrder = preferences.defaultMangaOrder().getOrDefault()
if (defOrder.firstOrNull()?.isLetter() == true) default.mangaSort = defOrder.first()
else default.mangaOrder = defOrder.split("/").mapNotNull { it.toLongOrNull() }
@ -284,7 +284,8 @@ class LibraryPresenter(
*/
private fun getLibraryObservable(): Observable<Library> {
return Observable.combineLatest(getCategoriesObservable(), getLibraryMangasObservable()) { dbCategories, libraryManga ->
val categories = if (libraryManga.containsKey(0)) arrayListOf(Category.createDefault()) + dbCategories
val categories = if (libraryManga.containsKey(0)) arrayListOf(Category.createDefault
(context)) + dbCategories
else dbCategories
this.categories = categories

View File

@ -132,7 +132,7 @@ class SettingsLibraryController : SettingsController() {
key = Keys.defaultCategory
titleRes = R.string.default_category
val categories = listOf(Category.createDefault()) + dbCategories
val categories = listOf(Category.createDefault(context)) + dbCategories
entries = listOf(context.getString(R.string.default_category_summary)) +
categories.map { it.name }.toTypedArray()
entryValues = listOf(-1) + categories.mapNotNull { it.id }.toList()