mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 07:16:54 +00:00
spotlessApply
This commit is contained in:
@@ -39,12 +39,12 @@ import app.lawnchair.smartspace.model.SmartspaceMode
|
||||
import app.lawnchair.smartspace.model.SmartspaceTimeFormat
|
||||
import app.lawnchair.theme.color.ColorMode
|
||||
import app.lawnchair.theme.color.ColorOption
|
||||
import app.lawnchair.ui.preferences.components.HiddenAppsInSearch
|
||||
import app.lawnchair.util.kotlinxJson
|
||||
import com.android.launcher3.InvariantDeviceProfile
|
||||
import com.android.launcher3.LauncherAppState
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.graphics.IconShape as L3IconShape
|
||||
import app.lawnchair.ui.preferences.components.HiddenAppsInSearch
|
||||
import com.android.launcher3.util.DynamicResource
|
||||
import com.android.launcher3.util.MainThreadInitializedObject
|
||||
import com.patrykmichalik.opto.core.PreferenceManager
|
||||
@@ -245,18 +245,18 @@ class PreferenceManager2 private constructor(private val context: Context) : Pre
|
||||
|
||||
val showHiddenAppsInSearch = preference(
|
||||
key = booleanPreferencesKey(name = "show_hidden_apps_in_search"),
|
||||
defaultValue = false
|
||||
defaultValue = false,
|
||||
)
|
||||
|
||||
val enableSmartHide = preference(
|
||||
key = booleanPreferencesKey(name = "enable_smart_hide"),
|
||||
defaultValue = false
|
||||
defaultValue = false,
|
||||
)
|
||||
|
||||
val hiddenAppsInSearch = preference(
|
||||
key = stringPreferencesKey(name = "hidden_apps_in_search"),
|
||||
defaultValue = HiddenAppsInSearch.NEVER,
|
||||
onSet = { reloadHelper.recreate() }
|
||||
onSet = { reloadHelper.recreate() },
|
||||
)
|
||||
|
||||
val showSuggestedAppsInDrawer = preference(
|
||||
|
||||
@@ -25,6 +25,6 @@ fun HiddenAppsInSearchPreference() {
|
||||
ListPreference(
|
||||
adapter = preferenceManager2().hiddenAppsInSearch.getAdapter(),
|
||||
entries = hiddenAppsInSearchEntries,
|
||||
label = "Show Hidden Apps in Search Results"
|
||||
label = "Show Hidden Apps in Search Results",
|
||||
)
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.rememberUpdatedState
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -42,7 +44,7 @@ fun SearchSuggestionPreference(
|
||||
isPermissionGranted: Boolean = true,
|
||||
onPermissionRequest: (() -> Unit)? = null,
|
||||
requestPermissionDescription: String? = null,
|
||||
content: @Composable (() -> Unit)? = null
|
||||
content: @Composable (() -> Unit)? = null,
|
||||
) {
|
||||
val bottomSheetHandler = bottomSheetHandler
|
||||
|
||||
@@ -69,7 +71,7 @@ fun SearchSuggestionPreference(
|
||||
onPermissionDenied = {},
|
||||
onPermissionGranted = {},
|
||||
requestPermissionDescription = requestPermissionDescription,
|
||||
preventSwitchChange = preventSwitchChange
|
||||
preventSwitchChange = preventSwitchChange,
|
||||
)
|
||||
}
|
||||
},
|
||||
@@ -95,8 +97,11 @@ private fun BottomSheetContent(
|
||||
requestPermissionDescription: String?,
|
||||
preventSwitchChange: Boolean = false,
|
||||
) {
|
||||
LaunchedEffect(null) {
|
||||
if (!isPermissionGranted && adapterValue) { adapterOnChange(false) }
|
||||
val latestOnClick by rememberUpdatedState(adapterOnChange)
|
||||
LaunchedEffect(Unit) {
|
||||
if (!isPermissionGranted && adapterValue) {
|
||||
latestOnClick(false)
|
||||
}
|
||||
}
|
||||
|
||||
ModalBottomSheetContent(
|
||||
@@ -137,7 +142,7 @@ private fun BottomSheetContent(
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(16.dp)
|
||||
.padding(16.dp),
|
||||
) {
|
||||
Text(
|
||||
text = requestPermissionDescription,
|
||||
@@ -158,15 +163,14 @@ private fun BottomSheetContent(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Composable
|
||||
private fun SearchSuggestionsSwitchPreference(
|
||||
label: String,
|
||||
description: String? = null,
|
||||
checked: Boolean,
|
||||
preventSwitchChange: Boolean,
|
||||
onClick: () -> Unit,
|
||||
enabled: Boolean,
|
||||
description: String? = null,
|
||||
) {
|
||||
PreferenceTemplate(
|
||||
modifier = Modifier.clickable {
|
||||
@@ -201,7 +205,7 @@ private fun SearchSuggestionsSwitchPreference(
|
||||
|
||||
@PreviewLawnchair
|
||||
@Composable
|
||||
fun SearchSuggestionsSwitchPreferencePreview() {
|
||||
private fun SearchSuggestionsSwitchPreferencePreview() {
|
||||
LawnchairTheme {
|
||||
SearchSuggestionsSwitchPreference(
|
||||
label = "example",
|
||||
|
||||
@@ -46,7 +46,7 @@ fun MainSwitchPreference(
|
||||
MainSwitchPreference(
|
||||
checked = checked,
|
||||
onCheckedChange = onCheckedChange,
|
||||
label = label,
|
||||
label = label,
|
||||
enabled = enabled,
|
||||
)
|
||||
|
||||
@@ -77,7 +77,7 @@ fun MainSwitchPreference(
|
||||
checked: Boolean,
|
||||
onCheckedChange: (Boolean) -> Unit,
|
||||
label: String,
|
||||
enabled: Boolean = true
|
||||
enabled: Boolean = true,
|
||||
) {
|
||||
Surface(
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
@@ -94,7 +94,7 @@ fun MainSwitchPreference(
|
||||
checked = checked,
|
||||
onCheckedChange = onCheckedChange,
|
||||
label = label,
|
||||
enabled = enabled
|
||||
enabled = enabled,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,16 +28,11 @@ import app.lawnchair.ui.preferences.components.NavigationActionPreference
|
||||
import app.lawnchair.ui.preferences.components.SuggestionsPreference
|
||||
import app.lawnchair.ui.preferences.components.controls.SliderPreference
|
||||
import app.lawnchair.ui.preferences.components.controls.SwitchPreference
|
||||
import app.lawnchair.ui.preferences.components.layout.DividerColumn
|
||||
import app.lawnchair.ui.preferences.components.layout.ExpandAndShrink
|
||||
import app.lawnchair.ui.preferences.components.layout.PreferenceGroup
|
||||
import app.lawnchair.ui.preferences.components.layout.PreferenceLayout
|
||||
import app.lawnchair.ui.preferences.preferenceGraph
|
||||
import app.lawnchair.ui.preferences.subRoute
|
||||
import app.lawnchair.util.checkAndRequestFilesPermission
|
||||
import app.lawnchair.util.contactPermissionGranted
|
||||
import app.lawnchair.util.filesAndStorageGranted
|
||||
import app.lawnchair.util.requestContactPermissionGranted
|
||||
import com.android.launcher3.R
|
||||
|
||||
object AppDrawerRoutes {
|
||||
|
||||
@@ -108,7 +108,7 @@ fun PreferencesDashboard() {
|
||||
label = stringResource(R.string.drawer_search_label),
|
||||
description = stringResource(R.string.drawer_search_description),
|
||||
iconResource = R.drawable.ic_search,
|
||||
route = Routes.SEARCH
|
||||
route = Routes.SEARCH,
|
||||
)
|
||||
|
||||
PreferenceCategory(
|
||||
|
||||
@@ -36,11 +36,9 @@ fun SearchPreferences() {
|
||||
val showDrawerSearchBar = !prefs2.hideAppDrawerSearchBar.getAdapter()
|
||||
val hiddenApps = prefs2.hiddenApps.getAdapter().state.value
|
||||
|
||||
|
||||
PreferenceLayout(label = stringResource(id = R.string.drawer_search_label)) {
|
||||
MainSwitchPreference(adapter = showDrawerSearchBar, label = stringResource(id = R.string.show_app_search_bar)) {
|
||||
|
||||
PreferenceGroup (heading = stringResource(R.string.general_label)){
|
||||
PreferenceGroup(heading = stringResource(R.string.general_label)) {
|
||||
ExpandAndShrink(visible = hiddenApps.isNotEmpty()) {
|
||||
HiddenAppsInSearchPreference()
|
||||
}
|
||||
@@ -56,7 +54,7 @@ fun SearchPreferences() {
|
||||
SearchSuggestionPreference(
|
||||
adapter = prefs.searchResultApps.getAdapter(),
|
||||
maxCountAdapter = prefs2.maxSearchResultCount.getAdapter(),
|
||||
maxCountRange = 3 .. 15,
|
||||
maxCountRange = 3..15,
|
||||
label = stringResource(R.string.search_pref_result_apps_and_shortcuts_title),
|
||||
maxCountLabel = stringResource(R.string.max_apps_result_count_title),
|
||||
preventSwitchChange = true,
|
||||
@@ -126,7 +124,7 @@ fun SearchPreferences() {
|
||||
SearchSuggestionPreference(
|
||||
adapter = prefs.searchResulRecentSuggestion.getAdapter(),
|
||||
maxCountAdapter = prefs2.maxRecentResultCount.getAdapter(),
|
||||
maxCountRange = 1..10,
|
||||
maxCountRange = 1..10,
|
||||
label = stringResource(id = R.string.search_pref_result_history_title),
|
||||
maxCountLabel = stringResource(id = R.string.max_recent_result_count_title),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user