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 * Navigation enum. 21 * <p/>This is used in the manifest in the uses-configuration node and in the resource folder names. 22 */ 23 public enum Navigation implements ResourceEnum { 24 NONAV("nonav", "None", "No navigation"), //$NON-NLS-1$ 25 DPAD("dpad", "D-pad", "D-pad navigation"), //$NON-NLS-1$ 26 TRACKBALL("trackball", "Trackball", "Trackball navigation"), //$NON-NLS-1$ 27 WHEEL("wheel", "Wheel", "Wheel navigation"); //$NON-NLS-1$ 28 29 private final String mValue; 30 private final String mShortDisplayValue; 31 private final String mLongDisplayValue; 32 Navigation(String value, String shortDisplayValue, String longDisplayValue)33 private Navigation(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 Navigation getEnum(String value) { 45 for (Navigation nav : values()) { 46 if (nav.mValue.equals(value)) { 47 return nav; 48 } 49 } 50 51 return null; 52 } 53 54 @Override getResourceValue()55 public String getResourceValue() { 56 return mValue; 57 } 58 59 @Override getShortDisplayValue()60 public String getShortDisplayValue() { 61 return mShortDisplayValue; 62 } 63 64 @Override getLongDisplayValue()65 public String getLongDisplayValue() { 66 return mLongDisplayValue; 67 } 68 getIndex(Navigation value)69 public static int getIndex(Navigation value) { 70 int i = 0; 71 for (Navigation nav : values()) { 72 if (nav == value) { 73 return i; 74 } 75 76 i++; 77 } 78 79 return -1; 80 } 81 getByIndex(int index)82 public static Navigation getByIndex(int index) { 83 int i = 0; 84 for (Navigation value : values()) { 85 if (i == index) { 86 return value; 87 } 88 i++; 89 } 90 return null; 91 } 92 93 @Override isFakeValue()94 public boolean isFakeValue() { 95 return false; 96 } 97 98 @Override isValidValueForDevice()99 public boolean isValidValueForDevice() { 100 return true; 101 } 102 103 }