feat: haptic for terminal extra buttons
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
## 0.2.3
|
## 0.2.3
|
||||||
|
|
||||||
- 改进: 莫奈颜色更多配置项
|
- 改进: 莫奈颜色更多配置项
|
||||||
|
- 改进: 终端按钮触感反馈
|
||||||
|
|
||||||
## 0.2.2
|
## 0.2.2
|
||||||
|
|
||||||
|
|||||||
@@ -844,7 +844,7 @@ fun SettingsPage(
|
|||||||
value = asBundle.terminalFontDisplayName,
|
value = asBundle.terminalFontDisplayName,
|
||||||
onValueChange = {},
|
onValueChange = {},
|
||||||
readOnly = true,
|
readOnly = true,
|
||||||
label = "系统等宽字体",
|
label = "内置等宽字体",
|
||||||
useLabelAsPlaceholder = true,
|
useLabelAsPlaceholder = true,
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
trailingIcon = {
|
trailingIcon = {
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import androidx.compose.ui.graphics.luminance
|
|||||||
import androidx.compose.ui.graphics.toArgb
|
import androidx.compose.ui.graphics.toArgb
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalDensity
|
import androidx.compose.ui.platform.LocalDensity
|
||||||
|
import androidx.compose.ui.platform.LocalHapticFeedback
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
@@ -56,6 +57,7 @@ import io.github.miuzarte.scrcpyforandroid.services.LocalSnackbarController
|
|||||||
import io.github.miuzarte.scrcpyforandroid.storage.Storage.appSettings
|
import io.github.miuzarte.scrcpyforandroid.storage.Storage.appSettings
|
||||||
import io.github.miuzarte.scrcpyforandroid.ui.BlurredBar
|
import io.github.miuzarte.scrcpyforandroid.ui.BlurredBar
|
||||||
import io.github.miuzarte.scrcpyforandroid.ui.LocalEnableBlur
|
import io.github.miuzarte.scrcpyforandroid.ui.LocalEnableBlur
|
||||||
|
import io.github.miuzarte.scrcpyforandroid.ui.contextClick
|
||||||
import io.github.miuzarte.scrcpyforandroid.ui.rememberBlurBackdrop
|
import io.github.miuzarte.scrcpyforandroid.ui.rememberBlurBackdrop
|
||||||
import io.github.miuzarte.scrcpyforandroid.widgets.PopupMenuItem
|
import io.github.miuzarte.scrcpyforandroid.widgets.PopupMenuItem
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
@@ -208,6 +210,7 @@ private fun TerminalPage(
|
|||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val density = LocalDensity.current
|
val density = LocalDensity.current
|
||||||
val snackbar = LocalSnackbarController.current
|
val snackbar = LocalSnackbarController.current
|
||||||
|
val haptic = LocalHapticFeedback.current
|
||||||
val asBundleShared by appSettings.bundleState.collectAsState()
|
val asBundleShared by appSettings.bundleState.collectAsState()
|
||||||
val uiScope = rememberCoroutineScope()
|
val uiScope = rememberCoroutineScope()
|
||||||
val taskScope = remember { CoroutineScope(SupervisorJob() + Dispatchers.IO) }
|
val taskScope = remember { CoroutineScope(SupervisorJob() + Dispatchers.IO) }
|
||||||
@@ -348,7 +351,8 @@ private fun TerminalPage(
|
|||||||
view: TerminalView,
|
view: TerminalView,
|
||||||
event: MotionEvent,
|
event: MotionEvent,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val shouldLock = event.pointerCount > 1 || event.actionMasked == MotionEvent.ACTION_POINTER_DOWN
|
val shouldLock =
|
||||||
|
event.pointerCount > 1 || event.actionMasked == MotionEvent.ACTION_POINTER_DOWN
|
||||||
if (shouldLock) {
|
if (shouldLock) {
|
||||||
view.parent?.requestDisallowInterceptTouchEvent(true)
|
view.parent?.requestDisallowInterceptTouchEvent(true)
|
||||||
if (!pinchGestureLock) {
|
if (!pinchGestureLock) {
|
||||||
@@ -714,31 +718,52 @@ private fun TerminalPage(
|
|||||||
TerminalExtraKeyButton(
|
TerminalExtraKeyButton(
|
||||||
label = "ESC",
|
label = "ESC",
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
) { writeLiteralKey("\u001B") }
|
) {
|
||||||
|
haptic.contextClick()
|
||||||
|
writeLiteralKey("\u001B")
|
||||||
|
}
|
||||||
TerminalExtraKeyButton(
|
TerminalExtraKeyButton(
|
||||||
label = "/",
|
label = "/",
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
) { writeLiteralKey("/") }
|
) {
|
||||||
|
haptic.contextClick()
|
||||||
|
writeLiteralKey("/")
|
||||||
|
}
|
||||||
TerminalExtraKeyButton(
|
TerminalExtraKeyButton(
|
||||||
label = "-",
|
label = "-",
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
) { writeLiteralKey("-") }
|
) {
|
||||||
|
haptic.contextClick()
|
||||||
|
writeLiteralKey("-")
|
||||||
|
}
|
||||||
TerminalExtraKeyButton(
|
TerminalExtraKeyButton(
|
||||||
label = "HOME",
|
label = "HOME",
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
) { writeSpecialKey(KeyEvent.KEYCODE_MOVE_HOME) }
|
) {
|
||||||
|
haptic.contextClick()
|
||||||
|
writeSpecialKey(KeyEvent.KEYCODE_MOVE_HOME)
|
||||||
|
}
|
||||||
TerminalExtraKeyButton(
|
TerminalExtraKeyButton(
|
||||||
label = "↑",
|
label = "↑",
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
) { writeSpecialKey(KeyEvent.KEYCODE_DPAD_UP) }
|
) {
|
||||||
|
haptic.contextClick()
|
||||||
|
writeSpecialKey(KeyEvent.KEYCODE_DPAD_UP)
|
||||||
|
}
|
||||||
TerminalExtraKeyButton(
|
TerminalExtraKeyButton(
|
||||||
label = "END",
|
label = "END",
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
) { writeSpecialKey(KeyEvent.KEYCODE_MOVE_END) }
|
) {
|
||||||
|
haptic.contextClick()
|
||||||
|
writeSpecialKey(KeyEvent.KEYCODE_MOVE_END)
|
||||||
|
}
|
||||||
TerminalExtraKeyButton(
|
TerminalExtraKeyButton(
|
||||||
label = "PGUP",
|
label = "PGUP",
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
) { writeSpecialKey(KeyEvent.KEYCODE_PAGE_UP) }
|
) {
|
||||||
|
haptic.contextClick()
|
||||||
|
writeSpecialKey(KeyEvent.KEYCODE_PAGE_UP)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
@@ -747,33 +772,54 @@ private fun TerminalPage(
|
|||||||
TerminalExtraKeyButton(
|
TerminalExtraKeyButton(
|
||||||
label = "TAB",
|
label = "TAB",
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
) { writeSpecialKey(KeyEvent.KEYCODE_TAB) }
|
) {
|
||||||
|
haptic.contextClick()
|
||||||
|
writeSpecialKey(KeyEvent.KEYCODE_TAB)
|
||||||
|
}
|
||||||
TerminalExtraKeyButton(
|
TerminalExtraKeyButton(
|
||||||
label = "CTRL",
|
label = "CTRL",
|
||||||
active = ctrlLatched,
|
active = ctrlLatched,
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
) { ctrlLatched = !ctrlLatched }
|
) {
|
||||||
|
haptic.contextClick()
|
||||||
|
ctrlLatched = !ctrlLatched
|
||||||
|
}
|
||||||
TerminalExtraKeyButton(
|
TerminalExtraKeyButton(
|
||||||
label = "ALT",
|
label = "ALT",
|
||||||
active = altLatched,
|
active = altLatched,
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
) { altLatched = !altLatched }
|
) {
|
||||||
|
haptic.contextClick()
|
||||||
|
altLatched = !altLatched
|
||||||
|
}
|
||||||
TerminalExtraKeyButton(
|
TerminalExtraKeyButton(
|
||||||
label = "←",
|
label = "←",
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
) { writeSpecialKey(KeyEvent.KEYCODE_DPAD_LEFT) }
|
) {
|
||||||
|
haptic.contextClick()
|
||||||
|
writeSpecialKey(KeyEvent.KEYCODE_DPAD_LEFT)
|
||||||
|
}
|
||||||
TerminalExtraKeyButton(
|
TerminalExtraKeyButton(
|
||||||
label = "↓",
|
label = "↓",
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
) { writeSpecialKey(KeyEvent.KEYCODE_DPAD_DOWN) }
|
) {
|
||||||
|
haptic.contextClick()
|
||||||
|
writeSpecialKey(KeyEvent.KEYCODE_DPAD_DOWN)
|
||||||
|
}
|
||||||
TerminalExtraKeyButton(
|
TerminalExtraKeyButton(
|
||||||
label = "→",
|
label = "→",
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
) { writeSpecialKey(KeyEvent.KEYCODE_DPAD_RIGHT) }
|
) {
|
||||||
|
haptic.contextClick()
|
||||||
|
writeSpecialKey(KeyEvent.KEYCODE_DPAD_RIGHT)
|
||||||
|
}
|
||||||
TerminalExtraKeyButton(
|
TerminalExtraKeyButton(
|
||||||
label = "PGDN",
|
label = "PGDN",
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
) { writeSpecialKey(KeyEvent.KEYCODE_PAGE_DOWN) }
|
) {
|
||||||
|
haptic.contextClick()
|
||||||
|
writeSpecialKey(KeyEvent.KEYCODE_PAGE_DOWN)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user