SDK:
- set application name correctly for android application git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8834 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
875ed1c7cc
commit
670c95ad14
@ -13,6 +13,7 @@ import java.io.OutputStreamWriter;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.netbeans.api.project.Project;
|
import org.netbeans.api.project.Project;
|
||||||
|
import org.netbeans.api.project.ProjectInformation;
|
||||||
import org.openide.DialogDisplayer;
|
import org.openide.DialogDisplayer;
|
||||||
import org.openide.NotifyDescriptor;
|
import org.openide.NotifyDescriptor;
|
||||||
import org.openide.NotifyDescriptor.Message;
|
import org.openide.NotifyDescriptor.Message;
|
||||||
@ -239,6 +240,7 @@ public class AndroidSdkTool {
|
|||||||
Exceptions.printStackTrace(ex);
|
Exceptions.printStackTrace(ex);
|
||||||
}
|
}
|
||||||
updateAndroidManifest(project);
|
updateAndroidManifest(project);
|
||||||
|
updateAndroidApplicationName(project, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateProject(Project project, String target, String name) {
|
public static void updateProject(Project project, String target, String name) {
|
||||||
@ -267,6 +269,7 @@ public class AndroidSdkTool {
|
|||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Exceptions.printStackTrace(ex);
|
Exceptions.printStackTrace(ex);
|
||||||
}
|
}
|
||||||
|
updateAndroidApplicationName(project, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void updateAndroidManifest(Project project) {
|
private static void updateAndroidManifest(Project project) {
|
||||||
@ -318,6 +321,56 @@ public class AndroidSdkTool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void updateAndroidApplicationName(Project project, String name) {
|
||||||
|
FileObject manifest = project.getProjectDirectory().getFileObject("mobile/res/values/strings.xml");
|
||||||
|
if (manifest == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
InputStream in = null;
|
||||||
|
FileLock lock = null;
|
||||||
|
OutputStream out = null;
|
||||||
|
try {
|
||||||
|
in = manifest.getInputStream();
|
||||||
|
Document configuration = XMLUtil.parse(new InputSource(in), false, false, null, null);
|
||||||
|
in.close();
|
||||||
|
in = null;
|
||||||
|
Element sdkElement = XmlHelper.findChildElementWithAttribute(configuration.getDocumentElement(), "string", "name", "app_name");
|
||||||
|
if (sdkElement == null) {
|
||||||
|
sdkElement = configuration.createElement("string");
|
||||||
|
sdkElement.setAttribute("name", "app_name");
|
||||||
|
configuration.getDocumentElement().appendChild(sdkElement);
|
||||||
|
}
|
||||||
|
if (!sdkElement.getTextContent().trim().equals(name)) {
|
||||||
|
sdkElement.setTextContent(name);
|
||||||
|
lock = manifest.lock();
|
||||||
|
out = manifest.getOutputStream(lock);
|
||||||
|
XMLUtil.write(configuration, out, "UTF-8");
|
||||||
|
out.close();
|
||||||
|
out = null;
|
||||||
|
lock.releaseLock();
|
||||||
|
lock = null;
|
||||||
|
}
|
||||||
|
} catch (SAXException ex) {
|
||||||
|
Exceptions.printStackTrace(ex);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
Exceptions.printStackTrace(ex);
|
||||||
|
} finally {
|
||||||
|
if (lock != null) {
|
||||||
|
lock.releaseLock();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (in != null) {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
if (out != null) {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
} catch (IOException ex1) {
|
||||||
|
Exceptions.printStackTrace(ex1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static String mainActivityString(String mainClass, String packag) {
|
private static String mainActivityString(String mainClass, String packag) {
|
||||||
String str =
|
String str =
|
||||||
"package " + packag + ";\n"
|
"package " + packag + ";\n"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user