phone: rewind/forward buttons in remote screen (DPAD left/right)
This commit is contained in:
@@ -15,6 +15,8 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.FastForward
|
||||
import androidx.compose.material.icons.filled.FastRewind
|
||||
import androidx.compose.material.icons.filled.Keyboard
|
||||
import androidx.compose.material.icons.filled.Pause
|
||||
import androidx.compose.material.icons.filled.PlayArrow
|
||||
@@ -45,6 +47,8 @@ import pw.binom.rayneovm.shared.VmDisplay
|
||||
|
||||
// android.view.KeyEvent-коды. Здесь обычные числа, чтобы не тянуть android-зависимости в UI-тесты.
|
||||
private const val KEYCODE_BACK = 4
|
||||
private const val KEYCODE_DPAD_LEFT = 21
|
||||
private const val KEYCODE_DPAD_RIGHT = 22
|
||||
private const val KEYCODE_MEDIA_PLAY = 126
|
||||
private const val KEYCODE_MEDIA_PAUSE = 127
|
||||
|
||||
@@ -56,7 +60,7 @@ private const val CLICK_GRACE_MS = 100L
|
||||
* - тачпад-мышь: движение одного пальца → курсор (отыгрывается на очках в обоих глазах),
|
||||
* тап по тачпаду → клик в текущей позиции курсора;
|
||||
* - два пальца по тачпаду → скролл (вверх/вниз/вправо/влево) под курсором;
|
||||
* - кнопки «Назад», «Плей», «Пауза»;
|
||||
* - кнопки «Перемотка», «Плей», «Вперёд», «Назад», «Пауза»;
|
||||
* - «Клавиатура» — заглушка (сделаем позже).
|
||||
*/
|
||||
@Composable
|
||||
@@ -170,12 +174,24 @@ fun RemoteScreen(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
RemoteButton(Icons.AutoMirrored.Filled.ArrowBack, "Назад", Modifier.weight(1f)) {
|
||||
scope.launch { controller.sendKey(KEYCODE_BACK) }
|
||||
RemoteButton(Icons.Default.FastRewind, "Перемотка", Modifier.weight(1f)) {
|
||||
scope.launch { controller.sendKey(KEYCODE_DPAD_LEFT) }
|
||||
}
|
||||
RemoteButton(Icons.Default.PlayArrow, "Плей", Modifier.weight(1f)) {
|
||||
scope.launch { controller.sendKey(KEYCODE_MEDIA_PLAY) }
|
||||
}
|
||||
RemoteButton(Icons.Default.FastForward, "Вперёд", Modifier.weight(1f)) {
|
||||
scope.launch { controller.sendKey(KEYCODE_DPAD_RIGHT) }
|
||||
}
|
||||
}
|
||||
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
RemoteButton(Icons.AutoMirrored.Filled.ArrowBack, "Назад", Modifier.weight(1f)) {
|
||||
scope.launch { controller.sendKey(KEYCODE_BACK) }
|
||||
}
|
||||
RemoteButton(Icons.Default.Pause, "Пауза", Modifier.weight(1f)) {
|
||||
scope.launch { controller.sendKey(KEYCODE_MEDIA_PAUSE) }
|
||||
}
|
||||
@@ -197,7 +213,7 @@ private fun RemoteButton(
|
||||
onClick = onClick,
|
||||
enabled = enabled,
|
||||
modifier = modifier,
|
||||
contentPadding = PaddingValues(vertical = 12.dp),
|
||||
contentPadding = PaddingValues(horizontal = 4.dp, vertical = 12.dp),
|
||||
) {
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
Icon(icon, contentDescription = label)
|
||||
|
||||
Reference in New Issue
Block a user