Remove search result order preference
This commit is contained in:
parent
774777f79c
commit
77a68f8361
@ -5,6 +5,7 @@ import androidx.compose.animation.AnimatedVisibility
|
|||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.automirrored.rounded.Sort
|
||||||
import androidx.compose.material.icons.rounded.AppShortcut
|
import androidx.compose.material.icons.rounded.AppShortcut
|
||||||
import androidx.compose.material.icons.rounded.ArrowOutward
|
import androidx.compose.material.icons.rounded.ArrowOutward
|
||||||
import androidx.compose.material.icons.rounded.Calculate
|
import androidx.compose.material.icons.rounded.Calculate
|
||||||
@ -37,7 +38,6 @@ import androidx.lifecycle.compose.LocalLifecycleOwner
|
|||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import androidx.lifecycle.repeatOnLifecycle
|
import androidx.lifecycle.repeatOnLifecycle
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import de.mm20.launcher2.preferences.SearchResultOrder
|
|
||||||
import de.mm20.launcher2.ui.R
|
import de.mm20.launcher2.ui.R
|
||||||
import de.mm20.launcher2.ui.component.BottomSheetDialog
|
import de.mm20.launcher2.ui.component.BottomSheetDialog
|
||||||
import de.mm20.launcher2.ui.component.MissingPermissionBanner
|
import de.mm20.launcher2.ui.component.MissingPermissionBanner
|
||||||
@ -296,22 +296,6 @@ fun SearchSettingsScreen() {
|
|||||||
}
|
}
|
||||||
item {
|
item {
|
||||||
PreferenceCategory {
|
PreferenceCategory {
|
||||||
val searchResultOrdering by viewModel.searchResultOrdering.collectAsStateWithLifecycle(
|
|
||||||
null
|
|
||||||
)
|
|
||||||
ListPreference(
|
|
||||||
title = stringResource(R.string.preference_search_result_ordering),
|
|
||||||
items = listOf(
|
|
||||||
stringResource(R.string.preference_search_result_ordering_alphabetic) to SearchResultOrder.Alphabetical,
|
|
||||||
stringResource(R.string.preference_search_result_ordering_weighted) to SearchResultOrder.Weighted
|
|
||||||
),
|
|
||||||
value = searchResultOrdering,
|
|
||||||
onValueChanged = {
|
|
||||||
if (it != null) viewModel.setSearchResultOrdering(it)
|
|
||||||
},
|
|
||||||
icon = Icons.Rounded.Sort
|
|
||||||
)
|
|
||||||
|
|
||||||
val reverseSearchResults by viewModel.reverseSearchResults.collectAsStateWithLifecycle(
|
val reverseSearchResults by viewModel.reverseSearchResults.collectAsStateWithLifecycle(
|
||||||
null
|
null
|
||||||
)
|
)
|
||||||
@ -325,6 +309,7 @@ fun SearchSettingsScreen() {
|
|||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
if (it != null) viewModel.setReverseSearchResults(it)
|
if (it != null) viewModel.setReverseSearchResults(it)
|
||||||
},
|
},
|
||||||
|
icon = Icons.AutoMirrored.Rounded.Sort
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,10 @@
|
|||||||
package de.mm20.launcher2.ui.settings.search
|
package de.mm20.launcher2.ui.settings.search
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.pm.LauncherApps
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.compose.runtime.mutableStateOf
|
|
||||||
import androidx.core.content.getSystemService
|
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import de.mm20.launcher2.permissions.PermissionGroup
|
import de.mm20.launcher2.permissions.PermissionGroup
|
||||||
import de.mm20.launcher2.permissions.PermissionsManager
|
import de.mm20.launcher2.permissions.PermissionsManager
|
||||||
import de.mm20.launcher2.preferences.SearchResultOrder
|
|
||||||
import de.mm20.launcher2.preferences.search.CalculatorSearchSettings
|
import de.mm20.launcher2.preferences.search.CalculatorSearchSettings
|
||||||
import de.mm20.launcher2.preferences.search.CalendarSearchSettings
|
import de.mm20.launcher2.preferences.search.CalendarSearchSettings
|
||||||
import de.mm20.launcher2.preferences.search.ContactSearchSettings
|
import de.mm20.launcher2.preferences.search.ContactSearchSettings
|
||||||
@ -111,14 +106,6 @@ class SearchSettingsScreenVM : ViewModel(), KoinComponent {
|
|||||||
shortcutSearchSettings.setEnabled(appShortcuts)
|
shortcutSearchSettings.setEnabled(appShortcuts)
|
||||||
}
|
}
|
||||||
|
|
||||||
val searchResultOrdering = searchUiSettings.resultOrder
|
|
||||||
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
|
|
||||||
|
|
||||||
fun setSearchResultOrdering(searchResultOrdering: SearchResultOrder) {
|
|
||||||
searchUiSettings.setResultOrder(searchResultOrdering)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
val reverseSearchResults = searchUiSettings.reversedResults
|
val reverseSearchResults = searchUiSettings.reversedResults
|
||||||
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
|
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
|
||||||
|
|
||||||
|
|||||||
@ -89,7 +89,6 @@ data class LauncherSettingsData internal constructor(
|
|||||||
val searchBarFixed: Boolean = false,
|
val searchBarFixed: Boolean = false,
|
||||||
|
|
||||||
val searchResultsReversed: Boolean = false,
|
val searchResultsReversed: Boolean = false,
|
||||||
val searchResultOrder: SearchResultOrder = SearchResultOrder.Weighted,
|
|
||||||
val separateWorkProfile: Boolean = true,
|
val separateWorkProfile: Boolean = true,
|
||||||
|
|
||||||
val rankingWeightFactor: WeightFactor = WeightFactor.Default,
|
val rankingWeightFactor: WeightFactor = WeightFactor.Default,
|
||||||
@ -374,12 +373,6 @@ sealed interface GestureAction {
|
|||||||
data class Launch(val key: String?) : GestureAction
|
data class Launch(val key: String?) : GestureAction
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
|
||||||
enum class SearchResultOrder {
|
|
||||||
Weighted,
|
|
||||||
Alphabetical,
|
|
||||||
LaunchCount,
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
enum class WeightFactor {
|
enum class WeightFactor {
|
||||||
|
|||||||
@ -1,13 +1,12 @@
|
|||||||
package de.mm20.launcher2.preferences.ui
|
package de.mm20.launcher2.preferences.ui
|
||||||
|
|
||||||
import de.mm20.launcher2.preferences.LauncherDataStore
|
import de.mm20.launcher2.preferences.LauncherDataStore
|
||||||
import de.mm20.launcher2.preferences.SearchResultOrder
|
|
||||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
|
|
||||||
class SearchUiSettings internal constructor(
|
class SearchUiSettings internal constructor(
|
||||||
private val launcherDataStore: LauncherDataStore,
|
private val launcherDataStore: LauncherDataStore,
|
||||||
){
|
) {
|
||||||
val launchOnEnter
|
val launchOnEnter
|
||||||
get() = launcherDataStore.data.map { it.searchLaunchOnEnter }.distinctUntilChanged()
|
get() = launcherDataStore.data.map { it.searchLaunchOnEnter }.distinctUntilChanged()
|
||||||
|
|
||||||
@ -35,15 +34,6 @@ class SearchUiSettings internal constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val resultOrder
|
|
||||||
get() = launcherDataStore.data.map { it.searchResultOrder }.distinctUntilChanged()
|
|
||||||
|
|
||||||
fun setResultOrder(resultOrder: SearchResultOrder) {
|
|
||||||
launcherDataStore.update {
|
|
||||||
it.copy(searchResultOrder = resultOrder)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val openKeyboard
|
val openKeyboard
|
||||||
get() = launcherDataStore.data.map { it.searchBarKeyboard }.distinctUntilChanged()
|
get() = launcherDataStore.data.map { it.searchBarKeyboard }.distinctUntilChanged()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user