mirror of
https://github.com/home-assistant/android
synced 2024-09-06 17:23:32 +00:00
Update conversation tile text and icon (#3209)
* Update conversation tile text and icon * Minor design tweaks: increase corner radius, push down icon * Update per review comment
This commit is contained in:
parent
d6fbc1e95d
commit
a5cbe04315
|
@ -1001,7 +1001,7 @@
|
|||
<string name="tile_vibrate">Vibrate when clicked</string>
|
||||
<string name="tile_auth_required">Requires unlocked device</string>
|
||||
<string name="no_results">No results yet</string>
|
||||
<string name="speak">Speak</string>
|
||||
<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>
|
||||
</resources>
|
||||
|
|
|
@ -6,11 +6,12 @@ import androidx.wear.tiles.ColorBuilders.argb
|
|||
import androidx.wear.tiles.DimensionBuilders.dp
|
||||
import androidx.wear.tiles.DimensionBuilders.sp
|
||||
import androidx.wear.tiles.LayoutElementBuilders
|
||||
import androidx.wear.tiles.LayoutElementBuilders.Layout
|
||||
import androidx.wear.tiles.LayoutElementBuilders.LayoutElement
|
||||
import androidx.wear.tiles.LayoutElementBuilders.VERTICAL_ALIGN_CENTER
|
||||
import androidx.wear.tiles.ModifiersBuilders
|
||||
import androidx.wear.tiles.RequestBuilders.ResourcesRequest
|
||||
import androidx.wear.tiles.RequestBuilders.TileRequest
|
||||
import androidx.wear.tiles.ResourceBuilders
|
||||
import androidx.wear.tiles.ResourceBuilders.ImageResource
|
||||
import androidx.wear.tiles.ResourceBuilders.Resources
|
||||
import androidx.wear.tiles.TileBuilders.Tile
|
||||
import androidx.wear.tiles.TileService
|
||||
|
@ -37,7 +38,7 @@ class ConversationTile : TileService() {
|
|||
.setTimeline(
|
||||
Timeline.Builder().addTimelineEntry(
|
||||
TimelineEntry.Builder().setLayout(
|
||||
Layout.Builder().setRoot(
|
||||
LayoutElementBuilders.Layout.Builder().setRoot(
|
||||
boxLayout()
|
||||
).build()
|
||||
).build()
|
||||
|
@ -49,6 +50,16 @@ class ConversationTile : TileService() {
|
|||
serviceScope.future {
|
||||
Resources.Builder()
|
||||
.setVersion("1")
|
||||
.addIdToImageMapping(
|
||||
"image",
|
||||
ImageResource.Builder()
|
||||
.setAndroidResourceByResId(
|
||||
ResourceBuilders.AndroidImageResourceByResId.Builder()
|
||||
.setResourceId(io.homeassistant.companion.android.R.drawable.ic_comment_processing_outline)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
}
|
||||
|
||||
|
@ -58,11 +69,10 @@ class ConversationTile : TileService() {
|
|||
serviceJob.cancel()
|
||||
}
|
||||
|
||||
private fun boxLayout(): LayoutElement =
|
||||
private fun boxLayout(): LayoutElementBuilders.LayoutElement =
|
||||
LayoutElementBuilders.Box.Builder()
|
||||
.addContent(tappableElement())
|
||||
.setHeight(dp(50f))
|
||||
.setWidth(dp(100f))
|
||||
.addContent(rowElement())
|
||||
.setHeight(dp(40f))
|
||||
.setModifiers(
|
||||
ModifiersBuilders.Modifiers.Builder()
|
||||
.setClickable(
|
||||
|
@ -83,22 +93,60 @@ class ConversationTile : TileService() {
|
|||
.setColor(argb(ContextCompat.getColor(baseContext, R.color.colorAccent)))
|
||||
.setCorner(
|
||||
ModifiersBuilders.Corner.Builder()
|
||||
.setRadius(dp(10f))
|
||||
.setRadius(dp(20f))
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
.setPadding(
|
||||
ModifiersBuilders.Padding.Builder()
|
||||
.setStart(dp(16f))
|
||||
.setEnd(dp(24f))
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
|
||||
private fun tappableElement(): LayoutElement =
|
||||
private fun tappableElement(): LayoutElementBuilders.LayoutElement =
|
||||
LayoutElementBuilders.Text.Builder()
|
||||
.setText(getString(R.string.speak))
|
||||
.setText(getString(R.string.assist))
|
||||
.setFontStyle(
|
||||
LayoutElementBuilders.FontStyle.Builder()
|
||||
.setSize(sp(30f))
|
||||
.setSize(sp(24f))
|
||||
.build()
|
||||
)
|
||||
.setModifiers(
|
||||
ModifiersBuilders.Modifiers.Builder()
|
||||
.setPadding(
|
||||
ModifiersBuilders.Padding.Builder()
|
||||
.setStart(dp(8f))
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
|
||||
private fun imageElement(): LayoutElementBuilders.LayoutElement =
|
||||
LayoutElementBuilders.Image.Builder()
|
||||
.setResourceId("image")
|
||||
.setWidth(dp(24f))
|
||||
.setHeight(dp(24f))
|
||||
.setModifiers(
|
||||
ModifiersBuilders.Modifiers.Builder()
|
||||
.setPadding(
|
||||
ModifiersBuilders.Padding.Builder()
|
||||
.setTop(dp(2f))
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
|
||||
private fun rowElement(): LayoutElementBuilders.LayoutElement =
|
||||
LayoutElementBuilders.Row.Builder()
|
||||
.addContent(imageElement())
|
||||
.addContent(tappableElement())
|
||||
.setVerticalAlignment(VERTICAL_ALIGN_CENTER)
|
||||
.build()
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 14 KiB |
8
wear/src/main/res/drawable/ic_comment_processing_outline.xml
Executable file
8
wear/src/main/res/drawable/ic_comment_processing_outline.xml
Executable file
|
@ -0,0 +1,8 @@
|
|||
<!-- drawable/comment_processing_outline.xml -->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<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" />
|
||||
</vector>
|
Loading…
Reference in a new issue