1 /* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.resources; 18 19 /** 20 * Screen size enum. 21 * <p/>This is used in the manifest in the uses-configuration node and in the resource folder names. 22 */ 23 public enum ScreenSize implements ResourceEnum { 24 SMALL("small", "Small", "Small Screen"), //$NON-NLS-1$ 25 NORMAL("normal", "Normal", "Normal Screen"), //$NON-NLS-1$ 26 LARGE("large", "Large", "Large Screen"), //$NON-NLS-1$ 27 XLARGE("xlarge", "X-Large", "Extra Large Screen"); //$NON-NLS-1$ 28 29 private final String mValue; 30 private final String mShortDisplayValue; 31 private final String mLongDisplayValue; 32 ScreenSize(String value, String shortDisplayValue, String longDisplayValue)33 private ScreenSize(String value, String shortDisplayValue, String longDisplayValue) { 34 mValue = value; 35 mShortDisplayValue = shortDisplayValue; 36 mLongDisplayValue = longDisplayValue; 37 } 38 39 /** 40 * Returns the enum for matching the provided qualifier value. 41 * @param value The qualifier value. 42 * @return the enum for the qualifier value or null if no matching was found. 43 */ getEnum(String value)44 public static ScreenSize getEnum(String value) { 45 for (ScreenSize orient : values()) { 46 if (orient.mValue.equals(value)) { 47 return orient; 48 } 49 } 50 51 return null; 52 } 53 54 @Override getResourceValue()55 public String getResourceValue() { 56 return mValue; 57 } 58 59 @Override getShortDisplayValue()60 public String getShortDisplayValue() { 61 return mShortDisplayValue; 62 } 63 64 @Override getLongDisplayValue()65 public String getLongDisplayValue() { 66 return mLongDisplayValue; 67 } 68 getIndex(ScreenSize orientation)69 public static int getIndex(ScreenSize orientation) { 70 int i = 0; 71 for (ScreenSize orient : values()) { 72 if (orient == orientation) { 73 return i; 74 } 75 76 i++; 77 } 78 79 return -1; 80 } 81 getByIndex(int index)82 public static ScreenSize getByIndex(int index) { 83 int i = 0; 84 for (ScreenSize orient : values()) { 85 if (i == index) { 86 return orient; 87 } 88 i++; 89 } 90 91 return null; 92 } 93 94 @Override isFakeValue()95 public boolean isFakeValue() { 96 return false; 97 } 98 99 @Override isValidValueForDevice()100 public boolean isValidValueForDevice() { 101 return true; 102 } 103 104 } 105