diff options
author | Tor Norbye <tnorbye@google.com> | 2012-12-06 10:07:38 -0800 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2012-12-06 10:07:38 -0800 |
commit | 92841953d8d71c1ee8de87eb8256a7a3c28a5a11 (patch) | |
tree | 90736551bf7e928e6f18b589844d8769363eb575 | |
parent | 0a5363dd7b7b24f22179f339cd98214d626eaf33 (diff) | |
parent | 35d7c22bb687592a848d2fd5232c77b540082e2c (diff) | |
download | sdk-92841953d8d71c1ee8de87eb8256a7a3c28a5a11.zip sdk-92841953d8d71c1ee8de87eb8256a7a3c28a5a11.tar.gz sdk-92841953d8d71c1ee8de87eb8256a7a3c28a5a11.tar.bz2 |
Merge "Filter out non-launcher activity from new project activity list"
2 files changed, 30 insertions, 8 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/ActivityPage.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/ActivityPage.java index 9d2dd9a..ba4aedc 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/ActivityPage.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/ActivityPage.java @@ -17,11 +17,13 @@ package com.android.ide.eclipse.adt.internal.wizards.templates; import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectWizard.CATEGORY_ACTIVITIES; import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectWizard.CATEGORY_OTHER; +import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectWizard.IS_LAUNCHER; import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.PREVIEW_PADDING; import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.PREVIEW_WIDTH; import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.internal.editors.layout.gle2.ImageControl; +import com.google.common.collect.Lists; import com.google.common.io.Files; import org.eclipse.core.runtime.IStatus; @@ -61,6 +63,7 @@ class ActivityPage extends WizardPage implements SelectionListener { private Label mDescription; private boolean mOnlyActivities; private boolean mAskCreate; + private boolean mLauncherActivitiesOnly; /** * Create the wizard. @@ -84,6 +87,11 @@ class ActivityPage extends WizardPage implements SelectionListener { } } + /** Sets whether the activity page should only offer launcher activities */ + void setLauncherActivitiesOnly(boolean launcherActivitiesOnly) { + mLauncherActivitiesOnly = launcherActivitiesOnly; + } + @Override public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NULL); @@ -108,18 +116,31 @@ class ActivityPage extends WizardPage implements SelectionListener { TemplateManager manager = mValues.template.getManager(); - mTemplates = manager.getTemplates(CATEGORY_ACTIVITIES); + java.util.List<File> templates = manager.getTemplates(CATEGORY_ACTIVITIES); + if (!mOnlyActivities) { - mTemplates.addAll(manager.getTemplates(CATEGORY_OTHER)); + templates.addAll(manager.getTemplates(CATEGORY_OTHER)); } - java.util.List<String> names = new ArrayList<String>(mTemplates.size()); + java.util.List<String> names = new ArrayList<String>(templates.size()); File current = mValues.activityValues.getTemplateLocation(); + mTemplates = Lists.newArrayListWithExpectedSize(templates.size()); int index = -1; - for (int i = 0, n = mTemplates.size(); i < n; i++) { - File template = mTemplates.get(i); - names.add(template.getName()); + for (int i = 0, n = templates.size(); i < n; i++) { + File template = templates.get(i); + TemplateMetadata metadata = manager.getTemplate(template); + if (metadata == null) { + continue; + } + if (mLauncherActivitiesOnly) { + Parameter parameter = metadata.getParameter(IS_LAUNCHER); + if (parameter == null) { + continue; + } + } + mTemplates.add(template); + names.add(metadata.getTitle()); if (template.equals(current)) { - index = i; + index = names.size(); } } String[] items = names.toArray(new String[names.size()]); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java index fdb26b1..84de9a4 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java @@ -59,7 +59,7 @@ import java.util.Set; public class NewProjectWizard extends TemplateWizard { private static final String PARENT_ACTIVITY_CLASS = "parentActivityClass"; //$NON-NLS-1$ private static final String ACTIVITY_TITLE = "activityTitle"; //$NON-NLS-1$ - private static final String IS_LAUNCHER = "isLauncher"; //$NON-NLS-1$ + static final String IS_LAUNCHER = "isLauncher"; //$NON-NLS-1$ static final String IS_NEW_PROJECT = "isNewProject"; //$NON-NLS-1$ static final String IS_LIBRARY_PROJECT = "isLibraryProject"; //$NON-NLS-1$ static final String ATTR_COPY_ICONS = "copyIcons"; //$NON-NLS-1$ @@ -100,6 +100,7 @@ public class NewProjectWizard extends TemplateWizard { mContentsPage = new ProjectContentsPage(mValues); mContentsPage.init(selection, AdtUtils.getActivePart()); mActivityPage = new ActivityPage(mValues, true, true); + mActivityPage.setLauncherActivitiesOnly(true); } @Override |