Update action editor

This commit is contained in:
Aleksandras Kostarevas 2024-07-21 00:12:39 +03:00
parent 9985f2a715
commit 5c11fa4e3f
4 changed files with 78 additions and 5 deletions

View File

@ -0,0 +1,42 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="m5,9 l-3,3 3,3"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#FFFFFF"/>
<path
android:pathData="m9,5 l3,-3 3,3"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#FFFFFF"/>
<path
android:pathData="m15,19 l-3,3 -3,-3"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#FFFFFF"/>
<path
android:pathData="m19,9 l3,3 -3,3"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#FFFFFF"/>
<path
android:pathData="M2,12h20"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#FFFFFF"/>
<path
android:pathData="M12,2v20"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#FFFFFF"/>
</vector>

View File

@ -15,6 +15,12 @@
<string name="mem_debug_action_title">Debug Info</string>
<string name="more_actions_action_title">More Actions</string>
<string name="action_kind_action_key">Action Key</string>
<string name="action_kind_pinned_key">Pinned Action(s)</string>
<string name="action_kind_favorites">Favorite Actions</string>
<string name="action_kind_more">More Actions</string>
<string name="action_kind_disabled">Hidden Actions</string>
<string name="amoled_dark_theme_name">AMOLED Dark Purple</string>
<string name="classic_material_dark_theme_name">AOSP Material Dark</string>
<string name="classic_material_light_theme_name">AOSP Material Light</string>

View File

@ -14,6 +14,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.GridItemSpan
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
@ -21,6 +22,7 @@ import androidx.compose.foundation.lazy.grid.items
import androidx.compose.foundation.lazy.grid.rememberLazyGridState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Surface
@ -38,6 +40,7 @@ import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
@ -54,15 +57,24 @@ import sh.calvin.reorderable.rememberReorderableLazyGridState
@Composable
fun ActionItem(action: Action, modifier: Modifier = Modifier) {
Surface(color = MaterialTheme.colorScheme.primaryContainer, modifier = modifier
fun ActionItem(action: Action, modifier: Modifier = Modifier, dragIcon: Boolean = false, dragIconModifier: Modifier = Modifier) {
Surface(color = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.5f), modifier = modifier
.fillMaxWidth()
.height(92.dp)
, shape = RoundedCornerShape(8.dp)) {
, shape = RoundedCornerShape(16.dp)) {
Box(modifier = Modifier
.fillMaxSize()
.padding(8.dp)) {
if(dragIcon) {
Icon(
painterResource(id = R.drawable.move),
contentDescription = null,
modifier = dragIconModifier.size(16.dp).align(Alignment.TopEnd),
tint = LocalContentColor.current.copy(alpha = 0.6f)
)
}
Column(modifier = Modifier
.align(Center)
.padding(8.dp)) {
@ -114,6 +126,8 @@ fun MoreActionsView() {
}
}
val CategoryTitleStyle = Typography.titleMedium.copy(fontWeight = FontWeight.W500)
@OptIn(ExperimentalFoundationApi::class)
@Composable
@ -171,7 +185,7 @@ fun ActionsEditor() {
onDragStopped = {
view.performHapticFeedback(HapticFeedbackConstants.GESTURE_END)
},
))
), dragIcon = true, dragIconModifier = Modifier.draggableHandle())
}
}
is ActionEditorItem.Separator -> {
@ -186,7 +200,7 @@ fun ActionsEditor() {
}
}
}
Text(it.category.name)
Text(it.category.name(context), modifier = Modifier.padding(top = 24.dp), style = CategoryTitleStyle, color = LocalContentColor.current.copy(alpha = 0.6f))
}
}
}

View File

@ -4,6 +4,7 @@ import android.content.Context
import androidx.core.content.edit
import androidx.datastore.preferences.core.stringPreferencesKey
import org.futo.inputmethod.keyboard.internal.KeyboardCodesSet
import org.futo.inputmethod.latin.R
import org.futo.inputmethod.latin.settings.Settings
import org.futo.inputmethod.latin.uix.Action
import org.futo.inputmethod.latin.uix.PreferenceUtils
@ -84,6 +85,16 @@ enum class ActionCategory {
Disabled
}
fun ActionCategory.name(context: Context): String {
return context.getString(when(this) {
ActionCategory.ActionKey -> R.string.action_kind_action_key
ActionCategory.PinnedKey -> R.string.action_kind_pinned_key
ActionCategory.Favorites -> R.string.action_kind_favorites
ActionCategory.More -> R.string.action_kind_more
ActionCategory.Disabled -> R.string.action_kind_disabled
})
}
fun ActionCategory.toSepName(): String {
return "_SEP_${name}"
}