diff --git a/app/src/main/java/eur/cfpifpsi/titanboard/InputMethod.java b/app/src/main/java/eur/cfpifpsi/titanboard/InputMethod.java index 7ec536b..0d4595d 100644 --- a/app/src/main/java/eur/cfpifpsi/titanboard/InputMethod.java +++ b/app/src/main/java/eur/cfpifpsi/titanboard/InputMethod.java @@ -20,7 +20,6 @@ package eur.cfpifpsi.titanboard; import android.annotation.SuppressLint; import android.inputmethodservice.InputMethodService; -import android.os.Build; import android.os.Handler; import android.os.Looper; import android.os.Vibrator; @@ -86,41 +85,41 @@ public class InputMethod extends InputMethodService { mMetaKeyManager.updateMetaStateDown(keyCode); mInputView.updateStateText(); - switch (keyCode) { - case KeyEvent.KEYCODE_BACK: - if (isInputViewShown()) { - requestHideSelf(0); - return true; - } - return false; - case KeyEvent.KEYCODE_DEL: - case KeyEvent.KEYCODE_ENTER: - mMetaKeyManager.adjustMetaStateAfterKeypress(); - mInputView.updateStateText(); - return false; - default: - ArrayList symbols = mKeymapManager.getSymbols(keyCode, mMetaKeyManager); - InputConnection conn = getCurrentInputConnection(); - - if (symbols == null || conn == null) { - return false; - } - - if (event.getRepeatCount() == 0 && !symbols.isEmpty()) { - conn.commitText(symbols.get(0), 1); - mMetaKeyManager.adjustMetaStateAfterKeypress(); - mInputView.updateStateText(); - mHandler.removeCallbacksAndMessages(null); - - // If there's no symbols to cycle, why cycle at all? - if (symbols.size() > 1) { - mSymbolCycler.prepare(symbols); - mHandler.postDelayed(mSymbolCycler, mPreferenceHolder.getCycleSpeed()); - } - } - + if (keyCode == KeyEvent.KEYCODE_BACK) { + if (isInputViewShown()) { + requestHideSelf(0); return true; + } + return false; } + + if (keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_ENTER) { + mMetaKeyManager.adjustMetaStateAfterKeypress(); + mInputView.updateStateText(); + return false; + } + + ArrayList symbols = mKeymapManager.getSymbols(keyCode, mMetaKeyManager); + InputConnection conn = getCurrentInputConnection(); + + if (symbols == null || conn == null) { + return false; + } + + if (event.getRepeatCount() == 0 && !symbols.isEmpty()) { + conn.commitText(symbols.get(0), 1); + mMetaKeyManager.adjustMetaStateAfterKeypress(); + mInputView.updateStateText(); + mHandler.removeCallbacksAndMessages(null); + + // If there's no symbols to cycle, why cycle at all? + if (symbols.size() > 1) { + mSymbolCycler.prepare(symbols); + mHandler.postDelayed(mSymbolCycler, mPreferenceHolder.getCycleSpeed()); + } + } + + return true; } public boolean onKeyUp(int keyCode, KeyEvent event) {