mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Replace INVERSED/UNDETERMINATE for IGNORE in TriStateCheckBox
This commit is contained in:
parent
4f2bf33b21
commit
c6a9cb32ea
11 changed files with 54 additions and 55 deletions
|
@ -188,7 +188,7 @@ class ManageCategoryDialog(bundle: Bundle? = null) :
|
||||||
updateCategories.add(categoryId.toString())
|
updateCategories.add(categoryId.toString())
|
||||||
excludeUpdateCategories.remove(categoryId.toString())
|
excludeUpdateCategories.remove(categoryId.toString())
|
||||||
}
|
}
|
||||||
TriStateCheckBox.State.INVERSED -> {
|
TriStateCheckBox.State.IGNORE -> {
|
||||||
updateCategories.remove(categoryId.toString())
|
updateCategories.remove(categoryId.toString())
|
||||||
excludeUpdateCategories.add(categoryId.toString())
|
excludeUpdateCategories.add(categoryId.toString())
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,7 @@ class ManageCategoryDialog(bundle: Bundle? = null) :
|
||||||
box.isVisible = (updateCategories.isNotEmpty() || excludeUpdateCategories.isNotEmpty()) && shouldShow
|
box.isVisible = (updateCategories.isNotEmpty() || excludeUpdateCategories.isNotEmpty()) && shouldShow
|
||||||
if (shouldShow) box.state = when {
|
if (shouldShow) box.state = when {
|
||||||
updateCategories.any { category?.id == it.toIntOrNull() } -> TriStateCheckBox.State.CHECKED
|
updateCategories.any { category?.id == it.toIntOrNull() } -> TriStateCheckBox.State.CHECKED
|
||||||
excludeUpdateCategories.any { category?.id == it.toIntOrNull() } -> TriStateCheckBox.State.INVERSED
|
excludeUpdateCategories.any { category?.id == it.toIntOrNull() } -> TriStateCheckBox.State.IGNORE
|
||||||
else -> TriStateCheckBox.State.UNCHECKED
|
else -> TriStateCheckBox.State.UNCHECKED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ class AddCategoryItem(val category: Category) : AbstractItem<FastAdapter.ViewHol
|
||||||
val binding = AddCategoryItemBinding.bind(view)
|
val binding = AddCategoryItemBinding.bind(view)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
binding.categoryCheckbox.useIndeterminateForInverse = true
|
binding.categoryCheckbox.useIndeterminateForIgnore = true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun bindView(item: AddCategoryItem, payloads: List<Any>) {
|
override fun bindView(item: AddCategoryItem, payloads: List<Any>) {
|
||||||
|
|
|
@ -69,7 +69,7 @@ class SetCategoriesSheet(
|
||||||
category.takeIf { preselected[index] == TriStateCheckBox.State.CHECKED }
|
category.takeIf { preselected[index] == TriStateCheckBox.State.CHECKED }
|
||||||
}
|
}
|
||||||
private val preIndeterminateCategories = categories.mapIndexedNotNull { index, category ->
|
private val preIndeterminateCategories = categories.mapIndexedNotNull { index, category ->
|
||||||
category.takeIf { preselected[index] == TriStateCheckBox.State.INDETERMINATE }
|
category.takeIf { preselected[index] == TriStateCheckBox.State.IGNORE }
|
||||||
}
|
}
|
||||||
private val selectedCategories = preIndeterminateCategories + preCheckedCategories
|
private val selectedCategories = preIndeterminateCategories + preCheckedCategories
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ class SetCategoriesSheet(
|
||||||
get() = itemAdapter.adapterItems.filter { it.state == TriStateCheckBox.State.CHECKED }.toSet()
|
get() = itemAdapter.adapterItems.filter { it.state == TriStateCheckBox.State.CHECKED }.toSet()
|
||||||
|
|
||||||
private val indeterminateItems: Set<AddCategoryItem>
|
private val indeterminateItems: Set<AddCategoryItem>
|
||||||
get() = itemAdapter.adapterItems.filter { it.state == TriStateCheckBox.State.INDETERMINATE }.toSet()
|
get() = itemAdapter.adapterItems.filter { it.state == TriStateCheckBox.State.IGNORE }.toSet()
|
||||||
|
|
||||||
private val uncheckedItems: Set<AddCategoryItem>
|
private val uncheckedItems: Set<AddCategoryItem>
|
||||||
get() = itemAdapter.adapterItems.filter { !it.isSelected }.toSet()
|
get() = itemAdapter.adapterItems.filter { !it.isSelected }.toSet()
|
||||||
|
@ -135,7 +135,7 @@ class SetCategoriesSheet(
|
||||||
itemAdapter.set(
|
itemAdapter.set(
|
||||||
categories.mapIndexed { index, category ->
|
categories.mapIndexed { index, category ->
|
||||||
AddCategoryItem(category).apply {
|
AddCategoryItem(category).apply {
|
||||||
skipInversed = preselected[index] != TriStateCheckBox.State.INDETERMINATE
|
skipInversed = preselected[index] != TriStateCheckBox.State.IGNORE
|
||||||
state = preselected[index]
|
state = preselected[index]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -540,17 +540,17 @@ class MangaDetailsPresenter(
|
||||||
) {
|
) {
|
||||||
manga.readFilter = when (unread) {
|
manga.readFilter = when (unread) {
|
||||||
TriStateCheckBox.State.CHECKED -> Manga.CHAPTER_SHOW_UNREAD
|
TriStateCheckBox.State.CHECKED -> Manga.CHAPTER_SHOW_UNREAD
|
||||||
TriStateCheckBox.State.INVERSED -> Manga.CHAPTER_SHOW_READ
|
TriStateCheckBox.State.IGNORE -> Manga.CHAPTER_SHOW_READ
|
||||||
else -> Manga.SHOW_ALL
|
else -> Manga.SHOW_ALL
|
||||||
}
|
}
|
||||||
manga.downloadedFilter = when (downloaded) {
|
manga.downloadedFilter = when (downloaded) {
|
||||||
TriStateCheckBox.State.CHECKED -> Manga.CHAPTER_SHOW_DOWNLOADED
|
TriStateCheckBox.State.CHECKED -> Manga.CHAPTER_SHOW_DOWNLOADED
|
||||||
TriStateCheckBox.State.INVERSED -> Manga.CHAPTER_SHOW_NOT_DOWNLOADED
|
TriStateCheckBox.State.IGNORE -> Manga.CHAPTER_SHOW_NOT_DOWNLOADED
|
||||||
else -> Manga.SHOW_ALL
|
else -> Manga.SHOW_ALL
|
||||||
}
|
}
|
||||||
manga.bookmarkedFilter = when (bookmarked) {
|
manga.bookmarkedFilter = when (bookmarked) {
|
||||||
TriStateCheckBox.State.CHECKED -> Manga.CHAPTER_SHOW_BOOKMARKED
|
TriStateCheckBox.State.CHECKED -> Manga.CHAPTER_SHOW_BOOKMARKED
|
||||||
TriStateCheckBox.State.INVERSED -> Manga.CHAPTER_SHOW_NOT_BOOKMARKED
|
TriStateCheckBox.State.IGNORE -> Manga.CHAPTER_SHOW_NOT_BOOKMARKED
|
||||||
else -> Manga.SHOW_ALL
|
else -> Manga.SHOW_ALL
|
||||||
}
|
}
|
||||||
manga.setFilterToLocal()
|
manga.setFilterToLocal()
|
||||||
|
@ -587,21 +587,21 @@ class MangaDetailsPresenter(
|
||||||
preferences.filterChapterByRead().set(
|
preferences.filterChapterByRead().set(
|
||||||
when (unread) {
|
when (unread) {
|
||||||
TriStateCheckBox.State.CHECKED -> Manga.CHAPTER_SHOW_UNREAD
|
TriStateCheckBox.State.CHECKED -> Manga.CHAPTER_SHOW_UNREAD
|
||||||
TriStateCheckBox.State.INVERSED -> Manga.CHAPTER_SHOW_READ
|
TriStateCheckBox.State.IGNORE -> Manga.CHAPTER_SHOW_READ
|
||||||
else -> Manga.SHOW_ALL
|
else -> Manga.SHOW_ALL
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
preferences.filterChapterByDownloaded().set(
|
preferences.filterChapterByDownloaded().set(
|
||||||
when (downloaded) {
|
when (downloaded) {
|
||||||
TriStateCheckBox.State.CHECKED -> Manga.CHAPTER_SHOW_DOWNLOADED
|
TriStateCheckBox.State.CHECKED -> Manga.CHAPTER_SHOW_DOWNLOADED
|
||||||
TriStateCheckBox.State.INVERSED -> Manga.CHAPTER_SHOW_NOT_DOWNLOADED
|
TriStateCheckBox.State.IGNORE -> Manga.CHAPTER_SHOW_NOT_DOWNLOADED
|
||||||
else -> Manga.SHOW_ALL
|
else -> Manga.SHOW_ALL
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
preferences.filterChapterByBookmarked().set(
|
preferences.filterChapterByBookmarked().set(
|
||||||
when (bookmarked) {
|
when (bookmarked) {
|
||||||
TriStateCheckBox.State.CHECKED -> Manga.CHAPTER_SHOW_BOOKMARKED
|
TriStateCheckBox.State.CHECKED -> Manga.CHAPTER_SHOW_BOOKMARKED
|
||||||
TriStateCheckBox.State.INVERSED -> Manga.CHAPTER_SHOW_NOT_BOOKMARKED
|
TriStateCheckBox.State.IGNORE -> Manga.CHAPTER_SHOW_NOT_BOOKMARKED
|
||||||
else -> Manga.SHOW_ALL
|
else -> Manga.SHOW_ALL
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -49,17 +49,17 @@ class ChapterFilterLayout @JvmOverloads constructor(context: Context, attrs: Att
|
||||||
fun setCheckboxes(manga: Manga, preferences: PreferencesHelper) {
|
fun setCheckboxes(manga: Manga, preferences: PreferencesHelper) {
|
||||||
binding.showUnread.state = when (manga.readFilter(preferences)) {
|
binding.showUnread.state = when (manga.readFilter(preferences)) {
|
||||||
Manga.CHAPTER_SHOW_UNREAD -> TriStateCheckBox.State.CHECKED
|
Manga.CHAPTER_SHOW_UNREAD -> TriStateCheckBox.State.CHECKED
|
||||||
Manga.CHAPTER_SHOW_READ -> TriStateCheckBox.State.INVERSED
|
Manga.CHAPTER_SHOW_READ -> TriStateCheckBox.State.IGNORE
|
||||||
else -> TriStateCheckBox.State.UNCHECKED
|
else -> TriStateCheckBox.State.UNCHECKED
|
||||||
}
|
}
|
||||||
binding.showDownload.state = when (manga.downloadedFilter(preferences)) {
|
binding.showDownload.state = when (manga.downloadedFilter(preferences)) {
|
||||||
Manga.CHAPTER_SHOW_DOWNLOADED -> TriStateCheckBox.State.CHECKED
|
Manga.CHAPTER_SHOW_DOWNLOADED -> TriStateCheckBox.State.CHECKED
|
||||||
Manga.CHAPTER_SHOW_NOT_DOWNLOADED -> TriStateCheckBox.State.INVERSED
|
Manga.CHAPTER_SHOW_NOT_DOWNLOADED -> TriStateCheckBox.State.IGNORE
|
||||||
else -> TriStateCheckBox.State.UNCHECKED
|
else -> TriStateCheckBox.State.UNCHECKED
|
||||||
}
|
}
|
||||||
binding.showBookmark.state = when (manga.bookmarkedFilter(preferences)) {
|
binding.showBookmark.state = when (manga.bookmarkedFilter(preferences)) {
|
||||||
Manga.CHAPTER_SHOW_BOOKMARKED -> TriStateCheckBox.State.CHECKED
|
Manga.CHAPTER_SHOW_BOOKMARKED -> TriStateCheckBox.State.CHECKED
|
||||||
Manga.CHAPTER_SHOW_NOT_BOOKMARKED -> TriStateCheckBox.State.INVERSED
|
Manga.CHAPTER_SHOW_NOT_BOOKMARKED -> TriStateCheckBox.State.IGNORE
|
||||||
else -> TriStateCheckBox.State.UNCHECKED
|
else -> TriStateCheckBox.State.UNCHECKED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ open class TriStateItem(val filter: Filter.TriState) : AbstractFlexibleItem<TriS
|
||||||
view.state = when (filter.state) {
|
view.state = when (filter.state) {
|
||||||
Filter.TriState.STATE_IGNORE -> TriStateCheckBox.State.UNCHECKED
|
Filter.TriState.STATE_IGNORE -> TriStateCheckBox.State.UNCHECKED
|
||||||
Filter.TriState.STATE_INCLUDE -> TriStateCheckBox.State.CHECKED
|
Filter.TriState.STATE_INCLUDE -> TriStateCheckBox.State.CHECKED
|
||||||
Filter.TriState.STATE_EXCLUDE -> TriStateCheckBox.State.INVERSED
|
Filter.TriState.STATE_EXCLUDE -> TriStateCheckBox.State.IGNORE
|
||||||
else -> throw Exception("Unknown state")
|
else -> throw Exception("Unknown state")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ open class TriStateItem(val filter: Filter.TriState) : AbstractFlexibleItem<TriS
|
||||||
filter.state = when (state) {
|
filter.state = when (state) {
|
||||||
TriStateCheckBox.State.UNCHECKED -> Filter.TriState.STATE_IGNORE
|
TriStateCheckBox.State.UNCHECKED -> Filter.TriState.STATE_IGNORE
|
||||||
TriStateCheckBox.State.CHECKED -> Filter.TriState.STATE_INCLUDE
|
TriStateCheckBox.State.CHECKED -> Filter.TriState.STATE_INCLUDE
|
||||||
else -> Filter.TriState.STATE_EXCLUDE
|
TriStateCheckBox.State.IGNORE -> Filter.TriState.STATE_EXCLUDE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ fun List<Manga>.moveCategories(
|
||||||
categories.map {
|
categories.map {
|
||||||
when (it) {
|
when (it) {
|
||||||
in commonCategories -> TriStateCheckBox.State.CHECKED
|
in commonCategories -> TriStateCheckBox.State.CHECKED
|
||||||
in mixedCategories -> TriStateCheckBox.State.INDETERMINATE
|
in mixedCategories -> TriStateCheckBox.State.IGNORE
|
||||||
else -> TriStateCheckBox.State.UNCHECKED
|
else -> TriStateCheckBox.State.UNCHECKED
|
||||||
}
|
}
|
||||||
}.toTypedArray(),
|
}.toTypedArray(),
|
||||||
|
|
|
@ -118,7 +118,7 @@ internal fun MaterialAlertDialogBuilder.setNegativeStateItems(
|
||||||
items = items,
|
items = items,
|
||||||
initialSelection = initialSelection.map {
|
initialSelection = initialSelection.map {
|
||||||
if (it) {
|
if (it) {
|
||||||
TriStateCheckBox.State.INVERSED.ordinal
|
TriStateCheckBox.State.IGNORE.ordinal
|
||||||
} else {
|
} else {
|
||||||
TriStateCheckBox.State.UNCHECKED.ordinal
|
TriStateCheckBox.State.UNCHECKED.ordinal
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ internal fun MaterialAlertDialogBuilder.setNegativeStateItems(
|
||||||
.toIntArray(),
|
.toIntArray(),
|
||||||
skipChecked = true
|
skipChecked = true
|
||||||
) { _, _, _, index, state ->
|
) { _, _, _, index, state ->
|
||||||
listener.onClick(null, index, state == TriStateCheckBox.State.INVERSED.ordinal)
|
listener.onClick(null, index, state == TriStateCheckBox.State.IGNORE.ordinal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,18 +18,18 @@ import kotlin.math.roundToInt
|
||||||
class TriStateCheckBox constructor(context: Context, attrs: AttributeSet?) :
|
class TriStateCheckBox constructor(context: Context, attrs: AttributeSet?) :
|
||||||
FrameLayout(context, attrs) {
|
FrameLayout(context, attrs) {
|
||||||
|
|
||||||
var useIndeterminateForInverse: Boolean = false
|
var useIndeterminateForIgnore: Boolean = false
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
if (if (field) state == State.INVERSED else state == State.INDETERMINATE) {
|
if (state == State.IGNORE) {
|
||||||
state = if (!field) State.INVERSED else State.INDETERMINATE
|
updateDrawable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var skipInversed: Boolean = false
|
var skipInversed: Boolean = false
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
if (field && (state == State.INVERSED || state == State.INDETERMINATE)) {
|
if (field && state == State.IGNORE) {
|
||||||
state = State.UNCHECKED
|
state = State.UNCHECKED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,8 @@ class TriStateCheckBox constructor(context: Context, attrs: AttributeSet?) :
|
||||||
private val checkedColor = ColorStateList.valueOf(context.getResourceColor(R.attr.colorSecondary))
|
private val checkedColor = ColorStateList.valueOf(context.getResourceColor(R.attr.colorSecondary))
|
||||||
private val inverseColor = ColorStateList.valueOf(context.getResourceColor(R.attr.colorSecondaryVariant))
|
private val inverseColor = ColorStateList.valueOf(context.getResourceColor(R.attr.colorSecondaryVariant))
|
||||||
private val indeterColor = ColorStateList.valueOf(context.getResourceColor(R.attr.colorPrimary))
|
private val indeterColor = ColorStateList.valueOf(context.getResourceColor(R.attr.colorPrimary))
|
||||||
|
private val ignoreColor get() = if (useIndeterminateForIgnore) indeterColor else inverseColor
|
||||||
|
|
||||||
private val disabledColor = ColorStateList.valueOf(
|
private val disabledColor = ColorStateList.valueOf(
|
||||||
ColorUtils.setAlphaComponent(context.getResourceColor(R.attr.colorControlNormal), (disabledAlpha * 255).roundToInt())
|
ColorUtils.setAlphaComponent(context.getResourceColor(R.attr.colorControlNormal), (disabledAlpha * 255).roundToInt())
|
||||||
)
|
)
|
||||||
|
@ -121,11 +123,7 @@ class TriStateCheckBox constructor(context: Context, attrs: AttributeSet?) :
|
||||||
fun goToNextStep() {
|
fun goToNextStep() {
|
||||||
setState(
|
setState(
|
||||||
when (state) {
|
when (state) {
|
||||||
State.CHECKED -> when {
|
State.CHECKED -> if (skipInversed) State.UNCHECKED else State.IGNORE
|
||||||
skipInversed -> State.UNCHECKED
|
|
||||||
useIndeterminateForInverse -> State.INDETERMINATE
|
|
||||||
else -> State.INVERSED
|
|
||||||
}
|
|
||||||
State.UNCHECKED -> State.CHECKED
|
State.UNCHECKED -> State.CHECKED
|
||||||
else -> State.UNCHECKED
|
else -> State.UNCHECKED
|
||||||
},
|
},
|
||||||
|
@ -172,8 +170,11 @@ class TriStateCheckBox constructor(context: Context, attrs: AttributeSet?) :
|
||||||
State.UNCHECKED -> {
|
State.UNCHECKED -> {
|
||||||
setAnimVectorCompat(
|
setAnimVectorCompat(
|
||||||
when (oldState) {
|
when (oldState) {
|
||||||
State.INDETERMINATE -> R.drawable.anim_checkbox_indeterminate_to_blank_24dp
|
State.IGNORE -> if (useIndeterminateForIgnore) {
|
||||||
State.INVERSED -> R.drawable.anim_check_box_x_to_blank_24dp
|
R.drawable.anim_checkbox_indeterminate_to_blank_24dp
|
||||||
|
} else {
|
||||||
|
R.drawable.anim_check_box_x_to_blank_24dp
|
||||||
|
}
|
||||||
else -> R.drawable.anim_check_box_checked_to_blank_24dp
|
else -> R.drawable.anim_check_box_checked_to_blank_24dp
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -183,18 +184,15 @@ class TriStateCheckBox constructor(context: Context, attrs: AttributeSet?) :
|
||||||
setAnimVectorCompat(R.drawable.anim_check_box_blank_to_checked_24dp)
|
setAnimVectorCompat(R.drawable.anim_check_box_blank_to_checked_24dp)
|
||||||
backgroundTintList = checkedColor
|
backgroundTintList = checkedColor
|
||||||
}
|
}
|
||||||
State.INVERSED -> {
|
State.IGNORE -> {
|
||||||
setAnimVectorCompat(
|
setAnimVectorCompat(
|
||||||
when (oldState) {
|
when {
|
||||||
State.CHECKED -> R.drawable.anim_check_box_checked_to_x_24dp
|
useIndeterminateForIgnore -> R.drawable.anim_check_box_checked_to_indeterminate_24dp
|
||||||
|
oldState == State.CHECKED -> R.drawable.anim_check_box_checked_to_x_24dp
|
||||||
else -> R.drawable.anim_checkbox_blank_to_x_24dp
|
else -> R.drawable.anim_checkbox_blank_to_x_24dp
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
backgroundTintList = inverseColor
|
backgroundTintList = ignoreColor
|
||||||
}
|
|
||||||
State.INDETERMINATE -> {
|
|
||||||
setAnimVectorCompat(R.drawable.anim_check_box_checked_to_indeterminate_24dp)
|
|
||||||
backgroundTintList = indeterColor
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this@TriStateCheckBox.isEnabled) imageTintList = backgroundTintList
|
if (this@TriStateCheckBox.isEnabled) imageTintList = backgroundTintList
|
||||||
|
@ -216,13 +214,15 @@ class TriStateCheckBox constructor(context: Context, attrs: AttributeSet?) :
|
||||||
setVectorCompat(R.drawable.ic_check_box_24dp)
|
setVectorCompat(R.drawable.ic_check_box_24dp)
|
||||||
checkedColor
|
checkedColor
|
||||||
}
|
}
|
||||||
State.INVERSED -> {
|
State.IGNORE -> {
|
||||||
setVectorCompat(R.drawable.ic_check_box_x_24dp)
|
setVectorCompat(
|
||||||
inverseColor
|
if (useIndeterminateForIgnore) {
|
||||||
}
|
R.drawable.ic_check_box_indeterminate_24dp
|
||||||
State.INDETERMINATE -> {
|
} else {
|
||||||
setVectorCompat(R.drawable.ic_check_box_indeterminate_24dp)
|
R.drawable.ic_check_box_x_24dp
|
||||||
indeterColor
|
}
|
||||||
|
)
|
||||||
|
ignoreColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this@TriStateCheckBox.isEnabled) imageTintList = backgroundTintList
|
if (this@TriStateCheckBox.isEnabled) imageTintList = backgroundTintList
|
||||||
|
@ -232,8 +232,7 @@ class TriStateCheckBox constructor(context: Context, attrs: AttributeSet?) :
|
||||||
enum class State {
|
enum class State {
|
||||||
UNCHECKED,
|
UNCHECKED,
|
||||||
CHECKED,
|
CHECKED,
|
||||||
INVERSED,
|
IGNORE,
|
||||||
INDETERMINATE,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -32,7 +32,7 @@ internal class TriStateMultiChoiceDialogAdapter(
|
||||||
private val states = TriStateCheckBox.State.values()
|
private val states = TriStateCheckBox.State.values()
|
||||||
private val defaultOrdinal
|
private val defaultOrdinal
|
||||||
get() = if (skipChecked) {
|
get() = if (skipChecked) {
|
||||||
TriStateCheckBox.State.INVERSED.ordinal
|
TriStateCheckBox.State.IGNORE.ordinal
|
||||||
} else {
|
} else {
|
||||||
TriStateCheckBox.State.CHECKED.ordinal
|
TriStateCheckBox.State.CHECKED.ordinal
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ internal class TriStateMultiChoiceDialogAdapter(
|
||||||
// This value was selected
|
// This value was selected
|
||||||
notifyItemChanged(index, CheckPayload)
|
notifyItemChanged(index, CheckPayload)
|
||||||
}
|
}
|
||||||
current == TriStateCheckBox.State.INVERSED.ordinal && previous != TriStateCheckBox.State.INVERSED.ordinal -> {
|
current == TriStateCheckBox.State.IGNORE.ordinal && previous != TriStateCheckBox.State.IGNORE.ordinal -> {
|
||||||
// This value was inverse selected
|
// This value was inverse selected
|
||||||
notifyItemChanged(index, InverseCheckPayload)
|
notifyItemChanged(index, InverseCheckPayload)
|
||||||
}
|
}
|
||||||
|
@ -64,8 +64,8 @@ internal class TriStateMultiChoiceDialogAdapter(
|
||||||
internal fun itemClicked(index: Int) {
|
internal fun itemClicked(index: Int) {
|
||||||
val newSelection = this.currentSelection.toMutableList()
|
val newSelection = this.currentSelection.toMutableList()
|
||||||
newSelection[index] = when (currentSelection[index]) {
|
newSelection[index] = when (currentSelection[index]) {
|
||||||
TriStateCheckBox.State.CHECKED.ordinal -> TriStateCheckBox.State.INVERSED.ordinal
|
TriStateCheckBox.State.CHECKED.ordinal -> TriStateCheckBox.State.IGNORE.ordinal
|
||||||
TriStateCheckBox.State.INVERSED.ordinal -> TriStateCheckBox.State.UNCHECKED.ordinal
|
TriStateCheckBox.State.IGNORE.ordinal -> TriStateCheckBox.State.UNCHECKED.ordinal
|
||||||
// UNCHECKED
|
// UNCHECKED
|
||||||
else -> defaultOrdinal
|
else -> defaultOrdinal
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ internal class TriStateMultiChoiceDialogAdapter(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
InverseCheckPayload -> {
|
InverseCheckPayload -> {
|
||||||
holder.controlView.setState(TriStateCheckBox.State.INVERSED, true)
|
holder.controlView.setState(TriStateCheckBox.State.IGNORE, true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
UncheckPayload -> {
|
UncheckPayload -> {
|
||||||
|
|
|
@ -91,7 +91,7 @@ class TriStateListPreference @JvmOverloads constructor(
|
||||||
.map {
|
.map {
|
||||||
when (it) {
|
when (it) {
|
||||||
in set -> TriStateCheckBox.State.CHECKED.ordinal
|
in set -> TriStateCheckBox.State.CHECKED.ordinal
|
||||||
in excludedSet -> TriStateCheckBox.State.INVERSED.ordinal
|
in excludedSet -> TriStateCheckBox.State.IGNORE.ordinal
|
||||||
else -> TriStateCheckBox.State.UNCHECKED.ordinal
|
else -> TriStateCheckBox.State.UNCHECKED.ordinal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ class TriStateListPreference @JvmOverloads constructor(
|
||||||
.map { entryValues[it] }
|
.map { entryValues[it] }
|
||||||
.toSet()
|
.toSet()
|
||||||
excludedItems = selections
|
excludedItems = selections
|
||||||
.mapIndexed { index, value -> if (value == TriStateCheckBox.State.INVERSED.ordinal) index else null }
|
.mapIndexed { index, value -> if (value == TriStateCheckBox.State.IGNORE.ordinal) index else null }
|
||||||
.filterNotNull()
|
.filterNotNull()
|
||||||
.map { entryValues[it] }
|
.map { entryValues[it] }
|
||||||
.toSet()
|
.toSet()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue