Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24881] Android: Label ellipsize modes START and MIDDLE don't work if "autoLink" is true

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2019-05-21T21:58:13.000+0000
Affected Version/sRelease 6.1.1
Fix Version/sRelease 8.1.0
ComponentsAndroid
Labelsandroid, label
ReporterJoshua Quick
AssigneeJoshua Quick
Created2017-06-23T00:05:58.000+0000
Updated2019-05-21T21:58:13.000+0000

Description

*Summary:* When a Label is set up to "autoLink" its text which contains at least 1 URL, then ellipsize modes START and MIDDLE are not honored. The label will use ellipsize mode END instead. *Code Example:*
var window = Ti.UI.createWindow();
window.add(Ti.UI.createLabel(
{
	text: "https://www.appcelerator.com",
	font: { fontSize: "50dp" },
	autoLink: Ti.UI.AUTOLINK_URLS,
//	ellipsize: Ti.UI.TEXT_ELLIPSIZE_TRUNCATE_START,
	ellipsize: Ti.UI.TEXT_ELLIPSIZE_TRUNCATE_MIDDLE,
	width: "100%",
}));
window.open();
*Result:* Ellipsis are shown at the end instead of the start or middle. *Reason:* Android's Java "TextView does not support displaying START or MIDDLE ellipsis while a "MovementMethod" (such as "LinkMovementMethod" in this case) is applied to it. Our existing "TiUILabel.java" code works-around this problem and applies an END ellipsis in this case instead. *Suggested Solution:* Android 5.0 and above supports URL taps without a MovementMethod, but Android 4.0 does not (I'm not sure which OS versions in the middle do support it). This is because Google's "TextView.java" code in its onTouchEvent() method handles URL taps for newer OS versions (see their code on github). So, the recommended solution here is to not set a MovementMethod in "TiUILabel.java" and for us to replicate what Google does in their TextView.onTouchEvent() in our TiUILabel code so that we can support URL taps on all Android OS versions.

Comments

  1. Joshua Quick 2019-05-15

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/10887
  2. Keerthi Mahalingam 2019-05-21

    Verified the fix on SDK 8.1.0.v20190521052940.Label ellipsize works as expected. *Test Environment:* {CODE} Name = Mac OS X Version = 10.13.6 Architecture = 64bit # CPUs = 8 Memory = 17179869184 Node.js Node.js Version = 8.9.1 npm Version = 5.5.1 Titanium CLI CLI Version = 5.1.1 Titanium SDK SDK Version = 8.1.0.v20190521052940 Device =Samsung s5 android 6 Emulator = Pixel android 9,galaxy nexus android 4.4 {CODE}

JSON Source