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

[TIMOB-25374] Android: borderColor not visible on Android tiSDK 6.2.2 #9510

Merged
merged 9 commits into from
Nov 13, 2017
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,7 @@ private void initializeBorder(KrollDict d, Integer bgColor)
}
borderView.setRadius(radius);
}

if (bgColor != null) {
borderView.setBgColor(bgColor);
borderView.setColor(bgColor);
Expand All @@ -1428,14 +1428,21 @@ private void initializeBorder(KrollDict d, Integer bgColor)
borderView.setColor(TiConvert.toColor(d, TiC.PROPERTY_BORDER_COLOR));
}

//Have a default border width of 1
Object borderWidth = "1";
Copy link
Contributor

Choose a reason for hiding this comment

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

I've confirmed that Titanium for iOS defaults the borderWidth to "1dp" (Apple's framework takes UI measurements in points/dips by default). This can be seen in the [TiUIView setBorderColor] method here...
https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/TiUIView.m#L483

So, I recommend that you change "1" to "1dp" here to match iOS' behavior.

Copy link
Contributor Author

@ypbnv ypbnv Oct 10, 2017

Choose a reason for hiding this comment

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

@jquick-axway I set it as a String with value '1' to use the ti.ui.defaultunit that is set in tiapp.xml. I think iOS does the same here:
https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/TiDimension.m#L103

if (d.containsKey(TiC.PROPERTY_BORDER_WIDTH)) {
TiDimension width = TiConvert.toTiDimension(d.get(TiC.PROPERTY_BORDER_WIDTH), TiDimension.TYPE_WIDTH);
if (width != null) {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN) {
disableHWAcceleration();
}
borderView.setBorderWidth((float) width.getPixels(borderView));
borderWidth = d.get(TiC.PROPERTY_BORDER_WIDTH);
} else {
// Add the default width of 1 to the proxy as well
proxy.setProperty(TiC.PROPERTY_BORDER_WIDTH, borderWidth);
}

TiDimension width = TiConvert.toTiDimension(borderWidth, TiDimension.TYPE_WIDTH);
if (width != null) {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN) {
disableHWAcceleration();
}
borderView.setBorderWidth((float) width.getPixels(borderView));
}

nativeView.invalidate();
Expand Down
3 changes: 3 additions & 0 deletions apidoc/Titanium/UI/View.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,9 @@ properties:

- name: borderWidth
summary: Border width of the view.
description: |
If [borderColor](Ti.UI.View.borderColor) is set without [borderWidth](Ti.UI.View.borderWidth), this value
will be changed to 1 of the unit declared as 'ti.ui.defaultunit' in tiapp.xml descriptor.
type: Number
default: 0

Expand Down