mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 15:26:58 +00:00
Minor prefs UX improvements
This commit does the following: * Remove spacer when announcement is inactive * Improve drag/drop animation for recents quick action preferences * Improve permission request UI for SearchSuggestionPreference * Shorten wording of maximum entry count (fix #4547, fix #4548)
This commit is contained in:
@@ -690,21 +690,21 @@
|
||||
<string name="search_pref_result_web_provider_description">Via <xliff:g id="web_search_provider">%1$s</xliff:g></string>
|
||||
|
||||
<!-- Maximum xyz for each search result type -->
|
||||
<string name="max_apps_result_count_title">Maximum number of apps in search results</string>
|
||||
<string name="max_people_result_count_title">Maximum number of people in search results</string>
|
||||
<string name="max_file_result_count_title">Maximum number of files in search results</string>
|
||||
<string name="max_settings_entry_result_count_title">Maximum number of settings entries in search results</string>
|
||||
<string name="max_recent_result_count_title">Maximum number of history entries in search results</string>
|
||||
<string name="max_suggestion_result_count_title">Maximum number of suggestions in search results</string>
|
||||
<string name="max_apps_result_count_title">Maximum number of apps</string>
|
||||
<string name="max_people_result_count_title">Maximum number of people</string>
|
||||
<string name="max_file_result_count_title">Maximum number of files</string>
|
||||
<string name="max_settings_entry_result_count_title">Maximum number of settings</string>
|
||||
<string name="max_recent_result_count_title">Maximum items for search history</string>
|
||||
<string name="max_suggestion_result_count_title">Maximum number of suggestions</string>
|
||||
<string name="max_web_suggestion_delay">Maximum web suggestion delay</string>
|
||||
|
||||
<!-- Permission warnings -->
|
||||
<string name="warn_contact_permission_content">To search for contacts, grant contacts and phone permissions to Lawnchair</string>
|
||||
<string name="warn_files_permission_content">To search your files, grant storage permissions to Lawnchair</string>
|
||||
<string name="grant_requested_permissions">Grant permissions</string>
|
||||
<string name="hotseat_mode_lawnchair_compose">Lawnchair (compose)</string>
|
||||
|
||||
<string name="allapps_web_suggestion_provider_label">Web suggestion provider</string>
|
||||
<string name="allapps_use_web_suggestion_icon_label">Show web suggestion provider icon in search bar</string>
|
||||
<string name="allapps_match_qsb_style_label">Match dock search bar style</string>
|
||||
<string name="allapps_match_qsb_style_label">Match dock search bar actions</string>
|
||||
<string name="allapps_match_qsb_style_description">Clicking the dock search bar will now open the app drawer search UI</string>
|
||||
</resources>
|
||||
|
||||
@@ -72,7 +72,7 @@ fun AnnouncementPreference(
|
||||
announcements.forEachIndexed { index, announcement ->
|
||||
var show by rememberSaveable { mutableStateOf(true) }
|
||||
AnnouncementItem(show, announcement) { show = false }
|
||||
if (index != announcements.lastIndex && show && (!announcement.test || BuildConfig.DEBUG)) {
|
||||
if (index != announcements.lastIndex && show && announcement.active && (!announcement.test || BuildConfig.DEBUG)) {
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package app.lawnchair.ui.preferences.components
|
||||
|
||||
import android.view.HapticFeedbackConstants
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.core.animateDpAsState
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@@ -22,10 +23,11 @@ import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.ripple
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.key
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
@@ -82,8 +84,12 @@ fun QuickActionsPreferences(
|
||||
) {
|
||||
var orderedItems = sortListByIdOrder(items, order)
|
||||
|
||||
val isAnyDragging = remember { mutableStateOf(false) }
|
||||
val lastItemIdIndex = remember { mutableIntStateOf(4) }
|
||||
var isAnyDragging by remember { mutableStateOf(false) }
|
||||
|
||||
val elevation by animateDpAsState(
|
||||
targetValue = if (!isAnyDragging) 1.dp else 0.dp,
|
||||
label = "card background animation",
|
||||
)
|
||||
|
||||
val view = LocalView.current
|
||||
|
||||
@@ -94,7 +100,7 @@ fun QuickActionsPreferences(
|
||||
Surface(
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
shape = MaterialTheme.shapes.large,
|
||||
tonalElevation = if (!isAnyDragging.value) 1.dp else 0.dp,
|
||||
tonalElevation = elevation,
|
||||
) {
|
||||
ReorderableColumn(
|
||||
modifier = Modifier,
|
||||
@@ -102,16 +108,15 @@ fun QuickActionsPreferences(
|
||||
onSettle = { fromIndex, toIndex ->
|
||||
orderedItems = orderedItems.toMutableList().apply {
|
||||
add(toIndex, removeAt(fromIndex))
|
||||
}.toList().also { items ->
|
||||
}.toList().also { newItems ->
|
||||
onOrderChange(
|
||||
items.map { it.id }.joinToString(separator = ","),
|
||||
newItems.map { it.id }.joinToString(separator = ","),
|
||||
)
|
||||
isAnyDragging.value = false
|
||||
lastItemIdIndex.intValue = items.last().id
|
||||
isAnyDragging = false
|
||||
}
|
||||
},
|
||||
onMove = {
|
||||
isAnyDragging.value = true
|
||||
isAnyDragging = true
|
||||
if (Utilities.ATLEAST_U) {
|
||||
view.performHapticFeedback(HapticFeedbackConstants.SEGMENT_FREQUENT_TICK)
|
||||
}
|
||||
@@ -185,13 +190,14 @@ fun QuickActionsPreferences(
|
||||
DragHandle(
|
||||
interactionSource = interactionSource,
|
||||
scope = scope,
|
||||
onDragStop = {
|
||||
isAnyDragging = false
|
||||
},
|
||||
)
|
||||
},
|
||||
)
|
||||
AnimatedVisibility(visible = !isAnyDragging.value) {
|
||||
if (index != lastItemIdIndex.intValue) {
|
||||
HorizontalDivider()
|
||||
}
|
||||
AnimatedVisibility(!isAnyDragging && index != orderedItems.lastIndex) {
|
||||
HorizontalDivider()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -256,6 +262,7 @@ fun DraggableSwitchPreference(
|
||||
private fun DragHandle(
|
||||
scope: ReorderableScope,
|
||||
interactionSource: MutableInteractionSource,
|
||||
onDragStop: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val view = LocalView.current
|
||||
@@ -271,6 +278,7 @@ private fun DragHandle(
|
||||
if (Utilities.ATLEAST_R) {
|
||||
view.performHapticFeedback(HapticFeedbackConstants.GESTURE_END)
|
||||
}
|
||||
onDragStop()
|
||||
},
|
||||
)
|
||||
},
|
||||
|
||||
@@ -3,6 +3,7 @@ package app.lawnchair.ui.preferences.components
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
@@ -84,14 +85,14 @@ fun SearchSuggestionPreference(
|
||||
content: @Composable (() -> Unit)? = null,
|
||||
) {
|
||||
val bottomSheetHandler = bottomSheetHandler
|
||||
val preventSwitchChange = false
|
||||
|
||||
SearchSuggestionsSwitchPreference(
|
||||
label = label,
|
||||
description = description,
|
||||
checked = adapter.state.value,
|
||||
onCheckedChange = adapter::onChange,
|
||||
enabled = isGranted,
|
||||
preventSwitchChange = preventSwitchChange,
|
||||
preventSwitchChange = !isGranted,
|
||||
onClick = {
|
||||
bottomSheetHandler.show {
|
||||
BottomSheetContent(
|
||||
@@ -100,14 +101,13 @@ fun SearchSuggestionPreference(
|
||||
adapterValue = adapter.state.value,
|
||||
adapterOnChange = adapter::onChange,
|
||||
label = label,
|
||||
description = description,
|
||||
maxCountLabel = maxCountLabel,
|
||||
maxCountAdapter = maxCountAdapter,
|
||||
maxCountRange = maxCountRange,
|
||||
content = content,
|
||||
onRequestPermission = onRequestPermission,
|
||||
permissionRationale = permissionRationale,
|
||||
preventSwitchChange = preventSwitchChange,
|
||||
preventSwitchChange = !isGranted,
|
||||
)
|
||||
}
|
||||
},
|
||||
@@ -119,16 +119,14 @@ private fun BottomSheetContent(
|
||||
adapterValue: Boolean,
|
||||
adapterOnChange: (Boolean) -> Unit,
|
||||
label: String,
|
||||
description: String?,
|
||||
maxCountLabel: String,
|
||||
maxCountAdapter: PreferenceAdapter<Int>,
|
||||
maxCountRange: ClosedRange<Int>,
|
||||
isPermissionGranted: Boolean,
|
||||
onHide: () -> Unit,
|
||||
onRequestPermission: (() -> Unit)?,
|
||||
// TODO optimize permission requesting code
|
||||
permissionRationale: String?,
|
||||
preventSwitchChange: Boolean = false,
|
||||
preventSwitchChange: Boolean,
|
||||
content: @Composable (() -> Unit)?,
|
||||
) {
|
||||
ModalBottomSheetContent(
|
||||
@@ -147,7 +145,6 @@ private fun BottomSheetContent(
|
||||
}
|
||||
},
|
||||
label = label,
|
||||
description = description,
|
||||
enabled = if (preventSwitchChange) false else isPermissionGranted,
|
||||
) {
|
||||
Column(modifier = Modifier.padding(horizontal = 16.dp)) {
|
||||
@@ -174,13 +171,17 @@ private fun BottomSheetContent(
|
||||
Text(
|
||||
text = permissionRationale,
|
||||
)
|
||||
Button(
|
||||
onClick = {
|
||||
onHide()
|
||||
onRequestPermission()
|
||||
},
|
||||
) {
|
||||
Text(text = stringResource(id = R.string.grant_requested_permissions))
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Row {
|
||||
Spacer(Modifier.weight(1f))
|
||||
Button(
|
||||
onClick = {
|
||||
onHide()
|
||||
onRequestPermission()
|
||||
},
|
||||
) {
|
||||
Text(text = stringResource(id = R.string.grant_requested_permissions))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -194,6 +195,7 @@ private fun BottomSheetContent(
|
||||
private fun SearchSuggestionsSwitchPreference(
|
||||
label: String,
|
||||
checked: Boolean,
|
||||
onCheckedChange: (Boolean) -> Unit,
|
||||
preventSwitchChange: Boolean,
|
||||
onClick: () -> Unit,
|
||||
enabled: Boolean,
|
||||
@@ -222,7 +224,7 @@ private fun SearchSuggestionsSwitchPreference(
|
||||
.padding(all = 16.dp)
|
||||
.height(24.dp),
|
||||
checked = checked,
|
||||
onCheckedChange = { onClick() },
|
||||
onCheckedChange = { onCheckedChange(it) },
|
||||
enabled = if (preventSwitchChange) false else enabled,
|
||||
)
|
||||
},
|
||||
@@ -238,6 +240,7 @@ private fun SearchSuggestionsSwitchPreferencePreview() {
|
||||
label = "example",
|
||||
checked = true,
|
||||
onClick = { /*TODO*/ },
|
||||
onCheckedChange = {},
|
||||
preventSwitchChange = false,
|
||||
enabled = true,
|
||||
)
|
||||
|
||||
@@ -69,6 +69,7 @@ fun SearchPreferences() {
|
||||
)
|
||||
SwitchPreference(
|
||||
label = stringResource(R.string.allapps_match_qsb_style_label),
|
||||
description = stringResource(R.string.allapps_match_qsb_style_description),
|
||||
adapter = prefs2.matchHotseatQsbStyle.getAdapter(),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user