mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-12 12:08:56 +01:00
Added category-wise display setting (#5232)
* Added category-wise display setting Co-authored-by: Rogavactive <30288842+Rogavactive@users.noreply.github.com> * Use flag instead of preference * Remove database call in LibraryItem * Remove unnecessary code Co-authored-by: Rogavactive <30288842+Rogavactive@users.noreply.github.com>
This commit is contained in:
@@ -12,8 +12,21 @@ interface Category : Serializable {
|
||||
|
||||
var flags: Int
|
||||
|
||||
private fun setFlags(flag: Int, mask: Int) {
|
||||
flags = flags and mask.inv() or (flag and mask)
|
||||
}
|
||||
|
||||
var displayMode: Int
|
||||
get() = flags and MASK
|
||||
set(mode) = setFlags(mode, MASK)
|
||||
|
||||
companion object {
|
||||
|
||||
const val COMPACT_GRID = 0b00000000
|
||||
const val COMFORTABLE_GRID = 0b00000001
|
||||
const val LIST = 0b00000010
|
||||
const val MASK = 0b00000011
|
||||
|
||||
fun create(name: String): Category = CategoryImpl().apply {
|
||||
this.name = name
|
||||
}
|
||||
|
||||
@@ -185,6 +185,8 @@ object PreferenceKeys {
|
||||
|
||||
const val defaultCategory = "default_category"
|
||||
|
||||
const val categorizedDisplay = "categorized_display"
|
||||
|
||||
const val skipRead = "skip_read"
|
||||
|
||||
const val skipFiltered = "skip_filtered"
|
||||
|
||||
@@ -284,6 +284,8 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun defaultCategory() = prefs.getInt(Keys.defaultCategory, -1)
|
||||
|
||||
fun categorisedDisplaySettings() = flowPrefs.getBoolean(Keys.categorizedDisplay, false)
|
||||
|
||||
fun skipRead() = prefs.getBoolean(Keys.skipRead, false)
|
||||
|
||||
fun skipFiltered() = prefs.getBoolean(Keys.skipFiltered, true)
|
||||
|
||||
Reference in New Issue
Block a user