1
0
Fork 0

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:
Clam 2014-10-21 01:17:02 +11:00
parent fedd835ba5
commit 079de4c475
13 changed files with 200 additions and 164 deletions

19
.gitignore vendored
View file

@ -1,34 +1,35 @@
# built application files
# Built application files
*.apk
*.ap_
# files for the dex VM
# Files for the Dalvik VM
*.dex
# Java class files
*.class
# generated files
# Generated files
bin/
build/
gen/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Eclipse project files
.classpath
.project
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Intellij project files
*.iws
*.iml
.idea/
#Other
.gradle/
assets/dict.properties
t9build.properties

View file

@ -4,10 +4,8 @@
android:versionCode="4"
android:versionName="git" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="10" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-configuration
android:reqFiveWayNav="true"
android:reqHardKeyboard="true"

View file

@ -3,7 +3,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.0'
classpath 'com.android.tools.build:gradle:0.13.2'
}
}
apply plugin: 'android'
@ -65,6 +65,7 @@ def saveProps(Properties props) {
props.store(new FileOutputStream(new File("t9build.properties")), null)
}
// -PincrementBuildNumber assembleRelease
def computeVersionNumber = { ->
Properties props = getProps()
int verNum = Integer.valueOf(props.getProperty("verNum", "0"))
@ -77,8 +78,8 @@ def computeVersionNumber = { ->
}
android {
compileSdkVersion 10
buildToolsVersion "19.0.0"
compileSdkVersion 8
buildToolsVersion "19.1"
sourceSets {
main {
@ -128,14 +129,13 @@ android {
}
task getDictSizes {
inputs.files 'assets/en-utf8.txt', 'assets/ru-utf8.txt'
inputs.dir fileTree(dir:'assets', excludes:['dict.properties'])
outputs.file "t9build.properties"
doLast {
ant.echo("Calculating dict size...")
FileCollection dicts = files("assets/en-utf8.txt", "assets/ru-utf8.txt")
dicts.each {File file ->
inputs.getFiles().each {File file ->
ant.echo("dict: "+ file.name)
ant.propertyfile(file:"assets/dict.properties") {
entry(key: "size."+ file.name, value: file.length())
}

View file

@ -1,6 +1,6 @@
#Sat Mar 22 23:26:27 EST 2014
#Sun Oct 19 13:30:51 EST 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-all.zip

View file

@ -5,21 +5,11 @@
<item>Текст</item>
<item>Цифры</item>
</string-array>
<string-array name="pref_inputmode_values">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
<string-array name="pref_lang_defaults">
<item>0</item>
</string-array>
<string-array name="pref_lang_titles">
<item>English</item>
<item>Русский</item>
</string-array>
<string-array name="pref_lang_values">
<item>0</item>
<item>1</item>
<item>Немецкий</item>
</string-array>
<string-array name="capsMode">

View file

@ -2,14 +2,13 @@
<resources>
<string name="action_settings">Настройки</string>
<string name="add_word">Добавить слово</string>
<string name="add_word_badchar">Невозможно добавить слово с таким символом %1$s.</string>
<string name="add_word_badchar">Невозможно добавить слово с таким символом %1$s (%2$s).</string>
<string name="add_word_blank">Невозможно добавить слово.</string>
<string name="add_word_exist1">Слово (%1$s) уже есть в словаре.</string>
<string name="add_word_exist2">Слово (%1$s) уже есть в словаре %2$s.</string>
<string name="app_name">Traditional T9</string>
<string name="cancel">Отмена</string>
<string name="hello_world">Hello world!</string>
<string name="ime_english">T9</string>
<string name="ime_name">Клавиатура T9</string>
<string name="ime_number">Цифры</string>
<string name="main_left_addword">Добавить слово</string>
@ -28,23 +27,22 @@
<string name="pref_inputmode_desc">Режим ввода по умолчанию</string>
<string name="pref_load_title">Загрузить словарь IME</string>
<string name="pref_loaddict">Загрузить словарь</string>
<string name="pref_loadingbackup">Восстановление словаря...</string>
<string name="pref_loadingbackup">Восстановление словаря</string>
<string name="pref_loadingdict">Загрузка словаря</string>
<string name="pref_loadinguserdict">Загрузка пользовательского словаря...</string>
<string name="pref_loadinguserdict">Загрузка пользовательского словаря</string>
<string name="pref_loaduserdict">Загрузить свой словарь</string>
<string name="pref_loaduserdictdesc">SDcard/traditionalt9/user.lang.dict (lang: en/ru)</string>
<string name="pref_lang_title">Мультиязычная поддержка</string>
<string name="pref_nuke_title">Очистить IME словарь</string>
<string name="pref_nuke_warn">Предупреждение: Будет выполнена очстка словаря. Продолжить?</string>
<string name="pref_nukedict">Очистить словарь</string>
<string name="pref_nukingdict">Очистка словаря... Пожалуйста, подождите...</string>
<string name="pref_nukingdict">Очистка словаря… Пожалуйста, подождите…</string>
<string name="pref_querytest">Query test</string>
<string name="pref_restore_noext">Ошибка: Внешняя память недоступна. Восстановление невозможно.</string>
<string name="pref_restore_nofile">Ошибка: Файл встановления не найден.</string>
<string name="pref_restore_title">Восстановить базу данных IME</string>
<string name="pref_restore_warn">При восстановлении существующая база данных будет очищена. Если это нежелательно, то сначала выберите \"%1$s\" перед использованием этой опции.</string>
<string name="pref_restoredict">Сохранить словарь</string>
<string name="pref_savingbackup">Сохранение словаря...</string>
<string name="pref_savingbackup">Сохранение словаря</string>
<string name="pref_testfunc">Test func</string>
<string name="ricon_desc">Hold Icon</string>
<string name="pref_help">О программе</string>

View file

@ -5,22 +5,24 @@
<item >Text</item>
<item >Number</item>
</string-array>
<string-array name="pref_inputmode_values">
<string-array translatable="false" name="pref_inputmode_values">
<item >0</item>
<item >1</item>
<item >2</item>
</string-array>
<string-array name="pref_lang_defaults">
<string-array translatable="false" name="pref_lang_defaults">
<item >0</item>
</string-array>
<string-array name="pref_lang_titles">
<item >English</item>
<item >Russian</item>
<item >German</item>
</string-array>
<string-array name="pref_lang_values">
<string-array translatable="false" name="pref_lang_values">
<item >0</item>
<item >1</item>
<item >2</item>
</string-array>
<string-array name="capsMode">

View file

@ -3,7 +3,6 @@
<string translatable="false" name="help_url">https://github.com/Clam-/TraditionalT9/wiki/Traditional-T9-keypad-IME-for-Android</string>
<string name="app_name">Traditional T9</string>
<string name="ime_name">Traditional T9</string>
<string name="ime_english">English</string>
<string name="ime_number">Numbers</string>
<string name="pref_inputmode">Default Input Mode</string>
<string name="pref_inputmode_desc">Default mode used for \'normal\' text entry</string>
@ -26,7 +25,7 @@
<string name="ok">OK</string>
<string name="close">Close</string>
<string name="add_word_blank">Blank word not added.</string>
<string name="add_word_badchar">Cannot add word with unmappable symbol for %1$s.</string>
<string name="add_word_badchar">Cannot add word with unmappable character for %1$s (%2$s).</string>
<string name="add_word_exist1">Word (%1$s) already in DB.</string>
<string name="add_word_exist2">Word (%1$s) already in DB for %2$s.</string>
<string name="cancel">Cancel</string>
@ -43,7 +42,7 @@
<string name="pref_help">"Show help</string>
<string name="pref_loaddict">Load dictionary</string>
<string name="pref_loaduserdict">Load user dictionary</string>
<string name="pref_loaduserdictdesc">SDcard/traditionalt9/user.lang.dict (lang: en/ru)</string>
<string translatable="false" name="pref_loaduserdictdesc">SDcard/traditionalt9/user.lang.dict (lang: en/ru/de)</string>
<string name="pref_nukedict">Nuke dictionary</string>
<string name="pref_backupdict">Backup dictionary</string>
<string name="pref_restoredict">Restore dictionary</string>

View file

@ -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();
}
}

View file

@ -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) {

View file

@ -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 +

View file

@ -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);

View file

@ -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++;