Minor settings sheet cleanup
(cherry picked from commit 07fdb74fbc9ae2afa67e427bb4a94860c7a2d8e6) # Conflicts: # app/src/main/java/eu/kanade/domain/library/service/LibraryPreferences.kt # app/src/main/java/eu/kanade/presentation/manga/ChapterSettingsDialog.kt # app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsSheet.kt
This commit is contained in:
parent
669e88f34b
commit
935b6576d0
@ -39,21 +39,21 @@ class LibraryPreferences(
|
|||||||
|
|
||||||
// region Filter
|
// region Filter
|
||||||
|
|
||||||
fun filterDownloaded() = preferenceStore.getInt("pref_filter_library_downloaded", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value)
|
fun filterDownloaded() = preferenceStore.getInt("pref_filter_library_downloaded", ExtendedNavigationView.Item.TriStateGroup.State.DISABLED.value)
|
||||||
|
|
||||||
fun filterUnread() = preferenceStore.getInt("pref_filter_library_unread", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value)
|
fun filterUnread() = preferenceStore.getInt("pref_filter_library_unread", ExtendedNavigationView.Item.TriStateGroup.State.DISABLED.value)
|
||||||
|
|
||||||
fun filterStarted() = preferenceStore.getInt("pref_filter_library_started", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value)
|
fun filterStarted() = preferenceStore.getInt("pref_filter_library_started", ExtendedNavigationView.Item.TriStateGroup.State.DISABLED.value)
|
||||||
|
|
||||||
fun filterBookmarked() = preferenceStore.getInt("pref_filter_library_bookmarked", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value)
|
fun filterBookmarked() = preferenceStore.getInt("pref_filter_library_bookmarked", ExtendedNavigationView.Item.TriStateGroup.State.DISABLED.value)
|
||||||
|
|
||||||
fun filterCompleted() = preferenceStore.getInt("pref_filter_library_completed", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value)
|
fun filterCompleted() = preferenceStore.getInt("pref_filter_library_completed", ExtendedNavigationView.Item.TriStateGroup.State.DISABLED.value)
|
||||||
|
|
||||||
// SY -->
|
// SY -->
|
||||||
fun filterLewd() = preferenceStore.getInt("pref_filter_library_lewd", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value)
|
fun filterLewd() = preferenceStore.getInt("pref_filter_library_lewd", ExtendedNavigationView.Item.TriStateGroup.State.DISABLED.value)
|
||||||
// SY <--
|
// SY <--
|
||||||
|
|
||||||
fun filterTracking(name: Int) = preferenceStore.getInt("pref_filter_library_tracked_$name", ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value)
|
fun filterTracking(name: Int) = preferenceStore.getInt("pref_filter_library_tracked_$name", ExtendedNavigationView.Item.TriStateGroup.State.DISABLED.value)
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package eu.kanade.presentation.manga
|
|||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.ColumnScope
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
@ -113,56 +114,7 @@ fun ChapterSettingsDialog(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun SetAsDefaultDialog(
|
private fun ColumnScope.FilterPage(
|
||||||
onDismissRequest: () -> Unit,
|
|
||||||
onConfirmed: (optionalChecked: Boolean) -> Unit,
|
|
||||||
) {
|
|
||||||
var optionalChecked by rememberSaveable { mutableStateOf(false) }
|
|
||||||
AlertDialog(
|
|
||||||
onDismissRequest = onDismissRequest,
|
|
||||||
title = { Text(text = stringResource(R.string.chapter_settings)) },
|
|
||||||
text = {
|
|
||||||
Column(
|
|
||||||
verticalArrangement = Arrangement.spacedBy(12.dp),
|
|
||||||
) {
|
|
||||||
Text(text = stringResource(R.string.confirm_set_chapter_settings))
|
|
||||||
|
|
||||||
Row(
|
|
||||||
modifier = Modifier
|
|
||||||
.clickable { optionalChecked = !optionalChecked }
|
|
||||||
.padding(vertical = 8.dp)
|
|
||||||
.fillMaxWidth(),
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
) {
|
|
||||||
Checkbox(
|
|
||||||
checked = optionalChecked,
|
|
||||||
onCheckedChange = null,
|
|
||||||
)
|
|
||||||
Text(text = stringResource(R.string.also_set_chapter_settings_for_library))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
dismissButton = {
|
|
||||||
TextButton(onClick = onDismissRequest) {
|
|
||||||
Text(text = stringResource(android.R.string.cancel))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
confirmButton = {
|
|
||||||
TextButton(
|
|
||||||
onClick = {
|
|
||||||
onConfirmed(optionalChecked)
|
|
||||||
onDismissRequest()
|
|
||||||
},
|
|
||||||
) {
|
|
||||||
Text(text = stringResource(android.R.string.ok))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun FilterPage(
|
|
||||||
downloadFilter: TriStateFilter,
|
downloadFilter: TriStateFilter,
|
||||||
onDownloadFilterChanged: ((TriStateFilter) -> Unit)?,
|
onDownloadFilterChanged: ((TriStateFilter) -> Unit)?,
|
||||||
unreadFilter: TriStateFilter,
|
unreadFilter: TriStateFilter,
|
||||||
@ -223,41 +175,86 @@ private fun SetScanlatorsItem(
|
|||||||
// SY <--
|
// SY <--
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun SortPage(
|
private fun ColumnScope.SortPage(
|
||||||
sortingMode: Long,
|
sortingMode: Long,
|
||||||
sortDescending: Boolean,
|
sortDescending: Boolean,
|
||||||
onItemSelected: (Long) -> Unit,
|
onItemSelected: (Long) -> Unit,
|
||||||
) {
|
) {
|
||||||
|
listOf(
|
||||||
|
R.string.sort_by_source to Manga.CHAPTER_SORTING_SOURCE,
|
||||||
|
R.string.sort_by_number to Manga.CHAPTER_SORTING_NUMBER,
|
||||||
|
R.string.sort_by_upload_date to Manga.CHAPTER_SORTING_UPLOAD_DATE,
|
||||||
|
).map { (titleRes, mode) ->
|
||||||
SortItem(
|
SortItem(
|
||||||
label = stringResource(R.string.sort_by_source),
|
label = stringResource(titleRes),
|
||||||
sortDescending = sortDescending.takeIf { sortingMode == Manga.CHAPTER_SORTING_SOURCE },
|
sortDescending = sortDescending.takeIf { sortingMode == mode },
|
||||||
onClick = { onItemSelected(Manga.CHAPTER_SORTING_SOURCE) },
|
onClick = { onItemSelected(mode) },
|
||||||
)
|
|
||||||
SortItem(
|
|
||||||
label = stringResource(R.string.sort_by_number),
|
|
||||||
sortDescending = sortDescending.takeIf { sortingMode == Manga.CHAPTER_SORTING_NUMBER },
|
|
||||||
onClick = { onItemSelected(Manga.CHAPTER_SORTING_NUMBER) },
|
|
||||||
)
|
|
||||||
SortItem(
|
|
||||||
label = stringResource(R.string.sort_by_upload_date),
|
|
||||||
sortDescending = sortDescending.takeIf { sortingMode == Manga.CHAPTER_SORTING_UPLOAD_DATE },
|
|
||||||
onClick = { onItemSelected(Manga.CHAPTER_SORTING_UPLOAD_DATE) },
|
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun DisplayPage(
|
private fun ColumnScope.DisplayPage(
|
||||||
displayMode: Long,
|
displayMode: Long,
|
||||||
onItemSelected: (Long) -> Unit,
|
onItemSelected: (Long) -> Unit,
|
||||||
) {
|
) {
|
||||||
|
listOf(
|
||||||
|
R.string.show_title to Manga.CHAPTER_DISPLAY_NAME,
|
||||||
|
R.string.show_chapter_number to Manga.CHAPTER_DISPLAY_NUMBER,
|
||||||
|
).map { (titleRes, mode) ->
|
||||||
RadioItem(
|
RadioItem(
|
||||||
label = stringResource(R.string.show_title),
|
label = stringResource(titleRes),
|
||||||
selected = displayMode == Manga.CHAPTER_DISPLAY_NAME,
|
selected = displayMode == mode,
|
||||||
onClick = { onItemSelected(Manga.CHAPTER_DISPLAY_NAME) },
|
onClick = { onItemSelected(mode) },
|
||||||
)
|
)
|
||||||
RadioItem(
|
}
|
||||||
label = stringResource(R.string.show_chapter_number),
|
}
|
||||||
selected = displayMode == Manga.CHAPTER_DISPLAY_NUMBER,
|
|
||||||
onClick = { onItemSelected(Manga.CHAPTER_DISPLAY_NUMBER) },
|
@Composable
|
||||||
|
private fun SetAsDefaultDialog(
|
||||||
|
onDismissRequest: () -> Unit,
|
||||||
|
onConfirmed: (optionalChecked: Boolean) -> Unit,
|
||||||
|
) {
|
||||||
|
var optionalChecked by rememberSaveable { mutableStateOf(false) }
|
||||||
|
AlertDialog(
|
||||||
|
onDismissRequest = onDismissRequest,
|
||||||
|
title = { Text(text = stringResource(R.string.chapter_settings)) },
|
||||||
|
text = {
|
||||||
|
Column(
|
||||||
|
verticalArrangement = Arrangement.spacedBy(12.dp),
|
||||||
|
) {
|
||||||
|
Text(text = stringResource(R.string.confirm_set_chapter_settings))
|
||||||
|
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.clickable { optionalChecked = !optionalChecked }
|
||||||
|
.padding(vertical = 8.dp)
|
||||||
|
.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
) {
|
||||||
|
Checkbox(
|
||||||
|
checked = optionalChecked,
|
||||||
|
onCheckedChange = null,
|
||||||
|
)
|
||||||
|
Text(text = stringResource(R.string.also_set_chapter_settings_for_library))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dismissButton = {
|
||||||
|
TextButton(onClick = onDismissRequest) {
|
||||||
|
Text(text = stringResource(android.R.string.cancel))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
confirmButton = {
|
||||||
|
TextButton(
|
||||||
|
onClick = {
|
||||||
|
onConfirmed(optionalChecked)
|
||||||
|
onDismissRequest()
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
Text(text = stringResource(android.R.string.ok))
|
||||||
|
}
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -116,9 +116,9 @@ object Migrations {
|
|||||||
fun convertBooleanPrefToTriState(key: String): Int {
|
fun convertBooleanPrefToTriState(key: String): Int {
|
||||||
val oldPrefValue = prefs.getBoolean(key, false)
|
val oldPrefValue = prefs.getBoolean(key, false)
|
||||||
return if (oldPrefValue) {
|
return if (oldPrefValue) {
|
||||||
ExtendedNavigationView.Item.TriStateGroup.State.INCLUDE.value
|
ExtendedNavigationView.Item.TriStateGroup.State.ENABLED_IS.value
|
||||||
} else {
|
} else {
|
||||||
ExtendedNavigationView.Item.TriStateGroup.State.IGNORE.value
|
ExtendedNavigationView.Item.TriStateGroup.State.DISABLED.value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prefs.edit {
|
prefs.edit {
|
||||||
|
@ -229,8 +229,8 @@ class LibraryScreenModel(
|
|||||||
prefs.filterStarted or
|
prefs.filterStarted or
|
||||||
prefs.filterBookmarked or
|
prefs.filterBookmarked or
|
||||||
prefs.filterCompleted
|
prefs.filterCompleted
|
||||||
) != TriStateGroup.State.IGNORE.value
|
) != TriStateGroup.State.DISABLED.value
|
||||||
val b = trackFilter.values.any { it != TriStateGroup.State.IGNORE.value }
|
val b = trackFilter.values.any { it != TriStateGroup.State.DISABLED.value }
|
||||||
a || b
|
a || b
|
||||||
}
|
}
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
@ -282,8 +282,8 @@ class LibraryScreenModel(
|
|||||||
|
|
||||||
val isNotLoggedInAnyTrack = loggedInTrackServices.isEmpty()
|
val isNotLoggedInAnyTrack = loggedInTrackServices.isEmpty()
|
||||||
|
|
||||||
val excludedTracks = loggedInTrackServices.mapNotNull { if (it.value == TriStateGroup.State.EXCLUDE.value) it.key else null }
|
val excludedTracks = loggedInTrackServices.mapNotNull { if (it.value == TriStateGroup.State.ENABLED_NOT.value) it.key else null }
|
||||||
val includedTracks = loggedInTrackServices.mapNotNull { if (it.value == TriStateGroup.State.INCLUDE.value) it.key else null }
|
val includedTracks = loggedInTrackServices.mapNotNull { if (it.value == TriStateGroup.State.ENABLED_IS.value) it.key else null }
|
||||||
val trackFiltersIsIgnored = includedTracks.isEmpty() && excludedTracks.isEmpty()
|
val trackFiltersIsIgnored = includedTracks.isEmpty() && excludedTracks.isEmpty()
|
||||||
|
|
||||||
// SY -->
|
// SY -->
|
||||||
@ -291,12 +291,12 @@ class LibraryScreenModel(
|
|||||||
// SY <--
|
// SY <--
|
||||||
|
|
||||||
val filterFnDownloaded: (LibraryItem) -> Boolean = downloaded@{
|
val filterFnDownloaded: (LibraryItem) -> Boolean = downloaded@{
|
||||||
if (!downloadedOnly && filterDownloaded == TriStateGroup.State.IGNORE.value) return@downloaded true
|
if (!downloadedOnly && filterDownloaded == TriStateGroup.State.DISABLED.value) return@downloaded true
|
||||||
|
|
||||||
val isDownloaded = it.libraryManga.manga.isLocal() ||
|
val isDownloaded = it.libraryManga.manga.isLocal() ||
|
||||||
it.downloadCount > 0 ||
|
it.downloadCount > 0 ||
|
||||||
downloadManager.getDownloadCount(it.libraryManga.manga) > 0
|
downloadManager.getDownloadCount(it.libraryManga.manga) > 0
|
||||||
return@downloaded if (downloadedOnly || filterDownloaded == TriStateGroup.State.INCLUDE.value) {
|
return@downloaded if (downloadedOnly || filterDownloaded == TriStateGroup.State.ENABLED_IS.value) {
|
||||||
isDownloaded
|
isDownloaded
|
||||||
} else {
|
} else {
|
||||||
!isDownloaded
|
!isDownloaded
|
||||||
@ -304,10 +304,10 @@ class LibraryScreenModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val filterFnUnread: (LibraryItem) -> Boolean = unread@{
|
val filterFnUnread: (LibraryItem) -> Boolean = unread@{
|
||||||
if (filterUnread == TriStateGroup.State.IGNORE.value) return@unread true
|
if (filterUnread == TriStateGroup.State.DISABLED.value) return@unread true
|
||||||
|
|
||||||
val isUnread = it.libraryManga.unreadCount > 0
|
val isUnread = it.libraryManga.unreadCount > 0
|
||||||
return@unread if (filterUnread == TriStateGroup.State.INCLUDE.value) {
|
return@unread if (filterUnread == TriStateGroup.State.ENABLED_IS.value) {
|
||||||
isUnread
|
isUnread
|
||||||
} else {
|
} else {
|
||||||
!isUnread
|
!isUnread
|
||||||
@ -315,10 +315,10 @@ class LibraryScreenModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val filterFnStarted: (LibraryItem) -> Boolean = started@{
|
val filterFnStarted: (LibraryItem) -> Boolean = started@{
|
||||||
if (filterStarted == TriStateGroup.State.IGNORE.value) return@started true
|
if (filterStarted == TriStateGroup.State.DISABLED.value) return@started true
|
||||||
|
|
||||||
val hasStarted = it.libraryManga.hasStarted
|
val hasStarted = it.libraryManga.hasStarted
|
||||||
return@started if (filterStarted == TriStateGroup.State.INCLUDE.value) {
|
return@started if (filterStarted == TriStateGroup.State.ENABLED_IS.value) {
|
||||||
hasStarted
|
hasStarted
|
||||||
} else {
|
} else {
|
||||||
!hasStarted
|
!hasStarted
|
||||||
@ -326,10 +326,10 @@ class LibraryScreenModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val filterFnBookmarked: (LibraryItem) -> Boolean = bookmarked@{
|
val filterFnBookmarked: (LibraryItem) -> Boolean = bookmarked@{
|
||||||
if (filterBookmarked == TriStateGroup.State.IGNORE.value) return@bookmarked true
|
if (filterBookmarked == TriStateGroup.State.DISABLED.value) return@bookmarked true
|
||||||
|
|
||||||
val hasBookmarks = it.libraryManga.hasBookmarks
|
val hasBookmarks = it.libraryManga.hasBookmarks
|
||||||
return@bookmarked if (filterBookmarked == TriStateGroup.State.INCLUDE.value) {
|
return@bookmarked if (filterBookmarked == TriStateGroup.State.ENABLED_IS.value) {
|
||||||
hasBookmarks
|
hasBookmarks
|
||||||
} else {
|
} else {
|
||||||
!hasBookmarks
|
!hasBookmarks
|
||||||
@ -337,10 +337,10 @@ class LibraryScreenModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val filterFnCompleted: (LibraryItem) -> Boolean = completed@{
|
val filterFnCompleted: (LibraryItem) -> Boolean = completed@{
|
||||||
if (filterCompleted == TriStateGroup.State.IGNORE.value) return@completed true
|
if (filterCompleted == TriStateGroup.State.DISABLED.value) return@completed true
|
||||||
|
|
||||||
val isCompleted = it.libraryManga.manga.status.toInt() == SManga.COMPLETED
|
val isCompleted = it.libraryManga.manga.status.toInt() == SManga.COMPLETED
|
||||||
return@completed if (filterCompleted == TriStateGroup.State.INCLUDE.value) {
|
return@completed if (filterCompleted == TriStateGroup.State.ENABLED_IS.value) {
|
||||||
isCompleted
|
isCompleted
|
||||||
} else {
|
} else {
|
||||||
!isCompleted
|
!isCompleted
|
||||||
@ -369,10 +369,10 @@ class LibraryScreenModel(
|
|||||||
|
|
||||||
// SY -->
|
// SY -->
|
||||||
val filterFnLewd: (LibraryItem) -> Boolean = lewd@{
|
val filterFnLewd: (LibraryItem) -> Boolean = lewd@{
|
||||||
if (filterLewd == TriStateGroup.State.IGNORE.value) return@lewd true
|
if (filterLewd == TriStateGroup.State.DISABLED.value) return@lewd true
|
||||||
val isLewd = it.libraryManga.manga.isLewd()
|
val isLewd = it.libraryManga.manga.isLewd()
|
||||||
|
|
||||||
return@lewd if (filterLewd == TriStateGroup.State.INCLUDE.value) {
|
return@lewd if (filterLewd == TriStateGroup.State.ENABLED_IS.value) {
|
||||||
isLewd
|
isLewd
|
||||||
} else {
|
} else {
|
||||||
!isLewd
|
!isLewd
|
||||||
|
@ -113,7 +113,7 @@ class LibrarySettingsSheet(
|
|||||||
* Returns true if there's at least one filter from [FilterGroup] active.
|
* Returns true if there's at least one filter from [FilterGroup] active.
|
||||||
*/
|
*/
|
||||||
fun hasActiveFilters(): Boolean {
|
fun hasActiveFilters(): Boolean {
|
||||||
return filterGroup.items.filterIsInstance<Item.TriStateGroup>().any { it.state != State.IGNORE.value }
|
return filterGroup.items.filterIsInstance<Item.TriStateGroup>().any { it.state != State.DISABLED.value }
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class FilterGroup : Group {
|
inner class FilterGroup : Group {
|
||||||
@ -153,7 +153,7 @@ class LibrarySettingsSheet(
|
|||||||
|
|
||||||
override fun initModels() {
|
override fun initModels() {
|
||||||
if (preferences.downloadedOnly().get()) {
|
if (preferences.downloadedOnly().get()) {
|
||||||
downloaded.state = State.INCLUDE.value
|
downloaded.state = State.ENABLED_IS.value
|
||||||
downloaded.enabled = false
|
downloaded.enabled = false
|
||||||
} else {
|
} else {
|
||||||
downloaded.state = libraryPreferences.filterDownloaded().get()
|
downloaded.state = libraryPreferences.filterDownloaded().get()
|
||||||
@ -176,9 +176,9 @@ class LibrarySettingsSheet(
|
|||||||
override fun onItemClicked(item: Item) {
|
override fun onItemClicked(item: Item) {
|
||||||
item as Item.TriStateGroup
|
item as Item.TriStateGroup
|
||||||
val newState = when (item.state) {
|
val newState = when (item.state) {
|
||||||
State.IGNORE.value -> State.INCLUDE.value
|
State.DISABLED.value -> State.ENABLED_IS.value
|
||||||
State.INCLUDE.value -> State.EXCLUDE.value
|
State.ENABLED_IS.value -> State.ENABLED_NOT.value
|
||||||
State.EXCLUDE.value -> State.IGNORE.value
|
State.ENABLED_NOT.value -> State.DISABLED.value
|
||||||
else -> throw Exception("Unknown State")
|
else -> throw Exception("Unknown State")
|
||||||
}
|
}
|
||||||
item.state = newState
|
item.state = newState
|
||||||
|
@ -133,16 +133,16 @@ open class ExtendedNavigationView @JvmOverloads constructor(
|
|||||||
class TriStateGroup(resId: Int, group: Group) : MultiStateGroup(resId, group) {
|
class TriStateGroup(resId: Int, group: Group) : MultiStateGroup(resId, group) {
|
||||||
|
|
||||||
enum class State(val value: Int) {
|
enum class State(val value: Int) {
|
||||||
IGNORE(0),
|
DISABLED(0),
|
||||||
INCLUDE(1),
|
ENABLED_IS(1),
|
||||||
EXCLUDE(2),
|
ENABLED_NOT(2),
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getStateDrawable(context: Context): Drawable? {
|
override fun getStateDrawable(context: Context): Drawable? {
|
||||||
return when (state) {
|
return when (state) {
|
||||||
State.IGNORE.value -> tintVector(context, R.drawable.ic_check_box_outline_blank_24dp, R.attr.colorControlNormal)
|
State.DISABLED.value -> tintVector(context, R.drawable.ic_check_box_outline_blank_24dp, R.attr.colorControlNormal)
|
||||||
State.INCLUDE.value -> tintVector(context, R.drawable.ic_check_box_24dp)
|
State.ENABLED_IS.value -> tintVector(context, R.drawable.ic_check_box_24dp)
|
||||||
State.EXCLUDE.value -> tintVector(context, R.drawable.ic_check_box_x_24dp)
|
State.ENABLED_NOT.value -> tintVector(context, R.drawable.ic_check_box_x_24dp)
|
||||||
else -> throw Exception("Unknown state")
|
else -> throw Exception("Unknown state")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,5 +55,5 @@ sealed class LibraryDisplayMode(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val Category.display: LibraryDisplayMode
|
val Category?.display: LibraryDisplayMode
|
||||||
get() = LibraryDisplayMode.valueOf(flags)
|
get() = LibraryDisplayMode.valueOf(this?.flags)
|
||||||
|
@ -73,7 +73,8 @@ data class LibrarySort(
|
|||||||
val directions = setOf(Direction.Ascending, Direction.Descending)
|
val directions = setOf(Direction.Ascending, Direction.Descending)
|
||||||
val default = LibrarySort(Type.Alphabetical, Direction.Ascending)
|
val default = LibrarySort(Type.Alphabetical, Direction.Ascending)
|
||||||
|
|
||||||
fun valueOf(flag: Long): LibrarySort {
|
fun valueOf(flag: Long?): LibrarySort {
|
||||||
|
if (flag == null) return default
|
||||||
return LibrarySort(
|
return LibrarySort(
|
||||||
Type.valueOf(flag),
|
Type.valueOf(flag),
|
||||||
Direction.valueOf(flag),
|
Direction.valueOf(flag),
|
||||||
@ -123,5 +124,5 @@ data class LibrarySort(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val Category.sort: LibrarySort
|
val Category?.sort: LibrarySort
|
||||||
get() = LibrarySort.valueOf(flags)
|
get() = LibrarySort.valueOf(this?.flags)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user