Skip to content

Commit

Permalink
[TIMOB-23501]: Cherry-Pick Android and Fix If
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelkPetkov committed Jun 29, 2016
1 parent 2bb7df5 commit 18d8c00
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class LabelProxy extends TiViewProxy
public LabelProxy()
{
defaultValues.put(TiC.PROPERTY_TEXT, "");
defaultValues.put(TiC.PROPERTY_ELLIPSIZE, UIModule.TEXT_ELLIPSIZE_TRUNCATE_END);
}

public LabelProxy(TiContext tiContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public class UIModule extends KrollModule implements Handler.Callback
@Kroll.constant public static final int TEXT_ELLIPSIZE_TRUNCATE_MIDDLE = 1;
@Kroll.constant public static final int TEXT_ELLIPSIZE_TRUNCATE_END = 2;
@Kroll.constant public static final int TEXT_ELLIPSIZE_TRUNCATE_MARQUEE = 3;
@Kroll.constant public static final int TEXT_ELLIPSIZE_TRUNCATE_NONE = 4;

@Kroll.constant public static final String SIZE = TiC.LAYOUT_SIZE;
@Kroll.constant public static final String FILL = TiC.LAYOUT_FILL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class TiUILabel extends TiUIView

private int defaultColor;
private boolean wordWrap = true;
private TruncateAt ellipsize;
private TruncateAt ellipsize = TruncateAt.END;
private float shadowRadius = DEFAULT_SHADOW_RADIUS;
private float shadowX = 0f;
private float shadowY = 0f;
Expand Down Expand Up @@ -135,6 +135,7 @@ public boolean onTouchEvent(MotionEvent event) {
tv.setKeyListener(null);
tv.setFocusable(false);
tv.setSingleLine(false);
tv.setEllipsize(ellipsize);
TiUIHelper.styleText(tv, null);
defaultColor = tv.getCurrentTextColor();
setNativeView(tv);
Expand Down Expand Up @@ -217,7 +218,6 @@ public void processProperties(KrollDict d)
if (d.containsKey(TiC.PROPERTY_ELLIPSIZE)) {

Object value = d.get(TiC.PROPERTY_ELLIPSIZE);

if (value instanceof Boolean){
ellipsize = (Boolean) value ? TruncateAt.END : null;
}
Expand Down
9 changes: 9 additions & 0 deletions apidoc/Titanium/UI/UI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,15 @@ properties:
platforms: [android]
since: "4.1.0"

- name: TEXT_ELLIPSIZE_TRUNCATE_NONE
summary: Disables ellipsizing of the label. The text will be cut off if it is too long.
description: |
One of the group of constants for the <Titanium.UI.Label.ellipsize> property.
type: Number
permission: read-only
platforms: [android]
since: "6.0.0"

- name: EXTEND_EDGE_TOP
summary: Specifies that the top edge of the window can extend.
description: |
Expand Down
4 changes: 2 additions & 2 deletions iphone/Classes/TiUILabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,8 @@ -(void)setColor_:(id)color
-(void)setEllipsize_:(id)value
{
ENSURE_SINGLE_ARG(value, NSNumber);
if ([TiUtils intValue:value] == 1) {
[[self label] setLineBreakMode:NSLineBreakByCharWrapping];
if ([[TiUtils stringValue:value] isEqualToString:@"true"]) {
[[self label] setLineBreakMode:NSLineBreakByTruncatingTail];
return;
}
[[self label] setLineBreakMode:[TiUtils intValue:value]];
Expand Down

0 comments on commit 18d8c00

Please sign in to comment.