Skip to content

Commit

Permalink
minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
codeanticode committed Jan 22, 2023
1 parent 4718cd0 commit c9ff840
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions mode/src/processing/mode/android/Manifest.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,32 +324,36 @@ protected void load(boolean forceNew) {
try {
xml = new XML(manifestFile);

boolean saveOld = false;

XML app = xml.getChild("application");
String icon = app.getString("android:icon");
if (icon.equals("@drawable/icon")) {
// Manifest file generated with older version of the mode, replace icon and save
app.setString("android:icon", "@mipmap/ic_launcher");
if (!forceNew) save();
saveOld = true;
}

XML activity = app.getChild("activity");
XML service = app.getChild("service");
if (activity != null && activity.getString("android:name").equals(".MainActivity")) {
addExportedAttrib(activity);
if (!forceNew) save();
saveOld = true;
}
if (service != null && service.getString("android:name").equals(".MainService")) {
addExportedAttrib(service);
if (!forceNew) save();
saveOld = true;
}

XML usesSDK = xml.getChild("uses-sdk");
if (usesSDK != null) {
// Manifest file generated with older version of the mode, uses-sdk is no longer needed in manifest
xml.removeChild(usesSDK);
if (!forceNew) save();
saveOld = true;
}

if (saveOld && !forceNew) save();

} catch (Exception e) {
e.printStackTrace();
System.err.println("Problem reading AndroidManifest.xml, creating a new version");
Expand Down

0 comments on commit c9ff840

Please sign in to comment.