Skip to content

Commit 354cb0a

Browse files
committed
getting external to work, and other tweaks
1 parent 999928a commit 354cb0a

File tree

9 files changed

+58
-47
lines changed

9 files changed

+58
-47
lines changed

core/src/processing/core/PApplet.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import android.os.Build;
4444
import android.os.Bundle;
4545
import android.support.annotation.LayoutRes;
46-
import android.support.v4.content.ContextCompat;
4746
import android.view.LayoutInflater;
4847
import android.view.MotionEvent;
4948
import android.view.SurfaceHolder;
@@ -480,13 +479,6 @@ public void initSurface(LayoutInflater inflater, ViewGroup container,
480479
surface = g.createSurface(component, holder, false);
481480
if (DEBUG) println("Created surface");
482481

483-
//set smooth level
484-
if (smooth == 0) {
485-
g.noSmooth();
486-
} else {
487-
g.smooth(smooth);
488-
}
489-
490482
if (parentLayout == -1) {
491483
setFullScreenVisibility();
492484
surface.initView(width, height);
@@ -1299,6 +1291,11 @@ public void setSize(int width, int height) {
12991291
}
13001292

13011293

1294+
public void setExternal(boolean external) {
1295+
this.external = external;
1296+
}
1297+
1298+
13021299
//. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13031300

13041301

core/src/processing/core/PGraphics.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,8 +847,6 @@ protected void checkSettings() {
847847
* This is currently called by checkSettings(), during beginDraw().
848848
*/
849849
protected void defaultSettings() { // ignore
850-
smooth(); // 2.0a5
851-
852850
colorMode(RGB, 255);
853851
fill(255);
854852
stroke(0);

core/src/processing/opengl/PSurfaceGLES.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ protected void callDraw() {
9999
public class SketchSurfaceViewGL extends GLSurfaceView {
100100
SurfaceHolder holder;
101101

102-
@SuppressWarnings("deprecation")
103102
public SketchSurfaceViewGL(Context context, SurfaceHolder holder) {
104103
super(context);
105104
this.holder = holder;
@@ -121,8 +120,17 @@ public SketchSurfaceViewGL(Context context, SurfaceHolder holder) {
121120
setPreserveEGLContextOnPause(true);
122121

123122
int samples = sketch.sketchSmooth();
124-
System.out.println("Using smooth level " + samples);
125-
setEGLConfigChooser(getConfigChooser(samples));
123+
if (1 < samples) {
124+
setEGLConfigChooser(getConfigChooser(samples));
125+
} else {
126+
// use default EGL config chooser for now...
127+
// setEGLConfigChooser(getConfigChooser(5, 6, 5, 4, 16, 1, samples));
128+
129+
// Some notes on how to choose an EGL configuration:
130+
// https://github.com/mapbox/mapbox-gl-native/issues/574
131+
// http://malideveloper.arm.com/sample-code/selecting-the-correct-eglconfig/
132+
}
133+
126134

127135
// The renderer can be set only once.
128136
setRenderer(getRenderer());
@@ -237,15 +245,10 @@ public AndroidContextFactory getContextFactory() {
237245
return new AndroidContextFactory();
238246
}
239247

240-
public AndroidConfigChooser getConfigChooser() {
241-
return new AndroidConfigChooser(8, 8, 8, 8, 16, 8, 1);
242-
// return new AndroidConfigChooser(5, 6, 5, 4, 16, 1, samples);
243-
}
244-
245248

246249
public AndroidConfigChooser getConfigChooser(int samples) {
247-
return new AndroidConfigChooser(8, 8, 8, 8, 16, 8, samples);
248-
// return new AndroidConfigChooser(5, 6, 5, 4, 16, 1, samples);
250+
return new AndroidConfigChooser(5, 6, 5, 4, 16, 1, samples);
251+
// return new AndroidConfigChooser(8, 8, 8, 8, 16, 8, samples);
249252
}
250253

251254

libraries/vr/src/processing/vr/PSurfaceVR.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,13 @@ public GLVRSurfaceView(Context context) {
221221
setFocusableInTouchMode(true);
222222
requestFocus();
223223

224-
setEGLConfigChooser(8, 8, 8, 8, 16, 8);
224+
225225
int samples = sketch.sketchSmooth();
226226
if (1 < samples) {
227-
System.out.println("setting multisampling to " + samples);
228227
setMultisampling(samples);
228+
} else {
229+
// use default EGL config chooser for now
230+
// setEGLConfigChooser(8, 8, 8, 8, 16, 8);
229231
}
230232

231233
// The renderer can be set only once.

src/processing/mode/android/AndroidBuild.java

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class AndroidBuild extends JavaBuild {
5858
static private final String VR_ACTIVITY_TEMPLATE = "VRActivity.java.tmpl";
5959
static private final String HANDHELD_ACTIVITY_TEMPLATE = "HandheldActivity.java.tmpl";
6060
static private final String HANDHELD_MANIFEST_TEMPLATE = "HandheldManifest.xml.tmpl";
61-
static private final String HANDHELD_LAYOUT_TEMPLATE = "HandheldLayout.xml.tmpl";
61+
// static private final String HANDHELD_LAYOUT_TEMPLATE = "HandheldLayout.xml.tmpl";
6262
static private final String WEARABLE_DESCRIPTION_TEMPLATE = "WearableDescription.xml.tmpl";
6363
static private final String LAYOUT_ACTIVITY_TEMPLATE = "LayoutActivity.xml.tmpl";
6464
static private final String STYLES_FRAGMENT_TEMPLATE = "StylesFragment.xml.tmpl";
@@ -165,15 +165,15 @@ public File build(String target) throws IOException, SketchException {
165165
// https://developer.android.com/training/wearables/apps/creating.html
166166
// so the watchface can be uninstalled from the phone, and can be
167167
// published on Google Play.
168-
File wearFolder = createProject(targetID, true);
168+
File wearFolder = createProject(targetID, true, true);
169169
if (wearFolder == null) return null;
170170
if (!antBuild()) return null;
171171
File folder = createHandheldProject(targetID, wearFolder, null);
172172
if (folder == null) return null;
173173
if (!antBuild()) return null;
174174
return folder;
175175
} else {
176-
File folder = createProject(targetID, false);
176+
File folder = createProject(targetID, true, false);
177177
if (folder != null) {
178178
if (!antBuild()) {
179179
return null;
@@ -211,7 +211,7 @@ protected boolean ignorableImport(String pkg) {
211211
* Populates the 'src' folder with Java code, and 'libs' folder with the
212212
* libraries and code folder contents. Also copies data folder to 'assets'.
213213
*/
214-
public File createProject(String targetID, boolean wear)
214+
public File createProject(String targetID, boolean external, boolean wear)
215215
throws IOException, SketchException {
216216
tmpFolder = createTempBuildFolder(sketch);
217217
if (wear) {
@@ -251,7 +251,7 @@ public File createProject(String targetID, boolean wear)
251251
writeRes(resFolder);
252252

253253
renderer = info.getRenderer();
254-
writeMainClass(srcFolder, renderer);
254+
writeMainClass(srcFolder, renderer, external);
255255

256256
final File libsFolder = mkdirs(tmpFolder, "libs");
257257
final File assetsFolder = mkdirs(tmpFolder, "assets");
@@ -403,6 +403,7 @@ private void writeHandheldManifest(final File tmpFolder, String versionCode, Str
403403
}
404404

405405

406+
/*
406407
private void writeHandheldLayout(final File resFolder) {
407408
File xmlTemplate = mode.getContentFile("templates/" + HANDHELD_LAYOUT_TEMPLATE);
408409
File xmlFile = new File(resFolder, "layout/activity_handheld.xml");
@@ -412,7 +413,7 @@ private void writeHandheldLayout(final File resFolder) {
412413
413414
AndroidMode.createFileFromTemplate(xmlTemplate, xmlFile, replaceMap);
414415
}
415-
416+
*/
416417

417418
private void writeWearableDescription(final File resFolder, final String apkName,
418419
final String versionCode, String versionName) {
@@ -600,7 +601,7 @@ public File exportProject() throws IOException, SketchException {
600601
if (appComponent == WATCHFACE) {
601602
// We are building a watchface not to run on the emulator. We need the
602603
// handheld app:
603-
File wearFolder = createProject(targetID, true);
604+
File wearFolder = createProject(targetID, false, true);
604605
if (wearFolder == null) return null;
605606
if (!antBuild()) return null;
606607

@@ -617,7 +618,7 @@ public File exportProject() throws IOException, SketchException {
617618
}
618619
return null;
619620
} else {
620-
File projectFolder = createProject(targetID, false);
621+
File projectFolder = createProject(targetID, false, false);
621622
if (projectFolder != null) {
622623
File exportFolder = createExportFolder();
623624
if (buildSystem.equals("gradle")) {
@@ -637,7 +638,7 @@ public File exportPackage(String keyStorePassword) throws Exception {
637638
this.target = "release";
638639
String targetID = getTargetID();
639640
// We need to sign and align the wearable and handheld apps:
640-
File wearFolder = createProject(targetID, true);
641+
File wearFolder = createProject(targetID, true, true);
641642
if (wearFolder == null) return null;
642643
if (!antBuild()) return null;
643644
File signedWearPackage = signPackage(wearFolder, keyStorePassword);
@@ -1086,82 +1087,93 @@ private File mkdirs(final File parent, final String name) throws SketchException
10861087
}
10871088

10881089

1089-
private void writeMainClass(final File srcDirectory, String renderer) {
1090+
private void writeMainClass(final File srcDirectory,
1091+
final String renderer, final boolean external) {
10901092
int comp = getAppComponent();
10911093
String[] permissions = manifest.getPermissions();
10921094
if (comp == FRAGMENT) {
1093-
writeFragmentActivity(srcDirectory, permissions);
1095+
writeFragmentActivity(srcDirectory, permissions, external);
10941096
} else if (comp == WALLPAPER) {
1095-
writeWallpaperService(srcDirectory, permissions);
1097+
writeWallpaperService(srcDirectory, permissions, external);
10961098
} else if (comp == WATCHFACE) {
10971099
if (usesOpenGL()) {
1098-
writeWatchFaceGLESService(srcDirectory, permissions);
1100+
writeWatchFaceGLESService(srcDirectory, permissions, external);
10991101
} else {
1100-
writeWatchFaceCanvasService(srcDirectory, permissions);
1102+
writeWatchFaceCanvasService(srcDirectory, permissions, external);
11011103
}
11021104
} else if (comp == VR) {
1103-
writeVRActivity(srcDirectory, permissions);
1105+
writeVRActivity(srcDirectory, permissions, external);
11041106
}
11051107
}
11061108

11071109

1108-
private void writeFragmentActivity(final File srcDirectory, String[] permissions) {
1110+
private void writeFragmentActivity(final File srcDirectory,
1111+
final String[] permissions, final boolean external) {
11091112
File javaTemplate = mode.getContentFile("templates/" + FRAGMENT_ACTIVITY_TEMPLATE);
11101113
File javaFile = new File(new File(srcDirectory, getPackageName().replace(".", "/")), "MainActivity.java");
11111114

11121115
HashMap<String, String> replaceMap = new HashMap<String, String>();
11131116
replaceMap.put("@@package_name@@", getPackageName());
11141117
replaceMap.put("@@sketch_class_name@@", sketchClassName);
1118+
replaceMap.put("@@external@@", external ? "\n sketch.setExternal(true);" : "");
11151119

11161120
AndroidMode.createFileFromTemplate(javaTemplate, javaFile, replaceMap);
11171121
}
11181122

11191123

1120-
private void writeWallpaperService(final File srcDirectory, String[] permissions) {
1124+
private void writeWallpaperService(final File srcDirectory,
1125+
String[] permissions, final boolean external) {
11211126
File javaTemplate = mode.getContentFile("templates/" + WALLPAPER_SERVICE_TEMPLATE);
11221127
File javaFile = new File(new File(srcDirectory, getPackageName().replace(".", "/")), "MainService.java");
11231128

11241129
HashMap<String, String> replaceMap = new HashMap<String, String>();
11251130
replaceMap.put("@@package_name@@", getPackageName());
11261131
replaceMap.put("@@sketch_class_name@@", sketchClassName);
1132+
replaceMap.put("@@external@@", external ? "\n sketch.setExternal(true);" : "");
11271133

11281134
AndroidMode.createFileFromTemplate(javaTemplate, javaFile, replaceMap);
11291135
}
11301136

11311137

1132-
private void writeWatchFaceGLESService(final File srcDirectory, String[] permissions) {
1138+
private void writeWatchFaceGLESService(final File srcDirectory,
1139+
String[] permissions, final boolean external) {
11331140
File javaTemplate = mode.getContentFile("templates/" + WATCHFACE_SERVICE_TEMPLATE);
11341141
File javaFile = new File(new File(srcDirectory, getPackageName().replace(".", "/")), "MainService.java");
11351142

11361143
HashMap<String, String> replaceMap = new HashMap<String, String>();
11371144
replaceMap.put("@@watchface_classs@@", "PWatchFaceGLES");
11381145
replaceMap.put("@@package_name@@", getPackageName());
11391146
replaceMap.put("@@sketch_class_name@@", sketchClassName);
1147+
replaceMap.put("@@external@@", external ? "\n sketch.setExternal(true);" : "");
11401148

11411149
AndroidMode.createFileFromTemplate(javaTemplate, javaFile, replaceMap);
11421150
}
11431151

11441152

1145-
private void writeWatchFaceCanvasService(final File srcDirectory, String[] permissions) {
1153+
private void writeWatchFaceCanvasService(final File srcDirectory,
1154+
String[] permissions, final boolean external) {
11461155
File javaTemplate = mode.getContentFile("templates/" + WATCHFACE_SERVICE_TEMPLATE);
11471156
File javaFile = new File(new File(srcDirectory, getPackageName().replace(".", "/")), "MainService.java");
11481157

11491158
HashMap<String, String> replaceMap = new HashMap<String, String>();
11501159
replaceMap.put("@@watchface_classs@@", "PWatchFaceCanvas");
11511160
replaceMap.put("@@package_name@@", getPackageName());
11521161
replaceMap.put("@@sketch_class_name@@", sketchClassName);
1162+
replaceMap.put("@@external@@", external ? "\n sketch.setExternal(true);" : "");
11531163

11541164
AndroidMode.createFileFromTemplate(javaTemplate, javaFile, replaceMap);
11551165
}
11561166

11571167

1158-
private void writeVRActivity(final File srcDirectory, String[] permissions) {
1168+
private void writeVRActivity(final File srcDirectory, String[] permissions,
1169+
final boolean external) {
11591170
File javaTemplate = mode.getContentFile("templates/" + VR_ACTIVITY_TEMPLATE);
11601171
File javaFile = new File(new File(srcDirectory, getPackageName().replace(".", "/")), "MainActivity.java");
11611172

11621173
HashMap<String, String> replaceMap = new HashMap<String, String>();
11631174
replaceMap.put("@@package_name@@", getPackageName());
11641175
replaceMap.put("@@sketch_class_name@@", sketchClassName);
1176+
replaceMap.put("@@external@@", external ? "\n sketch.setExternal(true);" : "");
11651177

11661178
AndroidMode.createFileFromTemplate(javaTemplate, javaFile, replaceMap);
11671179
}
@@ -1557,7 +1569,6 @@ private void copyGVRLibs(String targetID, File libsFolder) throws IOException {
15571569
////////////////////////////////////////////////////////////////////////
15581570
// first step: unpack the VR packages in the project's
15591571
// libs folder:
1560-
PApplet.println("GVR version to use", gvr_sdk_version);
15611572
File baseZipFile = mode.getContentFile("libraries/vr/gvrsdk/" + gvr_sdk_version + "/sdk-base.zip");
15621573
File commonZipFile = mode.getContentFile("libraries/vr/gvrsdk/" + gvr_sdk_version + "/sdk-common.zip");
15631574
File audioZipFile = mode.getContentFile("libraries/vr/gvrsdk/" + gvr_sdk_version + "/sdk-audio.zip");

templates/FragmentActivity.java.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class MainActivity extends AppCompatActivity {
2020
setContentView(frame, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
2121
ViewGroup.LayoutParams.MATCH_PARENT));
2222

23-
sketch = new @@sketch_class_name@@();
23+
sketch = new @@sketch_class_name@@();@@external@@
2424
PFragment fragment = new PFragment();
2525
fragment.setSketch(sketch, frame, getSupportFragmentManager());
2626
}

templates/VRActivity.java.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class MainActivity extends PVR {
99
@Override
1010
public void onCreate(Bundle savedInstanceState) {
1111
super.onCreate(savedInstanceState);
12-
PApplet sketch = new @@sketch_class_name@@();
12+
PApplet sketch = new @@sketch_class_name@@();@@external@@
1313
setSketch(sketch);
1414
}
1515
}

templates/WallpaperService.java.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import processing.core.PApplet;
66
public class MainService extends PWallpaper {
77
@Override
88
public PApplet createSketch() {
9-
PApplet sketch = new @@sketch_class_name@@();
9+
PApplet sketch = new @@sketch_class_name@@();@@external@@
1010
return sketch;
1111
}
1212
}

templates/WatchFaceService.java.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import processing.core.PApplet;
66
public class MainService extends @@watchface_classs@@ {
77
@Override
88
public PApplet createSketch() {
9-
PApplet sketch = new @@sketch_class_name@@();
9+
PApplet sketch = new @@sketch_class_name@@();@@external@@
1010
return sketch;
1111
}
1212
}

0 commit comments

Comments
 (0)