1
0
Fork 0

Added French support and many other changes:

* Updated gradle
* Gradle build script changed to prompt for password in UI
* Initial French support NOTE: Missing UI resources.
* IntelliJ IDEA: Optimize Imports
* Fixed dictionary loading UI oddity when loading multiple dicts
This commit is contained in:
Clam 2015-08-08 02:37:34 +10:00
parent e7466a292f
commit 0ec529a6d3
21 changed files with 336715 additions and 110 deletions

View file

@ -1,10 +1,10 @@
package org.nyanya.android.traditionalt9;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.view.View;

View file

@ -1,8 +1,5 @@
package org.nyanya.android.traditionalt9;
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
@ -11,6 +8,9 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.view.View;
import java.util.ArrayList;
import java.util.List;
public class CandidateView extends View {
private List<String> mSuggestions;

View file

@ -1,15 +1,15 @@
package org.nyanya.android.traditionalt9;
import android.util.Log;
import org.nyanya.android.traditionalt9.LangHelper.LANGUAGE;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import android.util.Log;
import org.nyanya.android.traditionalt9.LangHelper.LANGUAGE;
public class CharMap {
protected static final AbstractList<Map<Character, Integer>> CHARTABLE = new ArrayList<Map<Character, Integer>>(LangHelper.NLANGS);
static {
@ -38,10 +38,11 @@ public class CharMap {
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));
// add extra characters for German and French maps.
enMap.put('€', 1); enMap.put('ß', 7); // German chars
enMap.put('î', 4); enMap.put('ù', 8); // French chars
Map<Character, Integer> endefrmap = Collections.unmodifiableMap(enMap);
CHARTABLE.add(0, endefrmap);
// Russian
Map<Character, Integer> ruMap = new HashMap<Character, Integer>();
@ -68,22 +69,23 @@ public class CharMap {
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);
ruMap.put('+', 0);
ruMap.put('0', 0);
CHARTABLE.add(1, Collections.unmodifiableMap(ruMap));
//German (lol pretty simple, hopefully.)
CHARTABLE.add(2, Collections.unmodifiableMap(enMap));
CHARTABLE.add(2, Collections.unmodifiableMap(endefrmap));
CHARTABLE.add(3, Collections.unmodifiableMap(endefrmap));
}
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' } };
protected static final char[][] RUT9TABLE = { { '0', '+' },
{ '.', ',', '?', '!', '"', '\'', '-', '@', '$', '%', '&', '*', '(', ')', '_', '1' },
{ '.', ',', '?', '!', '"', '/', '-', '@', '$', '%', '&', '*', '(', ')', '_', '1' },
{ 'а', 'б', 'в', 'г', 'А', 'Б', 'В', 'Г', '2' }, { 'д', 'е', 'ё', 'ж', 'з', 'Д', 'Е', 'Ё', 'Ж', 'З', '3' },
{ 'и', 'й', 'к', 'л', 'И', 'Й', 'К', 'Л', '4' }, { 'м', 'н', 'о', 'п', 'М', 'Н', 'О', 'П', '5' },
{ 'р', 'с', 'т', 'у', 'Р', 'С', 'Т', 'У', '6' }, { 'ф', 'х', 'ц', 'ч', 'Ф', 'Х', 'Ц', 'Ч', '7' },
@ -101,7 +103,20 @@ public class CharMap {
{ '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 final char[][] FRT9TABLE = {
{ ' ', '+', '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, FRT9TABLE};
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};

View file

@ -1,10 +1,7 @@
package org.nyanya.android.traditionalt9;
import android.content.Context;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.TextView;
import android.widget.ViewSwitcher;

View file

@ -1,20 +1,20 @@
package org.nyanya.android.traditionalt9;
import android.util.Log;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import pl.wavesoftware.widget.MultiSelectListPreference;
public class LangHelper {
protected static final Locale RUSSIAN = new Locale("ru","RU");
public enum LANGUAGE {
// MAKE SURE THESE MATCH WITH values/const.xml
NONE(-1, -1), EN(0,1), RU(1,2), DE(2,4), ;
public final int id;
// (index, id) Where index is index in arrays like LOCALES and MUST increment and MUST be in
// the same order as arrays.xml/pref_lang_values, and id is the identifier used in
// the database and such. id should never change unless database update is done.
// id MUST increment in doubles (as the enabled languages are stored as an integer)
NONE(-1, -1), EN(0,1), RU(1,2), DE(2,4), FR(3,8);
public final int index;
public final int id;
// lookup map
private static final Map<Integer, LANGUAGE> lookup = new HashMap<Integer, LANGUAGE>();
private static final LANGUAGE[] ids = LANGUAGE.values();
@ -25,7 +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};
protected static final Locale[] LOCALES = {Locale.ENGLISH, RUSSIAN, Locale.GERMAN, Locale.FRENCH};
//protected static final String[] LANGS = {"EN", "RU", "DE"};
public static final int LANG_DEFAULT = LANGUAGE.EN.id;
@ -43,24 +43,30 @@ public class LangHelper {
//[LANG][MODE][CAPSMODE] = iconref
// first group en, first line LANG, second line TEXT, last line NUM
protected static final int[][][] ICONMAP = {
{
//English resources
{
//English resources
{R.drawable.ime_en_lang_lower, R.drawable.ime_en_lang_single, R.drawable.ime_en_lang_upper},
{R.drawable.ime_en_text_lower, R.drawable.ime_en_text_single, R.drawable.ime_en_text_upper},
{R.drawable.ime_number},
},
{
// Russian resources
{R.drawable.ime_en_text_lower, R.drawable.ime_en_text_single, R.drawable.ime_en_text_upper},
{R.drawable.ime_number},
},
{
// Russian resources
{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
},
{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
},
{
// French 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
},
};

View file

@ -1,12 +1,5 @@
package org.nyanya.android.traditionalt9;
import java.util.AbstractList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
@ -22,6 +15,12 @@ import android.widget.Toast;
import org.nyanya.android.traditionalt9.LangHelper.LANGUAGE;
import java.util.AbstractList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class T9DB {
private static volatile T9DB instance = null;

View file

@ -1,10 +1,5 @@
package org.nyanya.android.traditionalt9;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import android.content.Intent;
import android.content.res.Resources;
import android.inputmethodservice.InputMethodService;
@ -23,6 +18,10 @@ import android.widget.Toast;
import org.nyanya.android.traditionalt9.LangHelper.LANGUAGE;
import org.nyanya.android.traditionalt9.T9DB.DBSettings.SETTING;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.List;
public class TraditionalT9 extends InputMethodService implements
KeyboardView.OnKeyboardActionListener {

View file

@ -3,8 +3,41 @@ package org.nyanya.android.traditionalt9;
/*
Source for English dictionary: http://wordlist.sourceforge.net/
Source for Russian dictionary: Various sources from Russian user
Source for German dictionary: Modified version from http://www.winedt.org/Dict/
Source for French dictionary: http://www.pallier.org/ressources/dicofr/dicofr.html
*/
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.database.Cursor;
import android.database.DatabaseUtils.InsertHelper;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Toast;
import com.stackoverflow.answer.UnicodeBOMInputStream;
import org.nyanya.android.traditionalt9.LangHelper.LANGUAGE;
import org.nyanya.android.traditionalt9.T9DB.DBSettings.SETTING;
import org.nyanya.android.traditionalt9.settings.CustomInflater;
import org.nyanya.android.traditionalt9.settings.Setting;
import org.nyanya.android.traditionalt9.settings.SettingAdapter;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
@ -26,38 +59,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.database.Cursor;
import android.database.DatabaseUtils.InsertHelper;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Toast;
import com.stackoverflow.answer.UnicodeBOMInputStream;
import org.nyanya.android.traditionalt9.settings.CustomInflater;
import org.nyanya.android.traditionalt9.settings.Setting;
import org.nyanya.android.traditionalt9.settings.SettingAdapter;
import org.nyanya.android.traditionalt9.LangHelper.LANGUAGE;
import org.nyanya.android.traditionalt9.T9DB.DBSettings.SETTING;
public class TraditionalT9Settings extends ListActivity implements
DialogInterface.OnCancelListener {
@ -466,12 +467,12 @@ public class TraditionalT9Settings extends ListActivity implements
if ((pos - last) > 4096) {
// Log.d("doInBackground", "line: " + linecount);
// Log.d("doInBackground", "word: " + word);
publishProgress((int) ((float) pos / size * 10000));
if (size >= 0) { publishProgress((int) ((float) pos / size * 10000)); }
last = pos;
}
word = getLine(br, rpl, fname);
}
publishProgress(10000);
publishProgress((int) ((float) pos / size * 10000));
db.setTransactionSuccessful();
} finally {
db.setLockingEnabled(true);

View file

@ -5,9 +5,7 @@ package org.nyanya.android.traditionalt9.settings;
import android.content.Context;
import android.content.res.XmlResourceParser;
import android.util.AttributeSet;
import android.util.Log;
import org.nyanya.android.traditionalt9.R;
import org.xmlpull.v1.XmlPullParser;
import java.lang.reflect.Constructor;

View file

@ -3,7 +3,6 @@ package org.nyanya.android.traditionalt9.settings;
// https://github.com/codepath/android_guides/wiki/Using-an-ArrayAdapter-with-ListView
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

View file

@ -4,7 +4,6 @@ import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.TextView;
import org.nyanya.android.traditionalt9.LangHelper;