aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AddSupportJarAction.java12
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectPage.java5
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandler.java25
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateManager.java9
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateMetadata.java36
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TypedVariable.java50
6 files changed, 128 insertions, 9 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AddSupportJarAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AddSupportJarAction.java
index 2eeec5b..f0af8bb 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AddSupportJarAction.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AddSupportJarAction.java
@@ -342,9 +342,15 @@ public class AddSupportJarAction implements IObjectActionDelegate {
assert path.equals(libraryPath) : path;
}
- // Create workspace copy of the project and add library dependency
- IProject libraryProject = createLibraryProject(libraryPath, project,
- APP_COMPAT_LIB_NAME, waitForFinish);
+ // Check to see if there's already a version of the library available
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IWorkspaceRoot root = workspace.getRoot();
+ IProject libraryProject = root.getProject(APP_COMPAT_LIB_NAME);
+ if (!libraryProject.exists()) {
+ // Create workspace copy of the project and add library dependency
+ libraryProject = createLibraryProject(libraryPath, project,
+ APP_COMPAT_LIB_NAME, waitForFinish);
+ }
if (libraryProject != null) {
return addLibraryDependency(libraryProject, project, waitForFinish);
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectPage.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectPage.java
index ebaacfe..60dd0f2 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectPage.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectPage.java
@@ -21,6 +21,7 @@ import static com.android.ide.eclipse.adt.AdtUtils.extractClassName;
import static com.android.ide.eclipse.adt.internal.wizards.templates.NewTemplatePage.WIZARD_PAGE_WIDTH;
import com.android.annotations.Nullable;
+import com.android.ide.common.sdk.SdkVersionInfo;
import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.AdtUtils;
import com.android.ide.eclipse.adt.internal.editors.IconFactory;
@@ -550,7 +551,9 @@ public class NewProjectPage extends WizardPage
try {
minSdk = Integer.parseInt(mValues.minSdk);
} catch (NumberFormatException nufe) {
- minSdk = 1;
+ // If not a number, then the string is a codename, so treat it
+ // as a preview version.
+ minSdk = SdkVersionInfo.HIGHEST_KNOWN_API + 1;
}
}
mValues.iconState.minSdk = minSdk.intValue();
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandler.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandler.java
index b393b82..8e11841 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandler.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandler.java
@@ -168,6 +168,8 @@ class TemplateHandler {
static final String TAG_THUMBS = "thumbs"; //$NON-NLS-1$
static final String TAG_DEPENDENCY = "dependency"; //$NON-NLS-1$
static final String TAG_ICONS = "icons"; //$NON-NLS-1$
+ static final String TAG_FORMFACTOR = "formfactor"; //$NON-NLS-1$
+ static final String TAG_CATEGORY = "category"; //$NON-NLS-1$
static final String ATTR_FORMAT = "format"; //$NON-NLS-1$
static final String ATTR_REVISION = "revision"; //$NON-NLS-1$
static final String ATTR_VALUE = "value"; //$NON-NLS-1$
@@ -191,9 +193,16 @@ class TemplateHandler {
static final String ATTR_CLIPART_NAME = "clipartName";//$NON-NLS-1$
static final String ATTR_TEXT = "text"; //$NON-NLS-1$
static final String ATTR_SRC_DIR = "srcDir"; //$NON-NLS-1$
+ static final String ATTR_SRC_OUT = "srcOut"; //$NON-NLS-1$
static final String ATTR_RES_DIR = "resDir"; //$NON-NLS-1$
+ static final String ATTR_RES_OUT = "resOut"; //$NON-NLS-1$
static final String ATTR_MANIFEST_DIR = "manifestDir";//$NON-NLS-1$
+ static final String ATTR_MANIFEST_OUT = "manifestOut";//$NON-NLS-1$
+ static final String ATTR_PROJECT_DIR = "projectDir"; //$NON-NLS-1$
+ static final String ATTR_PROJECT_OUT = "projectOut"; //$NON-NLS-1$
static final String ATTR_MAVEN_URL = "mavenUrl"; //$NON-NLS-1$
+ static final String ATTR_DEBUG_KEYSTORE_SHA1 =
+ "debugKeystoreSha1"; //$NON-NLS-1$
static final String CATEGORY_ACTIVITIES = "activities";//$NON-NLS-1$
static final String CATEGORY_PROJECTS = "projects"; //$NON-NLS-1$
@@ -363,6 +372,12 @@ class TemplateHandler {
IPath manifestDir = project.getProjectRelativePath();
parameters.put(ATTR_MANIFEST_DIR, manifestDir.toString());
+ parameters.put(ATTR_MANIFEST_OUT, manifestDir.toString());
+
+ parameters.put(ATTR_PROJECT_DIR, manifestDir.toString());
+ parameters.put(ATTR_PROJECT_OUT, manifestDir.toString());
+
+ parameters.put(ATTR_DEBUG_KEYSTORE_SHA1, "");
}
@Nullable
@@ -474,8 +489,7 @@ class TemplateHandler {
} else if (TAG_GLOBAL.equals(name)) {
String id = attributes.getValue(ATTR_ID);
if (!paramMap.containsKey(id)) {
- String value = attributes.getValue(ATTR_VALUE);
- paramMap.put(id, value);
+ paramMap.put(id, TypedVariable.parseGlobal(attributes));
}
} else if (TAG_GLOBALS.equals(name)) {
// Handle evaluation of variables
@@ -503,9 +517,10 @@ class TemplateHandler {
}
}
}
- } else if (!name.equals("template") && !name.equals("category")
- && !name.equals("option") && !name.equals(TAG_THUMBS) &&
- !name.equals(TAG_THUMB) && !name.equals(TAG_ICONS)) {
+ } else if (!name.equals("template") && !name.equals(TAG_CATEGORY) &&
+ !name.equals(TAG_FORMFACTOR) && !name.equals("option") &&
+ !name.equals(TAG_THUMBS) && !name.equals(TAG_THUMB) &&
+ !name.equals(TAG_ICONS)) {
System.err.println("WARNING: Unknown template directive " + name);
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateManager.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateManager.java
index de625e0..30dd09e 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateManager.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateManager.java
@@ -28,6 +28,7 @@ import com.android.ide.eclipse.adt.internal.editors.layout.gle2.DomUtilities;
import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs;
import com.google.common.base.Charsets;
import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
import com.google.common.io.Files;
import org.w3c.dom.Document;
@@ -39,9 +40,13 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
/** Handles locating templates and providing template metadata */
public class TemplateManager {
+ private static final Set<String> EXCLUDED_CATEGORIES = Sets.newHashSet("Folder", "Google");
+ private static final Set<String> EXCLUDED_FORMFACTORS = Sets.newHashSet("Wear", "TV");
+
TemplateManager() {
}
@@ -239,6 +244,10 @@ public class TemplateManager {
Document doc = DomUtilities.parseDocument(xml, true);
if (doc != null && doc.getDocumentElement() != null) {
TemplateMetadata metadata = new TemplateMetadata(doc);
+ if (EXCLUDED_CATEGORIES.contains(metadata.getCategory()) ||
+ EXCLUDED_FORMFACTORS.contains(metadata.getFormFactor())) {
+ return null;
+ }
mTemplateMap.put(templateDir, metadata);
return metadata;
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateMetadata.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateMetadata.java
index f5e35ef..4ce7d74 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateMetadata.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateMetadata.java
@@ -30,11 +30,14 @@ import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHan
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.ATTR_TEXT;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.ATTR_TRIM;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.ATTR_TYPE;
+import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.ATTR_VALUE;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.CURRENT_FORMAT;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.TAG_DEPENDENCY;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.TAG_ICONS;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.TAG_PARAMETER;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.TAG_THUMB;
+import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.TAG_FORMFACTOR;
+import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.TAG_CATEGORY;
import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
@@ -76,6 +79,8 @@ class TemplateMetadata {
private Integer mRevision;
private boolean mNoIcons;
private CreateAssetSetWizardState mIconState;
+ private String mFormFactor;
+ private String mCategory;
TemplateMetadata(@NonNull Document document) {
mDocument = document;
@@ -180,6 +185,37 @@ class TemplateMetadata {
return mRevision.intValue();
}
+
+ public String getFormFactor() {
+ if (mFormFactor == null) {
+ mFormFactor = "Mobile";
+
+ NodeList formfactorDeclarations = mDocument.getElementsByTagName(TAG_FORMFACTOR);
+ if (formfactorDeclarations.getLength() > 0) {
+ Element element = (Element) formfactorDeclarations.item(0);
+ String formFactor = element.getAttribute(ATTR_VALUE);
+ if (formFactor != null && !formFactor.isEmpty()) {
+ mFormFactor = formFactor;
+ }
+ }
+ }
+ return mFormFactor;
+ }
+
+ public String getCategory() {
+ if (mCategory == null) {
+ mCategory = "";
+ NodeList categories = mDocument.getElementsByTagName(TAG_CATEGORY);
+ if (categories.getLength() > 0) {
+ Element element = (Element) categories.item(0);
+ String category = element.getAttribute(ATTR_VALUE);
+ if (category != null && !category.isEmpty()) {
+ mCategory = category;
+ }
+ }
+ }
+ return mCategory;
+ }
/**
* Returns a suitable icon wizard state instance if this wizard requests
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TypedVariable.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TypedVariable.java
new file mode 100644
index 0000000..468a10c
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TypedVariable.java
@@ -0,0 +1,50 @@
+package com.android.ide.eclipse.adt.internal.wizards.templates;
+
+import java.util.Locale;
+
+import org.xml.sax.Attributes;
+
+public class TypedVariable {
+ public enum Type {
+ STRING,
+ BOOLEAN,
+ INTEGER;
+
+ public static Type get(String name) {
+ if (name == null) {
+ return STRING;
+ }
+ try {
+ return valueOf(name.toUpperCase(Locale.US));
+ } catch (IllegalArgumentException e) {
+ System.err.println("Unexpected global type '" + name + "'");
+ System.err.println("Expected one of :");
+ for (Type s : Type.values()) {
+ System.err.println(" " + s.name().toLowerCase(Locale.US));
+ }
+ }
+
+ return STRING;
+ }
+ }
+
+ public static Object parseGlobal(Attributes attributes) {
+ String value = attributes.getValue(TemplateHandler.ATTR_VALUE);
+ Type type = Type.get(attributes.getValue(TemplateHandler.ATTR_TYPE));
+
+ switch (type) {
+ case STRING:
+ return value;
+ case BOOLEAN:
+ return Boolean.parseBoolean(value);
+ case INTEGER:
+ try {
+ return Integer.parseInt(value);
+ } catch (NumberFormatException e) {
+ return value;
+ }
+ }
+
+ return value;
+ }
+}