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] Fix ImageButton Padding the third #25223

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aheubusch
Copy link
Contributor

Description of Change

Improve the workaround (#22298) for the iffy Android ShapeImageView contentPadding/padding handling.
The underlying problem is that ShapeImageView updates Padding in onMeasure leading to a double padding. The previous workaround reset the Padding after one eventloop hoping that onMeasure was called in the meantime. This worked for most cases but not all. The "improved" workaround overrides onMeasure and resets the Padding as soon as it was set.

I ran all ImageButton tests I could find and they are all green. So thats a good sign.

Issues Fixed

Fixes #25201
Fixes #16713
Fixes #18001
Fixes #13101

@aheubusch aheubusch requested a review from a team as a code owner October 11, 2024 22:46
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Oct 11, 2024
Copy link
Contributor

Hey there @aheubusch! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

platformButton.SetContentPadding((int)padding.Left, (int)padding.Top, (int)padding.Right, (int)padding.Bottom);
platformButton.SetPadding(0, 0, 0, 0);

// Just like before, the bugs are not done. This needs to trigger a re-calculation of
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mattleibow You have added this part (ShapeAppearanceModel) in #22298. I am not sure if I can just remove it. None of the tests that looked relevant failed on my machine.

Copy link
Member

Choose a reason for hiding this comment

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

I am scared tbh. I forget the corner cases where this happens - and they yield is especially scary. I think I was going off the fixes the native side was doing.

The current test set may not be enough and we will have to go remove this and see what breaks manually, and then make your change to see if it fixes it.

@jsuarezruiz
Copy link
Contributor

jsuarezruiz commented Oct 14, 2024

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@aheubusch
Copy link
Contributor Author

Not sure if the test failure are because of this PR. They all fail with a System.TimeoutException.

@aheubusch aheubusch closed this Oct 23, 2024
@aheubusch aheubusch deleted the android_imagebutton_padding branch October 23, 2024 07:48
@aheubusch aheubusch restored the android_imagebutton_padding branch October 23, 2024 08:34
@aheubusch aheubusch reopened this Oct 23, 2024
@jfversluis
Copy link
Member

/rebase

Remove ShapeableImageView Padding immediately after it is set in its
onMeasure method to avoid double padding (ContentPadding + Padding).
@github-actions github-actions bot force-pushed the android_imagebutton_padding branch from 0a0de1e to 8a3a074 Compare December 6, 2024 15:02
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Member

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

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

I am super scared with this as the ImageButton was super fragile and I think I have seen padding issues but was super hard to repro in a test or I was not able to reliably repro.

I added tests as I did things, and TJ probably added more. But, I am not sure there are enough.

This comment does not help move the PR along, but I need to play a bit more and try and repro the issues that required the terrible hacks.

platformButton.SetContentPadding((int)padding.Left, (int)padding.Top, (int)padding.Right, (int)padding.Bottom);
platformButton.SetPadding(0, 0, 0, 0);

// Just like before, the bugs are not done. This needs to trigger a re-calculation of
Copy link
Member

Choose a reason for hiding this comment

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

I am scared tbh. I forget the corner cases where this happens - and they yield is especially scary. I think I was going off the fixes the native side was doing.

The current test set may not be enough and we will have to go remove this and see what breaks manually, and then make your change to see if it fixes it.

@BlueRaja
Copy link

Any chance to get this in for the next release? Both Border and Padding on ImageButton are still broken, with no known workaround. This seems like pretty basic functionality to just straight up not work at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants