diff --git a/src/org/recompile/mobile/MobilePlatform.java b/src/org/recompile/mobile/MobilePlatform.java index d66fc7c6..4e764314 100644 --- a/src/org/recompile/mobile/MobilePlatform.java +++ b/src/org/recompile/mobile/MobilePlatform.java @@ -16,6 +16,8 @@ */ package org.recompile.mobile; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.net.URLDecoder; import java.nio.charset.StandardCharsets; @@ -31,6 +33,7 @@ import java.io.IOException; import java.io.InputStream; + import java.awt.Color; import java.awt.Graphics2D; import java.awt.RenderingHints; @@ -230,6 +233,24 @@ private void updateKeyState(int key, int val) public boolean load(String fileName) { Map descriptorProperties = new HashMap<>(); + + /* + * If loading a jar directly, check if an accompanying jad with the same name + * is present in the directory, to load any platform properties from there. + */ + if(fileName.toLowerCase().contains(".jar")) + { + try + { + File checkJad = new File(new URI(fileName.replace(".jar", ".jad"))); + if(checkJad.exists() && !checkJad.isDirectory()) + { + Mobile.log(Mobile.LOG_INFO, MobilePlatform.class.getPackage().getName() + "." + MobilePlatform.class.getSimpleName() + ": " + "Accompanying JAD found! Parsing additional MIDlet properties."); + fileName = fileName.replace(".jar", ".jad"); + } + } catch (Exception e) { Mobile.log(Mobile.LOG_INFO, MobilePlatform.class.getPackage().getName() + "." + MobilePlatform.class.getSimpleName() + ": " + "Couldn't check for accompanying JAD:" + e.getMessage()); } + } + boolean isJad = fileName.toLowerCase().endsWith(".jad"); if (isJad)