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] Allow to update Entry Background (once established) #12227

Merged
merged 44 commits into from
Apr 14, 2023
Merged

Conversation

jsuarezruiz
Copy link
Contributor

@jsuarezruiz jsuarezruiz commented Dec 20, 2022

Description of Change

Allow to update Entry Background.

fix-12212

Captura de pantalla 2022-12-20 a las 14 12 46

Issues Fixed

Fixes #12212
Fixes #12991
Fixes #14600

@jsuarezruiz jsuarezruiz added t/bug Something isn't working platform/android 🤖 area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing labels Dec 20, 2022
@jsuarezruiz jsuarezruiz changed the title [Android] Allow to update Button Background [Android] Allow to update Button Background (once established) Dec 20, 2022
@jsuarezruiz jsuarezruiz changed the title [Android] Allow to update Button Background (once established) [Android] Allow to update Entry Background (once established) Dec 20, 2022
@jsuarezruiz jsuarezruiz added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Jan 10, 2023
@PureWeen PureWeen self-assigned this Jan 25, 2023
@jsuarezruiz
Copy link
Contributor Author

Added more samples to validate #12991
fix-12991

var backgroundDrawable = paint!.ToDrawable(platformView.Context);
LayerDrawable layer = new LayerDrawable(new Drawable[] { backgroundDrawable!, previousDrawable! });
LayerDrawable layer = new LayerDrawable(new Drawable[] { backgroundDrawable!, defaultBackground! });
Copy link
Member

Choose a reason for hiding this comment

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

Can we pull this background from android resources? This same update method is called by all the picker handlers and the searchbox as well. If we can localize all of this to the extension method and just load this drawable from the android resources then this would all just work and it'd be theme change safe.

I think we can pull the drawable for this from this

ContextCompat.GetDrawable(Context, Resource.Drawable.abc_edit_text_material);

https://stackoverflow.com/a/62015982

Copy link
Member

@mandel-macaque mandel-macaque left a comment

Choose a reason for hiding this comment

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

Answers needed.

var backgroundDrawable = paint!.ToDrawable(platformView.Context);
LayerDrawable layer = new LayerDrawable(new Drawable[] { backgroundDrawable!, previousDrawable! });
LayerDrawable layer = new LayerDrawable(new Drawable[] { backgroundDrawable!, defaultBackground! });
Copy link
Member

Choose a reason for hiding this comment

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

Try to avoid the use of !, are we sure this is not null, better wrap on an if that an NRE. What happens is null? do we need the new layer, do we exit the method? Do we create a new later with no drawable contents?

@github-actions
Copy link
Contributor

⚠️ Your code has been reformatted. ⚠️

@github-actions
Copy link
Contributor

⚠️ Your code has been reformatted. ⚠️

src/Core/src/Graphics/PaintExtensions.cs Outdated Show resolved Hide resolved
src/Core/src/Platform/Android/ViewExtensions.cs Outdated Show resolved Hide resolved
@rmarinho rmarinho enabled auto-merge (squash) April 4, 2023 10:41
@rmarinho rmarinho merged commit 48d0294 into main Apr 14, 2023
29 checks passed
@rmarinho rmarinho deleted the fix-12212 branch April 14, 2023 17:27
@marshallellis
Copy link

Hey guys ... just checking in on this issue since we updated VS last week and this issue is still happening???

Thank you

Marshall

@marshallellis
Copy link

marshallellis commented May 6, 2023

I also cannot get this handler to work??? Will turn yellow when it gets focus but not to gray when it loses focus??? The code does get called normally and there is no exception from debugging???

handler.PlatformView.FocusChange += (sender, e) => { try { if (e.HasFocus) { ((Entry)handler.VirtualView).BackgroundColor = Colors.Yellow; } else { ((Entry)handler.VirtualView).BackgroundColor = Colors.Gray; } } catch (Exception E) { //log exception... } };

@marshallellis
Copy link

Just following up to see if this is really fixed because it is not in my code???
Running: 17.6.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor platform/android 🤖 t/bug Something isn't working
Projects
None yet
5 participants