Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI updates for ButtonWidget #4594

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

PizzaMarinara
Copy link

@PizzaMarinara PizzaMarinara commented Aug 26, 2024

Summary

Implementation of a fresher look for Button widget as suggested in #4549, adding a parameter to make the icon's color customizable.

Screenshots

Config:

Day:

Night:

Dynamic:

Transparent:

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#1097

Any other notes

Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @PizzaMarinara

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@bgoncal
Copy link
Member

bgoncal commented Aug 27, 2024

Thats looks nice! I see some different top and leading padding, can you check that? For reference, this is the iOS view https://github.com/home-assistant/iOS/blob/master/Sources/Extensions/Widgets/Common/WidgetBasicView.swift
Also, how big of a change it would be to allow multiple items inside the same widget like iOS has?

@jpelgrom
Copy link
Member

Also, how big of a change it would be to allow multiple items inside the same widget like iOS has?

Quite big, let's not increase the scope of the PR here. (And personally, I think a combined widget with entity state, which has an easy toggle/run instead of requiring you to configure each action, would make more sense for large amounts of items.)

@PizzaMarinara
Copy link
Author

Thats looks nice! I see some different top and leading padding, can you check that? For reference, this is the iOS view https://github.com/home-assistant/iOS/blob/master/Sources/Extensions/Widgets/Common/WidgetBasicView.swift Also, how big of a change it would be to allow multiple items inside the same widget like iOS has?

Hi @bgoncal, the different padding is totally a personal preference given the default appearance of the widget is more rectangular shaped I tried leaving less padding horizontally than vertically to allow a little bit more space for the label. I can change it to an uniform padding (given the widget can be also resized). Also as @jpelgrom mentioned, I assume a multi-item widget would be a completely different kind of widget, with its own configuration so possibly a bit too outside the scope of the PR.

@bgoncal
Copy link
Member

bgoncal commented Aug 27, 2024

Agree on having a separate PR for multiple items widget ✅
About the UI, it's not really personal preference, you are proposing a change to align it more with iOS widget style, so, while for the text I may agree it is useful to have more space, for the icon it looks misaligned when it's top marging is different from it's leading margin, unless this is something common in Material Design and I am unaware

app/src/main/res/layout/widget_button.xml Outdated Show resolved Hide resolved
app/src/main/res/layout/widget_button.xml Outdated Show resolved Hide resolved
android:id="@+id/widgetImageButtonLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingVertical="4dp"
android:layout_height="wrap_content"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The size change will create visual problems with longer labels and/or smaller widget sizes:
Widget with text overlapping icon
(default size, and this label isn't even that long)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has not been resolved. It may be less obvious now, but text is cut off (note the bottom of the g/p), and especially for users with larger font sizes configured this will happen quite easily.
image

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I figured the issue is now caused by the text's size rather than its layout overlapping the above icon. I can reproduce it only if I manually set my font size in the phone's setting to the maximum, otherwise it looks good to me. Is that the case here as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is on the default text and display size for me (Pixel 7a; text size 2/7, display size 2/5).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see this review comment.

app/src/main/res/layout/widget_button_configure.xml Outdated Show resolved Hide resolved
app/src/main/res/layout/widget_button_configure.xml Outdated Show resolved Hide resolved
@PizzaMarinara
Copy link
Author

PizzaMarinara commented Aug 27, 2024

Added a commit that fixes most of @jpelgrom's remarks.

Why use translationZ which is relative, instead of elevation?

I believe they're equivalent? I'm not sure if there's any specific reason to use either.

Copy link
Member

@jpelgrom jpelgrom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The layout changes in the latest commit completely change the design, no longer being close to the requested tile design, with small text and with (too) narrow padding. If I'm being honest, it looks broken even without the tile design reference.

Updated tile design: blue circle with a black icon in the top left, on a yellow dynamic color background, with small text right next to the curved corner

@@ -228,6 +233,10 @@ class ButtonWidget : AppWidgetProvider() {
// Render the icon into the Button's ImageView
setImageViewBitmap(R.id.widgetImageButton, icon.toBitmap(width, height))

widget?.iconColor?.let {
setCustomColorToIcon(it, this)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will overwrite the color set to the icon in line 204/206, which is fine if you have set a custom color but when using the transparent theme it might create a mismatch (black icon on a colored circle with white text, while the option says it'll color text + icon, and it just looks odd).
Transparent widget: blue circle with black icon, and white text below

app/src/main/res/drawable/rounded_image_background.xml Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants