mirror of
https://github.com/home-assistant/android
synced 2024-10-01 13:53:53 +00:00
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:
parent
f1d07a1b6e
commit
f3071e79e6
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue