* Added "Space on Zero" option to address #5 * Implemented quick and simple fix for #11 * Expanded remapping feature. Can remap just IME keys or OSwide.
This commit is contained in:
parent
1b15cd0928
commit
e08c4a4fde
9 changed files with 253 additions and 169 deletions
|
|
@ -70,6 +70,12 @@
|
|||
<string name="pref_nuke_title">Nuke IME dictionary</string>
|
||||
<string name="pref_reloadKeys">Reload KeyMap</string>
|
||||
<string name="pref_reloadKeysSum" translatable="false">Force reload of key mapping overrides</string>
|
||||
<string name="pref_reloadKeysDone" translatable="false">Reload complete.</string>
|
||||
<string name="pref_reloadKeysDoneWE" translatable="false">Reload complete with errors (check logcat.)</string>
|
||||
<string name="pref_reloadKeysNoFile" translatable="false">No keymap.txt file found.</string>
|
||||
<string name="pref_keyRemap" translatable="false">Translate keys</string>
|
||||
<string name="pref_keyRemapSum" translatable="false">Enable to send translated keys to apps, otherwise keymap is for IME only.</string>
|
||||
<string name="pref_spaceOnZero" translatable="false">Space on 0 key</string>
|
||||
|
||||
<string name="hello_world">Hello world!</string>
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,12 @@
|
|||
entries="@array/pref_lang_titles"
|
||||
entryValues="@array/pref_lang_values"
|
||||
title="@string/pref_lang_title" />
|
||||
<SettingCheck
|
||||
id="pref_spaceOnZero"
|
||||
title="@string/pref_spaceOnZero"
|
||||
summary="@string/pref_keyRemapSum"
|
||||
defaultValue="false"
|
||||
/>
|
||||
<SettingCheck
|
||||
id="pref_mode_notify"
|
||||
title="@string/pref_mode_notify"
|
||||
|
|
@ -27,4 +33,10 @@
|
|||
<Setting title="@string/pref_backupdict" id="backupdict"/>
|
||||
<Setting title="@string/pref_restoredict" id="restoredict"/>
|
||||
<Setting title="@string/pref_reloadKeys" summary="@string/pref_reloadKeysSum" id="reloadKeys"/>
|
||||
<SettingCheck
|
||||
id="pref_keyMap"
|
||||
title="@string/pref_keyRemap"
|
||||
summary="@string/pref_keyRemapSum"
|
||||
defaultValue="false"
|
||||
/>
|
||||
</Settings>
|
||||
|
|
|
|||
|
|
@ -80,22 +80,22 @@ public class CharMap {
|
|||
}
|
||||
|
||||
protected static final char[][] ENT9TABLE = { { '0', '+' },
|
||||
{ '.', ',', '?', '!', '"', '/', '-', '@', '$', '%', '&', '*', '(', ')', '_', '1' },
|
||||
{ '.', ',', '?', '!', '"', '/', '-', '@', '$', '%', '&', '*', '#', '(', ')', '_', '1' },
|
||||
{ 'a', 'b', 'c', 'A', 'B', 'C', '2' }, { 'd', 'e', 'f', 'D', 'E', 'F', '3' },
|
||||
{ 'g', 'h', 'i', 'G', 'H', 'I', '4' }, { 'j', 'k', 'l', 'J', 'K', 'L', '5' },
|
||||
{ 'm', 'n', 'o', 'M', 'N', 'O', '6' }, { 'p', 'q', 'r', 's', 'P', 'Q', 'R', 'S', '7' },
|
||||
{ 't', 'u', 'v', 'T', 'U', 'V', '8' }, { 'w', 'x', 'y', 'z', 'W', 'X', 'Y', 'Z', '9' },
|
||||
{ ' ', '\n' } };
|
||||
{ ' ', '\n' }, { ' ', '0', '+' }, { '\n' } }; // LAST TWO SPACE ON 0
|
||||
protected static final char[][] RUT9TABLE = { { '0', '+' },
|
||||
{ '.', ',', '?', '!', '"', '/', '-', '@', '$', '%', '&', '*', '(', ')', '_', '1' },
|
||||
{ '.', ',', '?', '!', '"', '/', '-', '@', '$', '%', '&', '*', '#', '(', ')', '_', '1' },
|
||||
{ 'а', 'б', 'в', 'г', 'А', 'Б', 'В', 'Г', '2' }, { 'д', 'е', 'ё', 'ж', 'з', 'Д', 'Е', 'Ё', 'Ж', 'З', '3' },
|
||||
{ 'и', 'й', 'к', 'л', 'И', 'Й', 'К', 'Л', '4' }, { 'м', 'н', 'о', 'п', 'М', 'Н', 'О', 'П', '5' },
|
||||
{ 'р', 'с', 'т', 'у', 'Р', 'С', 'Т', 'У', '6' }, { 'ф', 'х', 'ц', 'ч', 'Ф', 'Х', 'Ц', 'Ч', '7' },
|
||||
{ 'ш', 'щ', 'ъ', 'ы', 'Ш', 'Щ', 'Ъ', 'Ы', '8' }, { 'ь', 'э', 'ю', 'я', 'Ь', 'Э', 'Ю', 'Я', '9' },
|
||||
{ ' ', '\n' } };
|
||||
{ ' ', '\n' }, { ' ', '0', '+' }, { '\n' } }; // LAST TWO SPACE ON 0
|
||||
protected static final char[][] DET9TABLE = {
|
||||
{ ' ', '+', '0' },
|
||||
{ '.', ',', '?', '!', ':', ';', '"', '\'', '-', '@', '^', '€', '$', '%', '&', '*', '(', ')', '_', '1' },
|
||||
{ '0', '+' },
|
||||
{ '.', ',', '?', '!', ':', ';', '"', '\'', '-', '@', '^', '€', '$', '%', '&', '*', '#', '(', ')', '_', '1' },
|
||||
{ 'a', 'b', 'c', 'A', 'B', 'C', 'ä', 'Ä','á', 'â', 'à', 'å', 'ç', 'Á', 'Â', 'À', 'Å', 'Ç', '2' },
|
||||
{ 'd', 'e', 'f', 'D', 'E', 'F', 'é','ë','è','ê', 'É', 'Ë', 'È', 'Ê', '3' },
|
||||
{ 'g', 'h', 'i', 'G', 'H', 'I', 'í', 'ï', 'Í', 'Ï', '4' },
|
||||
|
|
@ -104,11 +104,11 @@ public class CharMap {
|
|||
{ 'p', 'q', 'r', 's', 'P', 'Q', 'R', 'S', 'ß', '7' },
|
||||
{ 't', 'u', 'v', 'T', 'U', 'V', 'ü', 'Ü', 'û', 'Û', '8' },
|
||||
{ 'w', 'x', 'y', 'z', 'W', 'X', 'Y', 'Z', '9' },
|
||||
{ '\n' } };
|
||||
{ ' ', '\n' }, { ' ', '0', '+' }, { '\n' } }; // LAST TWO SPACE ON 0
|
||||
|
||||
protected static final char[][] FRT9TABLE = {
|
||||
{ ' ', '+', '0' },
|
||||
{ '.', ',', '?', '!', ':', ';', '"', '/', '-', '@', '^', '€', '$', '%', '&', '*', '(', ')', '_', '1' },
|
||||
{ '0', '+' },
|
||||
{ '.', ',', '?', '!', ':', ';', '"', '/', '-', '@', '^', '€', '$', '%', '&', '*', '#', '(', ')', '_', '1' },
|
||||
{ 'a', 'b', 'c', 'A', 'B', 'C', 'ä', 'Ä','á', 'â', 'à', 'å', 'ç', 'Á', 'Â', 'À', 'Å', 'Ç', '2' },
|
||||
{ 'd', 'e', 'f', 'D', 'E', 'F', 'é','ë','è','ê', 'É', 'Ë', 'È', 'Ê', '3' },
|
||||
{ 'g', 'h', 'i', 'G', 'H', 'I', 'í', 'ï', 'Í', 'Ï', '4' },
|
||||
|
|
@ -117,23 +117,25 @@ public class CharMap {
|
|||
{ 'p', 'q', 'r', 's', 'P', 'Q', 'R', 'S', 'ß', '7' },
|
||||
{ 't', 'u', 'v', 'T', 'U', 'V', 'ü', 'Ü', 'û', 'Û', '8' },
|
||||
{ 'w', 'x', 'y', 'z', 'W', 'X', 'Y', 'Z', '9' },
|
||||
{ '\n' } };
|
||||
|
||||
{ ' ', '\n' }, { ' ', '0', '+' }, { '\n' } }; // LAST TWO SPACE ON 0
|
||||
|
||||
protected static final char[][] ITT9TABLE = {
|
||||
{ ' ', '+', '0' },
|
||||
{ '.', ',', '?', '!', ':', ';', '"', '/', '-', '@', '^', '€', '$', '%', '&', '*', '(', ')', '_', '1' },
|
||||
{ '+', '0' },
|
||||
{ '.', ',', '?', '!', ':', ';', '"', '/', '-', '@', '^', '€', '$', '%', '&', '*', '#', '(', ')', '_', '1' },
|
||||
{ 'a', 'b', 'c', 'A', 'B', 'C', 'à', 'À', '2' }, { 'd', 'e', 'f', 'D', 'E', 'F', 'é', 'è', 'É', 'È', '3' },
|
||||
{ 'g', 'h', 'i', 'G', 'H', 'I', 'ì', 'Ì', '4' }, { 'j', 'k', 'l', 'J', 'K', 'L', '5' },
|
||||
{ 'm', 'n', 'o', 'M', 'N', 'O', 'ò', 'Ò', '6' }, { 'p', 'q', 'r', 's', 'P', 'Q', 'R', 'S', '7' },
|
||||
{ 't', 'u', 'v', 'T', 'U', 'V', 'ù', 'Ù', '8' }, { 'w', 'x', 'y', 'z', 'W', 'X', 'Y', 'Z', '9' },
|
||||
{ '\n' } };
|
||||
{ ' ', '\n' }, { ' ', '0', '+' }, { '\n' } }; // LAST TWO SPACE ON 0
|
||||
|
||||
protected static final char[][][] T9TABLE = { ENT9TABLE, RUT9TABLE, DET9TABLE, FRT9TABLE, ITT9TABLE };
|
||||
|
||||
protected static final int[] ENT9CAPSTART = { 0, 0, 3, 3, 3, 3, 3, 4, 3, 4, 0 };
|
||||
protected static final int [] RUT9CAPSTART = {0, 0, 4, 5, 4, 4, 4, 4, 4, 4, 0};
|
||||
protected static final int[] DET9CAPSTART = { 0, 0, 3, 3, 3, 3, 3, 4, 3, 4, 0 };
|
||||
protected static final int[] FRT9CAPSTART = { 0, 0, 3, 3, 3, 3, 3, 4, 3, 4, 0 };
|
||||
protected static final int[] ITT9CAPSTART = { 0, 0, 3, 3, 3, 3, 3, 4, 3, 4, 0 };
|
||||
// last 2 don't matter, are for spaceOnZero extra 'slots' 0 position, and 10 position
|
||||
protected static final int[] ENT9CAPSTART = { 0, 0, 3, 3, 3, 3, 3, 4, 3, 4, 0, 0, 0 };
|
||||
protected static final int[] RUT9CAPSTART = { 0, 0, 4, 5, 4, 4, 4, 4, 4, 4, 0, 0, 0 };
|
||||
protected static final int[] DET9CAPSTART = { 0, 0, 3, 3, 3, 3, 3, 4, 3, 4, 0, 0, 0 };
|
||||
protected static final int[] FRT9CAPSTART = { 0, 0, 3, 3, 3, 3, 3, 4, 3, 4, 0, 0, 0 };
|
||||
protected static final int[] ITT9CAPSTART = { 0, 0, 3, 3, 3, 3, 3, 4, 3, 4, 0, 0, 0 };
|
||||
protected static final int[][] T9CAPSTART = {ENT9CAPSTART, RUT9CAPSTART, DET9CAPSTART, FRT9CAPSTART, ITT9CAPSTART};
|
||||
|
||||
protected static String getStringSequence(String word, LANGUAGE lang) {
|
||||
|
|
|
|||
|
|
@ -2,34 +2,26 @@ package org.nyanya.android.traditionalt9;
|
|||
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class KeyMap {
|
||||
public static final String keymapfname = "keymap.txt";
|
||||
public static Map<Integer, Integer> keyMapping = new HashMap<Integer, Integer>();
|
||||
|
||||
public static int DPAD_CENTER = KeyEvent.KEYCODE_DPAD_CENTER;
|
||||
public static int DPAD_DOWN = KeyEvent.KEYCODE_DPAD_DOWN;
|
||||
public static int DPAD_UP = KeyEvent.KEYCODE_DPAD_UP;
|
||||
public static int DPAD_LEFT = KeyEvent.KEYCODE_DPAD_LEFT;
|
||||
public static int DPAD_RIGHT = KeyEvent.KEYCODE_DPAD_RIGHT;
|
||||
public static int SOFT_RIGHT = KeyEvent.KEYCODE_SOFT_RIGHT;
|
||||
public static int SOFT_LEFT = KeyEvent.KEYCODE_SOFT_LEFT;
|
||||
public static int DEL = KeyEvent.KEYCODE_DEL;
|
||||
public static int BACK = KeyEvent.KEYCODE_BACK;
|
||||
public static int ENTER = KeyEvent.KEYCODE_ENTER;
|
||||
public static int STAR = KeyEvent.KEYCODE_STAR;
|
||||
public static int POUND = KeyEvent.KEYCODE_POUND;
|
||||
static {
|
||||
setKeys();
|
||||
}
|
||||
|
||||
public static void setKeys() {
|
||||
public static int setKeys() {
|
||||
int msg = 0;
|
||||
keyMapping = new HashMap<Integer, Integer>();
|
||||
// check storage
|
||||
if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(Environment.getExternalStorageState())
|
||||
|| Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
|
||||
|
|
@ -37,7 +29,7 @@ public class KeyMap {
|
|||
if ((new File(new File(Environment.getExternalStorageDirectory(), TraditionalT9Settings.sddir),
|
||||
keymapfname)).exists()) {
|
||||
BufferedReader br = null;
|
||||
Log.d("KeyMap", "Attemping to load keys");
|
||||
Log.d("T9.KeyMap", "Attemping to load keys");
|
||||
try {
|
||||
br = new BufferedReader(new FileReader(new File(
|
||||
new File(Environment.getExternalStorageDirectory(), TraditionalT9Settings.sddir), keymapfname)));
|
||||
|
|
@ -48,43 +40,21 @@ public class KeyMap {
|
|||
if (ws.length != 2) {continue;}
|
||||
else if (line.startsWith("#")) {continue;}
|
||||
try {
|
||||
if (ws[0].equals("DPAD_CENTER")) {
|
||||
DPAD_CENTER = Integer.parseInt(ws[1]);
|
||||
} else if (ws[0].equals("DPAD_DOWN")) {
|
||||
DPAD_DOWN = Integer.parseInt(ws[1]);
|
||||
} else if (ws[0].equals("DPAD_UP")) {
|
||||
DPAD_UP = Integer.parseInt(ws[1]);
|
||||
} else if (ws[0].equals("DPAD_LEFT")) {
|
||||
DPAD_LEFT = Integer.parseInt(ws[1]);
|
||||
} else if (ws[0].equals("DPAD_RIGHT")) {
|
||||
DPAD_RIGHT = Integer.parseInt(ws[1]);
|
||||
} else if (ws[0].equals("SOFT_RIGHT")) {
|
||||
SOFT_RIGHT = Integer.parseInt(ws[1]);
|
||||
} else if (ws[0].equals("SOFT_LEFT")) {
|
||||
SOFT_LEFT = Integer.parseInt(ws[1]);
|
||||
} else if (ws[0].equals("DEL")) {
|
||||
DEL = Integer.parseInt(ws[1]);
|
||||
} else if (ws[0].equals("BACK")) {
|
||||
BACK = Integer.parseInt(ws[1]);
|
||||
} else if (ws[0].equals("ENTER")) {
|
||||
ENTER = Integer.parseInt(ws[1]);
|
||||
} else if (ws[0].equals("STAR")) {
|
||||
STAR = Integer.parseInt(ws[1]);
|
||||
} else if (ws[0].equals("POUND")) {
|
||||
POUND = Integer.parseInt(ws[1]);
|
||||
}
|
||||
keyMapping.put(Integer.parseInt(ws[0]), Integer.parseInt(ws[1]));
|
||||
} catch (NumberFormatException _ignore) {
|
||||
Log.w("T9.KeyMap", "Invalid number found");
|
||||
msg = R.string.pref_reloadKeysDoneWE;
|
||||
}
|
||||
}
|
||||
Log.d("KeyMap", "Done.");
|
||||
Log.d("T9.KeyMap", "Done.");
|
||||
} catch (IOException _ignore) {
|
||||
Log.e("T9.KeyMap", "Error while reading line.");
|
||||
try { br.close(); }
|
||||
catch (IOException ignored) {}
|
||||
}
|
||||
} catch (FileNotFoundException ignored) { }
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException ignored) { msg = R.string.pref_reloadKeysDone; }
|
||||
} else { msg = R.string.pref_reloadKeysNoFile; }
|
||||
} else { msg = R.string.pref_reloadKeysNoFile; }
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,8 +25,7 @@ public class LangHelper {
|
|||
public static LANGUAGE get(int i) { return lookup.get(i);}
|
||||
}
|
||||
|
||||
protected static final Locale[] LOCALES = {Locale.ENGLISH, RUSSIAN, Locale.GERMAN, Locale.FRENCH, Locale.ITALIAN};
|
||||
//protected static final String[] LANGS = {"EN", "RU", "DE"};
|
||||
protected static final Locale[] LOCALES = {Locale.ENGLISH, RUSSIAN, Locale.GERMAN, Locale.FRENCH, Locale.ITALIAN};
|
||||
|
||||
public static final int LANG_DEFAULT = LANGUAGE.EN.id;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class T9DB {
|
|||
protected boolean ready = true;
|
||||
|
||||
protected static final String DATABASE_NAME = "t9dict.db";
|
||||
protected static final int DATABASE_VERSION = 3;
|
||||
protected static final int DATABASE_VERSION = 4;
|
||||
protected static final String WORD_TABLE_NAME = "word";
|
||||
protected static final String SETTING_TABLE_NAME = "setting";
|
||||
protected static final String FREQ_TRIGGER_NAME = "freqtrigger";
|
||||
|
|
@ -66,19 +66,26 @@ public class T9DB {
|
|||
|
||||
public static class DBSettings {
|
||||
public enum SETTING {
|
||||
INPUT_MODE("pref_inputmode", 0),
|
||||
LANG_SUPPORT("pref_lang_support", 1),
|
||||
MODE_NOTIFY("pref_mode_notify", 0),
|
||||
LAST_LANG("set_last_lang", 1),
|
||||
LAST_WORD("set_last_word", null);
|
||||
INPUT_MODE("pref_inputmode", 0, 0),
|
||||
LANG_SUPPORT("pref_lang_support", 1, 1),
|
||||
MODE_NOTIFY("pref_mode_notify", 0, 2),
|
||||
LAST_LANG("set_last_lang", 1, 5),
|
||||
LAST_WORD("set_last_word", null, 6),
|
||||
SPACE_ZERO("pref_spaceOnZero", 0, 4),
|
||||
KEY_REMAP("pref_keyMap", 0, 3);
|
||||
|
||||
public final String id;
|
||||
public final Integer defvalue;
|
||||
public final int sqOrder; // used for building SettingsUI
|
||||
|
||||
// lookup map
|
||||
private static final Map<String, SETTING> lookup = new HashMap<String, SETTING>();
|
||||
private static final SETTING[] settings = SETTING.values();
|
||||
static { for (SETTING l : settings) lookup.put(l.id, l); }
|
||||
|
||||
private SETTING(String id, Integer defval) { this.id = id; this.defvalue = defval;}
|
||||
private SETTING(String id, Integer defval, int sqOrder) {
|
||||
this.id = id; this.defvalue = defval; this.sqOrder = sqOrder;
|
||||
}
|
||||
|
||||
public static SETTING get(String i) { return lookup.get(i);}
|
||||
public static StringBuilder join(SETTING[] settings, StringBuilder sb) {
|
||||
|
|
@ -485,14 +492,9 @@ public class T9DB {
|
|||
+ COLUMN_FREQUENCY + " / " + FREQ_DIV +
|
||||
" WHERE " + COLUMN_SEQ + " = NEW." + COLUMN_SEQ + ";" +
|
||||
" END;");
|
||||
// protected static final String[] setting_keys = {INPUT_MODE, LANG_SUPPORT, MODE_NOTIFY, LAST_LANG};
|
||||
db.execSQL("CREATE TABLE IF NOT EXISTS " + SETTING_TABLE_NAME + " (" +
|
||||
COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||
DBSettings.SETTING.INPUT_MODE.id + " INTEGER, " +
|
||||
DBSettings.SETTING.LANG_SUPPORT.id + " INTEGER, " +
|
||||
DBSettings.SETTING.MODE_NOTIFY.id + " INTEGER, " +
|
||||
DBSettings.SETTING.LAST_LANG.id + " INTEGER, " +
|
||||
DBSettings.SETTING.LAST_WORD.id + " TEXT )");
|
||||
|
||||
createSettingsTable(db);
|
||||
|
||||
StringBuilder sb = new StringBuilder("INSERT OR IGNORE INTO "); sb.append(SETTING_TABLE_NAME);
|
||||
sb.append(" ("); sb.append(COLUMN_ID); sb.append(", ");
|
||||
sb = DBSettings.SETTING.join(DBSettings.SETTING.settings, sb);
|
||||
|
|
@ -508,10 +510,22 @@ public class T9DB {
|
|||
db.execSQL(sb.toString());
|
||||
}
|
||||
|
||||
private void createSettingsTable(SQLiteDatabase db) {
|
||||
db.execSQL("CREATE TABLE IF NOT EXISTS " + SETTING_TABLE_NAME + " (" +
|
||||
COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||
DBSettings.SETTING.INPUT_MODE.id + " INTEGER, " +
|
||||
DBSettings.SETTING.LANG_SUPPORT.id + " INTEGER, " +
|
||||
DBSettings.SETTING.MODE_NOTIFY.id + " INTEGER, " +
|
||||
DBSettings.SETTING.LAST_LANG.id + " INTEGER, " +
|
||||
DBSettings.SETTING.KEY_REMAP.id + " INTEGER, " +
|
||||
DBSettings.SETTING.SPACE_ZERO.id + " INTEGER, " +
|
||||
DBSettings.SETTING.LAST_WORD.id + " TEXT )");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
Log.i("T9DB.onUpgrade", "Upgrading database from version " + oldVersion + " to " + newVersion);
|
||||
if (oldVersion == 1) {
|
||||
if (oldVersion <= 1) {
|
||||
// ADDED LANG
|
||||
db.execSQL("DROP INDEX IF EXISTS idx");
|
||||
db.execSQL("ALTER TABLE " + WORD_TABLE_NAME + " ADD COLUMN " +
|
||||
|
|
@ -519,18 +533,28 @@ public class T9DB {
|
|||
ContentValues updatedata = new ContentValues();
|
||||
updatedata.put(COLUMN_LANG, 0);
|
||||
db.update(WORD_TABLE_NAME, updatedata, null, null);
|
||||
onCreate(db);
|
||||
oldVersion = 2;
|
||||
}
|
||||
if (oldVersion == 2) {
|
||||
if (oldVersion <= 2) {
|
||||
// ADDED SETTINGS, CHANGED LANG VALUE
|
||||
db.execSQL("DROP INDEX IF EXISTS idx");
|
||||
db.execSQL("UPDATE " + WORD_TABLE_NAME + " SET " + COLUMN_LANG + "=" + LANGUAGE.RU.id +
|
||||
" WHERE " + COLUMN_LANG + "=1");
|
||||
db.execSQL("UPDATE " + WORD_TABLE_NAME + " SET " + COLUMN_LANG + "=" + LANGUAGE.EN.id +
|
||||
" WHERE " + COLUMN_LANG + "=0");
|
||||
onCreate(db);
|
||||
" WHERE " + COLUMN_LANG + "=0");
|
||||
createSettingsTable(db);
|
||||
}
|
||||
if (oldVersion == 3) {
|
||||
// ADDED REMAP OPTION and SPACEONZERO
|
||||
db.execSQL("ALTER TABLE " + SETTING_TABLE_NAME + " ADD COLUMN " +
|
||||
DBSettings.SETTING.KEY_REMAP.id + " INTEGER");
|
||||
db.execSQL("ALTER TABLE " + SETTING_TABLE_NAME + " ADD COLUMN " +
|
||||
DBSettings.SETTING.SPACE_ZERO.id + " INTEGER");
|
||||
ContentValues updatedata = new ContentValues();
|
||||
updatedata.put(DBSettings.SETTING.KEY_REMAP.id, 0);
|
||||
updatedata.put(DBSettings.SETTING.SPACE_ZERO.id, 0);
|
||||
db.update(SETTING_TABLE_NAME, updatedata, null, null);
|
||||
}
|
||||
onCreate(db);
|
||||
Log.i("T9DB.onUpgrade", "Done.");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ import java.util.AbstractList;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
public class TraditionalT9 extends InputMethodService implements
|
||||
KeyboardView.OnKeyboardActionListener {
|
||||
|
||||
|
|
@ -46,6 +44,9 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
private boolean mGaveUpdateWarn = false;
|
||||
|
||||
private boolean mFirstPress = false;
|
||||
private boolean keyRemap = false;
|
||||
|
||||
private boolean spaceOnZero = false;
|
||||
|
||||
private boolean mIgnoreDPADKeyUp = false;
|
||||
private KeyEvent mDPADkeyEvent = null;
|
||||
|
|
@ -195,7 +196,6 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
while (bounds < after.length() && !Character.isWhitespace(after.charAt(bounds))) {
|
||||
bounds++;
|
||||
}
|
||||
Log.d("getSurroundingWord", "after:"+after.toString());
|
||||
after = after.subSequence(0, bounds);
|
||||
}
|
||||
return before.toString().trim() + after.toString().trim();
|
||||
|
|
@ -248,14 +248,13 @@ 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);
|
||||
currentInputConnection = getCurrentInputConnection();
|
||||
|
||||
if (attribute.inputType == 0) {
|
||||
//Log.d("T9.onStartInput", "INPUTTYPE: " + attribute.inputType + " FIELDID: " + attribute.fieldId +
|
||||
// " FIELDNAME: " + attribute.fieldName + " PACKAGE NAME: " + attribute.packageName);
|
||||
if (attribute.inputType == 0 || attribute.inputType == 3) {
|
||||
mLang = null;
|
||||
// don't do anything when not in any kind of edit field.
|
||||
// OR in dialer-type inputs. Hopefully OS will translate longpress 0 to +
|
||||
// should also turn off input screen and stuff
|
||||
mEditing = NON_EDIT;
|
||||
requestHideSelf(0);
|
||||
|
|
@ -264,6 +263,9 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
// if (interfacehandler != null) {
|
||||
// interfacehandler.hideView();
|
||||
// }
|
||||
// Get keyMap setting:
|
||||
Object[] setting = db.getSettings(new SETTING[] {SETTING.KEY_REMAP} );
|
||||
keyRemap = setting[0].equals(1);
|
||||
return;
|
||||
}
|
||||
mFirstPress = true;
|
||||
|
|
@ -274,12 +276,14 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
clearState();
|
||||
|
||||
// get settings
|
||||
Object[] settings = db.getSettings(new SETTING[]
|
||||
// 0, 1, 2,
|
||||
{SETTING.LANG_SUPPORT, SETTING.LAST_LANG, SETTING.MODE_NOTIFY,
|
||||
// 3, 4
|
||||
SETTING.INPUT_MODE, SETTING.LAST_WORD} );
|
||||
Object[] settings = db.getSettings(new SETTING[] {
|
||||
// 0, 1, 2,
|
||||
SETTING.LANG_SUPPORT, SETTING.LAST_LANG, SETTING.MODE_NOTIFY,
|
||||
// 3, 4, 5
|
||||
SETTING.INPUT_MODE, SETTING.LAST_WORD, SETTING.SPACE_ZERO
|
||||
});
|
||||
|
||||
spaceOnZero = settings[5].equals(1);
|
||||
mLangsAvailable = LangHelper.buildLangs((Integer)settings[0]);
|
||||
mLang = sanitizeLang(LANGUAGE.get((Integer)settings[1]));
|
||||
|
||||
|
|
@ -496,14 +500,18 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
// ??????????????
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this to monitor key events being delivered to the application. We get
|
||||
* first crack at them, and can either resume them or let them continue to
|
||||
* the app.
|
||||
*/
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
// Log.d("onKeyDown", "Key: " + event + " repeat?: " +
|
||||
private KeyEvent TranslateKey(int keyCode, KeyEvent event) {
|
||||
KeyEvent key = event;
|
||||
if (KeyMap.keyMapping.containsKey(keyCode)) {
|
||||
key = new KeyEvent(event.getDownTime(), event.getEventTime(), event.getAction(),
|
||||
KeyMap.keyMapping.get(keyCode), event.getRepeatCount(), event.getMetaState(),
|
||||
event.getDeviceId(), 0, event.getFlags());
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
private boolean onKeyDown_(int keyCode, KeyEvent event) {
|
||||
// Log.d("onKeyDown", "Key: " + event + " repeat?: " +
|
||||
// event.getRepeatCount() + " long-time: " + event.isLongPress());
|
||||
if (mEditing == NON_EDIT) {
|
||||
// // catch for UI weirdness on up event thing
|
||||
|
|
@ -511,7 +519,7 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
}
|
||||
mFirstPress = false;
|
||||
|
||||
if (keyCode == KeyMap.DPAD_CENTER) {
|
||||
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
|
||||
if (interfacehandler != null) {
|
||||
interfacehandler.setPressed(keyCode, true);
|
||||
} // pass-through
|
||||
|
|
@ -521,17 +529,17 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
return false;
|
||||
}
|
||||
return handleDPAD(keyCode, event, true);
|
||||
} else if (keyCode == KeyMap.DPAD_DOWN || keyCode == KeyMap.DPAD_UP || keyCode == KeyMap.DPAD_LEFT || keyCode == KeyMap.DPAD_RIGHT) {
|
||||
} else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN || keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
|
||||
if (mEditing == EDITING_NOSHOW) {
|
||||
return false;
|
||||
}
|
||||
return handleDPAD(keyCode, event, true);
|
||||
} else if (keyCode == KeyMap.SOFT_RIGHT || keyCode == KeyMap.SOFT_LEFT) {
|
||||
} else if (keyCode == KeyEvent.KEYCODE_SOFT_RIGHT || keyCode == KeyEvent.KEYCODE_SOFT_LEFT) {
|
||||
if (!isInputViewShown()) {
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
} else if (keyCode == KeyMap.DEL) {// Special handling of the delete key: if we currently are
|
||||
} else if (keyCode == KeyEvent.KEYCODE_DEL) {// Special handling of the delete key: if we currently are
|
||||
// composing text for the user, we want to modify that instead
|
||||
// of let the application do the delete itself.
|
||||
// if (mComposing.length() > 0) {
|
||||
|
|
@ -548,17 +556,17 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
if (mKeyMode == MODE_TEXT) {
|
||||
t9releasehandler.removeCallbacks(mt9release);
|
||||
}
|
||||
if (keyCode == KeyMap.BACK) {// The InputMethodService already takes care of the back
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {// The InputMethodService already takes care of the back
|
||||
// key for us, to dismiss the input method if it is shown.
|
||||
// but we will manage it ourselves because native Android handling
|
||||
// of the input view is ... flakey at best.
|
||||
// Log.d("onKeyDown", "back pres");
|
||||
return isInputViewShown();
|
||||
} else if (keyCode == KeyMap.ENTER) {// Let the underlying text editor always handle these.
|
||||
} else if (keyCode == KeyEvent.KEYCODE_ENTER) {// Let the underlying text editor always handle these.
|
||||
return false;
|
||||
|
||||
// special case for softkeys
|
||||
} else if (keyCode == KeyMap.SOFT_RIGHT || keyCode == KeyMap.SOFT_LEFT) {
|
||||
} else if (keyCode == KeyEvent.KEYCODE_SOFT_RIGHT || keyCode == KeyEvent.KEYCODE_SOFT_LEFT) {
|
||||
if (interfacehandler != null) {
|
||||
interfacehandler.setPressed(keyCode, true);
|
||||
}
|
||||
|
|
@ -570,7 +578,7 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
} else if (keyCode == KeyEvent.KEYCODE_0 || keyCode == KeyEvent.KEYCODE_1 || keyCode == KeyEvent.KEYCODE_2 ||
|
||||
keyCode == KeyEvent.KEYCODE_3 || keyCode == KeyEvent.KEYCODE_4 || keyCode == KeyEvent.KEYCODE_5 ||
|
||||
keyCode == KeyEvent.KEYCODE_6 || keyCode == KeyEvent.KEYCODE_7 || keyCode == KeyEvent.KEYCODE_8 ||
|
||||
keyCode == KeyEvent.KEYCODE_9 || keyCode == KeyMap.POUND || keyCode == KeyMap.STAR) {
|
||||
keyCode == KeyEvent.KEYCODE_9 || keyCode == KeyEvent.KEYCODE_POUND || keyCode == KeyEvent.KEYCODE_STAR) {
|
||||
event.startTracking();
|
||||
return true;
|
||||
} else {// KeyCharacterMap.load(KeyCharacterMap.BUILT_IN_KEYBOARD).getNumber(keyCode)
|
||||
|
|
@ -581,13 +589,42 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
commitReset();
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
/**
|
||||
* Use this to monitor key events being delivered to the application. We get
|
||||
* first crack at them, and can either resume them or let them continue to
|
||||
* the app.
|
||||
*/
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
// Translate key
|
||||
KeyEvent key = TranslateKey(keyCode, event);
|
||||
if (key != null) {
|
||||
keyCode = key.getKeyCode();
|
||||
event = key;
|
||||
}
|
||||
|
||||
if (!onKeyDown_(keyCode, event)) {
|
||||
if (key == null || keyRemap) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
// push key to lower level
|
||||
// dumb handling of null for edge weird timing cases.
|
||||
if (currentInputConnection == null)
|
||||
currentInputConnection = getCurrentInputConnection();
|
||||
if (currentInputConnection != null)
|
||||
currentInputConnection.sendKeyEvent(event);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void launchOptions() {
|
||||
Intent awintent = new Intent(this, TraditionalT9Settings.class);
|
||||
awintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
awintent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
|
||||
if (interfacehandler != null) {
|
||||
interfacehandler.setPressed(KeyMap.SOFT_RIGHT, false);
|
||||
interfacehandler.setPressed(KeyEvent.KEYCODE_SOFT_RIGHT, false);
|
||||
}
|
||||
hideWindow();
|
||||
startActivity(awintent);
|
||||
|
|
@ -602,14 +639,14 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
|
||||
// Log.d("onLongPress", "LONG PRESS: " + keyCode);
|
||||
// HANDLE SPECIAL KEYS
|
||||
if (keyCode == KeyMap.POUND) {
|
||||
if (keyCode == KeyEvent.KEYCODE_POUND) {
|
||||
commitReset();
|
||||
// do default action or insert new line
|
||||
if (!sendDefaultEditorAction(true)) {
|
||||
onText("\n");
|
||||
}
|
||||
return true;
|
||||
} else if (keyCode == KeyMap.STAR) {
|
||||
} else if (keyCode == KeyEvent.KEYCODE_STAR) {
|
||||
if (mKeyMode != MODE_NUM) {
|
||||
if (mLangsAvailable.length > 1) {
|
||||
nextLang();
|
||||
|
|
@ -619,7 +656,7 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
return true;
|
||||
}
|
||||
|
||||
} else if (keyCode == KeyMap.SOFT_LEFT) {
|
||||
} else if (keyCode == KeyEvent.KEYCODE_SOFT_LEFT) {
|
||||
if (interfacehandler != null) {
|
||||
interfacehandler.setPressed(keyCode, false);
|
||||
}
|
||||
|
|
@ -631,7 +668,7 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
}
|
||||
}
|
||||
|
||||
} else if (keyCode == KeyMap.SOFT_RIGHT) {
|
||||
} else if (keyCode == KeyEvent.KEYCODE_SOFT_RIGHT) {
|
||||
if (interfacehandler != null) {
|
||||
interfacehandler.setPressed(keyCode, false);
|
||||
}
|
||||
|
|
@ -655,15 +692,9 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this to monitor key events being delivered to the application. We get
|
||||
* first crack at them, and can either resume them or let them continue to
|
||||
* the app.
|
||||
*/
|
||||
@Override
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
// Log.d("onKeyUp", "Key: " + keyCode + " repeat?: " +
|
||||
// event.getRepeatCount());
|
||||
private boolean onKeyUp_(int keyCode, KeyEvent event) {
|
||||
// Log.d("onKeyUp", "Key: " + keyCode + " repeat?: " +
|
||||
// event.getRepeatCount());
|
||||
if (mEditing == NON_EDIT) {
|
||||
// if (mButtonClose) {
|
||||
// //handle UI weirdness on up event
|
||||
|
|
@ -677,7 +708,7 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
return super.onKeyUp(keyCode, event);
|
||||
}
|
||||
|
||||
if (keyCode == KeyMap.DPAD_CENTER) {
|
||||
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
|
||||
if (interfacehandler != null) {
|
||||
interfacehandler.setPressed(keyCode, false);
|
||||
}
|
||||
|
|
@ -685,35 +716,34 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
return false;
|
||||
}
|
||||
return handleDPAD(keyCode, event, false);
|
||||
} else if (keyCode == KeyMap.DPAD_DOWN || keyCode == KeyMap.DPAD_UP || keyCode == KeyMap.DPAD_LEFT || keyCode == KeyMap.DPAD_RIGHT) {
|
||||
} else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN || keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
|
||||
if (mEditing == EDITING_NOSHOW) {
|
||||
return false;
|
||||
}
|
||||
return handleDPAD(keyCode, event, false);
|
||||
} else if (keyCode == KeyMap.SOFT_RIGHT || keyCode == KeyMap.SOFT_LEFT) {
|
||||
} else if (keyCode == KeyEvent.KEYCODE_SOFT_RIGHT || keyCode == KeyEvent.KEYCODE_SOFT_LEFT) {
|
||||
if (!isInputViewShown()) {
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (event.isCanceled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (keyCode == KeyMap.BACK) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
if (isInputViewShown()) {
|
||||
hideWindow();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else if (keyCode == KeyMap.DEL) {
|
||||
} else if (keyCode == KeyEvent.KEYCODE_DEL) {
|
||||
return true;
|
||||
} else if (keyCode == KeyMap.ENTER) {
|
||||
} else if (keyCode == KeyEvent.KEYCODE_ENTER) {
|
||||
return false;
|
||||
|
||||
// special case for softkeys
|
||||
} else if (keyCode == KeyMap.SOFT_RIGHT || keyCode == KeyMap.SOFT_LEFT) {// if (mAddingWord){
|
||||
} else if (keyCode == KeyEvent.KEYCODE_SOFT_RIGHT || keyCode == KeyEvent.KEYCODE_SOFT_LEFT) {// if (mAddingWord){
|
||||
// Log.d("onKeyUp", "key: " + keyCode + " skip: " +
|
||||
// mAddingSkipInput);
|
||||
// if (mAddingSkipInput) {
|
||||
|
|
@ -734,7 +764,7 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
} else if (keyCode == KeyEvent.KEYCODE_0 || keyCode == KeyEvent.KEYCODE_1 || keyCode == KeyEvent.KEYCODE_2
|
||||
|| keyCode == KeyEvent.KEYCODE_3 || keyCode == KeyEvent.KEYCODE_4 || keyCode == KeyEvent.KEYCODE_5 ||
|
||||
keyCode == KeyEvent.KEYCODE_6 || keyCode == KeyEvent.KEYCODE_7 || keyCode == KeyEvent.KEYCODE_8 ||
|
||||
keyCode == KeyEvent.KEYCODE_9 || keyCode == KeyMap.POUND || keyCode == KeyMap.STAR) {
|
||||
keyCode == KeyEvent.KEYCODE_9 || keyCode == KeyEvent.KEYCODE_POUND || keyCode == KeyEvent.KEYCODE_STAR) {
|
||||
// if (!isInputViewShown()){
|
||||
// Log.d("onKeyUp", "showing window.");
|
||||
// //showWindow(true);
|
||||
|
|
@ -750,6 +780,35 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
commitReset();
|
||||
return super.onKeyUp(keyCode, event);
|
||||
}
|
||||
/**
|
||||
* Use this to monitor key events being delivered to the application. We get
|
||||
* first crack at them, and can either resume them or let them continue to
|
||||
* the app.
|
||||
*/
|
||||
@Override
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
// Translate key
|
||||
KeyEvent key = TranslateKey(keyCode, event);
|
||||
if (key != null) {
|
||||
keyCode = key.getKeyCode();
|
||||
event = key;
|
||||
}
|
||||
|
||||
if (!onKeyUp_(keyCode, event)) {
|
||||
if (key == null || keyRemap) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
// push key to lower level
|
||||
// dumb handling of null for edge weird timing cases.
|
||||
if (currentInputConnection == null)
|
||||
currentInputConnection = getCurrentInputConnection();
|
||||
if (currentInputConnection != null)
|
||||
currentInputConnection.sendKeyEvent(event);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to commit any text being composed in to the editor.
|
||||
|
|
@ -814,32 +873,28 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
// Log.d("OnKey", "pri: " + keyCode);
|
||||
// Log.d("onKey", "START Cm: " + mCapsMode);
|
||||
// HANDLE SPECIAL KEYS
|
||||
if (keyCode == KeyMap.DEL) {
|
||||
if (keyCode == KeyEvent.KEYCODE_DEL) {
|
||||
handleBackspace();
|
||||
|
||||
} else if (keyCode == KeyEvent.KEYCODE_STAR) {
|
||||
// change case
|
||||
} else if (keyCode == KeyMap.STAR) {
|
||||
if (mKeyMode == MODE_NUM) {
|
||||
handleCharacter(KeyMap.STAR);
|
||||
handleCharacter(KeyEvent.KEYCODE_STAR);
|
||||
} else {
|
||||
handleShift();
|
||||
}
|
||||
|
||||
} else if (keyCode == KeyMap.BACK) {
|
||||
} else if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
handleClose();
|
||||
|
||||
} else if (keyCode == KeyEvent.KEYCODE_POUND) {
|
||||
// space
|
||||
} else if (keyCode == KeyMap.POUND) {
|
||||
handleCharacter(KeyMap.POUND);
|
||||
|
||||
} else if (keyCode == KeyMap.SOFT_LEFT) {
|
||||
handleCharacter(KeyEvent.KEYCODE_POUND);
|
||||
} else if (keyCode == KeyEvent.KEYCODE_SOFT_LEFT) {
|
||||
if (mWordFound) {
|
||||
showSymbolPage();
|
||||
} else {
|
||||
showAddWord();
|
||||
}
|
||||
|
||||
} else if (keyCode == KeyMap.SOFT_RIGHT) {
|
||||
} else if (keyCode == KeyEvent.KEYCODE_SOFT_RIGHT) {
|
||||
nextKeyMode();
|
||||
|
||||
} else {
|
||||
|
|
@ -1030,7 +1085,7 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
updateCandidates();
|
||||
} else {
|
||||
mPreviousWord = "";
|
||||
keyDownUp(KeyMap.DEL);
|
||||
keyDownUp(KeyEvent.KEYCODE_DEL);
|
||||
}
|
||||
updateShiftKeyState(getCurrentInputEditorInfo());
|
||||
// Log.d("handleBS", "Cm: " + mCapsMode);
|
||||
|
|
@ -1064,8 +1119,9 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
switch (mKeyMode) {
|
||||
case MODE_LANG:
|
||||
// it begins
|
||||
// on POUND commit and space
|
||||
if (keyCode == KeyMap.POUND) {
|
||||
// take note of spaceOnZero
|
||||
if (keyCode == KeyEvent.KEYCODE_POUND ||
|
||||
( spaceOnZero && (keyCode == KeyEvent.KEYCODE_0) )) {
|
||||
if (mComposing.length() > 0) {
|
||||
commitTyped();
|
||||
}
|
||||
|
|
@ -1084,11 +1140,18 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
|
||||
case MODE_TEXT:
|
||||
t9releasehandler.removeCallbacks(mt9release);
|
||||
if (keyCode == KeyMap.POUND) {
|
||||
if (keyCode == KeyEvent.KEYCODE_POUND) {
|
||||
keyCode = 10;
|
||||
} else {
|
||||
keyCode = keyCode - KeyEvent.KEYCODE_0;
|
||||
}
|
||||
// special translation of that keyCode (which is now T9TABLE index
|
||||
if (spaceOnZero) {
|
||||
if (keyCode == 0)
|
||||
keyCode = 11;
|
||||
if (keyCode == 10)
|
||||
keyCode = 12;
|
||||
}
|
||||
//Log.d("handleChar", "Key: " + keyCode + "Previous Key: " + mPrevious + " Index:" + mCharIndex);
|
||||
|
||||
boolean newChar = false;
|
||||
|
|
@ -1132,9 +1195,9 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
break;
|
||||
|
||||
case MODE_NUM:
|
||||
if (keyCode == KeyMap.POUND) {
|
||||
if (keyCode == KeyEvent.KEYCODE_POUND) {
|
||||
onText("#");
|
||||
} else if (keyCode == KeyMap.STAR) {
|
||||
} else if (keyCode == KeyEvent.KEYCODE_STAR) {
|
||||
onText("*");
|
||||
} else {
|
||||
onText(String.valueOf(keyCode - KeyEvent.KEYCODE_0));
|
||||
|
|
@ -1177,17 +1240,17 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
return super.onKeyUp(keyCode, event);
|
||||
} else {
|
||||
if (mKeyMode != MODE_NUM && mComposing.length() > 0) {
|
||||
if (keyCode == KeyMap.DPAD_DOWN) {
|
||||
if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
|
||||
mCandidateView.scrollSuggestion(1);
|
||||
if (mSuggestionStrings.size() > mCandidateView.mSelectedIndex)
|
||||
currentInputConnection.setComposingText(mSuggestionStrings.get(mCandidateView.mSelectedIndex), 1);
|
||||
return true;
|
||||
} else if (keyCode == KeyMap.DPAD_UP) {
|
||||
} else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
|
||||
mCandidateView.scrollSuggestion(-1);
|
||||
if (mSuggestionStrings.size() > mCandidateView.mSelectedIndex)
|
||||
currentInputConnection.setComposingText(mSuggestionStrings.get(mCandidateView.mSelectedIndex), 1);
|
||||
return true;
|
||||
} else if (keyCode == KeyMap.DPAD_LEFT || keyCode == KeyMap.DPAD_RIGHT) {
|
||||
} else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
|
||||
if (mKeyMode == MODE_LANG) {
|
||||
commitTyped();
|
||||
} else if (mKeyMode == MODE_TEXT) {
|
||||
|
|
@ -1198,7 +1261,7 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
return true;
|
||||
}
|
||||
}
|
||||
if (keyCode == KeyMap.DPAD_CENTER) {
|
||||
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
|
||||
handleMidButton();
|
||||
return true;
|
||||
} else {// Send stored event to input connection then pass current
|
||||
|
|
|
|||
|
|
@ -692,8 +692,8 @@ public class TraditionalT9Settings extends ListActivity implements
|
|||
|
||||
// get settings
|
||||
Object[] settings = T9DB.getInstance(this).getSettings(new SETTING[]
|
||||
// 0, 1, 2
|
||||
{SETTING.INPUT_MODE, SETTING.LANG_SUPPORT, SETTING.MODE_NOTIFY});
|
||||
// Order should be based on SETTING.sqOrder
|
||||
{SETTING.INPUT_MODE, SETTING.LANG_SUPPORT, SETTING.MODE_NOTIFY, SETTING.KEY_REMAP, SETTING.SPACE_ZERO});
|
||||
ListAdapter settingitems;
|
||||
try {
|
||||
settingitems = new SettingAdapter(this, CustomInflater.inflate(this, R.xml.prefs, settings));
|
||||
|
|
@ -722,8 +722,12 @@ public class TraditionalT9Settings extends ListActivity implements
|
|||
backupDict();
|
||||
else if (s.id.equals("restoredict"))
|
||||
restoreDict();
|
||||
else if (s.id.equals("reloadKeys"))
|
||||
KeyMap.setKeys();
|
||||
else if (s.id.equals("reloadKeys")) {
|
||||
int msg = KeyMap.setKeys();
|
||||
if (msg != 0) {
|
||||
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
else
|
||||
s.clicked(mContext);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import android.widget.CheckBox;
|
|||
|
||||
import org.nyanya.android.traditionalt9.R;
|
||||
import org.nyanya.android.traditionalt9.T9DB;
|
||||
import org.nyanya.android.traditionalt9.T9DB.DBSettings.SETTING;
|
||||
|
||||
public class SettingCheck extends Setting {
|
||||
boolean value;
|
||||
|
|
@ -21,11 +22,14 @@ public class SettingCheck extends Setting {
|
|||
defaultValue = attrs.getAttributeBooleanValue(i, false);
|
||||
}
|
||||
}
|
||||
if (id.equals("pref_mode_notify")){
|
||||
if (isettings[2] != null)
|
||||
value = isettings[2].equals(1);
|
||||
else
|
||||
|
||||
SETTING s = SETTING.get(id);
|
||||
if (s != null) {
|
||||
Object o = isettings[s.sqOrder];
|
||||
if (o == null)
|
||||
value = defaultValue;
|
||||
else
|
||||
value = o.equals(1);
|
||||
}
|
||||
widgetID = R.layout.checkbox;
|
||||
layout = R.layout.setting_widget;
|
||||
|
|
@ -34,7 +38,7 @@ public class SettingCheck extends Setting {
|
|||
@Override
|
||||
public void clicked(Context context) {
|
||||
value = !value;
|
||||
T9DB.getInstance(context).storeSettingInt(T9DB.DBSettings.SETTING.get(id), value ? 1 : 0);
|
||||
T9DB.getInstance(context).storeSettingInt(SETTING.get(id), value ? 1 : 0);
|
||||
((CheckBox)view.findViewById(R.id.checkbox)).setChecked(value);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue