diff options
Diffstat (limited to 'layoutlib_api/src/main/java/com/android/resources')
17 files changed, 0 insertions, 1730 deletions
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; - } -} |