auto import from //depot/cupcake/@137055
This commit is contained in:
@@ -103,6 +103,8 @@ public final class SdkConstants {
|
||||
public final static String FD_ASSETS = "assets"; //$NON-NLS-1$
|
||||
/** Default source folder name, i.e. "src" */
|
||||
public final static String FD_SOURCES = "src"; //$NON-NLS-1$
|
||||
/** Default generated source folder name, i.e. "gen" */
|
||||
public final static String FD_GEN_SOURCES = "gen"; //$NON-NLS-1$
|
||||
/** Default native library folder name inside the project, i.e. "libs"
|
||||
* While the folder inside the .apk is "lib", we call that one libs because
|
||||
* that's what we use in ant for both .jar and .so and we need to make the 2 development ways
|
||||
|
||||
@@ -55,6 +55,12 @@ public final class AvdManager {
|
||||
public final static String AVD_INI_IMAGES_1 = "image.sysdir.1";
|
||||
public final static String AVD_INI_IMAGES_2 = "image.sysdir.2";
|
||||
|
||||
/**
|
||||
* Pattern to match pixel-sized skin "names", e.g. "320x480".
|
||||
*/
|
||||
public final static Pattern NUMERIC_SKIN_SIZE = Pattern.compile("[0-9]{2,}x[0-9]{2,}");
|
||||
|
||||
|
||||
private final static String USERDATA_IMG = "userdata.img";
|
||||
private final static String CONFIG_INI = "config.ini";
|
||||
private final static String SDCARD_IMG = "sdcard.img";
|
||||
@@ -255,16 +261,21 @@ public final class AvdManager {
|
||||
skinName = target.getDefaultSkin();
|
||||
}
|
||||
|
||||
// get the path of the skin (relative to the SDK)
|
||||
// assume skin name is valid
|
||||
String skinPath = getSkinRelativePath(skinName, target, log);
|
||||
if (skinPath == null) {
|
||||
needCleanup = true;
|
||||
return null;
|
||||
}
|
||||
if (NUMERIC_SKIN_SIZE.matcher(skinName).matches()) {
|
||||
// Skin name is an actual screen resolution, no skin.path
|
||||
values.put(AVD_INI_SKIN_NAME, skinName);
|
||||
} else {
|
||||
// get the path of the skin (relative to the SDK)
|
||||
// assume skin name is valid
|
||||
String skinPath = getSkinRelativePath(skinName, target, log);
|
||||
if (skinPath == null) {
|
||||
needCleanup = true;
|
||||
return null;
|
||||
}
|
||||
|
||||
values.put(AVD_INI_SKIN_PATH, skinPath);
|
||||
values.put(AVD_INI_SKIN_NAME, skinName);
|
||||
values.put(AVD_INI_SKIN_PATH, skinPath);
|
||||
values.put(AVD_INI_SKIN_NAME, skinName);
|
||||
}
|
||||
|
||||
if (sdcard != null) {
|
||||
File sdcardFile = new File(sdcard);
|
||||
|
||||
@@ -25,24 +25,30 @@ import java.util.Map.Entry;
|
||||
* Helper class to read and write Apk Configuration into a {@link ProjectProperties} file.
|
||||
*/
|
||||
public class ApkConfigurationHelper {
|
||||
/** Prefix for property names for config definition. This prevents having config named
|
||||
* after other valid properties such as "target". */
|
||||
final static String CONFIG_PREFIX = "apk-config-";
|
||||
|
||||
/**
|
||||
* Reads the Apk Configurations from a {@link ProjectProperties} file and returns them as a map.
|
||||
* <p/>If there are no defined configurations, the returned map will be empty.
|
||||
* @return a map of apk configurations. The map contains (name, filter) where name is
|
||||
* the name of the configuration (a-zA-Z0-9 only), and filter is the comma separated list of
|
||||
* resource configuration to include in the apk (see aapt -c)
|
||||
*/
|
||||
public static Map<String, String> getConfigs(ProjectProperties properties) {
|
||||
HashMap<String, String> configMap = new HashMap<String, String>();
|
||||
|
||||
// get the list of configs.
|
||||
String configList = properties.getProperty(ProjectProperties.PROPERTY_CONFIGS);
|
||||
String configList = properties.getProperty(ProjectProperties.PROPERTY_APK_CONFIGS);
|
||||
if (configList != null) {
|
||||
// this is a comma separated list
|
||||
String[] configs = configList.split(","); //$NON-NLS-1$
|
||||
|
||||
// read the value of each config and store it in a map
|
||||
|
||||
for (String config : configs) {
|
||||
String configValue = properties.getProperty(config);
|
||||
config = config.trim();
|
||||
String configValue = properties.getProperty(CONFIG_PREFIX + config);
|
||||
if (configValue != null) {
|
||||
configMap.put(config, configValue);
|
||||
}
|
||||
@@ -54,6 +60,10 @@ public class ApkConfigurationHelper {
|
||||
|
||||
/**
|
||||
* Writes the Apk Configurations from a given map into a {@link ProjectProperties}.
|
||||
* @param properties the {@link ProjectProperties} in which to store the apk configurations.
|
||||
* @param configMap a map of apk configurations. The map contains (name, filter) where name is
|
||||
* the name of the configuration (a-zA-Z0-9 only), and filter is the comma separated list of
|
||||
* resource configuration to include in the apk (see aapt -c)
|
||||
* @return true if the {@link ProjectProperties} contained Apk Configuration that were not
|
||||
* present in the map.
|
||||
*/
|
||||
@@ -62,17 +72,20 @@ public class ApkConfigurationHelper {
|
||||
// in case a config was removed.
|
||||
|
||||
// get the list of configs.
|
||||
String configList = properties.getProperty(ProjectProperties.PROPERTY_CONFIGS);
|
||||
|
||||
// this is a comma separated list
|
||||
String[] configs = configList.split(","); //$NON-NLS-1$
|
||||
|
||||
String configList = properties.getProperty(ProjectProperties.PROPERTY_APK_CONFIGS);
|
||||
|
||||
boolean hasRemovedConfig = false;
|
||||
|
||||
for (String config : configs) {
|
||||
if (configMap.containsKey(config) == false) {
|
||||
hasRemovedConfig = true;
|
||||
properties.removeProperty(config);
|
||||
|
||||
if (configList != null) {
|
||||
// this is a comma separated list
|
||||
String[] configs = configList.split(","); //$NON-NLS-1$
|
||||
|
||||
for (String config : configs) {
|
||||
config = config.trim();
|
||||
if (configMap.containsKey(config) == false) {
|
||||
hasRemovedConfig = true;
|
||||
properties.removeProperty(CONFIG_PREFIX + config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,9 +97,9 @@ public class ApkConfigurationHelper {
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append(entry.getKey());
|
||||
properties.setProperty(entry.getKey(), entry.getValue());
|
||||
properties.setProperty(CONFIG_PREFIX + entry.getKey(), entry.getValue());
|
||||
}
|
||||
properties.setProperty(ProjectProperties.PROPERTY_CONFIGS, sb.toString());
|
||||
properties.setProperty(ProjectProperties.PROPERTY_APK_CONFIGS, sb.toString());
|
||||
|
||||
return hasRemovedConfig;
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ public class ProjectCreator {
|
||||
}
|
||||
|
||||
// create the source folder and the java package folders.
|
||||
final String srcFolderPath = SdkConstants.FD_SOURCES + File.separator + packagePath;
|
||||
String srcFolderPath = SdkConstants.FD_SOURCES + File.separator + packagePath;
|
||||
File sourceFolder = createDirs(projectFolder, srcFolderPath);
|
||||
String javaTemplate = "java_file.template";
|
||||
String activityFileName = activityName + ".java";
|
||||
@@ -220,6 +220,10 @@ public class ProjectCreator {
|
||||
installTemplate(javaTemplate, new File(sourceFolder, activityFileName),
|
||||
keywords, target);
|
||||
|
||||
// create the generate source folder
|
||||
srcFolderPath = SdkConstants.FD_GEN_SOURCES + File.separator + packagePath;
|
||||
sourceFolder = createDirs(projectFolder, srcFolderPath);
|
||||
|
||||
// create other useful folders
|
||||
File resourceFodler = createDirs(projectFolder, SdkConstants.FD_RESOURCES);
|
||||
createDirs(projectFolder, SdkConstants.FD_OUTPUT);
|
||||
|
||||
@@ -33,7 +33,7 @@ import java.util.Map.Entry;
|
||||
public final class ProjectProperties {
|
||||
/** The property name for the project target */
|
||||
public final static String PROPERTY_TARGET = "target";
|
||||
public final static String PROPERTY_CONFIGS = "configs";
|
||||
public final static String PROPERTY_APK_CONFIGS = "apk-configurations";
|
||||
public final static String PROPERTY_SDK = "sdk-location";
|
||||
|
||||
public static enum PropertyType {
|
||||
@@ -98,7 +98,19 @@ public final class ProjectProperties {
|
||||
// 1-------10--------20--------30--------40--------50--------60--------70--------80
|
||||
COMMENT_MAP.put(PROPERTY_TARGET,
|
||||
"# Project target.\n");
|
||||
COMMENT_MAP.put(PROPERTY_SDK, "# location of the SDK. This is only used by Ant\n" +
|
||||
COMMENT_MAP.put(PROPERTY_APK_CONFIGS,
|
||||
"# apk configurations. This property allows creation of APK files with limited\n" +
|
||||
"# resources. For example, if your application contains many locales and\n" +
|
||||
"# you wish to release multiple smaller apks instead of a large one, you can\n" +
|
||||
"# define configuration to create apks with limited language sets.\n" +
|
||||
"# Format is a comma separated list of configuration names. For each\n" +
|
||||
"# configuration, a property will declare the resource configurations to\n" +
|
||||
"# include. Example:\n" +
|
||||
"# " + PROPERTY_APK_CONFIGS +"=european,northamerica\n" +
|
||||
"# " + ApkConfigurationHelper.CONFIG_PREFIX + "european=en,fr,it,de,es\n" +
|
||||
"# " + ApkConfigurationHelper.CONFIG_PREFIX + "northamerica=en,es\n");
|
||||
COMMENT_MAP.put(PROPERTY_SDK,
|
||||
"# location of the SDK. This is only used by Ant\n" +
|
||||
"# For customization when using a Version Control System, please read the\n" +
|
||||
"# header note.\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user