mirror of
https://github.com/twinksoftware/Gearslip.git
synced 2026-12-01 07:40:31 +01:00
Shizuku gets its own section in Settings, and debug builds can step through every weather scene
This commit is contained in:
1 parent
e44028dc81
commit
4fcb2bdf56
6 files changed
+47
-3
No files matched your search
@@ -401,6 +401,26 @@ private fun AppsWallpaper() {
|
|||||||
Box(Modifier.fillMaxSize().background(background.copy(alpha = 0.3f)))
|
Box(Modifier.fillMaxSize().background(background.copy(alpha = 0.3f)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CarWallpaper.Mode.DEMO -> {
|
||||||
|
// Every scene by day, then by night, two seconds each, named in the corner.
|
||||||
|
val steps = remember { listOf(true, false).flatMap { day -> SkyScene.entries.map { it to day } } }
|
||||||
|
var step by remember { mutableStateOf(0) }
|
||||||
|
LaunchedEffect(Unit) {
|
||||||
|
while (true) {
|
||||||
|
kotlinx.coroutines.delay(2_000)
|
||||||
|
step = (step + 1) % steps.size
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val (scene, day) = steps[step]
|
||||||
|
WeatherScene(scene, day, dark, Modifier.fillMaxSize())
|
||||||
|
Text(
|
||||||
|
"${scene.name.lowercase().replace('_', ' ')} · ${if (day) "day" else "night"} · ${if (dark) "dark" else "light"} mode",
|
||||||
|
Modifier.fillMaxSize().padding(8.dp),
|
||||||
|
color = Color.White,
|
||||||
|
style = MaterialTheme.typography.labelLarge,
|
||||||
|
textAlign = TextAlign.End,
|
||||||
|
)
|
||||||
|
}
|
||||||
CarWallpaper.Mode.WEATHER -> {
|
CarWallpaper.Mode.WEATHER -> {
|
||||||
val weather by Weather.state.collectAsState()
|
val weather by Weather.state.collectAsState()
|
||||||
LaunchedEffect(Unit) { Weather.refresh(context) }
|
LaunchedEffect(Unit) { Weather.refresh(context) }
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ import kotlinx.coroutines.flow.StateFlow
|
|||||||
*/
|
*/
|
||||||
object CarWallpaper {
|
object CarWallpaper {
|
||||||
|
|
||||||
enum class Mode { OFF, PHOTO, WEATHER }
|
/** [DEMO] steps through every weather scene, for checking them; debug builds only. */
|
||||||
|
enum class Mode { OFF, PHOTO, WEATHER, DEMO }
|
||||||
|
|
||||||
private const val KEY_MODE = "car_wallpaper"
|
private const val KEY_MODE = "car_wallpaper"
|
||||||
private const val LIGHT = "wallpaper-light.jpg"
|
private const val LIGHT = "wallpaper-light.jpg"
|
||||||
|
|||||||
@@ -652,7 +652,10 @@ private fun WallpaperRows() {
|
|||||||
app.seb3thehacker.gearslip.car.CarWallpaper.Mode.OFF to stringResource(R.string.choice_wallpaper_off),
|
app.seb3thehacker.gearslip.car.CarWallpaper.Mode.OFF to stringResource(R.string.choice_wallpaper_off),
|
||||||
app.seb3thehacker.gearslip.car.CarWallpaper.Mode.PHOTO to stringResource(R.string.choice_wallpaper_photo),
|
app.seb3thehacker.gearslip.car.CarWallpaper.Mode.PHOTO to stringResource(R.string.choice_wallpaper_photo),
|
||||||
app.seb3thehacker.gearslip.car.CarWallpaper.Mode.WEATHER to stringResource(R.string.choice_wallpaper_weather),
|
app.seb3thehacker.gearslip.car.CarWallpaper.Mode.WEATHER to stringResource(R.string.choice_wallpaper_weather),
|
||||||
),
|
) + if (app.seb3thehacker.gearslip.BuildConfig.DEBUG) {
|
||||||
|
// Not translated: debug builds only, for checking every scene.
|
||||||
|
listOf(app.seb3thehacker.gearslip.car.CarWallpaper.Mode.DEMO to "Weather demo")
|
||||||
|
} else emptyList(),
|
||||||
mode,
|
mode,
|
||||||
{ app.seb3thehacker.gearslip.car.CarWallpaper.setMode(context, it) },
|
{ app.seb3thehacker.gearslip.car.CarWallpaper.setMode(context, it) },
|
||||||
note = stringResource(R.string.car_wallpaper_note),
|
note = stringResource(R.string.car_wallpaper_note),
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ fun SettingsScreen(
|
|||||||
footer = stringResource(R.string.settings_support_footer),
|
footer = stringResource(R.string.settings_support_footer),
|
||||||
) { DonateRows() }
|
) { DonateRows() }
|
||||||
if (ready(2)) ConnectionSection()
|
if (ready(2)) ConnectionSection()
|
||||||
|
if (ready(2)) ShizukuSection()
|
||||||
if (SHOW_RECOMMENDED_APPS && ready(6)) AppsSection(onOpenRecommendedApps)
|
if (SHOW_RECOMMENDED_APPS && ready(6)) AppsSection(onOpenRecommendedApps)
|
||||||
if (ready(7)) SettingsSection(
|
if (ready(7)) SettingsSection(
|
||||||
stringResource(R.string.settings_usage_notes),
|
stringResource(R.string.settings_usage_notes),
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package app.seb3thehacker.gearslip.ui
|
|||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.OutlinedButton
|
import androidx.compose.material3.OutlinedButton
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
@@ -35,7 +36,8 @@ fun ShizukuGrantButton(modifier: Modifier = Modifier) {
|
|||||||
if (state == ShizukuSetup.State.MISSING) return
|
if (state == ShizukuSetup.State.MISSING) return
|
||||||
Column(modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
Column(modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||||
when {
|
when {
|
||||||
granted -> Text(stringResource(R.string.shizuku_done), style = MaterialTheme.typography.bodyMedium)
|
// Phone apps on the car screen need Shizuku's permission even when adb did the grants.
|
||||||
|
granted && state == ShizukuSetup.State.READY -> Text(stringResource(R.string.shizuku_done), style = MaterialTheme.typography.bodyMedium)
|
||||||
state == ShizukuSetup.State.STOPPED -> Text(stringResource(R.string.shizuku_stopped), style = MaterialTheme.typography.bodyMedium)
|
state == ShizukuSetup.State.STOPPED -> Text(stringResource(R.string.shizuku_stopped), style = MaterialTheme.typography.bodyMedium)
|
||||||
else -> OutlinedButton(onClick = ShizukuSetup::setUp, enabled = !working, modifier = Modifier.fillMaxWidth()) {
|
else -> OutlinedButton(onClick = ShizukuSetup::setUp, enabled = !working, modifier = Modifier.fillMaxWidth()) {
|
||||||
Text(stringResource(if (working) R.string.shizuku_working else R.string.shizuku_set_up))
|
Text(stringResource(if (working) R.string.shizuku_working else R.string.shizuku_set_up))
|
||||||
@@ -43,3 +45,18 @@ fun ShizukuGrantButton(modifier: Modifier = Modifier) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Settings' own place for Shizuku, whatever the audio choice: the setup guide and Help only show
|
||||||
|
* the adb steps when music goes through Gearslip, but phone apps on the car screen need Shizuku
|
||||||
|
* too. Shown only when Shizuku is installed.
|
||||||
|
*/
|
||||||
|
@Composable
|
||||||
|
fun ShizukuSection() {
|
||||||
|
val state by ShizukuSetup.state.collectAsState()
|
||||||
|
LaunchedEffect(Unit) { ShizukuSetup.refresh() }
|
||||||
|
if (state == ShizukuSetup.State.MISSING) return
|
||||||
|
SettingsSection(stringResource(R.string.settings_shizuku), footer = stringResource(R.string.settings_shizuku_footer)) {
|
||||||
|
ShizukuGrantButton(Modifier.padding(horizontal = 16.dp, vertical = 12.dp))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -748,6 +748,8 @@
|
|||||||
<string name="car_wallpaper_chosen">Tap to change it.</string>
|
<string name="car_wallpaper_chosen">Tap to change it.</string>
|
||||||
<string name="car_wallpaper_remove">Remove</string>
|
<string name="car_wallpaper_remove">Remove</string>
|
||||||
<string name="native_app_failed">This app couldn\'t open on the car screen. Check that Shizuku is running, then try again.</string>
|
<string name="native_app_failed">This app couldn\'t open on the car screen. Check that Shizuku is running, then try again.</string>
|
||||||
|
<string name="settings_shizuku">Shizuku</string>
|
||||||
|
<string name="settings_shizuku_footer">Shizuku gives Gearslip the powers of adb without a computer. With it, Android stops asking to share the screen every drive, and any phone app can open on the car screen.</string>
|
||||||
<string name="shizuku_set_up">Set up with Shizuku</string>
|
<string name="shizuku_set_up">Set up with Shizuku</string>
|
||||||
<string name="shizuku_working">Setting up…</string>
|
<string name="shizuku_working">Setting up…</string>
|
||||||
<string name="shizuku_done">Set up through Shizuku. Nothing more to do here.</string>
|
<string name="shizuku_done">Set up through Shizuku. Nothing more to do here.</string>
|
||||||
|
|||||||
Reference in new issue
Block a user