Commit a321f908 authored by Matthew Coufal's avatar Matthew Coufal Committed by Susan Rati Lane

Add ReadOnly property to TextBox component (#1886)

parent bc27297d
......@@ -1538,6 +1538,10 @@ public final class YoungAndroidFormUpgrader {
// RequestFocus method was added
srcCompVersion = 5;
}
if (srcCompVersion < 6) {
// ReadOnly property was added
srcCompVersion = 6;
}
return srcCompVersion;
}
......
......@@ -2380,7 +2380,10 @@ Blockly.Versioning.AllUpgradeMaps =
4: "noUpgrade",
// AI2: Added RequestFocus method
5: "noUpgrade"
5: "noUpgrade",
// AI3: Added ReadOnly property
6: "noUpgrade"
}, // End TextBox upgraders
......
......@@ -1107,7 +1107,9 @@ public class YaVersion {
// - The MultiLine property was added.
// For TEXTBOX_COMPONENT_VERSION 5:
// - RequestFocus method was added
public static final int TEXTBOX_COMPONENT_VERSION = 5;
// For TEXTBOX_COMPONENT_VERSION 6:
// - ReadOnly property was added
public static final int TEXTBOX_COMPONENT_VERSION = 6;
// For TEXTING_COMPONENT_VERSION 2:
// Texting over Wifi was implemented using Google Voice
......
......@@ -79,6 +79,9 @@ public final class TextBox extends TextBoxBase {
// If true, then text box is multiline
private boolean multiLine;
// If true, then text box is read-only
private boolean readOnly;
/**
* Creates a new TextBox component.
*
......@@ -88,6 +91,7 @@ public final class TextBox extends TextBoxBase {
super(container, new EditText(container.$context()));
NumbersOnly(false);
MultiLine(false);
ReadOnly(false);
// We need to set the IME options here. Otherwise, Android's default
// behavior is that the action button will be Done or Next, depending on
......@@ -183,6 +187,24 @@ public final class TextBox extends TextBoxBase {
view.setSingleLine(!multiLine);
}
@SimpleProperty(
category = PropertyCategory.BEHAVIOR,
description = "Whether the %type% is read-only. By default, this is true."
)
public boolean ReadOnly() {
return readOnly;
}
@DesignerProperty(
editorType = PropertyTypeConstants.PROPERTY_TYPE_BOOLEAN,
defaultValue = "False"
)
@SimpleProperty
public void ReadOnly(boolean readOnly) {
this.readOnly = readOnly;
view.setEnabled(!readOnly);
}
// TODO(halabelson): We might also want a method to show the keyboard.
// Currently the text box keyboard will open when the text field becomes
// active, and that may be the best simple thing. If we implement show keyboard,
......
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