mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 20:45:43 +00:00
feat(bottom): brightness slider for the bottom screen with screen off at its end
This commit is contained in:
1 parent
6f26cc18a8
commit
d02592afdb
38 files changed
+229
-13
No files matched your search
@@ -154,6 +154,13 @@ object SessionPrefs {
|
||||
prefs(context).edit().putString("bottomPage.app.$game", page).apply()
|
||||
}
|
||||
|
||||
/** The bottom screen's brightness in percent, or null to follow the system. */
|
||||
fun bottomBrightness(context: Context): Int? = prefs(context).getInt("bottomBrightness", -1).takeIf { it >= 0 }
|
||||
|
||||
fun setBottomBrightness(context: Context, percent: Int) {
|
||||
prefs(context).edit().putInt("bottomBrightness", percent).apply()
|
||||
}
|
||||
|
||||
fun bottomAutoDim(context: Context): Boolean = prefs(context).getBoolean("bottomAutoDim", true)
|
||||
|
||||
fun setBottomAutoDim(context: Context, on: Boolean) {
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.provider.Settings
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.DarkMode
|
||||
import androidx.compose.material.icons.outlined.LightMode
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
|
||||
/** The bottom screen's own brightness, in percent. It never goes below [MIN] so the slider cannot leave the screen dark. */
|
||||
internal object BottomBrightness {
|
||||
const val MIN = 5
|
||||
const val STEP = 5
|
||||
|
||||
/** The window brightness to use while the screen is on, or null to follow the system. */
|
||||
fun level(context: Context): Float? = SessionPrefs.bottomBrightness(context)?.let { clamp(it) / 100f }
|
||||
|
||||
fun clamp(percent: Int): Int = percent.coerceIn(MIN, 100)
|
||||
|
||||
/** Where the slider starts: the saved level, else the system brightness as a percentage. */
|
||||
fun initial(context: Context): Int = clamp(SessionPrefs.bottomBrightness(context) ?: runCatching {
|
||||
Settings.System.getInt(context.contentResolver, Settings.System.SCREEN_BRIGHTNESS) * 100 / 255
|
||||
}.getOrDefault(60))
|
||||
|
||||
/** Auto-dim never brightens a screen the user set darker. */
|
||||
fun dimmed(context: Context, dim: Float): Float = level(context)?.let { minOf(it, dim) } ?: dim
|
||||
}
|
||||
|
||||
/** A dropdown under the bottom bar: a brightness slider and the screen-off button. A tap outside closes it. */
|
||||
@Composable
|
||||
internal fun BrightnessDrop(percent: Int, onChange: (Int) -> Unit, onScreenOff: () -> Unit, onDismiss: () -> Unit) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val shape = RoundedCornerShape(16.dp)
|
||||
Box(
|
||||
Modifier.fillMaxSize().clickable(remember { MutableInteractionSource() }, indication = null, onClick = onDismiss)
|
||||
.padding(top = BAR_HEIGHT, start = 12.dp, end = 12.dp),
|
||||
) {
|
||||
Row(
|
||||
Modifier.fillMaxWidth().testTag("bottom-brightness").clip(shape).background(colors.surface).border(1.dp, pal.line, shape)
|
||||
.clickable(remember { MutableInteractionSource() }, indication = null) {}
|
||||
.padding(horizontal = 12.dp, vertical = 6.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(10.dp),
|
||||
) {
|
||||
Icon(Icons.Outlined.LightMode, contentDescription = null, tint = colors.onSurfaceVariant, modifier = Modifier.size(22.dp))
|
||||
ValueSlider(
|
||||
percent, BottomBrightness.MIN..100, BottomBrightness.STEP, true, stringResource(R.string.bottom_brightness), { "$it%" },
|
||||
modifier = Modifier.weight(1f), track = 32.dp, onChange = onChange,
|
||||
)
|
||||
BarButton(stringResource(R.string.bottom_screen_off), Modifier.testTag("bottom-brightness-off"), vector = Icons.Filled.DarkMode,
|
||||
onClick = onScreenOff)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import android.widget.FrameLayout
|
||||
import android.widget.LinearLayout
|
||||
import androidx.activity.setViewTreeOnBackPressedDispatcherOwner
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.DarkMode
|
||||
import androidx.compose.material.icons.outlined.LightMode
|
||||
import androidx.lifecycle.setViewTreeLifecycleOwner
|
||||
import androidx.lifecycle.setViewTreeViewModelStoreOwner
|
||||
import androidx.savedstate.setViewTreeSavedStateRegistryOwner
|
||||
@@ -70,6 +70,18 @@ class SecondScreenPresentation(
|
||||
var controlsView: InputSurfaceView? = null
|
||||
private set
|
||||
private var created = false
|
||||
private val brightnessOpen = androidx.compose.runtime.mutableStateOf(false)
|
||||
private val brightness = androidx.compose.runtime.mutableIntStateOf(BottomBrightness.MIN)
|
||||
private val brightnessView by lazy {
|
||||
androidx.compose.ui.platform.ComposeView(context).apply {
|
||||
setContent {
|
||||
DroidDeckTheme {
|
||||
if (brightnessOpen.value) BrightnessDrop(brightness.intValue, ::setBrightness,
|
||||
onScreenOff = { brightnessOpen.value = false; screenOff() }, onDismiss = { brightnessOpen.value = false })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
setCancelable(false)
|
||||
@@ -83,7 +95,9 @@ class SecondScreenPresentation(
|
||||
window?.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
|
||||
frame.addView(root, FrameLayout.LayoutParams(-1, -1))
|
||||
frame.addView(brightnessView, FrameLayout.LayoutParams(-1, -1))
|
||||
frame.addView(sleepView, FrameLayout.LayoutParams(-1, -1))
|
||||
light(BottomScreenLight.ON)
|
||||
setContentView(frame)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
root.setOnApplyWindowInsetsListener { view, insets ->
|
||||
@@ -131,6 +145,7 @@ class SecondScreenPresentation(
|
||||
fun showMode(mode: SecondScreenMode) {
|
||||
if (currentMode == mode && isShowing) return
|
||||
currentMode = mode
|
||||
brightnessOpen.value = false
|
||||
if (created) renderMode()
|
||||
}
|
||||
|
||||
@@ -236,8 +251,13 @@ class SecondScreenPresentation(
|
||||
}
|
||||
|
||||
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
|
||||
if (screen != BottomScreenLight.ON) {
|
||||
if (event.actionMasked == MotionEvent.ACTION_DOWN) wake()
|
||||
if (event.actionMasked == MotionEvent.ACTION_DOWN && screen == BottomScreenLight.ON) waking = false
|
||||
if (screen != BottomScreenLight.ON || waking) {
|
||||
// The touch that wakes the screen is swallowed whole, so its release does not click what is under it.
|
||||
when (event.actionMasked) {
|
||||
MotionEvent.ACTION_DOWN -> if (screen != BottomScreenLight.ON) { waking = true; wake() }
|
||||
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> waking = false
|
||||
}
|
||||
return true
|
||||
}
|
||||
scheduleDim()
|
||||
@@ -250,6 +270,7 @@ class SecondScreenPresentation(
|
||||
visibility = View.GONE
|
||||
}
|
||||
private var screen = BottomScreenLight.ON
|
||||
private var waking = false
|
||||
private val dim = Runnable { if (screen == BottomScreenLight.ON) light(BottomScreenLight.DIM) }
|
||||
|
||||
fun screenOff() = light(BottomScreenLight.OFF)
|
||||
@@ -264,7 +285,25 @@ class SecondScreenPresentation(
|
||||
sleepView.visibility = if (state == BottomScreenLight.OFF) View.VISIBLE else View.GONE
|
||||
sleepView.alpha = 1f
|
||||
val w = window ?: return
|
||||
w.attributes = w.attributes.apply { screenBrightness = state.brightness }
|
||||
w.attributes = w.attributes.apply {
|
||||
screenBrightness = when (state) {
|
||||
BottomScreenLight.ON -> BottomBrightness.level(context) ?: state.brightness
|
||||
BottomScreenLight.DIM -> BottomBrightness.dimmed(context, state.brightness)
|
||||
BottomScreenLight.OFF -> state.brightness
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun toggleBrightness() {
|
||||
if (!brightnessOpen.value) brightness.intValue = BottomBrightness.initial(context)
|
||||
brightnessOpen.value = !brightnessOpen.value
|
||||
}
|
||||
|
||||
private fun setBrightness(percent: Int) {
|
||||
val value = BottomBrightness.clamp(percent)
|
||||
brightness.intValue = value
|
||||
SessionPrefs.setBottomBrightness(context, value)
|
||||
if (screen == BottomScreenLight.ON) light(BottomScreenLight.ON)
|
||||
}
|
||||
|
||||
private fun scheduleDim() {
|
||||
@@ -358,8 +397,8 @@ class SecondScreenPresentation(
|
||||
|
||||
internal fun barModel(mode: SecondScreenMode): BottomBarModel? {
|
||||
val extras = listOfNotNull(onSwap?.let { BarExtra(context.getString(R.string.swap_screens), icon = R.drawable.ic_bottom_swap, tag = "bottom-swap", onClick = it) }) +
|
||||
BarExtra(context.getString(R.string.bottom_screen_off), vector = Icons.Filled.DarkMode,
|
||||
tag = "bottom-screen-off", onClick = ::screenOff)
|
||||
BarExtra(context.getString(R.string.bottom_brightness), vector = Icons.Outlined.LightMode, active = brightnessOpen.value,
|
||||
tag = "bottom-brightness-toggle", onClick = ::toggleBrightness)
|
||||
fun model(extras: List<BarExtra>, tabs: BarTabs? = null) =
|
||||
sessionBarModel(context.getString(mode.label), onClose, onMenu, onSteamMenu, onQam, extras, tabs, picker?.invoke(mode))
|
||||
return when (mode) {
|
||||
|
||||
@@ -2177,6 +2177,7 @@
|
||||
<string name="bottom_chat_mic_off">الميكروفون متوقف</string>
|
||||
<string name="bottom_chat_mic_unavailable">الميكروفون متوقف لهذه اللعبة. للتحدث، فعِّل «الميكروفون» في إعدادات Steam في DroidDeck (الصوت) وابدأ اللعبة من جديد.</string>
|
||||
<string name="bottom_chat_volume">مستوى الصوت %1$d%%</string>
|
||||
<string name="bottom_brightness">سطوع الشاشة السفلية</string>
|
||||
<string name="bottom_screen_off">أطفئ الشاشة السفلية</string>
|
||||
<string name="bottom_page_guides">الأدلة</string>
|
||||
<string name="bottom_guides_no_game">ابدأ لعبة لترى أدلة Steam الخاصة بها هنا.</string>
|
||||
|
||||
@@ -2172,6 +2172,7 @@
|
||||
<string name="bottom_chat_mic_off">Micro desactivado</string>
|
||||
<string name="bottom_chat_mic_unavailable">El micro está desactivado en este juego. Para hablar, activa Micrófono en los ajustes de Steam de DroidDeck (Audio) y vuelve a iniciar el juego.</string>
|
||||
<string name="bottom_chat_volume">Volumen %1$d%%</string>
|
||||
<string name="bottom_brightness">Brillo de la pantalla inferior</string>
|
||||
<string name="bottom_screen_off">Apagar la pantalla inferior</string>
|
||||
<string name="bottom_page_guides">Guías</string>
|
||||
<string name="bottom_guides_no_game">Inicia un juego para ver aquí sus guías de Steam.</string>
|
||||
|
||||
@@ -2077,6 +2077,7 @@
|
||||
<string name="bottom_chat_mic_off">Микрофонът е изключен</string>
|
||||
<string name="bottom_chat_mic_unavailable">Микрофонът е изключен за тази игра. За да говорите, включете „Микрофон“ в настройките на Steam в DroidDeck (Звук) и стартирайте играта отново.</string>
|
||||
<string name="bottom_chat_volume">Сила на звука %1$d%%</string>
|
||||
<string name="bottom_brightness">Яркост на долния екран</string>
|
||||
<string name="bottom_screen_off">Изключи долния екран</string>
|
||||
<string name="bottom_page_guides">Ръководства</string>
|
||||
<string name="bottom_guides_no_game">Пуснете игра, за да видите тук нейните ръководства в Steam.</string>
|
||||
|
||||
@@ -2127,6 +2127,7 @@
|
||||
<string name="bottom_chat_mic_off">Mikrofon vypnut</string>
|
||||
<string name="bottom_chat_mic_unavailable">Mikrofon je pro tuto hru vypnutý. Chcete-li mluvit, zapněte Mikrofon v nastavení Steamu v DroidDecku (Zvuk) a spusťte hru znovu.</string>
|
||||
<string name="bottom_chat_volume">Hlasitost %1$d%%</string>
|
||||
<string name="bottom_brightness">Jas spodní obrazovky</string>
|
||||
<string name="bottom_screen_off">Vypnout spodní obrazovku</string>
|
||||
<string name="bottom_page_guides">Návody</string>
|
||||
<string name="bottom_guides_no_game">Spusťte hru a uvidíte zde její návody ze Steamu.</string>
|
||||
|
||||
@@ -2077,6 +2077,7 @@
|
||||
<string name="bottom_chat_mic_off">Mikrofon fra</string>
|
||||
<string name="bottom_chat_mic_unavailable">Mikrofonen er slået fra for dette spil. For at tale skal du slå Mikrofon til i DroidDecks Steam-indstillinger (Lyd) og starte spillet igen.</string>
|
||||
<string name="bottom_chat_volume">Lydstyrke %1$d%%</string>
|
||||
<string name="bottom_brightness">Lysstyrke på nederste skærm</string>
|
||||
<string name="bottom_screen_off">Sluk den nederste skærm</string>
|
||||
<string name="bottom_page_guides">Guides</string>
|
||||
<string name="bottom_guides_no_game">Start et spil for at se dets Steam-guides her.</string>
|
||||
|
||||
@@ -2069,6 +2069,7 @@
|
||||
<string name="bottom_chat_mic_off">Mikro aus</string>
|
||||
<string name="bottom_chat_mic_unavailable">Das Mikro ist für dieses Spiel aus. Um zu sprechen, aktiviere „Mikrofon“ in den Steam-Einstellungen von DroidDeck (Audio) und starte das Spiel neu.</string>
|
||||
<string name="bottom_chat_volume">Lautstärke %1$d%%</string>
|
||||
<string name="bottom_brightness">Helligkeit des unteren Bildschirms</string>
|
||||
<string name="bottom_screen_off">Unteren Bildschirm ausschalten</string>
|
||||
<string name="bottom_page_guides">Anleitungen</string>
|
||||
<string name="bottom_guides_no_game">Starte ein Spiel, um hier seine Steam-Anleitungen zu sehen.</string>
|
||||
|
||||
@@ -2077,6 +2077,7 @@
|
||||
<string name="bottom_chat_mic_off">Μικρόφωνο κλειστό</string>
|
||||
<string name="bottom_chat_mic_unavailable">Το μικρόφωνο είναι απενεργοποιημένο για αυτό το παιχνίδι. Για να μιλήσετε, ενεργοποιήστε το Μικρόφωνο στις ρυθμίσεις Steam του DroidDeck (Ήχος) και ξεκινήστε ξανά το παιχνίδι.</string>
|
||||
<string name="bottom_chat_volume">Ένταση %1$d%%</string>
|
||||
<string name="bottom_brightness">Φωτεινότητα κάτω οθόνης</string>
|
||||
<string name="bottom_screen_off">Απενεργοποίηση κάτω οθόνης</string>
|
||||
<string name="bottom_page_guides">Οδηγοί</string>
|
||||
<string name="bottom_guides_no_game">Ξεκινήστε ένα παιχνίδι για να δείτε εδώ τους οδηγούς του στο Steam.</string>
|
||||
|
||||
@@ -2102,6 +2102,7 @@
|
||||
<string name="bottom_chat_mic_off">Micro desactivado</string>
|
||||
<string name="bottom_chat_mic_unavailable">El micro está desactivado en este juego. Para hablar, activa Micrófono en los ajustes de Steam de DroidDeck (Audio) y vuelve a iniciar el juego.</string>
|
||||
<string name="bottom_chat_volume">Volumen %1$d%%</string>
|
||||
<string name="bottom_brightness">Brillo de la pantalla inferior</string>
|
||||
<string name="bottom_screen_off">Apagar la pantalla inferior</string>
|
||||
<string name="bottom_page_guides">Guías</string>
|
||||
<string name="bottom_guides_no_game">Inicia un juego para ver aquí sus guías de Steam.</string>
|
||||
|
||||
@@ -2077,6 +2077,7 @@
|
||||
<string name="bottom_chat_mic_off">Mikrofoni pois</string>
|
||||
<string name="bottom_chat_mic_unavailable">Mikrofoni on pois päältä tässä pelissä. Jos haluat puhua, kytke Mikrofoni päälle DroidDeckin Steam-asetuksissa (Ääni) ja käynnistä peli uudelleen.</string>
|
||||
<string name="bottom_chat_volume">Äänenvoimakkuus %1$d %%</string>
|
||||
<string name="bottom_brightness">Alanäytön kirkkaus</string>
|
||||
<string name="bottom_screen_off">Sammuta alanäyttö</string>
|
||||
<string name="bottom_page_guides">Oppaat</string>
|
||||
<string name="bottom_guides_no_game">Käynnistä peli nähdäksesi sen Steam-oppaat täällä.</string>
|
||||
|
||||
@@ -2101,6 +2101,7 @@
|
||||
<string name="bottom_chat_mic_off">Micro désactivé</string>
|
||||
<string name="bottom_chat_mic_unavailable">Le micro est désactivé pour ce jeu. Pour parler, activez Microphone dans les paramètres Steam de DroidDeck (Audio), puis relancez le jeu.</string>
|
||||
<string name="bottom_chat_volume">Volume %1$d %%</string>
|
||||
<string name="bottom_brightness">Luminosité de l’écran inférieur</string>
|
||||
<string name="bottom_screen_off">Éteindre l’écran du bas</string>
|
||||
<string name="bottom_page_guides">Guides</string>
|
||||
<string name="bottom_guides_no_game">Lancez un jeu pour voir ses guides Steam ici.</string>
|
||||
|
||||
@@ -2077,6 +2077,7 @@
|
||||
<string name="bottom_chat_mic_off">माइक बंद</string>
|
||||
<string name="bottom_chat_mic_unavailable">इस गेम के लिए माइक बंद है। बात करने के लिए DroidDeck की Steam सेटिंग (ऑडियो) में माइक्रोफ़ोन चालू करें और गेम फिर से शुरू करें।</string>
|
||||
<string name="bottom_chat_volume">वॉल्यूम %1$d%%</string>
|
||||
<string name="bottom_brightness">नीचे की स्क्रीन की चमक</string>
|
||||
<string name="bottom_screen_off">नीचे की स्क्रीन बंद करें</string>
|
||||
<string name="bottom_page_guides">गाइड</string>
|
||||
<string name="bottom_guides_no_game">यहाँ Steam गाइड देखने के लिए कोई गेम शुरू करें।</string>
|
||||
|
||||
@@ -2077,6 +2077,7 @@
|
||||
<string name="bottom_chat_mic_off">Mikrofon ki</string>
|
||||
<string name="bottom_chat_mic_unavailable">A mikrofon ki van kapcsolva ennél a játéknál. A beszédhez kapcsolja be a Mikrofon opciót a DroidDeck Steam-beállításaiban (Hang), majd indítsa újra a játékot.</string>
|
||||
<string name="bottom_chat_volume">Hangerő %1$d%%</string>
|
||||
<string name="bottom_brightness">Alsó kijelző fényereje</string>
|
||||
<string name="bottom_screen_off">Alsó képernyő kikapcsolása</string>
|
||||
<string name="bottom_page_guides">Útmutatók</string>
|
||||
<string name="bottom_guides_no_game">Indíts el egy játékot, hogy itt lásd a Steam-útmutatóit.</string>
|
||||
|
||||
@@ -2053,6 +2053,7 @@
|
||||
<string name="bottom_chat_mic_off">Mik mati</string>
|
||||
<string name="bottom_chat_mic_unavailable">Mik mati untuk gim ini. Untuk berbicara, aktifkan Mikrofon di setelan Steam DroidDeck (Audio) lalu mulai gim lagi.</string>
|
||||
<string name="bottom_chat_volume">Volume %1$d%%</string>
|
||||
<string name="bottom_brightness">Kecerahan layar bawah</string>
|
||||
<string name="bottom_screen_off">Matikan layar bawah</string>
|
||||
<string name="bottom_page_guides">Panduan</string>
|
||||
<string name="bottom_guides_no_game">Mulai game untuk melihat panduan Steam-nya di sini.</string>
|
||||
|
||||
@@ -2093,6 +2093,7 @@
|
||||
<string name="bottom_chat_mic_off">Microfono disattivato</string>
|
||||
<string name="bottom_chat_mic_unavailable">Il microfono è disattivato per questo gioco. Per parlare, attiva Microfono nelle impostazioni Steam di DroidDeck (Audio) e riavvia il gioco.</string>
|
||||
<string name="bottom_chat_volume">Volume %1$d%%</string>
|
||||
<string name="bottom_brightness">Luminosità dello schermo inferiore</string>
|
||||
<string name="bottom_screen_off">Spegni lo schermo inferiore</string>
|
||||
<string name="bottom_page_guides">Guide</string>
|
||||
<string name="bottom_guides_no_game">Avvia un gioco per vederne qui le guide di Steam.</string>
|
||||
|
||||
@@ -2053,6 +2053,7 @@
|
||||
<string name="bottom_chat_mic_off">マイク オフ</string>
|
||||
<string name="bottom_chat_mic_unavailable">このゲームではマイクがオフです。話すには、DroidDeckのSteam設定(オーディオ)でマイクをオンにして、ゲームを再起動してください。</string>
|
||||
<string name="bottom_chat_volume">音量 %1$d%%</string>
|
||||
<string name="bottom_brightness">下画面の明るさ</string>
|
||||
<string name="bottom_screen_off">下の画面をオフにする</string>
|
||||
<string name="bottom_page_guides">ガイド</string>
|
||||
<string name="bottom_guides_no_game">ゲームを起動すると、ここに Steam ガイドが表示されます。</string>
|
||||
|
||||
@@ -2053,6 +2053,7 @@
|
||||
<string name="bottom_chat_mic_off">마이크 꺼짐</string>
|
||||
<string name="bottom_chat_mic_unavailable">이 게임에서는 마이크가 꺼져 있습니다. 대화하려면 DroidDeck의 Steam 설정(오디오)에서 마이크를 켜고 게임을 다시 시작하세요.</string>
|
||||
<string name="bottom_chat_volume">볼륨 %1$d%%</string>
|
||||
<string name="bottom_brightness">아래쪽 화면 밝기</string>
|
||||
<string name="bottom_screen_off">아래 화면 끄기</string>
|
||||
<string name="bottom_page_guides">가이드</string>
|
||||
<string name="bottom_guides_no_game">게임을 시작하면 여기에 Steam 가이드가 표시됩니다.</string>
|
||||
|
||||
@@ -2053,6 +2053,7 @@
|
||||
<string name="bottom_chat_mic_off">Mikrofon mati</string>
|
||||
<string name="bottom_chat_mic_unavailable">Mikrofon dimatikan untuk permainan ini. Untuk bercakap, hidupkan Mikrofon dalam tetapan Steam DroidDeck (Audio) dan mulakan permainan semula.</string>
|
||||
<string name="bottom_chat_volume">Kelantangan %1$d%%</string>
|
||||
<string name="bottom_brightness">Kecerahan skrin bawah</string>
|
||||
<string name="bottom_screen_off">Matikan skrin bawah</string>
|
||||
<string name="bottom_page_guides">Panduan</string>
|
||||
<string name="bottom_guides_no_game">Mulakan permainan untuk melihat panduan Steamnya di sini.</string>
|
||||
|
||||
@@ -2077,6 +2077,7 @@
|
||||
<string name="bottom_chat_mic_off">Mikrofon av</string>
|
||||
<string name="bottom_chat_mic_unavailable">Mikrofonen er av for dette spillet. For å snakke, slå på Mikrofon i DroidDecks Steam-innstillinger (Lyd) og start spillet på nytt.</string>
|
||||
<string name="bottom_chat_volume">Volum %1$d%%</string>
|
||||
<string name="bottom_brightness">Lysstyrke på nedre skjerm</string>
|
||||
<string name="bottom_screen_off">Slå av den nederste skjermen</string>
|
||||
<string name="bottom_page_guides">Guider</string>
|
||||
<string name="bottom_guides_no_game">Start et spill for å se Steam-guidene her.</string>
|
||||
|
||||
@@ -2077,6 +2077,7 @@
|
||||
<string name="bottom_chat_mic_off">Microfoon uit</string>
|
||||
<string name="bottom_chat_mic_unavailable">De microfoon staat uit voor deze game. Zet Microfoon aan in de Steam-instellingen van DroidDeck (Audio) en start de game opnieuw om te praten.</string>
|
||||
<string name="bottom_chat_volume">Volume %1$d%%</string>
|
||||
<string name="bottom_brightness">Helderheid van het onderste scherm</string>
|
||||
<string name="bottom_screen_off">Onderste scherm uitzetten</string>
|
||||
<string name="bottom_page_guides">Handleidingen</string>
|
||||
<string name="bottom_guides_no_game">Start een game om hier de Steam-handleidingen te zien.</string>
|
||||
|
||||
@@ -2127,6 +2127,7 @@
|
||||
<string name="bottom_chat_mic_off">Mikrofon wył.</string>
|
||||
<string name="bottom_chat_mic_unavailable">Mikrofon jest wyłączony dla tej gry. Aby rozmawiać, włącz Mikrofon w ustawieniach Steam w DroidDeck (Dźwięk) i uruchom grę ponownie.</string>
|
||||
<string name="bottom_chat_volume">Głośność %1$d%%</string>
|
||||
<string name="bottom_brightness">Jasność dolnego ekranu</string>
|
||||
<string name="bottom_screen_off">Wyłącz dolny ekran</string>
|
||||
<string name="bottom_page_guides">Poradniki</string>
|
||||
<string name="bottom_guides_no_game">Uruchom grę, aby zobaczyć tu jej poradniki ze Steam.</string>
|
||||
|
||||
@@ -2107,6 +2107,7 @@
|
||||
<string name="bottom_chat_mic_off">Microfone desligado</string>
|
||||
<string name="bottom_chat_mic_unavailable">O microfone está desligado neste jogo. Para falar, ative Microfone nas definições do Steam do DroidDeck (Áudio) e volte a iniciar o jogo.</string>
|
||||
<string name="bottom_chat_volume">Volume %1$d%%</string>
|
||||
<string name="bottom_brightness">Brilho do ecrã inferior</string>
|
||||
<string name="bottom_screen_off">Desligar o ecrã inferior</string>
|
||||
<string name="bottom_page_guides">Guias</string>
|
||||
<string name="bottom_guides_no_game">Inicie um jogo para ver aqui os guias Steam dele.</string>
|
||||
|
||||
@@ -2115,6 +2115,7 @@
|
||||
<string name="bottom_chat_mic_off">Microfone desligado</string>
|
||||
<string name="bottom_chat_mic_unavailable">O microfone está desligado neste jogo. Para falar, ative Microfone nas configurações da Steam do DroidDeck (Áudio) e inicie o jogo de novo.</string>
|
||||
<string name="bottom_chat_volume">Volume %1$d%%</string>
|
||||
<string name="bottom_brightness">Brilho da tela inferior</string>
|
||||
<string name="bottom_screen_off">Desligar a tela inferior</string>
|
||||
<string name="bottom_page_guides">Guias</string>
|
||||
<string name="bottom_guides_no_game">Inicie um jogo para ver os guias Steam dele aqui.</string>
|
||||
|
||||
@@ -2102,6 +2102,7 @@
|
||||
<string name="bottom_chat_mic_off">Microfon oprit</string>
|
||||
<string name="bottom_chat_mic_unavailable">Microfonul este oprit pentru acest joc. Pentru a vorbi, activează Microfon în setările Steam din DroidDeck (Sunet) și pornește din nou jocul.</string>
|
||||
<string name="bottom_chat_volume">Volum %1$d%%</string>
|
||||
<string name="bottom_brightness">Luminozitatea ecranului de jos</string>
|
||||
<string name="bottom_screen_off">Oprește ecranul de jos</string>
|
||||
<string name="bottom_page_guides">Ghiduri</string>
|
||||
<string name="bottom_guides_no_game">Pornește un joc ca să-i vezi aici ghidurile Steam.</string>
|
||||
|
||||
@@ -2128,6 +2128,7 @@
|
||||
<string name="bottom_chat_mic_off">Микрофон выкл.</string>
|
||||
<string name="bottom_chat_mic_unavailable">Микрофон для этой игры выключен. Чтобы говорить, включите «Микрофон» в настройках Steam в DroidDeck (Аудио) и запустите игру снова.</string>
|
||||
<string name="bottom_chat_volume">Громкость %1$d%%</string>
|
||||
<string name="bottom_brightness">Яркость нижнего экрана</string>
|
||||
<string name="bottom_screen_off">Выключить нижний экран</string>
|
||||
<string name="bottom_page_guides">Руководства</string>
|
||||
<string name="bottom_guides_no_game">Запустите игру, чтобы увидеть здесь её руководства Steam.</string>
|
||||
|
||||
@@ -2077,6 +2077,7 @@
|
||||
<string name="bottom_chat_mic_off">Mikrofon av</string>
|
||||
<string name="bottom_chat_mic_unavailable">Mikrofonen är avstängd för det här spelet. Slå på Mikrofon i DroidDecks Steam-inställningar (Ljud) och starta spelet igen för att prata.</string>
|
||||
<string name="bottom_chat_volume">Volym %1$d%%</string>
|
||||
<string name="bottom_brightness">Ljusstyrka för nedre skärmen</string>
|
||||
<string name="bottom_screen_off">Stäng av den nedre skärmen</string>
|
||||
<string name="bottom_page_guides">Guider</string>
|
||||
<string name="bottom_guides_no_game">Starta ett spel för att se dess Steam-guider här.</string>
|
||||
|
||||
@@ -2053,6 +2053,7 @@
|
||||
<string name="bottom_chat_mic_off">ไมค์ปิด</string>
|
||||
<string name="bottom_chat_mic_unavailable">ไมค์ปิดอยู่สำหรับเกมนี้ หากต้องการพูด ให้เปิดไมโครโฟนในการตั้งค่า Steam ของ DroidDeck (เสียง) แล้วเริ่มเกมอีกครั้ง</string>
|
||||
<string name="bottom_chat_volume">ระดับเสียง %1$d%%</string>
|
||||
<string name="bottom_brightness">ความสว่างของหน้าจอล่าง</string>
|
||||
<string name="bottom_screen_off">ปิดหน้าจอล่าง</string>
|
||||
<string name="bottom_page_guides">คู่มือ</string>
|
||||
<string name="bottom_guides_no_game">เริ่มเกมเพื่อดูคู่มือ Steam ของเกมที่นี่</string>
|
||||
|
||||
@@ -2069,6 +2069,7 @@
|
||||
<string name="bottom_chat_mic_off">Mikrofon kapalı</string>
|
||||
<string name="bottom_chat_mic_unavailable">Bu oyun için mikrofon kapalı. Konuşmak için DroidDeck\'in Steam ayarlarında (Ses) Mikrofon\'u açın ve oyunu yeniden başlatın.</string>
|
||||
<string name="bottom_chat_volume">Ses düzeyi %1$d%%</string>
|
||||
<string name="bottom_brightness">Alt ekran parlaklığı</string>
|
||||
<string name="bottom_screen_off">Alt ekranı kapat</string>
|
||||
<string name="bottom_page_guides">Rehberler</string>
|
||||
<string name="bottom_guides_no_game">Steam rehberlerini burada görmek için bir oyun başlatın.</string>
|
||||
|
||||
@@ -2127,6 +2127,7 @@
|
||||
<string name="bottom_chat_mic_off">Мікрофон вимкнено</string>
|
||||
<string name="bottom_chat_mic_unavailable">Для цієї гри мікрофон вимкнено. Щоб говорити, увімкніть «Мікрофон» у налаштуваннях Steam у DroidDeck (Звук) і запустіть гру знову.</string>
|
||||
<string name="bottom_chat_volume">Гучність %1$d%%</string>
|
||||
<string name="bottom_brightness">Яскравість нижнього екрана</string>
|
||||
<string name="bottom_screen_off">Вимкнути нижній екран</string>
|
||||
<string name="bottom_page_guides">Посібники</string>
|
||||
<string name="bottom_guides_no_game">Запустіть гру, щоб побачити тут її посібники Steam.</string>
|
||||
|
||||
@@ -2053,6 +2053,7 @@
|
||||
<string name="bottom_chat_mic_off">Micro tắt</string>
|
||||
<string name="bottom_chat_mic_unavailable">Micro đang tắt cho game này. Để nói chuyện, hãy bật Micro trong thiết lập Steam của DroidDeck (Âm thanh) rồi khởi động lại game.</string>
|
||||
<string name="bottom_chat_volume">Âm lượng %1$d%%</string>
|
||||
<string name="bottom_brightness">Độ sáng màn hình dưới</string>
|
||||
<string name="bottom_screen_off">Tắt màn hình dưới</string>
|
||||
<string name="bottom_page_guides">Hướng dẫn</string>
|
||||
<string name="bottom_guides_no_game">Hãy mở một trò chơi để xem hướng dẫn Steam của nó tại đây.</string>
|
||||
|
||||
@@ -2130,6 +2130,7 @@
|
||||
<string name="bottom_chat_mic_off">麦克风已关</string>
|
||||
<string name="bottom_chat_mic_unavailable">此游戏的麦克风已关闭。如需语音通话,请在 DroidDeck 的 Steam 设置(音频)中开启麦克风,然后重新启动游戏。</string>
|
||||
<string name="bottom_chat_volume">音量 %1$d%%</string>
|
||||
<string name="bottom_brightness">下屏幕亮度</string>
|
||||
<string name="bottom_screen_off">关闭下屏</string>
|
||||
<string name="bottom_page_guides">指南</string>
|
||||
<string name="bottom_guides_no_game">启动游戏后,这里会显示它的 Steam 指南。</string>
|
||||
|
||||
@@ -2052,6 +2052,7 @@
|
||||
<string name="bottom_chat_mic_off">麥克風已關閉</string>
|
||||
<string name="bottom_chat_mic_unavailable">此遊戲的麥克風已關閉。若要說話,請在 DroidDeck 的 Steam 設定(音訊)中開啟麥克風,然後重新啟動遊戲。</string>
|
||||
<string name="bottom_chat_volume">音量 %1$d%%</string>
|
||||
<string name="bottom_brightness">下方螢幕亮度</string>
|
||||
<string name="bottom_screen_off">關閉下螢幕</string>
|
||||
<string name="bottom_page_guides">指南</string>
|
||||
<string name="bottom_guides_no_game">啟動遊戲後,這裡會顯示它的 Steam 指南。</string>
|
||||
|
||||
@@ -2052,6 +2052,7 @@
|
||||
<string name="bottom_chat_mic_off">麥克風已關閉</string>
|
||||
<string name="bottom_chat_mic_unavailable">此遊戲的麥克風已關閉。若要說話,請在 DroidDeck 的 Steam 設定(音訊)中開啟麥克風,然後重新啟動遊戲。</string>
|
||||
<string name="bottom_chat_volume">音量 %1$d%%</string>
|
||||
<string name="bottom_brightness">下方螢幕亮度</string>
|
||||
<string name="bottom_screen_off">關閉下螢幕</string>
|
||||
<string name="bottom_page_guides">指南</string>
|
||||
<string name="bottom_guides_no_game">啟動遊戲後,這裡會顯示它的 Steam 指南。</string>
|
||||
|
||||
@@ -2348,6 +2348,7 @@
|
||||
<string name="bottom_chat_mic_off">Mic off</string>
|
||||
<string name="bottom_chat_mic_unavailable">Mic is off for this game. To talk, turn on Microphone in DroidDeck\'s Steam settings (Audio) and start the game again.</string>
|
||||
<string name="bottom_chat_volume">Volume %1$d%%</string>
|
||||
<string name="bottom_brightness">Bottom screen brightness</string>
|
||||
<string name="bottom_screen_off">Turn off the bottom screen</string>
|
||||
<string name="bottom_page_guides">Guides</string>
|
||||
<string name="bottom_guides_no_game">Start a game to see its Steam guides here.</string>
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import android.content.Context
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
class BottomBrightnessTest {
|
||||
private val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
|
||||
@Test fun followsTheSystemUntilTheUserPicksALevel() {
|
||||
assertNull(BottomBrightness.level(context))
|
||||
SessionPrefs.setBottomBrightness(context, 40)
|
||||
assertEquals(0.4f, BottomBrightness.level(context)!!, 0.001f)
|
||||
}
|
||||
|
||||
@Test fun theSliderNeverReachesZero() {
|
||||
assertEquals(BottomBrightness.MIN, BottomBrightness.clamp(0))
|
||||
assertEquals(BottomBrightness.MIN, BottomBrightness.clamp(-20))
|
||||
assertEquals(100, BottomBrightness.clamp(150))
|
||||
SessionPrefs.setBottomBrightness(context, 0)
|
||||
assertEquals(BottomBrightness.MIN / 100f, BottomBrightness.level(context)!!, 0.001f)
|
||||
}
|
||||
|
||||
@Test fun autoDimNeverBrightensADarkerChoice() {
|
||||
assertEquals(0.05f, BottomBrightness.dimmed(context, 0.05f), 0.001f)
|
||||
SessionPrefs.setBottomBrightness(context, 5)
|
||||
assertEquals(0.05f, BottomBrightness.dimmed(context, 0.2f), 0.001f)
|
||||
SessionPrefs.setBottomBrightness(context, 80)
|
||||
assertEquals(0.05f, BottomBrightness.dimmed(context, 0.05f), 0.001f)
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.droiddeck.launcher.ui
|
||||
|
||||
import android.hardware.display.DisplayManager
|
||||
import android.view.Display
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.compose.runtime.MutableState
|
||||
@@ -76,6 +77,27 @@ class SecondScreenBarTest {
|
||||
return (0 until root.childCount).map { root.getChildAt(it) }
|
||||
}
|
||||
|
||||
@Test fun theTouchThatWakesTheScreenDoesNotReachThePanel() {
|
||||
SessionState.mode = SessionService.MODE_STEAM
|
||||
val panel = presentation()
|
||||
try {
|
||||
panel.show()
|
||||
panel.showMode(SecondScreenMode.KEYBOARD_TRACKPAD)
|
||||
val root: ViewGroup = ReflectionHelpers.getField(panel, "root")
|
||||
val seen = mutableListOf<Int>()
|
||||
root.setOnTouchListener { _, e -> seen += e.actionMasked; true }
|
||||
fun touch(action: Int) = MotionEvent.obtain(0, 0, action, 10f, 10f, 0).also { panel.dispatchTouchEvent(it); it.recycle() }
|
||||
panel.screenOff()
|
||||
touch(MotionEvent.ACTION_DOWN)
|
||||
touch(MotionEvent.ACTION_UP)
|
||||
assertTrue(seen.isEmpty())
|
||||
assertEquals(BottomScreenLight.ON, ReflectionHelpers.getField<BottomScreenLight>(panel, "screen"))
|
||||
assertEquals(false, ReflectionHelpers.getField<Boolean>(panel, "waking"))
|
||||
} finally {
|
||||
panel.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun trackpadPanelHasTheBarWithTheKeyboardToggleStateAndSwap() {
|
||||
SessionState.mode = SessionService.MODE_STEAM
|
||||
var swaps = 0
|
||||
@@ -90,13 +112,13 @@ class SecondScreenBarTest {
|
||||
assertEquals(context.getString(R.string.second_mode_keyboard_trackpad), bar.title)
|
||||
assertNotNull(bar.onClose); assertNotNull(bar.onMenu); assertNotNull(bar.onSteam); assertNotNull(bar.onQam)
|
||||
assertNull(bar.tabs)
|
||||
assertEquals(listOf("bottom-keyboard", "bottom-swap", "bottom-screen-off"), bar.extras.map { it.tag })
|
||||
assertEquals(listOf("bottom-keyboard", "bottom-swap", "bottom-brightness-toggle"), bar.extras.map { it.tag })
|
||||
val keyboard = bar.extras.first()
|
||||
assertEquals(context.getString(R.string.second_show_keyboard), keyboard.description)
|
||||
assertFalse(keyboard.active)
|
||||
bar.extras.first { it.tag == "bottom-swap" }.onClick()
|
||||
assertEquals(1, swaps)
|
||||
assertEquals(listOf("bottom-keyboard", "bottom-swap", "bottom-screen-off"), panel.barModel(SecondScreenMode.TERMINAL)!!.extras.map { it.tag })
|
||||
assertEquals(listOf("bottom-keyboard", "bottom-swap", "bottom-brightness-toggle"), panel.barModel(SecondScreenMode.TERMINAL)!!.extras.map { it.tag })
|
||||
ReflectionHelpers.getField<MutableState<Boolean>>(panel, "keyboardShown").value = true
|
||||
val shown = panel.barModel(SecondScreenMode.KEYBOARD_TRACKPAD)!!.extras.first()
|
||||
assertEquals(context.getString(R.string.second_hide_keyboard), shown.description)
|
||||
@@ -115,7 +137,7 @@ class SecondScreenBarTest {
|
||||
assertTrue(rootChildren(panel)[0] is ComposeView)
|
||||
val bar = panel.barModel(SecondScreenMode.DECK_CONTROLS)!!
|
||||
assertEquals(context.getString(R.string.second_mode_deck_controls), bar.title)
|
||||
assertEquals(listOf(context.getString(R.string.swap_screens), context.getString(R.string.bottom_screen_off)), bar.extras.map { it.description })
|
||||
assertEquals(listOf(context.getString(R.string.swap_screens), context.getString(R.string.bottom_brightness)), bar.extras.map { it.description })
|
||||
bar.extras.first { it.tag == "bottom-swap" }.onClick()
|
||||
assertEquals(1, swaps)
|
||||
assertEquals(DeckPanel.entries.map { context.getString(it.label) }, bar.tabs!!.labels)
|
||||
@@ -123,7 +145,7 @@ class SecondScreenBarTest {
|
||||
panel.showMode(SecondScreenMode.CUSTOM_CONTROLS)
|
||||
val profile = panel.barModel(SecondScreenMode.CUSTOM_CONTROLS)!!
|
||||
assertEquals(context.getString(R.string.input_profile_controls_mode), profile.title)
|
||||
assertEquals(listOf(context.getString(R.string.swap_screens), context.getString(R.string.bottom_screen_off)), profile.extras.map { it.description })
|
||||
assertEquals(listOf(context.getString(R.string.swap_screens), context.getString(R.string.bottom_brightness)), profile.extras.map { it.description })
|
||||
assertNotNull(profile.onClose); assertNotNull(profile.onMenu)
|
||||
profile.extras.first { it.tag == "bottom-swap" }.onClick()
|
||||
assertEquals(2, swaps)
|
||||
@@ -134,9 +156,9 @@ class SecondScreenBarTest {
|
||||
try {
|
||||
noSwap.show()
|
||||
noSwap.showMode(SecondScreenMode.DECK_CONTROLS)
|
||||
assertEquals(listOf("bottom-screen-off"), noSwap.barModel(SecondScreenMode.DECK_CONTROLS)!!.extras.map { it.tag })
|
||||
assertEquals(listOf("bottom-keyboard", "bottom-screen-off"), noSwap.barModel(SecondScreenMode.TERMINAL)!!.extras.map { it.tag })
|
||||
assertEquals(listOf("bottom-keyboard", "bottom-screen-off"), noSwap.barModel(SecondScreenMode.KEYBOARD_TRACKPAD)!!.extras.map { it.tag })
|
||||
assertEquals(listOf("bottom-brightness-toggle"), noSwap.barModel(SecondScreenMode.DECK_CONTROLS)!!.extras.map { it.tag })
|
||||
assertEquals(listOf("bottom-keyboard", "bottom-brightness-toggle"), noSwap.barModel(SecondScreenMode.TERMINAL)!!.extras.map { it.tag })
|
||||
assertEquals(listOf("bottom-keyboard", "bottom-brightness-toggle"), noSwap.barModel(SecondScreenMode.KEYBOARD_TRACKPAD)!!.extras.map { it.tag })
|
||||
} finally { noSwap.closeControls() }
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user