Added mode change notifications
This commit is contained in:
parent
7b5f1f7369
commit
faf704bc67
5 changed files with 70 additions and 5 deletions
|
|
@ -22,6 +22,17 @@
|
|||
<item>1</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="capsMode">
|
||||
<item>нижний регистр</item>
|
||||
<item>Первая заглавная</item>
|
||||
<item>Все заглавные</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="keyMode">
|
||||
<item>Словарь</item>
|
||||
<item>буквы</item>
|
||||
<item>цифры</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="smileyContentDescription">
|
||||
<item>улыбка</item>
|
||||
|
|
|
|||
|
|
@ -23,6 +23,17 @@
|
|||
<item >1</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="capsMode">
|
||||
<item>Caps off</item>
|
||||
<item>Single capital</item>
|
||||
<item>All caps</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="keyMode">
|
||||
<item>Dictionary</item>
|
||||
<item>Text</item>
|
||||
<item>Number</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="smileyContentDescription">
|
||||
<item> Smile </item>
|
||||
|
|
|
|||
|
|
@ -50,6 +50,9 @@
|
|||
<string name="pref_querytest">Query test</string>
|
||||
<string name="pref_testfunc">Test func</string>
|
||||
|
||||
<string name="pref_mode_notify">Mode notifications</string>
|
||||
<string name="pref_mode_notify_subtitle">Used for vocalization of mode changes</string>
|
||||
|
||||
<string name="pref_loadingdict">Loading dictionary…</string>
|
||||
<string name="pref_loadinguserdict">Loading user dictionary…</string>
|
||||
<string name="pref_load_title">Load IME dictionary</string>
|
||||
|
|
|
|||
|
|
@ -19,6 +19,13 @@
|
|||
android:key="pref_lang_support"
|
||||
android:persistent="true"
|
||||
android:title="@string/pref_lang_title" />
|
||||
<CheckBoxPreference
|
||||
android:key="pref_mode_notify"
|
||||
android:title="@string/pref_mode_notify"
|
||||
android:summary="@string/pref_mode_notify_subtitle"
|
||||
android:persistent="true"
|
||||
android:defaultValue="false"
|
||||
/>
|
||||
<Preference android:title="@string/pref_loaddict" android:key="loaddict"/>
|
||||
<Preference android:title="@string/pref_loaduserdict" android:summary="@string/pref_loaduserdictdesc" android:key="loaduserdict"/>
|
||||
<Preference android:title="@string/pref_nukedict" android:key="nukedict"/>
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue