|
@@ -21,7 +21,7 @@ public class Button {
|
21
|
21
|
public Text text = new NullText();
|
22
|
22
|
public Bool enabled = new NullBool();
|
23
|
23
|
public Bool disableIconTint = new NullBool();
|
24
|
|
- public int showAsAction;
|
|
24
|
+ public Number showAsAction = new NullNumber();
|
25
|
25
|
public Color color = new NullColor();
|
26
|
26
|
public Color disabledColor = new NullColor();
|
27
|
27
|
public Number fontSize = new NullNumber();
|
|
@@ -86,22 +86,37 @@ public class Button {
|
86
|
86
|
return icon.hasValue();
|
87
|
87
|
}
|
88
|
88
|
|
89
|
|
- private static int parseShowAsAction(JSONObject json) {
|
|
89
|
+ private static Number parseShowAsAction(JSONObject json) {
|
90
|
90
|
final Text showAsAction = TextParser.parse(json, "showAsAction");
|
91
|
91
|
if (!showAsAction.hasValue()) {
|
92
|
|
- return MenuItem.SHOW_AS_ACTION_IF_ROOM;
|
|
92
|
+ return new Number(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
93
|
93
|
}
|
94
|
94
|
|
95
|
95
|
switch (showAsAction.get()) {
|
96
|
96
|
case "always":
|
97
|
|
- return MenuItem.SHOW_AS_ACTION_ALWAYS;
|
|
97
|
+ return new Number(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
98
|
98
|
case "never":
|
99
|
|
- return MenuItem.SHOW_AS_ACTION_NEVER;
|
|
99
|
+ return new Number(MenuItem.SHOW_AS_ACTION_NEVER);
|
100
|
100
|
case "withText":
|
101
|
|
- return MenuItem.SHOW_AS_ACTION_WITH_TEXT;
|
|
101
|
+ return new Number(MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
102
|
102
|
case "ifRoom":
|
103
|
103
|
default:
|
104
|
|
- return MenuItem.SHOW_AS_ACTION_IF_ROOM;
|
|
104
|
+ return new Number(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
105
|
105
|
}
|
106
|
106
|
}
|
|
107
|
+
|
|
108
|
+ public void mergeWithDefault(Button defaultOptions) {
|
|
109
|
+ if (!text.hasValue()) text = defaultOptions.text;
|
|
110
|
+ if (!enabled.hasValue()) enabled = defaultOptions.enabled;
|
|
111
|
+ if (!disableIconTint.hasValue()) disableIconTint = defaultOptions.disableIconTint;
|
|
112
|
+ if (!color.hasValue()) color = defaultOptions.color;
|
|
113
|
+ if (!disabledColor.hasValue()) disabledColor = defaultOptions.disabledColor;
|
|
114
|
+ if (!fontSize.hasValue()) fontSize = defaultOptions.fontSize;
|
|
115
|
+ if (fontFamily == null) fontFamily = defaultOptions.fontFamily;
|
|
116
|
+ if (!fontWeight.hasValue()) fontWeight = defaultOptions.fontWeight;
|
|
117
|
+ if (!testId.hasValue()) testId = defaultOptions.testId;
|
|
118
|
+ if (!component.hasValue()) component = defaultOptions.component;
|
|
119
|
+ if (!showAsAction.hasValue()) showAsAction = defaultOptions.showAsAction;
|
|
120
|
+ if (!icon.hasValue()) icon = defaultOptions.icon;
|
|
121
|
+ }
|
107
|
122
|
}
|