| 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 |
* Keyboard enum. |
| 21 |
* <p>This is used in the manifest in the uses-configuration node and in the resource folder names. |
| 22 |
*/ |
| 23 |
public enum Keyboard implements ResourceEnum { |
| 24 |
NOKEY("nokeys", null, "No Keys", "No keyboard"), //$NON-NLS-1$ |
| 25 |
QWERTY("qwerty", null, "Qwerty", "Qwerty keyboard"), //$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 |
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 |
return value == null ? -1 : value.ordinal(); |
| 73 |
} |
| 74 |
|
| 75 |
public static Keyboard getByIndex(int index) { |
| 76 |
Keyboard[] values = values(); |
| 77 |
if (index >= 0 && index < values.length) { |
| 78 |
return values[index]; |
| 79 |
} |
| 80 |
return null; |
| 81 |
} |
| 82 |
|
| 83 |
@Override |
| 84 |
public boolean isFakeValue() { |
| 85 |
return false; |
| 86 |
} |
| 87 |
|
| 88 |
@Override |
| 89 |
public boolean isValidValueForDevice() { |
| 90 |
return true; |
| 91 |
} |
| 92 |
} |