Skip to content

Commit 73e1ac7

Browse files
committed
renamed icon files
1 parent aaf1157 commit 73e1ac7

16 files changed

+94
-158
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

mode/src/processing/mode/android/AndroidBuild.java

Lines changed: 36 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,20 @@ class AndroidBuild extends JavaBuild {
148148
static private final String WEAR_GRADLE_BUILD_ECJ_TEMPLATE = "WearBuildECJ.gradle.tmpl";
149149
static private final String WEAR_GRADLE_BUILD_TEMPLATE = "WearBuild.gradle.tmpl";
150150

151-
// Icon files
152-
static final String ICON_36 = "icon-36.png";
153-
static final String ICON_48 = "icon-48.png";
154-
static final String ICON_72 = "icon-72.png";
155-
static final String ICON_96 = "icon-96.png";
156-
static final String ICON_144 = "icon-144.png";
157-
static final String ICON_192 = "icon-192.png";
158-
static final String WATCHFACE_ICON_CIRCULAR = "preview_circular.png";
159-
static final String WATCHFACE_ICON_RECTANGULAR = "preview_rectangular.png";
151+
// Launcher and watch face icon files
152+
static final String[] SKETCH_LAUNCHER_ICONS = {"launcher_36.png", "launcher_48.png",
153+
"launcher_72.png", "launcher_96.png",
154+
"launcher_144.png", "launcher_192.png"};
155+
static final String[] SKETCH_OLD_LAUNCHER_ICONS = {"icon-36.png", "icon-48.png",
156+
"icon-72.png", "icon-96.png",
157+
"icon-144.png", "icon-192.png"};
158+
static final String[] BUILD_LAUNCHER_ICONS = {"mipmap-ldpi/ic_launcher.png", "mipmap-mdpi/ic_launcher.png",
159+
"mipmap-hdpi/ic_launcher.png", "mipmap-xhdpi/ic_launcher.png",
160+
"mipmap-xxhdpi/ic_launcher.png", "mipmap-xxxhdpi/ic_launcher.png"};
161+
static final String[] SKETCH_WATCHFACE_ICONS = {"preview_circular.png",
162+
"preview_rectangular.png"};
163+
static final String[] BUILD_WATCHFACE_ICONS = {"drawable-nodpi/preview_circular.png",
164+
"drawable-nodpi/preview_rectangular.png"};
160165

161166
private int appComponent = APP;
162167

@@ -638,10 +643,10 @@ private void writeRes(File resFolder) throws SketchException {
638643
}
639644

640645
File sketchFolder = sketch.getFolder();
641-
writeAppIconFiles(sketchFolder, resFolder);
646+
writeLauncherIconFiles(sketchFolder, resFolder);
642647
if (comp == WATCHFACE) {
643648
// Need the preview icons for watch faces.
644-
writeWatchIconFiles(sketchFolder, resFolder);
649+
writeWatchFaceIconFiles(sketchFolder, resFolder);
645650
}
646651
}
647652

@@ -650,74 +655,38 @@ private void writeRes(File resFolder) throws SketchException {
650655
// Icons
651656

652657

653-
private void writeAppIconFiles(File sketchFolder, File resFolder) {
654-
File localIcon36 = new File(sketchFolder, ICON_36);
655-
File localIcon48 = new File(sketchFolder, ICON_48);
656-
File localIcon72 = new File(sketchFolder, ICON_72);
657-
File localIcon96 = new File(sketchFolder, ICON_96);
658-
File localIcon144 = new File(sketchFolder, ICON_144);
659-
File localIcon192 = new File(sketchFolder, ICON_192);
660-
661-
File buildIcon48 = new File(resFolder, "drawable/icon.png");
662-
File buildIcon36 = new File(resFolder, "drawable-ldpi/icon.png");
663-
File buildIcon72 = new File(resFolder, "drawable-hdpi/icon.png");
664-
File buildIcon96 = new File(resFolder, "drawable-xhdpi/icon.png");
665-
File buildIcon144 = new File(resFolder, "drawable-xxhdpi/icon.png");
666-
File buildIcon192 = new File(resFolder, "drawable-xxxhdpi/icon.png");
667-
668-
if (!localIcon36.exists() && !localIcon48.exists() &&
669-
!localIcon72.exists() && !localIcon96.exists() &&
670-
!localIcon144.exists() && !localIcon192.exists()) {
671-
try {
672-
// if no icons are in the sketch folder, then copy all the defaults
673-
copyIcon(mode.getContentFile("icons/" + ICON_36), buildIcon36);
674-
copyIcon(mode.getContentFile("icons/" + ICON_48), buildIcon48);
675-
copyIcon(mode.getContentFile("icons/" + ICON_72), buildIcon72);
676-
copyIcon(mode.getContentFile("icons/" + ICON_96), buildIcon96);
677-
copyIcon(mode.getContentFile("icons/" + ICON_144), buildIcon144);
678-
copyIcon(mode.getContentFile("icons/" + ICON_192), buildIcon192);
679-
} catch (IOException e) {
680-
e.printStackTrace();
681-
}
682-
} else {
683-
// if at least one of the icons already exists, then use that across the board
684-
try {
685-
if (localIcon36.exists()) copyIcon(localIcon36, buildIcon36);
686-
if (localIcon48.exists()) copyIcon(localIcon48, buildIcon48);
687-
if (localIcon72.exists()) copyIcon(localIcon72, buildIcon72);
688-
if (localIcon96.exists()) copyIcon(localIcon96, buildIcon96);
689-
if (localIcon144.exists()) copyIcon(localIcon144, buildIcon144);
690-
if (localIcon192.exists()) copyIcon(localIcon192, buildIcon192);
691-
} catch (IOException e) {
692-
System.err.println("Problem while copying app icons.");
693-
e.printStackTrace();
694-
}
695-
}
658+
private void writeLauncherIconFiles(File sketchFolder, File resFolder) {
659+
writeIconFiles(sketchFolder, resFolder, SKETCH_LAUNCHER_ICONS, SKETCH_OLD_LAUNCHER_ICONS, BUILD_LAUNCHER_ICONS);
696660
}
697661

698662

699-
private void writeWatchIconFiles(File sketchFolder, File resFolder) {
700-
copyWatchIcon(new File(sketchFolder, WATCHFACE_ICON_CIRCULAR),
701-
new File(resFolder, "drawable/preview_circular.png"),
702-
mode.getContentFile("icons/" + WATCHFACE_ICON_CIRCULAR));
703-
copyWatchIcon(new File(sketchFolder, WATCHFACE_ICON_RECTANGULAR),
704-
new File(resFolder, "drawable/preview_rectangular.png"),
705-
mode.getContentFile("icons/" + WATCHFACE_ICON_RECTANGULAR));
663+
private void writeWatchFaceIconFiles(File sketchFolder, File resFolder) {
664+
writeIconFiles(sketchFolder, resFolder, SKETCH_WATCHFACE_ICONS, null, BUILD_WATCHFACE_ICONS);
706665
}
707666

708667

709-
private void copyWatchIcon(File srcFile, File destFile, File defFile) {
710-
if (!srcFile.exists()) {
668+
private void writeIconFiles(File sketchFolder, File resFolder,
669+
String[] sketchIconNames, String[] oldIconNames, String[] buildIconNames) {
670+
File[] localIcons = AndroidUtil.getFileList(sketchFolder, sketchIconNames, oldIconNames);
671+
File[] buildIcons = AndroidUtil.getFileList(resFolder, buildIconNames);
672+
if (AndroidUtil.noFileExists(localIcons)) {
673+
// If no icons are in the sketch folder, then copy all the defaults
674+
File[] defaultIcons = AndroidUtil.getFileList(mode, "icons/", sketchIconNames);
711675
try {
712-
copyIcon(defFile, destFile);
676+
for (int i = 0; i < localIcons.length; i++) {
677+
copyIcon(defaultIcons[i], buildIcons[i]);
678+
}
713679
} catch (IOException e) {
714680
e.printStackTrace();
715-
}
681+
}
716682
} else {
683+
// If at least one of the icons already exists, then use that across the board
717684
try {
718-
copyIcon(srcFile, destFile);
685+
for (int i = 0; i < localIcons.length; i++) {
686+
if (localIcons[i].exists()) copyIcon(localIcons[i], buildIcons[i]);
687+
}
719688
} catch (IOException e) {
720-
System.err.println("Problem while copying watch face icon.");
689+
System.err.println("Problem while copying icons.");
721690
e.printStackTrace();
722691
}
723692
}
@@ -732,73 +701,7 @@ private void copyIcon(File srcFile, File destFile) throws IOException {
732701
System.err.println("Could not create \"" + destFile.getParentFile() + "\" folder.");
733702
}
734703
}
735-
736-
737-
// ---------------------------------------------------------------------------
738-
// Dependencies
739-
740-
741-
// private void copyWearLib(File libsFolder) throws IOException {
742-
// The wear aar is needed even when the app is not a watch face, because on
743-
// devices with android < 5 the dependencies of the PWatchFace* classes
744-
// cannot be resolved.
745-
// copyAARFileFromSDK(sdk.getWearableFolder() + "/$VER", "wearable-$VER.aar", WEAR_VER, libsFolder);
746-
// }
747-
748-
749-
// private void copySupportLibs(File libsFolder) throws IOException {
750-
// copyAARFileFromSDK(sdk.getSupportLibrary() + "/support-core-utils/$VER", "support-core-utils-$VER.aar", SUPPORT_VER, libsFolder);
751-
// copyAARFileFromSDK(sdk.getSupportLibrary() + "/support-compat/$VER", "support-compat-$VER.aar", SUPPORT_VER, libsFolder);
752-
// copyAARFileFromSDK(sdk.getSupportLibrary() + "/support-fragment/$VER", "support-fragment-$VER.aar", SUPPORT_VER, libsFolder);
753-
// copyAARFileFromSDK(sdk.getSupportLibrary() + "/support-vector-drawable/$VER", "support-vector-drawable-$VER.aar", SUPPORT_VER, libsFolder);
754-
// }
755-
756-
757-
// private void copyAppCompatLib(File libsFolder) throws IOException {
758-
// copyAARFileFromSDK(sdk.getSupportLibrary() + "/appcompat-v7/$VER", "appcompat-v7-$VER.aar", SUPPORT_VER, libsFolder);
759-
// }
760-
761-
762-
// private void copyGVRLibs(File libsFolder) throws IOException {
763-
// copyAARFileFromMode("/libraries/vr/gvrsdk/$VER", "sdk-base-$VER.aar", GVR_VER, libsFolder);
764-
// copyAARFileFromMode("/libraries/vr/gvrsdk/$VER", "sdk-common-$VER.aar", GVR_VER, libsFolder);
765-
// copyAARFileFromMode("/libraries/vr/gvrsdk/$VER", "sdk-audio-$VER.aar", GVR_VER, libsFolder);
766-
// }
767704

768-
// private void copyGARLibs(File libsFolder) throws IOException {
769-
// copyAARFileFromMode("/libraries/ar/garsdk/$VER", "sdk-common-$VER.aar", GAR_VER, libsFolder);
770-
// }
771-
772-
/*
773-
private void copyAARFileFromSDK(String srcFolder, String filename, String version, File destFolder)
774-
throws IOException {
775-
String fn = filename.replace("$VER", version);
776-
File srcFile = new File(srcFolder.replace("$VER", version), fn);
777-
File destFile = new File(destFolder, fn);
778-
if (srcFile.exists()) {
779-
Util.copyFile(srcFile, destFile);
780-
} else {
781-
// If the AAR file does not exist in the installed SDK, gradle should be able to download it, and so
782-
// we don't to anything besides printing a warning.
783-
System.out.println("Warning: cannot find AAR package " + fn + " in installed SDK, gradle will try to download.");
784-
}
785-
}
786-
787-
788-
private void copyAARFileFromMode(String srcFolder, String filename, String version, File destFolder)
789-
throws IOException {
790-
String fn = filename.replace("$VER", version);
791-
File srcFile = mode.getContentFile(srcFolder.replace("$VER", version) + "/" + fn);
792-
File destFile = new File(destFolder, fn);
793-
if (srcFile.exists()) {
794-
Util.copyFile(srcFile, destFile);
795-
} else {
796-
// If the AAR file does not exist in the mode, gradle should be able to download it, and so
797-
// we don't to anything besides printing a warning.
798-
System.out.println("Warning: cannot find AAR package " + fn + " in Android mode, gradle will try to download");
799-
}
800-
}
801-
*/
802705

803706
// ---------------------------------------------------------------------------
804707
// Export project

mode/src/processing/mode/android/AndroidEditor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ public void actionPerformed(ActionEvent e) {
192192
wallpaperItem = new JCheckBoxMenuItem("Wallpaper");
193193
watchfaceItem = new JCheckBoxMenuItem("Watch Face");
194194
vrMenu = new JMenu("VR");
195-
cardBoardItem = new JCheckBoxMenuItem("CARDBOARD");
196-
dayDreamItem = new JCheckBoxMenuItem("DAYDREAM");
195+
cardBoardItem = new JCheckBoxMenuItem("Cardboard");
196+
dayDreamItem = new JCheckBoxMenuItem("Daydream");
197197
vrMenu.add(cardBoardItem);
198198
vrMenu.add(dayDreamItem);
199199
arItem = new JCheckBoxMenuItem("AR");

mode/src/processing/mode/android/AndroidMode.java

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -377,27 +377,18 @@ public boolean checkPackageName(Sketch sketch, int comp) {
377377

378378
public boolean checkAppIcons(Sketch sketch, int comp) {
379379
File sketchFolder = sketch.getFolder();
380-
381-
boolean allExist = false;
382-
383-
File localIcon36 = new File(sketchFolder, AndroidBuild.ICON_36);
384-
File localIcon48 = new File(sketchFolder, AndroidBuild.ICON_48);
385-
File localIcon72 = new File(sketchFolder, AndroidBuild.ICON_72);
386-
File localIcon96 = new File(sketchFolder, AndroidBuild.ICON_96);
387-
File localIcon144 = new File(sketchFolder, AndroidBuild.ICON_144);
388-
File localIcon192 = new File(sketchFolder, AndroidBuild.ICON_192);
389-
allExist = localIcon36.exists() && localIcon48.exists() &&
390-
localIcon72.exists() && localIcon96.exists() &&
391-
localIcon144.exists() && localIcon192.exists();
380+
381+
File[] launcherIcons = AndroidUtil.getFileList(sketchFolder, AndroidBuild.SKETCH_LAUNCHER_ICONS,
382+
AndroidBuild.SKETCH_OLD_LAUNCHER_ICONS);
383+
boolean allFilesExist = AndroidUtil.allFilesExists(launcherIcons);
392384

393385
if (comp == AndroidBuild.WATCHFACE) {
394386
// Additional preview icons are needed for watch faces
395-
File localIconSquare = new File(sketchFolder, AndroidBuild.WATCHFACE_ICON_RECTANGULAR);
396-
File localIconCircle = new File(sketchFolder, AndroidBuild.WATCHFACE_ICON_CIRCULAR);
397-
allExist &= localIconSquare.exists() && localIconCircle.exists();
387+
File[] watchFaceIcons = AndroidUtil.getFileList(sketchFolder, AndroidBuild.SKETCH_WATCHFACE_ICONS);
388+
allFilesExist &= AndroidUtil.allFilesExists(watchFaceIcons);
398389
}
399390

400-
if (!allExist) {
391+
if (!allFilesExist) {
401392
// The user did not set custom icons, show error and stop
402393
AndroidUtil.showMessage(EXPORT_DEFAULT_ICONS_TITLE,
403394
EXPORT_DEFAULT_ICONS_MESSAGE);

mode/src/processing/mode/android/AndroidUtil.java

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
import processing.app.Base;
4242
import processing.app.Messages;
43+
import processing.app.Mode;
4344
import processing.app.Platform;
4445
import processing.app.SketchException;
4546
import processing.app.Util;
@@ -253,5 +254,46 @@ static public void extractClassesJarFromAar(File wearFile, File explodeDir,
253254
File classFile = new File(explodeDir, "classes.jar");
254255
Util.copyFile(classFile, jarFile);
255256
Util.removeDir(explodeDir);
256-
}
257+
}
258+
259+
260+
static public File[] getFileList(File folder, String[] names) {
261+
return getFileList(folder, names, null);
262+
}
263+
264+
static public File[] getFileList(File folder, String[] names, String[] altNames) {
265+
File[] icons = new File[names.length];
266+
for (int i = 0; i < names.length; i++) {
267+
File f = new File(folder, names[i]);
268+
if (!f.exists() && altNames != null) {
269+
f = new File(folder, altNames[i]);
270+
}
271+
icons[i] = f;
272+
}
273+
return icons;
274+
}
275+
276+
277+
static public File[] getFileList(Mode mode, String prefix, String[] names) {
278+
File[] icons = new File[names.length];
279+
for (int i = 0; i < names.length; i++) {
280+
icons[i] = mode.getContentFile(prefix + names[i]);
281+
}
282+
return icons;
283+
}
284+
285+
static public boolean allFilesExists(File[] files) {
286+
for (File f: files) {
287+
if (!f.exists()) return false;
288+
}
289+
return true;
290+
}
291+
292+
293+
static public boolean noFileExists(File[] files) {
294+
for (File f: files) {
295+
if (f.exists()) return false;
296+
}
297+
return true;
298+
}
257299
}

0 commit comments

Comments
 (0)