aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2012-01-31 17:15:24 +0900
committerTadashi G. Takaoka <takaoka@google.com>2012-01-31 18:27:37 +0900
commit88e079ae6bbff1093b28f60e81d2befce1030495 (patch)
tree73545fccff7221900340c228005fb3efeff5fb96 /java/src
parent0ed2d3a4491cb0f6142975a15b653be6079b6a4e (diff)
downloadlatinime-88e079ae6bbff1093b28f60e81d2befce1030495.tar.gz
latinime-88e079ae6bbff1093b28f60e81d2befce1030495.tar.xz
latinime-88e079ae6bbff1093b28f60e81d2befce1030495.zip
Cleanup redundant methods of KeyboardSet
Change-Id: I69fa1b5661695d0323222c2969679f4792b6ef0d
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSet.java23
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java9
2 files changed, 18 insertions, 14 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSet.java b/java/src/com/android/inputmethod/keyboard/KeyboardSet.java
index 0aed5068c..d35948bad 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSet.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSet.java
@@ -59,6 +59,14 @@ public class KeyboardSet {
private final Params mParams;
private final KeysCache mKeysCache = new KeysCache();
+ public static class KeyboardSetException extends RuntimeException {
+ public final KeyboardId mKeyboardId;
+ public KeyboardSetException(Throwable cause, KeyboardId keyboardId) {
+ super(cause);
+ mKeyboardId = keyboardId;
+ }
+ }
+
public static class KeysCache {
private final Map<Key, Key> mMap;
@@ -107,11 +115,6 @@ public class KeyboardSet {
mParams = params;
}
- // TODO: Remove this method, use {@link #getKeyboard} directly.
- public Keyboard getMainKeyboard() {
- return getKeyboard(KeyboardId.ELEMENT_ALPHABET);
- }
-
public Keyboard getKeyboard(int baseKeyboardSetElementId) {
final int keyboardSetElementId;
switch (mParams.mMode) {
@@ -134,8 +137,11 @@ public class KeyboardSet {
KeyboardId.ELEMENT_ALPHABET);
}
final KeyboardId id = getKeyboardId(keyboardSetElementId);
- final Keyboard keyboard = getKeyboard(mContext, keyboardXmlId, id);
- return keyboard;
+ try {
+ return getKeyboard(mContext, keyboardXmlId, id);
+ } catch (RuntimeException e) {
+ throw new KeyboardSetException(e, id);
+ }
}
private Keyboard getKeyboard(Context context, int keyboardXmlId, KeyboardId id) {
@@ -169,11 +175,10 @@ public class KeyboardSet {
return keyboard;
}
- // TODO: Make this method private.
// Note: The keyboard for each locale, shift state, and mode are represented as KeyboardSet
// element id that is a key in keyboard_set.xml. Also that file specifies which XML layout
// should be used for each keyboard. The KeyboardId is an internal key for Keyboard object.
- public KeyboardId getKeyboardId(int keyboardSetElementId) {
+ private KeyboardId getKeyboardId(int keyboardSetElementId) {
final Params params = mParams;
final boolean isSymbols = (keyboardSetElementId == KeyboardId.ELEMENT_SYMBOLS
|| keyboardSetElementId == KeyboardId.ELEMENT_SYMBOLS_SHIFTED);
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index d5ea76a2f..df7296bb9 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -27,6 +27,7 @@ import android.view.View;
import android.view.inputmethod.EditorInfo;
import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
+import com.android.inputmethod.keyboard.KeyboardSet.KeyboardSetException;
import com.android.inputmethod.keyboard.PointerTracker.TimerProxy;
import com.android.inputmethod.keyboard.internal.KeyboardState;
import com.android.inputmethod.latin.DebugSettings;
@@ -138,11 +139,9 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
mKeyboardSet = builder.build();
try {
mState.onLoadKeyboard(mResources.getString(R.string.layout_switch_back_symbols));
- } catch (RuntimeException e) {
- Log.w(TAG, "loading keyboard failed: " + mKeyboardSet.getKeyboardId(
- KeyboardId.ELEMENT_ALPHABET), e);
- LatinImeLogger.logOnException(mKeyboardSet.getKeyboardId(
- KeyboardId.ELEMENT_ALPHABET).toString(), e);
+ } catch (KeyboardSetException e) {
+ Log.w(TAG, "loading keyboard failed: " + e.mKeyboardId, e.getCause());
+ LatinImeLogger.logOnException(e.mKeyboardId.toString(), e.getCause());
return;
}
}