Wear Assist: show login when logged out, scroll first item into view (#4174)

- Update Assist on Wear to automatically open the login screen when logged out, instead of asking the user to close and login, to prevent text being cut off issues
 - Add another item at the top of Assist on Wear to allow the pipeline selector to be scrolled into the center of the screen (the first item cannot be scrolled into the center of the screen)
This commit is contained in:
Joris Pelgröm 2024-01-30 19:43:49 +01:00 committed by GitHub
parent f1d07a1b6e
commit f3071e79e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 1 deletions

View file

@ -17,6 +17,7 @@ import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.lifecycle.lifecycleScope
import dagger.hilt.android.AndroidEntryPoint
import io.homeassistant.companion.android.conversation.views.LoadAssistView
import io.homeassistant.companion.android.home.HomeActivity
import kotlinx.coroutines.launch
@AndroidEntryPoint
@ -53,6 +54,9 @@ class ConversationActivity : ComponentActivity() {
val launchIntent = conversationViewModel.onCreate(hasRecordingPermission())
if (launchIntent) {
launchVoiceInputIntent()
} else if (!conversationViewModel.isRegistered()) {
startActivity(HomeActivity.newInstance(this@ConversationActivity))
finish()
}
}

View file

@ -129,6 +129,8 @@ class ConversationViewModel @Inject constructor(
return false
}
fun isRegistered(): Boolean = serverManager.isRegistered()
override fun getInput(): AssistInputMode = inputMode
override fun setInput(inputMode: AssistInputMode) {

View file

@ -121,7 +121,7 @@ fun ConversationResultView(
val scrollState = rememberScalingLazyListState()
LaunchedEffect(conversation.size) {
scrollState.scrollToItem(
if (inputMode != AssistViewModelBase.AssistInputMode.BLOCKED) conversation.size else (conversation.size - 1)
if (inputMode != AssistViewModelBase.AssistInputMode.BLOCKED) (conversation.size + 1) else conversation.size
)
}
if (hapticFeedback) {
@ -135,6 +135,9 @@ fun ConversationResultView(
}
ThemeLazyColumn(state = scrollState) {
item {
Spacer(Modifier.size(1.dp)) // This exists to allow the next item to be centered
}
item {
if (currentPipeline != null) {
val textColor = LocalContentColor.current.copy(alpha = 0.38f) // disabled/hint alpha