• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 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.spellcheck;
18 
19 import com.android.inputmethod.latin.Dictionary;
20 import com.android.inputmethod.keyboard.Keyboard;
21 import com.android.inputmethod.keyboard.KeyboardId;
22 import com.android.inputmethod.keyboard.KeyboardLayoutSet;
23 import com.android.inputmethod.keyboard.ProximityInfo;
24 
25 /**
26  * A container for a Dictionary and a Keyboard.
27  */
28 public final class DictAndKeyboard {
29     public final Dictionary mDictionary;
30     private final Keyboard mKeyboard;
31     private final Keyboard mManualShiftedKeyboard;
32 
DictAndKeyboard( final Dictionary dictionary, final KeyboardLayoutSet keyboardLayoutSet)33     public DictAndKeyboard(
34             final Dictionary dictionary, final KeyboardLayoutSet keyboardLayoutSet) {
35         mDictionary = dictionary;
36         if (keyboardLayoutSet == null) {
37             mKeyboard = null;
38             mManualShiftedKeyboard = null;
39             return;
40         }
41         mKeyboard = keyboardLayoutSet.getKeyboard(KeyboardId.ELEMENT_ALPHABET);
42         mManualShiftedKeyboard =
43                 keyboardLayoutSet.getKeyboard(KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED);
44     }
45 
getKeyboard(final int codePoint)46     public Keyboard getKeyboard(final int codePoint) {
47         if (mKeyboard == null) {
48             return null;
49         }
50         return mKeyboard.getKey(codePoint) != null ? mKeyboard : mManualShiftedKeyboard;
51     }
52 
getProximityInfo()53     public ProximityInfo getProximityInfo() {
54         return mKeyboard == null ? null : mKeyboard.getProximityInfo();
55     }
56 }
57