Commit d843e692 authored by Evan W. Patton's avatar Evan W. Patton Committed by Susan Rati Lane

Add HTMLContent property to Label (#1827)

* Add HTMLContent property to Label

Change-Id: I59c74e29d1ba2d339c0df2d88d25b06a143bfc9d
parent f7625a42
...@@ -1104,6 +1104,9 @@ public final class YoungAndroidFormUpgrader { ...@@ -1104,6 +1104,9 @@ public final class YoungAndroidFormUpgrader {
componentProperties.put("HasMargins", new ClientJsonString("False")); componentProperties.put("HasMargins", new ClientJsonString("False"));
srcCompVersion = 4; srcCompVersion = 4;
} }
if (srcCompVersion < 5) {
srcCompVersion = 5;
}
return srcCompVersion; return srcCompVersion;
} }
......
...@@ -1649,7 +1649,9 @@ Blockly.Versioning.AllUpgradeMaps = ...@@ -1649,7 +1649,9 @@ Blockly.Versioning.AllUpgradeMaps =
3: "noUpgrade", 3: "noUpgrade",
// AI2: Add HTMLFormat property // AI2: Add HTMLFormat property
4: "noUpgrade" 4: "noUpgrade",
5: "noUpgrade"
}, // End Label upgraders }, // End Label upgraders
......
...@@ -465,8 +465,10 @@ public class YaVersion { ...@@ -465,8 +465,10 @@ public class YaVersion {
// - HYGROMETER_COMPONENT_VERSION was initialized to 1 // - HYGROMETER_COMPONENT_VERSION was initialized to 1
// - LIGHTSENSOR_COMPONENT_VERSION was initialized to 1 // - LIGHTSENSOR_COMPONENT_VERSION was initialized to 1
// - THERMOMETER_COMPONENT_VERSION was initialized to 1 // - THERMOMETER_COMPONENT_VERSION was initialized to 1
// For YOUNG_ANDROID_VERSION 188:
// - Label component version incremented to 5
public static final int YOUNG_ANDROID_VERSION = 187; public static final int YOUNG_ANDROID_VERSION = 188;
// ............................... Blocks Language Version Number ............................... // ............................... Blocks Language Version Number ...............................
...@@ -873,8 +875,10 @@ public class YaVersion { ...@@ -873,8 +875,10 @@ public class YaVersion {
// - The HasMargins property was added // - The HasMargins property was added
// For LABEL_COMPONENT_VERSION 4: // For LABEL_COMPONENT_VERSION 4:
// - The HTML format is defined. // - The HTML format is defined.
// For LABEL_COMPONENT_VERSION 5:
// - The HTMLContent property is defined.
public static final int LABEL_COMPONENT_VERSION = 4; public static final int LABEL_COMPONENT_VERSION = 5;
// For LINESTRING_COMPONENT_VERSION 1: // For LINESTRING_COMPONENT_VERSION 1:
// - Initial LineString implementation for Maps // - Initial LineString implementation for Maps
......
...@@ -71,6 +71,9 @@ public final class Label extends AndroidViewComponent { ...@@ -71,6 +71,9 @@ public final class Label extends AndroidViewComponent {
// Label Format // Label Format
private boolean htmlFormat; private boolean htmlFormat;
// HTML content of the label
private String htmlContent;
/** /**
* Creates a new Label component. * Creates a new Label component.
* *
...@@ -365,6 +368,22 @@ private void setLabelMargins(boolean hasMargins) { ...@@ -365,6 +368,22 @@ private void setLabelMargins(boolean hasMargins) {
} else { } else {
TextViewUtil.setText(view, text); TextViewUtil.setText(view, text);
} }
htmlContent = text;
}
/**
* Returns the content of the Label as HTML. This is only useful if the
* HTMLFormat property is true.
*
* @return the HTML content of the label
*/
@SimpleProperty
public String HTMLContent() {
if (htmlFormat) {
return htmlContent;
} else {
return TextViewUtil.getText(view);
}
} }
......
...@@ -702,6 +702,10 @@ ...@@ -702,6 +702,10 @@
(left, right, top, bottom) are the same. This (left, right, top, bottom) are the same. This
property has no effect in the designer, property has no effect in the designer,
where labels are always shown with margins.</dd> where labels are always shown with margins.</dd>
<dt> <code> HTMLContent </code> </dt>
<dd> Retrieves the HTML content of the Label if the
HTMLFormat property is true and the Text property was set to
HTML. </dd>
<dt> <code> HTMLFormat </code> </dt> <dt> <code> HTMLFormat </code> </dt>
<dd> If true, sets text of label to html format else it is plain text format. Note: Not all HTML is supported.</dd> <dd> If true, sets text of label to html format else it is plain text format. Note: Not all HTML is supported.</dd>
<dt> <code> Height </code> </dt> <dt> <code> Height </code> </dt>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment