aboutsummaryrefslogtreecommitdiffstats
path: root/layoutlib_api/src/com/android/ide/common/rendering/api
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2012-12-06 17:24:36 -0800
committerXavier Ducrohet <xav@android.com>2012-12-06 17:24:36 -0800
commitc129ae26a6287a83ba0d53f1a18ac826c090e4de (patch)
tree93d8c4100caadf68185481860f882d9f38bf35ce /layoutlib_api/src/com/android/ide/common/rendering/api
parent9838fb6330c77935c09877066ff635a694aa87e1 (diff)
downloadsdk-c129ae26a6287a83ba0d53f1a18ac826c090e4de.zip
sdk-c129ae26a6287a83ba0d53f1a18ac826c090e4de.tar.gz
sdk-c129ae26a6287a83ba0d53f1a18ac826c090e4de.tar.bz2
refactor layoutlib_api folder structure.
Move folders around to match default gradle/maven folder structure. The custom structure confused some IDEs when importing the project as a Gradle project. Change-Id: Iddd154cd491e21a047d93bd67cc2cfa005fb6158
Diffstat (limited to 'layoutlib_api/src/com/android/ide/common/rendering/api')
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/AdapterBinding.java82
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/AttrResourceValue.java56
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/Bridge.java161
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/Capability.java69
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/DataBindingItem.java97
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/DeclareStyleableResourceValue.java71
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/DensityBasedResourceValue.java87
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/DrawableParams.java63
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/HardwareConfig.java91
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/IAnimationListener.java48
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/IImageFactory.java42
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/ILayoutPullParser.java46
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/IProjectCallback.java154
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/LayoutLog.java164
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/MergeCookie.java42
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/RenderParams.java236
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/RenderResources.java221
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/RenderSession.java269
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/ResourceReference.java103
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/ResourceValue.java121
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/Result.java189
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/SessionParams.java137
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/StyleResourceValue.java96
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/ViewInfo.java184
24 files changed, 0 insertions, 2829 deletions
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/AdapterBinding.java b/layoutlib_api/src/com/android/ide/common/rendering/api/AdapterBinding.java
deleted file mode 100644
index ddcdbd5..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/AdapterBinding.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2011 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.common.rendering.api;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Describe the content of the dynamic android.widget.Adapter used to fill
- * android.widget.AdapterView
- */
-public class AdapterBinding implements Iterable<DataBindingItem> {
-
- private final int mRepeatCount;
- private final List<ResourceReference> mHeaders = new ArrayList<ResourceReference>();
- private final List<DataBindingItem> mItems = new ArrayList<DataBindingItem>();
- private final List<ResourceReference> mFooters = new ArrayList<ResourceReference>();
-
- public AdapterBinding(int repeatCount) {
- mRepeatCount = repeatCount;
- }
-
- public int getRepeatCount() {
- return mRepeatCount;
- }
-
- public void addHeader(ResourceReference layoutInfo) {
- mHeaders.add(layoutInfo);
- }
-
- public int getHeaderCount() {
- return mHeaders.size();
- }
-
- public ResourceReference getHeaderAt(int index) {
- return mHeaders.get(index);
- }
-
- public void addItem(DataBindingItem item) {
- mItems.add(item);
- }
-
- public int getItemCount() {
- return mItems.size();
- }
-
- public DataBindingItem getItemAt(int index) {
- return mItems.get(index);
- }
-
- public void addFooter(ResourceReference layoutInfo) {
- mFooters.add(layoutInfo);
- }
-
- public int getFooterCount() {
- return mFooters.size();
- }
-
- public ResourceReference getFooterAt(int index) {
- return mFooters.get(index);
- }
-
- @Override
- public Iterator<DataBindingItem> iterator() {
- return mItems.iterator();
- }
-}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/AttrResourceValue.java b/layoutlib_api/src/com/android/ide/common/rendering/api/AttrResourceValue.java
deleted file mode 100644
index 530e3d5..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/AttrResourceValue.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2011 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.common.rendering.api;
-
-import com.android.resources.ResourceType;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * A Resource value representing an attr resource.
- *
- * {@link #getValue()} will return null, instead use {@link #getAttributeValues()} to
- * get the enum/flag value associated with an attribute defined in the declare-styleable.
- *
- */
-public class AttrResourceValue extends ResourceValue {
-
- private Map<String, Integer> mValueMap;
-
-
- public AttrResourceValue(ResourceType type, String name, boolean isFramework) {
- super(type, name, isFramework);
- }
-
- /**
- * Return the enum/flag integer values.
- *
- * @return the map of (name, integer) values. Can be null.
- */
- public Map<String, Integer> getAttributeValues() {
- return mValueMap;
- }
-
- public void addValue(String name, Integer value) {
- if (mValueMap == null) {
- mValueMap = new HashMap<String, Integer>();
- }
-
- mValueMap.put(name, value);
- }
-}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/Bridge.java b/layoutlib_api/src/com/android/ide/common/rendering/api/Bridge.java
deleted file mode 100644
index a19b8d5..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/Bridge.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (C) 2010 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.common.rendering.api;
-
-
-import static com.android.ide.common.rendering.api.Result.Status.NOT_IMPLEMENTED;
-
-import com.android.ide.common.rendering.api.Result.Status;
-
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.util.EnumSet;
-import java.util.Map;
-
-/**
- * Entry point of the Layout Library. Extensions of this class provide a method to compute
- * and render a layout.
- */
-public abstract class Bridge {
-
- public final static int API_CURRENT = 9;
-
- /**
- * Returns the API level of the layout library.
- * <p/>
- * While no methods will ever be removed, some may become deprecated, and some new ones
- * will appear.
- * <p/>All Layout libraries based on {@link Bridge} return at minimum an API level of 5.
- */
- public abstract int getApiLevel();
-
- /**
- * Returns the revision of the library inside a given (layoutlib) API level.
- * The true revision number of the library is {@link #getApiLevel()}.{@link #getRevision()}
- */
- public int getRevision() {
- return 0;
- }
-
- /**
- * Returns an {@link EnumSet} of the supported {@link Capability}.
- * @return an {@link EnumSet} with the supported capabilities.
- *
- */
- public EnumSet<Capability> getCapabilities() {
- return EnumSet.noneOf(Capability.class);
- }
-
- /**
- * Initializes the Bridge object.
- *
- * @param platformProperties The build properties for the platform.
- * @param fontLocation the location of the fonts.
- * @param enumValueMap map attrName => { map enumFlagName => Integer value }. This is typically
- * read from attrs.xml in the SDK target.
- * @param log a {@link LayoutLog} object. Can be null.
- * @return true if success.
- */
- public boolean init(Map<String, String> platformProperties,
- File fontLocation,
- Map<String, Map<String, Integer>> enumValueMap,
- LayoutLog log) {
- return false;
- }
-
- /**
- * Prepares the layoutlib to unloaded.
- */
- public boolean dispose() {
- return false;
- }
-
- /**
- * Starts a layout session by inflating and rendering it. The method returns a
- * {@link RenderSession} on which further actions can be taken.
- *
- * @return a new {@link RenderSession} object that contains the result of the scene creation and
- * first rendering.
- */
- public RenderSession createSession(SessionParams params) {
- return null;
- }
-
- /**
- * Renders a Drawable. If the rendering is successful, the result image is accessible through
- * {@link Result#getData()}. It is of type {@link BufferedImage}
- * @param params the rendering parameters.
- * @return the result of the action.
- */
- public Result renderDrawable(DrawableParams params) {
- return Status.NOT_IMPLEMENTED.createResult();
- }
-
- /**
- * Clears the resource cache for a specific project.
- * <p/>This cache contains bitmaps and nine patches that are loaded from the disk and reused
- * until this method is called.
- * <p/>The cache is not configuration dependent and should only be cleared when a
- * resource changes (at this time only bitmaps and 9 patches go into the cache).
- * <p/>
- * The project key provided must be similar to the one passed in {@link RenderParams}.
- *
- * @param projectKey the key for the project.
- */
- public void clearCaches(Object projectKey) {
-
- }
-
- /**
- * Utility method returning the parent of a given view object.
- *
- * @param viewObject the object for which to return the parent.
- *
- * @return a {@link Result} indicating the status of the action, and if success, the parent
- * object in {@link Result#getData()}
- */
- public Result getViewParent(Object viewObject) {
- return NOT_IMPLEMENTED.createResult();
- }
-
- /**
- * Utility method returning the index of a given view in its parent.
- * @param viewObject the object for which to return the index.
- *
- * @return a {@link Result} indicating the status of the action, and if success, the index in
- * the parent in {@link Result#getData()}
- */
- public Result getViewIndex(Object viewObject) {
- return NOT_IMPLEMENTED.createResult();
- }
-
- /**
- * Utility method returning the baseline value for a given view object. This basically returns
- * View.getBaseline().
- *
- * @param viewObject the object for which to return the index.
- *
- * @return the baseline value or -1 if not applicable to the view object or if this layout
- * library does not implement this method.
- *
- * @deprecated use the extended ViewInfo.
- */
- @Deprecated
- public Result getViewBaseline(Object viewObject) {
- return NOT_IMPLEMENTED.createResult();
- }
-}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/Capability.java b/layoutlib_api/src/com/android/ide/common/rendering/api/Capability.java
deleted file mode 100644
index 5ad438d..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/Capability.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2010 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.common.rendering.api;
-
-/**
- * Enum describing the layout bridge capabilities.
- *
- */
-public enum Capability {
- /** Ability to render at full size, as required by the layout, and unbound by the screen */
- UNBOUND_RENDERING,
- /** Ability to override the background of the rendering with transparency using
- * {@link SessionParams#setOverrideBgColor(int)} */
- CUSTOM_BACKGROUND_COLOR,
- /** Ability to call {@link RenderSession#render()} and {@link RenderSession#render(long)}. */
- RENDER,
- /** Ability to ask for a layout only with no rendering through
- * {@link SessionParams#setLayoutOnly()}
- */
- LAYOUT_ONLY,
- /**
- * Ability to control embedded layout parsers through {@link ILayoutPullParser#getParser(String)}
- */
- EMBEDDED_LAYOUT,
- /** Ability to call<br>
- * {@link RenderSession#insertChild(Object, ILayoutPullParser, int, IAnimationListener)}<br>
- * {@link RenderSession#moveChild(Object, Object, int, java.util.Map, IAnimationListener)}<br>
- * {@link RenderSession#setProperty(Object, String, String)}<br>
- * The method that receives an animation listener can only use it if the
- * ANIMATED_VIEW_MANIPULATION, or FULL_ANIMATED_VIEW_MANIPULATION is also supported.
- */
- VIEW_MANIPULATION,
- /** Ability to play animations with<br>
- * {@link RenderSession#animate(Object, String, boolean, IAnimationListener)}
- */
- PLAY_ANIMATION,
- /**
- * Ability to manipulate views with animation, as long as the view does not change parent.
- * {@link RenderSession#insertChild(Object, ILayoutPullParser, int, IAnimationListener)}<br>
- * {@link RenderSession#moveChild(Object, Object, int, java.util.Map, IAnimationListener)}<br>
- * {@link RenderSession#removeChild(Object, IAnimationListener)}<br>
- */
- ANIMATED_VIEW_MANIPULATION,
- /**
- * Ability to move views (even into a different ViewGroup) with animation.
- * see {@link RenderSession#moveChild(Object, Object, int, java.util.Map, IAnimationListener)}
- */
- FULL_ANIMATED_VIEW_MANIPULATION,
- ADAPTER_BINDING,
- EXTENDED_VIEWINFO,
- /**
- * Ability to properly resize nine-patch assets.
- */
- FIXED_SCALABLE_NINE_PATCH;
-}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/DataBindingItem.java b/layoutlib_api/src/com/android/ide/common/rendering/api/DataBindingItem.java
deleted file mode 100644
index 2a93f15..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/DataBindingItem.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2011 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.common.rendering.api;
-
-import com.android.resources.ResourceType;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * A data binding item. It contain a {@link ResourceReference} to the view used to represent it.
- * It also contains how many items of this type the AdapterView should display.
- *
- * It can also contain an optional list of children in case the AdapterView is an
- * ExpandableListView. In this case, the count value is used as a repeat count for the children,
- * similar to {@link AdapterBinding#getRepeatCount()}.
- *
- */
-public class DataBindingItem implements Iterable<DataBindingItem> {
- private final ResourceReference mReference;
- private final int mCount;
- private List<DataBindingItem> mChildren;
-
- public DataBindingItem(ResourceReference reference, int count) {
- mReference = reference;
- mCount = count;
- }
-
- public DataBindingItem(String name, boolean platformLayout, int count) {
- this(new ResourceReference(name, platformLayout), count);
- }
-
- public DataBindingItem(String name, boolean platformLayout) {
- this(name, platformLayout, 1);
- }
-
- public DataBindingItem(String name, int count) {
- this(name, false /*platformLayout*/, count);
- }
-
- public DataBindingItem(String name) {
- this(name, false /*platformLayout*/, 1);
- }
-
- /**
- * Returns the {@link ResourceReference} for the view. The {@link ResourceType} for the
- * referenced resource is implied to be {@link ResourceType#LAYOUT}.
- */
- public ResourceReference getViewReference() {
- return mReference;
- }
-
- /**
- * The repeat count for this object or the repeat count for the children if there are any.
- */
- public int getCount() {
- return mCount;
- }
-
- public void addChild(DataBindingItem child) {
- if (mChildren == null) {
- mChildren = new ArrayList<DataBindingItem>();
- }
-
- mChildren.add(child);
- }
-
- public List<DataBindingItem> getChildren() {
- if (mChildren != null) {
- return mChildren;
- }
-
- return Collections.emptyList();
- }
-
- @Override
- public Iterator<DataBindingItem> iterator() {
- List<DataBindingItem> list = getChildren();
- return list.iterator();
- }
-}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/DeclareStyleableResourceValue.java b/layoutlib_api/src/com/android/ide/common/rendering/api/DeclareStyleableResourceValue.java
deleted file mode 100644
index a8f269f..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/DeclareStyleableResourceValue.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2011 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.common.rendering.api;
-
-import com.android.resources.ResourceType;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * A Resource value representing a declare-styleable resource.
- *
- * {@link #getValue()} will return null, instead use {@link #getAttributeValues(String)} to
- * get the enum/flag value associated with an attribute defined in the declare-styleable.
- *
- * @deprecated This class is broken as it does not handle the namespace for each attribute.
- * Thankfully, newer versions of layoutlib don't actually use it, so we just keep it as is for
- * backward compatibility on older layoutlibs.
- *
- */
-@Deprecated
-public class DeclareStyleableResourceValue extends ResourceValue {
-
- private Map<String, AttrResourceValue> mAttrMap;
-
- public DeclareStyleableResourceValue(ResourceType type, String name, boolean isFramework) {
- super(type, name, isFramework);
- }
-
- /**
- * Return the enum/flag integer value for a given attribute.
- * @param name the name of the attribute
- * @return the map of (name, integer) values.
- */
- public Map<String, Integer> getAttributeValues(String name) {
- if (mAttrMap != null) {
- AttrResourceValue attr = mAttrMap.get(name);
- if (attr != null) {
- return attr.getAttributeValues();
- }
- }
-
- return null;
- }
-
- public Map<String, AttrResourceValue> getAllAttributes() {
- return mAttrMap;
- }
-
- public void addValue(AttrResourceValue attr) {
- if (mAttrMap == null) {
- mAttrMap = new HashMap<String, AttrResourceValue>();
- }
-
- mAttrMap.put(attr.getName(), attr);
- }
-}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/DensityBasedResourceValue.java b/layoutlib_api/src/com/android/ide/common/rendering/api/DensityBasedResourceValue.java
deleted file mode 100644
index 5add715..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/DensityBasedResourceValue.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2008 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.common.rendering.api;
-
-import com.android.layoutlib.api.IDensityBasedResourceValue;
-import com.android.resources.ResourceType;
-
-@SuppressWarnings("deprecation")
-public class DensityBasedResourceValue extends ResourceValue implements IDensityBasedResourceValue {
-
- private com.android.resources.Density mDensity;
-
- public DensityBasedResourceValue(ResourceType type, String name, String value,
- com.android.resources.Density density, boolean isFramework) {
- super(type, name, value, isFramework);
- mDensity = density;
- }
-
- /**
- * Returns the density for which this resource is configured.
- * @return the density.
- */
- public com.android.resources.Density getResourceDensity() {
- return mDensity;
- }
-
- /** Legacy method, do not call
- * @deprecated use {@link #getResourceDensity()} instead.
- */
- @Override
- @Deprecated
- public Density getDensity() {
- return Density.getEnum(mDensity.getDpiValue());
- }
-
- @Override
- public String toString() {
- return "DensityBasedResourceValue ["
- + getResourceType() + "/" + getName() + " = " + getValue()
- + " (density:" + mDensity +", framework:" + isFramework() + ")]";
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + ((mDensity == null) ? 0 : mDensity.hashCode());
- return result;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!super.equals(obj))
- return false;
- if (getClass() != obj.getClass())
- return false;
- DensityBasedResourceValue other = (DensityBasedResourceValue) obj;
- if (mDensity == null) {
- if (other.mDensity != null)
- return false;
- } else if (!mDensity.equals(other.mDensity))
- return false;
- return true;
- }
-}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/DrawableParams.java b/layoutlib_api/src/com/android/ide/common/rendering/api/DrawableParams.java
deleted file mode 100644
index b566ad3..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/DrawableParams.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2011 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.common.rendering.api;
-
-
-/**
- * Rendering parameters for {@link Bridge#renderDrawable(DrawableParams)}
- *
- */
-public class DrawableParams extends RenderParams {
-
- private final ResourceValue mDrawable;
-
- /**
- * Builds a param object with all the necessary parameters to render a drawable with
- * {@link Bridge#renderDrawable(DrawableParams)}
- *
- * @param drawable the {@link ResourceValue} identifying the drawable.
- * @param projectKey An Object identifying the project. This is used for the cache mechanism.
- * @param hardwareConfig the {@link HardwareConfig}.
- * @param renderResources a {@link RenderResources} object providing access to the resources.
- * @param projectCallback The {@link IProjectCallback} object to get information from
- * the project.
- * @param minSdkVersion the minSdkVersion of the project
- * @param targetSdkVersion the targetSdkVersion of the project
- * @param log the object responsible for displaying warning/errors to the user.
- */
- public DrawableParams(
- ResourceValue drawable,
- Object projectKey,
- HardwareConfig hardwareConfig,
- RenderResources renderResources,
- IProjectCallback projectCallback,
- int minSdkVersion, int targetSdkVersion,
- LayoutLog log) {
- super(projectKey, hardwareConfig,
- renderResources, projectCallback, minSdkVersion, targetSdkVersion, log);
- mDrawable = drawable;
- }
-
- public DrawableParams(DrawableParams params) {
- super(params);
- mDrawable = params.mDrawable;
- }
-
- public ResourceValue getDrawable() {
- return mDrawable;
- }
-}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/HardwareConfig.java b/layoutlib_api/src/com/android/ide/common/rendering/api/HardwareConfig.java
deleted file mode 100644
index 89f1424..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/HardwareConfig.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2012 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.common.rendering.api;
-
-import com.android.resources.Density;
-import com.android.resources.ScreenOrientation;
-import com.android.resources.ScreenSize;
-
-/**
- * Hardware configuration for the rendering.
- * This is immutable.
- *
- * @since 9
- */
-public class HardwareConfig {
-
- private final int mScreenWidth;
- private final int mScreenHeight;
- private final Density mDensity;
- private final float mXdpi;
- private final float mYdpi;
- private final ScreenOrientation mOrientation;
- private final ScreenSize mScreenSize;
-
- private final boolean mSoftwareButtons;
-
- public HardwareConfig(
- int screenWidth,
- int screenHeight,
- Density density,
- float xdpi,
- float ydpi,
- ScreenSize screenSize,
- ScreenOrientation orientation,
- boolean softwareButtons) {
- mScreenWidth = screenWidth;
- mScreenHeight = screenHeight;
- mDensity = density;
- mXdpi = xdpi;
- mYdpi = ydpi;
- mScreenSize = screenSize;
- mOrientation = orientation;
- mSoftwareButtons = softwareButtons;
- }
-
- public int getScreenWidth() {
- return mScreenWidth;
- }
-
- public int getScreenHeight() {
- return mScreenHeight;
- }
-
- public Density getDensity() {
- return mDensity;
- }
-
- public float getXdpi() {
- return mXdpi;
- }
-
- public float getYdpi() {
- return mYdpi;
- }
-
- public ScreenSize getScreenSize() {
- return mScreenSize;
- }
-
- public ScreenOrientation getOrientation() {
- return mOrientation;
- }
-
- public boolean hasSoftwareButtons() {
- return mSoftwareButtons;
- }
-}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/IAnimationListener.java b/layoutlib_api/src/com/android/ide/common/rendering/api/IAnimationListener.java
deleted file mode 100644
index 81a2320..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/IAnimationListener.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2010 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.common.rendering.api;
-
-
-import java.awt.image.BufferedImage;
-
-public interface IAnimationListener {
- /**
- * Called when a new animation frame is available for display.
- *
- * <p>The {@link RenderSession} object is provided as a convenience. It should be queried
- * for the image through {@link RenderSession#getImage()}.
- *
- * <p>If no {@link IImageFactory} is used, then each new animation frame will be rendered
- * in its own new {@link BufferedImage} object. However if an image factory is used, and it
- * always re-use the same object, then the image is only guaranteed to be valid during
- * this method call. As soon as this method return the image content will be overridden
- * with new drawing.
- *
- */
- void onNewFrame(RenderSession scene);
-
- /**
- * Called when the animation is done playing.
- */
- void done(Result result);
-
- /**
- * Return true to cancel the animation.
- */
- boolean isCanceled();
-
-}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/IImageFactory.java b/layoutlib_api/src/com/android/ide/common/rendering/api/IImageFactory.java
deleted file mode 100644
index 7681243..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/IImageFactory.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2010 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.common.rendering.api;
-
-
-import java.awt.image.BufferedImage;
-
-/**
- * Image Factory Interface.
- *
- * An Image factory's task is to create the {@link BufferedImage} into which the scene will be
- * rendered. The goal is to let the layoutlib caller create an image that's optimized for its use
- * case.
- *
- * If no factory is passed in {@link RenderParams#setImageFactory(IImageFactory)}, then a default
- * {@link BufferedImage} of type {@link BufferedImage#TYPE_INT_ARGB} is created.
- *
- */
-public interface IImageFactory {
-
- /**
- * Creates a buffered image with the given size
- * @param width the width of the image
- * @param height the height of the image
- * @return a new (or reused) BufferedImage of the given size.
- */
- BufferedImage getImage(int width, int height);
-}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/ILayoutPullParser.java b/layoutlib_api/src/com/android/ide/common/rendering/api/ILayoutPullParser.java
deleted file mode 100644
index 9c0e97b..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/ILayoutPullParser.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2008 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.common.rendering.api;
-
-import org.xmlpull.v1.XmlPullParser;
-
-/**
- * Extended version of {@link XmlPullParser} to use with
- * {@link Bridge#createSession(SessionParams)}
- */
-public interface ILayoutPullParser extends XmlPullParser {
-
- /**
- * Returns a cookie for the current XML node.
- * <p/>This cookie will be passed back in the {@link ViewInfo} objects, allowing association
- * of a particular XML node with its result from the layout computation.
- *
- * @see ViewInfo#getCookie()
- */
- Object getViewCookie();
-
- /**
- * Returns a custom parser for the layout of the given name.
- * @param layoutName the name of the layout.
- * @return returns a custom parser or null if no custom parsers are needed.
- *
- * @deprecated use {@link IProjectCallback#getParser(String)} instead
- */
- @Deprecated
- ILayoutPullParser getParser(String layoutName);
-}
-
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/IProjectCallback.java b/layoutlib_api/src/com/android/ide/common/rendering/api/IProjectCallback.java
deleted file mode 100644
index a88b0d3..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/IProjectCallback.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (C) 2008 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.common.rendering.api;
-
-import com.android.resources.ResourceType;
-import com.android.util.Pair;
-
-import java.net.URL;
-
-/**
- * Callback for project information needed by the Layout Library.
- * Classes implementing this interface provide methods giving access to some project data, like
- * resource resolution, namespace information, and instantiation of custom view.
- */
-public interface IProjectCallback {
-
- public enum ViewAttribute {
- TEXT(String.class),
- IS_CHECKED(Boolean.class),
- SRC(URL.class),
- COLOR(Integer.class);
-
- private final Class<?> mClass;
-
- private ViewAttribute(Class<?> theClass) {
- mClass = theClass;
- }
-
- public Class<?> getAttributeClass() {
- return mClass;
- }
- }
-
- /**
- * Loads a custom view with the given constructor signature and arguments.
- * @param name The fully qualified name of the class.
- * @param constructorSignature The signature of the class to use
- * @param constructorArgs The arguments to use on the constructor
- * @return A newly instantiated android.view.View object.
- * @throws ClassNotFoundException
- * @throws Exception
- */
- @SuppressWarnings("unchecked")
- Object loadView(String name, Class[] constructorSignature, Object[] constructorArgs)
- throws ClassNotFoundException, Exception;
-
- /**
- * Returns the namespace of the application.
- * <p/>This lets the Layout Lib load custom attributes for custom views.
- */
- String getNamespace();
-
- /**
- * Resolves the id of a resource Id.
- * <p/>The resource id is the value of a <code>R.&lt;type&gt;.&lt;name&gt;</code>, and
- * this method will return both the type and name of the resource.
- * @param id the Id to resolve.
- * @return a Pair of {@link ResourceType} and resource name, or null if the id
- * does not match any resource.
- */
- @SuppressWarnings("deprecation")
- Pair<ResourceType, String> resolveResourceId(int id);
-
- /**
- * Resolves the id of a resource Id of type int[]
- * <p/>The resource id is the value of a R.styleable.&lt;name&gt;, and this method will
- * return the name of the resource.
- * @param id the Id to resolve.
- * @return the name of the resource or <code>null</code> if not found.
- */
- String resolveResourceId(int[] id);
-
- /**
- * Returns the id of a resource.
- * <p/>The provided type and name must match an existing constant defined as
- * <code>R.&lt;type&gt;.&lt;name&gt;</code>.
- * @param type the type of the resource
- * @param name the name of the resource
- * @return an Integer containing the resource Id, or <code>null</code> if not found.
- */
- Integer getResourceId(ResourceType type, String name);
-
- /**
- * Returns a custom parser for the layout of the given name.
- * @param layoutName the name of the layout.
- * @return returns a custom parser or null if no custom parsers are needed.
- * @deprecated This is replaced by {@link #getParser(ResourceValue)} but older version
- * of the layoutlib (before API7) will still call this method.
- */
- @Deprecated
- ILayoutPullParser getParser(String layoutName);
-
- /**
- * Returns a custom parser for a given layout.
- * @param layoutResource The layout.
- * @return returns a custom parser or null if no custom parsers are needed.
- */
- ILayoutPullParser getParser(ResourceValue layoutResource);
-
- /**
- * Returns the value of an item used by an adapter.
- * @param adapterView The {@link ResourceReference} for the adapter view info.
- * @param adapterCookie the view cookie for this particular view.
- * @param itemRef the {@link ResourceReference} for the layout used by the adapter item.
- * @param fullPosition the position of the item in the full list.
- * @param positionPerType the position of the item if only items of the same type are
- * considered. If there is only one type of items, this is the same as
- * <var>fullPosition</var>.
- * @param fullParentPosition the full position of the item's parent. This is only
- * valid if the adapter view is an ExpandableListView.
- * @param parentPositionPerType the position of the parent's item, only considering items
- * of the same type. This is only valid if the adapter view is an ExpandableListView.
- * If there is only one type of items, this is the same as <var>fullParentPosition</var>.
- * @param viewRef The {@link ResourceReference} for the view we're trying to fill.
- * @param viewAttribute the attribute being queried.
- * @param defaultValue the default value for this attribute. The object class matches the
- * class associated with the {@link ViewAttribute}.
- * @return the item value or null if there's no value.
- *
- * @see ViewAttribute#getAttributeClass()
- */
- Object getAdapterItemValue(ResourceReference adapterView, Object adapterCookie,
- ResourceReference itemRef,
- int fullPosition, int positionPerType,
- int fullParentPosition, int parentPositionPerType,
- ResourceReference viewRef, ViewAttribute viewAttribute, Object defaultValue);
-
- /**
- * Returns an adapter binding for a given adapter view.
- * This is only called if {@link SessionParams} does not have an {@link AdapterBinding} for
- * the given {@link ResourceReference} already.
- *
- * @param adapterViewRef the reference of adapter view to return the adapter binding for.
- * @param adapterCookie the view cookie for this particular view.
- * @param viewObject the view object for the adapter.
- * @return an adapter binding for the given view or null if there's no data.
- */
- AdapterBinding getAdapterBinding(ResourceReference adapterViewRef, Object adapterCookie,
- Object viewObject);
-}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/LayoutLog.java b/layoutlib_api/src/com/android/ide/common/rendering/api/LayoutLog.java
deleted file mode 100644
index df29537..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/LayoutLog.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2010 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.common.rendering.api;
-
-/**
- * Log class for actions executed through {@link Bridge} and {@link RenderSession}.
- */
-public class LayoutLog {
- /**
- * Prefix for resource warnings/errors. This is not meant to be used as-is by the Layout
- * Library, but is there to help test against a wider type of warning/error.
- * <p/>
- * {@code tag.startsWith(LayoutLog.TAG_RESOURCE_PREFIX} will test if the tag is any type
- * of resource warning/error
- */
- public final static String TAG_RESOURCES_PREFIX = "resources.";
-
- /**
- * Prefix for matrix warnings/errors. This is not meant to be used as-is by the Layout
- * Library, but is there to help test against a wider type of warning/error.
- * <p/>
- * {@code tag.startsWith(LayoutLog.TAG_MATRIX_PREFIX} will test if the tag is any type
- * of matrix warning/error
- */
- public final static String TAG_MATRIX_PREFIX = "matrix.";
-
- /**
- * Tag for unsupported feature that can have a big impact on the rendering. For instance, aild
- * access.
- */
- public final static String TAG_UNSUPPORTED = "unsupported";
-
- /**
- * Tag for error when something really unexpected happens.
- */
- public final static String TAG_BROKEN = "broken";
-
- /**
- * Tag for resource resolution failure.
- * In this case the warning/error data object will be a ResourceValue containing the type
- * and name of the resource that failed to resolve
- */
- public final static String TAG_RESOURCES_RESOLVE = TAG_RESOURCES_PREFIX + "resolve";
-
- /**
- * Tag for resource resolution failure, specifically for theme attributes.
- * In this case the warning/error data object will be a ResourceValue containing the type
- * and name of the resource that failed to resolve
- */
- public final static String TAG_RESOURCES_RESOLVE_THEME_ATTR = TAG_RESOURCES_RESOLVE + ".theme";
-
- /**
- * Tag for failure when reading the content of a resource file.
- */
- public final static String TAG_RESOURCES_READ = TAG_RESOURCES_PREFIX + "read";
-
- /**
- * Tag for wrong format in a resource value.
- */
- public final static String TAG_RESOURCES_FORMAT = TAG_RESOURCES_PREFIX + "format";
-
- /**
- * Fidelity Tag used when a non affine transformation matrix is used in a Java API.
- */
- public final static String TAG_MATRIX_AFFINE = TAG_MATRIX_PREFIX + "affine";
-
- /**
- * Tag used when a matrix cannot be inverted.
- */
- public final static String TAG_MATRIX_INVERSE = TAG_MATRIX_PREFIX + "inverse";
-
- /**
- * Fidelity Tag used when a mask filter type is used but is not supported.
- */
- public final static String TAG_MASKFILTER = "maskfilter";
-
- /**
- * Fidelity Tag used when a draw filter type is used but is not supported.
- */
- public final static String TAG_DRAWFILTER = "drawfilter";
-
- /**
- * Fidelity Tag used when a path effect type is used but is not supported.
- */
- public final static String TAG_PATHEFFECT = "patheffect";
-
- /**
- * Fidelity Tag used when a color filter type is used but is not supported.
- */
- public final static String TAG_COLORFILTER = "colorfilter";
-
- /**
- * Fidelity Tag used when a rasterize type is used but is not supported.
- */
- public final static String TAG_RASTERIZER = "rasterizer";
-
- /**
- * Fidelity Tag used when a shader type is used but is not supported.
- */
- public final static String TAG_SHADER = "shader";
-
- /**
- * Fidelity Tag used when a xfermode type is used but is not supported.
- */
- public final static String TAG_XFERMODE = "xfermode";
-
- /**
- * Logs a warning.
- * @param tag a tag describing the type of the warning
- * @param message the message of the warning
- * @param data an optional data bundle that the client can use to improve the warning display.
- */
- public void warning(String tag, String message, Object data) {
- }
-
- /**
- * Logs a fidelity warning.
- *
- * This type of warning indicates that the render will not be
- * the same as the rendering on a device due to limitation of the Java rendering API.
- *
- * @param tag a tag describing the type of the warning
- * @param message the message of the warning
- * @param throwable an optional Throwable that triggered the warning
- * @param data an optional data bundle that the client can use to improve the warning display.
- */
- public void fidelityWarning(String tag, String message, Throwable throwable, Object data) {
- }
-
- /**
- * Logs an error.
- *
- * @param tag a tag describing the type of the error
- * @param message the message of the error
- * @param data an optional data bundle that the client can use to improve the error display.
- */
- public void error(String tag, String message, Object data) {
- }
-
- /**
- * Logs an error, and the {@link Throwable} that triggered it.
- *
- * @param tag a tag describing the type of the error
- * @param message the message of the error
- * @param throwable the Throwable that triggered the error
- * @param data an optional data bundle that the client can use to improve the error display.
- */
- public void error(String tag, String message, Throwable throwable, Object data) {
- }
-}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/MergeCookie.java b/layoutlib_api/src/com/android/ide/common/rendering/api/MergeCookie.java
deleted file mode 100644
index ce5d21d..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/MergeCookie.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2011 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.common.rendering.api;
-
-/**
- * Special wrapper class used in special case for {@link ILayoutPullParser#getViewCookie()}.
- * <p/>
- * When an {@code include} tag points to a layout with a {@code merge} top level item, there is no
- * top level item that can use the {@code include} item as cookie.
- * <p/>
- * This class is used as a cookie for all items under the {@code merge} (while referencing the
- * original {@code include} cookie) to make it easy on the client to group all merged items
- * into a single outline item.
- *
- */
-public final class MergeCookie {
-
- private final Object mCookie;
-
- public MergeCookie(Object cookie) {
- mCookie = cookie;
-
- }
-
- public Object getCookie() {
- return mCookie;
- }
-}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/RenderParams.java b/layoutlib_api/src/com/android/ide/common/rendering/api/RenderParams.java
deleted file mode 100644
index 2e53f14..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/RenderParams.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Copyright (C) 2010 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.common.rendering.api;
-
-import com.android.resources.Density;
-import com.android.resources.ScreenSize;
-
-/**
- * Base class for rendering parameters. This include the generic parameters but not what needs
- * to be rendered or additional parameters.
- *
- */
-public abstract class RenderParams {
-
- public final static long DEFAULT_TIMEOUT = 250; //ms
-
- private final Object mProjectKey;
- private final HardwareConfig mHardwareConfig;
- private final RenderResources mRenderResources;
- private final IProjectCallback mProjectCallback;
- private final int mMinSdkVersion;
- private final int mTargetSdkVersion;
- private final LayoutLog mLog;
-
- private boolean mCustomBackgroundEnabled;
- private int mCustomBackgroundColor;
- private long mTimeout;
-
- private IImageFactory mImageFactory = null;
-
- private String mAppIcon = null;
- private String mAppLabel = null;
- private String mLocale = null;
- private boolean mForceNoDecor;
-
- /**
- *
- * @param projectKey An Object identifying the project. This is used for the cache mechanism.
- * @param hardwareConfig the {@link HardwareConfig}.
- * @param renderResources a {@link RenderResources} object providing access to the resources.
- * @param projectCallback The {@link IProjectCallback} object to get information from
- * the project.
- * @param minSdkVersion the minSdkVersion of the project
- * @param targetSdkVersion the targetSdkVersion of the project
- * @param log the object responsible for displaying warning/errors to the user.
- */
- public RenderParams(
- Object projectKey,
- HardwareConfig hardwareConfig,
- RenderResources renderResources,
- IProjectCallback projectCallback,
- int minSdkVersion, int targetSdkVersion,
- LayoutLog log) {
- mProjectKey = projectKey;
- mHardwareConfig = hardwareConfig;
- mRenderResources = renderResources;
- mProjectCallback = projectCallback;
- mMinSdkVersion = minSdkVersion;
- mTargetSdkVersion = targetSdkVersion;
- mLog = log;
- mCustomBackgroundEnabled = false;
- mTimeout = DEFAULT_TIMEOUT;
- }
-
- /**
- * Copy constructor.
- */
- public RenderParams(RenderParams params) {
- mProjectKey = params.mProjectKey;
- mHardwareConfig = params.mHardwareConfig;
- mRenderResources = params.mRenderResources;
- mProjectCallback = params.mProjectCallback;
- mMinSdkVersion = params.mMinSdkVersion;
- mTargetSdkVersion = params.mTargetSdkVersion;
- mLog = params.mLog;
- mCustomBackgroundEnabled = params.mCustomBackgroundEnabled;
- mCustomBackgroundColor = params.mCustomBackgroundColor;
- mTimeout = params.mTimeout;
- mImageFactory = params.mImageFactory;
- mAppIcon = params.mAppIcon;
- mAppLabel = params.mAppLabel;
- mLocale = params.mLocale;
- mForceNoDecor = params.mForceNoDecor;
- }
-
- public void setOverrideBgColor(int color) {
- mCustomBackgroundEnabled = true;
- mCustomBackgroundColor = color;
- }
-
- public void setTimeout(long timeout) {
- mTimeout = timeout;
- }
-
- public void setImageFactory(IImageFactory imageFactory) {
- mImageFactory = imageFactory;
- }
-
- public void setAppIcon(String appIcon) {
- mAppIcon = appIcon;
- }
-
- public void setAppLabel(String appLabel) {
- mAppLabel = appLabel;
- }
-
- public void setLocale(String locale) {
- mLocale = locale;
- }
-
- public void setForceNoDecor() {
- mForceNoDecor = true;
- }
-
- public Object getProjectKey() {
- return mProjectKey;
- }
-
- public HardwareConfig getHardwareConfig() {
- return mHardwareConfig;
- }
-
- public int getMinSdkVersion() {
- return mMinSdkVersion;
- }
-
- public int getTargetSdkVersion() {
- return mTargetSdkVersion;
- }
-
- /**
- * @deprecated Use {@link #getHardwareConfig()}
- */
- @Deprecated
- public int getScreenWidth() {
- return mHardwareConfig.getScreenWidth();
- }
-
- /**
- * @deprecated Use {@link #getHardwareConfig()}
- */
- @Deprecated
- public int getScreenHeight() {
- return mHardwareConfig.getScreenHeight();
- }
-
- /**
- * @deprecated Use {@link #getHardwareConfig()}
- */
- @Deprecated
- public Density getDensity() {
- return mHardwareConfig.getDensity();
- }
-
- /**
- * @deprecated Use {@link #getHardwareConfig()}
- */
- @Deprecated
- public float getXdpi() {
- return mHardwareConfig.getXdpi();
- }
-
- /**
- * @deprecated Use {@link #getHardwareConfig()}
- */
- @Deprecated
- public float getYdpi() {
- return mHardwareConfig.getYdpi();
- }
-
- public RenderResources getResources() {
- return mRenderResources;
- }
-
- public IProjectCallback getProjectCallback() {
- return mProjectCallback;
- }
-
- public LayoutLog getLog() {
- return mLog;
- }
-
- public boolean isBgColorOverridden() {
- return mCustomBackgroundEnabled;
- }
-
- public int getOverrideBgColor() {
- return mCustomBackgroundColor;
- }
-
- public long getTimeout() {
- return mTimeout;
- }
-
- public IImageFactory getImageFactory() {
- return mImageFactory;
- }
-
- /**
- * @deprecated Use {@link #getHardwareConfig()}
- */
- @Deprecated
- public ScreenSize getConfigScreenSize() {
- return mHardwareConfig.getScreenSize();
- }
-
- public String getAppIcon() {
- return mAppIcon;
- }
-
- public String getAppLabel() {
- return mAppLabel;
- }
-
- public String getLocale() {
- return mLocale;
- }
-
- public boolean isForceNoDecor() {
- return mForceNoDecor;
- }
-}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/RenderResources.java b/layoutlib_api/src/com/android/ide/common/rendering/api/RenderResources.java
deleted file mode 100644
index c362224..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/RenderResources.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright (C) 2011 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.common.rendering.api;
-
-import com.android.resources.ResourceType;
-
-/**
- * A class containing all the resources needed to do a rendering.
- * <p/>
- * This contains both the project specific resources and the framework resources, and provide
- * convenience methods to resolve resource and theme references.
- */
-public class RenderResources {
-
- public final static String REFERENCE_NULL = "@null";
-
- public static class FrameworkResourceIdProvider {
- public Integer getId(ResourceType resType, String resName) {
- return null;
- }
- }
-
- public void setFrameworkResourceIdProvider(FrameworkResourceIdProvider provider) {
- }
-
- public void setLogger(LayoutLog logger) {
- }
-
- /**
- * Returns the {@link StyleResourceValue} representing the current theme.
- * @return the theme or null if there is no current theme.
- */
- public StyleResourceValue getCurrentTheme() {
- return null;
- }
-
- /**
- * Returns a theme by its name.
- *
- * @param name the name of the theme
- * @param frameworkTheme whether the theme is a framework theme.
- * @return the theme or null if there's no match
- */
- public StyleResourceValue getTheme(String name, boolean frameworkTheme) {
- return null;
- }
-
- /**
- * Returns whether a theme is a parent of a given theme.
- * @param parentTheme the parent theme
- * @param childTheme the child theme.
- * @return true if the parent theme is indeed a parent theme of the child theme.
- */
- public boolean themeIsParentOf(StyleResourceValue parentTheme, StyleResourceValue childTheme) {
- return false;
- }
-
- /**
- * Returns a framework resource by type and name. The returned resource is resolved.
- * @param resourceType the type of the resource
- * @param resourceName the name of the resource
- */
- public ResourceValue getFrameworkResource(ResourceType resourceType, String resourceName) {
- return null;
- }
-
- /**
- * Returns a project resource by type and name. The returned resource is resolved.
- * @param resourceType the type of the resource
- * @param resourceName the name of the resource
- */
- public ResourceValue getProjectResource(ResourceType resourceType, String resourceName) {
- return null;
- }
-
- /**
- * Returns the {@link ResourceValue} matching a given name in the current theme. If the
- * item is not directly available in the theme, the method looks in its parent theme.
- *
- * @param itemName the name of the item to search for.
- * @return the {@link ResourceValue} object or <code>null</code>
- *
- * @deprecated Use {@link #findItemInTheme(String, boolean)}
- */
- @Deprecated
- public ResourceValue findItemInTheme(String itemName) {
- StyleResourceValue currentTheme = getCurrentTheme();
- if (currentTheme != null) {
- return findItemInStyle(currentTheme, itemName);
- }
-
- return null;
- }
-
- /**
- * Returns the {@link ResourceValue} matching a given attribute in the current theme. If the
- * item is not directly available in the theme, the method looks in its parent theme.
- *
- * @param attrName the name of the attribute to search for.
- * @param isFrameworkAttr whether the attribute is a framework attribute
- * @return the {@link ResourceValue} object or <code>null</code>
- */
- public ResourceValue findItemInTheme(String attrName, boolean isFrameworkAttr) {
- StyleResourceValue currentTheme = getCurrentTheme();
- if (currentTheme != null) {
- return findItemInStyle(currentTheme, attrName, isFrameworkAttr);
- }
-
- return null;
- }
-
- /**
- * Returns the {@link ResourceValue} matching a given name in a given style. If the
- * item is not directly available in the style, the method looks in its parent style.
- *
- * This version of doesn't support providing the namespace of the attribute so it'll search
- * in both the project's namespace and then in the android namespace.
- *
- * @param style the style to search in
- * @param attrName the name of the attribute to search for.
- * @return the {@link ResourceValue} object or <code>null</code>
- *
- * @deprecated Use {@link #findItemInStyle(StyleResourceValue, String, boolean)} since this
- * method doesn't know the item namespace.
- */
- @Deprecated
- public ResourceValue findItemInStyle(StyleResourceValue style, String attrName) {
- return null;
- }
-
- /**
- * Returns the {@link ResourceValue} matching a given attribute in a given style. If the
- * item is not directly available in the style, the method looks in its parent style.
- *
- * @param style the style to search in
- * @param attrName the name of the attribute to search for.
- * @param isFrameworkAttr whether the attribute is a framework attribute
- * @return the {@link ResourceValue} object or <code>null</code>
- */
- public ResourceValue findItemInStyle(StyleResourceValue style, String attrName,
- boolean isFrameworkAttr) {
- return null;
- }
-
- /**
- * Searches for, and returns a {@link ResourceValue} by its reference.
- * <p/>
- * The reference format can be:
- * <pre>@resType/resName</pre>
- * <pre>@android:resType/resName</pre>
- * <pre>@resType/android:resName</pre>
- * <pre>?resType/resName</pre>
- * <pre>?android:resType/resName</pre>
- * <pre>?resType/android:resName</pre>
- * Any other string format will return <code>null</code>.
- * <p/>
- * The actual format of a reference is <pre>@[namespace:]resType/resName</pre> but this method
- * only support the android namespace.
- *
- * @param reference the resource reference to search for.
- * @param forceFrameworkOnly if true all references are considered to be toward framework
- * resource even if the reference does not include the android: prefix.
- * @return a {@link ResourceValue} or <code>null</code>.
- */
- public ResourceValue findResValue(String reference, boolean forceFrameworkOnly) {
- return null;
- }
-
- /**
- * Resolves the value of a resource, if the value references a theme or resource value.
- * <p/>
- * This method ensures that it returns a {@link ResourceValue} object that does not
- * reference another resource.
- * If the resource cannot be resolved, it returns <code>null</code>.
- * <p/>
- * If a value that does not need to be resolved is given, the method will return a new
- * instance of {@link ResourceValue} that contains the input value.
- *
- * @param type the type of the resource
- * @param name the name of the attribute containing this value.
- * @param value the resource value, or reference to resolve
- * @param isFrameworkValue whether the value is a framework value.
- *
- * @return the resolved resource value or <code>null</code> if it failed to resolve it.
- */
- public ResourceValue resolveValue(ResourceType type, String name, String value,
- boolean isFrameworkValue) {
- return null;
- }
-
- /**
- * Returns the {@link ResourceValue} referenced by the value of <var>value</var>.
- * <p/>
- * This method ensures that it returns a {@link ResourceValue} object that does not
- * reference another resource.
- * If the resource cannot be resolved, it returns <code>null</code>.
- * <p/>
- * If a value that does not need to be resolved is given, the method will return the input
- * value.
- *
- * @param value the value containing the reference to resolve.
- * @return a {@link ResourceValue} object or <code>null</code>
- */
- public ResourceValue resolveResValue(ResourceValue value) {
- return null;
- }
-}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/RenderSession.java b/layoutlib_api/src/com/android/ide/common/rendering/api/RenderSession.java
deleted file mode 100644
index 96caa6a..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/RenderSession.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Copyright (C) 2010 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.common.rendering.api;
-
-import static com.android.ide.common.rendering.api.Result.Status.NOT_IMPLEMENTED;
-
-import com.android.ide.common.rendering.api.Result.Status;
-
-import java.awt.image.BufferedImage;
-import java.util.List;
-import java.util.Map;
-
-/**
- * An object allowing interaction with an Android layout.
- *
- * This is returned by {@link Bridge#createSession(SessionParams)}.
- * and can then be used for subsequent actions on the layout.
- *
- * @since 5
- *
- */
-public class RenderSession {
-
- /**
- * Returns the last operation result.
- */
- public Result getResult() {
- return NOT_IMPLEMENTED.createResult();
- }
-
- /**
- * Returns the {@link ViewInfo} objects for the top level views.
- * <p/>
- * In most case the list will only contain one item. If the top level node is {@code merge}
- * though then it will contain all the items under the {@code merge} tag.
- * <p/>
- * This is reset to a new instance every time {@link #render()} is called and can be
- * <code>null</code> if the call failed (and the method returned a {@link Result} with
- * {@link Status#ERROR_UNKNOWN} or {@link Status#NOT_IMPLEMENTED}.
- * <p/>
- * This can be safely modified by the caller.
- *
- * @return the list of {@link ViewInfo} or null if there aren't any.
- */
- public List<ViewInfo> getRootViews() {
- return null;
- }
-
- /**
- * Returns the rendering of the full layout.
- * <p>
- * This is reset to a new instance every time {@link #render()} is called and can be
- * <code>null</code> if the call failed (and the method returned a {@link Result} with
- * {@link Status#ERROR_UNKNOWN} or {@link Status#NOT_IMPLEMENTED}.
- * <p/>
- * This can be safely modified by the caller.
- */
- public BufferedImage getImage() {
- return null;
- }
-
- /**
- * Returns true if the current image alpha channel is relevant.
- *
- * @return whether the image alpha channel is relevant.
- */
- public boolean isAlphaChannelImage() {
- return true;
- }
-
- /**
- * Returns a map of (XML attribute name, attribute value) containing only default attribute
- * values, for the given view Object.
- * @param viewObject the view object.
- * @return a map of the default property values or null.
- */
- public Map<String, String> getDefaultProperties(Object viewObject) {
- return null;
- }
-
- /**
- * Re-renders the layout as-is.
- * In case of success, this should be followed by calls to {@link #getRootViews()} and
- * {@link #getImage()} to access the result of the rendering.
- *
- * This is equivalent to calling <code>render(SceneParams.DEFAULT_TIMEOUT)</code>
- *
- * @return a {@link Result} indicating the status of the action.
- */
- public Result render() {
- return render(RenderParams.DEFAULT_TIMEOUT);
- }
-
- /**
- * Re-renders the layout as-is, with a given timeout in case other renderings are being done.
- * In case of success, this should be followed by calls to {@link #getRootViews()} and
- * {@link #getImage()} to access the result of the rendering.
- *
- * The {@link Bridge} is only able to inflate or render one layout at a time. There
- * is an internal lock object whenever such an action occurs. The timeout parameter is used
- * when attempting to acquire the lock. If the timeout expires, the method will return
- * {@link Status#ERROR_TIMEOUT}.
- *
- * @param timeout timeout for the rendering, in milliseconds.
- *
- * @return a {@link Result} indicating the status of the action.
- */
- public Result render(long timeout) {
- return NOT_IMPLEMENTED.createResult();
- }
-
- /**
- * Sets the value of a given property on a given object.
- * <p/>
- * This does nothing more than change the property. To render the scene in its new state, a
- * call to {@link #render()} is required.
- * <p/>
- * Any amount of actions can be taken on the scene before {@link #render()} is called.
- *
- * @param objectView
- * @param propertyName
- * @param propertyValue
- *
- * @return a {@link Result} indicating the status of the action.
- *
- * @throws IllegalArgumentException if the view object is not an android.view.View
- */
- public Result setProperty(Object objectView, String propertyName, String propertyValue) {
- return NOT_IMPLEMENTED.createResult();
- }
-
- /**
- * returns the value of a given property on a given object.
- * <p/>
- * This returns a {@link Result} object. If the operation of querying the object for its
- * property was successful (check {@link Result#isSuccess()}), then the property value
- * is set in the result and can be accessed through {@link Result#getData()}.
- *
- * @param objectView
- * @param propertyName
- *
- * @return a {@link Result} indicating the status of the action.
- *
- * @throws IllegalArgumentException if the view object is not an android.view.View
- */
- public Result getProperty(Object objectView, String propertyName) {
- return NOT_IMPLEMENTED.createResult();
- }
-
- /**
- * Inserts a new child in a ViewGroup object, and renders the result.
- * <p/>
- * The child is first inflated and then added to its new parent, at the given <var>index<var>
- * position. If the <var>index</var> is -1 then the child is added at the end of the parent.
- * <p/>
- * If an animation listener is passed then the rendering is done asynchronously and the
- * result is sent to the listener.
- * If the listener is null, then the rendering is done synchronously.
- * <p/>
- * The child stays in the view hierarchy after the rendering is done. To remove it call
- * {@link #removeChild(Object, IAnimationListener)}
- * <p/>
- * The returned {@link Result} object will contain the android.view.View object for
- * the newly inflated child. It is accessible through {@link Result#getData()}.
- *
- * @param parentView the parent View object to receive the new child.
- * @param childXml an {@link ILayoutPullParser} containing the content of the new child,
- * including ViewGroup.LayoutParams attributes.
- * @param index the index at which position to add the new child into the parent. -1 means at
- * the end.
- * @param listener an optional {@link IAnimationListener}.
- *
- * @return a {@link Result} indicating the status of the action.
- */
- public Result insertChild(Object parentView, ILayoutPullParser childXml, int index,
- IAnimationListener listener) {
- return NOT_IMPLEMENTED.createResult();
- }
-
- /**
- * Move a new child to a different ViewGroup object.
- * <p/>
- * The child is first removed from its current parent, and then added to its new parent, at the
- * given <var>index<var> position. In case the <var>parentView</var> is the current parent of
- * <var>childView</var> then the index must be the value with the <var>childView</var> removed
- * from its parent. If the <var>index</var> is -1 then the child is added at the end of
- * the parent.
- * <p/>
- * If an animation listener is passed then the rendering is done asynchronously and the
- * result is sent to the listener.
- * If the listener is null, then the rendering is done synchronously.
- * <p/>
- * The child stays in the view hierarchy after the rendering is done. To remove it call
- * {@link #removeChild(Object, IAnimationListener)}
- * <p/>
- * The returned {@link Result} object will contain the android.view.ViewGroup.LayoutParams
- * object created from the <var>layoutParams</var> map if it was non <code>null</code>.
- *
- * @param parentView the parent View object to receive the child. Can be the current parent
- * already.
- * @param childView the view to move.
- * @param index the index at which position to add the new child into the parent. -1 means at
- * the end.
- * @param layoutParams an optional map of new ViewGroup.LayoutParams attribute. If non null,
- * then the current layout params of the view will be removed and a new one will
- * be inflated and set with the content of the map.
- * @param listener an optional {@link IAnimationListener}.
- *
- * @return a {@link Result} indicating the status of the action.
- */
- public Result moveChild(Object parentView, Object childView, int index,
- Map<String, String> layoutParams, IAnimationListener listener) {
- return NOT_IMPLEMENTED.createResult();
- }
-
- /**
- * Removes a child from a ViewGroup object.
- * <p/>
- * This does nothing more than change the layout. To render the scene in its new state, a
- * call to {@link #render()} is required.
- * <p/>
- * Any amount of actions can be taken on the scene before {@link #render()} is called.
- *
- * @param childView the view object to remove from its parent
- * @param listener an optional {@link IAnimationListener}.
- *
- * @return a {@link Result} indicating the status of the action.
- */
- public Result removeChild(Object childView, IAnimationListener listener) {
- return NOT_IMPLEMENTED.createResult();
- }
-
- /**
- * Starts playing an given animation on a given object.
- * <p/>
- * The animation playback is asynchronous and the rendered frame is sent vi the
- * <var>listener</var>.
- *
- * @param targetObject the view object to animate
- * @param animationName the name of the animation (res/anim) to play.
- * @param listener the listener callback.
- *
- * @return a {@link Result} indicating the status of the action.
- */
- public Result animate(Object targetObject, String animationName,
- boolean isFrameworkAnimation, IAnimationListener listener) {
- return NOT_IMPLEMENTED.createResult();
- }
-
- /**
- * Discards the layout. No more actions can be called on this object.
- */
- public void dispose() {
- }
-}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/ResourceReference.java b/layoutlib_api/src/com/android/ide/common/rendering/api/ResourceReference.java
deleted file mode 100644
index f22f51e..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/ResourceReference.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2011 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.common.rendering.api;
-
-/**
- * A resource reference. This contains the String ID of the resource and whether this is a framework
- * reference.
- * This is an immutable class.
- *
- */
-public class ResourceReference {
- private final String mName;
- private final boolean mIsFramework;
-
- /**
- * Builds a resource reference.
- * @param name the name of the resource
- * @param isFramework whether the reference is to a framework resource.
- */
- public ResourceReference(String name, boolean isFramework) {
- mName = name;
- mIsFramework = isFramework;
- }
-
- /**
- * Builds a non-framework resource reference.
- * @param name the name of the resource
- */
- public ResourceReference(String name) {
- this(name, false /*platformLayout*/);
- }
-
- /**
- * Returns the name of the resource, as defined in the XML.
- */
- public final String getName() {
- return mName;
- }
-
- /**
- * Returns whether the resource is a framework resource (<code>true</code>) or a project
- * resource (<code>false</false>).
- */
- public final boolean isFramework() {
- return mIsFramework;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + (mIsFramework ? 1231 : 1237);
- result = prime * result + ((mName == null) ? 0 : mName.hashCode());
- return result;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- ResourceReference other = (ResourceReference) obj;
- if (mIsFramework != other.mIsFramework)
- return false;
- if (mName == null) {
- if (other.mName != null)
- return false;
- } else if (!mName.equals(other.mName))
- return false;
- return true;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "ResourceReference [" + mName + " (framework:" + mIsFramework+ ")]";
- }
-}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/ResourceValue.java b/layoutlib_api/src/com/android/ide/common/rendering/api/ResourceValue.java
deleted file mode 100644
index dceb7c5..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/ResourceValue.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2008 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.common.rendering.api;
-
-import com.android.layoutlib.api.IResourceValue;
-import com.android.resources.ResourceType;
-
-/**
- * Represents an android resource with a name and a string value.
- */
-@SuppressWarnings("deprecation")
-public class ResourceValue extends ResourceReference implements IResourceValue {
- private final ResourceType mType;
- private String mValue = null;
-
- public ResourceValue(ResourceType type, String name, boolean isFramework) {
- super(name, isFramework);
- mType = type;
- }
-
- public ResourceValue(ResourceType type, String name, String value, boolean isFramework) {
- super(name, isFramework);
- mType = type;
- mValue = value;
- }
-
- public ResourceType getResourceType() {
- return mType;
- }
-
- /**
- * Returns the type of the resource. For instance "drawable", "color", etc...
- * @deprecated use {@link #getResourceType()} instead.
- */
- @Override
- @Deprecated
- public String getType() {
- return mType.getName();
- }
-
- /**
- * Returns the value of the resource, as defined in the XML. This can be <code>null</code>
- */
- @Override
- public final String getValue() {
- return mValue;
- }
-
- /**
- * Sets the value of the resource.
- * @param value the new value
- */
- public void setValue(String value) {
- mValue = value;
- }
-
- /**
- * Sets the value from another resource.
- * @param value the resource value
- */
- public void replaceWith(ResourceValue value) {
- mValue = value.mValue;
- }
-
- @Override
- public String toString() {
- return "ResourceValue [" + mType + "/" + getName() + " = " + mValue //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + " (framework:" + isFramework() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + ((mType == null) ? 0 : mType.hashCode());
- result = prime * result + ((mValue == null) ? 0 : mValue.hashCode());
- return result;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!super.equals(obj))
- return false;
- if (getClass() != obj.getClass())
- return false;
- ResourceValue other = (ResourceValue) obj;
- if (mType == null) {
- if (other.mType != null)
- return false;
- } else if (!mType.equals(other.mType))
- return false;
- if (mValue == null) {
- if (other.mValue != null)
- return false;
- } else if (!mValue.equals(other.mValue))
- return false;
- return true;
- }
-}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/Result.java b/layoutlib_api/src/com/android/ide/common/rendering/api/Result.java
deleted file mode 100644
index a739e79..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/Result.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright (C) 2010 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.common.rendering.api;
-
-/**
- * Scene result class. This is an immutable class.
- * <p/>
- * This cannot be allocated directly, instead use
- * {@link Status#createResult()},
- * {@link Status#createResult(String, Throwable)},
- * {@link Status#createResult(String)}
- * {@link Status#createResult(Object)}
- */
-public class Result {
-
- private final Status mStatus;
- private final String mErrorMessage;
- private final Throwable mThrowable;
- private Object mData;
-
- /**
- * Scene Status enum.
- * <p/>This indicates the status of all scene actions.
- */
- public enum Status {
- SUCCESS,
- NOT_IMPLEMENTED,
- ERROR_TIMEOUT,
- ERROR_LOCK_INTERRUPTED,
- ERROR_INFLATION,
- ERROR_VIEWGROUP_NO_CHILDREN,
- ERROR_NOT_INFLATED,
- ERROR_RENDER,
- ERROR_ANIM_NOT_FOUND,
- ERROR_NOT_A_DRAWABLE,
- ERROR_REFLECTION,
- ERROR_UNKNOWN;
-
- private Result mResult;
-
- /**
- * Returns a {@link Result} object with this status.
- * @return an instance of SceneResult;
- */
- public Result createResult() {
- // don't want to get generic error that way.
- assert this != ERROR_UNKNOWN;
-
- if (mResult == null) {
- mResult = new Result(this);
- }
-
- return mResult;
- }
-
- /**
- * Returns a {@link Result} object with this status, and the given data.
- * @return an instance of SceneResult;
- *
- * @see Result#getData()
- */
- public Result createResult(Object data) {
- Result res = createResult();
-
- if (data != null) {
- res = res.getCopyWithData(data);
- }
-
- return res;
- }
-
- /**
- * Returns a {@link #ERROR_UNKNOWN} result with the given message and throwable
- * @param errorMessage the error message
- * @param throwable the throwable
- * @return an instance of SceneResult.
- */
- public Result createResult(String errorMessage, Throwable throwable) {
- return new Result(this, errorMessage, throwable);
- }
-
- /**
- * Returns a {@link #ERROR_UNKNOWN} result with the given message
- * @param errorMessage the error message
- * @return an instance of SceneResult.
- */
- public Result createResult(String errorMessage) {
- return new Result(this, errorMessage, null /*throwable*/);
- }
- }
-
- /**
- * Creates a {@link Result} object with the given SceneStatus.
- *
- * @param status the status. Must not be null.
- */
- private Result(Status status) {
- this(status, null, null);
- }
-
- /**
- * Creates a {@link Result} object with the given SceneStatus, and the given message
- * and {@link Throwable}
- *
- * @param status the status. Must not be null.
- * @param errorMessage an optional error message.
- * @param t an optional exception.
- */
- private Result(Status status, String errorMessage, Throwable t) {
- assert status != null;
- mStatus = status;
- mErrorMessage = errorMessage;
- mThrowable = t;
- }
-
- private Result(Result result) {
- mStatus = result.mStatus;
- mErrorMessage = result.mErrorMessage;
- mThrowable = result.mThrowable;
- }
-
- /**
- * Returns a copy of the current result with the added (or replaced) given data
- * @param data the data bundle
- *
- * @return returns a new SceneResult instance.
- */
- public Result getCopyWithData(Object data) {
- Result r = new Result(this);
- r.mData = data;
- return r;
- }
-
-
- /**
- * Returns whether the status is successful.
- * <p>
- * This is the same as calling <code>getStatus() == SceneStatus.SUCCESS</code>
- * @return <code>true</code> if the status is successful.
- */
- public boolean isSuccess() {
- return mStatus == Status.SUCCESS;
- }
-
- /**
- * Returns the status. This is never null.
- */
- public Status getStatus() {
- return mStatus;
- }
-
- /**
- * Returns the error message. This is only non-null when {@link #getStatus()} returns
- * {@link Status#ERROR_UNKNOWN}
- */
- public String getErrorMessage() {
- return mErrorMessage;
- }
-
- /**
- * Returns the exception. This is only non-null when {@link #getStatus()} returns
- * {@link Status#ERROR_UNKNOWN}
- */
- public Throwable getException() {
- return mThrowable;
- }
-
- /**
- * Returns the optional data bundle stored in the result object.
- * @return the data bundle or <code>null</code> if none have been set.
- */
- public Object getData() {
- return mData;
- }
-}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/SessionParams.java b/layoutlib_api/src/com/android/ide/common/rendering/api/SessionParams.java
deleted file mode 100644
index 709207e..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/SessionParams.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2011 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.common.rendering.api;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Rendering parameters for a {@link RenderSession}.
- */
-public class SessionParams extends RenderParams {
-
- public static enum RenderingMode {
- NORMAL(false, false),
- V_SCROLL(false, true),
- H_SCROLL(true, false),
- FULL_EXPAND(true, true);
-
- private final boolean mHorizExpand;
- private final boolean mVertExpand;
-
- private RenderingMode(boolean horizExpand, boolean vertExpand) {
- mHorizExpand = horizExpand;
- mVertExpand = vertExpand;
- }
-
- public boolean isHorizExpand() {
- return mHorizExpand;
- }
-
- public boolean isVertExpand() {
- return mVertExpand;
- }
- }
-
- private final ILayoutPullParser mLayoutDescription;
- private final RenderingMode mRenderingMode;
- private boolean mLayoutOnly = false;
- private Map<ResourceReference, AdapterBinding> mAdapterBindingMap;
- private boolean mExtendedViewInfoMode = false;
-
- /**
- *
- * @param layoutDescription the {@link ILayoutPullParser} letting the LayoutLib Bridge visit the
- * layout file.
- * @param renderingMode The rendering mode.
- * @param projectKey An Object identifying the project. This is used for the cache mechanism.
- * @param hardwareConfig the {@link HardwareConfig}.
- * @param renderResources a {@link RenderResources} object providing access to the resources.
- * @param projectCallback The {@link IProjectCallback} object to get information from
- * the project.
- * @param minSdkVersion the minSdkVersion of the project
- * @param targetSdkVersion the targetSdkVersion of the project
- * @param log the object responsible for displaying warning/errors to the user.
- */
- public SessionParams(
- ILayoutPullParser layoutDescription,
- RenderingMode renderingMode,
- Object projectKey,
- HardwareConfig hardwareConfig,
- RenderResources renderResources,
- IProjectCallback projectCallback,
- int minSdkVersion, int targetSdkVersion,
- LayoutLog log) {
- super(projectKey, hardwareConfig,
- renderResources, projectCallback, minSdkVersion, targetSdkVersion, log);
-
- mLayoutDescription = layoutDescription;
- mRenderingMode = renderingMode;
- }
-
- public SessionParams(SessionParams params) {
- super(params);
- mLayoutDescription = params.mLayoutDescription;
- mRenderingMode = params.mRenderingMode;
- if (params.mAdapterBindingMap != null) {
- mAdapterBindingMap = new HashMap<ResourceReference, AdapterBinding>(
- params.mAdapterBindingMap);
- }
- mExtendedViewInfoMode = params.mExtendedViewInfoMode;
- }
-
- public ILayoutPullParser getLayoutDescription() {
- return mLayoutDescription;
- }
-
- public RenderingMode getRenderingMode() {
- return mRenderingMode;
- }
-
- public void setLayoutOnly() {
- mLayoutOnly = true;
- }
-
- public boolean isLayoutOnly() {
- return mLayoutOnly;
- }
-
- public void addAdapterBinding(ResourceReference reference, AdapterBinding data) {
- if (mAdapterBindingMap == null) {
- mAdapterBindingMap = new HashMap<ResourceReference, AdapterBinding>();
- }
-
- mAdapterBindingMap.put(reference, data);
- }
-
- public Map<ResourceReference, AdapterBinding> getAdapterBindings() {
- if (mAdapterBindingMap == null) {
- return Collections.emptyMap();
- }
-
- return Collections.unmodifiableMap(mAdapterBindingMap);
- }
-
- public void setExtendedViewInfoMode(boolean mode) {
- mExtendedViewInfoMode = mode;
- }
-
- public boolean getExtendedViewInfoMode() {
- return mExtendedViewInfoMode;
- }
-}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/StyleResourceValue.java b/layoutlib_api/src/com/android/ide/common/rendering/api/StyleResourceValue.java
deleted file mode 100644
index 7fdfd6a..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/StyleResourceValue.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2008 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.common.rendering.api;
-
-import com.android.layoutlib.api.IResourceValue;
-import com.android.layoutlib.api.IStyleResourceValue;
-import com.android.resources.ResourceType;
-import com.android.util.Pair;
-
-import java.util.HashMap;
-
-/**
- * Represents an android style resources with a name and a list of children {@link ResourceValue}.
- */
-@SuppressWarnings("deprecation")
-public final class StyleResourceValue extends ResourceValue implements IStyleResourceValue {
-
- private String mParentStyle = null;
- private HashMap<Pair<String, Boolean>, ResourceValue> mItems = new HashMap<Pair<String, Boolean>, ResourceValue>();
-
- public StyleResourceValue(ResourceType type, String name, boolean isFramework) {
- super(type, name, isFramework);
- }
-
- public StyleResourceValue(ResourceType type, String name, String parentStyle,
- boolean isFramework) {
- super(type, name, isFramework);
- mParentStyle = parentStyle;
- }
-
- /**
- * Returns the parent style name or <code>null</code> if unknown.
- */
- @Override
- public String getParentStyle() {
- return mParentStyle;
- }
-
- /**
- * Finds a value in the list by name
- * @param name the name of the resource
- *
- * @deprecated use {@link #findValue(String, boolean)}
- */
- @Deprecated
- public ResourceValue findValue(String name) {
- return mItems.get(Pair.of(name, isFramework()));
- }
-
- /**
- * Finds a value in the list by name
- * @param name the name of the resource
- */
- public ResourceValue findValue(String name, boolean isFrameworkAttr) {
- return mItems.get(Pair.of(name, isFrameworkAttr));
- }
-
- public void addValue(ResourceValue value, boolean isFrameworkAttr) {
- mItems.put(Pair.of(value.getName(), isFrameworkAttr), value);
- }
-
- @Override
- public void replaceWith(ResourceValue value) {
- assert value instanceof StyleResourceValue;
- super.replaceWith(value);
-
- if (value instanceof StyleResourceValue) {
- mItems.clear();
- mItems.putAll(((StyleResourceValue)value).mItems);
- }
- }
-
- /**
- * Legacy method.
- * @deprecated use {@link #getValue()}
- */
- @Override
- @Deprecated
- public IResourceValue findItem(String name) {
- return mItems.get(name);
- }
-}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/ViewInfo.java b/layoutlib_api/src/com/android/ide/common/rendering/api/ViewInfo.java
deleted file mode 100644
index d859e95..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/ViewInfo.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright (C) 2010 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.common.rendering.api;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Layout information for a specific view object
- */
-public class ViewInfo {
-
- private final Object mCookie;
- private final String mName;
- private final int mLeft;
- private final int mRight;
- private final int mTop;
- private final int mBottom;
- private List<ViewInfo> mChildren = Collections.emptyList();
- private final Object mViewObject;
- private final Object mLayoutParamsObject;
-
- // optional info
- private int mBaseLine = Integer.MIN_VALUE;
- private int mLeftMargin = Integer.MIN_VALUE;
- private int mTopMargin = Integer.MIN_VALUE;
- private int mRightMargin = Integer.MIN_VALUE;
- private int mBottomMargin = Integer.MIN_VALUE;
-
- public ViewInfo(String name, Object cookie, int left, int top, int right, int bottom) {
- this(name, cookie, left, top, right, bottom, null /*viewObject*/,
- null /*layoutParamsObject*/);
- }
-
- public ViewInfo(String name, Object cookie, int left, int top, int right, int bottom,
- Object viewObject, Object layoutParamsObject) {
- mName = name;
- mCookie = cookie;
- mLeft = left;
- mRight = right;
- mTop = top;
- mBottom = bottom;
- mViewObject = viewObject;
- mLayoutParamsObject = layoutParamsObject;
- }
-
- /**
- * Sets the list of children {@link ViewInfo}.
- */
- public void setChildren(List<ViewInfo> children) {
- if (children != null) {
- mChildren = Collections.unmodifiableList(children);
- } else {
- mChildren = Collections.emptyList();
- }
- }
-
- public void setExtendedInfo(int baseLine, int leftMargin, int topMargin,
- int rightMargin, int bottomMargin) {
- mBaseLine = baseLine;
- mLeftMargin = leftMargin;
- mTopMargin = topMargin;
- mRightMargin = rightMargin;
- mBottomMargin = bottomMargin;
- }
-
- /**
- * Returns the list of children views. This is never null, but can be empty.
- */
- public List<ViewInfo> getChildren() {
- return mChildren;
- }
-
- /**
- * Returns the cookie associated with the XML node. Can be null.
- *
- * @see ILayoutPullParser#getViewCookie()
- */
- public Object getCookie() {
- return mCookie;
- }
-
- /**
- * Returns the class name of the view object. Can be null.
- */
- public String getClassName() {
- return mName;
- }
-
- /**
- * Returns the left of the view bounds, relative to the view parent bounds.
- */
- public int getLeft() {
- return mLeft;
- }
-
- /**
- * Returns the top of the view bounds, relative to the view parent bounds.
- */
- public int getTop() {
- return mTop;
- }
-
- /**
- * Returns the right of the view bounds, relative to the view parent bounds.
- */
- public int getRight() {
- return mRight;
- }
-
- /**
- * Returns the bottom of the view bounds, relative to the view parent bounds.
- */
- public int getBottom() {
- return mBottom;
- }
-
- /**
- * Returns the actual android.view.View (or child class) object. This can be used
- * to query the object properties that are not in the XML and not available through
- * {@link RenderSession#getProperty(Object, String)}.
- */
- public Object getViewObject() {
- return mViewObject;
- }
-
- /**
- * Returns the actual android.view.ViewGroup$LayoutParams (or child class) object.
- * This can be used to query the object properties that are not in the XML and not available
- * through {@link RenderSession#getProperty(Object, String)}.
- */
- public Object getLayoutParamsObject() {
- return mLayoutParamsObject;
- }
-
- /**
- * Returns the baseline value. If the value is unknown, returns {@link Integer#MIN_VALUE}.
- */
- public int getBaseLine() {
- return mBaseLine;
- }
-
- /**
- * Returns the left margin value. If the value is unknown, returns {@link Integer#MIN_VALUE}.
- */
- public int getLeftMargin() {
- return mLeftMargin;
- }
-
- /**
- * Returns the top margin value. If the value is unknown, returns {@link Integer#MIN_VALUE}.
- */
- public int getTopMargin() {
- return mTopMargin;
- }
-
- /**
- * Returns the right margin value. If the value is unknown, returns {@link Integer#MIN_VALUE}.
- */
- public int getRightMargin() {
- return mRightMargin;
- }
-
- /**
- * Returns the bottom margin value. If the value is unknown, returns {@link Integer#MIN_VALUE}.
- */
- public int getBottomMargin() {
- return mBottomMargin;
- }
-}