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-23500] Android: default value for ellipsize #8094

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);
Copy link
Collaborator

Choose a reason for hiding this comment

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

How does that effect current labels that do not have any ellipsize property defined? We should try to ensure that nothing breaks after this change (although 6.0 would be the right time to do this).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it will just be a "good" change:
ell

it will just affect the fields where you have a fixed width (no wordWrap) and the text would be out of the label anyway. That's mostly the point where you are searching on how to switch on ellipsize :)
But since Android can switch of the ellipsizing it might have a different default value. I would prefer truncateAt.END because it will make the label look the same on both platforms from the beginning. You decide ;)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Like it, thanks for that great example!

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 @@ -1279,6 +1279,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