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