Added initial German support. Updated gradle things, fixed bugs:
* Made the Gradle script act a bit better in regards to calcing dict sizes * Fixed some error messages * Hopefully fixed crash on no dict load * Fixed issue where some characters and cases weren't added to db
This commit is contained in:
parent
fedd835ba5
commit
079de4c475
13 changed files with 200 additions and 164 deletions
|
|
@ -9,101 +9,120 @@ import java.util.Map;
|
|||
import android.util.Log;
|
||||
|
||||
public class CharMap {
|
||||
protected static final AbstractList<Map<Character, Integer>> CHARTABLE = new ArrayList<Map<Character, Integer>>(2);
|
||||
static {
|
||||
Map<Character, Integer> enMap = new HashMap<Character, Integer>();
|
||||
enMap.put('.', 1); enMap.put(',', 1); enMap.put('!', 1); enMap.put('?', 1);
|
||||
enMap.put('-', 1); enMap.put('"', 1); enMap.put('\'', 1); enMap.put('@', 1);
|
||||
enMap.put('#', 1); enMap.put('$', 1); enMap.put('%', 1); enMap.put('&', 1);
|
||||
enMap.put('*', 1); enMap.put('(', 1); enMap.put(')', 1); enMap.put('1', 1);
|
||||
enMap.put(':', 1); enMap.put(';', 1); enMap.put('/', 1); enMap.put('\\', 1);
|
||||
enMap.put('+', 1); enMap.put('=', 1); enMap.put('<', 1); enMap.put('>', 1);
|
||||
enMap.put('[', 1); enMap.put(']', 1); enMap.put('{', 1); enMap.put('}', 1);
|
||||
enMap.put('^', 1); enMap.put('|', 1); enMap.put('_', 1); enMap.put('~', 1);
|
||||
enMap.put('`', 1);
|
||||
enMap.put('a', 2); enMap.put('\u00e1', 2); enMap.put('\u00e4', 2);
|
||||
enMap.put('\u00e2', 2); enMap.put('\u00e0', 2); enMap.put('\u00e5', 2);
|
||||
enMap.put('b', 2); enMap.put('c', 2); enMap.put('\u00e7', 2);
|
||||
enMap.put('2', 2); enMap.put('d', 3); enMap.put('e', 3);
|
||||
enMap.put('\u00e9', 3); enMap.put('\u00eb', 3); enMap.put('\u00e8', 3);
|
||||
enMap.put('\u00ea', 3); enMap.put('f', 3); enMap.put('3', 3);
|
||||
enMap.put('g', 4); enMap.put('h', 4); enMap.put('i', 4);
|
||||
enMap.put('\u00ed', 4); enMap.put('\u00ef', 4); enMap.put('4', 4);
|
||||
enMap.put('j', 5); enMap.put('k', 5); enMap.put('l', 5);
|
||||
enMap.put('5', 5); enMap.put('m', 6); enMap.put('n', 6);
|
||||
enMap.put('\u00f1', 6); enMap.put('o', 6); enMap.put('\u00f3', 6);
|
||||
enMap.put('\u00f6', 6); enMap.put('\u00f4', 6); enMap.put('\u00fb', 6);
|
||||
enMap.put('6', 6); enMap.put('p', 7); enMap.put('q', 7);
|
||||
enMap.put('r', 7); enMap.put('s', 7); enMap.put('7', 7);
|
||||
enMap.put('t', 8); enMap.put('u', 8); enMap.put('\u00fc', 8);
|
||||
enMap.put('v', 8); enMap.put('8', 8); enMap.put('w', 9);
|
||||
enMap.put('x', 9); enMap.put('y', 9); enMap.put('z', 9);
|
||||
enMap.put('9', 9); enMap.put('+', 0); enMap.put('0', 0);
|
||||
CHARTABLE.add(0, Collections.unmodifiableMap(enMap));
|
||||
protected static final AbstractList<Map<Character, Integer>> CHARTABLE = new ArrayList<Map<Character, Integer>>(LangHelper.NLANGS);
|
||||
static {
|
||||
// English
|
||||
Map<Character, Integer> enMap = new HashMap<Character, Integer>();
|
||||
enMap.put('.', 1); enMap.put(',', 1); enMap.put('!', 1); enMap.put('?', 1);
|
||||
enMap.put('-', 1); enMap.put('"', 1); enMap.put('\'', 1); enMap.put('@', 1);
|
||||
enMap.put('#', 1); enMap.put('$', 1); enMap.put('%', 1); enMap.put('&', 1);
|
||||
enMap.put('*', 1); enMap.put('(', 1); enMap.put(')', 1); enMap.put('1', 1);
|
||||
enMap.put(':', 1); enMap.put(';', 1); enMap.put('/', 1); enMap.put('\\', 1);
|
||||
enMap.put('+', 1); enMap.put('=', 1); enMap.put('<', 1); enMap.put('>', 1);
|
||||
enMap.put('[', 1); enMap.put(']', 1); enMap.put('{', 1); enMap.put('}', 1);
|
||||
enMap.put('^', 1); enMap.put('|', 1); enMap.put('_', 1); enMap.put('~', 1);
|
||||
enMap.put('`', 1);
|
||||
enMap.put('a', 2); enMap.put('á', 2); enMap.put('ä', 2); enMap.put('â', 2);
|
||||
enMap.put('à', 2); enMap.put('å', 2); enMap.put('b', 2); enMap.put('c', 2);
|
||||
enMap.put('ç', 2); enMap.put('2', 2);
|
||||
enMap.put('d', 3); enMap.put('e', 3); enMap.put('é', 3); enMap.put('ë', 3);
|
||||
enMap.put('è', 3); enMap.put('ê', 3); enMap.put('f', 3); enMap.put('3', 3);
|
||||
enMap.put('g', 4); enMap.put('h', 4); enMap.put('i', 4); enMap.put('í', 4);
|
||||
enMap.put('ï', 4); enMap.put('4', 4);
|
||||
enMap.put('j', 5); enMap.put('k', 5); enMap.put('l', 5); enMap.put('5', 5);
|
||||
enMap.put('m', 6); enMap.put('n', 6); enMap.put('ñ', 6); enMap.put('o', 6);
|
||||
enMap.put('ó', 6); enMap.put('ö', 6); enMap.put('ô', 6); enMap.put('6', 6);
|
||||
enMap.put('p', 7); enMap.put('q', 7); enMap.put('r', 7); enMap.put('s', 7);
|
||||
enMap.put('7', 7);
|
||||
enMap.put('t', 8); enMap.put('u', 8); enMap.put('û', 6); enMap.put('ü', 8);
|
||||
enMap.put('v', 8); enMap.put('8', 8); enMap.put('w', 9);
|
||||
enMap.put('x', 9); enMap.put('y', 9); enMap.put('z', 9);
|
||||
enMap.put('9', 9); enMap.put('+', 0); enMap.put('0', 0);
|
||||
// for German support reusing the same table since it already had special characters
|
||||
enMap.put('€', 1);
|
||||
enMap.put('ß', 7);
|
||||
CHARTABLE.add(0, Collections.unmodifiableMap(enMap));
|
||||
|
||||
Map<Character, Integer> ruMap = new HashMap<Character, Integer>();
|
||||
ruMap.put('.', 1); ruMap.put(',', 1); ruMap.put('!', 1); ruMap.put('?', 1);
|
||||
ruMap.put('-', 1); ruMap.put('"', 1); ruMap.put('\'', 1); ruMap.put('@', 1);
|
||||
ruMap.put('#', 1); ruMap.put('$', 1); ruMap.put('%', 1); ruMap.put('&', 1);
|
||||
ruMap.put('*', 1); ruMap.put('(', 1); ruMap.put(')', 1); ruMap.put('1', 1);
|
||||
ruMap.put(':', 1); ruMap.put(';', 1); ruMap.put('/', 1); ruMap.put('\\', 1);
|
||||
ruMap.put('+', 1); ruMap.put('=', 1); ruMap.put('<', 1); ruMap.put('>', 1);
|
||||
ruMap.put('[', 1); ruMap.put(']', 1); ruMap.put('{', 1); ruMap.put('}', 1);
|
||||
ruMap.put('^', 1); ruMap.put('|', 1); ruMap.put('_', 1); ruMap.put('~', 1);
|
||||
ruMap.put('`', 1); ruMap.put('1', 1);
|
||||
ruMap.put('а', 2); ruMap.put('б', 2); ruMap.put('в', 2); ruMap.put('г', 2);
|
||||
ruMap.put('2', 2);
|
||||
ruMap.put('д', 3); ruMap.put('е', 3); ruMap.put('ё', 3); ruMap.put('ж', 3);
|
||||
ruMap.put('з', 3); ruMap.put('3', 3);
|
||||
ruMap.put('и', 4); ruMap.put('й', 4); ruMap.put('к', 4); ruMap.put('л', 4);
|
||||
ruMap.put('4', 4);
|
||||
ruMap.put('м', 5); ruMap.put('н', 5); ruMap.put('о', 5); ruMap.put('п', 5);
|
||||
ruMap.put('5', 5);
|
||||
ruMap.put('р', 6); ruMap.put('с', 6); ruMap.put('т', 6); ruMap.put('у', 6);
|
||||
ruMap.put('6', 6);
|
||||
ruMap.put('ф', 7); ruMap.put('х', 7); ruMap.put('ц', 7); ruMap.put('ч', 7);
|
||||
ruMap.put('7', 7);
|
||||
ruMap.put('ш', 8); ruMap.put('щ', 8); ruMap.put('ъ', 8); ruMap.put('ы', 8);
|
||||
ruMap.put('8', 8);
|
||||
ruMap.put('ь', 9); ruMap.put('э', 9); ruMap.put('ю', 9); ruMap.put('я', 9);
|
||||
ruMap.put('9', 9);
|
||||
ruMap.put('+', 0); ruMap.put('0', 0);
|
||||
CHARTABLE.add(1, Collections.unmodifiableMap(ruMap));
|
||||
}
|
||||
// Russian
|
||||
Map<Character, Integer> ruMap = new HashMap<Character, Integer>();
|
||||
ruMap.put('.', 1); ruMap.put(',', 1); ruMap.put('!', 1); ruMap.put('?', 1);
|
||||
ruMap.put('-', 1); ruMap.put('"', 1); ruMap.put('\'', 1); ruMap.put('@', 1);
|
||||
ruMap.put('#', 1); ruMap.put('$', 1); ruMap.put('%', 1); ruMap.put('&', 1);
|
||||
ruMap.put('*', 1); ruMap.put('(', 1); ruMap.put(')', 1); ruMap.put('1', 1);
|
||||
ruMap.put(':', 1); ruMap.put(';', 1); ruMap.put('/', 1); ruMap.put('\\', 1);
|
||||
ruMap.put('+', 1); ruMap.put('=', 1); ruMap.put('<', 1); ruMap.put('>', 1);
|
||||
ruMap.put('[', 1); ruMap.put(']', 1); ruMap.put('{', 1); ruMap.put('}', 1);
|
||||
ruMap.put('^', 1); ruMap.put('|', 1); ruMap.put('_', 1); ruMap.put('~', 1);
|
||||
ruMap.put('`', 1); ruMap.put('1', 1);
|
||||
ruMap.put('а', 2); ruMap.put('б', 2); ruMap.put('в', 2); ruMap.put('г', 2);
|
||||
ruMap.put('2', 2);
|
||||
ruMap.put('д', 3); ruMap.put('е', 3); ruMap.put('ё', 3); ruMap.put('ж', 3);
|
||||
ruMap.put('з', 3); ruMap.put('3', 3);
|
||||
ruMap.put('и', 4); ruMap.put('й', 4); ruMap.put('к', 4); ruMap.put('л', 4);
|
||||
ruMap.put('4', 4);
|
||||
ruMap.put('м', 5); ruMap.put('н', 5); ruMap.put('о', 5); ruMap.put('п', 5);
|
||||
ruMap.put('5', 5);
|
||||
ruMap.put('р', 6); ruMap.put('с', 6); ruMap.put('т', 6); ruMap.put('у', 6);
|
||||
ruMap.put('6', 6);
|
||||
ruMap.put('ф', 7); ruMap.put('х', 7); ruMap.put('ц', 7); ruMap.put('ч', 7);
|
||||
ruMap.put('7', 7);
|
||||
ruMap.put('ш', 8); ruMap.put('щ', 8); ruMap.put('ъ', 8); ruMap.put('ы', 8);
|
||||
ruMap.put('8', 8);
|
||||
ruMap.put('ь', 9); ruMap.put('э', 9); ruMap.put('ю', 9); ruMap.put('я', 9);
|
||||
ruMap.put('9', 9);
|
||||
ruMap.put('+', 0); ruMap.put('0', 0);
|
||||
CHARTABLE.add(1, Collections.unmodifiableMap(ruMap));
|
||||
|
||||
protected static final char[][] ENT9TABLE = { { '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' } };
|
||||
protected static final char[][] RUT9TABLE = { { '0', '+' },
|
||||
{ '.', ',', '?', '!', '"', '\'', '-', '@', '$', '%', '&', '*', '(', ')', '_', '1' },
|
||||
{ 'а', 'б', 'в', 'г', 'А', 'Б', 'В', 'Г', '2' }, { 'д', 'е', 'ё', 'ж', 'з', 'Д', 'Е', 'Ё', 'Ж', 'З', '3' },
|
||||
{ 'и', 'й', 'к', 'л', 'И', 'Й', 'К', 'Л', '4' }, { 'м', 'н', 'о', 'п', 'М', 'Н', 'О', 'П', '5' },
|
||||
{ 'р', 'с', 'т', 'у', 'Р', 'С', 'Т', 'У', '6' }, { 'ф', 'х', 'ц', 'ч', 'Ф', 'Х', 'Ц', 'Ч', '7' },
|
||||
{ 'ш', 'щ', 'ъ', 'ы', 'Ш', 'Щ', 'Ъ', 'Ы', '8' }, { 'ь', 'э', 'ю', 'я', 'Ь', 'Э', 'Ю', 'Я', '9' },
|
||||
{ ' ', '\n' } };
|
||||
protected static final char[][][] T9TABLE = {ENT9TABLE, RUT9TABLE};
|
||||
//German (lol pretty simple, hopefully.)
|
||||
CHARTABLE.add(2, Collections.unmodifiableMap(enMap));
|
||||
}
|
||||
|
||||
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[][] T9CAPSTART = {ENT9CAPSTART, RUT9CAPSTART};
|
||||
protected static final char[][] ENT9TABLE = { { '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' } };
|
||||
protected static final char[][] RUT9TABLE = { { '0', '+' },
|
||||
{ '.', ',', '?', '!', '"', '\'', '-', '@', '$', '%', '&', '*', '(', ')', '_', '1' },
|
||||
{ 'а', 'б', 'в', 'г', 'А', 'Б', 'В', 'Г', '2' }, { 'д', 'е', 'ё', 'ж', 'з', 'Д', 'Е', 'Ё', 'Ж', 'З', '3' },
|
||||
{ 'и', 'й', 'к', 'л', 'И', 'Й', 'К', 'Л', '4' }, { 'м', 'н', 'о', 'п', 'М', 'Н', 'О', 'П', '5' },
|
||||
{ 'р', 'с', 'т', 'у', 'Р', 'С', 'Т', 'У', '6' }, { 'ф', 'х', 'ц', 'ч', 'Ф', 'Х', 'Ц', 'Ч', '7' },
|
||||
{ 'ш', 'щ', 'ъ', 'ы', 'Ш', 'Щ', 'Ъ', 'Ы', '8' }, { 'ь', 'э', 'ю', 'я', 'Ь', 'Э', 'Ю', 'Я', '9' },
|
||||
{ ' ', '\n' } };
|
||||
protected static final char[][] DET9TABLE = {
|
||||
{ '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' } };
|
||||
protected static final char[][][] T9TABLE = {ENT9TABLE, RUT9TABLE, DET9TABLE};
|
||||
|
||||
protected static String getStringSequence(String word, int lang) {
|
||||
StringBuilder seq = new StringBuilder();
|
||||
String tword = word.toLowerCase(LangHelper.LOCALES[lang]);
|
||||
for (int i = 0; i < word.length(); i++) {
|
||||
char c = tword.charAt(i);
|
||||
Integer z = CharMap.CHARTABLE.get(lang).get(c);
|
||||
if (z == null) {
|
||||
Log.e("getStringSequence",
|
||||
"ERROR: " + (int) c + " NOT FOUND FOR [" + lang + "] (" + Integer.toHexString((int) c) + ") Index: " + i);
|
||||
throw new NullPointerException();
|
||||
}
|
||||
seq.append(z.toString());
|
||||
}
|
||||
return seq.toString();
|
||||
}
|
||||
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, 9, 7, 5, 3, 7, 5, 5, 4, 0 };
|
||||
protected static final int[][] T9CAPSTART = {ENT9CAPSTART, RUT9CAPSTART, DET9CAPSTART};
|
||||
|
||||
protected static String getStringSequence(String word, int lang) {
|
||||
StringBuilder seq = new StringBuilder();
|
||||
String tword = word.toLowerCase(LangHelper.LOCALES[lang]);
|
||||
for (int i = 0; i < word.length(); i++) {
|
||||
char c = tword.charAt(i);
|
||||
Integer z = CharMap.CHARTABLE.get(lang).get(c);
|
||||
if (z == null) {
|
||||
Log.e("getStringSequence",
|
||||
"ERROR: " + (int) c + " NOT FOUND FOR [" + lang + "] (" + Integer.toHexString((int) c) + ") Index: " + i);
|
||||
throw new NullPointerException();
|
||||
}
|
||||
seq.append(z.toString());
|
||||
}
|
||||
return seq.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@ public class LangHelper {
|
|||
protected static final Locale RUSSIAN = new Locale("ru","RU");
|
||||
protected static final int EN = 0;
|
||||
protected static final int RU = 1;
|
||||
protected static final Locale[] LOCALES = {Locale.ENGLISH, RUSSIAN};
|
||||
protected static final String[] LANGS = {"EN", "RU"};
|
||||
protected static final int DE = 1;
|
||||
protected static final Locale[] LOCALES = {Locale.ENGLISH, RUSSIAN, Locale.GERMAN};
|
||||
protected static final String[] LANGS = {"EN", "RU", "DE"};
|
||||
|
||||
protected static final int NLANGS = LANGS.length;
|
||||
|
||||
|
|
@ -31,7 +32,14 @@ public class LangHelper {
|
|||
{R.drawable.ime_ru_lang_lower, R.drawable.ime_ru_lang_single, R.drawable.ime_ru_lang_upper}, //LANG
|
||||
{R.drawable.ime_ru_text_lower, R.drawable.ime_ru_text_single, R.drawable.ime_ru_text_upper}, //TEXT
|
||||
{R.drawable.ime_number}, //NUM
|
||||
}
|
||||
},
|
||||
{
|
||||
// German resources
|
||||
{R.drawable.ime_de_lang_lower, R.drawable.ime_de_lang_single, R.drawable.ime_de_lang_upper}, //LANG
|
||||
{R.drawable.ime_en_text_lower, R.drawable.ime_en_text_single, R.drawable.ime_en_text_upper}, //TEXT
|
||||
{R.drawable.ime_number}, //NUM
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
protected static int[] buildLangs(CharSequence s) {
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ public class T9DB {
|
|||
try {
|
||||
seq = CharMap.getStringSequence(iword, lang);
|
||||
} catch (NullPointerException e) {
|
||||
throw new DBException(r.getString(R.string.add_word_badchar, LangHelper.LANGS[lang]));
|
||||
throw new DBException(r.getString(R.string.add_word_badchar, LangHelper.LANGS[lang], iword));
|
||||
}
|
||||
// add int sequence into num table
|
||||
ContentValues values = new ContentValues();
|
||||
|
|
@ -211,22 +211,24 @@ public class T9DB {
|
|||
return result;
|
||||
} else {
|
||||
int islen = is.length();
|
||||
char c = is.charAt(islen - 1);
|
||||
c++;
|
||||
q = "SELECT " + COLUMN_WORD + " FROM " + WORD_TABLE_NAME +
|
||||
" WHERE " + COLUMN_LANG + "=? AND " + COLUMN_SEQ + " >= '" + is + "1" +
|
||||
"' AND " + COLUMN_SEQ + " < '" + is.substring(0, islen - 1) + c + "'" +
|
||||
" ORDER BY " + COLUMN_FREQUENCY + " DESC, " + COLUMN_SEQ + " ASC" +
|
||||
" LIMIT " + (MAX_RESULTS - hits);
|
||||
cur = db.rawQuery(q, new String[] { String.valueOf(lang) });
|
||||
if (islen >= 2) {
|
||||
char c = is.charAt(islen - 1);
|
||||
c++;
|
||||
q = "SELECT " + COLUMN_WORD + " FROM " + WORD_TABLE_NAME +
|
||||
" WHERE " + COLUMN_LANG + "=? AND " + COLUMN_SEQ + " >= '" + is + "1" +
|
||||
"' AND " + COLUMN_SEQ + " < '" + is.substring(0, islen - 1) + c + "'" +
|
||||
" ORDER BY " + COLUMN_FREQUENCY + " DESC, " + COLUMN_SEQ + " ASC" +
|
||||
" LIMIT " + (MAX_RESULTS - hits);
|
||||
cur = db.rawQuery(q, new String[]{String.valueOf(lang)});
|
||||
|
||||
if (cur.moveToFirst()) {
|
||||
result = cur.getString(0);
|
||||
if (cur.moveToFirst()) {
|
||||
result = cur.getString(0);
|
||||
}
|
||||
if (result == null) {
|
||||
result = "";
|
||||
}
|
||||
cur.close();
|
||||
}
|
||||
if (result == null) {
|
||||
result = "";
|
||||
}
|
||||
cur.close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -256,7 +258,7 @@ public class T9DB {
|
|||
}
|
||||
cur.close();
|
||||
|
||||
if (hits < MINHITS) {
|
||||
if ((hits < MINHITS) && (islen <= 2)) {
|
||||
char c = is.charAt(islen - 1);
|
||||
c++;
|
||||
String q = "SELECT " + COLUMN_ID + ", " + COLUMN_WORD +
|
||||
|
|
|
|||
|
|
@ -562,8 +562,7 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
if (interfacehandler != null) {
|
||||
interfacehandler.setPressed(keyCode, true);
|
||||
}
|
||||
case KeyEvent.KEYCODE_FOCUS:
|
||||
// pass-through
|
||||
// pass-through
|
||||
case KeyEvent.KEYCODE_0:
|
||||
case KeyEvent.KEYCODE_1:
|
||||
case KeyEvent.KEYCODE_2:
|
||||
|
|
@ -767,7 +766,7 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
if (interfacehandler != null) {
|
||||
interfacehandler.setPressed(keyCode, false);
|
||||
}
|
||||
// pass-through
|
||||
// pass-through
|
||||
case KeyEvent.KEYCODE_0:
|
||||
case KeyEvent.KEYCODE_1:
|
||||
case KeyEvent.KEYCODE_2:
|
||||
|
|
@ -780,7 +779,7 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
case KeyEvent.KEYCODE_9:
|
||||
case KeyEvent.KEYCODE_POUND:
|
||||
case KeyEvent.KEYCODE_STAR:
|
||||
case KeyEvent.KEYCODE_FOCUS:
|
||||
//case KeyEvent.KEYCODE_FOCUS:
|
||||
// if (!isInputViewShown()){
|
||||
// Log.d("onKeyUp", "showing window.");
|
||||
// //showWindow(true);
|
||||
|
|
|
|||
|
|
@ -327,6 +327,7 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
|||
final int freqColumn = wordhelp.getColumnIndex(T9DB.COLUMN_FREQUENCY);
|
||||
final int seqColumn = wordhelp.getColumnIndex(T9DB.COLUMN_SEQ);
|
||||
|
||||
// load CHARTABLE and then load T9table, just to cover all bases.
|
||||
for (Map.Entry<Character, Integer> entry : CharMap.CHARTABLE.get(lang).entrySet()) {
|
||||
wordhelp.prepareForReplace();
|
||||
wordhelp.bind(langColumn, Integer.toString(lang));
|
||||
|
|
@ -334,6 +335,25 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
|||
wordhelp.bind(wordColumn, Character.toString(entry.getKey()));
|
||||
wordhelp.bind(freqColumn, 0);
|
||||
wordhelp.execute();
|
||||
// upper case
|
||||
wordhelp.prepareForReplace();
|
||||
wordhelp.bind(langColumn, Integer.toString(lang));
|
||||
wordhelp.bind(seqColumn, Integer.toString(entry.getValue()));
|
||||
wordhelp.bind(wordColumn, Character.toString(Character.toUpperCase(entry.getKey())));
|
||||
wordhelp.bind(freqColumn, 0);
|
||||
wordhelp.execute();
|
||||
}
|
||||
char[][] chartable = CharMap.T9TABLE[lang];
|
||||
for (int numkey=0; numkey<chartable.length; numkey++) {
|
||||
char[] chars = chartable[numkey];
|
||||
for (int charindex=0; charindex<chars.length; charindex++) {
|
||||
wordhelp.prepareForReplace();
|
||||
wordhelp.bind(langColumn, Integer.toString(lang));
|
||||
wordhelp.bind(seqColumn, Integer.toString(numkey));
|
||||
wordhelp.bind(wordColumn, Character.toString(chars[charindex]));
|
||||
wordhelp.bind(freqColumn, 0);
|
||||
wordhelp.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -425,7 +445,7 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
|||
rpl.status = false;
|
||||
rpl.addMsg("Error on word ("+word+") line "+
|
||||
linecount+" in (" + fname+"): "+
|
||||
getResources().getString(R.string.add_word_badchar, LangHelper.LANGS[lang]));
|
||||
getResources().getString(R.string.add_word_badchar, LangHelper.LANGS[lang], word));
|
||||
break;
|
||||
}
|
||||
linecount++;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue