1
0
Fork 0

Big changes: Multilingual, dbupdating, bugfixes:

* Multilingual backend support with initial Russian language support
* Updater service to update the database in the background, and overhauled
backend access
* Fixed long pressing numbers in Lang mode would not input digit
* Fixed Add Word not behaving as you would expect
* Some other minor fixes
This commit is contained in:
Clam 2014-02-17 00:03:14 +11:00
parent 878a8e594a
commit b0d403257b
64 changed files with 3040 additions and 1704 deletions

View file

@ -2,12 +2,15 @@ package org.nyanya.android.traditionalt9;
import android.app.Dialog;
import android.content.Context;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import java.util.Arrays;
public abstract class AbsSymDialog extends Dialog implements
View.OnClickListener {
@ -20,15 +23,15 @@ public abstract class AbsSymDialog extends Dialog implements
private String title;
private boolean started;
private static final int[] buttons = {
private static final int[] buttons = {
R.id.text_keyone, R.id.text_keytwo,
R.id.text_keythree, R.id.text_keyfour, R.id.text_keyfive,
R.id.text_keysix, R.id.text_keyseven, R.id.text_keyeight,
R.id.text_keynine, R.id.text_keyzero
R.id.text_keynine, R.id.text_keyzero
};
private static final int[] buttons2 = {
private static final int[] buttons2 = {
R.id.text_keystar,
R.id.text_keypound
R.id.text_keypound
};
public AbsSymDialog(Context c, View mv) {
@ -279,6 +282,11 @@ public abstract class AbsSymDialog extends Dialog implements
win.setAttributes(lp);
win.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
updateButtons();
show();
try {
show();
} catch (Exception e) {
Log.e("AbsSymDialog", "Cannot create Dialog:");
Log.e("AbsSymDialog", Arrays.toString(e.getStackTrace()));
}
}
}

View file

@ -1,52 +1,87 @@
package org.nyanya.android.traditionalt9;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.app.Activity;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
public class AddWordAct extends Activity {
View main;
int lang;
SharedPreferences pref;
String origword;
@Override
protected void onCreate(Bundle savedData) {
super.onCreate(savedData);
View v = getLayoutInflater().inflate(R.layout.addwordview, null);
EditText et = (EditText) v.findViewById(R.id.add_word_text);
String word = getIntent().getStringExtra("org.nyanya.android.traditionalt9.word");
Intent i = getIntent();
origword = i.getStringExtra("org.nyanya.android.traditionalt9.word");
lang = i.getIntExtra("org.nyanya.android.traditionalt9.lang", -1);
if (lang == -1) {
Log.e("AddWordAct.onCreate", "lang is invalid. How?");
}
// Log.d("AddWord", "data.get: " + word);
et.setText(word);
et.setSelection(word.length());
et.setText(origword);
et.setSelection(origword.length());
setContentView(v);
main = v;
pref = PreferenceManager.getDefaultSharedPreferences(this);
}
public void addWordButton(View v) {
EditText et = (EditText) main.findViewById(R.id.add_word_text);
// Log.d("AddWordAct", "adding word: " + et.getText());
if (TraditionalT9.ghettoaccess == null) {
Log.e("AddWordAct.addWordbutton", "ghettoaccess is null? Oh no.");
} else {
TraditionalT9.ghettoaccess.doAddWord(et.getText().toString());
}
doAddWord(et.getText().toString());
this.finish();
}
public void doAddWord(String text) {
T9DB db = T9DB.getInstance(this);
try {
db.addWord(text, lang);
} catch (DBException e) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
String msg = e.getMessage();
//Log.e("AddWord.doAddWord", msg);
builder.setMessage(msg).setTitle(R.string.add_word)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
// Window win = dialog.getWindow();
// WindowManager.LayoutParams lp = win.getAttributes();
// lp.token = getWindow().getWindow().getDecorView().getWindowToken();
// lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
// win.setAttributes(lp);
// win.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
dialog.show();
}
SharedPreferences.Editor prefedit = pref.edit();
prefedit.putString("last_word", text);
prefedit.commit();
}
public void cancelButton(View v) {
// Log.d("AddWordAct", "Cancelled...");
// TraditionalT9.ghettoaccess.addCancel();
this.finish();
}
@Override
public void onStop() {
TraditionalT9.ghettoaccess.addCancel();
super.onStop();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.

View file

@ -46,16 +46,15 @@ public class CandidateView extends View {
/**
* Construct a CandidateView for showing suggested words for completion.
*
*
* @param context
* @param attrs
*/
public CandidateView(Context context) {
super(context);
mSelectionHighlight = context.getResources().getDrawable(
android.R.drawable.list_selector_background);
mSelectionHighlight.setState(new int[] {
android.R.attr.state_enabled, android.R.attr.state_focused,
mSelectionHighlight.setState(new int[] {
android.R.attr.state_enabled, android.R.attr.state_focused,
android.R.attr.state_window_focused, android.R.attr.state_pressed });
Resources r = context.getResources();

View file

@ -1,5 +1,6 @@
package org.nyanya.android.traditionalt9;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
@ -8,77 +9,101 @@ import java.util.Map;
import android.util.Log;
public class CharMap {
protected static final Map<Character, Integer> CHARTABLE;
protected static final ArrayList<Map<Character, Integer>> CHARTABLE = new ArrayList<Map<Character, Integer>>(2);
static {
Map<Character, Integer> aMap = new HashMap<Character, Integer>();
aMap.put('.', 1); aMap.put(',', 1); aMap.put('!', 1); aMap.put('?', 1);
aMap.put('-', 1); aMap.put('"', 1); aMap.put('\'', 1); aMap.put('@', 1);
aMap.put('#', 1); aMap.put('$', 1); aMap.put('%', 1); aMap.put('&', 1);
aMap.put('*', 1); aMap.put('(', 1); aMap.put(')', 1); aMap.put('1', 1);
aMap.put(':', 1); aMap.put(';', 1); aMap.put('/', 1); aMap.put('\\', 1);
aMap.put('+', 1); aMap.put('=', 1); aMap.put('<', 1); aMap.put('>', 1);
aMap.put('[', 1); aMap.put(']', 1); aMap.put('{', 1); aMap.put('}', 1);
aMap.put('^', 1); aMap.put('|', 1); aMap.put('_', 1); aMap.put('~', 1);
aMap.put('`', 1);
aMap.put('a', 2); aMap.put('\u00e1', 2); aMap.put('\u00e4', 2);
aMap.put('\u00e2', 2); aMap.put('\u00e0', 2); aMap.put('\u00e5', 2);
aMap.put('b', 2); aMap.put('c', 2); aMap.put('\u00e7', 2);
aMap.put('2', 2); aMap.put('d', 3); aMap.put('e', 3);
aMap.put('\u00e9', 3); aMap.put('\u00eb', 3); aMap.put('\u00e8', 3);
aMap.put('\u00ea', 3); aMap.put('f', 3); aMap.put('3', 3);
aMap.put('g', 4); aMap.put('h', 4); aMap.put('i', 4);
aMap.put('\u00ed', 4); aMap.put('\u00ef', 4); aMap.put('4', 4);
aMap.put('j', 5); aMap.put('k', 5); aMap.put('l', 5);
aMap.put('5', 5); aMap.put('m', 6); aMap.put('n', 6);
aMap.put('\u00f1', 6); aMap.put('o', 6); aMap.put('\u00f3', 6);
aMap.put('\u00f6', 6); aMap.put('\u00f4', 6); aMap.put('\u00fb', 6);
aMap.put('6', 6); aMap.put('p', 7); aMap.put('q', 7);
aMap.put('r', 7); aMap.put('s', 7); aMap.put('7', 7);
aMap.put('t', 8); aMap.put('u', 8); aMap.put('\u00fc', 8);
aMap.put('v', 8); aMap.put('8', 8); aMap.put('w', 9);
aMap.put('x', 9); aMap.put('y', 9); aMap.put('z', 9);
aMap.put('9', 9); aMap.put('+', 0); aMap.put('0', 0);
CHARTABLE = Collections.unmodifiableMap(aMap);
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));
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[][] T9TABLE = { { '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 int[] T9CAPSTART = { 0, 0, 3, 3, 3, 3, 3, 4, 3, 4, 0 };
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};
protected static int[] getSequence(String word) {
int[] intseq = new int[word.length()];
String tword = word.toLowerCase(Locale.ENGLISH);
for (int i = 0; i < word.length(); i++) {
char c = tword.charAt(i);
Integer z = CharMap.CHARTABLE.get(c);
if (z == null) {
Log.e("getSequence",
"ERROR: " + (int) c + " NOT FOUND (" + Integer.toHexString((int) c) + ")");
throw new NullPointerException();
}
intseq[i] = z;
}
return intseq;
}
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 String getStringSequence(String word) {
StringBuilder seq = new StringBuilder();
String tword = word.toLowerCase(Locale.ENGLISH);
for (int i = 0; i < word.length(); i++) {
char c = tword.charAt(i);
Integer z = CharMap.CHARTABLE.get(c);
if (z == null) {
Log.e("getStringSequence",
"ERROR: " + (int) c + " NOT FOUND (" + Integer.toHexString((int) c) + ")");
throw new NullPointerException();
}
seq.append(z.toString());
}
return seq.toString();
}
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

@ -0,0 +1,71 @@
package org.nyanya.android.traditionalt9;
import android.app.IntentService;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Handler;
import android.util.Log;
import android.widget.Toast;
public class DBUpdateService extends IntentService {
private static final int UPDATING_NOTIFICATION_ID = 9640142;
private Handler mHandler;
// http://stackoverflow.com/a/20690225
public class DisplayToast implements Runnable {
private final Context mContext;
CharSequence mText;
public DisplayToast(Context mContext, CharSequence text){
this.mContext = mContext;
mText = text;
}
public void run(){
Toast.makeText(mContext, mText, Toast.LENGTH_SHORT).show();
}
}
public DBUpdateService() {
super("DBUpdateService");
mHandler = new Handler();
}
/**
* The IntentService calls this method from the default worker thread with
* the intent that started the service. When this method returns, IntentService
* stops the service, as appropriate.
*/
@Override
protected void onHandleIntent(Intent intent) {
// do things
T9DB dbhelper = T9DB.getInstance(this);
if (dbhelper.getSQLDB(this) != null) {
return;
}
Log.d("T9DBUpdate.onHandle", "Update pass check.");
// do real things
Notification notification = new Notification(R.drawable.ime_en_lang_lower, getText(R.string.updating_database_title),
System.currentTimeMillis());
Intent notificationIntent = new Intent(this, DBUpdateService.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(this, getText(R.string.updating_database_title),
getText(R.string.updating_database), pendingIntent);
startForeground(UPDATING_NOTIFICATION_ID, notification);
//put this in a thread
mHandler.post(new DisplayToast(this, getText(R.string.updating_database)));
SQLiteDatabase tdb = dbhelper.getWritableDatabase();
dbhelper.setSQLDB(tdb);
mHandler.post(new DisplayToast(this, getText(R.string.updating_database_done)));
Log.d("T9DBUpdate.onHandle", "done.");
}
}

View file

@ -126,8 +126,7 @@ public class InterfaceHandler implements View.OnClickListener, View.OnLongClickL
parent.showAddWord();
break;
case R.id.main_right:
((InputMethodManager) parent.getSystemService(Context.INPUT_METHOD_SERVICE))
.showInputMethodPicker();
parent.launchOptions();
break;
default:
return false;

View file

@ -0,0 +1,34 @@
package org.nyanya.android.traditionalt9;
import java.util.Locale;
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 NLANGS = LANGS.length;
protected static String getString(int lang) {
return LANGS[lang];
}
//[LANG][MODE][CAPSMODE] = iconref
// first group en, first line LANG, second line TEXT, last line NUM
protected static final int[][][] ICONMAP = {
{
//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_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
}
};
}

View file

@ -1,11 +1,16 @@
package org.nyanya.android.traditionalt9;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Locale;
import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.database.Cursor;
import android.database.sqlite.SQLiteConstraintException;
@ -13,11 +18,15 @@ import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.BaseColumns;
import android.util.Log;
import android.widget.Toast;
public class T9DB {
private static volatile T9DB instance = null;
protected boolean ready = true;
protected static final String DATABASE_NAME = "t9dict.db";
protected static final int DATABASE_VERSION = 1;
protected static final int DATABASE_VERSION = 2;
protected static final String WORD_TABLE_NAME = "word";
protected static final String FREQ_TRIGGER_NAME = "freqtrigger";
// 50k, 10k
@ -25,11 +34,15 @@ public class T9DB {
private static final int FREQ_DIV = 10000;
protected static final String COLUMN_ID = BaseColumns._ID;
protected static final String COLUMN_LANG = "lang";
protected static final String COLUMN_SEQ = "seq";
protected static final String COLUMN_WORD = "word";
protected static final String COLUMN_FREQUENCY = "freq";
private static final String QUERY1 = "SELECT " + COLUMN_ID + ", " + COLUMN_WORD + " FROM " + WORD_TABLE_NAME +
" WHERE " + COLUMN_LANG + "=? AND " + COLUMN_SEQ + "=?" +
" ORDER BY " + COLUMN_FREQUENCY + " DESC";
private static final int MAX_RESULTS = 8;
private static final int CAPS_OFF = 0;
@ -39,78 +52,157 @@ public class T9DB {
private DatabaseHelper mOpenHelper;
private SQLiteDatabase db;
private Context parent;
private Context mContext;
public T9DB(Context caller) {
// create db
parent = caller;
mContext = caller;
mOpenHelper = new DatabaseHelper(caller);
}
public static SQLiteDatabase getSQLDB(Context caller) {
return new DatabaseHelper(caller).getWritableDatabase();
public static T9DB getInstance(Context caller) {
if (instance == null) {
synchronized (T9DB.class){
if (instance == null) {
instance = new T9DB (caller);
instance.init();
}
}
}
return instance;
}
public void init() {
db = mOpenHelper.getWritableDatabase();
// mOpenHelper.onUpgrade(db, 0, DATABASE_VERSION);
public static SQLiteDatabase getSQLDB(Context caller) {
T9DB t9dbhelper = getInstance(caller);
//Log.d("T9DB.getSQLDB", "db:" + t9dbhelper.db.isOpen());
return t9dbhelper.db;
}
private void init() {
if (mOpenHelper.needsUpgrading() ) {
ready = false;
Log.i("T9.init", "needsUpgrading");
// start updating service
if (db != null) {
try {
db.close();
} catch (NullPointerException e) { }
db = null;
}
Intent intent = new Intent(mContext, DBUpdateService.class);
Log.i("T9.init", "Invoking update service...");
mContext.startService(intent);
} else {
db = mOpenHelper.getWritableDatabase();
}
}
protected boolean checkReady() {
if (ready) {
if (db == null) {
db = getWritableDatabase();
}
return true;
} else {
return false;
}
}
protected SQLiteDatabase getWritableDatabase() {
return mOpenHelper.getWritableDatabase();
}
protected void setSQLDB(SQLiteDatabase tdb) {
synchronized (T9DB.class){
db = tdb;
ready = true;
}
}
public void close() {
db.close();
}
public void nuke() {
init();
mOpenHelper.onUpgrade(db, 0, DATABASE_VERSION);
db.close();
try { db.close(); }
catch (NullPointerException e) { }
db = null;
}
public void addWord(String iword) throws DBException {
Resources r = parent.getResources();
public void nuke() {
Log.i("T9DB.nuke", "Deleting database...");
synchronized (T9DB.class){
if (db != null) {
db.close();
}
if (!mContext.deleteDatabase(DATABASE_NAME)) {
Log.e("T9DB", "Couldn't delete database.");
}
Log.i("T9DB.nuke", "Preparing database...");
getWritableDatabase().close();
db = null;
ready = true;
init();
}
Log.i("T9DB.nuke", "Done...");
}
public void addWord(String iword, int lang) throws DBException {
Resources r = mContext.getResources();
if (iword.equals("")) {
throw new DBException(r.getString(R.string.add_word_blank));
}
// get int sequence
String seq;
try {
seq = CharMap.getStringSequence(iword);
seq = CharMap.getStringSequence(iword, lang);
} catch (NullPointerException e) {
throw new DBException(r.getString(R.string.add_word_badchar));
throw new DBException(r.getString(R.string.add_word_badchar, LangHelper.LANGS[lang]));
}
// add int sequence into num table
ContentValues values = new ContentValues();
values.put(COLUMN_SEQ, seq);
values.put(COLUMN_LANG, lang);
// add word into word
values.put(COLUMN_WORD, iword);
values.put(COLUMN_FREQUENCY, 1);
if (!checkReady()) {
Log.e("T9DB.addWord", "not ready");
Toast.makeText(mContext, R.string.database_notready, Toast.LENGTH_SHORT).show();
return;
}
try {
db.insertOrThrow(WORD_TABLE_NAME, null, values);
} catch (SQLiteConstraintException e) {
String msg = r.getString(R.string.add_word_exist1) + iword
+ r.getString(R.string.add_word_exist2);
String msg = r.getString(R.string.add_word_exist2, iword, LangHelper.LANGS[lang]);
Log.w("T9DB.addWord", msg);
throw new DBException(msg);
}
}
public void incrementWord(int id) {
if (!checkReady()) {
Log.e("T9DB.incrementWord", "not ready");
Toast.makeText(mContext, R.string.database_notready, Toast.LENGTH_SHORT).show();
return;
}
db.execSQL(
"UPDATE " + WORD_TABLE_NAME +
" SET " + COLUMN_FREQUENCY + " = " + COLUMN_FREQUENCY + "+ 1" +
" WHERE " + COLUMN_ID + " = \"" + id + "\"");
// if id's freq is greater than X we should normalise those with the
// same seq
"UPDATE " + WORD_TABLE_NAME +
" SET " + COLUMN_FREQUENCY + " = " + COLUMN_FREQUENCY + "+ 1" +
" WHERE " + COLUMN_ID + " = \"" + id + "\"");
// if id's freq is greater than FREQ_MAX, it gets normalized with trigger
}
protected String getWord(String is) {
protected String getWord(String is, int lang) {
String result = null;
String q =
"SELECT " + COLUMN_WORD + " FROM " + WORD_TABLE_NAME +
" WHERE " + COLUMN_SEQ + "=?" +
" ORDER BY " + COLUMN_FREQUENCY + " DESC";
Cursor cur = db.rawQuery(q, new String[] { is });
String q =
"SELECT " + COLUMN_WORD + " FROM " + WORD_TABLE_NAME +
" WHERE " + COLUMN_LANG + "=? AND " + COLUMN_SEQ + "=?" +
" ORDER BY " + COLUMN_FREQUENCY + " DESC";
if (!checkReady()) {
Log.e("T9DB.getWord", "not ready");
Toast.makeText(mContext, R.string.database_notready, Toast.LENGTH_SHORT).show();
return "";
}
Cursor cur = db.rawQuery(q, new String[] { is, String.valueOf(lang) });
int hits = 0;
if (cur.moveToFirst()) {
result = cur.getString(0);
@ -122,15 +214,15 @@ public class T9DB {
int islen = is.length();
char c = is.charAt(islen - 1);
c++;
q = "SELECT " + COLUMN_WORD + " FROM " + WORD_TABLE_NAME +
" WHERE " + 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, null);
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(1);
result = cur.getString(0);
}
if (result == null) {
result = "";
@ -139,50 +231,48 @@ public class T9DB {
}
return result;
}
public void updateWords(String is, ArrayList<String> stringList, ArrayList<Integer> intList,
int capsMode) {
int capsMode, int lang) {
stringList.clear();
intList.clear();
// String[] sa = packInts(stringToInts(is), true);
int islen = is.length();
String q =
"SELECT " + COLUMN_ID + ", " + COLUMN_WORD + " FROM " + WORD_TABLE_NAME +
" WHERE " + COLUMN_SEQ + "=?" +
" ORDER BY " + COLUMN_FREQUENCY + " DESC";
Cursor cur = db.rawQuery(q, new String[] { is });
if (!checkReady()) {
Log.e("T9DB.updateWords", "not ready");
Toast.makeText(mContext, R.string.database_notready, Toast.LENGTH_SHORT).show();
return;
}
Cursor cur = db.rawQuery(QUERY1, new String[] { String.valueOf(lang), is });
int hits = 0;
for (cur.moveToFirst(); !cur.isAfterLast(); cur.moveToNext()) {
intList.add(cur.getInt(0));
stringList.add(cur.getString(1));
if (hits >= 15) {
break;
}
// if (hits >= 15) {
// break;
// }
hits++;
}
cur.close();
if (hits < 4) {
// TODO: profile this and if it takes too long to only do it when hits is super low...
if (hits < 10) {
char c = is.charAt(islen - 1);
c++;
// q = "SELECT " + COLUMN_WORD +", " + COLUMN_FREQUENCY +
// " FROM " + WORD_TABLE_NAME +
// " WHERE " + COLUMN_SEQ + " LIKE ?" +
// " ORDER BY " + COLUMN_SEQ + " ASC, " + COLUMN_FREQUENCY +
// " DESC;";
// c = db.rawQuery(q, new String[] {is + "_%"});
// above is hella slow below is gotta query fast
q = "SELECT " + COLUMN_ID + ", " + COLUMN_WORD +
" FROM " + WORD_TABLE_NAME +
" WHERE " + 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, null);
String q = "SELECT " + COLUMN_ID + ", " + 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) });
for (cur.moveToFirst(); !cur.isAfterLast(); cur.moveToNext()) {
intList.add(cur.getInt(0));
stringList.add(cur.getString(1));
if (hits >= 10) {
if (hits >= 20) {
break;
}
hits++;
@ -203,36 +293,36 @@ public class T9DB {
while (iter.hasNext()) {
word = iter.next();
switch (capsMode) {
case CAPS_ALL:
wordtemp = word.toUpperCase(Locale.US);
if (wordtemp.equals(word)) {
index++;
continue;
} else if (stringList.contains(wordtemp)) {
// remove this entry
iter.remove();
removed = true;
} else {
stringList.set(index, wordtemp);
}
break;
case CAPS_SINGLE:
if (word.length() > 1) {
wordtemp = word.substring(0, 1).toUpperCase(Locale.US) + word.substring(1);
} else {
wordtemp = word.toUpperCase(Locale.US);
}
if (wordtemp.equals(word)) {
index++;
continue;
} else if (stringList.contains(wordtemp)) {
// remove this entry
iter.remove();
removed = true;
} else {
stringList.set(index, wordtemp);
}
break;
case CAPS_ALL:
wordtemp = word.toUpperCase(LangHelper.LOCALES[lang]);
if (wordtemp.equals(word)) {
index++;
continue;
} else if (stringList.contains(wordtemp)) {
// remove this entry
iter.remove();
removed = true;
} else {
stringList.set(index, wordtemp);
}
break;
case CAPS_SINGLE:
if (word.length() > 1) {
wordtemp = word.substring(0, 1).toUpperCase(LangHelper.LOCALES[lang]) + word.substring(1);
} else {
wordtemp = word.toUpperCase(LangHelper.LOCALES[lang]);
}
if (wordtemp.equals(word)) {
index++;
continue;
} else if (stringList.contains(wordtemp)) {
// remove this entry
iter.remove();
removed = true;
} else {
stringList.set(index, wordtemp);
}
break;
}
if (removed) {
intList.remove(index);
@ -241,21 +331,27 @@ public class T9DB {
index++;
}
}
//Log.d("T9DB.updateWords", "i:" + is + " words:" + Arrays.toString(stringList.toArray()));
return;
}
protected void updateWordsW(String is, ArrayList<String> stringList,
ArrayList<Integer> intList, ArrayList<Integer> freq) {
ArrayList<Integer> intList, ArrayList<Integer> freq, int lang) {
stringList.clear();
intList.clear();
freq.clear();
// String[] sa = packInts(stringToInts(is), true);
int islen = is.length();
String q = "SELECT " + COLUMN_ID + ", " + COLUMN_WORD + ", " + COLUMN_FREQUENCY +
" FROM " + WORD_TABLE_NAME +
" WHERE " + COLUMN_SEQ + "=?" +
" ORDER BY " + COLUMN_FREQUENCY + " DESC";
Cursor cur = db.rawQuery(q, new String[] { is });
String q = "SELECT " + COLUMN_ID + ", " + COLUMN_WORD + ", " + COLUMN_FREQUENCY +
" FROM " + WORD_TABLE_NAME +
" WHERE " + COLUMN_LANG + "=? AND " + COLUMN_SEQ + "=?" +
" ORDER BY " + COLUMN_FREQUENCY + " DESC";
if (!checkReady()) {
Log.e("T9DB.updateWordsW", "not ready");
Toast.makeText(mContext, R.string.database_notready, Toast.LENGTH_SHORT).show();
return;
}
Cursor cur = db.rawQuery(q, new String[] { is, String.valueOf(lang) });
int hits = 0;
for (cur.moveToFirst(); !cur.isAfterLast(); cur.moveToNext()) {
intList.add(cur.getInt(0));
@ -270,20 +366,13 @@ public class T9DB {
if (hits < 4) {
char c = is.charAt(islen - 1);
c++;
// q = "SELECT " + COLUMN_WORD +", " + COLUMN_FREQUENCY +
// " FROM " + WORD_TABLE_NAME +
// " WHERE " + COLUMN_SEQ + " LIKE ?" +
// " ORDER BY " + COLUMN_SEQ + " ASC, " + COLUMN_FREQUENCY +
// " DESC;";
// c = db.rawQuery(q, new String[] {is + "_%"});
// above is hella slow
q = "SELECT " + COLUMN_ID + ", " + COLUMN_WORD + ", " + COLUMN_FREQUENCY +
" FROM " + WORD_TABLE_NAME +
" WHERE " + COLUMN_SEQ + " >= '" + is + "' 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, null);
q = "SELECT " + COLUMN_ID + ", " + COLUMN_WORD + ", " + COLUMN_FREQUENCY +
" FROM " + WORD_TABLE_NAME +
" WHERE " + COLUMN_LANG + "=? AND " + COLUMN_SEQ + " >= '" + is +
"' 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) });
for (cur.moveToFirst(); !cur.isAfterLast(); cur.moveToNext()) {
intList.add(cur.getInt(0));
@ -301,37 +390,64 @@ public class T9DB {
private static class DatabaseHelper extends SQLiteOpenHelper {
Context mContext = null;
DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
mContext = context;
}
// partial code from parent class SQLiteOpenHelper
protected boolean needsUpgrading() {
//quick and dirty check to see if an existing database exists.
if (mContext.databaseList().length > 0) {
SQLiteDatabase db = mContext.openOrCreateDatabase(DATABASE_NAME, 0, null);
int version = db.getVersion();
db.close();
if (version < DATABASE_VERSION) {
return true;
}
else {
return false;
}
} else {
return false;
}
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + WORD_TABLE_NAME + " (" +
COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
COLUMN_SEQ + " TEXT, " +
COLUMN_WORD + " TEXT UNIQUE, " +
COLUMN_FREQUENCY + " INTEGER" + ")");
db.execSQL("CREATE TABLE IF NOT EXISTS " + WORD_TABLE_NAME + " (" +
COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
COLUMN_LANG + " INTEGER, " +
COLUMN_SEQ + " TEXT, " +
COLUMN_WORD + " TEXT, " +
COLUMN_FREQUENCY + " INTEGER, " +
"UNIQUE(" + COLUMN_LANG + ", " + COLUMN_WORD + ") )");
db.execSQL("CREATE INDEX idx ON " + WORD_TABLE_NAME + "("
+ COLUMN_SEQ + " ASC, " + COLUMN_FREQUENCY + " DESC )");
db.execSQL("CREATE TRIGGER " + FREQ_TRIGGER_NAME +
" AFTER UPDATE ON " + WORD_TABLE_NAME +
" WHEN NEW." + COLUMN_FREQUENCY + " > " + FREQ_MAX +
" BEGIN" +
+ COLUMN_LANG + ", " + COLUMN_SEQ + " ASC, " + COLUMN_FREQUENCY + " DESC )");
db.execSQL("CREATE TRIGGER IF NOT EXISTS " + FREQ_TRIGGER_NAME +
" AFTER UPDATE ON " + WORD_TABLE_NAME +
" WHEN NEW." + COLUMN_FREQUENCY + " > " + FREQ_MAX +
" BEGIN" +
" UPDATE " + WORD_TABLE_NAME + " SET " + COLUMN_FREQUENCY + " = "
+ COLUMN_FREQUENCY + " / " + FREQ_DIV +
" WHERE " + COLUMN_SEQ + " = NEW." + COLUMN_SEQ + ";" +
" END;");
+ COLUMN_FREQUENCY + " / " + FREQ_DIV +
" WHERE " + COLUMN_SEQ + " = NEW." + COLUMN_SEQ + ";" +
" END;");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w("T9DB", "Upgrading database from version " + oldVersion + " to " + newVersion
+ ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS " + WORD_TABLE_NAME);
db.execSQL("DROP INDEX IF EXISTS idx");
onCreate(db);
Log.w("T9DB", "Done.");
Log.i("T9DB.onUpgrade", "Upgrading database from version " + oldVersion + " to " + newVersion);
if (oldVersion == 1) {
db.execSQL("ALTER TABLE " + WORD_TABLE_NAME + " ADD COLUMN " +
COLUMN_LANG + " INTEGER");
db.execSQL("DROP INDEX IF EXISTS idx");
onCreate(db);
ContentValues updatedata = new ContentValues();
updatedata.put(COLUMN_LANG, 0);
db.update(WORD_TABLE_NAME, updatedata, null, null);
}
Log.i("T9DB.onUpgrade", "Done.");
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,73 @@
package org.nyanya.android.traditionalt9;
import android.text.InputType;
import android.util.Log;
public class Utils {
public static void printFlags(int inputType) {
if ((inputType & InputType.TYPE_CLASS_DATETIME) == InputType.TYPE_CLASS_DATETIME)
Log.i("Utils.printFlags", "TYPE_CLASS_DATETIME");
if ((inputType & InputType.TYPE_CLASS_NUMBER) == InputType.TYPE_CLASS_NUMBER)
Log.i("Utils.printFlags", "TYPE_CLASS_NUMBER");
if ((inputType & InputType.TYPE_CLASS_PHONE) == InputType.TYPE_CLASS_PHONE)
Log.i("Utils.printFlags", "TYPE_CLASS_PHONE");
if ((inputType & InputType.TYPE_CLASS_TEXT) == InputType.TYPE_CLASS_TEXT)
Log.i("Utils.printFlags", "TYPE_CLASS_TEXT");
if ((inputType & InputType.TYPE_DATETIME_VARIATION_DATE) == InputType.TYPE_DATETIME_VARIATION_DATE)
Log.i("Utils.printFlags", "TYPE_DATETIME_VARIATION_DATE");
if ((inputType & InputType.TYPE_DATETIME_VARIATION_NORMAL) == InputType.TYPE_DATETIME_VARIATION_NORMAL)
Log.i("Utils.printFlags", "TYPE_DATETIME_VARIATION_NORMAL");
if ((inputType & InputType.TYPE_DATETIME_VARIATION_TIME) == InputType.TYPE_DATETIME_VARIATION_TIME)
Log.i("Utils.printFlags", "YPE_DATETIME_VARIATION_TIME");
if ((inputType & InputType.TYPE_NULL) == InputType.TYPE_NULL)
Log.i("Utils.printFlags", "TYPE_NULL");
if ((inputType & InputType.TYPE_NUMBER_FLAG_DECIMAL) == InputType.TYPE_NUMBER_FLAG_DECIMAL)
Log.i("Utils.printFlags", "TYPE_NUMBER_FLAG_DECIMAL");
if ((inputType & InputType.TYPE_NUMBER_FLAG_SIGNED) == InputType.TYPE_NUMBER_FLAG_SIGNED)
Log.i("Utils.printFlags", "TYPE_NUMBER_FLAG_SIGNED");
if ((inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE) == InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE)
Log.i("Utils.printFlags", "TYPE_TEXT_FLAG_AUTO_COMPLETE");
if ((inputType & InputType.TYPE_TEXT_FLAG_AUTO_CORRECT) == InputType.TYPE_TEXT_FLAG_AUTO_CORRECT)
Log.i("Utils.printFlags", "TYPE_TEXT_FLAG_AUTO_CORRECT");
if ((inputType & InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS) == InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS)
Log.i("Utils.printFlags", "TYPE_TEXT_FLAG_CAP_CHARACTERS");
if ((inputType & InputType.TYPE_TEXT_FLAG_CAP_SENTENCES) == InputType.TYPE_TEXT_FLAG_CAP_SENTENCES)
Log.i("Utils.printFlags", "TYPE_TEXT_FLAG_CAP_SENTENCES");
if ((inputType & InputType.TYPE_TEXT_FLAG_CAP_WORDS) == InputType.TYPE_TEXT_FLAG_CAP_WORDS)
Log.i("Utils.printFlags", "TYPE_TEXT_FLAG_CAP_WORDS");
if ((inputType & InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE) == InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE)
Log.i("Utils.printFlags", "TYPE_TEXT_FLAG_IME_MULTI_LINE");
if ((inputType & InputType.TYPE_TEXT_FLAG_MULTI_LINE) == InputType.TYPE_TEXT_FLAG_MULTI_LINE)
Log.i("Utils.printFlags", "TYPE_TEXT_FLAG_MULTI_LINE");
if ((inputType & InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) == InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS)
Log.i("Utils.printFlags", "TYPE_TEXT_FLAG_NO_SUGGESTIONS");
if ((inputType & InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS) == InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS)
Log.i("Utils.printFlags", "TYPE_TEXT_VARIATION_EMAIL_ADDRESS");
if ((inputType & InputType.TYPE_TEXT_VARIATION_EMAIL_SUBJECT) == InputType.TYPE_TEXT_VARIATION_EMAIL_SUBJECT)
Log.i("Utils.printFlags", "TYPE_TEXT_VARIATION_EMAIL_SUBJECT");
if ((inputType & InputType.TYPE_TEXT_VARIATION_FILTER) == InputType.TYPE_TEXT_VARIATION_FILTER)
Log.i("Utils.printFlags", "TYPE_TEXT_VARIATION_FILTER");
if ((inputType & InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE) == InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE)
Log.i("Utils.printFlags", "TYPE_TEXT_VARIATION_LONG_MESSAGE");
if ((inputType & InputType.TYPE_TEXT_VARIATION_NORMAL) == InputType.TYPE_TEXT_VARIATION_NORMAL)
Log.i("Utils.printFlags", "TYPE_TEXT_VARIATION_NORMAL");
if ((inputType & InputType.TYPE_TEXT_VARIATION_PASSWORD) == InputType.TYPE_TEXT_VARIATION_PASSWORD)
Log.i("Utils.printFlags", "TYPE_TEXT_VARIATION_PASSWORD");
if ((inputType & InputType.TYPE_TEXT_VARIATION_PERSON_NAME) == InputType.TYPE_TEXT_VARIATION_PERSON_NAME)
Log.i("Utils.printFlags", "TYPE_TEXT_VARIATION_PERSON_NAME");
if ((inputType & InputType.TYPE_TEXT_VARIATION_PHONETIC) == InputType.TYPE_TEXT_VARIATION_PHONETIC)
Log.i("Utils.printFlags", "TYPE_TEXT_VARIATION_PHONETIC");
if ((inputType & InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS) == InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS)
Log.i("Utils.printFlags", "TYPE_TEXT_VARIATION_POSTAL_ADDRESS");
if ((inputType & InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE) == InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE)
Log.i("Utils.printFlags", "TYPE_TEXT_VARIATION_SHORT_MESSAGE");
if ((inputType & InputType.TYPE_TEXT_VARIATION_URI) == InputType.TYPE_TEXT_VARIATION_URI)
Log.i("Utils.printFlags", "TYPE_TEXT_VARIATION_URI");
if ((inputType & InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD)
Log.i("Utils.printFlags", "TYPE_TEXT_VARIATION_VISIBLE_PASSWORD");
if ((inputType & InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT) == InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT)
Log.i("Utils.printFlags", "TYPE_TEXT_VARIATION_WEB_EDIT_TEXT");
}
}