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 Ratio enum. 21 * <p/>This is used in the manifest in the uses-configuration node and in the resource folder names. 22 */ 23 public enum ScreenRatio implements ResourceEnum { 24 NOTLONG("notlong", "Not Long", "Short screen aspect ratio"), //$NON-NLS-1$ 25 LONG("long", "Long", "Long screen aspect ratio"); //$NON-NLS-1$ 26 27 private final String mValue; 28 private final String mShortDisplayValue; 29 private final String mLongDisplayValue; 30 ScreenRatio(String value, String displayValue, String longDisplayValue)31 private ScreenRatio(String value, String displayValue, String longDisplayValue) { 32 mValue = value; 33 mShortDisplayValue = displayValue; 34 mLongDisplayValue = longDisplayValue; 35 } 36 37 /** 38 * Returns the enum for matching the provided qualifier value. 39 * @param value The qualifier value. 40 * @return the enum for the qualifier value or null if no matching was found. 41 */ getEnum(String value)42 public static ScreenRatio getEnum(String value) { 43 for (ScreenRatio orient : values()) { 44 if (orient.mValue.equals(value)) { 45 return orient; 46 } 47 } 48 49 return null; 50 } 51 52 @Override getResourceValue()53 public String getResourceValue() { 54 return mValue; 55 } 56 57 @Override getShortDisplayValue()58 public String getShortDisplayValue() { 59 return mShortDisplayValue; 60 } 61 62 @Override getLongDisplayValue()63 public String getLongDisplayValue() { 64 return mLongDisplayValue; 65 } 66 getIndex(ScreenRatio orientation)67 public static int getIndex(ScreenRatio orientation) { 68 int i = 0; 69 for (ScreenRatio orient : values()) { 70 if (orient == orientation) { 71 return i; 72 } 73 74 i++; 75 } 76 77 return -1; 78 } 79 getByIndex(int index)80 public static ScreenRatio getByIndex(int index) { 81 int i = 0; 82 for (ScreenRatio orient : values()) { 83 if (i == index) { 84 return orient; 85 } 86 i++; 87 } 88 89 return null; 90 } 91 92 @Override isFakeValue()93 public boolean isFakeValue() { 94 return false; 95 } 96 97 @Override isValidValueForDevice()98 public boolean isValidValueForDevice() { 99 return true; 100 } 101 102 } 103 104