@@ -58,7 +58,7 @@ class AndroidBuild extends JavaBuild {
58
58
static private final String VR_ACTIVITY_TEMPLATE = "VRActivity.java.tmpl" ;
59
59
static private final String HANDHELD_ACTIVITY_TEMPLATE = "HandheldActivity.java.tmpl" ;
60
60
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";
62
62
static private final String WEARABLE_DESCRIPTION_TEMPLATE = "WearableDescription.xml.tmpl" ;
63
63
static private final String LAYOUT_ACTIVITY_TEMPLATE = "LayoutActivity.xml.tmpl" ;
64
64
static private final String STYLES_FRAGMENT_TEMPLATE = "StylesFragment.xml.tmpl" ;
@@ -165,15 +165,15 @@ public File build(String target) throws IOException, SketchException {
165
165
// https://developer.android.com/training/wearables/apps/creating.html
166
166
// so the watchface can be uninstalled from the phone, and can be
167
167
// published on Google Play.
168
- File wearFolder = createProject (targetID , true );
168
+ File wearFolder = createProject (targetID , true , true );
169
169
if (wearFolder == null ) return null ;
170
170
if (!antBuild ()) return null ;
171
171
File folder = createHandheldProject (targetID , wearFolder , null );
172
172
if (folder == null ) return null ;
173
173
if (!antBuild ()) return null ;
174
174
return folder ;
175
175
} else {
176
- File folder = createProject (targetID , false );
176
+ File folder = createProject (targetID , true , false );
177
177
if (folder != null ) {
178
178
if (!antBuild ()) {
179
179
return null ;
@@ -211,7 +211,7 @@ protected boolean ignorableImport(String pkg) {
211
211
* Populates the 'src' folder with Java code, and 'libs' folder with the
212
212
* libraries and code folder contents. Also copies data folder to 'assets'.
213
213
*/
214
- public File createProject (String targetID , boolean wear )
214
+ public File createProject (String targetID , boolean external , boolean wear )
215
215
throws IOException , SketchException {
216
216
tmpFolder = createTempBuildFolder (sketch );
217
217
if (wear ) {
@@ -251,7 +251,7 @@ public File createProject(String targetID, boolean wear)
251
251
writeRes (resFolder );
252
252
253
253
renderer = info .getRenderer ();
254
- writeMainClass (srcFolder , renderer );
254
+ writeMainClass (srcFolder , renderer , external );
255
255
256
256
final File libsFolder = mkdirs (tmpFolder , "libs" );
257
257
final File assetsFolder = mkdirs (tmpFolder , "assets" );
@@ -403,6 +403,7 @@ private void writeHandheldManifest(final File tmpFolder, String versionCode, Str
403
403
}
404
404
405
405
406
+ /*
406
407
private void writeHandheldLayout(final File resFolder) {
407
408
File xmlTemplate = mode.getContentFile("templates/" + HANDHELD_LAYOUT_TEMPLATE);
408
409
File xmlFile = new File(resFolder, "layout/activity_handheld.xml");
@@ -412,7 +413,7 @@ private void writeHandheldLayout(final File resFolder) {
412
413
413
414
AndroidMode.createFileFromTemplate(xmlTemplate, xmlFile, replaceMap);
414
415
}
415
-
416
+ */
416
417
417
418
private void writeWearableDescription (final File resFolder , final String apkName ,
418
419
final String versionCode , String versionName ) {
@@ -600,7 +601,7 @@ public File exportProject() throws IOException, SketchException {
600
601
if (appComponent == WATCHFACE ) {
601
602
// We are building a watchface not to run on the emulator. We need the
602
603
// handheld app:
603
- File wearFolder = createProject (targetID , true );
604
+ File wearFolder = createProject (targetID , false , true );
604
605
if (wearFolder == null ) return null ;
605
606
if (!antBuild ()) return null ;
606
607
@@ -617,7 +618,7 @@ public File exportProject() throws IOException, SketchException {
617
618
}
618
619
return null ;
619
620
} else {
620
- File projectFolder = createProject (targetID , false );
621
+ File projectFolder = createProject (targetID , false , false );
621
622
if (projectFolder != null ) {
622
623
File exportFolder = createExportFolder ();
623
624
if (buildSystem .equals ("gradle" )) {
@@ -637,7 +638,7 @@ public File exportPackage(String keyStorePassword) throws Exception {
637
638
this .target = "release" ;
638
639
String targetID = getTargetID ();
639
640
// We need to sign and align the wearable and handheld apps:
640
- File wearFolder = createProject (targetID , true );
641
+ File wearFolder = createProject (targetID , true , true );
641
642
if (wearFolder == null ) return null ;
642
643
if (!antBuild ()) return null ;
643
644
File signedWearPackage = signPackage (wearFolder , keyStorePassword );
@@ -1086,82 +1087,93 @@ private File mkdirs(final File parent, final String name) throws SketchException
1086
1087
}
1087
1088
1088
1089
1089
- private void writeMainClass (final File srcDirectory , String renderer ) {
1090
+ private void writeMainClass (final File srcDirectory ,
1091
+ final String renderer , final boolean external ) {
1090
1092
int comp = getAppComponent ();
1091
1093
String [] permissions = manifest .getPermissions ();
1092
1094
if (comp == FRAGMENT ) {
1093
- writeFragmentActivity (srcDirectory , permissions );
1095
+ writeFragmentActivity (srcDirectory , permissions , external );
1094
1096
} else if (comp == WALLPAPER ) {
1095
- writeWallpaperService (srcDirectory , permissions );
1097
+ writeWallpaperService (srcDirectory , permissions , external );
1096
1098
} else if (comp == WATCHFACE ) {
1097
1099
if (usesOpenGL ()) {
1098
- writeWatchFaceGLESService (srcDirectory , permissions );
1100
+ writeWatchFaceGLESService (srcDirectory , permissions , external );
1099
1101
} else {
1100
- writeWatchFaceCanvasService (srcDirectory , permissions );
1102
+ writeWatchFaceCanvasService (srcDirectory , permissions , external );
1101
1103
}
1102
1104
} else if (comp == VR ) {
1103
- writeVRActivity (srcDirectory , permissions );
1105
+ writeVRActivity (srcDirectory , permissions , external );
1104
1106
}
1105
1107
}
1106
1108
1107
1109
1108
- private void writeFragmentActivity (final File srcDirectory , String [] permissions ) {
1110
+ private void writeFragmentActivity (final File srcDirectory ,
1111
+ final String [] permissions , final boolean external ) {
1109
1112
File javaTemplate = mode .getContentFile ("templates/" + FRAGMENT_ACTIVITY_TEMPLATE );
1110
1113
File javaFile = new File (new File (srcDirectory , getPackageName ().replace ("." , "/" )), "MainActivity.java" );
1111
1114
1112
1115
HashMap <String , String > replaceMap = new HashMap <String , String >();
1113
1116
replaceMap .put ("@@package_name@@" , getPackageName ());
1114
1117
replaceMap .put ("@@sketch_class_name@@" , sketchClassName );
1118
+ replaceMap .put ("@@external@@" , external ? "\n sketch.setExternal(true);" : "" );
1115
1119
1116
1120
AndroidMode .createFileFromTemplate (javaTemplate , javaFile , replaceMap );
1117
1121
}
1118
1122
1119
1123
1120
- private void writeWallpaperService (final File srcDirectory , String [] permissions ) {
1124
+ private void writeWallpaperService (final File srcDirectory ,
1125
+ String [] permissions , final boolean external ) {
1121
1126
File javaTemplate = mode .getContentFile ("templates/" + WALLPAPER_SERVICE_TEMPLATE );
1122
1127
File javaFile = new File (new File (srcDirectory , getPackageName ().replace ("." , "/" )), "MainService.java" );
1123
1128
1124
1129
HashMap <String , String > replaceMap = new HashMap <String , String >();
1125
1130
replaceMap .put ("@@package_name@@" , getPackageName ());
1126
1131
replaceMap .put ("@@sketch_class_name@@" , sketchClassName );
1132
+ replaceMap .put ("@@external@@" , external ? "\n sketch.setExternal(true);" : "" );
1127
1133
1128
1134
AndroidMode .createFileFromTemplate (javaTemplate , javaFile , replaceMap );
1129
1135
}
1130
1136
1131
1137
1132
- private void writeWatchFaceGLESService (final File srcDirectory , String [] permissions ) {
1138
+ private void writeWatchFaceGLESService (final File srcDirectory ,
1139
+ String [] permissions , final boolean external ) {
1133
1140
File javaTemplate = mode .getContentFile ("templates/" + WATCHFACE_SERVICE_TEMPLATE );
1134
1141
File javaFile = new File (new File (srcDirectory , getPackageName ().replace ("." , "/" )), "MainService.java" );
1135
1142
1136
1143
HashMap <String , String > replaceMap = new HashMap <String , String >();
1137
1144
replaceMap .put ("@@watchface_classs@@" , "PWatchFaceGLES" );
1138
1145
replaceMap .put ("@@package_name@@" , getPackageName ());
1139
1146
replaceMap .put ("@@sketch_class_name@@" , sketchClassName );
1147
+ replaceMap .put ("@@external@@" , external ? "\n sketch.setExternal(true);" : "" );
1140
1148
1141
1149
AndroidMode .createFileFromTemplate (javaTemplate , javaFile , replaceMap );
1142
1150
}
1143
1151
1144
1152
1145
- private void writeWatchFaceCanvasService (final File srcDirectory , String [] permissions ) {
1153
+ private void writeWatchFaceCanvasService (final File srcDirectory ,
1154
+ String [] permissions , final boolean external ) {
1146
1155
File javaTemplate = mode .getContentFile ("templates/" + WATCHFACE_SERVICE_TEMPLATE );
1147
1156
File javaFile = new File (new File (srcDirectory , getPackageName ().replace ("." , "/" )), "MainService.java" );
1148
1157
1149
1158
HashMap <String , String > replaceMap = new HashMap <String , String >();
1150
1159
replaceMap .put ("@@watchface_classs@@" , "PWatchFaceCanvas" );
1151
1160
replaceMap .put ("@@package_name@@" , getPackageName ());
1152
1161
replaceMap .put ("@@sketch_class_name@@" , sketchClassName );
1162
+ replaceMap .put ("@@external@@" , external ? "\n sketch.setExternal(true);" : "" );
1153
1163
1154
1164
AndroidMode .createFileFromTemplate (javaTemplate , javaFile , replaceMap );
1155
1165
}
1156
1166
1157
1167
1158
- private void writeVRActivity (final File srcDirectory , String [] permissions ) {
1168
+ private void writeVRActivity (final File srcDirectory , String [] permissions ,
1169
+ final boolean external ) {
1159
1170
File javaTemplate = mode .getContentFile ("templates/" + VR_ACTIVITY_TEMPLATE );
1160
1171
File javaFile = new File (new File (srcDirectory , getPackageName ().replace ("." , "/" )), "MainActivity.java" );
1161
1172
1162
1173
HashMap <String , String > replaceMap = new HashMap <String , String >();
1163
1174
replaceMap .put ("@@package_name@@" , getPackageName ());
1164
1175
replaceMap .put ("@@sketch_class_name@@" , sketchClassName );
1176
+ replaceMap .put ("@@external@@" , external ? "\n sketch.setExternal(true);" : "" );
1165
1177
1166
1178
AndroidMode .createFileFromTemplate (javaTemplate , javaFile , replaceMap );
1167
1179
}
@@ -1557,7 +1569,6 @@ private void copyGVRLibs(String targetID, File libsFolder) throws IOException {
1557
1569
////////////////////////////////////////////////////////////////////////
1558
1570
// first step: unpack the VR packages in the project's
1559
1571
// libs folder:
1560
- PApplet .println ("GVR version to use" , gvr_sdk_version );
1561
1572
File baseZipFile = mode .getContentFile ("libraries/vr/gvrsdk/" + gvr_sdk_version + "/sdk-base.zip" );
1562
1573
File commonZipFile = mode .getContentFile ("libraries/vr/gvrsdk/" + gvr_sdk_version + "/sdk-common.zip" );
1563
1574
File audioZipFile = mode .getContentFile ("libraries/vr/gvrsdk/" + gvr_sdk_version + "/sdk-audio.zip" );
0 commit comments