@@ -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" );
0 commit comments