From faf704bc673f2ef2c00059cf521e76c56b8eb2a0 Mon Sep 17 00:00:00 2001 From: Clam Date: Sun, 30 Mar 2014 16:34:51 +1100 Subject: [PATCH] Added mode change notifications --- res/values-ru/arrays.xml | 11 +++++ res/values/arrays.xml | 11 +++++ res/values/strings.xml | 3 ++ res/xml/prefs.xml | 7 +++ .../android/traditionalt9/TraditionalT9.java | 43 ++++++++++++++++--- 5 files changed, 70 insertions(+), 5 deletions(-) diff --git a/res/values-ru/arrays.xml b/res/values-ru/arrays.xml index 1e467d8a..dc780296 100644 --- a/res/values-ru/arrays.xml +++ b/res/values-ru/arrays.xml @@ -22,6 +22,17 @@ 1 + + нижний регистр + Первая заглавная + Все заглавные + + + + Словарь + буквы + цифры + улыбка diff --git a/res/values/arrays.xml b/res/values/arrays.xml index fd14352e..d03349ee 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -23,6 +23,17 @@ 1 + + Caps off + Single capital + All caps + + + + Dictionary + Text + Number + Smile diff --git a/res/values/strings.xml b/res/values/strings.xml index 7cb4867c..11b1368a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -50,6 +50,9 @@ Query test Test func + Mode notifications + Used for vocalization of mode changes + Loading dictionary… Loading user dictionary… Load IME dictionary diff --git a/res/xml/prefs.xml b/res/xml/prefs.xml index 14c35f1c..1754fddf 100644 --- a/res/xml/prefs.xml +++ b/res/xml/prefs.xml @@ -19,6 +19,13 @@ android:key="pref_lang_support" android:persistent="true" android:title="@string/pref_lang_title" /> + diff --git a/src/org/nyanya/android/traditionalt9/TraditionalT9.java b/src/org/nyanya/android/traditionalt9/TraditionalT9.java index 0a229b42..1a9eeb0a 100644 --- a/src/org/nyanya/android/traditionalt9/TraditionalT9.java +++ b/src/org/nyanya/android/traditionalt9/TraditionalT9.java @@ -8,6 +8,7 @@ import java.util.List; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; +import android.content.res.Resources; import android.inputmethodservice.InputMethodService; import android.inputmethodservice.KeyboardView; import android.os.Handler; @@ -89,6 +90,9 @@ public class TraditionalT9 extends InputMethodService implements private int mKeyMode; private SharedPreferences pref; + + private Toast modeNotification = null; + /** * Main initialization of the input method component. Be sure to call to * super class. @@ -112,8 +116,7 @@ public class TraditionalT9 extends InputMethodService implements @Override public boolean onEvaluateInputViewShown() { Log.d("T9.onEvaluateInputViewShown", "whatis"); - Log.d("T9.onEval", "fullscreen?: " + isFullscreenMode() + " isshow?: " + isInputViewShown() + " isrequestedshow?: " + isShowInputRequested()); - Log.d("T9.onEval", "noshow?: " + mEditing); + //Log.d("T9.onEval", "fullscreen?: " + isFullscreenMode() + " isshow?: " + isInputViewShown() + " isrequestedshow?: " + isShowInputRequested()); if (mEditing == EDITING_NOSHOW) { return false; } @@ -226,9 +229,9 @@ public class TraditionalT9 extends InputMethodService implements @Override public void onStartInput(EditorInfo attribute, boolean restarting) { super.onStartInput(attribute, restarting); - Log.d("onStartInput", "attribute.inputType: " + attribute.inputType + - " restarting? " + restarting); - Utils.printFlags(attribute.inputType); + //Log.d("onStartInput", "attribute.inputType: " + attribute.inputType + + // " restarting? " + restarting); + //Utils.printFlags(attribute.inputType); if (attribute.inputType == 0) { // don't do anything when not in any kind of edit field. @@ -259,6 +262,13 @@ public class TraditionalT9 extends InputMethodService implements mKeyMode = MODE_TEXT; + boolean modenotify = pref.getBoolean("pref_mode_notify", false); + if (!modenotify && modeNotification != null) { + modeNotification = null; + } else if (modenotify && modeNotification == null){ + modeNotification = Toast.makeText(this, "", Toast.LENGTH_SHORT); + } + // We are now going to initialize our state based on the type of // text being edited. switch (attribute.inputType & InputType.TYPE_MASK_CLASS) { @@ -350,6 +360,15 @@ public class TraditionalT9 extends InputMethodService implements prefedit.remove("last_word"); prefedit.commit(); } + if (modenotify) { + Resources r = getResources(); + if (mKeyMode != MODE_NUM) + modeNotify(String.format("%s %s %s", r.getStringArray(R.array.pref_lang_titles)[mLang], + r.getStringArray(R.array.keyMode)[mKeyMode], r.getStringArray(R.array.capsMode)[mCapsMode])); + else + modeNotify(String.format("%s %s", r.getStringArray(R.array.pref_lang_titles)[mLang], + r.getStringArray(R.array.keyMode)[mKeyMode])); + } } // Update the label on the enter key, depending on what the application @@ -1076,6 +1095,8 @@ public class TraditionalT9 extends InputMethodService implements getCurrentInputConnection().setComposingText(mComposing, 1); } updateKeyMode(); + if (modeNotification != null) + modeNotify(getResources().getStringArray(R.array.capsMode)[mCapsMode]); } /** @@ -1273,6 +1294,15 @@ public class TraditionalT9 extends InputMethodService implements } updateKeyMode(); resetKeyMode(); + if (modeNotification != null) + modeNotify(getResources().getStringArray(R.array.keyMode)[mKeyMode]); + } + + private void modeNotify(String s) { + modeNotification.setText(s); + modeNotification.show(); + modeNotification.cancel(); // TODO: This will not always hide the Toast. + // will probably need to implement custom view } private void nextLang() { @@ -1282,6 +1312,9 @@ public class TraditionalT9 extends InputMethodService implements } mLang = mLangsAvailable[mLangIndex]; updateKeyMode(); + if (modeNotification != null) { + modeNotify(getResources().getStringArray(R.array.pref_lang_titles)[mLang]); + } } private void resetKeyMode() {