From 4ddd7f1a8a4b533ab8ff60e8f44c1fa2954fdcc0 Mon Sep 17 00:00:00 2001 From: Nathanael Anderson Date: Mon, 7 Sep 2015 14:07:00 -0500 Subject: [PATCH 1/3] Enable Link Detection (iOS) and Link Clicking (iOS & Android) --- ui/html-view/html-view.android.ts | 2 ++ ui/html-view/html-view.ios.ts | 15 +++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ui/html-view/html-view.android.ts b/ui/html-view/html-view.android.ts index fdca0da27..b469db3c8 100644 --- a/ui/html-view/html-view.android.ts +++ b/ui/html-view/html-view.android.ts @@ -30,5 +30,7 @@ export class HtmlView extends common.HtmlView { public _createUI() { this._android = new android.widget.TextView(this._context); + this._android.setAutoLinkMask(15); // 15 (0x0f) = Linkify All } + } \ No newline at end of file diff --git a/ui/html-view/html-view.ios.ts b/ui/html-view/html-view.ios.ts index 79001ff2d..2d9b831ea 100644 --- a/ui/html-view/html-view.ios.ts +++ b/ui/html-view/html-view.ios.ts @@ -27,21 +27,24 @@ function onHtmlPropertyChanged(data: dependencyObservable.PropertyChangeData) { global.moduleMerge(common, exports); export class HtmlView extends common.HtmlView { - private _ios: UILabel; + private _ios: UITextView; constructor(options?: definition.Options) { super(options); + this._ios = UITextView.new(); - this._ios = new UILabel(); - this._ios.userInteractionEnabled = true; - this._ios.numberOfLines = 0; + this._ios.scrollEnabled = false; + this._ios.editable = false; + this._ios.selectable = true; + this._ios.userInteractionEnabled = true; + this._ios.dataDetectorTypes = 255; // Future Proof this; valid max in iOS is currently 15; however ALL = MAX UNSIGNED INT which isn't valid in JavaScript } - get ios(): UILabel { + get ios(): UITextView { return this._ios; } - get _nativeView(): UILabel { + get _nativeView(): UITextView { return this._ios; } From 9dffb57bcb145583e4d22344ee62138040e71fd7 Mon Sep 17 00:00:00 2001 From: Nathanael Anderson Date: Mon, 7 Sep 2015 15:11:29 -0500 Subject: [PATCH 2/3] Issue with Android and urls... --- ui/html-view/html-view.android.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ui/html-view/html-view.android.ts b/ui/html-view/html-view.android.ts index b469db3c8..0a83663f7 100644 --- a/ui/html-view/html-view.android.ts +++ b/ui/html-view/html-view.android.ts @@ -10,6 +10,13 @@ function onHtmlPropertyChanged(data: dependencyObservable.PropertyChangeData) { } if (types.isString(data.newValue)) { + // If the data.newValue actually has a in it; we need to disable auto-linking + // as it internally disables anyways; and then links won't work.. + if (data.newValue.toLowerCase().indexOf(" 0) { + view.android.setAutoLinkMask(0); + } else { + view.android.setAutoLinkMask(15); // 15 (0x0f) = Linkify All text links + } view.android.setText(android.text.Html.fromHtml(data.newValue)); } else { view.android.setText(""); @@ -30,7 +37,10 @@ export class HtmlView extends common.HtmlView { public _createUI() { this._android = new android.widget.TextView(this._context); - this._android.setAutoLinkMask(15); // 15 (0x0f) = Linkify All + // This makes the work + this._android.setLinksClickable(true); + this._android.setMovementMethod(android.text.method.LinkMovementMethod.getInstance()); + } } \ No newline at end of file From e184308169786cab70d03bd13493b8eabaa8277d Mon Sep 17 00:00:00 2001 From: Nathanael Anderson Date: Wed, 9 Sep 2015 19:35:31 -0500 Subject: [PATCH 3/3] Update code to take in account suggestions. --- ui/html-view/html-view.android.ts | 15 ++++++++------- ui/html-view/html-view.ios.ts | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ui/html-view/html-view.android.ts b/ui/html-view/html-view.android.ts index 0a83663f7..8ac93fe1f 100644 --- a/ui/html-view/html-view.android.ts +++ b/ui/html-view/html-view.android.ts @@ -10,13 +10,14 @@ function onHtmlPropertyChanged(data: dependencyObservable.PropertyChangeData) { } if (types.isString(data.newValue)) { - // If the data.newValue actually has a in it; we need to disable auto-linking - // as it internally disables anyways; and then links won't work.. - if (data.newValue.toLowerCase().indexOf(" 0) { - view.android.setAutoLinkMask(0); - } else { - view.android.setAutoLinkMask(15); // 15 (0x0f) = Linkify All text links + // If the data.newValue actually has a in it; we need to disable autolink mask + // it internally disables the coloring, but then the links won't work.. So to support both + // styles of links (html and just text based) we have to manually enable/disable the autolink mask + var mask = 15; + if (data.newValue.search(/= 0) { + mask = 0; } + view.android.setAutoLinkMask(mask); view.android.setText(android.text.Html.fromHtml(data.newValue)); } else { view.android.setText(""); @@ -37,7 +38,7 @@ export class HtmlView extends common.HtmlView { public _createUI() { this._android = new android.widget.TextView(this._context); - // This makes the work + // This makes the html vwork this._android.setLinksClickable(true); this._android.setMovementMethod(android.text.method.LinkMovementMethod.getInstance()); diff --git a/ui/html-view/html-view.ios.ts b/ui/html-view/html-view.ios.ts index 2d9b831ea..ba42724e3 100644 --- a/ui/html-view/html-view.ios.ts +++ b/ui/html-view/html-view.ios.ts @@ -37,7 +37,7 @@ export class HtmlView extends common.HtmlView { this._ios.editable = false; this._ios.selectable = true; this._ios.userInteractionEnabled = true; - this._ios.dataDetectorTypes = 255; // Future Proof this; valid max in iOS is currently 15; however ALL = MAX UNSIGNED INT which isn't valid in JavaScript + this._ios.dataDetectorTypes = UIDataDetectorTypes.UIDataDetectorTypeAll; } get ios(): UITextView {