Home | History | Annotate | Download | only in latin
      1 /*
      2  * Copyright (C) 2012 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.inputmethod.latin;
     18 
     19 public final class Constants {
     20     public static final class Color {
     21         /**
     22          * The alpha value for fully opaque.
     23          */
     24         public final static int ALPHA_OPAQUE = 255;
     25     }
     26 
     27     public static final class ImeOption {
     28         /**
     29          * The private IME option used to indicate that no microphone should be shown for a given
     30          * text field. For instance, this is specified by the search dialog when the dialog is
     31          * already showing a voice search button.
     32          *
     33          * @deprecated Use {@link ImeOption#NO_MICROPHONE} with package name prefixed.
     34          */
     35         @SuppressWarnings("dep-ann")
     36         public static final String NO_MICROPHONE_COMPAT = "nm";
     37 
     38         /**
     39          * The private IME option used to indicate that no microphone should be shown for a given
     40          * text field. For instance, this is specified by the search dialog when the dialog is
     41          * already showing a voice search button.
     42          */
     43         public static final String NO_MICROPHONE = "noMicrophoneKey";
     44 
     45         /**
     46          * The private IME option used to indicate that no settings key should be shown for a given
     47          * text field.
     48          */
     49         public static final String NO_SETTINGS_KEY = "noSettingsKey";
     50 
     51         /**
     52          * The private IME option used to indicate that the given text field needs ASCII code points
     53          * input.
     54          *
     55          * @deprecated Use EditorInfo#IME_FLAG_FORCE_ASCII.
     56          */
     57         @SuppressWarnings("dep-ann")
     58         public static final String FORCE_ASCII = "forceAscii";
     59 
     60         private ImeOption() {
     61             // This utility class is not publicly instantiable.
     62         }
     63     }
     64 
     65     public static final class Subtype {
     66         /**
     67          * The subtype mode used to indicate that the subtype is a keyboard.
     68          */
     69         public static final String KEYBOARD_MODE = "keyboard";
     70 
     71         public static final class ExtraValue {
     72             /**
     73              * The subtype extra value used to indicate that the subtype keyboard layout is capable
     74              * for typing ASCII characters.
     75              */
     76             public static final String ASCII_CAPABLE = "AsciiCapable";
     77 
     78             /**
     79              * The subtype extra value used to indicate that the subtype require network connection
     80              * to work.
     81              */
     82             public static final String REQ_NETWORK_CONNECTIVITY = "requireNetworkConnectivity";
     83 
     84             /**
     85              * The subtype extra value used to indicate that the subtype display name contains "%s"
     86              * for replacement mark and it should be replaced by this extra value.
     87              * This extra value is supported on JellyBean and later.
     88              */
     89             public static final String UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME =
     90                     "UntranslatableReplacementStringInSubtypeName";
     91 
     92             /**
     93              * The subtype extra value used to indicate that the subtype keyboard layout set name.
     94              * This extra value is private to LatinIME.
     95              */
     96             public static final String KEYBOARD_LAYOUT_SET = "KeyboardLayoutSet";
     97 
     98             /**
     99              * The subtype extra value used to indicate that the subtype is additional subtype
    100              * that the user defined. This extra value is private to LatinIME.
    101              */
    102             public static final String IS_ADDITIONAL_SUBTYPE = "isAdditionalSubtype";
    103 
    104             private ExtraValue() {
    105                 // This utility class is not publicly instantiable.
    106             }
    107         }
    108 
    109         private Subtype() {
    110             // This utility class is not publicly instantiable.
    111         }
    112     }
    113 
    114     public static final class TextUtils {
    115         /**
    116          * Capitalization mode for {@link android.text.TextUtils#getCapsMode}: don't capitalize
    117          * characters.  This value may be used with
    118          * {@link android.text.TextUtils#CAP_MODE_CHARACTERS},
    119          * {@link android.text.TextUtils#CAP_MODE_WORDS}, and
    120          * {@link android.text.TextUtils#CAP_MODE_SENTENCES}.
    121          */
    122         public static final int CAP_MODE_OFF = 0;
    123 
    124         private TextUtils() {
    125             // This utility class is not publicly instantiable.
    126         }
    127     }
    128 
    129     public static final class Dictionary {
    130         // Must be equal to MAX_WORD_LENGTH in native/jni/src/defines.h
    131         public static final int MAX_WORD_LENGTH = 48;
    132 
    133         private Dictionary() {
    134              // This utility class is no publicly instantiable.
    135         }
    136     }
    137 
    138     public static final int NOT_A_CODE = -1;
    139 
    140     public static final int NOT_A_COORDINATE = -1;
    141     public static final int SUGGESTION_STRIP_COORDINATE = -2;
    142     public static final int SPELL_CHECKER_COORDINATE = -3;
    143     public static final int EXTERNAL_KEYBOARD_COORDINATE = -4;
    144 
    145     public static boolean isValidCoordinate(final int coordinate) {
    146         // Detect {@link NOT_A_COORDINATE}, {@link SUGGESTION_STRIP_COORDINATE},
    147         // and {@link SPELL_CHECKER_COORDINATE}.
    148         return coordinate >= 0;
    149     }
    150 
    151     /**
    152      * Some common keys code. Must be positive.
    153      */
    154     public static final int CODE_ENTER = '\n';
    155     public static final int CODE_TAB = '\t';
    156     public static final int CODE_SPACE = ' ';
    157     public static final int CODE_PERIOD = '.';
    158     public static final int CODE_DASH = '-';
    159     public static final int CODE_SINGLE_QUOTE = '\'';
    160     public static final int CODE_DOUBLE_QUOTE = '"';
    161     public static final int CODE_QUESTION_MARK = '?';
    162     public static final int CODE_EXCLAMATION_MARK = '!';
    163     public static final int CODE_SLASH = '/';
    164     public static final int CODE_COMMERCIAL_AT = '@';
    165     // TODO: Check how this should work for right-to-left languages. It seems to stand
    166     // that for rtl languages, a closing parenthesis is a left parenthesis. Is this
    167     // managed by the font? Or is it a different char?
    168     public static final int CODE_CLOSING_PARENTHESIS = ')';
    169     public static final int CODE_CLOSING_SQUARE_BRACKET = ']';
    170     public static final int CODE_CLOSING_CURLY_BRACKET = '}';
    171     public static final int CODE_CLOSING_ANGLE_BRACKET = '>';
    172 
    173     /**
    174      * Special keys code. Must be negative.
    175      * These should be aligned with KeyboardCodesSet.ID_TO_NAME[],
    176      * KeyboardCodesSet.DEFAULT[] and KeyboardCodesSet.RTL[]
    177      */
    178     public static final int CODE_SHIFT = -1;
    179     public static final int CODE_SWITCH_ALPHA_SYMBOL = -2;
    180     public static final int CODE_OUTPUT_TEXT = -3;
    181     public static final int CODE_DELETE = -4;
    182     public static final int CODE_SETTINGS = -5;
    183     public static final int CODE_SHORTCUT = -6;
    184     public static final int CODE_ACTION_NEXT = -7;
    185     public static final int CODE_ACTION_PREVIOUS = -8;
    186     public static final int CODE_LANGUAGE_SWITCH = -9;
    187     public static final int CODE_RESEARCH = -10;
    188     public static final int CODE_SHIFT_ENTER = -11;
    189     // Code value representing the code is not specified.
    190     public static final int CODE_UNSPECIFIED = -12;
    191 
    192     public static boolean isLetterCode(final int code) {
    193         return code >= CODE_SPACE;
    194     }
    195 
    196     public static String printableCode(final int code) {
    197         switch (code) {
    198         case CODE_SHIFT: return "shift";
    199         case CODE_SWITCH_ALPHA_SYMBOL: return "symbol";
    200         case CODE_OUTPUT_TEXT: return "text";
    201         case CODE_DELETE: return "delete";
    202         case CODE_SETTINGS: return "settings";
    203         case CODE_SHORTCUT: return "shortcut";
    204         case CODE_ACTION_NEXT: return "actionNext";
    205         case CODE_ACTION_PREVIOUS: return "actionPrevious";
    206         case CODE_LANGUAGE_SWITCH: return "languageSwitch";
    207         case CODE_UNSPECIFIED: return "unspec";
    208         case CODE_TAB: return "tab";
    209         case CODE_ENTER: return "enter";
    210         case CODE_RESEARCH: return "research";
    211         default:
    212             if (code < CODE_SPACE) return String.format("'\\u%02x'", code);
    213             if (code < 0x100) return String.format("'%c'", code);
    214             return String.format("'\\u%04x'", code);
    215         }
    216     }
    217 
    218     // Constants for CSV parsing.
    219     public static final char CSV_SEPARATOR = ',';
    220     public static final char CSV_ESCAPE = '\\';
    221 
    222     private Constants() {
    223         // This utility class is not publicly instantiable.
    224     }
    225 }
    226