Skip to content

Commit

Permalink
Wear Assist: show login when logged out, scroll first item into view (#…
Browse files Browse the repository at this point in the history
…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)
  • Loading branch information
jpelgrom committed Jan 30, 2024
1 parent f1d07a1 commit f3071e7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
}

Expand Down
Expand Up @@ -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) {
Expand Down
Expand Up @@ -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) {
Expand All @@ -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
Expand Down

0 comments on commit f3071e7

Please sign in to comment.