Add hints for dragn and drop arrangable preferences
This commit is contained in:
parent
8de1732e1b
commit
f008d9366c
@ -2,9 +2,13 @@ package de.mm20.launcher2.ui.settings.filterbar
|
|||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.compose.animation.core.animateDpAsState
|
import androidx.compose.animation.core.animateDpAsState
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.automirrored.rounded.ArrowBack
|
||||||
|
import androidx.compose.material.icons.outlined.Info
|
||||||
import androidx.compose.material.icons.rounded.ArrowBack
|
import androidx.compose.material.icons.rounded.ArrowBack
|
||||||
import androidx.compose.material3.CenterAlignedTopAppBar
|
import androidx.compose.material3.CenterAlignedTopAppBar
|
||||||
import androidx.compose.material3.HorizontalDivider
|
import androidx.compose.material3.HorizontalDivider
|
||||||
@ -19,6 +23,7 @@ import androidx.compose.runtime.collectAsState
|
|||||||
import androidx.compose.runtime.derivedStateOf
|
import androidx.compose.runtime.derivedStateOf
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
@ -86,7 +91,7 @@ fun FilterBarSettingsScreen() {
|
|||||||
activity?.onBackPressed()
|
activity?.onBackPressed()
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
Icon(imageVector = Icons.Rounded.ArrowBack, contentDescription = "Back")
|
Icon(imageVector = Icons.AutoMirrored.Rounded.ArrowBack, contentDescription = "Back")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -103,6 +108,26 @@ fun FilterBarSettingsScreen() {
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
) {
|
) {
|
||||||
|
item(
|
||||||
|
key = "disabled-info"
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(start = 28.dp, top = 16.dp, end = 16.dp, bottom = 16.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
) {
|
||||||
|
Icon(Icons.Outlined.Info, null,
|
||||||
|
modifier = Modifier.padding(end = 24.dp).size(16.dp),
|
||||||
|
tint = MaterialTheme.colorScheme.secondary
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
modifier = Modifier,
|
||||||
|
text = stringResource(R.string.hint_drag_and_drop_reorder),
|
||||||
|
style = MaterialTheme.typography.titleSmall,
|
||||||
|
color = MaterialTheme.colorScheme.secondary
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
for (i in 0 until KeyboardFilterBarItem.entries.size) {
|
for (i in 0 until KeyboardFilterBarItem.entries.size) {
|
||||||
val item = enabledItems!!.getOrNull(i) ?: disabledItems[i - enabledItems!!.size]
|
val item = enabledItems!!.getOrNull(i) ?: disabledItems[i - enabledItems!!.size]
|
||||||
val prevItem = enabledItems!!.getOrNull(i - 1) ?: disabledItems.getOrNull(i - enabledItems!!.size - 1)
|
val prevItem = enabledItems!!.getOrNull(i - 1) ?: disabledItems.getOrNull(i - enabledItems!!.size - 1)
|
||||||
|
|||||||
@ -7,16 +7,24 @@ import androidx.browser.customtabs.CustomTabsIntent
|
|||||||
import androidx.compose.animation.core.animateDpAsState
|
import androidx.compose.animation.core.animateDpAsState
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.outlined.Info
|
||||||
import androidx.compose.material.icons.rounded.Add
|
import androidx.compose.material.icons.rounded.Add
|
||||||
import androidx.compose.material.icons.rounded.ArrowBack
|
import androidx.compose.material.icons.rounded.ArrowBack
|
||||||
|
import androidx.compose.material.icons.rounded.Delete
|
||||||
|
import androidx.compose.material.icons.rounded.Edit
|
||||||
import androidx.compose.material.icons.rounded.HelpOutline
|
import androidx.compose.material.icons.rounded.HelpOutline
|
||||||
|
import androidx.compose.material.icons.rounded.MoreVert
|
||||||
import androidx.compose.material3.CenterAlignedTopAppBar
|
import androidx.compose.material3.CenterAlignedTopAppBar
|
||||||
|
import androidx.compose.material3.DropdownMenu
|
||||||
|
import androidx.compose.material3.DropdownMenuItem
|
||||||
import androidx.compose.material3.FloatingActionButton
|
import androidx.compose.material3.FloatingActionButton
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
@ -27,6 +35,10 @@ import androidx.compose.material3.Text
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.toArgb
|
import androidx.compose.ui.graphics.toArgb
|
||||||
@ -66,7 +78,7 @@ fun SearchActionsSettingsScreen() {
|
|||||||
onDragStart = {
|
onDragStart = {
|
||||||
it.key != "divider" && !(it.key as String).startsWith("disabled-")
|
it.key != "divider" && !(it.key as String).startsWith("disabled-")
|
||||||
},
|
},
|
||||||
onItemMove = { from, to -> viewModel.moveItem(from.index, to.index) }
|
onItemMove = { from, to -> viewModel.moveItem(from.index - 1, to.index - 1) }
|
||||||
)
|
)
|
||||||
|
|
||||||
val searchActions by viewModel.searchActions.collectAsState()
|
val searchActions by viewModel.searchActions.collectAsState()
|
||||||
@ -102,11 +114,14 @@ fun SearchActionsSettingsScreen() {
|
|||||||
CustomTabsIntent.Builder()
|
CustomTabsIntent.Builder()
|
||||||
.setDefaultColorSchemeParams(
|
.setDefaultColorSchemeParams(
|
||||||
CustomTabColorSchemeParams.Builder()
|
CustomTabColorSchemeParams.Builder()
|
||||||
.setToolbarColor(colorScheme.primaryContainer.toArgb())
|
.setToolbarColor(colorScheme.primaryContainer.toArgb())
|
||||||
.setSecondaryToolbarColor(colorScheme.secondaryContainer.toArgb())
|
.setSecondaryToolbarColor(colorScheme.secondaryContainer.toArgb())
|
||||||
.build()
|
.build()
|
||||||
|
)
|
||||||
|
.build().launchUrl(
|
||||||
|
context,
|
||||||
|
Uri.parse("https://kvaesitso.mm20.de/docs/user-guide/search/quickactions")
|
||||||
)
|
)
|
||||||
.build().launchUrl(context, Uri.parse("https://kvaesitso.mm20.de/docs/user-guide/search/quickactions"))
|
|
||||||
}) {
|
}) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Rounded.HelpOutline,
|
imageVector = Icons.Rounded.HelpOutline,
|
||||||
@ -124,6 +139,26 @@ fun SearchActionsSettingsScreen() {
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
) {
|
) {
|
||||||
|
item(
|
||||||
|
key = "disabled-info"
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(start = 28.dp, top = 16.dp, end = 16.dp, bottom = 16.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
) {
|
||||||
|
Icon(Icons.Outlined.Info, null,
|
||||||
|
modifier = Modifier.padding(end = 24.dp).size(16.dp),
|
||||||
|
tint = MaterialTheme.colorScheme.secondary
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
modifier = Modifier,
|
||||||
|
text = stringResource(R.string.hint_drag_and_drop_reorder),
|
||||||
|
style = MaterialTheme.typography.titleSmall,
|
||||||
|
color = MaterialTheme.colorScheme.secondary
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
items(
|
items(
|
||||||
items = searchActions,
|
items = searchActions,
|
||||||
key = { it.key }
|
key = { it.key }
|
||||||
@ -146,6 +181,51 @@ fun SearchActionsSettingsScreen() {
|
|||||||
title = item.label,
|
title = item.label,
|
||||||
onClick = {
|
onClick = {
|
||||||
viewModel.editAction(item)
|
viewModel.editAction(item)
|
||||||
|
},
|
||||||
|
controls = {
|
||||||
|
var showDropdown by remember { mutableStateOf(false) }
|
||||||
|
IconButton(
|
||||||
|
onClick = {
|
||||||
|
showDropdown = true
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
Icon(Icons.Rounded.MoreVert, stringResource(R.string.edit))
|
||||||
|
DropdownMenu(
|
||||||
|
expanded = showDropdown,
|
||||||
|
onDismissRequest = { showDropdown = false }
|
||||||
|
) {
|
||||||
|
DropdownMenuItem(
|
||||||
|
leadingIcon = {
|
||||||
|
Icon(
|
||||||
|
Icons.Rounded.Edit,
|
||||||
|
contentDescription = null
|
||||||
|
)
|
||||||
|
},
|
||||||
|
text = {
|
||||||
|
Text(stringResource(R.string.edit))
|
||||||
|
},
|
||||||
|
onClick = {
|
||||||
|
viewModel.editAction(item)
|
||||||
|
showDropdown = false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
DropdownMenuItem(
|
||||||
|
leadingIcon = {
|
||||||
|
Icon(
|
||||||
|
Icons.Rounded.Delete,
|
||||||
|
contentDescription = null
|
||||||
|
)
|
||||||
|
},
|
||||||
|
text = {
|
||||||
|
Text(stringResource(R.string.menu_delete))
|
||||||
|
},
|
||||||
|
onClick = {
|
||||||
|
viewModel.removeAction(item)
|
||||||
|
showDropdown = false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -54,8 +54,8 @@ class SearchActionsSettingsScreenVM : ViewModel(), KoinComponent {
|
|||||||
|
|
||||||
fun moveItem(fromIndex: Int, toIndex: Int) {
|
fun moveItem(fromIndex: Int, toIndex: Int) {
|
||||||
val actions = searchActions.value?.toMutableList() ?: return
|
val actions = searchActions.value?.toMutableList() ?: return
|
||||||
if (fromIndex > actions.lastIndex) return
|
if (fromIndex > actions.lastIndex || fromIndex < 0) return
|
||||||
if (toIndex > actions.lastIndex) return
|
if (toIndex > actions.lastIndex || toIndex < 0) return
|
||||||
val item = actions.removeAt(fromIndex)
|
val item = actions.removeAt(fromIndex)
|
||||||
actions.add(toIndex, item)
|
actions.add(toIndex, item)
|
||||||
searchActionService.saveSearchActionBuilders(actions)
|
searchActionService.saveSearchActionBuilders(actions)
|
||||||
|
|||||||
@ -991,4 +991,5 @@
|
|||||||
<string name="profile_private_profile_state_locked">Private space is locked.</string>
|
<string name="profile_private_profile_state_locked">Private space is locked.</string>
|
||||||
<string name="profile_private_profile_action_unlock">Unlock</string>
|
<string name="profile_private_profile_action_unlock">Unlock</string>
|
||||||
<string name="profile_private_profile_action_lock">Lock private space</string>
|
<string name="profile_private_profile_action_lock">Lock private space</string>
|
||||||
|
<string name="hint_drag_and_drop_reorder">Hold and drag items to rearrange them</string>
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
x
Reference in New Issue
Block a user