Bug 57521 - Add implicit conversion from Int32 to Android.Graphics.Color
Summary: Add implicit conversion from Int32 to Android.Graphics.Color
Status: CONFIRMED
Alias: None
Product: Android
Classification: Xamarin
Component: Bindings ()
Version: 8.0 (15.4)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Atsushi Eno
URL:
Depends on:
Blocks:
 
Reported: 2017-06-15 11:43 UTC by Daniel Katz
Modified: 2017-08-21 21:24 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 57521 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Daniel Katz 2017-06-15 11:43:00 UTC
In Java, there is an implicit conversion between int and android.graphics.Color in both directions.
On Xamarin.Android there is only an implicit conversion from Color to Int32 but not the other way around.
Comment 1 Jon Douglas [MSFT] 2017-06-26 15:39:25 UTC
(In reply to Daniel Katz from comment #0)
> In Java, there is an implicit conversion between int and
> android.graphics.Color in both directions.
> On Xamarin.Android there is only an implicit conversion from Color to Int32
> but not the other way around.

Hi Daniel,

Can you give a couple of concrete examples of the implicit conversions in Java and what is lacking in comparison in the Xamarin.Android bindings? This will help give a clear picture of what exactly we can add to help.

I assume you are referring to a color int which is packed in a 32 bit int. i.e. ARGB (8 bit/8 bit/8 bit/8 bit)

Perhaps in this scenario is might be better to implement a "ColorInt" attribute similar to the @ColorInt annotation in Android.

One thing to keep in mind is that Color longs are coming in Android O, so we might want to do a similar thing there.
Comment 2 Jon Douglas [MSFT] 2017-08-21 21:24:43 UTC
I am going to CONFIRM this as there is some general improvements here in the sense of adding some extension methods for 

Color -> int / int -> Color 

long -> Color / Color -> long

https://developer.android.com/reference/android/graphics/Color.html