diff --git a/app/src/main/java/io/github/sds100/keymapper/sorting/SortField.kt b/app/src/main/java/io/github/sds100/keymapper/sorting/SortField.kt index 03ff280643..f7831ad790 100644 --- a/app/src/main/java/io/github/sds100/keymapper/sorting/SortField.kt +++ b/app/src/main/java/io/github/sds100/keymapper/sorting/SortField.kt @@ -1,10 +1,5 @@ package io.github.sds100.keymapper.sorting -import io.github.sds100.keymapper.constraints.ConstraintUiHelper -import io.github.sds100.keymapper.sorting.comparators.KeyMapActionsComparator -import io.github.sds100.keymapper.sorting.comparators.KeyMapConstraintsComparator -import io.github.sds100.keymapper.sorting.comparators.KeyMapOptionsComparator -import io.github.sds100.keymapper.sorting.comparators.KeyMapTriggerComparator import kotlinx.serialization.Serializable @Serializable @@ -14,20 +9,3 @@ enum class SortField { CONSTRAINTS, OPTIONS, } - -fun SortField.Companion.getTriggerComparator( - reverse: Boolean, -) = KeyMapTriggerComparator(reverse) - -fun SortField.Companion.getActionsComparator( - reverse: Boolean, -) = KeyMapActionsComparator(reverse) - -fun SortField.Companion.getConstraintsComparator( - constraintUiHelper: ConstraintUiHelper, - reverse: Boolean, -) = KeyMapConstraintsComparator(constraintUiHelper, reverse) - -fun SortField.Companion.getOptionsComparator( - reverse: Boolean, -) = KeyMapOptionsComparator(reverse) diff --git a/app/src/main/java/io/github/sds100/keymapper/sorting/SortKeyMapsUseCase.kt b/app/src/main/java/io/github/sds100/keymapper/sorting/SortKeyMapsUseCase.kt index 9786e5660e..a4f91561f5 100644 --- a/app/src/main/java/io/github/sds100/keymapper/sorting/SortKeyMapsUseCase.kt +++ b/app/src/main/java/io/github/sds100/keymapper/sorting/SortKeyMapsUseCase.kt @@ -5,6 +5,10 @@ import io.github.sds100.keymapper.data.Keys import io.github.sds100.keymapper.data.repositories.PreferenceRepository import io.github.sds100.keymapper.mappings.DisplaySimpleMappingUseCase import io.github.sds100.keymapper.mappings.keymaps.KeyMap +import io.github.sds100.keymapper.sorting.comparators.KeyMapActionsComparator +import io.github.sds100.keymapper.sorting.comparators.KeyMapConstraintsComparator +import io.github.sds100.keymapper.sorting.comparators.KeyMapOptionsComparator +import io.github.sds100.keymapper.sorting.comparators.KeyMapTriggerComparator import io.github.sds100.keymapper.util.ui.ResourceProviderImpl import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map @@ -19,6 +23,9 @@ class SortKeyMapsUseCaseImpl( private val constraintUiHelper = ConstraintUiHelper(displaySimpleMappingUseCase, resourceProvider) + private val actionUiHelper = + ConstraintUiHelper(displaySimpleMappingUseCase, resourceProvider) + private val defaultOrder = listOf( SortFieldOrder(SortField.TRIGGER), SortFieldOrder(SortField.ACTIONS), @@ -74,16 +81,16 @@ class SortKeyMapsUseCaseImpl( val reverseOrder = sortFieldOrder.order == SortOrder.DESCENDING return when (sortFieldOrder.field) { - SortField.TRIGGER -> SortField.getTriggerComparator(reverseOrder) + SortField.TRIGGER -> KeyMapTriggerComparator(reverseOrder) - SortField.ACTIONS -> SortField.getActionsComparator(reverseOrder) + SortField.ACTIONS -> KeyMapActionsComparator(reverseOrder) - SortField.CONSTRAINTS -> SortField.getConstraintsComparator( + SortField.CONSTRAINTS -> KeyMapConstraintsComparator( constraintUiHelper, reverseOrder, ) - SortField.OPTIONS -> SortField.getOptionsComparator(reverseOrder) + SortField.OPTIONS -> KeyMapOptionsComparator(reverseOrder) } } }