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 17package com.android.resources; 18 19/** 20 * Keyboard enum. 21 * <p/>This is used in the manifest in the uses-configuration node and in the resource folder names. 22 */ 23public enum Keyboard implements ResourceEnum { 24 NOKEY("nokeys", null, "No Keys", "No keyboard"), //$NON-NLS-1$ 25 QWERTY("qwerty", null, "Qwerty", "Qwerty keybard"), //$NON-NLS-1$ 26 TWELVEKEY("12key", "twelvekey", "12 Key", "12 key keyboard"); //$NON-NLS-1$ //$NON-NLS-2$ 27 28 private final String mValue, mValue2; 29 private final String mShortDisplayValue; 30 private final String mLongDisplayValue; 31 32 private Keyboard(String value, String value2, String shortDisplayValue, 33 String longDisplayValue) { 34 mValue = value; 35 mValue2 = value2; 36 mShortDisplayValue = shortDisplayValue; 37 mLongDisplayValue = longDisplayValue; 38 } 39 40 /** 41 * Returns the enum for matching the provided qualifier value. 42 * @param value The qualifier value. 43 * @return the enum for the qualifier value or null if no matching was found. 44 */ 45 public static Keyboard getEnum(String value) { 46 for (Keyboard kbrd : values()) { 47 if (kbrd.mValue.equals(value) || 48 (kbrd.mValue2 != null && kbrd.mValue2.equals(value))) { 49 return kbrd; 50 } 51 } 52 53 return null; 54 } 55 56 @Override 57 public String getResourceValue() { 58 return mValue; 59 } 60 61 @Override 62 public String getShortDisplayValue() { 63 return mShortDisplayValue; 64 } 65 66 @Override 67 public String getLongDisplayValue() { 68 return mLongDisplayValue; 69 } 70 71 public static int getIndex(Keyboard value) { 72 int i = 0; 73 for (Keyboard input : values()) { 74 if (value == input) { 75 return i; 76 } 77 78 i++; 79 } 80 81 return -1; 82 } 83 84 public static Keyboard getByIndex(int index) { 85 int i = 0; 86 for (Keyboard value : values()) { 87 if (i == index) { 88 return value; 89 } 90 i++; 91 } 92 return null; 93 } 94 95 @Override 96 public boolean isFakeValue() { 97 return false; 98 } 99 100 @Override 101 public boolean isValidValueForDevice() { 102 return true; 103 } 104} 105