From 5e452934622ab5706c8f596bf40414f57ba2a646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Bene=C5=A1?= Date: Fri, 13 Nov 2026 14:30:41 +0000 Subject: [PATCH] Wake word with the screen off: the sheet stays over the lock screen and listens A phone whose screen is off is locked. AssistActivity.take() sent every locked opening through requestDismissKeyguard and finished the activity on onDismissCancelled / onDismissError -- which is Android's answer when nobody unlocks. So the wake word lit the screen, showed the sheet, and closed it. lockedStart() decides now: a way in that means to speak (the wake word, a headset's button) stays and listens; what is heard is held in the state (waiting), shown as the person's own question with "Unlock to send", and Android is asked to unlock at once. Not unlocking leaves the sheet as it is. The question is asked on unlock (the dismiss callback or USER_PRESENT). The other locked openings ask to unlock first, as before. Nothing from the account over the lock screen still holds, and a little more than before: turns that were on the sheet when the phone locked are not drawn while it is locked (onStart reads the keyguard again), and a sheet over the lock screen goes when the screen goes off. The screen is kept on while it listens or works. The session (screen on, locked) listens over the lock screen as well and hands what it heard to the activity. Co-Authored-By: Claude Fable 5.2 --- CHANGELOG.md | 10 ++ .../llembas/android/assist/AssistActivity.kt | 145 +++++++++++++++--- .../android/assist/AssistController.kt | 42 +++++ .../eu/llembas/android/assist/AssistPanel.kt | 2 + .../llembas/android/assist/AssistService.kt | 21 ++- .../eu/llembas/android/assist/AssistSheet.kt | 44 +++++- app/src/main/res/values-cs/strings.xml | 2 + app/src/main/res/values-de/strings.xml | 2 + app/src/main/res/values-es/strings.xml | 2 + app/src/main/res/values-fr/strings.xml | 2 + app/src/main/res/values-hu/strings.xml | 2 + app/src/main/res/values-it/strings.xml | 2 + app/src/main/res/values-pl/strings.xml | 2 + app/src/main/res/values-sk/strings.xml | 2 + app/src/main/res/values/strings.xml | 2 + .../java/eu/llembas/android/AssistTest.kt | 22 +++ .../eu/llembas/android/shots/ScreenShots.kt | 7 + scripts/strings.py | 2 + scripts/strings_own.json | 16 ++ 19 files changed, 303 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a803dfe..07462bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,16 @@ is in alpha and releases come off `main`. ### Fixed +- **The wake word with the screen off: the sheet showed for a moment and was gone.** A phone + whose screen is off is locked, and a sheet opened over the lock screen asked Android to unlock + first and closed itself when that was turned down -- which is what happens when nobody is + there to unlock. Opened to listen (the wake word, a headset's button), the sheet now stays up + over the lock screen and listens. What it heard is shown as your question, with **Unlock to + send**, and Android is asked to unlock at once: a face or a fingerprint sends it. Leave it, + and it stays until the screen goes off. Nothing is asked and no answer is shown or spoken + while the phone is locked -- an answer over the lock screen is not offered. +- A conversation that was on the assistant's sheet when the phone locked is no longer readable + over the lock screen. - **A new assistant chat could start on the wrong model.** After *Continue the last chat*, *New chat* kept that chat's model instead of going back to the assistant's own; and a question sent the moment the sheet opened, before the instance had said which models it has, went to diff --git a/app/src/main/java/eu/llembas/android/assist/AssistActivity.kt b/app/src/main/java/eu/llembas/android/assist/AssistActivity.kt index 1d74faf..e677655 100644 --- a/app/src/main/java/eu/llembas/android/assist/AssistActivity.kt +++ b/app/src/main/java/eu/llembas/android/assist/AssistActivity.kt @@ -3,10 +3,13 @@ package eu.llembas.android.assist import android.Manifest import android.app.KeyguardManager import android.app.NotificationManager +import android.content.BroadcastReceiver import android.content.Context import android.content.Intent +import android.content.IntentFilter import android.os.Bundle import android.os.SystemClock +import android.view.WindowManager import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge @@ -14,6 +17,7 @@ import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf +import androidx.core.content.ContextCompat import androidx.lifecycle.lifecycleScope import eu.llembas.android.AppLanguage import eu.llembas.android.auth.Prefs @@ -22,6 +26,9 @@ import eu.llembas.android.ui.theme.LembasTheme import eu.llembas.android.wake.AssistLink import eu.llembas.android.wake.AssistPresence import eu.llembas.android.wake.WakeWordService +import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.map +import kotlinx.coroutines.launch import java.lang.ref.WeakReference /** What a way into the sheet asks for. */ @@ -51,13 +58,45 @@ enum class Opening { } } +/** How the sheet starts, given whether the phone is locked. */ +enum class LockedStart { + /** Not locked: do what the way in asked for. */ + Go, + + /** Locked, and the way in means to speak: stay over the lock screen and listen; what is heard waits for the unlock. */ + Listen, + + /** Locked, with a question handed over: it is shown and waits for the unlock. */ + Hold, + + /** Locked, anything else: ask Android to unlock first; the sheet goes if that is turned down. */ + Unlock, +} + +/** + * What a sheet opened while the phone is [locked] does. The wake word with the screen off, and a + * headset's button, open it listening ([Opening.Listen]) and nobody is there to unlock: asking + * Android to unlock first -- and closing when that is cancelled, which is what happens when + * nobody answers the lock screen -- showed the sheet for a moment and took it away again. So it + * stays and listens, and only *sending* waits for the unlock. Without the microphone's + * permission there is nothing to listen with, and its prompt needs the phone unlocked anyway. + */ +fun lockedStart(locked: Boolean, opening: Opening, question: Boolean, micAllowed: Boolean): LockedStart = when { + !locked -> LockedStart.Go + question -> LockedStart.Hold + opening == Opening.Listen && micAllowed -> LockedStart.Listen + else -> LockedStart.Unlock +} + /** * The assistant as an activity: what the Quick Settings tile, the "Ask" shortcut and a plain * `ACTION_ASSIST` open, and where the voice-interaction session hands over what needs an * activity -- a question asked over the lock screen, or the microphone's permission prompt * ([EXTRA_LISTEN]). The same sheet as the session's, in a see-through window over the app * underneath. Shown over the lock screen, but it asks Android to unlock before it sends - * anything -- and shows nothing from the account until then. + * anything -- and shows nothing from the account until then. Opened there to listen (the wake + * word, a headset's button) it stays up and listens; the question it heard is shown and waits + * for the unlock ([lockedStart]). */ class AssistActivity : ComponentActivity() { private lateinit var controller: AssistController @@ -71,6 +110,20 @@ class AssistActivity : ComponentActivity() { if (granted) controller.listen() } + /** + * The phone was unlocked by the person themselves (a fingerprint while the sheet is up): the + * question that waited is sent. And the screen went off over the lock screen: the sheet goes, + * so that it is not what the phone shows when it is next picked up. + */ + private val screen = object : BroadcastReceiver() { + override fun onReceive(context: Context, intent: Intent) { + when (intent.action) { + Intent.ACTION_USER_PRESENT -> unlockedNow() + Intent.ACTION_SCREEN_OFF -> if (locked.value) finish() + } + } + } + override fun attachBaseContext(newBase: Context) = super.attachBaseContext(AppLanguage.wrap(newBase)) override fun onCreate(savedInstanceState: Bundle?) { @@ -80,6 +133,28 @@ class AssistActivity : ComponentActivity() { controller = AssistController(this, lifecycleScope) keyguard = getSystemService(KeyguardManager::class.java) locked.value = keyguard.isKeyguardLocked + ContextCompat.registerReceiver( + this, + screen, + IntentFilter().apply { + addAction(Intent.ACTION_USER_PRESENT) + addAction(Intent.ACTION_SCREEN_OFF) + }, + ContextCompat.RECEIVER_NOT_EXPORTED, + ) + // A question waits for the unlock: Android is asked for it at once (a face or a + // fingerprint is then enough), and the sheet stays if nobody answers. + lifecycleScope.launch { + controller.state.map { it.waiting }.distinctUntilChanged().collect { waiting -> + if (waiting.isNotBlank() && locked.value) askToUnlock() + } + } + // The lock screen turns the display off after a few seconds: not in the middle of a question. + lifecycleScope.launch { + controller.state.map { it.listening || it.busy }.distinctUntilChanged().collect { on -> + if (on) window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) else window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) + } + } // Opened by the wake word: the screen comes on with it (a spoken phrase is not a touch, // so nothing else has woken the phone). woken(intent) @@ -91,15 +166,9 @@ class AssistActivity : ComponentActivity() { controller = controller, locked = locked.value, onUnlockAndAsk = { text -> - keyguard.requestDismissKeyguard( - this@AssistActivity, - object : KeyguardManager.KeyguardDismissCallback() { - override fun onDismissSucceeded() { - locked.value = false - if (text.isBlank()) controller.opened(locked = false) else controller.ask(text) - } - }, - ) + askToUnlock(askWaiting = text.isBlank()) { + if (text.isBlank()) controller.opened(locked = false) else controller.ask(text) + } }, onOpenApp = { startActivity(controller.appIntent()) @@ -107,6 +176,7 @@ class AssistActivity : ComponentActivity() { }, onNeedMic = { mic.launch(Manifest.permission.RECORD_AUDIO) }, onDismiss = { finish() }, + onUnlock = { askToUnlock() }, ) } } @@ -140,6 +210,8 @@ class AssistActivity : ComponentActivity() { override fun onStart() { super.onStart() started = true + // The phone may have locked, or been unlocked, while the sheet was out of sight. + if (keyguard.isKeyguardLocked) locked.value = true else unlockedNow() open = WeakReference(this) AssistPresence.shown() AssistLink.sheetShown(SystemClock.elapsedRealtime()) @@ -156,28 +228,37 @@ class AssistActivity : ComponentActivity() { /** * What the way in asked for: a question handed over by the session, listening (the headset's - * voice button, the widget's microphone, the Speak shortcut), the last assistant chat (the - * widget, the shortcut), or just the sheet. Over the lock screen each waits for Android to - * unlock first. + * voice button, the widget's microphone, the Speak shortcut, the wake word), the last + * assistant chat (the widget, the shortcut), or just the sheet. Over the lock screen: + * [lockedStart]. */ private fun take(intent: Intent) { val opening = Opening.of(intent) val waiting = intent.getStringExtra(EXTRA_QUESTION).orEmpty() val go = { when { - waiting.isNotBlank() -> controller.ask(waiting) + waiting.isNotBlank() -> controller.ask(waiting, spoken = intent.getBooleanExtra(EXTRA_SPOKEN, false)) opening == Opening.Continue -> controller.continueWhenReady() opening == Opening.Listen && !controller.micAllowed() -> mic.launch(Manifest.permission.RECORD_AUDIO) opening == Opening.Listen -> controller.opened(locked = false, listen = true) else -> controller.opened(locked = false) } } - if (keyguard.isKeyguardLocked) { - keyguard.requestDismissKeyguard( + val isLocked = keyguard.isKeyguardLocked + if (isLocked) locked.value = true + when (lockedStart(isLocked, opening, waiting.isNotBlank(), controller.micAllowed())) { + LockedStart.Go -> go() + + LockedStart.Listen -> controller.listenOverLock() + + // Shown, and Android asked to unlock (the collector in onCreate): it stays if nobody does. + LockedStart.Hold -> controller.hold(waiting, spoken = intent.getBooleanExtra(EXTRA_SPOKEN, false)) + + LockedStart.Unlock -> keyguard.requestDismissKeyguard( this, object : KeyguardManager.KeyguardDismissCallback() { override fun onDismissSucceeded() { - locked.value = false + unlockedNow() go() } @@ -186,12 +267,35 @@ class AssistActivity : ComponentActivity() { override fun onDismissError() = finish() }, ) - } else { - go() } } + /** + * Ask Android to unlock. When it does, the question that waited is sent (unless [askWaiting] + * says another takes its place) and [then] runs. When it does not -- nobody there, or Back + * on the lock screen -- nothing happens: the sheet stays as it is, with the way to try again. + */ + private fun askToUnlock(askWaiting: Boolean = true, then: () -> Unit = {}) { + keyguard.requestDismissKeyguard( + this, + object : KeyguardManager.KeyguardDismissCallback() { + override fun onDismissSucceeded() { + unlockedNow(askWaiting) + then() + } + }, + ) + } + + /** The phone is unlocked now, however that came about: once. */ + private fun unlockedNow(askWaiting: Boolean = true) { + if (!locked.value) return + locked.value = false + controller.unlocked(ask = askWaiting) + } + override fun onDestroy() { + runCatching { unregisterReceiver(screen) } controller.close() super.onDestroy() } @@ -199,6 +303,9 @@ class AssistActivity : ComponentActivity() { companion object { const val EXTRA_QUESTION = "eu.llembas.android.QUESTION" + /** With [EXTRA_QUESTION]: it was spoken, and is answered as a spoken one. */ + const val EXTRA_SPOKEN = "eu.llembas.android.SPOKEN" + /** Handed over by the session: ask for the microphone, then listen. */ const val EXTRA_LISTEN = "eu.llembas.android.LISTEN" diff --git a/app/src/main/java/eu/llembas/android/assist/AssistController.kt b/app/src/main/java/eu/llembas/android/assist/AssistController.kt index fee0a4b..a4bb5f1 100644 --- a/app/src/main/java/eu/llembas/android/assist/AssistController.kt +++ b/app/src/main/java/eu/llembas/android/assist/AssistController.kt @@ -88,6 +88,11 @@ data class AssistUiState( val conversation: Boolean = false, /** Whether the person let the assistant read the notifications when asked (Settings and Android both). */ val canReadNotifications: Boolean = false, + /** + * A question that waits for the phone to be unlocked: heard (or typed) over the lock screen, + * the person's own words and nothing from the account. Asked once the phone is unlocked. + */ + val waiting: String = "", ) { val screenAvailable: Boolean get() = screenText || screenshot != null val modelInfo: ModelInfo? get() = models.firstOrNull { it.id == modelId } @@ -155,6 +160,12 @@ class AssistController(private val context: Context, private val scope: Coroutin * that chat's own; a new chat goes back to this one. */ private var newChatModel: String? = null + + /** Over the lock screen: what is heard is held ([AssistUiState.waiting]), not asked. */ + private var overLock = false + + /** Whether the held question was spoken (and is answered aloud like one). */ + private var waitingSpoken = false private val ready: Job init { @@ -227,6 +238,36 @@ class AssistController(private val context: Context, private val scope: Coroutin } } + /** + * The sheet came up over the lock screen by a way in that means to speak -- the wake word, a + * headset's button: it listens, and what it hears is held for the unlock ([hold]), never + * asked from here. The reply is not for the lock screen (nothing from the account shows there). + */ + fun listenOverLock() { + overLock = true + scope.launch { + ready.join() + val s = _state.value + if (overLock && s.signedIn && s.canListen && !s.listening && s.waiting.isBlank() && micAllowed()) listen() + } + } + + /** Keep [question] until the phone is unlocked ([unlocked]). */ + fun hold(question: String, spoken: Boolean) { + if (question.isBlank()) return + overLock = true + waitingSpoken = spoken + _state.update { it.copy(waiting = question, conversation = false) } + } + + /** The phone is unlocked: the question that waited is asked now -- unless [ask] says another one takes its place. */ + fun unlocked(ask: Boolean = true) { + overLock = false + val waited = _state.value.waiting + _state.update { it.copy(waiting = "") } + if (ask && waited.isNotBlank()) ask(waited, spoken = waitingSpoken) + } + /** Open at the last assistant chat, once it is known which that is. */ fun continueWhenReady() { scope.launch { @@ -416,6 +457,7 @@ class AssistController(private val context: Context, private val scope: Coroutin /** What was said: in a conversation, "stop" (or the like) ends it; anything else is asked. */ private fun askOrStop(words: String) { + if (overLock) return hold(words, spoken = true) val phrases = context.getString(R.string.assist_stop_words).split("|") if (_state.value.conversation && isStopPhrase(words, phrases)) endConversation() else ask(words, spoken = true) } diff --git a/app/src/main/java/eu/llembas/android/assist/AssistPanel.kt b/app/src/main/java/eu/llembas/android/assist/AssistPanel.kt index 73ac5c9..ac5f4d0 100644 --- a/app/src/main/java/eu/llembas/android/assist/AssistPanel.kt +++ b/app/src/main/java/eu/llembas/android/assist/AssistPanel.kt @@ -18,6 +18,7 @@ fun AssistPanel( onOpenApp: () -> Unit, onNeedMic: () -> Unit, onDismiss: () -> Unit, + onUnlock: () -> Unit = {}, ) { val state by controller.state.collectAsState() AssistSheetFrame(onDismiss = onDismiss) { handle, _ -> @@ -27,6 +28,7 @@ fun AssistPanel( locked = locked, handle = handle, onOpenApp = onOpenApp, + onUnlock = onUnlock, onSend = { text -> if (locked) onUnlockAndAsk(text) else controller.ask(text) }, onMic = { when { diff --git a/app/src/main/java/eu/llembas/android/assist/AssistService.kt b/app/src/main/java/eu/llembas/android/assist/AssistService.kt index d2ab336..fd2952d 100644 --- a/app/src/main/java/eu/llembas/android/assist/AssistService.kt +++ b/app/src/main/java/eu/llembas/android/assist/AssistService.kt @@ -36,9 +36,11 @@ import eu.llembas.android.wake.AssistPresence import eu.llembas.android.wake.wakeLogConnected import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.cancel import kotlinx.coroutines.flow.first +import kotlinx.coroutines.flow.map import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking @@ -144,6 +146,9 @@ class LembasAssistSession(context: Context) : /** Whether this session's sheet is up, as far as the wake word's pause is concerned. */ private var up = false + /** Over the lock screen: waiting for what is heard, to hand it to the sheet's activity. */ + private var handing: Job? = null + override val lifecycle: Lifecycle get() = registry override val savedStateRegistry: SavedStateRegistry get() = saved.savedStateRegistry @@ -203,7 +208,18 @@ class LembasAssistSession(context: Context) : // this one was slow to come, goes now that this one is here. AssistActivity.closeWoken() // The wake word asks for the sheet listening, whatever Settings says about opening. - controller.opened(locked(), listen = args?.getBoolean(AssistActivity.EXTRA_LISTEN) == true) + val listen = args?.getBoolean(AssistActivity.EXTRA_LISTEN) == true + if (listen && locked()) { + // Over the lock screen too: it listens, and what it hears goes to the sheet's + // activity, which shows it and asks Android to unlock before anything is sent. + val showing = controller + showing.listenOverLock() + // Once: Android may call onShow again while the sheet is up. + handing?.cancel() + handing = scope.launch { handOff(showing.state.map { it.waiting }.first { it.isNotBlank() }, spoken = true) } + } else { + controller.opened(locked(), listen = listen) + } } /** @@ -261,10 +277,11 @@ class LembasAssistSession(context: Context) : * which asks Android to unlock first and only then sends it. The microphone's permission * prompt needs an activity too. */ - private fun handOff(text: String, listen: Boolean = false) { + private fun handOff(text: String, listen: Boolean = false, spoken: Boolean = false) { startAssistantActivity( Intent(context, AssistActivity::class.java) .putExtra(AssistActivity.EXTRA_QUESTION, text) + .putExtra(AssistActivity.EXTRA_SPOKEN, spoken) .putExtra(AssistActivity.EXTRA_LISTEN, listen) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), ) diff --git a/app/src/main/java/eu/llembas/android/assist/AssistSheet.kt b/app/src/main/java/eu/llembas/android/assist/AssistSheet.kt index b93fc2c..05109d7 100644 --- a/app/src/main/java/eu/llembas/android/assist/AssistSheet.kt +++ b/app/src/main/java/eu/llembas/android/assist/AssistSheet.kt @@ -46,6 +46,7 @@ import androidx.compose.material.icons.filled.Forum import androidx.compose.material.icons.filled.History import androidx.compose.material.icons.filled.Keyboard import androidx.compose.material.icons.filled.Lightbulb +import androidx.compose.material.icons.filled.LockOpen import androidx.compose.material.icons.filled.Mic import androidx.compose.material.icons.filled.Notifications import androidx.compose.material.icons.filled.ScreenshotMonitor @@ -197,7 +198,9 @@ fun AssistSheetFrame(onDismiss: () -> Unit, content: @Composable ColumnScope.(ha * - **the foot**: Use screen, then the microphone first -- while listening, the words as they are * heard and how loud -- or the words typed, and Send. * - * Nothing from the account is on it while the phone is [locked]: no model list, no last chat. + * Nothing from the account is on it while the phone is [locked]: no model list, no last chat, + * no question asked earlier and no answer. A question heard over the lock screen is shown -- the + * person's own words -- with the way to unlock, which sends it ([onUnlock]). */ @Composable fun ColumnScope.AssistSheetContent( @@ -206,6 +209,7 @@ fun ColumnScope.AssistSheetContent( locked: Boolean, handle: Modifier = Modifier, onOpenApp: () -> Unit = {}, + onUnlock: () -> Unit = {}, onSend: (String) -> Unit = actions::ask, onMic: () -> Unit = actions::listen, ) { @@ -267,10 +271,15 @@ fun ColumnScope.AssistSheetContent( Modifier.weight(1f).fillMaxWidth().verticalScroll(scroll).padding(horizontal = 16.dp, vertical = 8.dp), verticalArrangement = Arrangement.spacedBy(16.dp), ) { - if (state.empty) { - Starting(state, actions, locked) - } else { - state.turns.forEachIndexed { i, turn -> + when { + locked && state.waiting.isNotBlank() -> Waiting(state.waiting, onUnlock) + + // A conversation that was on the sheet when the phone locked: not for the lock screen. + locked && !state.empty -> Text(stringResource(R.string.assist_locked_line), style = MaterialTheme.typography.bodyMedium, color = palette.inkMuted) + + state.empty -> Starting(state, actions, locked) + + else -> state.turns.forEachIndexed { i, turn -> Turn(turn, last = i == state.turns.lastIndex, state, actions, onOpenApp) } } @@ -468,6 +477,31 @@ private fun QuickAction(icon: androidx.compose.ui.graphics.vector.ImageVector, l ) } +/** + * Over the lock screen: the question that was heard, as its bubble, and the one thing to do about + * it. Unlocking sends it; nothing is sent and no answer shown before. + */ +@Composable +private fun Waiting(question: String, onUnlock: () -> Unit) { + val palette = LocalPalette.current + Column(Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(8.dp)) { + Box(Modifier.fillMaxWidth(), contentAlignment = Alignment.CenterEnd) { + Surface(color = palette.bubbleUser, contentColor = palette.ink, shape = RoundedCornerShape(20.dp), modifier = Modifier.widthIn(max = 300.dp)) { + Text(question, style = MaterialTheme.typography.bodyLarge, modifier = Modifier.padding(horizontal = 14.dp, vertical = 10.dp)) + } + } + Text(stringResource(R.string.assist_locked_line), style = MaterialTheme.typography.bodyMedium, color = palette.inkMuted) + AssistChip( + onClick = onUnlock, + label = { Text(stringResource(R.string.assist_unlock_to_send)) }, + leadingIcon = { Icon(Icons.Filled.LockOpen, contentDescription = null, modifier = Modifier.size(18.dp)) }, + colors = AssistChipDefaults.assistChipColors(containerColor = palette.surfaceRaised, leadingIconContentColor = palette.accent), + border = BorderStroke(1.dp, palette.border), + modifier = Modifier.heightIn(min = 48.dp), + ) + } +} + /** One question, as a bubble on the right, and its answer at full width -- as in the app's chats. */ @Composable private fun Turn(turn: AssistTurn, last: Boolean, state: AssistUiState, actions: AssistActions, onOpenApp: () -> Unit) { diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index b872af1..0b9d04b 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -424,6 +424,8 @@ Řekněte to a odmlčte se Raději psát Zapisuji, co jste řekli… + Odemknout a odeslat + Telefon je zamčený. Dokud ho neodemknete, nic se neodešle a žádná odpověď se nezobrazí. Rozhovor Po každé odpovědi znovu poslouchám. Řekněte „stop“ a skončíme. Ukončit diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index aa62dd5..aa446d1 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -424,6 +424,8 @@ Sprechen Sie, dann kurz Pause Lieber tippen Ihr Gesagtes wird aufgeschrieben… + Entsperren und senden + Das Telefon ist gesperrt. Bis du es entsperrst, wird nichts gesendet und keine Antwort angezeigt. Im Gespräch Nach jeder Antwort höre ich wieder zu. Sag „Stopp“, um zu beenden. Beenden diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 546b794..729ce00 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -424,6 +424,8 @@ Dígalo y haga una pausa Escribir en su lugar Escribiendo lo que ha dicho… + Desbloquear para enviar + El teléfono está bloqueado. Hasta que lo desbloquees no se envía nada ni se muestra ninguna respuesta. En conversación Vuelvo a escuchar después de cada respuesta. Di «para» para terminar. Terminar diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 988724a..bfdb4d1 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -424,6 +424,8 @@ Dites-le, puis marquez une pause Taper plutôt Transcription de ce que vous avez dit… + Déverrouiller pour envoyer + Le téléphone est verrouillé. Rien n’est envoyé et aucune réponse n’est affichée tant que vous ne l’avez pas déverrouillé. En conversation J’écoute à nouveau après chaque réponse. Dites « stop » pour arrêter. Terminer diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index bfdd0b5..6e719bb 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -424,6 +424,8 @@ Mondja, aztán tartson szünetet Inkább gépelés Lejegyzem, amit mondott… + Feloldás és küldés + A telefon zárolva van. Amíg fel nem oldod, semmi sem megy el, és válasz sem jelenik meg. Beszélgetés Minden válasz után újra figyelek. A befejezéshez mondd: „állj”. Befejezés diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 68c3ae1..78a11b5 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -424,6 +424,8 @@ Lo dica, poi faccia una pausa Scrivi invece Trascrivo ciò che ha detto… + Sblocca per inviare + Il telefono è bloccato. Finché non lo sblocchi non viene inviato nulla e non viene mostrata alcuna risposta. In conversazione Ascolto di nuovo dopo ogni risposta. Di’ «basta» per finire. Termina diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 1be330d..66f5940 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -424,6 +424,8 @@ Powiedz to i zrób pauzę Zamiast tego pisz Zapisuję, co powiedziałeś… + Odblokuj, aby wysłać + Telefon jest zablokowany. Dopóki go nie odblokujesz, nic nie zostanie wysłane ani żadna odpowiedź nie zostanie pokazana. Rozmowa Po każdej odpowiedzi słucham znowu. Powiedz „stop”, aby zakończyć. Zakończ diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index 713fbba..418f0f5 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -424,6 +424,8 @@ Povedzte to a odmlčte sa Radšej písať Zapisujem, čo ste povedali… + Odomknúť a odoslať + Telefón je zamknutý. Kým ho neodomknete, nič sa neodošle a žiadna odpoveď sa nezobrazí. Rozhovor Po každej odpovedi znova počúvam. Povedzte „stop“ a skončíme. Ukončiť diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 702a952..f9d4f16 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -426,6 +426,8 @@ Say it, then pause Type instead Writing down what you said… + Unlock to send + The phone is locked. Nothing is sent, and no answer is shown, until you unlock it. In conversation I listen again after each answer. Say “stop” to end. End diff --git a/app/src/test/java/eu/llembas/android/AssistTest.kt b/app/src/test/java/eu/llembas/android/AssistTest.kt index cf85424..fdbc853 100644 --- a/app/src/test/java/eu/llembas/android/AssistTest.kt +++ b/app/src/test/java/eu/llembas/android/AssistTest.kt @@ -6,9 +6,12 @@ import eu.llembas.android.api.Step import eu.llembas.android.api.Tail import eu.llembas.android.assist.AssistController import eu.llembas.android.assist.AssistTurn +import eu.llembas.android.assist.LockedStart +import eu.llembas.android.assist.Opening import eu.llembas.android.assist.Recorder import eu.llembas.android.assist.SheetStop import eu.llembas.android.assist.isStopPhrase +import eu.llembas.android.assist.lockedStart import eu.llembas.android.assist.settle import eu.llembas.android.assist.usePhoneRecognizer import eu.llembas.android.auth.Prefs @@ -70,6 +73,25 @@ class AssistTest { assertEquals(null, AssistController.assistantModelFor("quick", null, emptyList())) } + @Test + fun overTheLockScreenAWayInThatMeansToSpeakStaysAndListens() { + // The wake word with the screen off: nobody is there to unlock. It listens; sending waits. + assertEquals(LockedStart.Listen, lockedStart(locked = true, Opening.Listen, question = false, micAllowed = true)) + // A question handed over (heard by the assistant's own sheet, or typed there) is held, not dropped. + assertEquals(LockedStart.Hold, lockedStart(locked = true, Opening.Sheet, question = true, micAllowed = true)) + assertEquals(LockedStart.Hold, lockedStart(locked = true, Opening.Listen, question = true, micAllowed = false)) + // Anything else over the lock screen asks to unlock first, as before: the plain sheet, + // the last chat (which is the account's), and the microphone's permission prompt. + assertEquals(LockedStart.Unlock, lockedStart(locked = true, Opening.Sheet, question = false, micAllowed = true)) + assertEquals(LockedStart.Unlock, lockedStart(locked = true, Opening.Continue, question = false, micAllowed = true)) + assertEquals(LockedStart.Unlock, lockedStart(locked = true, Opening.Listen, question = false, micAllowed = false)) + // Unlocked, the way in decides alone. + for (opening in Opening.entries) { + assertEquals(LockedStart.Go, lockedStart(locked = false, opening, question = false, micAllowed = true)) + assertEquals(LockedStart.Go, lockedStart(locked = false, opening, question = true, micAllowed = false)) + } + } + @Test fun aVoiceReadsOnlyTheWords() { val steps = listOf( diff --git a/app/src/test/java/eu/llembas/android/shots/ScreenShots.kt b/app/src/test/java/eu/llembas/android/shots/ScreenShots.kt index 0a3b1f1..5524f0a 100644 --- a/app/src/test/java/eu/llembas/android/shots/ScreenShots.kt +++ b/app/src/test/java/eu/llembas/android/shots/ScreenShots.kt @@ -335,6 +335,13 @@ class ScreenShots { shoot("20-assistant-answered", content = over(Fakes.assistAnswered, false)) shoot("21-assistant-writing", content = over(Fakes.assistWriting, false)) shoot("22-assistant-locked", content = over(Fakes.assistOpened, true)) + // Over the lock screen after the wake word: listening, then the question waiting for the + // unlock; and a conversation that was up when the phone locked is not shown. + shoot("22-assistant-locked-listening", content = over(Fakes.assistListening, true)) + val waiting = Fakes.assistOpened.copy(waiting = "How far is it to the next town?") + shoot("22-assistant-locked-waiting", content = over(waiting, true)) + shoot("22-assistant-locked-waiting", Phone.Small, fontScale = 1.5f, content = over(waiting, true)) + shoot("22-assistant-locked-answered", content = over(Fakes.assistAnswered, true)) shoot("23-assistant-offline", Phone.Small, content = over(Fakes.assistOffline, false)) shoot("24-assistant-conversation", content = over(Fakes.assistConversation, false)) shoot("24-assistant-conversation", Phone.Small, fontScale = 1.5f, content = over(Fakes.assistConversation, false)) diff --git a/scripts/strings.py b/scripts/strings.py index 7452e37..55ffcd3 100755 --- a/scripts/strings.py +++ b/scripts/strings.py @@ -451,6 +451,8 @@ STRINGS: dict[str, str] = { "assist_say_it": "Say it, then pause", "assist_type": "Type instead", "assist_writing_down": "Writing down what you said…", + "assist_unlock_to_send": "Unlock to send", + "assist_locked_line": "The phone is locked. Nothing is sent, and no answer is shown, until you unlock it.", "assist_conversation": "In conversation", "assist_conversation_line": "I listen again after each answer. Say “stop” to end.", "assist_conversation_end": "End", diff --git a/scripts/strings_own.json b/scripts/strings_own.json index 06158bb..d47121e 100644 --- a/scripts/strings_own.json +++ b/scripts/strings_own.json @@ -42,6 +42,7 @@ "assist_conversation_line": "Po každé odpovědi znovu poslouchám. Řekněte „stop“ a skončíme.", "assist_help": "Podržením tlačítka napájení otevřete asistenta nad libovolnou aplikací; nebo použijte dlaždici v Rychlém nastavení.", "assist_hint": "Zeptejte se na cokoli", + "assist_locked_line": "Telefon je zamčený. Dokud ho neodemknete, nic se neodešle a žádná odpověď se nezobrazí.", "assist_no_model": "Žádný model", "assist_notifications": "Shrnout má oznámení", "assist_notifications_phrases": "moje oznámení|má oznámení|mých oznámení|moje notifikace", @@ -66,6 +67,7 @@ "assist_stop_reading": "Přestat číst", "assist_stop_words": "stop|dost|to je vše|to je všechno|konec|nashledanou|díky to je vše|zrušit|stop stop", "assist_type": "Raději psát", + "assist_unlock_to_send": "Odemknout a odeslat", "assist_use_screen": "Použít obrazovku", "assist_voice_reply_off": "Hlasová odpověď je vypnutá", "assist_voice_reply_on": "Hlasová odpověď je zapnutá", @@ -427,6 +429,7 @@ "assist_conversation_line": "Nach jeder Antwort höre ich wieder zu. Sag „Stopp“, um zu beenden.", "assist_help": "Halten Sie die Ein-/Aus-Taste, um den Assistenten über jeder App zu öffnen, oder nutzen Sie die Kachel in den Schnelleinstellungen.", "assist_hint": "Fragen Sie irgendetwas", + "assist_locked_line": "Das Telefon ist gesperrt. Bis du es entsperrst, wird nichts gesendet und keine Antwort angezeigt.", "assist_no_model": "Kein Modell", "assist_notifications": "Meine Benachrichtigungen zusammenfassen", "assist_notifications_phrases": "meine benachrichtigungen|meinen benachrichtigungen|meiner benachrichtigungen", @@ -451,6 +454,7 @@ "assist_stop_reading": "Vorlesen beenden", "assist_stop_words": "stopp|stop|das wars|das war's|das ist alles|genug|ende|tschüss|auf wiedersehen|danke das wars|abbrechen", "assist_type": "Lieber tippen", + "assist_unlock_to_send": "Entsperren und senden", "assist_use_screen": "Bildschirm verwenden", "assist_voice_reply_off": "Sprachantwort ist aus", "assist_voice_reply_on": "Sprachantwort ist an", @@ -813,6 +817,7 @@ "assist_conversation_line": "Vuelvo a escuchar después de cada respuesta. Di «para» para terminar.", "assist_help": "Mantenga pulsado el botón de encendido para abrir el asistente sobre cualquier app, o use el mosaico de Ajustes rápidos.", "assist_hint": "Pregunte lo que quiera", + "assist_locked_line": "El teléfono está bloqueado. Hasta que lo desbloquees no se envía nada ni se muestra ninguna respuesta.", "assist_no_model": "Sin modelo", "assist_notifications": "Resumir mis notificaciones", "assist_notifications_phrases": "mis notificaciones", @@ -837,6 +842,7 @@ "assist_stop_reading": "Dejar de leer", "assist_stop_words": "para|stop|basta|eso es todo|ya está|adiós|terminar|fin|gracias eso es todo|cancelar", "assist_type": "Escribir en su lugar", + "assist_unlock_to_send": "Desbloquear para enviar", "assist_use_screen": "Usar la pantalla", "assist_voice_reply_off": "Respuesta por voz desactivada", "assist_voice_reply_on": "Respuesta por voz activada", @@ -1198,6 +1204,7 @@ "assist_conversation_line": "J’écoute à nouveau après chaque réponse. Dites « stop » pour arrêter.", "assist_help": "Maintenez le bouton marche/arrêt pour ouvrir l’assistant par-dessus n’importe quelle app, ou utilisez la tuile des Réglages rapides.", "assist_hint": "Demandez n'importe quoi", + "assist_locked_line": "Le téléphone est verrouillé. Rien n’est envoyé et aucune réponse n’est affichée tant que vous ne l’avez pas déverrouillé.", "assist_no_model": "Aucun modèle", "assist_notifications": "Résumer mes notifications", "assist_notifications_phrases": "mes notifications", @@ -1222,6 +1229,7 @@ "assist_stop_reading": "Arrêter la lecture", "assist_stop_words": "stop|arrête|c'est tout|ça suffit|au revoir|fin|terminé|merci c'est tout|annuler", "assist_type": "Taper plutôt", + "assist_unlock_to_send": "Déverrouiller pour envoyer", "assist_use_screen": "Utiliser l’écran", "assist_voice_reply_off": "Réponse vocale désactivée", "assist_voice_reply_on": "Réponse vocale activée", @@ -1584,6 +1592,7 @@ "assist_conversation_line": "Minden válasz után újra figyelek. A befejezéshez mondd: „állj”.", "assist_help": "Tartsa lenyomva a bekapcsológombot, hogy bármely alkalmazás fölött megnyissa az asszisztenst, vagy használja a Gyorsbeállítások csempét.", "assist_hint": "Kérdezzen bármit", + "assist_locked_line": "A telefon zárolva van. Amíg fel nem oldod, semmi sem megy el, és válasz sem jelenik meg.", "assist_no_model": "Nincs modell", "assist_notifications": "Értesítéseim összefoglalása", "assist_notifications_phrases": "értesítéseim|értesítéseimet|az értesítéseimről", @@ -1608,6 +1617,7 @@ "assist_stop_reading": "Felolvasás leállítása", "assist_stop_words": "állj|stop|ennyi|ennyi volt|elég|vége|viszlát|köszönöm ennyi|mégse", "assist_type": "Inkább gépelés", + "assist_unlock_to_send": "Feloldás és küldés", "assist_use_screen": "Képernyő használata", "assist_voice_reply_off": "A hangos válasz ki van kapcsolva", "assist_voice_reply_on": "A hangos válasz be van kapcsolva", @@ -1970,6 +1980,7 @@ "assist_conversation_line": "Ascolto di nuovo dopo ogni risposta. Di’ «basta» per finire.", "assist_help": "Tenga premuto il tasto di accensione per aprire l’assistente sopra qualsiasi app, oppure usi il riquadro delle Impostazioni rapide.", "assist_hint": "Chiedi qualsiasi cosa", + "assist_locked_line": "Il telefono è bloccato. Finché non lo sblocchi non viene inviato nulla e non viene mostrata alcuna risposta.", "assist_no_model": "Nessun modello", "assist_notifications": "Riassumi le mie notifiche", "assist_notifications_phrases": "le mie notifiche|mie notifiche", @@ -1994,6 +2005,7 @@ "assist_stop_reading": "Interrompi la lettura", "assist_stop_words": "basta|stop|è tutto|fine|ciao|arrivederci|grazie è tutto|annulla|smetti", "assist_type": "Scrivi invece", + "assist_unlock_to_send": "Sblocca per inviare", "assist_use_screen": "Usa lo schermo", "assist_voice_reply_off": "Risposta vocale disattivata", "assist_voice_reply_on": "Risposta vocale attiva", @@ -2355,6 +2367,7 @@ "assist_conversation_line": "Po każdej odpowiedzi słucham znowu. Powiedz „stop”, aby zakończyć.", "assist_help": "Przytrzymaj przycisk zasilania, aby otworzyć asystenta nad dowolną aplikacją, albo użyj kafelka w Szybkich ustawieniach.", "assist_hint": "Zapytaj o cokolwiek", + "assist_locked_line": "Telefon jest zablokowany. Dopóki go nie odblokujesz, nic nie zostanie wysłane ani żadna odpowiedź nie zostanie pokazana.", "assist_no_model": "Brak modelu", "assist_notifications": "Podsumuj moje powiadomienia", "assist_notifications_phrases": "moje powiadomienia|moich powiadomień|moje notyfikacje", @@ -2379,6 +2392,7 @@ "assist_stop_reading": "Przestań czytać", "assist_stop_words": "stop|wystarczy|to wszystko|koniec|do widzenia|dzięki to wszystko|anuluj|przestań", "assist_type": "Zamiast tego pisz", + "assist_unlock_to_send": "Odblokuj, aby wysłać", "assist_use_screen": "Użyj ekranu", "assist_voice_reply_off": "Odpowiedź głosowa wyłączona", "assist_voice_reply_on": "Odpowiedź głosowa włączona", @@ -2740,6 +2754,7 @@ "assist_conversation_line": "Po každej odpovedi znova počúvam. Povedzte „stop“ a skončíme.", "assist_help": "Podržaním tlačidla napájania otvoríte asistenta nad ľubovoľnou aplikáciou; alebo použite dlaždicu v Rýchlych nastaveniach.", "assist_hint": "Spýtajte sa na čokoľvek", + "assist_locked_line": "Telefón je zamknutý. Kým ho neodomknete, nič sa neodošle a žiadna odpoveď sa nezobrazí.", "assist_no_model": "Žiadny model", "assist_notifications": "Zhrnúť moje oznámenia", "assist_notifications_phrases": "moje oznámenia|mojich oznámení|moje notifikácie", @@ -2764,6 +2779,7 @@ "assist_stop_reading": "Prestať čítať", "assist_stop_words": "stop|dosť|to je všetko|koniec|dovidenia|ďakujem to je všetko|zrušiť|prestaň", "assist_type": "Radšej písať", + "assist_unlock_to_send": "Odomknúť a odoslať", "assist_use_screen": "Použiť obrazovku", "assist_voice_reply_off": "Hlasová odpoveď je vypnutá", "assist_voice_reply_on": "Hlasová odpoveď je zapnutá",