Skip to content

Commit c8258ec

Browse files
author
Jamie Stuart
committed
Merge remote-tracking branch 'upstream/master'
Field Trial Submission 1 update
2 parents f1206ad + 411a930 commit c8258ec

File tree

140 files changed

+24580
-1736
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+24580
-1736
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ android {
5555
targetSdkVersion 23
5656
versionCode 1
5757
versionName '1.0'
58-
resValue "string", "app_name", "Pedro"
58+
resValue "string", "app_name", "Setup Prototype"
5959
buildConfigField 'String', 'SETTINGS_FILE', '"config/settings_pedro.plist"'
6060
manifestPlaceholders = [
6161
appIcon: "@mipmap/judges",
@@ -73,6 +73,18 @@ android {
7373
appIcon: "@mipmap/judges",
7474
]
7575
}
76+
judgeMenu_test {
77+
minSdkVersion 22
78+
applicationId 'org.onebillion.onecourse.judges'
79+
targetSdkVersion 23
80+
versionCode 1
81+
versionName '1.0'
82+
resValue "string", "app_name", "onecourse - Judges"
83+
buildConfigField 'String', 'SETTINGS_FILE', '"config/settings_judge_test.plist"'
84+
manifestPlaceholders = [
85+
appIcon: "@mipmap/judges",
86+
]
87+
}
7688
// judgeMenu_ny_ {
7789
// minSdkVersion 23
7890
// applicationId 'org.onebillion.onecourse.judges.ny'
@@ -92,7 +104,19 @@ android {
92104
versionCode 1
93105
versionName '1.0'
94106
resValue "string", "app_name", "onecourse - Child"
95-
buildConfigField 'String', 'SETTINGS_FILE', '"config/settings_child_sw.plist"'
107+
buildConfigField 'String', 'SETTINGS_FILE', '"config/settings_community_sw.plist"'
108+
manifestPlaceholders = [
109+
appIcon: "@mipmap/icon_child"
110+
]
111+
}
112+
childMenuTestVersion {
113+
minSdkVersion 22
114+
applicationId 'org.onebillion.onecourse.child.test'
115+
targetSdkVersion 23
116+
versionCode 1
117+
versionName '1.0'
118+
resValue "string", "app_name", "Dev - Child"
119+
buildConfigField 'String', 'SETTINGS_FILE', '"config/settings_test_sw.plist"'
96120
manifestPlaceholders = [
97121
appIcon: "@mipmap/icon_child"
98122
]
@@ -104,7 +128,19 @@ android {
104128
versionCode 1
105129
versionName '1.0'
106130
resValue "string", "app_name", "onecourse - Child (english)"
107-
buildConfigField 'String', 'SETTINGS_FILE', '"config/settings_child_en_GB.plist"'
131+
buildConfigField 'String', 'SETTINGS_FILE', '"config/settings_community_enGB.plist"'
132+
manifestPlaceholders = [
133+
appIcon: "@mipmap/child_en_gb"
134+
]
135+
}
136+
childMenu_enGB_TestVersion {
137+
minSdkVersion 22
138+
applicationId 'org.onebillion.onecourse.child.en_GB.test'
139+
targetSdkVersion 23
140+
versionCode 1
141+
versionName '1.0'
142+
resValue "string", "app_name", "Dev - Child enGB"
143+
buildConfigField 'String', 'SETTINGS_FILE', '"config/settings_test_enGB.plist"'
108144
manifestPlaceholders = [
109145
appIcon: "@mipmap/child_en_gb"
110146
]
@@ -133,6 +169,18 @@ android {
133169
appIcon: "@mipmap/child_ny"
134170
]
135171
}
172+
wifiTestVersion {
173+
minSdkVersion 22
174+
applicationId 'org.onebillion.onecourse.wifi.test'
175+
targetSdkVersion 23
176+
versionCode 1
177+
versionName '1.0'
178+
resValue "string", "app_name", "onecourse - wifi"
179+
buildConfigField 'String', 'SETTINGS_FILE', '"config/settings_test_wifi.plist"'
180+
manifestPlaceholders = [
181+
appIcon: "@mipmap/child_en_gb"
182+
]
183+
}
136184
}
137185
}
138186

@@ -145,4 +193,5 @@ dependencies {
145193
// compile 'org.apache.httpcomponents:httpclient:4.5'
146194
//
147195
compile files('libs/commons-io-2.5.jar')
196+
compile files('libs/commons-net-3.6.jar')
148197
}

app/libs/commons-net-3.6.jar

300 KB
Binary file not shown.

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
1818
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"/>
1919
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
20-
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
2120
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
2221
<uses-permission android:name="android.permission.WAKE_LOCK"/>
2322
<uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
@@ -28,7 +27,9 @@
2827
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
2928
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
3029
<uses-permission android:name="android.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS" />
30+
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
3131
<uses-permission android:name="android.permission.SET_TIME" />
32+
<uses-permission android:name="android.permission.DEVICE_POWER" />
3233

3334
<uses-feature android:name="android.hardware.camera"/>
3435
<uses-feature android:name="android.hardware.camera.autofocus"/>
@@ -104,6 +105,7 @@
104105
</intent-filter>
105106
</activity>
106107

108+
<!--
107109
<receiver android:name="org.onebillion.onecourse.receivers.OBBatteryReceiver">
108110
<intent-filter>
109111
<action android:name="android.intent.action.ACTION_BATTERY_LOW"/>
@@ -112,8 +114,8 @@
112114
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED"/>
113115
</intent-filter>
114116
</receiver>
115-
116-
<receiver android:name="org.onebillion.onecourse.utils.OBAlarmReceiver"></receiver>
117+
-->
118+
<receiver android:name="org.onebillion.onecourse.receivers.OBAlarmReceiver"></receiver>
117119
</application>
118120

119121
</manifest>

app/src/main/java/org/onebillion/onecourse/controls/OBControl.java

Lines changed: 98 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class OBControl
3939
public static int LCC_NORMAL = 0,
4040
LCC_DISABLED = 1,
4141
LCC_SELECTED = 2;
42-
public static int APPLY_EFFECTS = 1;
42+
public static int APPLY_EFFECTS = 1,IGNORE_DYNAMIC_MASK = 2;
4343
public int state;
4444
public Map<String, Object> settings;
4545
public OBLayer layer;
@@ -59,6 +59,7 @@ public class OBControl
5959
public String textureKey;
6060
public Texture texture;
6161
public float[] modelMatrix = new float[16];
62+
public float[] multiplyMatrix = new float[16];
6263
public float[] tempMatrix = new float[16];
6364
public float[] shadMatrix = new float[16];
6465
public float blendColour[] = {1, 1, 1, 1};
@@ -72,7 +73,7 @@ public class OBControl
7273
float rasterScale, zPosition;
7374
OBStroke stroke;
7475
boolean frameValid, masksToBounds,displayBoundsValid=false;
75-
boolean maskControlReversed = false, dynamicMask = false;
76+
public boolean maskControlReversed = false, dynamicMask = false;
7677
private int shadowColour;
7778
float shadowOffsetX, shadowOffsetY, shadowOpacity, shadowRadius;
7879
float shadowPad = 0f;
@@ -106,6 +107,7 @@ public OBControl ()
106107
rasterScale = 1;
107108
blendMode = 1;
108109
layer = new OBLayer();
110+
android.opengl.Matrix.setIdentityM(multiplyMatrix, 0);
109111
}
110112

111113
public static List<OBControl> controlsSortedFrontToBack (List<OBControl> controls)
@@ -248,14 +250,17 @@ public void setBounds (float l, float t, float r, float b)
248250

249251
public RectF frame ()
250252
{
251-
if (!frameValid)
253+
synchronized (frame)
252254
{
253-
frame.set(bounds());
254-
Matrix m = matrixForBackwardConvert();
255-
m.mapRect(frame);
256-
frameValid = true;
255+
if (!frameValid)
256+
{
257+
frame.set(bounds());
258+
Matrix m = matrixForBackwardConvert();
259+
m.mapRect(frame);
260+
frameValid = true;
261+
}
262+
return frame;
257263
}
258-
return frame;
259264
}
260265

261266
public void setFrame (RectF f)
@@ -597,6 +602,7 @@ public void drawLayer(Canvas canvas, int flags)
597602
canvas.saveLayerAlpha(bounds(), (int) (opacity() * 255));
598603
}
599604
layer.draw(canvas);
605+
applyMask(canvas,flags);
600606
if (needsRestore)
601607
canvas.restore();
602608
}
@@ -1202,7 +1208,11 @@ public float[] matrix3dForDraw ()
12021208
android.opengl.Matrix.rotateM(modelMatrix, 0, (float) Math.toDegrees(yRotation), 1, 0, 0);
12031209
if (scaleX != 1 || scaleY != 1)
12041210
android.opengl.Matrix.scaleM(modelMatrix, 0, scaleX, scaleY, 1);
1211+
1212+
1213+
android.opengl.Matrix.multiplyMM(modelMatrix,0,modelMatrix,0,multiplyMatrix,0);
12051214
android.opengl.Matrix.translateM(modelMatrix, 0, -ax, -ay, 0);
1215+
12061216
return modelMatrix;
12071217

12081218
}
@@ -1391,11 +1401,16 @@ public boolean isInsideView(float[] modelViewMatrix)
13911401
}
13921402

13931403
public void draw (Canvas canvas)
1404+
{
1405+
draw(canvas,0);
1406+
}
1407+
1408+
public void draw (Canvas canvas,int flags)
13941409
{
13951410
if (!hidden)
13961411
{
13971412
canvas.save();
1398-
boolean shadowrequired = (shadowColour != 0 && shadowRadius > 0);
1413+
boolean shadowrequired = shadowOpacity > 0;
13991414
if (cache != null)
14001415
{
14011416
Matrix m = matrixForDraw();
@@ -1435,10 +1450,17 @@ else if (shadowrequired)
14351450
canvas.saveLayer(bounds(), p, Canvas.ALL_SAVE_FLAG);*/
14361451
if (shadowCache == null)
14371452
createShadowCache(drawn());
1453+
1454+
Matrix m = new Matrix();
1455+
float rs = 1 / rasterScale;
1456+
m.preScale(rs, rs);
1457+
canvas.save();
1458+
canvas.concat(m);
14381459
canvas.drawBitmap(shadowCache, shadowOffsetX, shadowOffsetY, new Paint());
1460+
canvas.restore();
14391461
}
14401462
drawBorderAndBackground(canvas);
1441-
drawLayer(canvas,APPLY_EFFECTS);
1463+
drawLayer(canvas,flags | APPLY_EFFECTS);
14421464

14431465
}
14441466
canvas.restore();
@@ -1692,6 +1714,17 @@ public void setScreenMaskControl(OBControl m)
16921714
invalidate();
16931715
}
16941716

1717+
1718+
public void setScreenMaskControl(OBControl m, OBViewController cont)
1719+
{
1720+
m.texturise(false,cont);
1721+
dynamicMask = true;
1722+
maskControlReversed = false;
1723+
maskControl = m;
1724+
invalidate();
1725+
}
1726+
1727+
16951728
public void setReversedScreenMaskControl(OBControl m)
16961729
{
16971730
m.texturise(false,controller);
@@ -1701,6 +1734,16 @@ public void setReversedScreenMaskControl(OBControl m)
17011734
invalidate();
17021735
}
17031736

1737+
public void setReversedScreenMaskControl(OBControl m, OBViewController cont)
1738+
{
1739+
m.texturise(false,cont);
1740+
dynamicMask = true;
1741+
maskControlReversed = true;
1742+
maskControl = m;
1743+
invalidate();
1744+
}
1745+
1746+
17041747
public float rotation ()
17051748
{
17061749
return rotation;
@@ -1840,6 +1883,11 @@ public void setShadow (final float sradius, final float sopacity, final float so
18401883

18411884
}
18421885

1886+
public void setShadowOpacity(float opacity)
1887+
{
1888+
setShadow(shadowRadius,opacity,shadowOffsetX,shadowOffsetY,shadowColour);
1889+
}
1890+
18431891
private boolean shouldRenderShadow()
18441892
{
18451893
return parent == null && shadowOpacity > 0;
@@ -2103,4 +2151,44 @@ public RectF displayBounds()
21032151
}
21042152
return displayBounds;
21052153
}
2154+
2155+
2156+
public int YPositionCompare(OBControl other)
2157+
{
2158+
return (int) (this.position.y - other.position.y);
2159+
}
2160+
2161+
protected void applyMask(Canvas canvas,int flags)
2162+
{
2163+
if (maskControl != null && (dynamicMask == false || (flags & IGNORE_DYNAMIC_MASK) != 0))
2164+
{
2165+
Paint p = new Paint();
2166+
p.setXfermode(new PorterDuffXfermode(maskControlReversed ? PorterDuff.Mode.DST_OUT : PorterDuff.Mode.DST_IN));
2167+
float fw = (bounds().right - bounds().left) * Math.abs(rasterScale);
2168+
float fh = (bounds().bottom - bounds().top) * Math.abs(rasterScale);
2169+
int width = (int) Math.ceil(fw);
2170+
int height = (int) Math.ceil(fh);
2171+
boolean needs2ndrestore = false;
2172+
canvas.saveLayer(0, 0, width, height, p, Canvas.ALL_SAVE_FLAG);
2173+
if (dynamicMask)
2174+
{
2175+
canvas.save();
2176+
needs2ndrestore = true;
2177+
RectF f = frame();
2178+
canvas.translate(-f.left,-f.top);
2179+
}
2180+
maskControl.draw(canvas);
2181+
canvas.restore();
2182+
if (needs2ndrestore)
2183+
canvas.restore();
2184+
}
2185+
}
2186+
2187+
public void sizeBoundsToShadow()
2188+
{
2189+
RectF bounds = bounds();
2190+
bounds.inset(-Math.abs(shadowOffsetX), -Math.abs(shadowOffsetY));
2191+
setBounds(bounds);
2192+
}
2193+
21062194
}

app/src/main/java/org/onebillion/onecourse/controls/OBGradientPath.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,22 @@ public void drawLayer(Canvas canvas, int flags)
145145
{
146146
if (gradientLayer != null)
147147
{
148+
boolean needsRestore = false;
148149
canvas.save();
149150
if (highlightColour != 0)
150151
{
151152
gradientLayer.setColourFilter(new PorterDuffColorFilter(highlightColour, PorterDuff.Mode.SRC_ATOP));
152153
}
154+
if (needsRestore = (opacity() != 1.0f))
155+
canvas.saveLayerAlpha(bounds(), (int) (opacity() * 255));
153156
if (maskLayer != null)
154157
canvas.clipPath(maskLayer.path);
155158
gradientLayer.draw(canvas);
156159
if (strokeLayer != null)
157160
strokeLayer.draw(canvas);
161+
162+
if (needsRestore)
163+
canvas.restore();
158164
canvas.restore();
159165
}
160166
}

app/src/main/java/org/onebillion/onecourse/controls/OBGroup.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -819,18 +819,7 @@ public void drawLayer(Canvas canvas, int flags)
819819
canvas.saveLayerAlpha(bounds(), (int) (opacity() * 255));
820820
for (OBControl c : sortedAttachedControls)
821821
c.draw(canvas);
822-
if (maskControl != null && dynamicMask == false)
823-
{
824-
Paint p = new Paint();
825-
p.setXfermode(new PorterDuffXfermode(maskControlReversed ? PorterDuff.Mode.DST_OUT : PorterDuff.Mode.DST_IN));
826-
float fw = (bounds().right - bounds().left) * Math.abs(rasterScale);
827-
float fh = (bounds().bottom - bounds().top) * Math.abs(rasterScale);
828-
int width = (int) Math.ceil(fw);
829-
int height = (int) Math.ceil(fh);
830-
canvas.saveLayer(0, 0, width, height, p, Canvas.ALL_SAVE_FLAG);
831-
maskControl.draw(canvas);
832-
canvas.restore();
833-
}
822+
applyMask(canvas,flags);
834823

835824
if (needsRestore)
836825
canvas.restore();

0 commit comments

Comments
 (0)