diff options
Diffstat (limited to 'eclipse/plugins')
26 files changed, 160 insertions, 134 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/resources/platform/AttrsXmlParser.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/resources/platform/AttrsXmlParser.java index a0a5ad8..a7bc53b 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/resources/platform/AttrsXmlParser.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/resources/platform/AttrsXmlParser.java @@ -17,6 +17,7 @@ package com.android.ide.common.resources.platform; import static com.android.ide.common.layout.LayoutConstants.DOT_LAYOUT_PARAMS; +import static com.android.ide.eclipse.adt.AdtConstants.DOC_HIDE; import com.android.ide.common.api.IAttributeInfo.Format; import com.android.ide.common.log.ILogger; @@ -291,7 +292,12 @@ public final class AttrsXmlParser { mStyleMap.put(name, style); unknownParents.remove(name); if (lastComment != null) { - style.setJavaDoc(parseJavadoc(lastComment.getNodeValue())); + String nodeValue = lastComment.getNodeValue(); + if (nodeValue.contains(DOC_HIDE)) { + mStyleMap.remove(name); + } else { + style.setJavaDoc(parseJavadoc(nodeValue)); + } } } } @@ -416,8 +422,12 @@ public final class AttrsXmlParser { } if (info != null) { if (lastComment != null) { - info.setJavaDoc(parseJavadoc(lastComment.getNodeValue())); - info.setDeprecatedDoc(parseDeprecatedDoc(lastComment.getNodeValue())); + String nodeValue = lastComment.getNodeValue(); + if (nodeValue.contains(DOC_HIDE)) { + return null; + } + info.setJavaDoc(parseJavadoc(nodeValue)); + info.setDeprecatedDoc(parseDeprecatedDoc(nodeValue)); } } } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtConstants.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtConstants.java index 8ac1012..670dd20 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtConstants.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtConstants.java @@ -289,4 +289,7 @@ public class AdtConstants { public static final String CODESITE_BASE_URL = "http://code.google.com/android"; //$NON-NLS-1$ public static final String LIBRARY_TEST_RUNNER = "android.test.runner"; //$NON-NLS-1$ + + /** Documentation marker for elements, attributes etc that should be hidden */ + public static final String DOC_HIDE = "@hide"; //$NON-NLS-1$ } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtUtils.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtUtils.java index 4cf4a00..d6ca12a 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtUtils.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtUtils.java @@ -30,8 +30,6 @@ import com.android.sdklib.AndroidVersion; import com.android.sdklib.IAndroidTarget; import com.android.sdklib.repository.PkgProps; import com.android.util.XmlUtils; -import com.google.common.base.Splitter; -import com.google.common.collect.Iterables; import com.google.common.io.ByteStreams; import com.google.common.io.Closeables; @@ -860,7 +858,7 @@ public class AdtUtils { * @return the highest known API number */ public static int getHighestKnownApiLevel() { - return 15; + return 16; } /** @@ -981,41 +979,6 @@ public class AdtUtils { } /** - * Splits the given path into its individual parts, attempting to be - * tolerant about path separators (: or ;). It can handle possibly ambiguous - * paths, such as {@code c:\foo\bar:\other}, though of course these are to - * be avoided if possible. - * - * @param path the path variable to split, which can use both : and ; as - * path separators. - * @return the individual path components as an iterable of strings - */ - public static Iterable<String> splitPath(String path) { - if (path.indexOf(';') != -1) { - return Splitter.on(';').omitEmptyStrings().trimResults().split(path); - } - - List<String> combined = new ArrayList<String>(); - Iterables.addAll(combined, Splitter.on(':').omitEmptyStrings().trimResults().split(path)); - for (int i = 0, n = combined.size(); i < n; i++) { - String p = combined.get(i); - if (p.length() == 1 && i < n - 1 && Character.isLetter(p.charAt(0)) - // Technically, Windows paths do not have to have a \ after the :, - // which means it would be using the current directory on that drive, - // but that's unlikely to be the case in a path since it would have - // unpredictable results - && !combined.get(i+1).isEmpty() && combined.get(i+1).charAt(0) == '\\') { - combined.set(i, p + ':' + combined.get(i+1)); - combined.remove(i+1); - n--; - continue; - } - } - - return combined; - } - - /** * Reads the contents of an {@link IFile} and return it as a byte array * * @param file the file to be read diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationComposite.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationComposite.java index 0237769..172b7a4 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationComposite.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationComposite.java @@ -67,6 +67,7 @@ import com.android.resources.UiMode; import com.android.sdklib.AndroidVersion; import com.android.sdklib.IAndroidTarget; import com.android.sdklib.devices.Device; +import com.android.sdklib.devices.DeviceManager; import com.android.sdklib.devices.State; import com.android.sdklib.internal.avd.AvdInfo; import com.android.sdklib.internal.avd.AvdManager; @@ -204,6 +205,9 @@ public class ConfigurationComposite extends Composite implements SelectionListen /** The config listener given to the constructor. Never null. */ private final IConfigListener mListener; + /** The device menu listener, so we can remove it when the device lists are updated */ + private Listener mDeviceListener; + /** The {@link FolderConfiguration} representing the state of the UI controls */ private final FolderConfiguration mCurrentConfig = new FolderConfiguration(); @@ -1906,6 +1910,11 @@ public class ConfigurationComposite extends Composite implements SelectionListen menu.setVisible(true); } }; + + if (mDeviceListener != null) { + combo.removeListener(SWT.Selection, mDeviceListener); + } + mDeviceListener = menuListener; combo.addListener(SWT.Selection, menuListener); } @@ -2656,9 +2665,17 @@ public class ConfigurationComposite extends Composite implements SelectionListen * Loads the list of {@link Device}s and inits the UI with it. */ private void initDevices() { - Sdk sdk = Sdk.getCurrent(); + final Sdk sdk = Sdk.getCurrent(); if (sdk != null) { mDeviceList = sdk.getDevices(); + DeviceManager manager = sdk.getDeviceManager(); + manager.registerListener(new DeviceManager.DevicesChangeListener() { + @Override + public void onDevicesChange() { + mDeviceList = sdk.getDevices(); + addDeviceMenuListener(mDeviceCombo); + } + }); } else { mDeviceList = new ArrayList<Device>(); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintFix.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintFix.java index 9fa5018..1ab02c3 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintFix.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintFix.java @@ -28,6 +28,7 @@ import com.android.tools.lint.checks.PxUsageDetector; import com.android.tools.lint.checks.ScrollViewChildDetector; import com.android.tools.lint.checks.SecurityDetector; import com.android.tools.lint.checks.TextFieldDetector; +import com.android.tools.lint.checks.TranslationDetector; import com.android.tools.lint.checks.TypoDetector; import com.android.tools.lint.checks.TypographyDetector; import com.android.tools.lint.checks.UseCompoundDrawableDetector; @@ -153,6 +154,7 @@ abstract class LintFix implements ICompletionProposal { sFixes.put(PxUsageDetector.PX_ISSUE.getId(), ConvertToDpFix.class); sFixes.put(TextFieldDetector.ISSUE.getId(), SetAttributeFix.class); sFixes.put(SecurityDetector.EXPORTED_SERVICE.getId(), SetAttributeFix.class); + sFixes.put(TranslationDetector.MISSING.getId(), SetAttributeFix.class); sFixes.put(DetectMissingPrefix.MISSING_NAMESPACE.getId(), AddPrefixFix.class); sFixes.put(ScrollViewChildDetector.ISSUE.getId(), SetScrollViewSizeFix.class); sFixes.put(ObsoleteLayoutParamsDetector.ISSUE.getId(), ObsoleteLayoutParamsFix.class); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintFixGenerator.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintFixGenerator.java index a07101f..5d38df2 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintFixGenerator.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintFixGenerator.java @@ -98,6 +98,7 @@ import java.util.List; * in the Problems view; perhaps we should use a custom view for these. That would also * make marker management more obvious. */ +@SuppressWarnings("restriction") // DOM model public class LintFixGenerator implements IMarkerResolutionGenerator2, IQuickAssistProcessor { /** Constructs a new {@link LintFixGenerator} */ public LintFixGenerator() { @@ -248,7 +249,6 @@ public class LintFixGenerator implements IMarkerResolutionGenerator2, IQuickAssi * * @param marker the marker pointing to the error to be suppressed */ - @SuppressWarnings("restriction") // XML model public static void addSuppressAnnotation(IMarker marker) { String id = EclipseLintClient.getId(marker); if (id != null) { diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/SetAttributeFix.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/SetAttributeFix.java index 896966e..a860c69 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/SetAttributeFix.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/SetAttributeFix.java @@ -18,17 +18,18 @@ package com.android.ide.eclipse.adt.internal.lint; import static com.android.ide.common.layout.LayoutConstants.ATTR_CONTENT_DESCRIPTION; import static com.android.ide.common.layout.LayoutConstants.ATTR_INPUT_TYPE; import static com.android.ide.common.layout.LayoutConstants.VALUE_FALSE; +import static com.android.tools.lint.detector.api.LintConstants.ATTR_TRANSLATABLE; import com.android.tools.lint.checks.AccessibilityDetector; import com.android.tools.lint.checks.InefficientWeightDetector; import com.android.tools.lint.checks.SecurityDetector; import com.android.tools.lint.checks.TextFieldDetector; +import com.android.tools.lint.checks.TranslationDetector; import com.android.tools.lint.detector.api.LintConstants; import org.eclipse.core.resources.IMarker; /** Shared fix class for various builtin attributes */ -@SuppressWarnings("restriction") // DOM model final class SetAttributeFix extends SetPropertyFix { private SetAttributeFix(String id, IMarker marker) { super(id, marker); @@ -44,6 +45,8 @@ final class SetAttributeFix extends SetPropertyFix { return LintConstants.ATTR_PERMISSION; } else if (mId.equals(TextFieldDetector.ISSUE.getId())) { return ATTR_INPUT_TYPE; + } else if (mId.equals(TranslationDetector.MISSING.getId())) { + return ATTR_TRANSLATABLE; } else { assert false : mId; return ""; @@ -51,6 +54,15 @@ final class SetAttributeFix extends SetPropertyFix { } @Override + protected boolean isAndroidAttribute() { + if (mId.equals(TranslationDetector.MISSING.getId())) { + return false; + } + + return true; + } + + @Override public String getDisplayString() { if (mId.equals(AccessibilityDetector.ISSUE.getId())) { return "Add content description attribute"; @@ -60,6 +72,8 @@ final class SetAttributeFix extends SetPropertyFix { return "Set input type"; } else if (mId.equals(SecurityDetector.EXPORTED_SERVICE.getId())) { return "Add permission attribute"; + } else if (mId.equals(TranslationDetector.MISSING.getId())) { + return "Mark this as a non-translatable resource"; } else { assert false : mId; return ""; @@ -67,15 +81,37 @@ final class SetAttributeFix extends SetPropertyFix { } @Override + public String getAdditionalProposalInfo() { + String help = super.getAdditionalProposalInfo(); + + if (mId.equals(TranslationDetector.MISSING.getId())) { + help = "<b>Adds translatable=\"false\" to this <string>.</b><br><br>" + help; + } + + return help; + } + + @Override protected boolean invokeCodeCompletion() { return mId.equals(SecurityDetector.EXPORTED_SERVICE.getId()) || mId.equals(TextFieldDetector.ISSUE.getId()); } @Override + public boolean selectValue() { + if (mId.equals(TranslationDetector.MISSING.getId())) { + return false; + } else { + return super.selectValue(); + } + } + + @Override protected String getProposal() { if (mId.equals(InefficientWeightDetector.BASELINE_WEIGHTS.getId())) { return VALUE_FALSE; + } else if (mId.equals(TranslationDetector.MISSING.getId())) { + return VALUE_FALSE; } return super.getProposal(); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/SetPropertyFix.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/SetPropertyFix.java index 2bfe5e8..8b32734 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/SetPropertyFix.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/SetPropertyFix.java @@ -48,6 +48,9 @@ abstract class SetPropertyFix extends DocumentFix { /** Attribute to be added */ protected abstract String getAttribute(); + /** Whether it's in the android: namespace */ + protected abstract boolean isAndroidAttribute(); + protected String getProposal() { return invokeCodeCompletion() ? "" : "TODO"; //$NON-NLS-1$ } @@ -70,7 +73,10 @@ abstract class SetPropertyFix extends DocumentFix { Element element = (Element) node; String proposal = getProposal(); String localAttribute = getAttribute(); - String prefix = XmlUtils.lookupNamespacePrefix(node, ANDROID_URI); + String prefix = null; + if (isAndroidAttribute()) { + prefix = XmlUtils.lookupNamespacePrefix(node, ANDROID_URI); + } String attribute = prefix != null ? prefix + ':' + localAttribute : localAttribute; // This does not work even though it should: it does not include the prefix @@ -78,18 +84,29 @@ abstract class SetPropertyFix extends DocumentFix { // So workaround instead: element.setAttribute(attribute, proposal); - Attr attr = element.getAttributeNodeNS(ANDROID_URI, localAttribute); + Attr attr = null; + if (isAndroidAttribute()) { + attr = element.getAttributeNodeNS(ANDROID_URI, localAttribute); + } else { + attr = element.getAttributeNode(localAttribute); + } if (attr instanceof IndexedRegion) { IndexedRegion region = (IndexedRegion) attr; int offset = region.getStartOffset(); // We only want to select the value part inside the quotes, // so skip the attribute and =" parts added by WST: offset += attribute.length() + 2; - mSelect = new Region(offset, proposal.length()); + if (selectValue()) { + mSelect = new Region(offset, proposal.length()); + } } } } + protected boolean selectValue() { + return true; + } + @Override public void apply(IDocument document) { try { diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/TypoFix.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/TypoFix.java index 7c34e3e..4358410 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/TypoFix.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/TypoFix.java @@ -63,7 +63,7 @@ final class TypoFix extends DocumentFix { return; } List<String> replacements = TypoDetector.getSuggestions(message); - if (replacements.size() == 0) { + if (replacements == null || replacements.isEmpty()) { return; } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java index 467602f..022857e 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java @@ -20,7 +20,6 @@ import static com.android.sdklib.internal.project.ProjectProperties.PROPERTY_SDK import com.android.ide.eclipse.adt.AdtConstants; import com.android.ide.eclipse.adt.AdtPlugin; -import com.android.ide.eclipse.adt.AdtUtils; import com.android.ide.eclipse.adt.AndroidPrintStream; import com.android.ide.eclipse.adt.internal.build.BuildHelper; import com.android.ide.eclipse.adt.internal.build.DexException; @@ -36,6 +35,7 @@ import com.android.sdklib.build.ApkCreationException; import com.android.sdklib.build.DuplicateFileException; import com.android.sdklib.internal.project.ProjectProperties; import com.android.sdklib.xml.AndroidManifest; +import com.android.tools.lint.detector.api.LintUtils; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; @@ -177,7 +177,7 @@ public final class ExportHelper { proguardConfig = proguardConfig.replace('/', File.separatorChar); } - Iterable<String> paths = AdtUtils.splitPath(proguardConfig); + Iterable<String> paths = LintUtils.splitPath(proguardConfig); for (String path : paths) { if (path.startsWith(SDK_PROPERTY_REF)) { path = AdtPrefs.getPrefs().getOsSdkFolder() + diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplatePage.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplatePage.java index 0a62c8b..5f10ce0 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplatePage.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplatePage.java @@ -239,9 +239,9 @@ public class NewTemplatePage extends WizardPage String id = parameter.id; assert id != null && !id.isEmpty() : ATTR_ID; - String value = defaults.get(id); + Object value = defaults.get(id); if (value == null) { - value = parameter.initial; + value = parameter.value; } String name = parameter.name; @@ -289,8 +289,8 @@ public class NewTemplatePage extends WizardPage 2, 1)); } - if (value != null && !value.isEmpty()){ - text.setText(value); + if (value instanceof String) { + text.setText((String) value); mValues.parameters.put(id, value); } @@ -319,8 +319,8 @@ public class NewTemplatePage extends WizardPage checkBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); - if (value != null && !value.isEmpty()){ - Boolean selected = Boolean.valueOf(value); + if (value instanceof Boolean) { + Boolean selected = (Boolean) value; checkBox.setSelection(selected); mValues.parameters.put(id, value); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizardState.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizardState.java index 00183d2..6101161 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizardState.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizardState.java @@ -29,6 +29,8 @@ import com.android.annotations.Nullable; import com.android.ide.eclipse.adt.internal.assetstudio.ConfigureAssetSetPage; import com.android.ide.eclipse.adt.internal.assetstudio.CreateAssetSetWizardState; import com.android.ide.eclipse.adt.internal.editors.manifest.ManifestInfo; +import com.android.ide.eclipse.adt.internal.sdk.Sdk; +import com.android.sdklib.IAndroidTarget; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; @@ -124,13 +126,17 @@ public class NewTemplateWizardState { return manifest.getMinSdkVersion(); } - /** Returns the min SDK version to use */ + /** Returns the build API version to use */ int getBuildApi() { if (project == null) { return -1; } - ManifestInfo manifest = ManifestInfo.get(project); - return manifest.getMinSdkVersion(); + IAndroidTarget target = Sdk.getCurrent().getTarget(project); + if (target != null) { + return target.getVersion().getApiLevel(); + } + + return getMinSdk(); } /** Computes the changes this wizard will make */ diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/Parameter.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/Parameter.java index 9c31033..a9a3f33 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/Parameter.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/Parameter.java @@ -237,7 +237,11 @@ class Parameter { constraints = EnumSet.noneOf(Constraint.class); } - value = initial; + if (initial != null && !initial.isEmpty() && type == Type.BOOLEAN) { + value = Boolean.valueOf(initial); + } else { + value = initial; + } } Parameter(@NonNull Type type, @NonNull String id, @NonNull String initialValue) { 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 1c3b862..e214788 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 @@ -98,8 +98,16 @@ import javax.xml.parsers.SAXParserFactory; * and merging into existing files */ class TemplateHandler { - /** Highest supported format; templates with a higher number will be skipped */ - static final int CURRENT_FORMAT = 1; + /** Highest supported format; templates with a higher number will be skipped + * <p> + * <ul> + * <li> 1: Initial format, supported by ADT 20 and up. + * <li> 2: ADT 21 and up. Boolean variables that have a default value and are not + * edited by the user would end up as strings in ADT 20; now they are always + * proper Booleans. Templates which rely on this should specify format >= 2. + * </ul> + */ + static final int CURRENT_FORMAT = 2; /** * Special marker indicating that this path refers to the special shared @@ -396,7 +404,14 @@ class TemplateHandler { String id = attributes.getValue(ATTR_ID); if (!paramMap.containsKey(id)) { String value = attributes.getValue(ATTR_DEFAULT); - paramMap.put(id, value); + Object mapValue = value; + if (value != null && !value.isEmpty()) { + String type = attributes.getValue(ATTR_TYPE); + if ("boolean".equals(type)) { //$NON-NLS-1$ + mapValue = Boolean.valueOf(value); + } + } + paramMap.put(id, mapValue); } } else if (TAG_GLOBAL.equals(name)) { String id = attributes.getValue(ATTR_ID); diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/.classpath b/eclipse/plugins/com.android.ide.eclipse.monitor/.classpath index 9642053..1be4b68 100644 --- a/eclipse/plugins/com.android.ide.eclipse.monitor/.classpath +++ b/eclipse/plugins/com.android.ide.eclipse.monitor/.classpath @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> + <classpathentry exported="true" kind="lib" path="libs/sdkuilib.jar"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.monitor/META-INF/MANIFEST.MF index 2a2a405..047072b 100644 --- a/eclipse/plugins/com.android.ide.eclipse.monitor/META-INF/MANIFEST.MF +++ b/eclipse/plugins/com.android.ide.eclipse.monitor/META-INF/MANIFEST.MF @@ -11,6 +11,7 @@ Require-Bundle: org.eclipse.ui, com.android.ide.eclipse.base Bundle-ActivationPolicy: lazy Bundle-Vendor: %Bundle-Vendor -Bundle-ClassPath: . +Bundle-ClassPath: ., + libs/sdkuilib.jar Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/build.properties b/eclipse/plugins/com.android.ide.eclipse.monitor/build.properties index 44471de..a2a2a99 100644 --- a/eclipse/plugins/com.android.ide.eclipse.monitor/build.properties +++ b/eclipse/plugins/com.android.ide.eclipse.monitor/build.properties @@ -7,4 +7,5 @@ bin.includes = META-INF/,\ plugin_customization.ini,\ plugin.properties,\ images/,\ - splash.bmp + splash.bmp,\ + libs/sdkuilib.jar diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorApplication.java b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorApplication.java index 27fcdd9..5f87813 100644 --- a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorApplication.java +++ b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorApplication.java @@ -18,7 +18,11 @@ package com.android.ide.eclipse.monitor; import com.android.ide.eclipse.monitor.SdkToolsLocator.SdkInstallStatus; import com.android.prefs.AndroidLocation; +import com.android.sdklib.ISdkLog; +import com.android.sdklib.NullSdkLog; +import com.android.sdklib.SdkManager; import com.android.sdkstats.SdkStatsService; +import com.android.sdkuilib.internal.repository.sdkman2.AdtUpdateDialog; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; @@ -55,6 +59,14 @@ public class MonitorApplication implements IApplication { } MonitorPlugin.getDefault().setSdkPath(sdkPath); + // install platform tools if necessary + ISdkLog sdkLog = new NullSdkLog(); + SdkManager manager = SdkManager.createManager(sdkPath, sdkLog); + if (manager.getPlatformToolsVersion() == null) { + AdtUpdateDialog window = new AdtUpdateDialog(new Shell(display), sdkLog, sdkPath); + window.installPlatformTools(); + } + // If this is the first time using ddms or adt, open up the stats service // opt out dialog, and request user for permissions. // Note that the actual ping is performed in MonitorStartup diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/SdkToolsLocator.java b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/SdkToolsLocator.java index ba87c7b..19e1a43 100644 --- a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/SdkToolsLocator.java +++ b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/SdkToolsLocator.java @@ -73,7 +73,7 @@ public class SdkToolsLocator { } public SdkInstallStatus isValidInstallation() { - List<String> executables = Arrays.asList(getAdbLocation(), + List<String> executables = Arrays.asList( getTraceViewLocation(), getHprofConvLocation()); diff --git a/eclipse/plugins/com.android.ide.eclipse.ndk/src/com/android/ide/eclipse/ndk/internal/launch/NdkGdbLaunchDelegate.java b/eclipse/plugins/com.android.ide.eclipse.ndk/src/com/android/ide/eclipse/ndk/internal/launch/NdkGdbLaunchDelegate.java index 57d96d7..818a5c1 100644 --- a/eclipse/plugins/com.android.ide.eclipse.ndk/src/com/android/ide/eclipse/ndk/internal/launch/NdkGdbLaunchDelegate.java +++ b/eclipse/plugins/com.android.ide.eclipse.ndk/src/com/android/ide/eclipse/ndk/internal/launch/NdkGdbLaunchDelegate.java @@ -19,9 +19,9 @@ package com.android.ide.eclipse.ndk.internal.launch; import com.android.ddmlib.AdbCommandRejectedException; import com.android.ddmlib.AndroidDebugBridge; import com.android.ddmlib.Client; +import com.android.ddmlib.CollectingOutputReceiver; import com.android.ddmlib.IDevice; import com.android.ddmlib.IDevice.DeviceUnixSocketNamespace; -import com.android.ddmlib.IShellOutputReceiver; import com.android.ddmlib.InstallException; import com.android.ddmlib.ShellCommandUnresponsiveException; import com.android.ddmlib.SyncException; @@ -233,7 +233,7 @@ public class NdkGdbLaunchDelegate extends GdbLaunchDelegate { activityName); try { CountDownLatch launchedLatch = new CountDownLatch(1); - ShellOutputReceiver receiver = new ShellOutputReceiver(launchedLatch); + CollectingOutputReceiver receiver = new CollectingOutputReceiver(launchedLatch); device.executeShellCommand(command, receiver); launchedLatch.await(5, TimeUnit.SECONDS); String shellOutput = receiver.getOutput(); @@ -479,39 +479,9 @@ public class NdkGdbLaunchDelegate extends GdbLaunchDelegate { String command = String.format("run-as %s /system/bin/sh -c pwd", app); //$NON-NLS-1$ CountDownLatch commandCompleteLatch = new CountDownLatch(1); - ShellOutputReceiver receiver = new ShellOutputReceiver(commandCompleteLatch); + CollectingOutputReceiver receiver = new CollectingOutputReceiver(commandCompleteLatch); device.executeShellCommand(command, receiver); commandCompleteLatch.await(timeout, timeoutUnit); return receiver.getOutput().trim(); } - - private static class ShellOutputReceiver implements IShellOutputReceiver { - private StringBuffer sb = new StringBuffer(); - private CountDownLatch mCompleteLatch; - - public ShellOutputReceiver(CountDownLatch commandCompleteLatch) { - mCompleteLatch = commandCompleteLatch; - } - - @Override - public void addOutput(byte[] data, int offset, int length) { - sb.append(new String(data, offset, length)); - } - - @Override - public void flush() { - if (mCompleteLatch != null) { - mCompleteLatch.countDown(); - } - } - - @Override - public boolean isCancelled() { - return false; - } - - public String getOutput() { - return sb.toString(); - } - } } diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion11-expected-completion73.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion11-expected-completion73.txt index 21baad8..a2feb13 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion11-expected-completion73.txt +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion11-expected-completion73.txt @@ -1,5 +1,5 @@ Code completion in completion11.xml for ?android:attr/Textapp^: -?android:attr/textAppearance +?android:attr/textAppearance : Base text color, typeface, size, and style. ?android:attr/textAppearanceButton ?android:attr/textAppearanceInverse ?android:attr/textAppearanceLarge diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion32.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion32.txt index 7e27fa6..30e6c31 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion32.txt +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion32.txt @@ -88,7 +88,6 @@ android:fillViewport : Defines whether the scrollview should stretch its content android:filterTouchesWhenObscured : Specifies whether to filter touches when the view's window is obscured by another visible window. [boolean] android:firstDayOfWeek : The first day of week according to java.util.Calendar. [integer] android:fitsSystemWindows : Boolean internal attribute to adjust view layout based on system windows such as the status bar. [boolean] -android:flingable : @hide Whether the number picker supports fligning. [boolean] android:flipInterval : [integer] android:focusable : Boolean that controls whether a view can take focus. [boolean] android:focusableInTouchMode : Boolean that controls whether a view can take focus while in touch mode. [boolean] @@ -221,8 +220,6 @@ android:secondaryProgress : Defines the secondary progress value, between 0 and android:selectAllOnFocus : If the text is selectable, select it all when the view takes focus instead of moving the cursor to the start or end. [boolean] android:selectedDateVerticalBar : Drawable for the vertical bar shown at the beggining and at the end of a selected date. [reference] android:selectedWeekBackgroundColor : The background color for the selected week. [color, reference] -android:selectionDivider : @hide The divider for making the selection area. [reference] -android:selectionDividerHeight : @hide The height of the selection divider. [dimension] android:shadowColor : Place a shadow of the specified color behind the text. [color] android:shadowDx : Horizontal offset of the shadow. [float] android:shadowDy : Vertical offset of the shadow. [float] @@ -233,7 +230,6 @@ android:shownWeekCount : The number of weeks to be shown. [integer] android:shrinkColumns : The zero-based index of the columns to shrink. [string] android:singleLine : Constrains the text to a single horizontally scrolling line instead of letting it wrap onto multiple lines, and advances focus instead of inserting a newline when you press the enter key. * Deprecated: This attribute is deprecated and is replaced by the textMultiLine flag in the inputType attribute. Use caution when altering existing layouts, as the default value of singeLine is false (multi-line mode), but if you specify any value for inputType, the default is single-line mode. (If both singleLine and inputType attributes are found, the inputType flags will override the value of singleLine.). [boolean] android:smoothScrollbar : When set to true, the list will use a more refined calculation method based on the pixels height of the items visible on screen. [boolean] -android:solidColor : @hide Color for the solid color background if such for optimized rendering. [color, reference] android:soundEffectsEnabled : Boolean that controls whether a view should have sound effects enabled for events such as clicking and touching. [boolean] android:spacing : [dimension] android:spinnerMode : Display mode for spinner options. [enum] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues2-expected-completion71.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues2-expected-completion71.txt index 641cddb..c491fea 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues2-expected-completion71.txt +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues2-expected-completion71.txt @@ -1,3 +1,2 @@ Code completion in completionvalues2.xml for <item name="main_layout5" type="string">@string/^app_name</item>: @string/app_name -@string/hello diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion18.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion18.txt index 21bb2fa..853d9a5 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion18.txt +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion18.txt @@ -1,5 +1,5 @@ Code completion in manifest.xml for <activity android:^name=".TestActivity": -android:name : Required name of the class implementing the activity, deriving from android.app.Activity. [string] +android:name : Required name of the class implementing the activity, deriving from android.app.Activity. [string]. * Required. android:theme : The overall theme to use for an activity. [reference] android:label : A user-legible name for the given item. [string, reference] android:description : Descriptive text for the associated data. [reference] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion69.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion69.txt index 627ff01..c60a305 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion69.txt +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion69.txt @@ -1,4 +1,5 @@ Code completion in manifest.xml for <uses-sdk android:minSdkVersion="^11" />: +16 : API 16: Android 4.1 (JellyBean) 15 : API 15: Android 4.0.3 (IceCreamSandwich) 14 : API 14: Android 4.0 (IceCreamSandwich) 13 : API 13: Android 3.2 (Honeycomb) diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/AdtUtilsTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/AdtUtilsTest.java index b2b6787..e0ebdbc 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/AdtUtilsTest.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/AdtUtilsTest.java @@ -15,9 +15,6 @@ */ package com.android.ide.eclipse.adt; -import com.google.common.collect.Iterables; - -import java.util.Arrays; import java.util.Locale; import junit.framework.TestCase; @@ -148,31 +145,6 @@ public class AdtUtilsTest extends TestCase { assertEquals("Foo", AdtUtils.stripSuffix("Foo", "Bar")); } - public void testSplitPath() throws Exception { - assertTrue(Arrays.equals(new String[] { "/foo", "/bar", "/baz" }, - Iterables.toArray(AdtUtils.splitPath("/foo:/bar:/baz"), String.class))); - - assertTrue(Arrays.equals(new String[] { "/foo", "/bar" }, - Iterables.toArray(AdtUtils.splitPath("/foo;/bar"), String.class))); - - assertTrue(Arrays.equals(new String[] { "/foo", "/bar:baz" }, - Iterables.toArray(AdtUtils.splitPath("/foo;/bar:baz"), String.class))); - - assertTrue(Arrays.equals(new String[] { "\\foo\\bar", "\\bar\\foo" }, - Iterables.toArray(AdtUtils.splitPath("\\foo\\bar;\\bar\\foo"), String.class))); - - assertTrue(Arrays.equals(new String[] { "${sdk.dir}\\foo\\bar", "\\bar\\foo" }, - Iterables.toArray(AdtUtils.splitPath("${sdk.dir}\\foo\\bar;\\bar\\foo"), - String.class))); - - assertTrue(Arrays.equals(new String[] { "${sdk.dir}/foo/bar", "/bar/foo" }, - Iterables.toArray(AdtUtils.splitPath("${sdk.dir}/foo/bar:/bar/foo"), - String.class))); - - assertTrue(Arrays.equals(new String[] { "C:\\foo", "/bar" }, - Iterables.toArray(AdtUtils.splitPath("C:\\foo:/bar"), String.class))); - } - public void testFormatFloatValue() throws Exception { assertEquals("1", AdtUtils.formatFloatAttribute(1.0f)); assertEquals("2", AdtUtils.formatFloatAttribute(2.0f)); |