aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse
diff options
context:
space:
mode:
Diffstat (limited to 'eclipse')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/icons/view.pngbin394 -> 0 bytes
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/UiElementPullParser.java11
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/OutlinePage.java17
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestEditor.java35
4 files changed, 45 insertions, 18 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/icons/view.png b/eclipse/plugins/com.android.ide.eclipse.adt/icons/view.png
deleted file mode 100644
index 35c4d8f..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.adt/icons/view.png
+++ /dev/null
Binary files differ
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/UiElementPullParser.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/UiElementPullParser.java
index f57d904..6915052 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/UiElementPullParser.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/UiElementPullParser.java
@@ -16,6 +16,7 @@
package com.android.ide.eclipse.adt.internal.editors.layout;
+import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI;
import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_HEIGHT;
import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH;
import static com.android.ide.common.layout.LayoutConstants.ATTR_PADDING;
@@ -24,6 +25,7 @@ import static com.android.ide.common.layout.LayoutConstants.VALUE_MATCH_PARENT;
import static com.android.ide.eclipse.adt.internal.editors.layout.descriptors.LayoutDescriptors.ATTR_LAYOUT;
import static com.android.ide.eclipse.adt.internal.editors.layout.descriptors.LayoutDescriptors.VIEW_FRAGMENT;
import static com.android.ide.eclipse.adt.internal.editors.layout.descriptors.LayoutDescriptors.VIEW_INCLUDE;
+import static com.android.tools.lint.detector.api.LintConstants.AUTO_URI;
import com.android.ide.common.rendering.api.ILayoutPullParser;
import com.android.ide.common.rendering.api.ViewInfo;
@@ -366,6 +368,15 @@ public class UiElementPullParser extends BasePullParser {
}
Node attribute = xmlNode.getAttributes().getNamedItemNS(namespace, localName);
+
+ // Auto-convert http://schemas.android.com/apk/res-auto resources. The lookup
+ // will be for the current application's resource package, e.g.
+ // http://schemas.android.com/apk/res/foo.bar, but the XML document will
+ // be using http://schemas.android.com/apk/res-auto in library projects:
+ if (attribute == null && namespace != null && !namespace.equals(ANDROID_URI)) {
+ attribute = xmlNode.getAttributes().getNamedItemNS(AUTO_URI, localName);
+ }
+
if (attribute != null) {
String value = attribute.getNodeValue();
if (mIncreaseExistingPadding && ATTR_PADDING.equals(localName) &&
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/OutlinePage.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/OutlinePage.java
index ef1a17c..485d574 100755
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/OutlinePage.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/OutlinePage.java
@@ -17,6 +17,7 @@
package com.android.ide.eclipse.adt.internal.editors.layout.gle2;
import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI;
+import static com.android.ide.common.layout.LayoutConstants.ATTR_CLASS;
import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_COLUMN;
import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_COLUMN_SPAN;
import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_ROW;
@@ -28,6 +29,7 @@ import static com.android.ide.common.layout.LayoutConstants.DRAWABLE_PREFIX;
import static com.android.ide.common.layout.LayoutConstants.LAYOUT_PREFIX;
import static com.android.ide.common.layout.LayoutConstants.LINEAR_LAYOUT;
import static com.android.ide.common.layout.LayoutConstants.VALUE_VERTICAL;
+import static com.android.ide.eclipse.adt.internal.editors.layout.descriptors.LayoutDescriptors.VIEW_VIEWTAG;
import static org.eclipse.jface.viewers.StyledString.QUALIFIER_STYLER;
import com.android.annotations.VisibleForTesting;
@@ -496,13 +498,26 @@ public class OutlinePage extends ContentOutlinePage
Image img = null;
// Special case for the common case of vertical linear layouts:
// show vertical linear icon (the default icon shows horizontal orientation)
- if (desc.getUiName().equals(LINEAR_LAYOUT)) {
+ String uiName = desc.getUiName();
+ if (uiName.equals(LINEAR_LAYOUT)) {
Element e = (Element) node.getXmlNode();
if (VALUE_VERTICAL.equals(e.getAttributeNS(ANDROID_URI,
ATTR_ORIENTATION))) {
IconFactory factory = IconFactory.getInstance();
img = factory.getIcon("VerticalLinearLayout"); //$NON-NLS-1$
}
+ } else if (uiName.equals(VIEW_VIEWTAG)) {
+ Node xmlNode = node.getXmlNode();
+ if (xmlNode instanceof Element) {
+ String className = ((Element) xmlNode).getAttribute(ATTR_CLASS);
+ if (className != null && className.length() > 0) {
+ int index = className.lastIndexOf('.');
+ if (index != -1) {
+ className = className.substring(index + 1);
+ }
+ img = IconFactory.getInstance().getIcon(className);
+ }
+ }
}
if (img == null) {
img = desc.getGenericIcon();
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestEditor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestEditor.java
index a8ebe75..8f34b48 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestEditor.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestEditor.java
@@ -35,7 +35,6 @@ import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode;
import com.android.ide.eclipse.adt.internal.resources.manager.GlobalProjectMonitor;
import com.android.ide.eclipse.adt.internal.resources.manager.GlobalProjectMonitor.IFileListener;
import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData;
-import com.android.sdklib.xml.AndroidXPathFactory;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
@@ -57,10 +56,6 @@ import org.w3c.dom.Node;
import java.util.Collection;
import java.util.List;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpressionException;
-
/**
* Multi-page form editor for AndroidManifest.xml.
*/
@@ -189,18 +184,24 @@ public final class ManifestEditor extends AndroidXmlEditor {
private Node getManifestXmlNode(Document xmlDoc) {
if (xmlDoc != null) {
- ElementDescriptor manifest_desc = mUiManifestNode.getDescriptor();
- try {
- XPath xpath = AndroidXPathFactory.newXPath();
- Node node = (Node) xpath.evaluate("/" + manifest_desc.getXmlName(), //$NON-NLS-1$
- xmlDoc,
- XPathConstants.NODE);
- assert node != null && node.getNodeName().equals(manifest_desc.getXmlName());
-
- return node;
- } catch (XPathExpressionException e) {
- AdtPlugin.log(e, "XPath error when trying to find '%s' element in XML.", //$NON-NLS-1$
- manifest_desc.getXmlName());
+ ElementDescriptor manifestDesc = mUiManifestNode.getDescriptor();
+ String manifestXmlName = manifestDesc == null ? null : manifestDesc.getXmlName();
+ assert manifestXmlName != null;
+
+ if (manifestXmlName != null) {
+ Node node = xmlDoc.getDocumentElement();
+ if (node != null && manifestXmlName.equals(node.getNodeName())) {
+ return node;
+ }
+
+ for (node = xmlDoc.getFirstChild();
+ node != null;
+ node = node.getNextSibling()) {
+ if (node.getNodeType() == Node.ELEMENT_NODE &&
+ manifestXmlName.equals(node.getNodeName())) {
+ return node;
+ }
+ }
}
}