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

[Android] Always apply configured Actions.IconSize #5704

Merged
merged 7 commits into from
Apr 30, 2021
Merged

Conversation

golddove
Copy link
Member

@golddove golddove commented Apr 21, 2021

Related Issue

Fixes #5567

Description

Fixes Android renderer to match JS behavior of applying HostConfig.ActionsConfig.IconSize always, not just when placement is above title. Previously, we were setting image height to match text height when placement is left of title.

However, this change results in a poor default (see screenshot below), because the default is arbitrarily set to 30 in the shared model. So, any host currently using iconPlacement: LeftOfTitle will need to newly configure their iconSize to restore the previous size.

If this is not a default we want, we could remove the arbitrary default in the object model (and make it optional), to allow the renderer to use a good default (i.e. icon height matches text height).

Sample Card

v1.2\Elements\Action.IconUrl.TwoActions

How Verified

(using default host config values)

Before PR:
image

After PR:
image

Microsoft Reviewers: Open in CodeFlow

@dclaux
Copy link
Member

dclaux commented Apr 21, 2021

I think the choice of 30px as a default is what is problematic here. The typical size of a button icon is 16px. I think you should change the default to 16px, which is what JS uses.

@jwoo-msft
Copy link
Member

I think the choice of 30px as a default is what is problematic here. The typical size of a button icon is 16px. I think you should change the default to 16px, which is what JS uses.

@dclaux
mobile platforms (iOS & Android) and probably UWP use the title height of the button for the image height when iconPlacement is LeftOfTitle. I don't have objections to change to use the iconsize for the icon even it's for LeftOfTitle. We probably have good reasons why we did this way. c.c. @jonmill @matthidinger @RebeccaAnne @paulcam206 @almaasrawi @golddove

@RebeccaAnne
Copy link
Contributor

My recollection was that it was intentional to use text height rather than icon size when the icon is left of the title, and in general I think that's a good approach. What would the above title button look like if we size the default down to 16? I suspect it would look a little too small in that case. For what it's worth the default of 30 is consistent with the documentation (ActionsConfig).

That said, it is weird to have an iconSize property but not always respect it (especially given that that behavior is not documented). I like @golddove's idea of having it be optional and having the renderer default to text height for left of title and the documented default (30) for above title. That seems like the best of both worlds in terms of letting us do the reasonable default but also respecting any explicit value from the host.

In any case, if we stick with the approach in this PR we'll need to check the other platforms as well as I suspect everyone except JavaScript is doing it the way Android was. We should also make sure to update the docs with whatever we land on.

@golddove
Copy link
Member Author

What would the above title button look like if we size the default down to 16? I suspect it would look a little too small in that case. For what it's worth the default of 30 is consistent with the documentation (ActionsConfig).

16 looks fine on Android:

image

@dclaux
Copy link
Member

dclaux commented Apr 22, 2021

I only suggested using 16 in place of 30 where 30 is currently used as a default, not to change other logic such as using title height.

@golddove
Copy link
Member Author

Documenting outcome from standup: match current JS behavior (i.e. always respect iconSize, and default to 16 when unset)

@@ -292,7 +292,7 @@ namespace AdaptiveSharedNamespace
unsigned int maxActions = 5;
Spacing spacing = Spacing::Default;
IconPlacement iconPlacement = IconPlacement::AboveTitle;
unsigned int iconSize = 30;
unsigned int iconSize = 16;
Copy link
Member

Choose a reason for hiding this comment

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

@golddove
How would we know if the iconSize is not set? Shouldn't we change it to optional to tell if it has a value?

Copy link
Member Author

Choose a reason for hiding this comment

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

The plan of record was to always respect iconSize.

Copy link
Contributor

@RebeccaAnne RebeccaAnne left a comment

Choose a reason for hiding this comment

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

If you haven't already could you log bugs to update the other renderers to use this behavior and reference this PR so we've got breadcrumbs back to the decision making? Otherwise looks good.

@golddove golddove requested a review from jwoo-msft April 29, 2021 17:22
@ghost ghost removed the Needs: Author Feedback label Apr 29, 2021
@golddove
Copy link
Member Author

If you haven't already could you log bugs to update the other renderers to use this behavior and reference this PR so we've got breadcrumbs back to the decision making? Otherwise looks good.

Logged UWP bug, and added comment to existing iOS bug,

@golddove golddove enabled auto-merge (squash) April 29, 2021 17:24
@golddove golddove merged commit 0bc5850 into main Apr 30, 2021
@golddove golddove deleted the golddove/5567 branch April 30, 2021 02:10
golddove added a commit that referenced this pull request May 4, 2021
* [Android] Always apply configured Actions.IconSize

* Default to 16

* Updated specs

Co-authored-by: Adaptive Cards Specs CI <donotreply@microsoft.com>
Co-authored-by: RebeccaAnne <rebecch@microsoft.com>
michaelfarnsworth pushed a commit to michaelfarnsworth/AdaptiveCards that referenced this pull request Nov 10, 2022
* [Android] Always apply configured Actions.IconSize

* Default to 16

* Updated specs

Co-authored-by: Adaptive Cards Specs CI <donotreply@microsoft.com>
Co-authored-by: RebeccaAnne <rebecch@microsoft.com>
rankush pushed a commit to rankush/AdaptiveCards that referenced this pull request May 8, 2024
* [Android] Always apply configured Actions.IconSize

* Default to 16

* Updated specs

Co-authored-by: Adaptive Cards Specs CI <donotreply@microsoft.com>
Co-authored-by: RebeccaAnne <rebecch@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Android][iconSize is not honoured for iconUrl using resource resolver]
4 participants