| 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 |
* Touch screen enum. |
| 21 |
* <p>This is used in the manifest in the uses-configuration node and in the resource folder names. |
| 22 |
*/ |
| 23 |
public enum TouchScreen implements ResourceEnum { |
| 24 |
NOTOUCH("notouch", "No Touch", "No-touch screen"), //$NON-NLS-1$ |
| 25 |
STYLUS("stylus", "Stylus", "Stylus-based touchscreen"), //$NON-NLS-1$ |
| 26 |
FINGER("finger", "Finger", "Finger-based touchscreen"); //$NON-NLS-1$ |
| 27 |
|
| 28 |
private final String mValue; |
| 29 |
private final String mShortDisplayValue; |
| 30 |
private final String mLongDisplayValue; |
| 31 |
|
| 32 |
TouchScreen(String value, String displayValue, String longDisplayValue) { |
| 33 |
mValue = value; |
| 34 |
mShortDisplayValue = displayValue; |
| 35 |
mLongDisplayValue = longDisplayValue; |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Returns the enum for matching the provided qualifier value. |
| 40 |
* @param value The qualifier value. |
| 41 |
* @return the enum for the qualifier value or null if no matching was found. |
| 42 |
*/ |
| 43 |
public static TouchScreen getEnum(String value) { |
| 44 |
for (TouchScreen orient : values()) { |
| 45 |
if (orient.mValue.equals(value)) { |
| 46 |
return orient; |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
return null; |
| 51 |
} |
| 52 |
|
| 53 |
@Override |
| 54 |
public String getResourceValue() { |
| 55 |
return mValue; |
| 56 |
} |
| 57 |
|
| 58 |
@Override |
| 59 |
public String getShortDisplayValue() { |
| 60 |
return mShortDisplayValue; |
| 61 |
} |
| 62 |
|
| 63 |
@Override |
| 64 |
public String getLongDisplayValue() { |
| 65 |
return mLongDisplayValue; |
| 66 |
} |
| 67 |
|
| 68 |
public static int getIndex(TouchScreen touch) { |
| 69 |
return touch == null ? -1 : touch.ordinal(); |
| 70 |
} |
| 71 |
|
| 72 |
public static TouchScreen getByIndex(int index) { |
| 73 |
TouchScreen[] values = values(); |
| 74 |
if (index >= 0 && index < values.length) { |
| 75 |
return values[index]; |
| 76 |
} |
| 77 |
return null; |
| 78 |
} |
| 79 |
|
| 80 |
@Override |
| 81 |
public boolean isFakeValue() { |
| 82 |
return false; |
| 83 |
} |
| 84 |
|
| 85 |
@Override |
| 86 |
public boolean isValidValueForDevice() { |
| 87 |
return true; |
| 88 |
} |
| 89 |
|
| 90 |
} |