mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 15:26:58 +00:00
fix(search): Disable zero state if history is disabled
This commit is contained in:
@@ -91,44 +91,36 @@ class LawnchairLocalSearchAlgorithm(context: Context) : LawnchairSearchAlgorithm
|
|||||||
|
|
||||||
override fun doZeroStateSearch(callback: SearchCallback<BaseAllAppsAdapter.AdapterItem>) {
|
override fun doZeroStateSearch(callback: SearchCallback<BaseAllAppsAdapter.AdapterItem>) {
|
||||||
currentJob?.cancel()
|
currentJob?.cancel()
|
||||||
currentJob = coroutineScope.launch {
|
|
||||||
val prefs = PreferenceManager.getInstance(context)
|
|
||||||
val prefs2 = PreferenceManager2.getInstance(context)
|
|
||||||
|
|
||||||
val historyEnabled = prefs.searchResulRecentSuggestion.get()
|
val prefs = PreferenceManager.getInstance(context)
|
||||||
val maxHistory = prefs2.maxRecentResultCount.firstBlocking()
|
val historyEnabled = prefs.searchResulRecentSuggestion.get()
|
||||||
|
|
||||||
val historyResults = if (historyEnabled) {
|
if (!historyEnabled) {
|
||||||
historySearchProvider.getRecentKeywords(context, maxHistory)
|
callback.clearSearchResult()
|
||||||
} else {
|
} else {
|
||||||
emptyList()
|
currentJob = coroutineScope.launch {
|
||||||
}
|
val prefs2 = PreferenceManager2.getInstance(context)
|
||||||
|
val maxHistory = prefs2.maxRecentResultCount.firstBlocking()
|
||||||
|
|
||||||
val resultsToTranslate = if (historyResults.isNotEmpty()) {
|
val historyResults = historySearchProvider.getRecentKeywords(context, maxHistory)
|
||||||
historyResults + listOf(SearchResult.Action.SearchSettings)
|
|
||||||
} else {
|
val resultsToTranslate = if (historyResults.isNotEmpty()) {
|
||||||
listOf(
|
historyResults + listOf(SearchResult.Action.SearchSettings)
|
||||||
if (historyEnabled) {
|
} else {
|
||||||
// State A: No History
|
listOf(
|
||||||
SearchResult.Action.EmptyState(
|
SearchResult.Action.EmptyState(
|
||||||
titleRes = R.string.search_empty_state_title,
|
titleRes = R.string.search_empty_state_title,
|
||||||
subtitleRes = R.string.search_empty_state_no_history_subtitle,
|
subtitleRes = R.string.search_empty_state_no_history_subtitle,
|
||||||
)
|
),
|
||||||
} else {
|
SearchResult.Action.SearchSettings,
|
||||||
// State B: History Disabled
|
)
|
||||||
SearchResult.Action.EmptyState(
|
}
|
||||||
titleRes = R.string.search_empty_state_title,
|
|
||||||
subtitleRes = R.string.search_empty_state_history_disabled_subtitle,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
SearchResult.Action.SearchSettings,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
val searchTargets = translateToSearchTargets(resultsToTranslate)
|
val searchTargets = translateToSearchTargets(resultsToTranslate)
|
||||||
val adapterItems = transformSearchResults(searchTargets)
|
val adapterItems = transformSearchResults(searchTargets)
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
callback.onSearchResult("", ArrayList(adapterItems))
|
callback.onSearchResult("", ArrayList(adapterItems))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user