@@ -69,8 +69,8 @@ class AndroidBuild extends JavaBuild {
6969 static public final String target_sdk = "23" ; // Marshmallow (6.0)
7070 static public final String target_platform = "android-" + target_sdk ;
7171
72- static public int appComponent = FRAGMENT ;
73- static boolean forceNewManifest = false ;
72+ private int appComponent = FRAGMENT ;
73+ static boolean forceNewManifest = false ; // TODO: this is just temporary, need to remove
7474
7575 private String renderer = "" ;
7676
@@ -88,30 +88,22 @@ class AndroidBuild extends JavaBuild {
8888 private File buildFile ;
8989
9090
91- public AndroidBuild (final Sketch sketch , final AndroidMode mode ) {
91+ public AndroidBuild (final Sketch sketch , final AndroidMode mode , final int appComp ) {
9292 super (sketch );
9393
94+ appComponent = appComp ;
9495 sdk = mode .getSDK ();
9596 coreZipFile = mode .getCoreZipLocation ();
9697 }
97-
98- public static void setPublishOption (int opt , Sketch sketch ) {
99- if (appComponent != opt ) {
100- appComponent = opt ;
101- forceNewManifest = true ;
102- } else {
103- forceNewManifest = false ;
104- }
105- }
10698
107- public static void setSdkTarget (AndroidSDK .SDKTarget target , Sketch sketch ) {
99+ // public static void setSdkTarget(AndroidSDK.SDKTarget target, Sketch sketch) {
108100// sdkName = target.name;
109101// sdkVersion = Integer.toString(target.version);
110102// sdkTarget = "android-" + sdkVersion;
111103//
112104// Preferences.set("android.sdk.version", target_);
113105// Preferences.set("android.sdk.name", target.name);
114- }
106+ // }
115107
116108 /**
117109 * Build into temporary folders (needed for the Windows 8.3 bugs in the Android SDK).
@@ -173,7 +165,7 @@ public File createProject() throws IOException, SketchException {
173165 Platform .openFolder (tmpFolder );
174166 }
175167
176- manifest = new Manifest (sketch );
168+ manifest = new Manifest (sketch , appComponent );
177169 manifest .setSdkTarget (target_sdk );
178170 forceNewManifest = false ;
179171
@@ -217,7 +209,7 @@ public File createProject() throws IOException, SketchException {
217209 copyLibraries (libsFolder , assetsFolder );
218210 copyCodeFolder (libsFolder );
219211
220- if (appComponent == WATCHFACE ) {
212+ if (getAppComponent () == WATCHFACE ) {
221213 // TODO: temporary hack until I find a better way to include the wearable aar
222214 // package included in the SDK:
223215
@@ -226,7 +218,7 @@ public File createProject() throws IOException, SketchException {
226218 Util .copyFile (wearJarFile , new File (libsFolder , "wearable-1.3.0-classes.jar" ));
227219 }
228220
229- if (appComponent == CARDBOARD ) {
221+ if (getAppComponent () == CARDBOARD ) {
230222 // TODO: temporary hack until I find a better way to include the cardboard aar
231223 // packages included in the cardboard SDK:
232224
@@ -410,6 +402,23 @@ private File createTempBuildFolder(final Sketch sketch) throws IOException {
410402 return tmp ;
411403 }
412404
405+ public boolean isWear () {
406+ return appComponent == WATCHFACE ;
407+ }
408+
409+
410+ public int getAppComponent () {
411+ return appComponent ;
412+ }
413+
414+ public void setAppComponent (int opt ) {
415+ if (appComponent != opt ) {
416+ appComponent = opt ;
417+ forceNewManifest = true ;
418+ } else {
419+ forceNewManifest = false ;
420+ }
421+ }
413422
414423 protected boolean usesGPU () {
415424 return renderer != null && (renderer .equals ("P2D" ) || renderer .equals ("P3D" ));
@@ -965,7 +974,8 @@ private void writeRes(File resFolder,
965974 File mainActivityLayoutFile = new File (layoutFolder , "main.xml" );
966975 writeResLayoutMainActivity (mainActivityLayoutFile );
967976
968- if (appComponent == WALLPAPER ) {
977+ int comp = getAppComponent ();
978+ if (comp == WALLPAPER ) {
969979 File xmlFolder = mkdirs (resFolder , "xml" );
970980 File mainServiceWallpaperFile = new File (xmlFolder , "wallpaper.xml" );
971981 writeResXMLWallpaper (mainServiceWallpaperFile );
@@ -1078,7 +1088,7 @@ private void writeRes(File resFolder,
10781088 }
10791089
10801090
1081- if (appComponent == WATCHFACE ) {
1091+ if (comp == WATCHFACE ) {
10821092 File xmlFolder = mkdirs (resFolder , "xml" );
10831093 File mainServiceWatchFaceFile = new File (xmlFolder , "watch_face.xml" );
10841094 writeResXMLWatchFace (mainServiceWatchFaceFile );
@@ -1153,17 +1163,18 @@ private File mkdirs(final File parent, final String name) throws SketchException
11531163
11541164
11551165 private void writeMainClass (final File srcDirectory , String renderer ) {
1156- if (appComponent == FRAGMENT ) {
1166+ int comp = getAppComponent ();
1167+ if (comp == FRAGMENT ) {
11571168 writeFragmentActivity (srcDirectory );
1158- } else if (appComponent == WALLPAPER ) {
1169+ } else if (comp == WALLPAPER ) {
11591170 writeWallpaperService (srcDirectory );
1160- } else if (appComponent == WATCHFACE ) {
1171+ } else if (comp == WATCHFACE ) {
11611172 if (usesGPU ()) {
11621173 writeWatchFaceGLESService (srcDirectory );
11631174 } else {
11641175 writeWatchFaceCanvasService (srcDirectory );
11651176 }
1166- } else if (appComponent == CARDBOARD ) {
1177+ } else if (comp == CARDBOARD ) {
11671178 writeCardboardActivity (srcDirectory );
11681179 }
11691180 }
0 commit comments