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 getResourceValue()54 public String getResourceValue() { 55 return mValue; 56 } 57 getShortDisplayValue()58 public String getShortDisplayValue() { 59 return mShortDisplayValue; 60 } 61 getLongDisplayValue()62 public String getLongDisplayValue() { 63 return mLongDisplayValue; 64 } 65 getIndex(ScreenSize orientation)66 public static int getIndex(ScreenSize orientation) { 67 int i = 0; 68 for (ScreenSize orient : values()) { 69 if (orient == orientation) { 70 return i; 71 } 72 73 i++; 74 } 75 76 return -1; 77 } 78 getByIndex(int index)79 public static ScreenSize getByIndex(int index) { 80 int i = 0; 81 for (ScreenSize orient : values()) { 82 if (i == index) { 83 return orient; 84 } 85 i++; 86 } 87 88 return null; 89 } 90 isFakeValue()91 public boolean isFakeValue() { 92 return false; 93 } 94 isValidValueForDevice()95 public boolean isValidValueForDevice() { 96 return true; 97 } 98 99 } 100