Skip to content

Commit

Permalink
Merge pull request #6917 from ashcoding/TIMOB-17827
Browse files Browse the repository at this point in the history
[TIMOB-17827] Android: Add support for lines and maxLines
  • Loading branch information
ashcoding committed Jun 17, 2015
2 parents f8d4137 + f90f825 commit 251d50d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
TiC.PROPERTY_SHADOW_OFFSET,
TiC.PROPERTY_SHADOW_COLOR,
TiC.PROPERTY_SHADOW_RADIUS,
TiC.PROPERTY_INCLUDE_FONT_PADDING
TiC.PROPERTY_INCLUDE_FONT_PADDING,
TiC.PROPERTY_LINES,
TiC.PROPERTY_MAX_LINES
})
public class LabelProxy extends TiViewProxy
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ public void processProperties(KrollDict d)
if (d.containsKey(TiC.PROPERTY_INCLUDE_FONT_PADDING)) {
tv.setIncludeFontPadding(TiConvert.toBoolean(d, TiC.PROPERTY_INCLUDE_FONT_PADDING, true));
}
if (d.containsKey(TiC.PROPERTY_LINES)) {
tv.setLines(TiConvert.toInt(d, TiC.PROPERTY_LINES));
}
if (d.containsKey(TiC.PROPERTY_MAX_LINES)) {
tv.setMaxLines(TiConvert.toInt(d, TiC.PROPERTY_MAX_LINES));
}

if (d.containsKey(TiC.PROPERTY_COLOR)) {
Object color = d.get(TiC.PROPERTY_COLOR);
Expand Down Expand Up @@ -337,6 +343,10 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
} else if (key.equals(TiC.PROPERTY_SHADOW_COLOR)) {
shadowColor = TiConvert.toColor(TiConvert.toString(newValue));
tv.setShadowLayer(shadowRadius, shadowX, shadowY, shadowColor);
} else if (key.equals(TiC.PROPERTY_LINES)) {
tv.setLines(TiConvert.toInt(newValue));
} else if (key.equals(TiC.PROPERTY_MAX_LINES)) {
tv.setMaxLines(TiConvert.toInt(newValue));
} else if (key.equals(TiC.PROPERTY_ATTRIBUTED_STRING) && newValue instanceof AttributedStringProxy) {
Spannable spannableText = AttributedStringProxy.toSpannable(((AttributedStringProxy)newValue), TiApplication.getAppCurrentActivity());
if (spannableText != null) {
Expand Down
14 changes: 12 additions & 2 deletions android/titanium/src/java/org/appcelerator/titanium/TiC.java
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,12 @@ public class TiC
* @module.api
*/
public static final String PROPERTY_LAYOUT_ID = "layoutId";


/**
* @module.api
*/
public static final String PROPERTY_LINES = "lines";

/**
* @module.api
*/
Expand Down Expand Up @@ -1647,7 +1652,12 @@ public class TiC
* @module.api
*/
public static final String PROPERTY_MAX_LENGTH = "maxLength";


/**
* @module.api
*/
public static final String PROPERTY_MAX_LINES = "maxLines";

/**
* @module.api
*/
Expand Down
12 changes: 12 additions & 0 deletions apidoc/Titanium/UI/Label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,18 @@ properties:
default: undefined but behaves as true
since: "3.3.0"

- name: lines
summary: Makes the label be exactly this many lines tall.
platforms: [android]
type: Number
since: "4.1.0"

- name: maxLines
summary: Makes the label at most this many lines tall.
platforms: [android]
type: Number
since: "4.1.0"

- name: minimumFontSize
summary: Minimum font size when the font is sized based on the contents.
description: |
Expand Down

0 comments on commit 251d50d

Please sign in to comment.