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
[TIMOB-17363] Android/iOS: Added "MaskedImage" support to Android. Moved BLEND_MODE constants to "Ti.UI". #10013
Conversation
…ved BLEND_MODE constants from "Ti.UI.iOS" to "Ti.UI".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some review changes, mainly about docs and iOS.
apidoc/Titanium/UI/UI.yml
Outdated
type: Number | ||
permission: read-only | ||
platforms: [iphone, ipad] | ||
since: "7.2.0" | ||
platforms: [android, iphone, ipad] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is not supported on Android, I would just leave out the android
key. If we would be very exact here, we would leave the iOS only constants on the iOS namespace and put the parity ones here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still define the constant on Android, but log a warning instead. I think it's better than letting the app crash.
It is possible to add the other modes on Android, but we would have to manipulate the bitmap pixels ourselves the slow way. (yuck)
I'll remove the "android" platform keys from the unsupported constants.
@@ -164,6 +164,35 @@ - (TiUIActivityIndicatorStyleProxy *)ActivityIndicatorStyle | |||
MAKE_SYSTEM_PROP(PICKER_TYPE_TIME, UIDatePickerModeTime); | |||
MAKE_SYSTEM_PROP(PICKER_TYPE_COUNT_DOWN_TIMER, UIDatePickerModeCountDownTimer); | |||
|
|||
MAKE_SYSTEM_PROP(BLEND_MODE_NORMAL, kCGBlendModeNormal); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please deprecate the old ones. We have a macro for this:
// Definition
MAKE_SYSTEM_PROP_DEPRECATED_REPLACED(name, map, api, in, newapi);
// Example
MAKE_SYSTEM_PROP_DEPRECATED_REPLACED(BLEND_MODE_NORMAL, kCGBlendModeNormal, @"UI.iOS.BLEND_MODE_NORMAL", @"7.3.0", @"UI.BLEND_MODE_NORMAL");
Note: The Ti
/ Titanium
is not included into the log as it is replaced by the app name during project generation. For the log, it's manually constructed to avoid being replaced, so we leave it out in every log.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
image: '/SplashScreen.png', | ||
mode: Ti.UI.BLEND_MODE_SOURCE_IN, | ||
width: Ti.UI.FILL, | ||
height: Ti.UI.FILL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should fill by default. How does this behave on iOS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Android currently auto-sizes by default. I'll double check the iOS handling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just re-tested this on iOS. You're right. An iOS MaskedImage
does a Ti.UI.FILL
by default. I'll change Android to make it match.
Also, our iOS MaskedImage
doesn't appear to support Ti.UI.SIZE
. I get a 0x0 size view when attempting to auto-size it. On Android, I made this work. I auto-size based on the image if available, otherwise I fallback to auto-sizing based on the mask size. (I'll keep this behavior.)
@hansemannn, do you know if we need to do anything on the Alloy side after moving the BLEND_MODE constants? |
// Android 4.4 has a bug where if bitmap byte width does not fit a 4 byte packing alignment, | ||
// then mask will appear skewed. Resizing bitmap doesn't work. So, give up if this happens. | ||
if ((Build.VERSION.SDK_INT == 19) || (Build.VERSION.SDK_INT == 20)) { | ||
if ((bitmap.getWidth() % 4) != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be moved above the bitmap.extractAlpha()
to fail before reaching bitmap.extractAlpha()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, good catch. I was trying to "fix" the resulting grayscaled bitmap, but later gave up.
{ | ||
if (this.maskedDrawable != null) { | ||
if (value != null) { | ||
int color = TiConvert.toColor(TiConvert.toString(value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe validate if value
is a string?
{ | ||
if (this.maskedDrawable != null) { | ||
if (value != null) { | ||
int color = TiConvert.toColor(TiConvert.toString(value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
- Ti.UI.iOS BLEND_MODE constants will now log a warning if used. - Modified Android's MaskedImage to be Ti.UI.FILL by default like iOS. (Was Ti.UI.SIZE) - Now logs a warning if a non-string type was given to MaskedImage color properties. - Modified Android to support mask, image, and tint all at the same time like iOS. * Used to not support both tint and image at the same time. - Fixed dynamic changes of "mask" and "tint" properties on Android. (Would not always update onscreen.) - Updated docs to indicate which BLEND_MODE constants are not supported by the Android platform.
Updated PR:
|
Generated by 🚫 dangerJS |
JIRA:
https://jira.appcelerator.org/browse/TIMOB-17363
Summary:
BLEND_MODE_*
constants fromTi.UI.iOS
toTi.UI
.Ti.UI.iOS
for backward compatibility on iOS, but are documented as deprecated.Ti.UI.MaskedImage
support to Android.tintColor
andopacity
properties. Applied to final result.mask
andtint
for all blend modes.mask
andimage
for modesSOURCE_IN
andDESTINATION_IN
.BLEND_MODE_COLOR
BLEND_MODE_COLOR_BURN
BLEND_MODE_COLOR_DODGE
BLEND_MODE_DIFFERENCE
BLEND_MODE_EXCLUSION
BLEND_MODE_HARD_LIGHT
BLEND_MODE_HUE
BLEND_MODE_LUMINOSITY
BLEND_MODE_PLUS_DARKER
BLEND_MODE_SATURATION
BLEND_MODE_SOFT_LIGHT
toImage()
renders bad image on Android 7.0 and higher when masking an image.Test:
Run the below test procedure on...
Test procedure...