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