Skip to content

Commit 090840f

Browse files
author
rjmatthews62
committed
FullScreenUI - color names, textStyle and nextFocus
1 parent 74c9d07 commit 090840f

File tree

2 files changed

+166
-1
lines changed

2 files changed

+166
-1
lines changed

android/Common/src/com/googlecode/android_scripting/facade/ui/ViewInflater.java

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.content.Context;
55
import android.graphics.Bitmap;
66
import android.graphics.BitmapFactory;
7+
import android.graphics.Typeface;
78
import android.graphics.drawable.BitmapDrawable;
89
import android.graphics.drawable.Drawable;
910
import android.net.Uri;
@@ -19,6 +20,7 @@
1920
import android.widget.ListAdapter;
2021
import android.widget.Spinner;
2122
import android.widget.SpinnerAdapter;
23+
import android.widget.TextView;
2224

2325
import com.googlecode.android_scripting.Log;
2426

@@ -50,6 +52,157 @@ public class ViewInflater {
5052
private Context mContext;
5153
private DisplayMetrics mMetrics;
5254
private static final Map<String, Integer> mInputTypes = new HashMap<String, Integer>();
55+
public static final Map<String, String> mColorNames = new HashMap<String, String>();
56+
57+
static {
58+
mColorNames.put("aliceblue", "#f0f8ff");
59+
mColorNames.put("antiquewhite", "#faebd7");
60+
mColorNames.put("aqua", "#00ffff");
61+
mColorNames.put("aquamarine", "#7fffd4");
62+
mColorNames.put("azure", "#f0ffff");
63+
mColorNames.put("beige", "#f5f5dc");
64+
mColorNames.put("bisque", "#ffe4c4");
65+
mColorNames.put("black", "#000000");
66+
mColorNames.put("blanchedalmond", "#ffebcd");
67+
mColorNames.put("blue", "#0000ff");
68+
mColorNames.put("blueviolet", "#8a2be2");
69+
mColorNames.put("brown", "#a52a2a");
70+
mColorNames.put("burlywood", "#deb887");
71+
mColorNames.put("cadetblue", "#5f9ea0");
72+
mColorNames.put("chartreuse", "#7fff00");
73+
mColorNames.put("chocolate", "#d2691e");
74+
mColorNames.put("coral", "#ff7f50");
75+
mColorNames.put("cornflowerblue", "#6495ed");
76+
mColorNames.put("cornsilk", "#fff8dc");
77+
mColorNames.put("crimson", "#dc143c");
78+
mColorNames.put("cyan", "#00ffff");
79+
mColorNames.put("darkblue", "#00008b");
80+
mColorNames.put("darkcyan", "#008b8b");
81+
mColorNames.put("darkgoldenrod", "#b8860b");
82+
mColorNames.put("darkgray", "#a9a9a9");
83+
mColorNames.put("darkgrey", "#a9a9a9");
84+
mColorNames.put("darkgreen", "#006400");
85+
mColorNames.put("darkkhaki", "#bdb76b");
86+
mColorNames.put("darkmagenta", "#8b008b");
87+
mColorNames.put("darkolivegreen", "#556b2f");
88+
mColorNames.put("darkorange", "#ff8c00");
89+
mColorNames.put("darkorchid", "#9932cc");
90+
mColorNames.put("darkred", "#8b0000");
91+
mColorNames.put("darksalmon", "#e9967a");
92+
mColorNames.put("darkseagreen", "#8fbc8f");
93+
mColorNames.put("darkslateblue", "#483d8b");
94+
mColorNames.put("darkslategray", "#2f4f4f");
95+
mColorNames.put("darkslategrey", "#2f4f4f");
96+
mColorNames.put("darkturquoise", "#00ced1");
97+
mColorNames.put("darkviolet", "#9400d3");
98+
mColorNames.put("deeppink", "#ff1493");
99+
mColorNames.put("deepskyblue", "#00bfff");
100+
mColorNames.put("dimgray", "#696969");
101+
mColorNames.put("dimgrey", "#696969");
102+
mColorNames.put("dodgerblue", "#1e90ff");
103+
mColorNames.put("firebrick", "#b22222");
104+
mColorNames.put("floralwhite", "#fffaf0");
105+
mColorNames.put("forestgreen", "#228b22");
106+
mColorNames.put("fuchsia", "#ff00ff");
107+
mColorNames.put("gainsboro", "#dcdcdc");
108+
mColorNames.put("ghostwhite", "#f8f8ff");
109+
mColorNames.put("gold", "#ffd700");
110+
mColorNames.put("goldenrod", "#daa520");
111+
mColorNames.put("gray", "#808080");
112+
mColorNames.put("grey", "#808080");
113+
mColorNames.put("green", "#008000");
114+
mColorNames.put("greenyellow", "#adff2f");
115+
mColorNames.put("honeydew", "#f0fff0");
116+
mColorNames.put("hotpink", "#ff69b4");
117+
mColorNames.put("indianred ", "#cd5c5c");
118+
mColorNames.put("indigo ", "#4b0082");
119+
mColorNames.put("ivory", "#fffff0");
120+
mColorNames.put("khaki", "#f0e68c");
121+
mColorNames.put("lavender", "#e6e6fa");
122+
mColorNames.put("lavenderblush", "#fff0f5");
123+
mColorNames.put("lawngreen", "#7cfc00");
124+
mColorNames.put("lemonchiffon", "#fffacd");
125+
mColorNames.put("lightblue", "#add8e6");
126+
mColorNames.put("lightcoral", "#f08080");
127+
mColorNames.put("lightcyan", "#e0ffff");
128+
mColorNames.put("lightgoldenrodyellow", "#fafad2");
129+
mColorNames.put("lightgray", "#d3d3d3");
130+
mColorNames.put("lightgrey", "#d3d3d3");
131+
mColorNames.put("lightgreen", "#90ee90");
132+
mColorNames.put("lightpink", "#ffb6c1");
133+
mColorNames.put("lightsalmon", "#ffa07a");
134+
mColorNames.put("lightseagreen", "#20b2aa");
135+
mColorNames.put("lightskyblue", "#87cefa");
136+
mColorNames.put("lightslategray", "#778899");
137+
mColorNames.put("lightslategrey", "#778899");
138+
mColorNames.put("lightsteelblue", "#b0c4de");
139+
mColorNames.put("lightyellow", "#ffffe0");
140+
mColorNames.put("lime", "#00ff00");
141+
mColorNames.put("limegreen", "#32cd32");
142+
mColorNames.put("linen", "#faf0e6");
143+
mColorNames.put("magenta", "#ff00ff");
144+
mColorNames.put("maroon", "#800000");
145+
mColorNames.put("mediumaquamarine", "#66cdaa");
146+
mColorNames.put("mediumblue", "#0000cd");
147+
mColorNames.put("mediumorchid", "#ba55d3");
148+
mColorNames.put("mediumpurple", "#9370d8");
149+
mColorNames.put("mediumseagreen", "#3cb371");
150+
mColorNames.put("mediumslateblue", "#7b68ee");
151+
mColorNames.put("mediumspringgreen", "#00fa9a");
152+
mColorNames.put("mediumturquoise", "#48d1cc");
153+
mColorNames.put("mediumvioletred", "#c71585");
154+
mColorNames.put("midnightblue", "#191970");
155+
mColorNames.put("mintcream", "#f5fffa");
156+
mColorNames.put("mistyrose", "#ffe4e1");
157+
mColorNames.put("moccasin", "#ffe4b5");
158+
mColorNames.put("navajowhite", "#ffdead");
159+
mColorNames.put("navy", "#000080");
160+
mColorNames.put("oldlace", "#fdf5e6");
161+
mColorNames.put("olive", "#808000");
162+
mColorNames.put("olivedrab", "#6b8e23");
163+
mColorNames.put("orange", "#ffa500");
164+
mColorNames.put("orangered", "#ff4500");
165+
mColorNames.put("orchid", "#da70d6");
166+
mColorNames.put("palegoldenrod", "#eee8aa");
167+
mColorNames.put("palegreen", "#98fb98");
168+
mColorNames.put("paleturquoise", "#afeeee");
169+
mColorNames.put("palevioletred", "#d87093");
170+
mColorNames.put("papayawhip", "#ffefd5");
171+
mColorNames.put("peachpuff", "#ffdab9");
172+
mColorNames.put("peru", "#cd853f");
173+
mColorNames.put("pink", "#ffc0cb");
174+
mColorNames.put("plum", "#dda0dd");
175+
mColorNames.put("powderblue", "#b0e0e6");
176+
mColorNames.put("purple", "#800080");
177+
mColorNames.put("red", "#ff0000");
178+
mColorNames.put("rosybrown", "#bc8f8f");
179+
mColorNames.put("royalblue", "#4169e1");
180+
mColorNames.put("saddlebrown", "#8b4513");
181+
mColorNames.put("salmon", "#fa8072");
182+
mColorNames.put("sandybrown", "#f4a460");
183+
mColorNames.put("seagreen", "#2e8b57");
184+
mColorNames.put("seashell", "#fff5ee");
185+
mColorNames.put("sienna", "#a0522d");
186+
mColorNames.put("silver", "#c0c0c0");
187+
mColorNames.put("skyblue", "#87ceeb");
188+
mColorNames.put("slateblue", "#6a5acd");
189+
mColorNames.put("slategray", "#708090");
190+
mColorNames.put("slategrey", "#708090");
191+
mColorNames.put("snow", "#fffafa");
192+
mColorNames.put("springgreen", "#00ff7f");
193+
mColorNames.put("steelblue", "#4682b4");
194+
mColorNames.put("tan", "#d2b48c");
195+
mColorNames.put("teal", "#008080");
196+
mColorNames.put("thistle", "#d8bfd8");
197+
mColorNames.put("tomato", "#ff6347");
198+
mColorNames.put("turquoise", "#40e0d0");
199+
mColorNames.put("violet", "#ee82ee");
200+
mColorNames.put("wheat", "#f5deb3");
201+
mColorNames.put("white", "#ffffff");
202+
mColorNames.put("whitesmoke", "#f5f5f5");
203+
mColorNames.put("yellow", "#ffff00");
204+
mColorNames.put("yellowgreen", "#9acd32");
205+
}
53206

54207
public static XmlPullParserFactory getFactory() throws XmlPullParserException {
55208
if (mFactory == null) {
@@ -308,10 +461,20 @@ private void setProperty(View view, ViewGroup root, String attr, String value)
308461
setInteger(view, attr, getInteger(InputType.class, value));
309462
} else if (attr.equals("background")) {
310463
setBackground(view, value);
464+
} else if (attr.startsWith("nextFocus")) {
465+
setInteger(view, attr + "Id", calcId(value));
311466
} else if (attr.equals("textSize")) {
312467
setFloat(view, attr, getFontSize(value));
313468
} else if (attr.equals("textColor")) {
314469
setInteger(view, attr, getColor(value));
470+
} else if (attr.equals("textStyle")) {
471+
TextView textview = (TextView) view;
472+
int style = getInteger(Typeface.class, value);
473+
if (style == 0) {
474+
textview.setTypeface(Typeface.DEFAULT);
475+
} else {
476+
textview.setTypeface(textview.getTypeface(), style);
477+
}
315478
} else if (attr.equals("src")) {
316479
setImage(view, value);
317480
} else {
@@ -403,6 +566,8 @@ private int getColor(String value) {
403566
return (int) result;
404567
} catch (Exception e) {
405568
}
569+
} else if (mColorNames.containsKey(value.toLowerCase())) {
570+
return getColor(mColorNames.get(value.toLowerCase()));
406571
}
407572
mErrors.add("Unknown color " + value);
408573
return 0;

android/ScriptingLayerForAndroid/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<manifest
33
xmlns:android="http://schemas.android.com/apk/res/android"
44
package="com.googlecode.android_scripting"
5-
android:installLocation="auto" android:versionCode="508" android:versionName="5x08">
5+
android:installLocation="auto" android:versionCode="509" android:versionName="5x09">
66
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
77
<uses-permission android:name="net.dinglisch.android.tasker.PERMISSION_RUN_TASKS"></uses-permission>
88
<application

0 commit comments

Comments
 (0)