mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-22 06:15:58 +00:00
Fix desktop profile selection and simplify default touch layouts
This commit is contained in:
1 parent
08526f8283
commit
c2d7765619
16 files changed
+265
-88
No files matched your search
@@ -3,6 +3,7 @@ package com.droiddeck.launcher.ui
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.foundation.Canvas
|
||||
@@ -26,14 +27,16 @@ internal fun InputElementProperties(element: InputSurfaceElement, onChange: (Inp
|
||||
val open = host.open == "element-icon"
|
||||
SettingsRow(stringResource(R.string.input_button_symbol), null, highlighted = open) {
|
||||
Box {
|
||||
ValueChip(if (element.image.isNotEmpty()) stringResource(R.string.input_imported_image) else if (element.icon == 0) stringResource(R.string.input_button_text) else pcKeyLabel(context, element.icon), open) { host.open = if (open) null else "element-icon" }
|
||||
ValueChip(if (element.image.isNotEmpty()) stringResource(R.string.input_imported_image) else if (element.icon == 0) stringResource(R.string.input_button_text) else InputButtonIcons.label(context, element.icon), open) { host.open = if (open) null else "element-icon" }
|
||||
AnchoredMenu(open, onDismiss = { host.open = null }, title = stringResource(R.string.input_button_symbol)) { firstItemFocus ->
|
||||
MenuItem(stringResource(R.string.input_button_text), element.icon == 0 && element.image.isEmpty(), focusRequester = firstItemFocus) { onChange(element.copy(icon = 0, image = "")); host.open = null }
|
||||
for (code in InputButtonIcons.codes) MenuItem(pcKeyLabel(context, code), element.icon == code && element.image.isEmpty(), leading = {
|
||||
for (code in InputButtonIcons.codes) MenuItem(InputButtonIcons.label(context, code), element.icon == code && element.image.isEmpty(), leading = {
|
||||
val color = MaterialTheme.colorScheme.onSurface
|
||||
val symbol = remember(context, code) { InputButtonIcons.drawable(context, code) }
|
||||
val paint = remember { android.graphics.Paint(android.graphics.Paint.ANTI_ALIAS_FLAG) }
|
||||
Canvas(Modifier.size(22.dp)) {
|
||||
val paint = android.graphics.Paint(android.graphics.Paint.ANTI_ALIAS_FLAG).apply { this.color = android.graphics.Color.argb((color.alpha * 255).toInt(), (color.red * 255).toInt(), (color.green * 255).toInt(), (color.blue * 255).toInt()) }
|
||||
InputButtonIcons.draw(drawContext.canvas.nativeCanvas, code, size.width / 2, size.height / 2, size.minDimension, paint)
|
||||
paint.color = android.graphics.Color.argb((color.alpha * 255).toInt(), (color.red * 255).toInt(), (color.green * 255).toInt(), (color.blue * 255).toInt())
|
||||
InputButtonIcons.draw(drawContext.canvas.nativeCanvas, code, size.width / 2, size.height / 2, size.minDimension, paint, symbol)
|
||||
}
|
||||
}) { onChange(element.copy(icon = code, image = "")); host.open = null }
|
||||
}
|
||||
|
||||
@@ -197,6 +197,7 @@ class InputSurfaceView(
|
||||
|
||||
private class HoldButton(context: Context, private val element: InputSurfaceElement, private val source: InputSurfaceSource?) : Surface(context) {
|
||||
private var down = false
|
||||
private val symbol = InputButtonIcons.drawable(context, element.icon)
|
||||
private val bitmap = element.image.takeIf { it.matches(Regex("[A-Za-z0-9_.-]{1,128}")) && it != "." && it != ".." }?.let { name ->
|
||||
val file = File(File(context.filesDir, "screenkeys"), name)
|
||||
val size = BitmapFactory.Options().apply { inJustDecodeBounds = true }
|
||||
@@ -221,7 +222,7 @@ class InputSurfaceView(
|
||||
canvas.drawBitmap(it, null, imageRect, labelPaint)
|
||||
return
|
||||
}
|
||||
if (element.icon != 0 && InputButtonIcons.draw(canvas, element.icon, cx, height / 2f, min(width, height) * .68f, labelPaint)) return
|
||||
if (element.icon != 0 && InputButtonIcons.draw(canvas, element.icon, cx, height / 2f, min(width, height) * .68f, labelPaint, symbol)) return
|
||||
if (!element.showLabel) return
|
||||
labelPaint.textSize = min(height * .3f, 30 * density)
|
||||
val labelWidth = labelPaint.measureText(element.name)
|
||||
|
||||
@@ -209,6 +209,7 @@ private class DrawerFocus {
|
||||
|
||||
class DrawerActions(
|
||||
val steam: Boolean,
|
||||
val desktop: Boolean,
|
||||
val direct: Boolean = false,
|
||||
val title: String? = null,
|
||||
val isHomeApp: Boolean,
|
||||
@@ -589,7 +590,7 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
}
|
||||
SessionDrawerPage.CONTROLLER -> {
|
||||
SettingsGroup(stringResource(R.string.drawer_page_controller)) {
|
||||
InputQuickSettings(host, desktop = !a.steam && !a.direct, onChanged = a.onInputSelection, onEdit = a.onInputSettings) { key -> focus.track(page, key) }
|
||||
InputQuickSettings(host, desktop = a.desktop, onChanged = a.onInputSelection, onEdit = a.onInputSettings) { key -> focus.track(page, key) }
|
||||
}
|
||||
SettingsGroup(stringResource(R.string.input_device_settings)) {
|
||||
a.padType?.let { type ->
|
||||
|
||||
Reference in new issue
Block a user