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