Make conversation activity launchable (#3254)

* Make conversation activity launchable

* Use better launcher icons per review comments

* Review comments
This commit is contained in:
Daniel Shokouhi 2023-01-24 19:27:04 -08:00 committed by GitHub
parent 96cf4f82a3
commit 65696e891b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 44 additions and 6 deletions

View file

@ -1013,4 +1013,6 @@
<string name="no_conversation_support">You must be at least on Home Assistant 2023.1 and have the conversation integration enabled</string>
<string name="conversation">Conversation</string>
<string name="assist">Assist</string>
<string name="not_registered">Please launch the Home Assistant app and login before you can use the assist feature.</string>
<string name="ha_assist">HA: Assist</string>
</resources>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@android:color/holo_red_dark"/>
<foreground android:drawable="@drawable/ic_assist_launcher_foreground"/>
</adaptive-icon>

View file

@ -87,7 +87,15 @@
<activity
android:name=".conversation.ConversationActivity"
android:exported="true" />
android:icon="@mipmap/ic_assist_launcher"
android:label="@string/ha_assist"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Tiles -->
<service
android:name=".tiles.ShortcutsTile"
@ -117,7 +125,7 @@
</service>
<service
android:name=".tiles.ConversationTile"
android:label="@string/conversation"
android:label="@string/assist"
android:permission="com.google.android.wearable.permission.BIND_TILE_PROVIDER"
android:exported="true">
<intent-filter>

View file

@ -33,6 +33,9 @@ class ConversationViewModel @Inject constructor(
var isHapticEnabled = mutableStateOf(false)
private set
var isRegistered by mutableStateOf(false)
private set
fun getConversation() {
viewModelScope.launch {
conversationResult = integrationUseCase.getConversation(speechResult) ?: ""
@ -40,6 +43,7 @@ class ConversationViewModel @Inject constructor(
}
suspend fun isSupportConversation() {
isRegistered = integrationUseCase.isRegistered()
supportsConversation =
integrationUseCase.isHomeAssistantVersionAtLeast(2023, 1, 0) &&
webSocketRepository.getConfig()?.components?.contains("conversation") == true

View file

@ -55,10 +55,11 @@ fun ConversationResultView(
Spacer(Modifier.padding(24.dp))
SpeechBubble(
text = conversationViewModel.speechResult.ifEmpty {
if (conversationViewModel.supportsConversation)
stringResource(R.string.no_results)
else
stringResource(R.string.no_conversation_support)
when {
(conversationViewModel.supportsConversation) -> stringResource(R.string.no_results)
(!conversationViewModel.isRegistered) -> stringResource(R.string.not_registered)
else -> stringResource(R.string.no_conversation_support)
}
},
false
)

View file

@ -0,0 +1,13 @@
<!-- drawable/comment_processing_outline.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group android:scaleX="0.45466667"
android:scaleY="0.45466667"
android:translateX="6.544"
android:translateY="6.544">
<path android:fillColor="#fff" android:pathData="M9,22A1,1 0 0,1 8,21V18H4A2,2 0 0,1 2,16V4C2,2.89 2.9,2 4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H13.9L10.2,21.71C10,21.9 9.75,22 9.5,22V22H9M10,16V19.08L13.08,16H20V4H4V16H10M17,11H15V9H17V11M13,11H11V9H13V11M9,11H7V9H9V11Z" />
</group>
</vector>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/colorAccent"/>
<foreground android:drawable="@drawable/ic_assist_launcher_foreground"/>
</adaptive-icon>