diff options
author | Raphael Moll <ralf@android.com> | 2013-02-05 11:01:35 -0800 |
---|---|---|
committer | Raphael Moll <ralf@android.com> | 2013-02-06 19:56:02 -0800 |
commit | 3cf16960a67f0c8178e7bc81988fb1436e775e91 (patch) | |
tree | caad2fa1366fc15d09c679476ae9caf5ed9a6596 /layoutlib_api/src | |
parent | b15ea7875a9a4101d4be7e547950b7d2b64c1464 (diff) | |
download | sdk-3cf16960a67f0c8178e7bc81988fb1436e775e91.zip sdk-3cf16960a67f0c8178e7bc81988fb1436e775e91.tar.gz sdk-3cf16960a67f0c8178e7bc81988fb1436e775e91.tar.bz2 |
Remove source of prebuilts.
Sources are now located in tools/base.git.
Change-Id: I9cbe1deb98f8c43e90f5fb04b668f664b9850620
Diffstat (limited to 'layoutlib_api/src')
54 files changed, 0 insertions, 5428 deletions
diff --git a/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/AdapterBinding.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/AdapterBinding.java deleted file mode 100644 index ddcdbd5..0000000 --- a/layoutlib_api/src/main/java/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/main/java/com/android/ide/common/rendering/api/AttrResourceValue.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/AttrResourceValue.java deleted file mode 100644 index 530e3d5..0000000 --- a/layoutlib_api/src/main/java/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/main/java/com/android/ide/common/rendering/api/Bridge.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/Bridge.java deleted file mode 100644 index a19b8d5..0000000 --- a/layoutlib_api/src/main/java/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/main/java/com/android/ide/common/rendering/api/Capability.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/Capability.java deleted file mode 100644 index 5ad438d..0000000 --- a/layoutlib_api/src/main/java/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/main/java/com/android/ide/common/rendering/api/DataBindingItem.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/DataBindingItem.java deleted file mode 100644 index 2a93f15..0000000 --- a/layoutlib_api/src/main/java/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/main/java/com/android/ide/common/rendering/api/DeclareStyleableResourceValue.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/DeclareStyleableResourceValue.java deleted file mode 100644 index a8f269f..0000000 --- a/layoutlib_api/src/main/java/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/main/java/com/android/ide/common/rendering/api/DensityBasedResourceValue.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/DensityBasedResourceValue.java deleted file mode 100644 index 5add715..0000000 --- a/layoutlib_api/src/main/java/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/main/java/com/android/ide/common/rendering/api/DrawableParams.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/DrawableParams.java deleted file mode 100644 index b566ad3..0000000 --- a/layoutlib_api/src/main/java/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/main/java/com/android/ide/common/rendering/api/HardwareConfig.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/HardwareConfig.java deleted file mode 100644 index 89f1424..0000000 --- a/layoutlib_api/src/main/java/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/main/java/com/android/ide/common/rendering/api/IAnimationListener.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/IAnimationListener.java deleted file mode 100644 index 81a2320..0000000 --- a/layoutlib_api/src/main/java/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/main/java/com/android/ide/common/rendering/api/IImageFactory.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/IImageFactory.java deleted file mode 100644 index 7681243..0000000 --- a/layoutlib_api/src/main/java/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/main/java/com/android/ide/common/rendering/api/ILayoutPullParser.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/ILayoutPullParser.java deleted file mode 100644 index 9c0e97b..0000000 --- a/layoutlib_api/src/main/java/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/main/java/com/android/ide/common/rendering/api/IProjectCallback.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/IProjectCallback.java deleted file mode 100644 index a88b0d3..0000000 --- a/layoutlib_api/src/main/java/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.<type>.<name></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.<name>, 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.<type>.<name></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/main/java/com/android/ide/common/rendering/api/LayoutLog.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/LayoutLog.java deleted file mode 100644 index df29537..0000000 --- a/layoutlib_api/src/main/java/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/main/java/com/android/ide/common/rendering/api/MergeCookie.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/MergeCookie.java deleted file mode 100644 index ce5d21d..0000000 --- a/layoutlib_api/src/main/java/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/main/java/com/android/ide/common/rendering/api/RenderParams.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/RenderParams.java deleted file mode 100644 index 2e53f14..0000000 --- a/layoutlib_api/src/main/java/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/main/java/com/android/ide/common/rendering/api/RenderResources.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/RenderResources.java deleted file mode 100644 index c362224..0000000 --- a/layoutlib_api/src/main/java/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/main/java/com/android/ide/common/rendering/api/RenderSession.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/RenderSession.java deleted file mode 100644 index 96caa6a..0000000 --- a/layoutlib_api/src/main/java/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/main/java/com/android/ide/common/rendering/api/ResourceReference.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/ResourceReference.java deleted file mode 100644 index f22f51e..0000000 --- a/layoutlib_api/src/main/java/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/main/java/com/android/ide/common/rendering/api/ResourceValue.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/ResourceValue.java deleted file mode 100644 index dceb7c5..0000000 --- a/layoutlib_api/src/main/java/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/main/java/com/android/ide/common/rendering/api/Result.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/Result.java deleted file mode 100644 index a739e79..0000000 --- a/layoutlib_api/src/main/java/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/main/java/com/android/ide/common/rendering/api/SessionParams.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/SessionParams.java deleted file mode 100644 index 709207e..0000000 --- a/layoutlib_api/src/main/java/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/main/java/com/android/ide/common/rendering/api/StyleResourceValue.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/StyleResourceValue.java deleted file mode 100644 index 7fdfd6a..0000000 --- a/layoutlib_api/src/main/java/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/main/java/com/android/ide/common/rendering/api/ViewInfo.java b/layoutlib_api/src/main/java/com/android/ide/common/rendering/api/ViewInfo.java deleted file mode 100644 index d859e95..0000000 --- a/layoutlib_api/src/main/java/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; - } -} diff --git a/layoutlib_api/src/main/java/com/android/layoutlib/api/IDensityBasedResourceValue.java b/layoutlib_api/src/main/java/com/android/layoutlib/api/IDensityBasedResourceValue.java deleted file mode 100644 index 25d9bfb..0000000 --- a/layoutlib_api/src/main/java/com/android/layoutlib/api/IDensityBasedResourceValue.java +++ /dev/null @@ -1,73 +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.layoutlib.api; - -import com.android.ide.common.rendering.api.DensityBasedResourceValue; - -/** - * Represents an Android Resources that has a density info attached to it. - * @deprecated use {@link DensityBasedResourceValue}. - */ -@Deprecated -public interface IDensityBasedResourceValue extends IResourceValue { - - /** - * Density. - * - * @deprecated use {@link com.android.resources.Density}. - */ - @Deprecated - public static enum Density { - XHIGH(320), - HIGH(240), - MEDIUM(160), - LOW(120), - NODPI(0); - - private final int mValue; - - Density(int value) { - mValue = value; - } - - public int getValue() { - return mValue; - } - - /** - * Returns the enum matching the given density value - * @param value The density value. - * @return the enum for the density value or null if no match was found. - */ - public static Density getEnum(int value) { - for (Density d : values()) { - if (d.mValue == value) { - return d; - } - } - - return null; - } - } - - /** - * Returns the density associated to the resource. - * @deprecated use {@link DensityBasedResourceValue#getResourceDensity()} - */ - @Deprecated - Density getDensity(); -} diff --git a/layoutlib_api/src/main/java/com/android/layoutlib/api/ILayoutBridge.java b/layoutlib_api/src/main/java/com/android/layoutlib/api/ILayoutBridge.java deleted file mode 100644 index f849cdd..0000000 --- a/layoutlib_api/src/main/java/com/android/layoutlib/api/ILayoutBridge.java +++ /dev/null @@ -1,230 +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.layoutlib.api; - -import com.android.ide.common.rendering.api.Bridge; - -import java.util.Map; - -/** - * Entry point of the Layout Lib. Implementations of this interface provide a method to compute - * and render a layout. - * <p/> - * <p/>{@link #getApiLevel()} gives the ability to know which methods are available. - * <p/> - * Changes in API level 5: - * <ul> - * <li>Bridge should extend {@link Bridge} instead of implementing {@link ILayoutBridge}.</li> - * </ul> - * Changes in API level 4: - * <ul> - * <li>new render method: {@link #computeLayout(IXmlPullParser, Object, int, int, boolean, int, float, float, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> - * <li>deprecated {@link #computeLayout(IXmlPullParser, Object, int, int, int, float, float, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> - * </ul> - * Changes in API level 3: - * <ul> - * <li>new render method: {@link #computeLayout(IXmlPullParser, Object, int, int, int, float, float, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> - * <li>deprecated {@link #computeLayout(IXmlPullParser, Object, int, int, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> - * </ul> - * Changes in API level 2: - * <ul> - * <li>new API Level method: {@link #getApiLevel()}</li> - * <li>new render method: {@link #computeLayout(IXmlPullParser, Object, int, int, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> - * <li>deprecated {@link #computeLayout(IXmlPullParser, Object, int, int, String, Map, Map, IProjectCallback, ILayoutLog)}</li> - * </ul> - * @deprecated Extend {@link Bridge} instead. - */ -@Deprecated -public interface ILayoutBridge { - - final int API_CURRENT = 4; - - /** - * Returns the API level of the layout library. - * While no methods will ever be removed, some may become deprecated, and some new ones - * will appear. - * <p/>If calling this method throws an {@link AbstractMethodError}, then the API level - * should be considered to be 1. - */ - int getApiLevel(); - - /** - * Initializes the Bridge object. - * @param fontOsLocation the location of the fonts. - * @param enumValueMap map attrName => { map enumFlagName => Integer value }. - * @return true if success. - * @since 1 - */ - boolean init(String fontOsLocation, Map<String, Map<String, Integer>> enumValueMap); - - /** - * Prepares the layoutlib to unloaded. - */ - boolean dispose(); - - /** - * Starts a layout session by inflating and rendering it. The method returns a - * {@link ILayoutResult} on which further actions can be taken. - * - * @param layoutDescription the {@link IXmlPullParser} letting the LayoutLib Bridge visit the - * layout file. - * @param projectKey An Object identifying the project. This is used for the cache mechanism. - * @param screenWidth the screen width - * @param screenHeight the screen height - * @param renderFullSize if true, the rendering will render the full size needed by the - * layout. This size is never smaller than <var>screenWidth</var> x <var>screenHeight</var>. - * @param density the density factor for the screen. - * @param xdpi the screen actual dpi in X - * @param ydpi the screen actual dpi in Y - * @param themeName The name of the theme to use. - * @param isProjectTheme true if the theme is a project theme, false if it is a framework theme. - * @param projectResources the resources of the project. The map contains (String, map) pairs - * where the string is the type of the resource reference used in the layout file, and the - * map contains (String, {@link IResourceValue}) pairs where the key is the resource name, - * and the value is the resource value. - * @param frameworkResources the framework resources. The map contains (String, map) pairs - * where the string is the type of the resource reference used in the layout file, and the map - * contains (String, {@link IResourceValue}) pairs where the key is the resource name, and the - * value is the resource value. - * @param projectCallback The {@link IProjectCallback} object to get information from - * the project. - * @param logger the object responsible for displaying warning/errors to the user. - * @return a new {@link ILayoutResult} object that contains the result of the layout. - * @deprecated use {@link Bridge#createSession(com.android.ide.common.rendering.api.SessionParams)} - * @since 4 - */ - @Deprecated - ILayoutResult computeLayout(IXmlPullParser layoutDescription, - Object projectKey, - int screenWidth, int screenHeight, boolean renderFullSize, - int density, float xdpi, float ydpi, - String themeName, boolean isProjectTheme, - Map<String, Map<String, IResourceValue>> projectResources, - Map<String, Map<String, IResourceValue>> frameworkResources, - IProjectCallback projectCallback, ILayoutLog logger); - - /** - * Computes and renders a layout - * @param layoutDescription the {@link IXmlPullParser} letting the LayoutLib Bridge visit the - * layout file. - * @param projectKey An Object identifying the project. This is used for the cache mechanism. - * @param screenWidth the screen width - * @param screenHeight the screen height - * @param density the density factor for the screen. - * @param xdpi the screen actual dpi in X - * @param ydpi the screen actual dpi in Y - * @param themeName The name of the theme to use. - * @param isProjectTheme true if the theme is a project theme, false if it is a framework theme. - * @param projectResources the resources of the project. The map contains (String, map) pairs - * where the string is the type of the resource reference used in the layout file, and the - * map contains (String, {@link IResourceValue}) pairs where the key is the resource name, - * and the value is the resource value. - * @param frameworkResources the framework resources. The map contains (String, map) pairs - * where the string is the type of the resource reference used in the layout file, and the map - * contains (String, {@link IResourceValue}) pairs where the key is the resource name, and the - * value is the resource value. - * @param projectCallback The {@link IProjectCallback} object to get information from - * the project. - * @param logger the object responsible for displaying warning/errors to the user. - * @return a new {@link ILayoutResult} object that contains the result of the layout. - * @deprecated use {@link Bridge#createSession(com.android.ide.common.rendering.api.SessionParams)} - * @since 3 - */ - @Deprecated - ILayoutResult computeLayout(IXmlPullParser layoutDescription, - Object projectKey, - int screenWidth, int screenHeight, int density, float xdpi, float ydpi, - String themeName, boolean isProjectTheme, - Map<String, Map<String, IResourceValue>> projectResources, - Map<String, Map<String, IResourceValue>> frameworkResources, - IProjectCallback projectCallback, ILayoutLog logger); - - /** - * Computes and renders a layout - * @param layoutDescription the {@link IXmlPullParser} letting the LayoutLib Bridge visit the - * layout file. - * @param projectKey An Object identifying the project. This is used for the cache mechanism. - * @param screenWidth the screen width - * @param screenHeight the screen height - * @param themeName The name of the theme to use. - * @param isProjectTheme true if the theme is a project theme, false if it is a framework theme. - * @param projectResources the resources of the project. The map contains (String, map) pairs - * where the string is the type of the resource reference used in the layout file, and the - * map contains (String, {@link IResourceValue}) pairs where the key is the resource name, - * and the value is the resource value. - * @param frameworkResources the framework resources. The map contains (String, map) pairs - * where the string is the type of the resource reference used in the layout file, and the map - * contains (String, {@link IResourceValue}) pairs where the key is the resource name, and the - * value is the resource value. - * @param projectCallback The {@link IProjectCallback} object to get information from - * the project. - * @param logger the object responsible for displaying warning/errors to the user. - * @return a new {@link ILayoutResult} object that contains the result of the layout. - * @deprecated use {@link Bridge#createSession(com.android.ide.common.rendering.api.SessionParams)} - * @since 2 - */ - @Deprecated - ILayoutResult computeLayout(IXmlPullParser layoutDescription, - Object projectKey, - int screenWidth, int screenHeight, String themeName, boolean isProjectTheme, - Map<String, Map<String, IResourceValue>> projectResources, - Map<String, Map<String, IResourceValue>> frameworkResources, - IProjectCallback projectCallback, ILayoutLog logger); - - /** - * Computes and renders a layout - * @param layoutDescription the {@link IXmlPullParser} letting the LayoutLib Bridge visit the - * layout file. - * @param projectKey An Object identifying the project. This is used for the cache mechanism. - * @param screenWidth - * @param screenHeight - * @param themeName The name of the theme to use. In order to differentiate project and platform - * themes sharing the same name, all project themes must be prepended with a '*' character. - * @param projectResources the resources of the project. The map contains (String, map) pairs - * where the string is the type of the resource reference used in the layout file, and the - * map contains (String, {@link IResourceValue}) pairs where the key is the resource name, - * and the value is the resource value. - * @param frameworkResources the framework resources. The map contains (String, map) pairs - * where the string is the type of the resource reference used in the layout file, and the map - * contains (String, {@link IResourceValue}) pairs where the key is the resource name, and the - * value is the resource value. - * @param projectCallback The {@link IProjectCallback} object to get information from - * the project. - * @param logger the object responsible for displaying warning/errors to the user. - * @return a new {@link ILayoutResult} object that contains the result of the layout. - * @deprecated use {@link Bridge#createSession(com.android.ide.common.rendering.api.SessionParams)} - * @since 1 - */ - @Deprecated - ILayoutResult computeLayout(IXmlPullParser layoutDescription, - Object projectKey, - int screenWidth, int screenHeight, String themeName, - Map<String, Map<String, IResourceValue>> projectResources, - Map<String, Map<String, IResourceValue>> frameworkResources, - IProjectCallback projectCallback, ILayoutLog logger); - - /** - * 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). - * @param projectKey the key for the project. - * @since 1 - */ - void clearCaches(Object projectKey); -} diff --git a/layoutlib_api/src/main/java/com/android/layoutlib/api/ILayoutLog.java b/layoutlib_api/src/main/java/com/android/layoutlib/api/ILayoutLog.java deleted file mode 100644 index 38a22b8..0000000 --- a/layoutlib_api/src/main/java/com/android/layoutlib/api/ILayoutLog.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.layoutlib.api; - -import com.android.ide.common.rendering.api.LayoutLog; - -/** - * Callback interface to display warnings/errors that happened during the computation and - * rendering of the layout. - * @deprecated use {@link LayoutLog}. - */ -@Deprecated -public interface ILayoutLog { - - /** - * Logs a warning message. - * @param message the message to log. - */ - void warning(String message); - - /** - * Logs an error message. - * @param message the message to log. - */ - void error(String message); - - /** - * Logs an exception - * @param t the {@link Throwable} to log. - */ - void error(Throwable t); -} diff --git a/layoutlib_api/src/main/java/com/android/layoutlib/api/ILayoutResult.java b/layoutlib_api/src/main/java/com/android/layoutlib/api/ILayoutResult.java deleted file mode 100644 index 6aeaf9f..0000000 --- a/layoutlib_api/src/main/java/com/android/layoutlib/api/ILayoutResult.java +++ /dev/null @@ -1,109 +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.layoutlib.api; - -import com.android.ide.common.rendering.api.Bridge; -import com.android.ide.common.rendering.api.RenderSession; - -import java.awt.image.BufferedImage; - -/** - * The result of a layout computation through {@link ILayoutBridge}. - * - * @since 1 - * @deprecated use {@link RenderSession} as returned by {@link Bridge#createSession(com.android.ide.common.rendering.api.SessionParams)} - */ -@Deprecated -public interface ILayoutResult { - /** - * Success return code - */ - final static int SUCCESS = 0; - - /** - * Error return code, in which case an error message is guaranteed to be defined. - * @see #getErrorMessage() - */ - final static int ERROR = 1; - - /** - * Returns the result code. - * @see #SUCCESS - * @see #ERROR - */ - int getSuccess(); - - /** - * Returns the {@link ILayoutViewInfo} object for the top level view. - */ - ILayoutViewInfo getRootView(); - - /** - * Returns the rendering of the full layout. - */ - BufferedImage getImage(); - - /** - * Returns the error message. - * <p/>Only valid when {@link #getSuccess()} returns {@link #ERROR} - */ - String getErrorMessage(); - - /** - * Layout information for a specific view. - * @deprecated - */ - @Deprecated - public interface ILayoutViewInfo { - - /** - * Returns the list of children views. - */ - ILayoutViewInfo[] getChildren(); - - /** - * Returns the key associated with the node. - * @see IXmlPullParser#getViewKey() - */ - Object getViewKey(); - - /** - * Returns the name of the view. - */ - String getName(); - - /** - * Returns the left of the view bounds. - */ - int getLeft(); - - /** - * Returns the top of the view bounds. - */ - int getTop(); - - /** - * Returns the right of the view bounds. - */ - int getRight(); - - /** - * Returns the bottom of the view bounds. - */ - int getBottom(); - } -} diff --git a/layoutlib_api/src/main/java/com/android/layoutlib/api/IProjectCallback.java b/layoutlib_api/src/main/java/com/android/layoutlib/api/IProjectCallback.java deleted file mode 100644 index 65e2a87..0000000 --- a/layoutlib_api/src/main/java/com/android/layoutlib/api/IProjectCallback.java +++ /dev/null @@ -1,73 +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.layoutlib.api; - -/** - * - * @deprecated - * - */ -public interface IProjectCallback { - - /** - * 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.<type>.<name></code>, and - * this method will return both the type and name of the resource. - * @param id the Id to resolve. - * @return an array of 2 strings containing the resource name and type, or null if the id - * does not match any resource. - */ - String[] resolveResourceValue(int id); - - /** - * Resolves the id of a resource Id of type int[] - * <p/>The resource id is the value of a R.styleable.<name>, 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 resolveResourceValue(int[] id); - - /** - * Returns the id of a resource. - * <p/>The provided type and name must match an existing constant defined as - * <code>R.<type>.<name></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 getResourceValue(String type, String name); -} diff --git a/layoutlib_api/src/main/java/com/android/layoutlib/api/IResourceValue.java b/layoutlib_api/src/main/java/com/android/layoutlib/api/IResourceValue.java deleted file mode 100644 index 9a00801..0000000 --- a/layoutlib_api/src/main/java/com/android/layoutlib/api/IResourceValue.java +++ /dev/null @@ -1,48 +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.layoutlib.api; - -import com.android.ide.common.rendering.api.ResourceValue; - -/** - * Represents an android resource with a name and a string value. - * @deprecated use {@link ResourceValue}. - */ -@Deprecated -public interface IResourceValue { - - /** - * Returns the type of the resource. For instance "drawable", "color", etc... - */ - String getType(); - - /** - * Returns the name of the resource, as defined in the XML. - */ - String getName(); - - /** - * Returns the value of the resource, as defined in the XML. This can be <code>null</code> - */ - String getValue(); - - /** - * Returns whether the resource is a framework resource (<code>true</code>) or a project - * resource (<code>false</false>). - */ - boolean isFramework(); -} diff --git a/layoutlib_api/src/main/java/com/android/layoutlib/api/IStyleResourceValue.java b/layoutlib_api/src/main/java/com/android/layoutlib/api/IStyleResourceValue.java deleted file mode 100644 index 21036ca..0000000 --- a/layoutlib_api/src/main/java/com/android/layoutlib/api/IStyleResourceValue.java +++ /dev/null @@ -1,40 +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.layoutlib.api; - -import com.android.ide.common.rendering.api.StyleResourceValue; - -/** - * Represents an android style resources with a name and a list of children {@link IResourceValue}. - * @deprecated Use {@link StyleResourceValue}. - */ -@Deprecated -public interface IStyleResourceValue extends IResourceValue { - - /** - * Returns the parent style name or <code>null</code> if unknown. - */ - String getParentStyle(); - - /** - * Find an item in the list by name - * @param name the name of the resource - * - * @deprecated use {@link StyleResourceValue#findValue(String)} - */ - IResourceValue findItem(String name); -} diff --git a/layoutlib_api/src/main/java/com/android/layoutlib/api/IXmlPullParser.java b/layoutlib_api/src/main/java/com/android/layoutlib/api/IXmlPullParser.java deleted file mode 100644 index e0a98a6..0000000 --- a/layoutlib_api/src/main/java/com/android/layoutlib/api/IXmlPullParser.java +++ /dev/null @@ -1,34 +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.layoutlib.api; - -import org.xmlpull.v1.XmlPullParser; - -/** - * @deprecated - */ -@Deprecated -public interface IXmlPullParser extends XmlPullParser { - - /** - * Returns a key for the current XML node. - * <p/>This key will be passed back in the {@link com.android.ide.common.rendering.api.ViewInfo} - * objects, allowing association of a particular XML node with its result from the - * layout computation. - */ - Object getViewKey(); -} diff --git a/layoutlib_api/src/main/java/com/android/resources/Density.java b/layoutlib_api/src/main/java/com/android/resources/Density.java deleted file mode 100644 index 1f3fb52..0000000 --- a/layoutlib_api/src/main/java/com/android/resources/Density.java +++ /dev/null @@ -1,142 +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.resources; - - -/** - * Density enum. - * <p/>This is used in the manifest in the uses-configuration node and in the resource folder names - * as well as other places needing to know the density values. - */ -public enum Density implements ResourceEnum { - XXHIGH("xxhdpi", "XX-High Density", 480, 16), //$NON-NLS-1$ - XHIGH("xhdpi", "X-High Density", 320, 8), //$NON-NLS-1$ - HIGH("hdpi", "High Density", 240, 4), //$NON-NLS-1$ - TV("tvdpi", "TV Density", 213, 13), //$NON-NLS-1$ - MEDIUM("mdpi", "Medium Density", 160, 4), //$NON-NLS-1$ - LOW("ldpi", "Low Density", 120, 4), //$NON-NLS-1$ - NODPI("nodpi", "No Density", 0, 4); //$NON-NLS-1$ - - public final static int DEFAULT_DENSITY = 160; - - private final String mValue; - private final String mDisplayValue; - private final int mDensity; - private final int mSince; - - private Density(String value, String displayValue, int density, int since) { - mValue = value; - mDisplayValue = displayValue; - mDensity = density; - mSince = since; - } - - /** - * Returns the enum matching the provided qualifier value. - * @param value The qualifier value. - * @return the enum for the qualifier value or null if no match was found. - */ - public static Density getEnum(String value) { - for (Density orient : values()) { - if (orient.mValue.equals(value)) { - return orient; - } - } - - return null; - } - - /** - * Returns the enum matching the given density value - * @param value The density value. - * @return the enum for the density value or null if no match was found. - */ - public static Density getEnum(int value) { - for (Density d : values()) { - if (d.mDensity == value) { - return d; - } - } - - return null; - } - - @Override - public String getResourceValue() { - return mValue; - } - - public int getDpiValue() { - return mDensity; - } - - public int since() { - return mSince; - } - - public String getLegacyValue() { - if (this != NODPI) { - return String.format("%1$ddpi", getDpiValue()); - } - - return ""; - } - - @Override - public String getShortDisplayValue() { - return mDisplayValue; - } - - @Override - public String getLongDisplayValue() { - return mDisplayValue; - } - - public static int getIndex(Density value) { - int i = 0; - for (Density input : values()) { - if (value == input) { - return i; - } - - i++; - } - - return -1; - } - - public static Density getByIndex(int index) { - int i = 0; - for (Density value : values()) { - if (i == index) { - return value; - } - i++; - } - return null; - } - - @Override - public boolean isFakeValue() { - return false; - } - - @Override - public boolean isValidValueForDevice() { - return this != NODPI; // nodpi is not a valid config for devices. - } -} diff --git a/layoutlib_api/src/main/java/com/android/resources/FolderTypeRelationship.java b/layoutlib_api/src/main/java/com/android/resources/FolderTypeRelationship.java deleted file mode 100644 index 61a6d85..0000000 --- a/layoutlib_api/src/main/java/com/android/resources/FolderTypeRelationship.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (C) 2007 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.resources; - - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * This class gives access to the bidirectional relationship between {@link ResourceType} and - * {@link ResourceFolderType}. - */ -public final class FolderTypeRelationship { - - private final static Map<ResourceType, List<ResourceFolderType>> mTypeToFolderMap = - new HashMap<ResourceType, List<ResourceFolderType>>(); - - private final static Map<ResourceFolderType, List<ResourceType>> mFolderToTypeMap = - new HashMap<ResourceFolderType, List<ResourceType>>(); - - static { - // generate the relationships in a temporary map - add(ResourceType.ANIM, ResourceFolderType.ANIM); - add(ResourceType.ANIMATOR, ResourceFolderType.ANIMATOR); - add(ResourceType.ARRAY, ResourceFolderType.VALUES); - add(ResourceType.ATTR, ResourceFolderType.VALUES); - add(ResourceType.BOOL, ResourceFolderType.VALUES); - add(ResourceType.COLOR, ResourceFolderType.VALUES); - add(ResourceType.COLOR, ResourceFolderType.COLOR); - add(ResourceType.DECLARE_STYLEABLE, ResourceFolderType.VALUES); - add(ResourceType.DIMEN, ResourceFolderType.VALUES); - add(ResourceType.DRAWABLE, ResourceFolderType.VALUES); - add(ResourceType.DRAWABLE, ResourceFolderType.DRAWABLE); - add(ResourceType.FRACTION, ResourceFolderType.VALUES); - add(ResourceType.ID, ResourceFolderType.VALUES); - add(ResourceType.INTEGER, ResourceFolderType.VALUES); - add(ResourceType.INTERPOLATOR, ResourceFolderType.INTERPOLATOR); - add(ResourceType.LAYOUT, ResourceFolderType.LAYOUT); - add(ResourceType.ID, ResourceFolderType.LAYOUT); - add(ResourceType.MENU, ResourceFolderType.MENU); - add(ResourceType.ID, ResourceFolderType.MENU); - add(ResourceType.MIPMAP, ResourceFolderType.MIPMAP); - add(ResourceType.PLURALS, ResourceFolderType.VALUES); - add(ResourceType.PUBLIC, ResourceFolderType.VALUES); - add(ResourceType.RAW, ResourceFolderType.RAW); - add(ResourceType.STRING, ResourceFolderType.VALUES); - add(ResourceType.STYLE, ResourceFolderType.VALUES); - add(ResourceType.STYLEABLE, ResourceFolderType.VALUES); - add(ResourceType.XML, ResourceFolderType.XML); - - makeSafe(); - } - - /** - * Returns a list of {@link ResourceType}s that can be generated from files inside a folder - * of the specified type. - * @param folderType The folder type. - * @return a list of {@link ResourceType}, possibly empty but never null. - */ - public static List<ResourceType> getRelatedResourceTypes(ResourceFolderType folderType) { - List<ResourceType> list = mFolderToTypeMap.get(folderType); - if (list != null) { - return list; - } - - return Collections.emptyList(); - } - - /** - * Returns a list of {@link ResourceFolderType} that can contain files generating resources - * of the specified type. - * @param resType the type of resource. - * @return a list of {@link ResourceFolderType}, possibly empty but never null. - */ - public static List<ResourceFolderType> getRelatedFolders(ResourceType resType) { - List<ResourceFolderType> list = mTypeToFolderMap.get(resType); - if (list != null) { - return list; - } - - return Collections.emptyList(); - } - - /** - * Returns true if the {@link ResourceType} and the {@link ResourceFolderType} values match. - * @param resType the resource type. - * @param folderType the folder type. - * @return true if files inside the folder of the specified {@link ResourceFolderType} - * could generate a resource of the specified {@link ResourceType} - */ - public static boolean match(ResourceType resType, ResourceFolderType folderType) { - List<ResourceFolderType> list = mTypeToFolderMap.get(resType); - - if (list != null) { - return list.contains(folderType); - } - - return false; - } - - /** - * Adds a {@link ResourceType} - {@link ResourceFolderType} relationship. this indicates that - * a file in the folder can generate a resource of the specified type. - * @param type The resourceType - * @param folder The {@link ResourceFolderType} - */ - private static void add(ResourceType type, ResourceFolderType folder) { - // first we add the folder to the list associated with the type. - List<ResourceFolderType> folderList = mTypeToFolderMap.get(type); - if (folderList == null) { - folderList = new ArrayList<ResourceFolderType>(); - mTypeToFolderMap.put(type, folderList); - } - if (folderList.indexOf(folder) == -1) { - folderList.add(folder); - } - - // now we add the type to the list associated with the folder. - List<ResourceType> typeList = mFolderToTypeMap.get(folder); - if (typeList == null) { - typeList = new ArrayList<ResourceType>(); - mFolderToTypeMap.put(folder, typeList); - } - if (typeList.indexOf(type) == -1) { - typeList.add(type); - } - } - - /** - * Makes the maps safe by replacing the current list values with unmodifiable lists. - */ - private static void makeSafe() { - for (ResourceType type : ResourceType.values()) { - List<ResourceFolderType> list = mTypeToFolderMap.get(type); - if (list != null) { - // replace with a unmodifiable list wrapper around the current list. - mTypeToFolderMap.put(type, Collections.unmodifiableList(list)); - } - } - - for (ResourceFolderType folder : ResourceFolderType.values()) { - List<ResourceType> list = mFolderToTypeMap.get(folder); - if (list != null) { - // replace with a unmodifiable list wrapper around the current list. - mFolderToTypeMap.put(folder, Collections.unmodifiableList(list)); - } - } - } -} diff --git a/layoutlib_api/src/main/java/com/android/resources/Keyboard.java b/layoutlib_api/src/main/java/com/android/resources/Keyboard.java deleted file mode 100644 index d6bc80a..0000000 --- a/layoutlib_api/src/main/java/com/android/resources/Keyboard.java +++ /dev/null @@ -1,104 +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.resources; - -/** - * Keyboard enum. - * <p/>This is used in the manifest in the uses-configuration node and in the resource folder names. - */ -public enum Keyboard implements ResourceEnum { - NOKEY("nokeys", null, "No Keys", "No keyboard"), //$NON-NLS-1$ - QWERTY("qwerty", null, "Qwerty", "Qwerty keybard"), //$NON-NLS-1$ - TWELVEKEY("12key", "twelvekey", "12 Key", "12 key keyboard"); //$NON-NLS-1$ //$NON-NLS-2$ - - private final String mValue, mValue2; - private final String mShortDisplayValue; - private final String mLongDisplayValue; - - private Keyboard(String value, String value2, String shortDisplayValue, - String longDisplayValue) { - mValue = value; - mValue2 = value2; - mShortDisplayValue = shortDisplayValue; - mLongDisplayValue = longDisplayValue; - } - - /** - * Returns the enum for matching the provided qualifier value. - * @param value The qualifier value. - * @return the enum for the qualifier value or null if no matching was found. - */ - public static Keyboard getEnum(String value) { - for (Keyboard kbrd : values()) { - if (kbrd.mValue.equals(value) || - (kbrd.mValue2 != null && kbrd.mValue2.equals(value))) { - return kbrd; - } - } - - return null; - } - - @Override - public String getResourceValue() { - return mValue; - } - - @Override - public String getShortDisplayValue() { - return mShortDisplayValue; - } - - @Override - public String getLongDisplayValue() { - return mLongDisplayValue; - } - - public static int getIndex(Keyboard value) { - int i = 0; - for (Keyboard input : values()) { - if (value == input) { - return i; - } - - i++; - } - - return -1; - } - - public static Keyboard getByIndex(int index) { - int i = 0; - for (Keyboard value : values()) { - if (i == index) { - return value; - } - i++; - } - return null; - } - - @Override - public boolean isFakeValue() { - return false; - } - - @Override - public boolean isValidValueForDevice() { - return true; - } -} diff --git a/layoutlib_api/src/main/java/com/android/resources/KeyboardState.java b/layoutlib_api/src/main/java/com/android/resources/KeyboardState.java deleted file mode 100644 index 2eb7e00..0000000 --- a/layoutlib_api/src/main/java/com/android/resources/KeyboardState.java +++ /dev/null @@ -1,102 +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.resources; - -/** - * Keyboard state enum. - * <p/>This is used in the manifest in the uses-configuration node and in the resource folder names. - */ -public enum KeyboardState implements ResourceEnum { - EXPOSED("keysexposed", "Exposed", "Exposed keyboard"), //$NON-NLS-1$ - HIDDEN("keyshidden", "Hidden", "Hidden keyboard"), //$NON-NLS-1$ - SOFT("keyssoft", "Soft", "Soft keyboard"); //$NON-NLS-1$ - - private final String mValue; - private final String mShortDisplayValue; - private final String mLongDisplayValue; - - private KeyboardState(String value, String shortDisplayValue, String longDisplayValue) { - mValue = value; - mShortDisplayValue = shortDisplayValue; - mLongDisplayValue = longDisplayValue; - } - - /** - * Returns the enum for matching the provided qualifier value. - * @param value The qualifier value. - * @return the enum for the qualifier value or null if no matching was found. - */ - public static KeyboardState getEnum(String value) { - for (KeyboardState state : values()) { - if (state.mValue.equals(value)) { - return state; - } - } - - return null; - } - - @Override - public String getResourceValue() { - return mValue; - } - - @Override - public String getShortDisplayValue() { - return mShortDisplayValue; - } - - @Override - public String getLongDisplayValue() { - return mLongDisplayValue; - } - - public static int getIndex(KeyboardState value) { - int i = 0; - for (KeyboardState input : values()) { - if (value == input) { - return i; - } - - i++; - } - - return -1; - } - - public static KeyboardState getByIndex(int index) { - int i = 0; - for (KeyboardState value : values()) { - if (i == index) { - return value; - } - i++; - } - return null; - } - - @Override - public boolean isFakeValue() { - return false; - } - - @Override - public boolean isValidValueForDevice() { - return true; - } - -} diff --git a/layoutlib_api/src/main/java/com/android/resources/LayoutDirection.java b/layoutlib_api/src/main/java/com/android/resources/LayoutDirection.java deleted file mode 100644 index fbc386d..0000000 --- a/layoutlib_api/src/main/java/com/android/resources/LayoutDirection.java +++ /dev/null @@ -1,100 +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.resources; - -/** - * Layout Direction enum. - */ -public enum LayoutDirection implements ResourceEnum { - LTR("ldltr", "LTR", "Left To Right"), //$NON-NLS-1$ - RTL("ldrtl", "RTL", "Right To Left"); //$NON-NLS-1$ - - private final String mValue; - private final String mShortDisplayValue; - private final String mLongDisplayValue; - - private LayoutDirection(String value, String shortDisplayValue, String longDisplayValue) { - mValue = value; - mShortDisplayValue = shortDisplayValue; - mLongDisplayValue = longDisplayValue; - } - - /** - * Returns the enum for matching the provided qualifier value. - * @param value The qualifier value. - * @return the enum for the qualifier value or null if no matching was found. - */ - public static LayoutDirection getEnum(String value) { - for (LayoutDirection orient : values()) { - if (orient.mValue.equals(value)) { - return orient; - } - } - - return null; - } - - @Override - public String getResourceValue() { - return mValue; - } - - @Override - public String getShortDisplayValue() { - return mShortDisplayValue; - } - - @Override - public String getLongDisplayValue() { - return mLongDisplayValue; - } - - public static int getIndex(LayoutDirection orientation) { - int i = 0; - for (LayoutDirection orient : values()) { - if (orient == orientation) { - return i; - } - - i++; - } - - return -1; - } - - public static LayoutDirection getByIndex(int index) { - int i = 0; - for (LayoutDirection orient : values()) { - if (i == index) { - return orient; - } - i++; - } - - return null; - } - - @Override - public boolean isFakeValue() { - return false; - } - - @Override - public boolean isValidValueForDevice() { - return true; - } -} diff --git a/layoutlib_api/src/main/java/com/android/resources/Navigation.java b/layoutlib_api/src/main/java/com/android/resources/Navigation.java deleted file mode 100644 index f857e5f..0000000 --- a/layoutlib_api/src/main/java/com/android/resources/Navigation.java +++ /dev/null @@ -1,103 +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.resources; - -/** - * Navigation enum. - * <p/>This is used in the manifest in the uses-configuration node and in the resource folder names. - */ -public enum Navigation implements ResourceEnum { - NONAV("nonav", "None", "No navigation"), //$NON-NLS-1$ - DPAD("dpad", "D-pad", "D-pad navigation"), //$NON-NLS-1$ - TRACKBALL("trackball", "Trackball", "Trackball navigation"), //$NON-NLS-1$ - WHEEL("wheel", "Wheel", "Wheel navigation"); //$NON-NLS-1$ - - private final String mValue; - private final String mShortDisplayValue; - private final String mLongDisplayValue; - - private Navigation(String value, String shortDisplayValue, String longDisplayValue) { - mValue = value; - mShortDisplayValue = shortDisplayValue; - mLongDisplayValue = longDisplayValue; - } - - /** - * Returns the enum for matching the provided qualifier value. - * @param value The qualifier value. - * @return the enum for the qualifier value or null if no matching was found. - */ - public static Navigation getEnum(String value) { - for (Navigation nav : values()) { - if (nav.mValue.equals(value)) { - return nav; - } - } - - return null; - } - - @Override - public String getResourceValue() { - return mValue; - } - - @Override - public String getShortDisplayValue() { - return mShortDisplayValue; - } - - @Override - public String getLongDisplayValue() { - return mLongDisplayValue; - } - - public static int getIndex(Navigation value) { - int i = 0; - for (Navigation nav : values()) { - if (nav == value) { - return i; - } - - i++; - } - - return -1; - } - - public static Navigation getByIndex(int index) { - int i = 0; - for (Navigation value : values()) { - if (i == index) { - return value; - } - i++; - } - return null; - } - - @Override - public boolean isFakeValue() { - return false; - } - - @Override - public boolean isValidValueForDevice() { - return true; - } - -}
\ No newline at end of file diff --git a/layoutlib_api/src/main/java/com/android/resources/NavigationState.java b/layoutlib_api/src/main/java/com/android/resources/NavigationState.java deleted file mode 100644 index 63b8fea..0000000 --- a/layoutlib_api/src/main/java/com/android/resources/NavigationState.java +++ /dev/null @@ -1,101 +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.resources; - -/** - * Navigation state enum. - * <p/>This is used in the resource folder names. - */ -public enum NavigationState implements ResourceEnum { - EXPOSED("navexposed", "Exposed", "Exposed navigation"), //$NON-NLS-1$ - HIDDEN("navhidden", "Hidden", "Hidden navigation"); //$NON-NLS-1$ - - private final String mValue; - private final String mShortDisplayValue; - private final String mLongDisplayValue; - - private NavigationState(String value, String shortDisplayValue, String longDisplayValue) { - mValue = value; - mShortDisplayValue = shortDisplayValue; - mLongDisplayValue = longDisplayValue; - } - - /** - * Returns the enum for matching the provided qualifier value. - * @param value The qualifier value. - * @return the enum for the qualifier value or null if no matching was found. - */ - public static NavigationState getEnum(String value) { - for (NavigationState state : values()) { - if (state.mValue.equals(value)) { - return state; - } - } - - return null; - } - - @Override - public String getResourceValue() { - return mValue; - } - - @Override - public String getShortDisplayValue() { - return mShortDisplayValue; - } - - @Override - public String getLongDisplayValue() { - return mLongDisplayValue; - } - - public static int getIndex(NavigationState value) { - int i = 0; - for (NavigationState input : values()) { - if (value == input) { - return i; - } - - i++; - } - - return -1; - } - - public static NavigationState getByIndex(int index) { - int i = 0; - for (NavigationState value : values()) { - if (i == index) { - return value; - } - i++; - } - return null; - } - - @Override - public boolean isFakeValue() { - return false; - } - - @Override - public boolean isValidValueForDevice() { - return true; - } - -} diff --git a/layoutlib_api/src/main/java/com/android/resources/NightMode.java b/layoutlib_api/src/main/java/com/android/resources/NightMode.java deleted file mode 100644 index 8fe1dd9..0000000 --- a/layoutlib_api/src/main/java/com/android/resources/NightMode.java +++ /dev/null @@ -1,101 +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.resources; - -/** - * Night enum. - * <p/>This is used in the resource folder names. - */ -public enum NightMode implements ResourceEnum { - NOTNIGHT("notnight", "Not Night", "Day time"), - NIGHT("night", "Night", "Night time"); - - private final String mValue; - private final String mShortDisplayValue; - private final String mLongDisplayValue; - - private NightMode(String value, String shortDisplayValue, String longDisplayValue) { - mValue = value; - mShortDisplayValue = shortDisplayValue; - mLongDisplayValue = longDisplayValue; - } - - /** - * Returns the enum for matching the provided qualifier value. - * @param value The qualifier value. - * @return the enum for the qualifier value or null if no matching was found. - */ - public static NightMode getEnum(String value) { - for (NightMode mode : values()) { - if (mode.mValue.equals(value)) { - return mode; - } - } - - return null; - } - - @Override - public String getResourceValue() { - return mValue; - } - - @Override - public String getShortDisplayValue() { - return mShortDisplayValue; - } - - @Override - public String getLongDisplayValue() { - return mLongDisplayValue; - } - - public static int getIndex(NightMode value) { - int i = 0; - for (NightMode mode : values()) { - if (mode == value) { - return i; - } - - i++; - } - - return -1; - } - - public static NightMode getByIndex(int index) { - int i = 0; - for (NightMode value : values()) { - if (i == index) { - return value; - } - i++; - } - return null; - } - - @Override - public boolean isFakeValue() { - return false; - } - - @Override - public boolean isValidValueForDevice() { - return true; - } - -} diff --git a/layoutlib_api/src/main/java/com/android/resources/ResourceConstants.java b/layoutlib_api/src/main/java/com/android/resources/ResourceConstants.java deleted file mode 100644 index 748f88a..0000000 --- a/layoutlib_api/src/main/java/com/android/resources/ResourceConstants.java +++ /dev/null @@ -1,50 +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.resources; - -/** - * Resource Constants. - */ -public class ResourceConstants { - - /** Default anim resource folder name, i.e. "anim" */ - public final static String FD_RES_ANIM = "anim"; //$NON-NLS-1$ - /** Default animator resource folder name, i.e. "animator" */ - public final static String FD_RES_ANIMATOR = "animator"; //$NON-NLS-1$ - /** Default color resource folder name, i.e. "color" */ - public final static String FD_RES_COLOR = "color"; //$NON-NLS-1$ - /** Default drawable resource folder name, i.e. "drawable" */ - public final static String FD_RES_DRAWABLE = "drawable"; //$NON-NLS-1$ - /** Default interpolator resource folder name, i.e. "interpolator" */ - public final static String FD_RES_INTERPOLATOR = "interpolator"; //$NON-NLS-1$ - /** Default layout resource folder name, i.e. "layout" */ - public final static String FD_RES_LAYOUT = "layout"; //$NON-NLS-1$ - /** Default menu resource folder name, i.e. "menu" */ - public final static String FD_RES_MENU = "menu"; //$NON-NLS-1$ - /** Default menu resource folder name, i.e. "mipmap" */ - public final static String FD_RES_MIPMAP = "mipmap"; //$NON-NLS-1$ - /** Default values resource folder name, i.e. "values" */ - public final static String FD_RES_VALUES = "values"; //$NON-NLS-1$ - /** Default xml resource folder name, i.e. "xml" */ - public final static String FD_RES_XML = "xml"; //$NON-NLS-1$ - /** Default raw resource folder name, i.e. "raw" */ - public final static String FD_RES_RAW = "raw"; //$NON-NLS-1$ - - /** Separator between the resource folder qualifier. */ - public final static String RES_QUALIFIER_SEP = "-"; //$NON-NLS-1$ - -} diff --git a/layoutlib_api/src/main/java/com/android/resources/ResourceEnum.java b/layoutlib_api/src/main/java/com/android/resources/ResourceEnum.java deleted file mode 100644 index 7f4e16a..0000000 --- a/layoutlib_api/src/main/java/com/android/resources/ResourceEnum.java +++ /dev/null @@ -1,60 +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.resources; - -/** - * An enum representing a resource qualifier value. - */ -public interface ResourceEnum { - - /** - * Returns the resource string. This is to be used in resource folder names. - */ - String getResourceValue(); - - /** - * Whether the value actually used on device. This returns true only if a device can report - * this value, false if it's just used to qualify resources. - */ - boolean isValidValueForDevice(); - - /** - * Whether the value is neither used for device nor resources. This returns false when - * the value is only used for internal usage in the custom editors. - */ - boolean isFakeValue(); - - /** - * Returns a short string for display value. The string does not need to show the context. - * <p/>For instance "exposed", which can be the value for the keyboard state or the navigation - * state, would be valid since something else in the UI is expected to show if this is about the - * keyboard or the navigation state. - * - * @see #getLongDisplayValue() - */ - String getShortDisplayValue(); - - /** - * Returns a long string for display value. This must not only include the enum value but - * context (qualifier) about what the value represents. - * <p/>For instance "Exposed keyboard", and "Export navigation", as "exposed" would not be - * enough to know what qualifier the value is about. - * - * @see #getShortDisplayValue() - */ - String getLongDisplayValue(); -} diff --git a/layoutlib_api/src/main/java/com/android/resources/ResourceFolderType.java b/layoutlib_api/src/main/java/com/android/resources/ResourceFolderType.java deleted file mode 100644 index 5a271cf..0000000 --- a/layoutlib_api/src/main/java/com/android/resources/ResourceFolderType.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2007 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.resources; - -/** - * Enum representing a type of resource folder. - */ -public enum ResourceFolderType { - ANIM(ResourceConstants.FD_RES_ANIM), - ANIMATOR(ResourceConstants.FD_RES_ANIMATOR), - COLOR(ResourceConstants.FD_RES_COLOR), - DRAWABLE(ResourceConstants.FD_RES_DRAWABLE), - INTERPOLATOR(ResourceConstants.FD_RES_INTERPOLATOR), - LAYOUT(ResourceConstants.FD_RES_LAYOUT), - MENU(ResourceConstants.FD_RES_MENU), - MIPMAP(ResourceConstants.FD_RES_MIPMAP), - RAW(ResourceConstants.FD_RES_RAW), - VALUES(ResourceConstants.FD_RES_VALUES), - XML(ResourceConstants.FD_RES_XML); - - private final String mName; - - ResourceFolderType(String name) { - mName = name; - } - - /** - * Returns the folder name for this resource folder type. - */ - public String getName() { - return mName; - } - - /** - * Returns the enum by name. - * @param name The enum string value. - * @return the enum or null if not found. - */ - public static ResourceFolderType getTypeByName(String name) { - assert name.indexOf('-') == -1 : name; // use #getFolderType instead - for (ResourceFolderType rType : values()) { - if (rType.mName.equals(name)) { - return rType; - } - } - return null; - } - - /** - * Returns the {@link ResourceFolderType} from the folder name - * @param folderName The name of the folder. This must be a valid folder name in the format - * <code>resType[-resqualifiers[-resqualifiers[...]]</code> - * @return the <code>ResourceFolderType</code> representing the type of the folder, or - * <code>null</code> if no matching type was found. - */ - public static ResourceFolderType getFolderType(String folderName) { - int index = folderName.indexOf(ResourceConstants.RES_QUALIFIER_SEP); - if (index != -1) { - folderName = folderName.substring(0, index); - } - return getTypeByName(folderName); - } -} diff --git a/layoutlib_api/src/main/java/com/android/resources/ResourceType.java b/layoutlib_api/src/main/java/com/android/resources/ResourceType.java deleted file mode 100644 index e9d4d53..0000000 --- a/layoutlib_api/src/main/java/com/android/resources/ResourceType.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2007 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.resources; - - -/** - * Enum representing a type of compiled resource. - */ -public enum ResourceType { - ANIM("anim", "Animation"), //$NON-NLS-1$ - ANIMATOR("animator", "Animator"), //$NON-NLS-1$ - ARRAY("array", "Array", "string-array", "integer-array"), //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-4$ - ATTR("attr", "Attr"), //$NON-NLS-1$ - BOOL("bool", "Boolean"), //$NON-NLS-1$ - COLOR("color", "Color"), //$NON-NLS-1$ - DECLARE_STYLEABLE("declare-styleable", "Declare Stylable"), //$NON-NLS-1$ - DIMEN("dimen", "Dimension"), //$NON-NLS-1$ - DRAWABLE("drawable", "Drawable"), //$NON-NLS-1$ - FRACTION("fraction", "Fraction"), //$NON-NLS-1$ - ID("id", "ID"), //$NON-NLS-1$ - INTEGER("integer", "Integer"), //$NON-NLS-1$ - INTERPOLATOR("interpolator", "Interpolator"), //$NON-NLS-1$ - LAYOUT("layout", "Layout"), //$NON-NLS-1$ - MENU("menu", "Menu"), //$NON-NLS-1$ - MIPMAP("mipmap", "Mip Map"), //$NON-NLS-1$ - PLURALS("plurals", "Plurals"), //$NON-NLS-1$ - RAW("raw", "Raw"), //$NON-NLS-1$ - STRING("string", "String"), //$NON-NLS-1$ - STYLE("style", "Style"), //$NON-NLS-1$ - STYLEABLE("styleable", "Styleable"), //$NON-NLS-1$ - XML("xml", "XML"), //$NON-NLS-1$ - // this is not actually used. Only there because they get parsed and since we want to - // detect new resource type, we need to have this one exist. - PUBLIC("public", "###"); //$NON-NLS-1$ //$NON-NLS-2$ - - private final String mName; - private final String mDisplayName; - private final String[] mAlternateXmlNames; - - ResourceType(String name, String displayName, String... alternateXmlNames) { - mName = name; - mDisplayName = displayName; - mAlternateXmlNames = alternateXmlNames; - } - - /** - * Returns the resource type name, as used by XML files. - */ - public String getName() { - return mName; - } - - /** - * Returns a translated display name for the resource type. - */ - public String getDisplayName() { - return mDisplayName; - } - - /** - * Returns the enum by its name as it appears in the XML or the R class. - * @param name name of the resource - * @return the matching {@link ResourceType} or <code>null</code> if no match was found. - */ - public static ResourceType getEnum(String name) { - for (ResourceType rType : values()) { - if (rType.mName.equals(name)) { - return rType; - } else if (rType.mAlternateXmlNames != null) { - // if there are alternate Xml Names, we test those too - for (String alternate : rType.mAlternateXmlNames) { - if (alternate.equals(name)) { - return rType; - } - } - } - } - return null; - } - - /** - * Returns an array with all the names defined by this enum. - */ - public static String[] getNames() { - ResourceType[] values = values(); - String[] names = new String[values.length]; - for (int i = values.length - 1; i >= 0; --i) { - names[i] = values[i].getName(); - } - return names; - } - - @Override - public String toString() { - return getName(); - } -} diff --git a/layoutlib_api/src/main/java/com/android/resources/ScreenOrientation.java b/layoutlib_api/src/main/java/com/android/resources/ScreenOrientation.java deleted file mode 100644 index b18753d..0000000 --- a/layoutlib_api/src/main/java/com/android/resources/ScreenOrientation.java +++ /dev/null @@ -1,103 +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.resources; - -/** - * Screen Orientation enum. - * <p/>This is used in the manifest in the uses-configuration node and in the resource folder names. - */ -public enum ScreenOrientation implements ResourceEnum { - PORTRAIT("port", "Portrait", "Portrait Orientation"), //$NON-NLS-1$ - LANDSCAPE("land", "Landscape", "Landscape Orientation"), //$NON-NLS-1$ - SQUARE("square", "Square", "Square Orientation"); //$NON-NLS-1$ - - private final String mValue; - private final String mShortDisplayValue; - private final String mLongDisplayValue; - - private ScreenOrientation(String value, String shortDisplayValue, String longDisplayValue) { - mValue = value; - mShortDisplayValue = shortDisplayValue; - mLongDisplayValue = longDisplayValue; - } - - /** - * Returns the enum for matching the provided qualifier value. - * @param value The qualifier value. - * @return the enum for the qualifier value or null if no matching was found. - */ - public static ScreenOrientation getEnum(String value) { - for (ScreenOrientation orient : values()) { - if (orient.mValue.equals(value)) { - return orient; - } - } - - return null; - } - - @Override - public String getResourceValue() { - return mValue; - } - - @Override - public String getShortDisplayValue() { - return mShortDisplayValue; - } - - @Override - public String getLongDisplayValue() { - return mLongDisplayValue; - } - - public static int getIndex(ScreenOrientation orientation) { - int i = 0; - for (ScreenOrientation orient : values()) { - if (orient == orientation) { - return i; - } - - i++; - } - - return -1; - } - - public static ScreenOrientation getByIndex(int index) { - int i = 0; - for (ScreenOrientation orient : values()) { - if (i == index) { - return orient; - } - i++; - } - - return null; - } - - @Override - public boolean isFakeValue() { - return false; - } - - @Override - public boolean isValidValueForDevice() { - return true; - } - -} diff --git a/layoutlib_api/src/main/java/com/android/resources/ScreenRatio.java b/layoutlib_api/src/main/java/com/android/resources/ScreenRatio.java deleted file mode 100644 index bb575b0..0000000 --- a/layoutlib_api/src/main/java/com/android/resources/ScreenRatio.java +++ /dev/null @@ -1,103 +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.resources; - -/** - * Screen Ratio enum. - * <p/>This is used in the manifest in the uses-configuration node and in the resource folder names. - */ -public enum ScreenRatio implements ResourceEnum { - NOTLONG("notlong", "Not Long", "Short screen aspect ratio"), //$NON-NLS-1$ - LONG("long", "Long", "Long screen aspect ratio"); //$NON-NLS-1$ - - private final String mValue; - private final String mShortDisplayValue; - private final String mLongDisplayValue; - - private ScreenRatio(String value, String displayValue, String longDisplayValue) { - mValue = value; - mShortDisplayValue = displayValue; - mLongDisplayValue = longDisplayValue; - } - - /** - * Returns the enum for matching the provided qualifier value. - * @param value The qualifier value. - * @return the enum for the qualifier value or null if no matching was found. - */ - public static ScreenRatio getEnum(String value) { - for (ScreenRatio orient : values()) { - if (orient.mValue.equals(value)) { - return orient; - } - } - - return null; - } - - @Override - public String getResourceValue() { - return mValue; - } - - @Override - public String getShortDisplayValue() { - return mShortDisplayValue; - } - - @Override - public String getLongDisplayValue() { - return mLongDisplayValue; - } - - public static int getIndex(ScreenRatio orientation) { - int i = 0; - for (ScreenRatio orient : values()) { - if (orient == orientation) { - return i; - } - - i++; - } - - return -1; - } - - public static ScreenRatio getByIndex(int index) { - int i = 0; - for (ScreenRatio orient : values()) { - if (i == index) { - return orient; - } - i++; - } - - return null; - } - - @Override - public boolean isFakeValue() { - return false; - } - - @Override - public boolean isValidValueForDevice() { - return true; - } - -} - diff --git a/layoutlib_api/src/main/java/com/android/resources/ScreenSize.java b/layoutlib_api/src/main/java/com/android/resources/ScreenSize.java deleted file mode 100644 index 4def540..0000000 --- a/layoutlib_api/src/main/java/com/android/resources/ScreenSize.java +++ /dev/null @@ -1,104 +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.resources; - -/** - * Screen size enum. - * <p/>This is used in the manifest in the uses-configuration node and in the resource folder names. - */ -public enum ScreenSize implements ResourceEnum { - SMALL("small", "Small", "Small Screen"), //$NON-NLS-1$ - NORMAL("normal", "Normal", "Normal Screen"), //$NON-NLS-1$ - LARGE("large", "Large", "Large Screen"), //$NON-NLS-1$ - XLARGE("xlarge", "X-Large", "Extra Large Screen"); //$NON-NLS-1$ - - private final String mValue; - private final String mShortDisplayValue; - private final String mLongDisplayValue; - - private ScreenSize(String value, String shortDisplayValue, String longDisplayValue) { - mValue = value; - mShortDisplayValue = shortDisplayValue; - mLongDisplayValue = longDisplayValue; - } - - /** - * Returns the enum for matching the provided qualifier value. - * @param value The qualifier value. - * @return the enum for the qualifier value or null if no matching was found. - */ - public static ScreenSize getEnum(String value) { - for (ScreenSize orient : values()) { - if (orient.mValue.equals(value)) { - return orient; - } - } - - return null; - } - - @Override - public String getResourceValue() { - return mValue; - } - - @Override - public String getShortDisplayValue() { - return mShortDisplayValue; - } - - @Override - public String getLongDisplayValue() { - return mLongDisplayValue; - } - - public static int getIndex(ScreenSize orientation) { - int i = 0; - for (ScreenSize orient : values()) { - if (orient == orientation) { - return i; - } - - i++; - } - - return -1; - } - - public static ScreenSize getByIndex(int index) { - int i = 0; - for (ScreenSize orient : values()) { - if (i == index) { - return orient; - } - i++; - } - - return null; - } - - @Override - public boolean isFakeValue() { - return false; - } - - @Override - public boolean isValidValueForDevice() { - return true; - } - -} diff --git a/layoutlib_api/src/main/java/com/android/resources/TouchScreen.java b/layoutlib_api/src/main/java/com/android/resources/TouchScreen.java deleted file mode 100644 index 7eeeb08..0000000 --- a/layoutlib_api/src/main/java/com/android/resources/TouchScreen.java +++ /dev/null @@ -1,103 +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.resources; - -/** - * Touch screen enum. - * <p/>This is used in the manifest in the uses-configuration node and in the resource folder names. - */ -public enum TouchScreen implements ResourceEnum { - NOTOUCH("notouch", "No Touch", "No-touch screen"), //$NON-NLS-1$ - STYLUS("stylus", "Stylus", "Stylus-based touchscreen"), //$NON-NLS-1$ - FINGER("finger", "Finger", "Finger-based touchscreen"); //$NON-NLS-1$ - - private final String mValue; - private final String mShortDisplayValue; - private final String mLongDisplayValue; - - private TouchScreen(String value, String displayValue, String longDisplayValue) { - mValue = value; - mShortDisplayValue = displayValue; - mLongDisplayValue = longDisplayValue; - } - - /** - * Returns the enum for matching the provided qualifier value. - * @param value The qualifier value. - * @return the enum for the qualifier value or null if no matching was found. - */ - public static TouchScreen getEnum(String value) { - for (TouchScreen orient : values()) { - if (orient.mValue.equals(value)) { - return orient; - } - } - - return null; - } - - @Override - public String getResourceValue() { - return mValue; - } - - @Override - public String getShortDisplayValue() { - return mShortDisplayValue; - } - - @Override - public String getLongDisplayValue() { - return mLongDisplayValue; - } - - public static int getIndex(TouchScreen touch) { - int i = 0; - for (TouchScreen t : values()) { - if (t == touch) { - return i; - } - - i++; - } - - return -1; - } - - public static TouchScreen getByIndex(int index) { - int i = 0; - for (TouchScreen value : values()) { - if (i == index) { - return value; - } - i++; - } - - return null; - } - - @Override - public boolean isFakeValue() { - return false; - } - - @Override - public boolean isValidValueForDevice() { - return true; - } - -} diff --git a/layoutlib_api/src/main/java/com/android/resources/UiMode.java b/layoutlib_api/src/main/java/com/android/resources/UiMode.java deleted file mode 100644 index d1ddbc8..0000000 --- a/layoutlib_api/src/main/java/com/android/resources/UiMode.java +++ /dev/null @@ -1,100 +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.resources; - -/** - * UI Mode enum. - * <p/>This is used in the resource folder names. - */ -public enum UiMode implements ResourceEnum { - NORMAL("", "Normal"), - CAR("car", "Car Dock"), - DESK("desk", "Desk Dock"), - TELEVISION("television", "Television"); - - private final String mValue; - private final String mDisplayValue; - - private UiMode(String value, String display) { - mValue = value; - mDisplayValue = display; - } - - /** - * Returns the enum for matching the provided qualifier value. - * @param value The qualifier value. - * @return the enum for the qualifier value or null if no matching was found. - */ - public static UiMode getEnum(String value) { - for (UiMode mode : values()) { - if (mode.mValue.equals(value)) { - return mode; - } - } - - return null; - } - - @Override - public String getResourceValue() { - return mValue; - } - - @Override - public String getShortDisplayValue() { - return mDisplayValue; - } - - @Override - public String getLongDisplayValue() { - return mDisplayValue; - } - - public static int getIndex(UiMode value) { - int i = 0; - for (UiMode mode : values()) { - if (mode == value) { - return i; - } - - i++; - } - - return -1; - } - - public static UiMode getByIndex(int index) { - int i = 0; - for (UiMode value : values()) { - if (i == index) { - return value; - } - i++; - } - return null; - } - - @Override - public boolean isFakeValue() { - return this == NORMAL; // NORMAL is not a real enum. it's used for internal state only. - } - - @Override - public boolean isValidValueForDevice() { - return this != NORMAL; - } -} diff --git a/layoutlib_api/src/main/java/com/android/util/Pair.java b/layoutlib_api/src/main/java/com/android/util/Pair.java deleted file mode 100644 index 7e797e0..0000000 --- a/layoutlib_api/src/main/java/com/android/util/Pair.java +++ /dev/null @@ -1,116 +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.util; - -/** - * A Pair class is simply a 2-tuple for use in this package. We might want to - * think about adding something like this to a more central utility place, or - * replace it by a common tuple class if one exists, or even rewrite the layout - * classes using this Pair by a more dedicated data structure (so we don't have - * to pass around generic signatures as is currently done, though at least the - * construction is helped a bit by the {@link #of} factory method. - * - * ================================================================================================= - * WARNING - * This copy of the class is to be used only by layoutlib and is not to be changed, EVER. - * To use Pair outside of layoutlib, use com.android.utils.Pair, found in common.jar instead. - * ================================================================================================= - * - * @param <S> The type of the first value - * @param <T> The type of the second value - * - * @deprecated This is used for backward compatibility with layoutlib_api. Use com.android.utils.Pair instead - */ -@Deprecated -public class Pair<S,T> { - private final S mFirst; - private final T mSecond; - - // Use {@link Pair#of} factory instead since it infers generic types - private Pair(S first, T second) { - this.mFirst = first; - this.mSecond = second; - } - - /** - * Return the first item in the pair - * - * @return the first item in the pair - */ - public S getFirst() { - return mFirst; - } - - /** - * Return the second item in the pair - * - * @return the second item in the pair - */ - public T getSecond() { - return mSecond; - } - - /** - * Constructs a new pair of the given two objects, inferring generic types. - * - * @param first the first item to store in the pair - * @param second the second item to store in the pair - * @param <S> the type of the first item - * @param <T> the type of the second item - * @return a new pair wrapping the two items - */ - public static <S,T> Pair<S,T> of(S first, T second) { - return new Pair<S,T>(first,second); - } - - @Override - public String toString() { - return "Pair [first=" + mFirst + ", second=" + mSecond + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((mFirst == null) ? 0 : mFirst.hashCode()); - result = prime * result + ((mSecond == null) ? 0 : mSecond.hashCode()); - return result; - } - - @SuppressWarnings("unchecked") - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Pair other = (Pair) obj; - if (mFirst == null) { - if (other.mFirst != null) - return false; - } else if (!mFirst.equals(other.mFirst)) - return false; - if (mSecond == null) { - if (other.mSecond != null) - return false; - } else if (!mSecond.equals(other.mSecond)) - return false; - return true; - } -} diff --git a/layoutlib_api/src/test/.classpath b/layoutlib_api/src/test/.classpath deleted file mode 100644 index 7564f2f..0000000 --- a/layoutlib_api/src/test/.classpath +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="java"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/> - <classpathentry combineaccessrules="false" kind="src" path="/common"/> - <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/guava-tools/guava-13.0.1.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/guava-tools/src.zip"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/layoutlib_api/src/test/.project b/layoutlib_api/src/test/.project deleted file mode 100644 index 9f550a3..0000000 --- a/layoutlib_api/src/test/.project +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>common-tests</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/layoutlib_api/src/test/java/com/android/resources/FolderTypeRelationShipTest.java b/layoutlib_api/src/test/java/com/android/resources/FolderTypeRelationShipTest.java deleted file mode 100644 index 809eae7..0000000 --- a/layoutlib_api/src/test/java/com/android/resources/FolderTypeRelationShipTest.java +++ /dev/null @@ -1,44 +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.resources; - -import com.android.resources.FolderTypeRelationship; -import com.android.resources.ResourceFolderType; -import com.android.resources.ResourceType; - -import junit.framework.TestCase; - -public class FolderTypeRelationShipTest extends TestCase { - - public void testResourceType() { - // all resource type should be in the FolderTypeRelationShip map. - // loop on all the enum, and make sure there's at least one folder type for it. - for (ResourceType type : ResourceType.values()) { - assertTrue(type.getDisplayName(), - FolderTypeRelationship.getRelatedFolders(type).size() > 0); - } - } - - public void testResourceFolderType() { - // all resource folder type should generate at least one type of resource. - // loop on all the enum, and make sure there's at least one res type for it. - for (ResourceFolderType type : ResourceFolderType.values()) { - assertTrue(type.getName(), - FolderTypeRelationship.getRelatedResourceTypes(type).size() > 0); - } - } -} diff --git a/layoutlib_api/src/test/java/com/android/resources/ResourceFolderTypeTest.java b/layoutlib_api/src/test/java/com/android/resources/ResourceFolderTypeTest.java deleted file mode 100644 index a3c2c51..0000000 --- a/layoutlib_api/src/test/java/com/android/resources/ResourceFolderTypeTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2013 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.resources; - -import junit.framework.TestCase; - -public class ResourceFolderTypeTest extends TestCase { - public void test() { - assertEquals(ResourceFolderType.LAYOUT, ResourceFolderType.getFolderType("layout")); - assertEquals(ResourceFolderType.LAYOUT, ResourceFolderType.getFolderType("layout-port")); - assertEquals(ResourceFolderType.LAYOUT, ResourceFolderType.getFolderType("layout-port-sw600")); - assertEquals(ResourceFolderType.VALUES, ResourceFolderType.getFolderType("values")); - - assertNull(ResourceFolderType.getFolderType("")); - assertNull(ResourceFolderType.getFolderType("foo")); - } -} |