Home | History | Annotate | Download | only in resources
      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 
     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      */
     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     public String getResourceValue() {
     55         return mValue;
     56     }
     57 
     58     public String getShortDisplayValue() {
     59         return mShortDisplayValue;
     60     }
     61 
     62     public String getLongDisplayValue() {
     63         return mLongDisplayValue;
     64     }
     65 
     66     public static int getIndex(Navigation value) {
     67         int i = 0;
     68         for (Navigation nav : values()) {
     69             if (nav == value) {
     70                 return i;
     71             }
     72 
     73             i++;
     74         }
     75 
     76         return -1;
     77     }
     78 
     79     public static Navigation getByIndex(int index) {
     80         int i = 0;
     81         for (Navigation value : values()) {
     82             if (i == index) {
     83                 return value;
     84             }
     85             i++;
     86         }
     87         return null;
     88     }
     89 
     90     public boolean isFakeValue() {
     91         return false;
     92     }
     93 
     94     public boolean isValidValueForDevice() {
     95         return true;
     96     }
     97 
     98 }