Skip to content

Commit

Permalink
Default Category now matches langauge
Browse files Browse the repository at this point in the history
Also more bug fixes with material dialogs
  • Loading branch information
Jays2Kings committed Jan 16, 2020
1 parent 6c6d9fb commit de66a66
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package eu.kanade.tachiyomi.data.database.models

import android.content.Context
import eu.kanade.tachiyomi.R
import java.io.Serializable

interface Category : Serializable {
Expand All @@ -25,7 +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 }
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
}
else {
category.mangaSort = ('a' + (it.second - 1))
if (category.name == "Default")
if (category.id == 0)
preferences.defaultMangaOrder().set(category.mangaSort.toString())
else
db.insertCategory(category).asRxObservable().subscribe()
Expand Down Expand Up @@ -329,7 +329,7 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
val mangaIds = adapter.currentItems.mapNotNull { it.manga.id }
category.mangaSort = null
category.mangaOrder = mangaIds
if (category.name == "Default")
if (category.id == 0)
preferences.defaultMangaOrder().set(mangaIds.joinToString("/"))
else
db.insertCategory(category).asRxObservable().subscribe()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ class LibraryController(
else
activeCategory

categories.find { it.id == 0 }?.let {
it.name = resources?.getString(R.string.default_columns) ?: "Default"
}
// Set the categories
adapter.categories = categories

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.library

import android.os.Bundle
import com.jakewharton.rxrelay.BehaviorRelay
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.cache.CoverCache
import eu.kanade.tachiyomi.data.database.DatabaseHelper
import eu.kanade.tachiyomi.data.database.models.Category
Expand Down Expand Up @@ -201,7 +202,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() }
Expand Down Expand Up @@ -285,7 +286,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.applicationContext)) + dbCategories
else dbCategories

this.categories = categories
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,31 +62,6 @@ class SettingsGeneralController : SettingsController() {
entryRange = 1..3
defaultValue = 1
}

/*intListPreference {
key = Keys.theme
titleRes = R.string.pref_theme
entriesRes = arrayOf(R.string.light_theme, R.string.dark_theme,
R.string.amoled_theme, R.string.darkblue_theme,
R.string.system_theme, R.string.system_amoled_theme, R.string.system_darkblue_theme)
entryValues = arrayOf("1", "2", "3", "4", "5", "6", "7")
defaultValue = "5"
summary = "%s"
onChange { newValue ->
activity?.recreate()
true
}
}
intListPreference {
key = Keys.startScreen
titleRes = R.string.pref_start_screen
entriesRes = arrayOf(R.string.label_library, R.string.label_recent_manga,
R.string.label_recent_updates)
entryValues = arrayOf("1", "2", "3")
defaultValue = "1"
summary = "%s"
}*/
switchPreference {
key = Keys.automaticUpdates
titleRes = R.string.pref_enable_automatic_updates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class SettingsLibraryController : SettingsController() {
titleRes = R.string.pref_library_update_restriction
entriesRes = arrayOf(R.string.wifi, R.string.charging)
entryValues = listOf("wifi", "ac")
customSummartRes = R.string.pref_library_update_restriction_summary
customSummaryRes = R.string.pref_library_update_restriction_summary

preferences.libraryUpdateInterval().asObservable()
.subscribeUntilDestroy { isVisible = it > 0 }
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ open class ListMatPreference @JvmOverloads constructor(context: Context, attrs:
else {
prefs.getStringPref(key, defValue).set(value)
this@ListMatPreference.summary = this@ListMatPreference.summary
callChangeListener(value)
}
dismiss()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MultiListMatPreference @JvmOverloads constructor(context: Context, attrs:
ListMatPreference(context, attrs) {

var allSelectionRes:Int? = null
var customSummartRes:Int
var customSummaryRes:Int
get() = 0
set(value) { customSummary = context.getString(value) }
var customSummary:String? = null
Expand Down Expand Up @@ -53,6 +53,7 @@ class MultiListMatPreference @JvmOverloads constructor(context: Context, attrs:
if (pos.isEmpty()) checkItem(0)
else uncheckItem(0)
}
callChangeListener(positions)
}
}
}
Expand Down

0 comments on commit de66a66

Please sign in to comment.