diff options
Diffstat (limited to 'eclipse/plugins')
12 files changed, 175 insertions, 21 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 98e43ab..37559e9 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 @@ -93,6 +93,7 @@ public class AddSupportJarAction implements IObjectActionDelegate { private static final String ANDROID_SUPPORT_V4_JAR = "android-support-v4.jar"; //$NON-NLS-1$ private static final String ANDROID_SUPPORT_V13_JAR = "android-support-v13.jar";//$NON-NLS-1$ private static final String APPCOMPAT_V7_JAR = "android-support-v7-appcompat.jar";//$NON-NLS-1$ + private static final String APP_COMPAT_LIB_NAME = "appcompat_v7"; //$NON-NLS-1$ private ISelection mSelection; /** @@ -310,6 +311,18 @@ public class AddSupportJarAction implements IObjectActionDelegate { final IJavaProject javaProject = JavaCore.create(project); if (javaProject != null) { + // Don't add in the library if it already exists + ProjectState state = Sdk.getProjectState(project); + ProjectPropertiesWorkingCopy copy = state.getProperties().makeWorkingCopy(); + for (String property : copy.keySet()) { + if (property.startsWith(ProjectProperties.PROPERTY_LIB_REF)) { + String libraryReference = copy.getProperty(property); + if (libraryReference != null && libraryReference.contains(APP_COMPAT_LIB_NAME)) { + return true; + } + } + } + File supportPath = getSupportPackageDir(); if (!supportPath.isDirectory()) { File path = installSupport(7); @@ -331,7 +344,7 @@ public class AddSupportJarAction implements IObjectActionDelegate { // Create workspace copy of the project and add library dependency IProject libraryProject = createLibraryProject(libraryPath, project, - "appcompat_v7", waitForFinish); // $NON-NLS-1$ + APP_COMPAT_LIB_NAME, waitForFinish); if (libraryProject != null) { return addLibraryDependency(libraryProject, project, waitForFinish); } @@ -460,7 +473,8 @@ public class AddSupportJarAction implements IObjectActionDelegate { ProjectState state = Sdk.getProjectState(project); String target = state.getProperties().getProperty(ProjectProperties.PROPERTY_TARGET); if (target != null && target.length() > 0) { - ProjectProperties properties = ProjectProperties.load(libraryPath.getPath(), + ProjectProperties properties = ProjectProperties.load( + destDir.toLocalFile(EFS.NONE, new NullProgressMonitor()).getPath(), PropertyType.PROJECT); ProjectPropertiesWorkingCopy copy = properties.makeWorkingCopy(); copy.setProperty(ProjectProperties.PROPERTY_TARGET, target); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/formatting/AndroidXmlFormattingStrategy.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/formatting/AndroidXmlFormattingStrategy.java index 9f69e41..4cab419 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/formatting/AndroidXmlFormattingStrategy.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/formatting/AndroidXmlFormattingStrategy.java @@ -559,6 +559,11 @@ public class AndroidXmlFormattingStrategy extends ContextBasedFormattingStrategy String[] segments = resourceFolder.split("-"); //$NON-NLS-1$ ResourceType type = ResourceType.getEnum(segments[0]); if (type != null) { + // <resources> files found in res/xml/ should be formatted as + // resource files! + if (type == ResourceType.XML && style == XmlFormatStyle.RESOURCE) { + return style; + } style = EclipseXmlPrettyPrinter.get(type); } } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java index 535aa1e..b33d65b 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java @@ -20,18 +20,25 @@ import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectW import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectWizard.ATTR_MIN_API_LEVEL; import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectWizard.ATTR_PACKAGE_NAME; import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectWizard.ATTR_TARGET_API; +import static org.eclipse.core.resources.IResource.DEPTH_INFINITE; import com.android.annotations.NonNull; +import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.AdtUtils; import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.ltk.core.refactoring.Change; +import org.eclipse.ltk.core.refactoring.CompositeChange; import org.eclipse.ui.IWorkbench; +import java.lang.reflect.InvocationTargetException; import java.util.List; import java.util.Set; @@ -132,6 +139,20 @@ public class NewActivityWizard extends TemplateWizard { } @Override + public boolean performFinish(IProgressMonitor monitor) throws InvocationTargetException { + boolean success = super.performFinish(monitor); + + if (success) { + List<Runnable> finalizingTasks = getFinalizingActions(); + for (Runnable r : finalizingTasks) { + r.run(); + } + return true; + } + return false; + } + + @Override @NonNull protected IProject getProject() { return mActivityValues.project; 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 6331720..d350a00 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 @@ -23,6 +23,7 @@ import com.android.annotations.VisibleForTesting; import com.android.assetstudiolib.GraphicGenerator; import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.AdtUtils; +import com.android.ide.eclipse.adt.internal.actions.AddSupportJarAction; import com.android.ide.eclipse.adt.internal.assetstudio.AssetType; import com.android.ide.eclipse.adt.internal.assetstudio.ConfigureAssetSetPage; import com.android.ide.eclipse.adt.internal.assetstudio.CreateAssetSetWizardState; @@ -75,6 +76,7 @@ public class NewProjectWizard extends TemplateWizard { static final String CATEGORY_PROJECTS = "projects"; //$NON-NLS-1$ static final String CATEGORY_ACTIVITIES = "activities"; //$NON-NLS-1$ static final String CATEGORY_OTHER = "other"; //$NON-NLS-1$ + static final String ATTR_APP_COMPAT = "appCompat"; //$NON-NLS-1$ /** * Reserved file name for the launcher icon, resolves to the xhdpi version * @@ -268,6 +270,17 @@ public class NewProjectWizard extends TemplateWizard { Map<String, Object> paramMap = new HashMap<String, Object>(); addProjectInfo(paramMap); TemplateHandler.addDirectoryParameters(paramMap, getProject()); + // We don't know at this point whether the activity is going to need + // AppCompat so we just assume that it will. + if (mValues.createActivity && mValues.minSdkLevel < 14) { + paramMap.put(ATTR_APP_COMPAT, true); + getFinalizingActions().add(new Runnable() { + @Override + public void run() { + AddSupportJarAction.installAppCompatLibrary(mProject, true); + } + }); + } return template.render(mProject, paramMap); } @@ -359,16 +372,10 @@ public class NewProjectWizard extends TemplateWizard { AdtPlugin.log(e, null); } - // Run finalizing actions - // Display.getDefault().asyncExec(new Runnable() { - // @Override - // public void run() { List<Runnable> finalizingTasks = getFinalizingActions(); for (Runnable r : finalizingTasks) { r.run(); } - // } - // }); return true; } catch (Exception ioe) { diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/DisplayRadix.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/DisplayRadix.java new file mode 100644 index 0000000..935f4d7 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/DisplayRadix.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.ide.eclipse.gltrace.state; + +public enum DisplayRadix { + DECIMAL, HEX +} diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLBooleanProperty.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLBooleanProperty.java index 22d8d47..8332b0a 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLBooleanProperty.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLBooleanProperty.java @@ -30,7 +30,7 @@ public final class GLBooleanProperty extends GLAbstractAtomicProperty { @Override public boolean isDefault() { - return mDefaultValue == mCurrentValue; + return mDefaultValue != null & mDefaultValue.equals(mCurrentValue); } public void setValue(Boolean newValue) { diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLIntegerProperty.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLIntegerProperty.java index 1a71fe2..7374ff0 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLIntegerProperty.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLIntegerProperty.java @@ -18,8 +18,6 @@ package com.android.ide.eclipse.gltrace.state; /** Properties that hold an integer value. */ public class GLIntegerProperty extends GLAbstractAtomicProperty { - public enum DisplayRadix { DECIMAL, HEX }; - private final Integer mDefaultValue; private Integer mCurrentValue; private final DisplayRadix mRadix; @@ -37,7 +35,7 @@ public class GLIntegerProperty extends GLAbstractAtomicProperty { @Override public boolean isDefault() { - return mCurrentValue == mDefaultValue; + return mDefaultValue != null & mDefaultValue.equals(mCurrentValue); } public void setValue(Integer newValue) { diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLLongProperty.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLLongProperty.java new file mode 100644 index 0000000..44c04ec --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLLongProperty.java @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.ide.eclipse.gltrace.state; + +/** Properties that hold a long value. */ +public class GLLongProperty extends GLAbstractAtomicProperty { + private final Long mDefaultValue; + private Long mCurrentValue; + private final DisplayRadix mRadix; + + public GLLongProperty(GLStateType name, Long defaultValue, DisplayRadix radix) { + super(name); + + mDefaultValue = mCurrentValue = defaultValue; + mRadix = radix; + } + + public GLLongProperty(GLStateType name, Long defaultValue) { + this(name, defaultValue, DisplayRadix.DECIMAL); + } + + @Override + public boolean isDefault() { + return mDefaultValue != null & mDefaultValue.equals(mCurrentValue); + } + + public void setValue(Long newValue) { + mCurrentValue = newValue; + } + + @Override + public String getStringValue() { + if (mRadix == DisplayRadix.HEX) { + return String.format("0x%08x", Long.valueOf(mCurrentValue)); + } + + return mCurrentValue.toString(); + } + + @Override + public String toString() { + return getType() + "=" + getStringValue(); //$NON-NLS-1$ + } + + @Override + public void setValue(Object value) { + if (value instanceof Long) { + mCurrentValue = (Long) value; + } else { + throw new IllegalArgumentException("Attempt to set non-integer value for " //$NON-NLS-1$ + + getType()); + } + } + + @Override + public Object getValue() { + return mCurrentValue; + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLObjectProperty.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLObjectProperty.java index 84ad6ec..703d4da 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLObjectProperty.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLObjectProperty.java @@ -34,7 +34,7 @@ public class GLObjectProperty extends GLAbstractAtomicProperty { @Override public boolean isDefault() { - return mDefaultValue == mCurrentValue; + return mDefaultValue != null & mDefaultValue.equals(mCurrentValue); } @Override diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLState.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLState.java index 1743499..6230586 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLState.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLState.java @@ -17,12 +17,12 @@ package com.android.ide.eclipse.gltrace.state; import com.android.ide.eclipse.gltrace.GLEnum; -import com.android.ide.eclipse.gltrace.state.GLIntegerProperty.DisplayRadix; +import com.android.ide.eclipse.gltrace.state.DisplayRadix; import java.util.Collections; public class GLState { - /** # of texture units modelled in the GL State. */ + /** # of texture units modeled in the GL State. */ public static final int TEXTURE_UNIT_COUNT = 16; /** # of vertex attributes */ @@ -56,7 +56,8 @@ public class GLState { stride = new GLIntegerProperty(GLStateType.VERTEX_ATTRIB_ARRAY_STRIDE, 0); type = new GLEnumProperty(GLStateType.VERTEX_ATTRIB_ARRAY_TYPE, GLEnum.GL_FLOAT); normalized = new GLBooleanProperty(GLStateType.VERTEX_ATTRIB_ARRAY_NORMALIZED, false); - pointer = new GLIntegerProperty(GLStateType.VERTEX_ATTRIB_ARRAY_POINTER, 0); + pointer = new GLLongProperty(GLStateType.VERTEX_ATTRIB_ARRAY_POINTER, 0L, + DisplayRadix.HEX); IGLProperty perVertexAttribArrayState = new GLCompositeProperty( GLStateType.VERTEX_ATTRIB_ARRAY_COMPOSITE, diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/StateTransformFactory.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/StateTransformFactory.java index fb9f227..023f84b 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/StateTransformFactory.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/StateTransformFactory.java @@ -189,7 +189,13 @@ public class StateTransformFactory { int type = msg.getArgs(2).getIntValue(0); boolean normalized = msg.getArgs(3).getBoolValue(0); int stride = msg.getArgs(4).getIntValue(0); - int pointer = msg.getArgs(5).getIntValue(0); + + long pointer; + if (msg.getArgs(5).getIntValueCount() > 0) { + pointer = msg.getArgs(5).getIntValue(0); + } else { + pointer = msg.getArgs(5).getInt64Value(0); + } List<IStateTransform> transforms = new ArrayList<IStateTransform>(); transforms.add(new PropertyChangeTransform( @@ -226,7 +232,7 @@ public class StateTransformFactory { GLStateType.VERTEX_ATTRIB_ARRAY, Integer.valueOf(index), GLStateType.VERTEX_ATTRIB_ARRAY_POINTER), - Integer.valueOf(pointer))); + Long.valueOf(pointer))); return transforms; } diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfoTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfoTest.java index 619fba5..43f9d68 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfoTest.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfoTest.java @@ -27,11 +27,13 @@ import com.android.sdklib.AndroidVersion; import com.android.sdklib.BuildToolInfo; import com.android.sdklib.IAndroidTarget; import com.android.sdklib.ISystemImage; +import com.android.sdklib.repository.descriptors.IdDisplay; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.NullProgressMonitor; import java.io.ByteArrayInputStream; +import java.io.File; import java.io.InputStream; import java.util.ArrayList; import java.util.List; @@ -273,7 +275,7 @@ public class ManifestInfoTest extends AdtProjectTest { } @Override - public String getDefaultSkin() { + public File getDefaultSkin() { return null; } @@ -288,7 +290,7 @@ public class ManifestInfoTest extends AdtProjectTest { } @Override - public ISystemImage getSystemImage(String abiType) { + public ISystemImage getSystemImage(IdDisplay tag, String abiType) { return null; } @@ -323,6 +325,12 @@ public class ManifestInfoTest extends AdtProjectTest { } @Override + public File getFile(int pathId) { + return null; + } + + + @Override public String[] getPlatformLibraries() { return null; } @@ -353,7 +361,7 @@ public class ManifestInfoTest extends AdtProjectTest { } @Override - public String[] getSkins() { + public File[] getSkins() { return null; } |
