diff options
author | Xavier Ducrohet <xav@android.com> | 2011-02-24 20:27:07 -0800 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2011-02-24 20:40:37 -0800 |
commit | 868a7bbe7c5862c02483ef8f71276fc551d40d60 (patch) | |
tree | 01d90d7d0e49cf59c2fedc727230b50b8f8168d5 /common | |
parent | c3105b949cd2a0f6cbf8a12ec4f30e49b5b5a502 (diff) | |
download | sdk-868a7bbe7c5862c02483ef8f71276fc551d40d60.zip sdk-868a7bbe7c5862c02483ef8f71276fc551d40d60.tar.gz sdk-868a7bbe7c5862c02483ef8f71276fc551d40d60.tar.bz2 |
Move ResourceFolderType into common.
Moved some constants from sdklib (which is not a dependency
of common but instead depends on common) into common.
Change-Id: I6fdfbad4e77813a9f2a2ca9ea0d740692d8bce5b
Diffstat (limited to 'common')
-rw-r--r-- | common/src/com/android/AndroidConstants.java | 50 | ||||
-rw-r--r-- | common/src/com/android/resources/ResourceFolderType.java | 78 | ||||
-rw-r--r-- | common/src/com/android/resources/ResourceType.java | 4 |
3 files changed, 130 insertions, 2 deletions
diff --git a/common/src/com/android/AndroidConstants.java b/common/src/com/android/AndroidConstants.java new file mode 100644 index 0000000..dfe137a --- /dev/null +++ b/common/src/com/android/AndroidConstants.java @@ -0,0 +1,50 @@ +/* + * 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; + +/** + * Generic Android Constants. + */ +public class AndroidConstants { + + /** 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/common/src/com/android/resources/ResourceFolderType.java b/common/src/com/android/resources/ResourceFolderType.java new file mode 100644 index 0000000..3a5b64d --- /dev/null +++ b/common/src/com/android/resources/ResourceFolderType.java @@ -0,0 +1,78 @@ +/* + * 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 com.android.AndroidConstants; + +/** + * Enum representing a type of resource folder. + */ +public enum ResourceFolderType { + ANIM(AndroidConstants.FD_RES_ANIM), + ANIMATOR(AndroidConstants.FD_RES_ANIMATOR), + COLOR(AndroidConstants.FD_RES_COLOR), + DRAWABLE(AndroidConstants.FD_RES_DRAWABLE), + INTERPOLATOR(AndroidConstants.FD_RES_INTERPOLATOR), + LAYOUT(AndroidConstants.FD_RES_LAYOUT), + MENU(AndroidConstants.FD_RES_MENU), + MIPMAP(AndroidConstants.FD_RES_MIPMAP), + RAW(AndroidConstants.FD_RES_RAW), + VALUES(AndroidConstants.FD_RES_VALUES), + XML(AndroidConstants.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) { + 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) { + // split the name of the folder in segments. + String[] folderSegments = folderName.split(AndroidConstants.RES_QUALIFIER_SEP); + + // get the enum for the resource type. + return getTypeByName(folderSegments[0]); + } +} diff --git a/common/src/com/android/resources/ResourceType.java b/common/src/com/android/resources/ResourceType.java index a4d3aa2..e9d4d53 100644 --- a/common/src/com/android/resources/ResourceType.java +++ b/common/src/com/android/resources/ResourceType.java @@ -1,11 +1,11 @@ /* * Copyright (C) 2007 The Android Open Source Project * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); + * 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.eclipse.org/org/documents/epl-v10.php + * 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, |