mirror of
https://github.com/twinksoftware/Gearslip.git
synced 2026-11-11 00:12:24 +01:00
car preview: type with the phone's keyboard instead of drawing the car's
This commit is contained in:
1 parent
068288a0e7
commit
a26605c0ab
3 files changed
+17
-6
No files matched your search
@@ -44,6 +44,12 @@ object CarKeyboardVisibility {
|
|||||||
val state = mutableStateOf(false)
|
val state = mutableStateOf(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True for the car UI the phone's own car preview draws. The phone is in hand there, so a
|
||||||
|
* [CarKeyboard] draws nothing and the phone's keyboard does the typing instead (see [PhoneTyping]).
|
||||||
|
*/
|
||||||
|
val LocalCarPreview = compositionLocalOf { false }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A keyboard the host draws itself.
|
* A keyboard the host draws itself.
|
||||||
*
|
*
|
||||||
@@ -73,10 +79,11 @@ fun CarKeyboard(
|
|||||||
) {
|
) {
|
||||||
var symbols by remember { mutableStateOf(false) }
|
var symbols by remember { mutableStateOf(false) }
|
||||||
var shifted by remember { mutableStateOf(false) }
|
var shifted by remember { mutableStateOf(false) }
|
||||||
|
val preview = LocalCarPreview.current
|
||||||
|
|
||||||
DisposableEffect(Unit) {
|
DisposableEffect(preview) {
|
||||||
CarKeyboardVisibility.state.value = true
|
if (!preview) CarKeyboardVisibility.state.value = true
|
||||||
onDispose { CarKeyboardVisibility.state.value = false }
|
onDispose { if (!preview) CarKeyboardVisibility.state.value = false }
|
||||||
}
|
}
|
||||||
|
|
||||||
// The same field on the phone, for typing on its own keyboard: see [PhoneTyping].
|
// The same field on the phone, for typing on its own keyboard: see [PhoneTyping].
|
||||||
@@ -88,6 +95,7 @@ fun CarKeyboard(
|
|||||||
}
|
}
|
||||||
DisposableEffect(phoneField) { onDispose { PhoneTyping.close(phoneField) } }
|
DisposableEffect(phoneField) { onDispose { PhoneTyping.close(phoneField) } }
|
||||||
LaunchedEffect(text) { PhoneTyping.carText(phoneField, text) }
|
LaunchedEffect(text) { PhoneTyping.carText(phoneField, text) }
|
||||||
|
if (preview) return
|
||||||
|
|
||||||
val rows = if (symbols) SYMBOL_ROWS else LETTER_ROWS
|
val rows = if (symbols) SYMBOL_ROWS else LETTER_ROWS
|
||||||
val keyHeight = keyHeight(LocalConfiguration.current.screenHeightDp)
|
val keyHeight = keyHeight(LocalConfiguration.current.screenHeightDp)
|
||||||
|
|||||||
@@ -76,7 +76,9 @@ fun CarPreviewScreen(onBack: () -> Unit) {
|
|||||||
// No surface yet: the SurfaceView below hands its own over once it exists, and the
|
// No surface yet: the SurfaceView below hands its own over once it exists, and the
|
||||||
// display draws straight into it. Copying each frame into a Bitmap instead cost two
|
// display draws straight into it. Copying each frame into a Bitmap instead cost two
|
||||||
// full-size allocations per frame on the main thread, and taps lagged with the size.
|
// full-size allocations per frame on the main thread, and taps lagged with the size.
|
||||||
projector.start(null, width, height, density, name = "gearslip-preview") { CarUi() }
|
projector.start(null, width, height, density, name = "gearslip-preview") {
|
||||||
|
androidx.compose.runtime.CompositionLocalProvider(app.seb3thehacker.gearslip.car.LocalCarPreview provides true) { CarUi() }
|
||||||
|
}
|
||||||
onDispose { projector.stop() }
|
onDispose { projector.stop() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -148,8 +148,9 @@ fun GearslipApp(onDisconnect: () -> Unit, onRequestCallScreening: () -> Unit) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// A car keyboard is open: offer the phone's own, for a passenger.
|
// A car keyboard is open: offer the phone's own, for a passenger. In the car preview it is
|
||||||
if (screen != Screen.CAR_PREVIEW) PhoneTypingBar()
|
// the only keyboard, since the preview draws none of its own.
|
||||||
|
PhoneTypingBar()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user