Fixed some bugs and cleaned up codes
* Fixed crash on backspacing from symbol (1 key) * Hopefully fixed weird crash trying to dismiss view * Fixed long press not working for SoftKeys
This commit is contained in:
parent
38df7d4563
commit
e226f45c26
13 changed files with 1169 additions and 1092 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="org.nyanya.android.traditionalt9"
|
package="org.nyanya.android.traditionalt9"
|
||||||
android:versionCode="2"
|
android:versionCode="4"
|
||||||
android:versionName="1.2" >
|
android:versionName="git" >
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="8"
|
android:minSdkVersion="8"
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
<string name="add_word">Add word</string>
|
<string name="add_word">Add word</string>
|
||||||
<string name="ok">OK</string>
|
<string name="ok">OK</string>
|
||||||
<string name="add_word_blank">Blank word not added.</string>
|
<string name="add_word_blank">Blank word not added.</string>
|
||||||
|
<string name="add_word_badchar">Cannot add word with unmappable symbol.</string>
|
||||||
<string name="add_word_exist1">Word (</string>
|
<string name="add_word_exist1">Word (</string>
|
||||||
<string name="add_word_exist2">) already in DB.</string>
|
<string name="add_word_exist2">) already in DB.</string>
|
||||||
<string name="cancel">Cancel</string>
|
<string name="cancel">Cancel</string>
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public abstract class AbsSymDialog extends Dialog
|
public abstract class AbsSymDialog extends Dialog implements
|
||||||
implements View.OnClickListener {
|
View.OnClickListener {
|
||||||
|
|
||||||
private TraditionalT9 parent;
|
private TraditionalT9 parent;
|
||||||
private View mainview;
|
private View mainview;
|
||||||
|
|
@ -21,11 +21,15 @@ public abstract class AbsSymDialog extends Dialog
|
||||||
private boolean started;
|
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_keyone, R.id.text_keytwo,
|
||||||
R.id.text_keyfour, R.id.text_keyfive, R.id.text_keysix,
|
R.id.text_keythree, R.id.text_keyfour, R.id.text_keyfive,
|
||||||
R.id.text_keyseven, R.id.text_keyeight, R.id.text_keynine,
|
R.id.text_keysix, R.id.text_keyseven, R.id.text_keyeight,
|
||||||
R.id.text_keyzero };
|
R.id.text_keynine, R.id.text_keyzero
|
||||||
private static final int[] buttons2 = { R.id.text_keystar, R.id.text_keypound };
|
};
|
||||||
|
private static final int[] buttons2 = {
|
||||||
|
R.id.text_keystar,
|
||||||
|
R.id.text_keypound
|
||||||
|
};
|
||||||
|
|
||||||
public AbsSymDialog(Context c, View mv) {
|
public AbsSymDialog(Context c, View mv) {
|
||||||
super(c);
|
super(c);
|
||||||
|
|
@ -131,17 +135,20 @@ public abstract class AbsSymDialog extends Dialog
|
||||||
nomore = symsize - 1;
|
nomore = symsize - 1;
|
||||||
}
|
}
|
||||||
for (int buttx = 0; symbx <= stop; symbx++) {
|
for (int buttx = 0; symbx <= stop; symbx++) {
|
||||||
//Log.d("SymbolDialog - updateButtons", "buttx: " + buttx + " symbx: " + symbx);
|
// Log.d("SymbolDialog - updateButtons", "buttx: " + buttx +
|
||||||
|
// " symbx: " + symbx);
|
||||||
if (symbx > nomore) {
|
if (symbx > nomore) {
|
||||||
((TextView) mainview.findViewById(buttons[buttx])).setText("");
|
((TextView) mainview.findViewById(buttons[buttx])).setText("");
|
||||||
} else {
|
} else {
|
||||||
((TextView)mainview.findViewById(buttons[buttx])).setText(String.valueOf(getSymbol(symbx)));
|
((TextView) mainview.findViewById(buttons[buttx]))
|
||||||
|
.setText(String.valueOf(getSymbol(symbx)));
|
||||||
}
|
}
|
||||||
buttx++;
|
buttx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean onKeyDown(int keyCode, KeyEvent event){
|
@Override
|
||||||
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
if (event.getRepeatCount() != 0) {
|
if (event.getRepeatCount() != 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -178,7 +185,8 @@ public abstract class AbsSymDialog extends Dialog
|
||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean onKeyUp(int keyCode, KeyEvent event) {
|
@Override
|
||||||
|
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||||
// Log.d("AbsSymDialog.onKeyUp", "Key: " + keyCode);
|
// Log.d("AbsSymDialog.onKeyUp", "Key: " + keyCode);
|
||||||
if (started) {
|
if (started) {
|
||||||
started = false;
|
started = false;
|
||||||
|
|
@ -211,7 +219,8 @@ public abstract class AbsSymDialog extends Dialog
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
// KeyCharacterMap.load(KeyCharacterMap.BUILT_IN_KEYBOARD).getNumber(keyCode)
|
// KeyCharacterMap.load(KeyCharacterMap.BUILT_IN_KEYBOARD).getNumber(keyCode)
|
||||||
//Log.w("onKeyUp", "Unhandled Key: " + keyCode + "(" + event.toString() + ")");
|
// Log.w("onKeyUp", "Unhandled Key: " + keyCode + "(" +
|
||||||
|
// event.toString() + ")");
|
||||||
}
|
}
|
||||||
return super.onKeyUp(keyCode, event);
|
return super.onKeyUp(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package org.nyanya.android.traditionalt9;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
@ -26,7 +27,11 @@ public class AddWordAct extends Activity {
|
||||||
public void addWordButton(View v) {
|
public void addWordButton(View v) {
|
||||||
EditText et = (EditText) main.findViewById(R.id.add_word_text);
|
EditText et = (EditText) main.findViewById(R.id.add_word_text);
|
||||||
// Log.d("AddWordAct", "adding word: " + et.getText());
|
// 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());
|
TraditionalT9.ghettoaccess.doAddWord(et.getText().toString());
|
||||||
|
}
|
||||||
this.finish();
|
this.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -36,7 +41,8 @@ public class AddWordAct extends Activity {
|
||||||
this.finish();
|
this.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onStop() {
|
@Override
|
||||||
|
public void onStop() {
|
||||||
TraditionalT9.ghettoaccess.addCancel();
|
TraditionalT9.ghettoaccess.addCancel();
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.nyanya.android.traditionalt9.R;
|
import org.nyanya.android.traditionalt9.R;
|
||||||
import org.nyanya.android.traditionalt9.TraditionalT9;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
|
@ -47,6 +46,7 @@ public class CandidateView extends View {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a CandidateView for showing suggested words for completion.
|
* Construct a CandidateView for showing suggested words for completion.
|
||||||
|
*
|
||||||
* @param context
|
* @param context
|
||||||
* @param attrs
|
* @param attrs
|
||||||
*/
|
*/
|
||||||
|
|
@ -55,11 +55,8 @@ public class CandidateView extends View {
|
||||||
mSelectionHighlight = context.getResources().getDrawable(
|
mSelectionHighlight = context.getResources().getDrawable(
|
||||||
android.R.drawable.list_selector_background);
|
android.R.drawable.list_selector_background);
|
||||||
mSelectionHighlight.setState(new int[] {
|
mSelectionHighlight.setState(new int[] {
|
||||||
android.R.attr.state_enabled,
|
android.R.attr.state_enabled, android.R.attr.state_focused,
|
||||||
android.R.attr.state_focused,
|
android.R.attr.state_window_focused, android.R.attr.state_pressed });
|
||||||
android.R.attr.state_window_focused,
|
|
||||||
android.R.attr.state_pressed
|
|
||||||
});
|
|
||||||
|
|
||||||
Resources r = context.getResources();
|
Resources r = context.getResources();
|
||||||
|
|
||||||
|
|
@ -84,14 +81,6 @@ public class CandidateView extends View {
|
||||||
setVerticalScrollBarEnabled(false);
|
setVerticalScrollBarEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A connection back to the service to communicate with the text field
|
|
||||||
* @param listener
|
|
||||||
*/
|
|
||||||
public void setService(TraditionalT9 listener) {
|
|
||||||
//mService = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int computeHorizontalScrollRange() {
|
public int computeHorizontalScrollRange() {
|
||||||
return mTotalWidth;
|
return mTotalWidth;
|
||||||
|
|
@ -105,24 +94,24 @@ public class CandidateView extends View {
|
||||||
// not have a divider below)
|
// not have a divider below)
|
||||||
|
|
||||||
mSelectionHighlight.getPadding(mPadding);
|
mSelectionHighlight.getPadding(mPadding);
|
||||||
final int desiredHeight = ((int)mPaint.getTextSize()) + mVerticalPadding
|
final int desiredHeight = ((int) mPaint.getTextSize()) + mVerticalPadding + mPadding.top
|
||||||
+ mPadding.top + mPadding.bottom;
|
+ mPadding.bottom;
|
||||||
|
|
||||||
// Maximum possible width and desired height
|
// Maximum possible width and desired height
|
||||||
setMeasuredDimension(measuredWidth,
|
setMeasuredDimension(measuredWidth, resolveSize(desiredHeight, heightMeasureSpec));
|
||||||
resolveSize(desiredHeight, heightMeasureSpec));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the canvas is null, then only touch calculations are performed to pick the target
|
* If the canvas is null, then only touch calculations are performed to pick
|
||||||
* candidate.
|
* the target candidate.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void onDraw(Canvas canvas) {
|
protected void onDraw(Canvas canvas) {
|
||||||
super.onDraw(canvas);
|
super.onDraw(canvas);
|
||||||
|
|
||||||
mTotalWidth = 0;
|
mTotalWidth = 0;
|
||||||
if (mSuggestions == null) return;
|
if (mSuggestions == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (mBgPadding == null) {
|
if (mBgPadding == null) {
|
||||||
mBgPadding = new Rect(0, 0, 0, 0);
|
mBgPadding = new Rect(0, 0, 0, 0);
|
||||||
|
|
@ -145,7 +134,8 @@ public class CandidateView extends View {
|
||||||
mWordX[i] = x;
|
mWordX[i] = x;
|
||||||
mWordWidth[i] = wordWidth;
|
mWordWidth[i] = wordWidth;
|
||||||
paint.setColor(mColorNormal);
|
paint.setColor(mColorNormal);
|
||||||
//if (touchX + scrollX >= x && touchX + scrollX < x + wordWidth && !scrolled) {
|
// if (touchX + scrollX >= x && touchX + scrollX < x + wordWidth &&
|
||||||
|
// !scrolled) {
|
||||||
if (i == mSelectedIndex) {
|
if (i == mSelectedIndex) {
|
||||||
canvas.translate(x, 0);
|
canvas.translate(x, 0);
|
||||||
mSelectionHighlight.setBounds(0, bgPadding.top, wordWidth, height);
|
mSelectionHighlight.setBounds(0, bgPadding.top, wordWidth, height);
|
||||||
|
|
@ -153,15 +143,14 @@ public class CandidateView extends View {
|
||||||
canvas.translate(-x, 0);
|
canvas.translate(-x, 0);
|
||||||
paint.setFakeBoldText(true);
|
paint.setFakeBoldText(true);
|
||||||
paint.setColor(mColorRecommended);
|
paint.setColor(mColorRecommended);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
paint.setColor(mColorOther);
|
paint.setColor(mColorOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas.drawText(suggestion, x + X_GAP, y, paint);
|
canvas.drawText(suggestion, x + X_GAP, y, paint);
|
||||||
paint.setColor(mColorOther);
|
paint.setColor(mColorOther);
|
||||||
canvas.drawLine(x + wordWidth + 0.5f, bgPadding.top,
|
canvas.drawLine(x + wordWidth + 0.5f, bgPadding.top, x + wordWidth + 0.5f, height + 1,
|
||||||
x + wordWidth + 0.5f, height + 1, paint);
|
paint);
|
||||||
paint.setFakeBoldText(false);
|
paint.setFakeBoldText(false);
|
||||||
|
|
||||||
x += wordWidth;
|
x += wordWidth;
|
||||||
|
|
@ -211,7 +200,6 @@ public class CandidateView extends View {
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void scrollSuggestion(int increment) {
|
protected void scrollSuggestion(int increment) {
|
||||||
if (mSuggestions != null && mSuggestions.size() > 1) {
|
if (mSuggestions != null && mSuggestions.size() > 1) {
|
||||||
mSelectedIndex = mSelectedIndex + increment;
|
mSelectedIndex = mSelectedIndex + increment;
|
||||||
|
|
@ -235,4 +223,3 @@ public class CandidateView extends View {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,11 @@ public class CharMap {
|
||||||
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('(', 1); aMap.put(')', 1); aMap.put('1', 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('a', 2); aMap.put('\u00e1', 2); aMap.put('\u00e4', 2);
|
||||||
aMap.put('\u00e2', 2); aMap.put('\u00e0', 2); aMap.put('\u00e5', 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('b', 2); aMap.put('c', 2); aMap.put('\u00e7', 2);
|
||||||
|
|
@ -35,18 +40,15 @@ public class CharMap {
|
||||||
aMap.put('9', 9); aMap.put('+', 0); aMap.put('0', 0);
|
aMap.put('9', 9); aMap.put('+', 0); aMap.put('0', 0);
|
||||||
CHARTABLE = Collections.unmodifiableMap(aMap);
|
CHARTABLE = Collections.unmodifiableMap(aMap);
|
||||||
}
|
}
|
||||||
protected static final char[][] T9TABLE = {
|
protected static final char[][] T9TABLE = { { '0', '+' },
|
||||||
{'0', '+'}, {'.', ',', '!', '?', '-', '"', '\'', '@', '#', '$', '%', '&', '*', '(', ')', '1'},
|
{ '.', ',', '!', '?', '-', '"', '\'', '@', '#', '$', '%', '&', '*', '(', ')', '1' },
|
||||||
{ 'a', 'b', 'c', 'A', 'B', 'C', '2' }, { 'd', 'e', 'f', 'D', 'E', 'F', '3' },
|
{ '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' },
|
{ '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' },
|
{ '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' },
|
{ 't', 'u', 'v', 'T', 'U', 'V', '8' }, { 'w', 'x', 'y', 'z', 'W', 'X', 'Y', 'Z', '9' },
|
||||||
{' ', '\n'}
|
{ ' ', '\n' } };
|
||||||
};
|
|
||||||
|
|
||||||
protected static final int[] T9CAPSTART = {
|
protected static final int[] T9CAPSTART = { 0, 0, 3, 3, 3, 3, 3, 4, 3, 4, 0 };
|
||||||
0, 0, 3, 3, 3, 3, 3, 4, 3, 4, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
protected static int[] getSequence(String word) {
|
protected static int[] getSequence(String word) {
|
||||||
int[] intseq = new int[word.length()];
|
int[] intseq = new int[word.length()];
|
||||||
|
|
@ -55,7 +57,8 @@ public class CharMap {
|
||||||
char c = tword.charAt(i);
|
char c = tword.charAt(i);
|
||||||
Integer z = CharMap.CHARTABLE.get(c);
|
Integer z = CharMap.CHARTABLE.get(c);
|
||||||
if (z == null) {
|
if (z == null) {
|
||||||
Log.e("getSequence", "ERROR: "+ (int)c + " NOT FOUND (" + Integer.toHexString((int)c) + ")");
|
Log.e("getSequence",
|
||||||
|
"ERROR: " + (int) c + " NOT FOUND (" + Integer.toHexString((int) c) + ")");
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
}
|
}
|
||||||
intseq[i] = z;
|
intseq[i] = z;
|
||||||
|
|
@ -70,7 +73,8 @@ public class CharMap {
|
||||||
char c = tword.charAt(i);
|
char c = tword.charAt(i);
|
||||||
Integer z = CharMap.CHARTABLE.get(c);
|
Integer z = CharMap.CHARTABLE.get(c);
|
||||||
if (z == null) {
|
if (z == null) {
|
||||||
Log.e("getStringSequence", "ERROR: "+ (int)c + " NOT FOUND (" + Integer.toHexString((int)c) + ")");
|
Log.e("getStringSequence",
|
||||||
|
"ERROR: " + (int) c + " NOT FOUND (" + Integer.toHexString((int) c) + ")");
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
}
|
}
|
||||||
seq.append(z.toString());
|
seq.append(z.toString());
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ public class InterfaceHandler implements View.OnClickListener, View.OnLongClickL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setPressed(int keyCode, boolean pressed) {
|
protected void setPressed(int keyCode, boolean pressed) {
|
||||||
int id = 0;
|
int id = 0;
|
||||||
switch (keyCode) {
|
switch (keyCode) {
|
||||||
|
|
@ -62,11 +63,15 @@ public class InterfaceHandler implements View.OnClickListener, View.OnLongClickL
|
||||||
|
|
||||||
protected void showNotFound(boolean notfound) {
|
protected void showNotFound(boolean notfound) {
|
||||||
if (notfound) {
|
if (notfound) {
|
||||||
((TextView) mainview.findViewById(R.id.left_hold_upper)).setText(R.string.main_left_notfound);
|
((TextView) mainview.findViewById(R.id.left_hold_upper))
|
||||||
((TextView) mainview.findViewById(R.id.left_hold_lower)).setText(R.string.main_left_insert);
|
.setText(R.string.main_left_notfound);
|
||||||
|
((TextView) mainview.findViewById(R.id.left_hold_lower))
|
||||||
|
.setText(R.string.main_left_insert);
|
||||||
} else {
|
} else {
|
||||||
((TextView) mainview.findViewById(R.id.left_hold_upper)).setText(R.string.main_left_insert);
|
((TextView) mainview.findViewById(R.id.left_hold_upper))
|
||||||
((TextView) mainview.findViewById(R.id.left_hold_lower)).setText(R.string.main_left_addword);
|
.setText(R.string.main_left_insert);
|
||||||
|
((TextView) mainview.findViewById(R.id.left_hold_lower))
|
||||||
|
.setText(R.string.main_left_addword);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,7 +87,8 @@ public class InterfaceHandler implements View.OnClickListener, View.OnLongClickL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onClick(View v) {
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case R.id.main_left:
|
case R.id.main_left:
|
||||||
if (parent.mAddingWord) {
|
if (parent.mAddingWord) {
|
||||||
|
|
@ -113,13 +119,15 @@ public class InterfaceHandler implements View.OnClickListener, View.OnLongClickL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean onLongClick(View v) {
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case R.id.main_left:
|
case R.id.main_left:
|
||||||
parent.showAddWord();
|
parent.showAddWord();
|
||||||
break;
|
break;
|
||||||
case R.id.main_right:
|
case R.id.main_right:
|
||||||
((InputMethodManager) parent.getSystemService (Context.INPUT_METHOD_SERVICE)).showInputMethodPicker();
|
((InputMethodManager) parent.getSystemService(Context.INPUT_METHOD_SERVICE))
|
||||||
|
.showInputMethodPicker();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -7,18 +7,14 @@ public class SmileyDialog extends AbsSymDialog {
|
||||||
|
|
||||||
private static final String[] symbols = {
|
private static final String[] symbols = {
|
||||||
// lol wiki http://en.wikipedia.org/wiki/List_of_emoticons
|
// lol wiki http://en.wikipedia.org/wiki/List_of_emoticons
|
||||||
":-)", ":)", ":o)", ":]", ":3", ":c)", ":>", "=]", "=)", ":}",
|
":-)", ":)", ":o)", ":]", ":3", ":c)", ":>", "=]", "=)", ":}", ":-D", ":D", "8-D",
|
||||||
":-D", ":D", "8-D", "8D", "X-D", "XD", "=-D", "=D", "B^D",
|
"8D", "X-D", "XD", "=-D", "=D", "B^D", ">:[", ":-(", ":(", ":c", ":-<", ":<", ":-[",
|
||||||
">:[", ":-(", ":(", ":c", ":-<", ":<", ":-[", ":[", ":{",
|
":[", ":{", ":'-(", ":'(", ":'-)", ":')", ":@", "D:<", "D:", "D8", "D;", "D=", "DX",
|
||||||
":'-(", ":'(", ":'-)", ":')", ":@", "D:<", "D:", "D8", "D;", "D=", "DX",
|
"v.v", "D-':", ">:O", ":-O", ":O", ":O", "o_O", "o_0", "o.O", "8-0", ":*", ";-)", ";)",
|
||||||
"v.v", "D-':", ">:O", ":-O", ":O", ":O", "o_O", "o_0", "o.O", "8-0",
|
";-]", ";]", ";D", ">:P", ":-P", ":P", "XP", "xp", ":-p", ":p", "=p", ":-b", ":b",
|
||||||
":*", ";-)", ";)", ";-]", ";]", ";D",
|
">:\\", ">:/", ":-/", ":-.", ":/", ":\\", "=/", "=\\", ":L", "=L", ":S", ">.<", ":|",
|
||||||
">:P", ":-P", ":P", "XP", "xp", ":-p", ":p", "=p", ":-b", ":b",
|
":-|", ":$", ":-X", ":X", ":-#", ":#", "O:-)", "0:-3", "0:3", "0:-)", "0:)", ">:)",
|
||||||
">:\\", ">:/", ":-/", ":-.", ":/", ":\\", "=/", "=\\", ":L", "=L", ":S", ">.<",
|
">;)", ">:-)", ">_>", "<_<", "\\o/", "<3", "</3", "=-3", "=3", };
|
||||||
":|", ":-|", ":$", ":-X", ":X", ":-#", ":#", "O:-)", "0:-3", "0:3", "0:-)", "0:)",
|
|
||||||
">:)", ">;)", ">:-)", ">_>", "<_<", "\\o/", "<3", "</3",
|
|
||||||
"=-3", "=3",
|
|
||||||
};
|
|
||||||
|
|
||||||
private static final int MAX_PAGE = (int) Math.ceil(symbols.length / 10.0);
|
private static final int MAX_PAGE = (int) Math.ceil(symbols.length / 10.0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,11 @@ package org.nyanya.android.traditionalt9;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
|
||||||
public class SymbolDialog extends AbsSymDialog {
|
public class SymbolDialog extends AbsSymDialog {
|
||||||
|
|
||||||
private static final char[] symbols = {
|
private static final char[] symbols = {
|
||||||
'.', ',', '!', '?', '$', '&', '%', '#', '@', '"', '\'', ':', ';', '(', ')', '/', '\\',
|
'.', ',', '!', '?', '$', '&', '%', '#', '@', '"', '\'', ':', ';', '(', ')', '/', '\\',
|
||||||
'-', '+', '=', '*', '<', '>', '[', ']', '{', '}', '^', '|', '_', '~', '`'
|
'-', '+', '=', '*', '<', '>', '[', ']', '{', '}', '^', '|', '_', '~', '`' }; // 32
|
||||||
}; //32
|
|
||||||
private static final int MAX_PAGE = (int) Math.ceil(symbols.length / 10.0);
|
private static final int MAX_PAGE = (int) Math.ceil(symbols.length / 10.0);
|
||||||
|
|
||||||
public SymbolDialog(Context c, View mv) {
|
public SymbolDialog(Context c, View mv) {
|
||||||
|
|
@ -36,6 +34,4 @@ public class SymbolDialog extends AbsSymDialog {
|
||||||
return MAX_PAGE;
|
return MAX_PAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -73,7 +73,12 @@ public class T9DB {
|
||||||
throw new DBException(r.getString(R.string.add_word_blank));
|
throw new DBException(r.getString(R.string.add_word_blank));
|
||||||
}
|
}
|
||||||
// get int sequence
|
// get int sequence
|
||||||
String seq = CharMap.getStringSequence(iword);
|
String seq;
|
||||||
|
try {
|
||||||
|
seq = CharMap.getStringSequence(iword);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
throw new DBException(r.getString(R.string.add_word_badchar));
|
||||||
|
}
|
||||||
// add int sequence into num table
|
// add int sequence into num table
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put(COLUMN_SEQ, seq);
|
values.put(COLUMN_SEQ, seq);
|
||||||
|
|
@ -83,25 +88,66 @@ public class T9DB {
|
||||||
try {
|
try {
|
||||||
db.insertOrThrow(WORD_TABLE_NAME, null, values);
|
db.insertOrThrow(WORD_TABLE_NAME, null, values);
|
||||||
} catch (SQLiteConstraintException e) {
|
} 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_exist1) + iword
|
||||||
|
+ r.getString(R.string.add_word_exist2);
|
||||||
Log.w("T9DB.addWord", msg);
|
Log.w("T9DB.addWord", msg);
|
||||||
throw new DBException(msg);
|
throw new DBException(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void incrementWord(int id) {
|
public void incrementWord(int id) {
|
||||||
db.execSQL("UPDATE " + WORD_TABLE_NAME + " SET " + COLUMN_FREQUENCY + " = " +
|
db.execSQL(
|
||||||
COLUMN_FREQUENCY + "+ 1 WHERE " + COLUMN_ID + " = \"" + id + "\"");
|
"UPDATE " + WORD_TABLE_NAME +
|
||||||
// if id's freq is greater than X we should normalise those with the same seq
|
" 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
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateWords(String is, ArrayList<String> stringList, ArrayList<Integer> intList, int capsMode){
|
protected String getWord(String is) {
|
||||||
|
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 });
|
||||||
|
int hits = 0;
|
||||||
|
if (cur.moveToFirst()) {
|
||||||
|
result = cur.getString(0);
|
||||||
|
}
|
||||||
|
cur.close();
|
||||||
|
if (result != null) {
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
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);
|
||||||
|
|
||||||
|
if (cur.moveToFirst()) {
|
||||||
|
result = cur.getString(1);
|
||||||
|
}
|
||||||
|
if (result == null) {
|
||||||
|
result = "";
|
||||||
|
}
|
||||||
|
cur.close();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateWords(String is, ArrayList<String> stringList, ArrayList<Integer> intList,
|
||||||
|
int capsMode) {
|
||||||
stringList.clear();
|
stringList.clear();
|
||||||
intList.clear();
|
intList.clear();
|
||||||
// String[] sa = packInts(stringToInts(is), true);
|
// String[] sa = packInts(stringToInts(is), true);
|
||||||
int islen = is.length();
|
int islen = is.length();
|
||||||
String q = "SELECT " + COLUMN_ID + ", " + COLUMN_WORD +
|
String q =
|
||||||
" FROM " + WORD_TABLE_NAME +
|
"SELECT " + COLUMN_ID + ", " + COLUMN_WORD + " FROM " + WORD_TABLE_NAME +
|
||||||
" WHERE " + COLUMN_SEQ + "=?" +
|
" WHERE " + COLUMN_SEQ + "=?" +
|
||||||
" ORDER BY " + COLUMN_FREQUENCY + " DESC";
|
" ORDER BY " + COLUMN_FREQUENCY + " DESC";
|
||||||
Cursor cur = db.rawQuery(q, new String[] { is });
|
Cursor cur = db.rawQuery(q, new String[] { is });
|
||||||
|
|
@ -121,12 +167,14 @@ public class T9DB {
|
||||||
// q = "SELECT " + COLUMN_WORD +", " + COLUMN_FREQUENCY +
|
// q = "SELECT " + COLUMN_WORD +", " + COLUMN_FREQUENCY +
|
||||||
// " FROM " + WORD_TABLE_NAME +
|
// " FROM " + WORD_TABLE_NAME +
|
||||||
// " WHERE " + COLUMN_SEQ + " LIKE ?" +
|
// " WHERE " + COLUMN_SEQ + " LIKE ?" +
|
||||||
// " ORDER BY " + COLUMN_SEQ + " ASC, " + COLUMN_FREQUENCY + " DESC;";
|
// " ORDER BY " + COLUMN_SEQ + " ASC, " + COLUMN_FREQUENCY +
|
||||||
|
// " DESC;";
|
||||||
// c = db.rawQuery(q, new String[] {is + "_%"});
|
// c = db.rawQuery(q, new String[] {is + "_%"});
|
||||||
// above is hella slow below is gotta query fast
|
// above is hella slow below is gotta query fast
|
||||||
q = "SELECT " + COLUMN_ID + ", " + COLUMN_WORD +
|
q = "SELECT " + COLUMN_ID + ", " + COLUMN_WORD +
|
||||||
" FROM " + WORD_TABLE_NAME +
|
" FROM " + WORD_TABLE_NAME +
|
||||||
" WHERE " + COLUMN_SEQ + " >= '" + is + "1" + "' AND " + COLUMN_SEQ + " < '" + is.substring(0, islen-1) + c + "'" +
|
" WHERE " + COLUMN_SEQ + " >= '" + is + "1" + "' AND " + COLUMN_SEQ + " < '"
|
||||||
|
+ is.substring(0, islen - 1) + c + "'" +
|
||||||
" ORDER BY " + COLUMN_FREQUENCY + " DESC, " + COLUMN_SEQ + " ASC" +
|
" ORDER BY " + COLUMN_FREQUENCY + " DESC, " + COLUMN_SEQ + " ASC" +
|
||||||
" LIMIT " + (MAX_RESULTS - hits);
|
" LIMIT " + (MAX_RESULTS - hits);
|
||||||
cur = db.rawQuery(q, null);
|
cur = db.rawQuery(q, null);
|
||||||
|
|
@ -196,9 +244,8 @@ public class T9DB {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void updateWordsW(String is, ArrayList<String> stringList,
|
||||||
protected void updateWordsW(String is, ArrayList<String> stringList, ArrayList<Integer> intList,
|
ArrayList<Integer> intList, ArrayList<Integer> freq) {
|
||||||
ArrayList<Integer> freq){
|
|
||||||
stringList.clear();
|
stringList.clear();
|
||||||
intList.clear();
|
intList.clear();
|
||||||
freq.clear();
|
freq.clear();
|
||||||
|
|
@ -226,12 +273,14 @@ public class T9DB {
|
||||||
// q = "SELECT " + COLUMN_WORD +", " + COLUMN_FREQUENCY +
|
// q = "SELECT " + COLUMN_WORD +", " + COLUMN_FREQUENCY +
|
||||||
// " FROM " + WORD_TABLE_NAME +
|
// " FROM " + WORD_TABLE_NAME +
|
||||||
// " WHERE " + COLUMN_SEQ + " LIKE ?" +
|
// " WHERE " + COLUMN_SEQ + " LIKE ?" +
|
||||||
// " ORDER BY " + COLUMN_SEQ + " ASC, " + COLUMN_FREQUENCY + " DESC;";
|
// " ORDER BY " + COLUMN_SEQ + " ASC, " + COLUMN_FREQUENCY +
|
||||||
|
// " DESC;";
|
||||||
// c = db.rawQuery(q, new String[] {is + "_%"});
|
// c = db.rawQuery(q, new String[] {is + "_%"});
|
||||||
// above is hella slow
|
// above is hella slow
|
||||||
q = "SELECT " + COLUMN_ID + ", " + COLUMN_WORD + ", " + COLUMN_FREQUENCY +
|
q = "SELECT " + COLUMN_ID + ", " + COLUMN_WORD + ", " + COLUMN_FREQUENCY +
|
||||||
" FROM " + WORD_TABLE_NAME +
|
" FROM " + WORD_TABLE_NAME +
|
||||||
" WHERE " + COLUMN_SEQ + " >= '" + is + "' AND " + COLUMN_SEQ + " < '" + is.substring(0, islen-1) + c + "'" +
|
" WHERE " + COLUMN_SEQ + " >= '" + is + "' AND " + COLUMN_SEQ
|
||||||
|
+ " < '" + is.substring(0, islen - 1) + c + "'" +
|
||||||
" ORDER BY " + COLUMN_FREQUENCY + " DESC, " + COLUMN_SEQ + " ASC" +
|
" ORDER BY " + COLUMN_FREQUENCY + " DESC, " + COLUMN_SEQ + " ASC" +
|
||||||
" LIMIT " + (MAX_RESULTS - hits);
|
" LIMIT " + (MAX_RESULTS - hits);
|
||||||
cur = db.rawQuery(q, null);
|
cur = db.rawQuery(q, null);
|
||||||
|
|
@ -250,35 +299,6 @@ public class T9DB {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected static int[] stringToInts(String s){
|
|
||||||
int[] il = new int[s.length()];
|
|
||||||
for (int x = 0; x < s.length(); x++){
|
|
||||||
il[x] = s.charAt(x) - 48; //lol hope this is ASCII all the time
|
|
||||||
}
|
|
||||||
return il;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static String[] packInts(int[] intseq, boolean stringArray){
|
|
||||||
int[] ia = packInts(intseq);
|
|
||||||
String[] sa = {Integer.toString(ia[0]), Integer.toString(ia[1])};
|
|
||||||
return sa;
|
|
||||||
}
|
|
||||||
protected static int[] packInts(int[] intseq){
|
|
||||||
int[] ia = {0, 0};
|
|
||||||
|
|
||||||
for (int x = 0; x < intseq.length; x++){
|
|
||||||
if (x < 8){
|
|
||||||
//packing 8 ints (<10) into 32bit int ... I hope...
|
|
||||||
ia[0] = ia[0] | (intseq[x] << x*4);
|
|
||||||
} else {
|
|
||||||
ia[1] = intseq[x] << (x % 8) * 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ia;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class DatabaseHelper extends SQLiteOpenHelper {
|
private static class DatabaseHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
DatabaseHelper(Context context) {
|
DatabaseHelper(Context context) {
|
||||||
|
|
@ -287,27 +307,27 @@ public class T9DB {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(SQLiteDatabase db) {
|
public void onCreate(SQLiteDatabase db) {
|
||||||
db.execSQL("CREATE TABLE " + WORD_TABLE_NAME + " ("
|
db.execSQL("CREATE TABLE " + WORD_TABLE_NAME + " (" +
|
||||||
+ COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
|
COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||||
+ COLUMN_SEQ + " TEXT, "
|
COLUMN_SEQ + " TEXT, " +
|
||||||
+ COLUMN_WORD + " TEXT UNIQUE, "
|
COLUMN_WORD + " TEXT UNIQUE, " +
|
||||||
+ COLUMN_FREQUENCY + " INTEGER"
|
COLUMN_FREQUENCY + " INTEGER" + ")");
|
||||||
+ ")");
|
|
||||||
db.execSQL("CREATE INDEX idx ON " + WORD_TABLE_NAME + "("
|
db.execSQL("CREATE INDEX idx ON " + WORD_TABLE_NAME + "("
|
||||||
//+ COLUMN_NUMHIGH + ", " + COLUMN_NUMLOW + ")");
|
|
||||||
+ COLUMN_SEQ + " ASC, " + COLUMN_FREQUENCY + " DESC )");
|
+ COLUMN_SEQ + " ASC, " + COLUMN_FREQUENCY + " DESC )");
|
||||||
db.execSQL("CREATE TRIGGER " + FREQ_TRIGGER_NAME + " AFTER UPDATE ON " + WORD_TABLE_NAME
|
db.execSQL("CREATE TRIGGER " + FREQ_TRIGGER_NAME +
|
||||||
+ " WHEN NEW." + COLUMN_FREQUENCY + " > " + FREQ_MAX
|
" AFTER UPDATE ON " + WORD_TABLE_NAME +
|
||||||
+ " BEGIN"
|
" WHEN NEW." + COLUMN_FREQUENCY + " > " + FREQ_MAX +
|
||||||
+ " UPDATE " + WORD_TABLE_NAME + " SET " + COLUMN_FREQUENCY
|
" BEGIN" +
|
||||||
+ " = " + COLUMN_FREQUENCY + " / " + FREQ_DIV + " WHERE " + COLUMN_SEQ + " = NEW." + COLUMN_SEQ + ";"
|
" UPDATE " + WORD_TABLE_NAME + " SET " + COLUMN_FREQUENCY + " = "
|
||||||
+ " END;");
|
+ COLUMN_FREQUENCY + " / " + FREQ_DIV +
|
||||||
|
" WHERE " + COLUMN_SEQ + " = NEW." + COLUMN_SEQ + ";" +
|
||||||
|
" END;");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
Log.w("T9DB", "Upgrading database from version " + oldVersion + " to "
|
Log.w("T9DB", "Upgrading database from version " + oldVersion + " to " + newVersion
|
||||||
+ newVersion + ", which will destroy all old data");
|
+ ", which will destroy all old data");
|
||||||
db.execSQL("DROP TABLE IF EXISTS " + WORD_TABLE_NAME);
|
db.execSQL("DROP TABLE IF EXISTS " + WORD_TABLE_NAME);
|
||||||
db.execSQL("DROP INDEX IF EXISTS idx");
|
db.execSQL("DROP INDEX IF EXISTS idx");
|
||||||
onCreate(db);
|
onCreate(db);
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import android.inputmethodservice.InputMethodService;
|
||||||
import android.inputmethodservice.KeyboardView;
|
import android.inputmethodservice.KeyboardView;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.text.InputType;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
|
|
@ -26,8 +27,8 @@ import android.view.inputmethod.EditorInfo;
|
||||||
import android.view.inputmethod.InputConnection;
|
import android.view.inputmethod.InputConnection;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
|
||||||
public class TraditionalT9 extends InputMethodService
|
public class TraditionalT9 extends InputMethodService implements
|
||||||
implements KeyboardView.OnKeyboardActionListener {
|
KeyboardView.OnKeyboardActionListener {
|
||||||
|
|
||||||
private CandidateView mCandidateView;
|
private CandidateView mCandidateView;
|
||||||
private InterfaceHandler interfacehandler = null;
|
private InterfaceHandler interfacehandler = null;
|
||||||
|
|
@ -39,7 +40,6 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
private ArrayList<Integer> mSuggestionInts = new ArrayList<Integer>(10);
|
private ArrayList<Integer> mSuggestionInts = new ArrayList<Integer>(10);
|
||||||
private ArrayList<String> mSuggestionSym = new ArrayList<String>(16);
|
private ArrayList<String> mSuggestionSym = new ArrayList<String>(16);
|
||||||
|
|
||||||
|
|
||||||
private static final int NON_EDIT = 0;
|
private static final int NON_EDIT = 0;
|
||||||
private static final int EDITING = 1;
|
private static final int EDITING = 1;
|
||||||
private static final int EDITING_NOSHOW = 2;
|
private static final int EDITING_NOSHOW = 2;
|
||||||
|
|
@ -67,6 +67,7 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
|
|
||||||
final Handler t9releasehandler = new Handler();
|
final Handler t9releasehandler = new Handler();
|
||||||
Runnable mt9release = new Runnable() {
|
Runnable mt9release = new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
commitReset();
|
commitReset();
|
||||||
}
|
}
|
||||||
|
|
@ -82,12 +83,12 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
private static final int[] MODE_CYCLE = { MODE_EN, MODE_TEXT, MODE_NUM };
|
private static final int[] MODE_CYCLE = { MODE_EN, MODE_TEXT, MODE_NUM };
|
||||||
private int mKeyMode;
|
private int mKeyMode;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main initialization of the input method component. Be sure to call
|
* Main initialization of the input method component. Be sure to call to
|
||||||
* to super class.
|
* super class.
|
||||||
*/
|
*/
|
||||||
@Override public void onCreate() {
|
@Override
|
||||||
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
|
||||||
mPrevious = -1;
|
mPrevious = -1;
|
||||||
|
|
@ -96,21 +97,13 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
db.init();
|
db.init();
|
||||||
|
|
||||||
if (interfacehandler == null) {
|
if (interfacehandler == null) {
|
||||||
interfacehandler = new InterfaceHandler(
|
interfacehandler = new InterfaceHandler(getLayoutInflater().inflate(R.layout.mainview,
|
||||||
getLayoutInflater().inflate(R.layout.mainview, null), this);
|
null), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* This is the point where you can do all of your UI initialization. It
|
public boolean onEvaluateInputViewShown() {
|
||||||
* is called after creation and any configuration change.
|
|
||||||
*/
|
|
||||||
// @Override public void onInitializeInterface() {
|
|
||||||
// //maybe do some stuff
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override public boolean onEvaluateInputViewShown (){
|
|
||||||
if (mEditing == EDITING_NOSHOW) {
|
if (mEditing == EDITING_NOSHOW) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -118,12 +111,13 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by the framework when your view for creating input needs to
|
* Called by the framework when your view for creating input needs to be
|
||||||
* be generated. This will be called the first time your input method
|
* generated. This will be called the first time your input method is
|
||||||
* is displayed, and every time it needs to be re-created such as due to
|
* displayed, and every time it needs to be re-created such as due to a
|
||||||
* a configuration change.
|
* configuration change.
|
||||||
*/
|
*/
|
||||||
@Override public View onCreateInputView() {
|
@Override
|
||||||
|
public View onCreateInputView() {
|
||||||
updateKeyMode();
|
updateKeyMode();
|
||||||
View v = getLayoutInflater().inflate(R.layout.mainview, null);
|
View v = getLayoutInflater().inflate(R.layout.mainview, null);
|
||||||
interfacehandler.changeView(v);
|
interfacehandler.changeView(v);
|
||||||
|
|
@ -135,26 +129,28 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by the framework when your view for showing candidates needs to
|
* Called by the framework when your view for showing candidates needs to be
|
||||||
* be generated, like {@link #onCreateInputView}.
|
* generated, like {@link #onCreateInputView}.
|
||||||
*/
|
*/
|
||||||
@Override public View onCreateCandidatesView() {
|
@Override
|
||||||
|
public View onCreateCandidatesView() {
|
||||||
mCandidateView = new CandidateView(this);
|
mCandidateView = new CandidateView(this);
|
||||||
mCandidateView.setService(this);
|
|
||||||
return mCandidateView;
|
return mCandidateView;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void showSymbolPage() {
|
protected void showSymbolPage() {
|
||||||
if (mSymbolPopup == null) {
|
if (mSymbolPopup == null) {
|
||||||
mSymbolPopup = new SymbolDialog(this, getLayoutInflater().inflate(R.layout.symbolview, null));
|
mSymbolPopup = new SymbolDialog(this, getLayoutInflater().inflate(R.layout.symbolview,
|
||||||
|
null));
|
||||||
}
|
}
|
||||||
mSymbolPopup.doShow(getWindow().getWindow().getDecorView());
|
mSymbolPopup.doShow(getWindow().getWindow().getDecorView());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void showSmileyPage() {
|
protected void showSmileyPage() {
|
||||||
if (mSmileyPopup == null) {
|
if (mSmileyPopup == null) {
|
||||||
mSmileyPopup = new SmileyDialog(this, getLayoutInflater().inflate(R.layout.symbolview, null));
|
mSmileyPopup = new SmileyDialog(this, getLayoutInflater().inflate(R.layout.symbolview,
|
||||||
|
null));
|
||||||
}
|
}
|
||||||
mSmileyPopup.doShow(getWindow().getWindow().getDecorView());
|
mSmileyPopup.doShow(getWindow().getWindow().getDecorView());
|
||||||
}
|
}
|
||||||
|
|
@ -175,8 +171,9 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
db.addWord(text);
|
db.addWord(text);
|
||||||
} catch (DBException e) {
|
} catch (DBException e) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setMessage(e.getMessage())
|
builder.setMessage(e.getMessage()).setTitle(R.string.add_word)
|
||||||
.setTitle(R.string.add_word).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
|
|
@ -201,13 +198,15 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the main point where we do our initialization of the input method
|
* This is the main point where we do our initialization of the input method
|
||||||
* to begin operating on an application. At this point we have been
|
* to begin operating on an application. At this point we have been bound to
|
||||||
* bound to the client, and are now receiving all of the detailed information
|
* the client, and are now receiving all of the detailed information about
|
||||||
* about the target of our edits.
|
* the target of our edits.
|
||||||
*/
|
*/
|
||||||
@Override public void onStartInput(EditorInfo attribute, boolean restarting) {
|
@Override
|
||||||
|
public void onStartInput(EditorInfo attribute, boolean restarting) {
|
||||||
super.onStartInput(attribute, restarting);
|
super.onStartInput(attribute, restarting);
|
||||||
//Log.d("onStartInput", "attribute.inputType: " + attribute.inputType + " restarting? " + restarting);
|
// Log.d("onStartInput", "attribute.inputType: " + attribute.inputType +
|
||||||
|
// " restarting? " + restarting);
|
||||||
if (attribute.inputType == 0) {
|
if (attribute.inputType == 0) {
|
||||||
// don't do anything when not in any kind of edit field.
|
// don't do anything when not in any kind of edit field.
|
||||||
// should also turn off input screen and stuff
|
// should also turn off input screen and stuff
|
||||||
|
|
@ -219,7 +218,8 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
mFirstPress = true;
|
mFirstPress = true;
|
||||||
mEditing = EDITING;
|
mEditing = EDITING;
|
||||||
// Reset our state. We want to do this even if restarting, because
|
// Reset our state. We want to do this even if restarting, because
|
||||||
// the underlying state of the text editor could have changed in any way.
|
// the underlying state of the text editor could have changed in any
|
||||||
|
// way.
|
||||||
mSuggestionStrings.clear();
|
mSuggestionStrings.clear();
|
||||||
mSuggestionInts.clear();
|
mSuggestionInts.clear();
|
||||||
mSuggestionSym.clear();
|
mSuggestionSym.clear();
|
||||||
|
|
@ -237,21 +237,21 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
|
|
||||||
// We are now going to initialize our state based on the type of
|
// We are now going to initialize our state based on the type of
|
||||||
// text being edited.
|
// text being edited.
|
||||||
switch (attribute.inputType & EditorInfo.TYPE_MASK_CLASS) {
|
switch (attribute.inputType & InputType.TYPE_MASK_CLASS) {
|
||||||
case EditorInfo.TYPE_CLASS_NUMBER:
|
case InputType.TYPE_CLASS_NUMBER:
|
||||||
case EditorInfo.TYPE_CLASS_DATETIME:
|
case InputType.TYPE_CLASS_DATETIME:
|
||||||
// Numbers and dates default to the symbols keyboard, with
|
// Numbers and dates default to the symbols keyboard, with
|
||||||
// no extra features.
|
// no extra features.
|
||||||
mKeyMode = MODE_NUM;
|
mKeyMode = MODE_NUM;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EditorInfo.TYPE_CLASS_PHONE:
|
case InputType.TYPE_CLASS_PHONE:
|
||||||
// Phones will also default to the symbols keyboard, though
|
// Phones will also default to the symbols keyboard, though
|
||||||
// often you will want to have a dedicated phone keyboard.
|
// often you will want to have a dedicated phone keyboard.
|
||||||
mKeyMode = MODE_NUM;
|
mKeyMode = MODE_NUM;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EditorInfo.TYPE_CLASS_TEXT:
|
case InputType.TYPE_CLASS_TEXT:
|
||||||
// This is general text editing. We will default to the
|
// This is general text editing. We will default to the
|
||||||
// normal alphabetic keyboard, and assume that we should
|
// normal alphabetic keyboard, and assume that we should
|
||||||
// be doing predictive text (showing candidates as the
|
// be doing predictive text (showing candidates as the
|
||||||
|
|
@ -260,23 +260,23 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
|
|
||||||
// We now look for a few special variations of text that will
|
// We now look for a few special variations of text that will
|
||||||
// modify our behavior.
|
// modify our behavior.
|
||||||
int variation = attribute.inputType & EditorInfo.TYPE_MASK_VARIATION;
|
int variation = attribute.inputType & InputType.TYPE_MASK_VARIATION;
|
||||||
if (variation == EditorInfo.TYPE_TEXT_VARIATION_PASSWORD ||
|
if (variation == InputType.TYPE_TEXT_VARIATION_PASSWORD
|
||||||
variation == EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) {
|
|| variation == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) {
|
||||||
// Do not display predictions / what the user is typing
|
// Do not display predictions / what the user is typing
|
||||||
// when they are entering a password.
|
// when they are entering a password.
|
||||||
mKeyMode = MODE_TEXT;
|
mKeyMode = MODE_TEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (variation == EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
|
if (variation == InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
|
||||||
|| variation == EditorInfo.TYPE_TEXT_VARIATION_URI
|
|| variation == InputType.TYPE_TEXT_VARIATION_URI
|
||||||
|| variation == EditorInfo.TYPE_TEXT_VARIATION_FILTER) {
|
|| variation == InputType.TYPE_TEXT_VARIATION_FILTER) {
|
||||||
// Our predictions are not useful for e-mail addresses
|
// Our predictions are not useful for e-mail addresses
|
||||||
// or URIs.
|
// or URIs.
|
||||||
mKeyMode = MODE_TEXT;
|
mKeyMode = MODE_TEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((attribute.inputType & EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE) != 0) {
|
if ((attribute.inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE) != 0) {
|
||||||
// If this is an auto-complete text view, then our predictions
|
// If this is an auto-complete text view, then our predictions
|
||||||
// will not be shown and instead we will allow the editor
|
// will not be shown and instead we will allow the editor
|
||||||
// to supply their own. We only show the editor's
|
// to supply their own. We only show the editor's
|
||||||
|
|
@ -286,8 +286,9 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
mKeyMode = Integer.parseInt(pref.getString("pref_inputmode", "0"));
|
mKeyMode = Integer.parseInt(pref.getString("pref_inputmode", "0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//handle filter list cases... do not hijack DPAD center and make sure back's go through proper
|
// handle filter list cases... do not hijack DPAD center and make
|
||||||
if ((attribute.inputType & EditorInfo.TYPE_TEXT_VARIATION_FILTER) != 0) {
|
// sure back's go through proper
|
||||||
|
if ((attribute.inputType & InputType.TYPE_TEXT_VARIATION_FILTER) != 0) {
|
||||||
mEditing = EDITING_NOSHOW;
|
mEditing = EDITING_NOSHOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -303,8 +304,8 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
// keyboard with no special features.
|
// keyboard with no special features.
|
||||||
updateShiftKeyState(attribute);
|
updateShiftKeyState(attribute);
|
||||||
}
|
}
|
||||||
if (attribute.privateImeOptions != null &&
|
if (attribute.privateImeOptions != null
|
||||||
attribute.privateImeOptions.equals("org.nyanya.android.traditionalt9.addword=true")) {
|
&& attribute.privateImeOptions.equals("org.nyanya.android.traditionalt9.addword=true")) {
|
||||||
mAddingWord = true;
|
mAddingWord = true;
|
||||||
// mAddingSkipInput = true;
|
// mAddingSkipInput = true;
|
||||||
// Log.d("onStartInput", "ADDING WORD");
|
// Log.d("onStartInput", "ADDING WORD");
|
||||||
|
|
@ -328,14 +329,14 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
|
|
||||||
updateKeyMode();
|
updateKeyMode();
|
||||||
// show Window()?
|
// show Window()?
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is called when the user is done editing a field. We can use
|
* This is called when the user is done editing a field. We can use this to
|
||||||
* this to reset our state.
|
* reset our state.
|
||||||
*/
|
*/
|
||||||
@Override public void onFinishInput() {
|
@Override
|
||||||
|
public void onFinishInput() {
|
||||||
super.onFinishInput();
|
super.onFinishInput();
|
||||||
// Log.d("onFinishInput", "When is this called?");
|
// Log.d("onFinishInput", "When is this called?");
|
||||||
if (mEditing == EDITING) {
|
if (mEditing == EDITING) {
|
||||||
|
|
@ -368,29 +369,32 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
hideStatusIcon();
|
hideStatusIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onDestroy() {
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
db.close();
|
db.close();
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override public void onStartInputView(EditorInfo attribute, boolean restarting) {
|
// @Override public void onStartInputView(EditorInfo attribute, boolean
|
||||||
// Log.d("onStartInputView", "attribute.inputType: " + attribute.inputType + " restarting? " + restarting);
|
// restarting) {
|
||||||
|
// Log.d("onStartInputView", "attribute.inputType: " + attribute.inputType +
|
||||||
|
// " restarting? " + restarting);
|
||||||
// //super.onStartInputView(attribute, restarting);
|
// //super.onStartInputView(attribute, restarting);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deal with the editor reporting movement of its cursor.
|
* Deal with the editor reporting movement of its cursor.
|
||||||
*/
|
*/
|
||||||
@Override public void onUpdateSelection(int oldSelStart, int oldSelEnd,
|
@Override
|
||||||
int newSelStart, int newSelEnd,
|
public void onUpdateSelection(int oldSelStart, int oldSelEnd, int newSelStart, int newSelEnd,
|
||||||
int candidatesStart, int candidatesEnd) {
|
int candidatesStart, int candidatesEnd) {
|
||||||
super.onUpdateSelection(oldSelStart, oldSelEnd, newSelStart, newSelEnd,
|
super.onUpdateSelection(oldSelStart, oldSelEnd, newSelStart, newSelEnd, candidatesStart,
|
||||||
candidatesStart, candidatesEnd);
|
candidatesEnd);
|
||||||
|
|
||||||
// If the current selection in the text view changes, we should
|
// If the current selection in the text view changes, we should
|
||||||
// clear whatever candidate text we have.
|
// clear whatever candidate text we have.
|
||||||
if ((mComposing.length() > 0 || mComposingI.length() > 0) && (newSelStart != candidatesEnd
|
if ((mComposing.length() > 0 || mComposingI.length() > 0)
|
||||||
|| newSelEnd != candidatesEnd)) {
|
&& (newSelStart != candidatesEnd || newSelEnd != candidatesEnd)) {
|
||||||
mComposing.setLength(0);
|
mComposing.setLength(0);
|
||||||
mComposingI.setLength(0);
|
mComposingI.setLength(0);
|
||||||
updateCandidates();
|
updateCandidates();
|
||||||
|
|
@ -402,31 +406,27 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This tells us about completions that the editor has determined based
|
* This tells us about completions that the editor has determined based on
|
||||||
* on the current text in it. We want to use this in fullscreen mode
|
* the current text in it. We want to use this in fullscreen mode to show
|
||||||
* to show the completions ourself, since the editor can not be seen
|
* the completions ourself, since the editor can not be seen in that
|
||||||
* in that situation.
|
* situation.
|
||||||
*/
|
*/
|
||||||
@Override public void onDisplayCompletions(CompletionInfo[] completions) {
|
@Override
|
||||||
|
public void onDisplayCompletions(CompletionInfo[] completions) {
|
||||||
// ??????????????
|
// ??????????????
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use this to monitor key events being delivered to the application.
|
* Use this to monitor key events being delivered to the application. We get
|
||||||
* We get first crack at them, and can either resume them or let them
|
* first crack at them, and can either resume them or let them continue to
|
||||||
* continue to the app.
|
* the app.
|
||||||
*/
|
*/
|
||||||
@Override public boolean onKeyDown(int keyCode, KeyEvent event) {
|
@Override
|
||||||
//Log.d("onKeyDown", "Key: " + event + " repeat?: " + event.getRepeatCount() + " long-time: " + event.isLongPress());
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
//Log.d("onKeyDown", "Key: " + keyCode + " repeat?: " + event.getRepeatCount());
|
// Log.d("onKeyDown", "Key: " + event + " repeat?: " +
|
||||||
|
// event.getRepeatCount() + " long-time: " + event.isLongPress());
|
||||||
if (mEditing == NON_EDIT) {
|
if (mEditing == NON_EDIT) {
|
||||||
// // catch for UI weirdness on up event thing
|
// // catch for UI weirdness on up event thing
|
||||||
// if (mButtonClose && keyCode != KeyEvent.KEYCODE_DPAD_CENTER) {
|
|
||||||
// mButtonClose = false;
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//Log.d("onKeyDown", "returned false");
|
|
||||||
//return super.onKeyDown(keyCode, event);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mFirstPress = false;
|
mFirstPress = false;
|
||||||
|
|
@ -467,6 +467,7 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
if (!isInputViewShown()) {
|
if (!isInputViewShown()) {
|
||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case KeyEvent.KEYCODE_DEL:
|
case KeyEvent.KEYCODE_DEL:
|
||||||
// Special handling of the delete key: if we currently are
|
// Special handling of the delete key: if we currently are
|
||||||
|
|
@ -479,7 +480,6 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
// break;
|
// break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// only handle first press except for delete
|
// only handle first press except for delete
|
||||||
if (event.getRepeatCount() != 0) {
|
if (event.getRepeatCount() != 0) {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -491,8 +491,8 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
case KeyEvent.KEYCODE_BACK:
|
case KeyEvent.KEYCODE_BACK:
|
||||||
// The InputMethodService already takes care of the back
|
// The InputMethodService already takes care of the back
|
||||||
// key for us, to dismiss the input method if it is shown.
|
// key for us, to dismiss the input method if it is shown.
|
||||||
// but we will manage it ourselves because native Android handling of
|
// but we will manage it ourselves because native Android handling
|
||||||
// the input view is ... flakey at best.
|
// of the input view is ... flakey at best.
|
||||||
// Log.d("onKeyDown", "back pres");
|
// Log.d("onKeyDown", "back pres");
|
||||||
if (isInputViewShown()) {
|
if (isInputViewShown()) {
|
||||||
// Log.d("inKeyDown", "input shown");
|
// Log.d("inKeyDown", "input shown");
|
||||||
|
|
@ -527,7 +527,8 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
// KeyCharacterMap.load(KeyCharacterMap.BUILT_IN_KEYBOARD).getNumber(keyCode)
|
// KeyCharacterMap.load(KeyCharacterMap.BUILT_IN_KEYBOARD).getNumber(keyCode)
|
||||||
//Log.w("onKeyDown", "Unhandled Key: " + keyCode + "(" + event.toString() + ")");
|
// Log.w("onKeyDown", "Unhandled Key: " + keyCode + "(" +
|
||||||
|
// event.toString() + ")");
|
||||||
}
|
}
|
||||||
Log.w("onKeyDown", "Unhandled Key: " + keyCode + "(" + event.toString() + ")");
|
Log.w("onKeyDown", "Unhandled Key: " + keyCode + "(" + event.toString() + ")");
|
||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
|
|
@ -535,7 +536,8 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
|
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
|
||||||
//consume since we will assume we have already handled the long press if greater than 1
|
// consume since we will assume we have already handled the long press
|
||||||
|
// if greater than 1
|
||||||
if (event.getRepeatCount() != 1) {
|
if (event.getRepeatCount() != 1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -584,7 +586,8 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
if (interfacehandler != null) {
|
if (interfacehandler != null) {
|
||||||
interfacehandler.setPressed(keyCode, false);
|
interfacehandler.setPressed(keyCode, false);
|
||||||
}
|
}
|
||||||
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).showInputMethodPicker();
|
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))
|
||||||
|
.showInputMethodPicker();
|
||||||
// show IME
|
// show IME
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -600,12 +603,14 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use this to monitor key events being delivered to the application.
|
* Use this to monitor key events being delivered to the application. We get
|
||||||
* We get first crack at them, and can either resume them or let them
|
* first crack at them, and can either resume them or let them continue to
|
||||||
* continue to the app.
|
* the app.
|
||||||
*/
|
*/
|
||||||
@Override public boolean onKeyUp(int keyCode, KeyEvent event) {
|
@Override
|
||||||
//Log.d("onKeyUp", "Key: " + keyCode + " repeat?: " + event.getRepeatCount());
|
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||||
|
// Log.d("onKeyUp", "Key: " + keyCode + " repeat?: " +
|
||||||
|
// event.getRepeatCount());
|
||||||
if (mEditing == NON_EDIT) {
|
if (mEditing == NON_EDIT) {
|
||||||
// if (mButtonClose) {
|
// if (mButtonClose) {
|
||||||
// //handle UI weirdness on up event
|
// //handle UI weirdness on up event
|
||||||
|
|
@ -654,9 +659,11 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
if (!isInputViewShown()) {
|
if (!isInputViewShown()) {
|
||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
// Log.d("onKeyUp", "Key: " + keyCode);
|
// Log.d("onKeyUp", "Key: " + keyCode);
|
||||||
//Log.d("onKeyUp", "Key: " + event + " cancelled?: " + event.isCanceled());
|
// Log.d("onKeyUp", "Key: " + event + " cancelled?: " +
|
||||||
|
// event.isCanceled());
|
||||||
if (event.isCanceled()) {
|
if (event.isCanceled()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -679,7 +686,8 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
case KeyEvent.KEYCODE_SOFT_RIGHT:
|
case KeyEvent.KEYCODE_SOFT_RIGHT:
|
||||||
case KeyEvent.KEYCODE_SOFT_LEFT:
|
case KeyEvent.KEYCODE_SOFT_LEFT:
|
||||||
// if (mAddingWord){
|
// if (mAddingWord){
|
||||||
// Log.d("onKeyUp", "key: " + keyCode + " skip: " + mAddingSkipInput);
|
// Log.d("onKeyUp", "key: " + keyCode + " skip: " +
|
||||||
|
// mAddingSkipInput);
|
||||||
// if (mAddingSkipInput) {
|
// if (mAddingSkipInput) {
|
||||||
// //mAddingSkipInput = false;
|
// //mAddingSkipInput = false;
|
||||||
// return true;
|
// return true;
|
||||||
|
|
@ -720,6 +728,7 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
private void commitTyped() {
|
private void commitTyped() {
|
||||||
commitTyped(getCurrentInputConnection());
|
commitTyped(getCurrentInputConnection());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void commitTyped(InputConnection ic) {
|
private void commitTyped(InputConnection ic) {
|
||||||
if (interfacehandler != null) {
|
if (interfacehandler != null) {
|
||||||
interfacehandler.midButtonUpdate(false);
|
interfacehandler.midButtonUpdate(false);
|
||||||
|
|
@ -742,7 +751,7 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
// Log.d("updateShift", "CM start: " + mCapsMode);
|
// Log.d("updateShift", "CM start: " + mCapsMode);
|
||||||
if (attr != null && mCapsMode != CAPS_ALL) {
|
if (attr != null && mCapsMode != CAPS_ALL) {
|
||||||
int caps = 0;
|
int caps = 0;
|
||||||
if (attr != null && attr.inputType != EditorInfo.TYPE_NULL) {
|
if (attr != null && attr.inputType != InputType.TYPE_NULL) {
|
||||||
caps = getCurrentInputConnection().getCursorCapsMode(attr.inputType);
|
caps = getCurrentInputConnection().getCursorCapsMode(attr.inputType);
|
||||||
}
|
}
|
||||||
// mInputView.setShifted(mCapsLock || caps != 0);
|
// mInputView.setShifted(mCapsLock || caps != 0);
|
||||||
|
|
@ -762,39 +771,23 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper to send a key down / key up pair to the current editor.
|
* Helper to send a key down / key up pair to the current editor. NOTE: Not
|
||||||
* NOTE: Not supposed to use this apparently. Need to use it for DEL.
|
* supposed to use this apparently. Need to use it for DEL. For other things
|
||||||
* For other things I'll have to onText
|
* I'll have to onText
|
||||||
*/
|
*/
|
||||||
private void keyDownUp(int keyEventCode) {
|
private void keyDownUp(int keyEventCode) {
|
||||||
InputConnection ic = getCurrentInputConnection();
|
InputConnection ic = getCurrentInputConnection();
|
||||||
KeyEvent kv = KeyEvent.changeFlags(
|
KeyEvent kv = KeyEvent.changeFlags(new KeyEvent(KeyEvent.ACTION_DOWN, keyEventCode),
|
||||||
new KeyEvent(KeyEvent.ACTION_DOWN, keyEventCode), KeyEvent.FLAG_SOFT_KEYBOARD);
|
KeyEvent.FLAG_SOFT_KEYBOARD);
|
||||||
ic.sendKeyEvent(kv);
|
ic.sendKeyEvent(kv);
|
||||||
kv = KeyEvent.changeFlags(
|
kv = KeyEvent.changeFlags(new KeyEvent(KeyEvent.ACTION_UP, keyEventCode),
|
||||||
new KeyEvent(KeyEvent.ACTION_UP, keyEventCode), KeyEvent.FLAG_SOFT_KEYBOARD);
|
KeyEvent.FLAG_SOFT_KEYBOARD);
|
||||||
ic.sendKeyEvent(kv);
|
ic.sendKeyEvent(kv);
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Helper to send a character to the editor as raw key events.
|
|
||||||
// */
|
|
||||||
// private void sendKey(int keyCode) {
|
|
||||||
// switch (keyCode) {
|
|
||||||
// case '\n':
|
|
||||||
// keyDownUp(KeyEvent.KEYCODE_ENTER);
|
|
||||||
// break;
|
|
||||||
// default:
|
|
||||||
// if (keyCode >= '0' && keyCode <= '9') {
|
|
||||||
// keyDownUp(keyCode - '0' + KeyEvent.KEYCODE_0);
|
|
||||||
// } else {
|
|
||||||
// getCurrentInputConnection().commitText(String.valueOf((char) keyCode), 1);
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Implementation of KeyboardViewListener
|
// Implementation of KeyboardViewListener
|
||||||
|
@Override
|
||||||
public void onKey(int keyCode, int[] keyCodes) {
|
public void onKey(int keyCode, int[] keyCodes) {
|
||||||
// Log.d("OnKey", "pri: " + keyCode);
|
// Log.d("OnKey", "pri: " + keyCode);
|
||||||
// Log.d("onKey", "START Cm: " + mCapsMode);
|
// Log.d("onKey", "START Cm: " + mCapsMode);
|
||||||
|
|
@ -838,9 +831,11 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
// Log.d("onKey", "END Cm: " + mCapsMode);
|
// Log.d("onKey", "END Cm: " + mCapsMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onText(CharSequence text) {
|
public void onText(CharSequence text) {
|
||||||
InputConnection ic = getCurrentInputConnection();
|
InputConnection ic = getCurrentInputConnection();
|
||||||
if (ic == null) return;
|
if (ic == null)
|
||||||
|
return;
|
||||||
ic.beginBatchEdit();
|
ic.beginBatchEdit();
|
||||||
if (mComposing.length() > 0 || mComposingI.length() > 0) {
|
if (mComposing.length() > 0 || mComposingI.length() > 0) {
|
||||||
commitTyped(ic);
|
commitTyped(ic);
|
||||||
|
|
@ -851,7 +846,8 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used from interface to either close the input UI if not composing text or to accept the composing text
|
* Used from interface to either close the input UI if not composing text or
|
||||||
|
* to accept the composing text
|
||||||
*/
|
*/
|
||||||
protected void handleMidButton() {
|
protected void handleMidButton() {
|
||||||
if (!isInputViewShown()) {
|
if (!isInputViewShown()) {
|
||||||
|
|
@ -877,9 +873,8 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the list of available candidates from the current composing
|
* Update the list of available candidates from the current composing text.
|
||||||
* text. This will need to be filled in by however you are determining
|
* This will need to be filled in by however you are determining candidates.
|
||||||
* candidates.
|
|
||||||
*/
|
*/
|
||||||
private void updateCandidates() {
|
private void updateCandidates() {
|
||||||
if (mKeyMode == MODE_EN) {
|
if (mKeyMode == MODE_EN) {
|
||||||
|
|
@ -890,25 +885,30 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
String prefix = "";
|
String prefix = "";
|
||||||
if (!nosuggestion) {
|
if (!nosuggestion) {
|
||||||
prefix = mSuggestionStrings.get(mCandidateView.mSelectedIndex);
|
prefix = mSuggestionStrings.get(mCandidateView.mSelectedIndex);
|
||||||
|
} else if (len > 1) {
|
||||||
|
prefix = db.getWord(mComposingI.substring(0, len - 1));
|
||||||
}
|
}
|
||||||
mSuggestionInts.clear();
|
mSuggestionInts.clear();
|
||||||
mSuggestionStrings.clear();
|
mSuggestionStrings.clear();
|
||||||
mSuggestionSym.clear();
|
mSuggestionSym.clear();
|
||||||
db.updateWords("1", mSuggestionSym, mSuggestionInts, mCapsMode);
|
db.updateWords("1", mSuggestionSym, mSuggestionInts, mCapsMode);
|
||||||
for (String a : mSuggestionSym) {
|
for (String a : mSuggestionSym) {
|
||||||
if (!nosuggestion) {
|
if (prefix != "") {
|
||||||
mSuggestionStrings.add(prefix + a);
|
mSuggestionStrings.add(prefix + a);
|
||||||
} else {
|
} else {
|
||||||
mSuggestionStrings.add(String.valueOf(a));
|
mSuggestionStrings.add(String.valueOf(a));
|
||||||
|
mComposingI.setLength(0);
|
||||||
|
mComposingI.append("1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
db.updateWords(mComposingI.toString(), mSuggestionStrings, mSuggestionInts, mCapsMode);
|
db.updateWords(mComposingI.toString(), mSuggestionStrings, mSuggestionInts,
|
||||||
|
mCapsMode);
|
||||||
}
|
}
|
||||||
if (!mSuggestionStrings.isEmpty()) {
|
if (!mSuggestionStrings.isEmpty()) {
|
||||||
mWordFound = true;
|
mWordFound = true;
|
||||||
mComposing.setLength(0);
|
mComposing.setLength(0);
|
||||||
mComposing.append(mSuggestionStrings.get(0).substring(0, len));
|
mComposing.append(mSuggestionStrings.get(0));
|
||||||
if (interfacehandler != null) {
|
if (interfacehandler != null) {
|
||||||
interfacehandler.showNotFound(false);
|
interfacehandler.showNotFound(false);
|
||||||
}
|
}
|
||||||
|
|
@ -928,8 +928,7 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
interfacehandler.showNotFound(false);
|
interfacehandler.showNotFound(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (mKeyMode == MODE_TEXT) {
|
||||||
else if (mKeyMode == MODE_TEXT) {
|
|
||||||
if (mComposing.length() > 0) {
|
if (mComposing.length() > 0) {
|
||||||
mSuggestionStrings.clear();
|
mSuggestionStrings.clear();
|
||||||
char[] ca = CharMap.T9TABLE[mPrevious];
|
char[] ca = CharMap.T9TABLE[mPrevious];
|
||||||
|
|
@ -967,6 +966,7 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
// Log.d("BS", "comp: " + length + " compI: " + length2);
|
// Log.d("BS", "comp: " + length + " compI: " + length2);
|
||||||
mComposing.delete(length - 1, length);
|
mComposing.delete(length - 1, length);
|
||||||
mComposingI.delete(length2 - 1, length2);
|
mComposingI.delete(length2 - 1, length2);
|
||||||
|
mSuggestionStrings.clear();
|
||||||
updateCandidates();
|
updateCandidates();
|
||||||
getCurrentInputConnection().setComposingText(mComposing, 1);
|
getCurrentInputConnection().setComposingText(mComposing, 1);
|
||||||
} else if (length > 0 || length2 > 0) {
|
} else if (length > 0 || length2 > 0) {
|
||||||
|
|
@ -974,6 +974,7 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
mComposingI.setLength(0);
|
mComposingI.setLength(0);
|
||||||
interfacehandler.midButtonUpdate(false);
|
interfacehandler.midButtonUpdate(false);
|
||||||
interfacehandler.showNotFound(false);
|
interfacehandler.showNotFound(false);
|
||||||
|
mSuggestionStrings.clear();
|
||||||
getCurrentInputConnection().commitText("", 0);
|
getCurrentInputConnection().commitText("", 0);
|
||||||
updateCandidates();
|
updateCandidates();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -989,8 +990,7 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
// do my own thing here
|
// do my own thing here
|
||||||
if (mCapsMode == CAPS_CYCLE.length - 1) {
|
if (mCapsMode == CAPS_CYCLE.length - 1) {
|
||||||
mCapsMode = 0;
|
mCapsMode = 0;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
mCapsMode++;
|
mCapsMode++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1002,8 +1002,8 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* handle input of a character.
|
* handle input of a character. Precondition: ONLY 0-9 AND *# ARE ALLOWED
|
||||||
* Precondition: ONLY 0-9 AND *# ARE ALLOWED
|
*
|
||||||
* @param keyCode
|
* @param keyCode
|
||||||
*/
|
*/
|
||||||
private void handleCharacter(int keyCode) {
|
private void handleCharacter(int keyCode) {
|
||||||
|
|
@ -1107,9 +1107,11 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
// the underlying edit box in a somewhat reliable manner.
|
// the underlying edit box in a somewhat reliable manner.
|
||||||
// (somewhat because there are a few cases where this doesn't work properly or acts strangely.)
|
// (somewhat because there are a few cases where this doesn't work properly or acts strangely.)
|
||||||
private boolean handleDPAD(int keyCode, KeyEvent event, boolean keyDown) {
|
private boolean handleDPAD(int keyCode, KeyEvent event, boolean keyDown) {
|
||||||
//Log.d("handleConsumeDPAD", "keyCode: " + keyCode + " isKeyDown: " + isKeyDown);
|
// Log.d("handleConsumeDPAD", "keyCode: " + keyCode + " isKeyDown: " +
|
||||||
|
// isKeyDown);
|
||||||
if (keyDown) {
|
if (keyDown) {
|
||||||
//track key, if seeing repeat count < 0, start sending this event and previous to super
|
// track key, if seeing repeat count < 0, start sending this event
|
||||||
|
// and previous to super
|
||||||
if (event.getRepeatCount() == 0) {
|
if (event.getRepeatCount() == 0) {
|
||||||
// store event
|
// store event
|
||||||
mDPADkeyEvent = event;
|
mDPADkeyEvent = event;
|
||||||
|
|
@ -1126,7 +1128,8 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// if we have been sending previous down events to super, do the same for up, else process the event
|
// if we have been sending previous down events to super, do the
|
||||||
|
// same for up, else process the event
|
||||||
if (mIgnoreDPADKeyUp) {
|
if (mIgnoreDPADKeyUp) {
|
||||||
mIgnoreDPADKeyUp = false;
|
mIgnoreDPADKeyUp = false;
|
||||||
return super.onKeyUp(keyCode, event);
|
return super.onKeyUp(keyCode, event);
|
||||||
|
|
@ -1152,13 +1155,15 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
handleMidButton();
|
handleMidButton();
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
//Send stored event to input connection then pass current event onto super
|
// Send stored event to input connection then pass current
|
||||||
|
// event onto super
|
||||||
getCurrentInputConnection().sendKeyEvent(mDPADkeyEvent);
|
getCurrentInputConnection().sendKeyEvent(mDPADkeyEvent);
|
||||||
return super.onKeyUp(keyCode, event);
|
return super.onKeyUp(keyCode, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void commitReset() {
|
private void commitReset() {
|
||||||
commitTyped(getCurrentInputConnection());
|
commitTyped(getCurrentInputConnection());
|
||||||
charReset();
|
charReset();
|
||||||
|
|
@ -1169,11 +1174,13 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
updateShiftKeyState(getCurrentInputEditorInfo());
|
updateShiftKeyState(getCurrentInputEditorInfo());
|
||||||
// Log.d("commitReset", "CM post: " + mCapsMode);
|
// Log.d("commitReset", "CM post: " + mCapsMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void charReset() {
|
private void charReset() {
|
||||||
t9releasehandler.removeCallbacks(mt9release);
|
t9releasehandler.removeCallbacks(mt9release);
|
||||||
mPrevious = -1;
|
mPrevious = -1;
|
||||||
mCharIndex = 0;
|
mCharIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleClose() {
|
private void handleClose() {
|
||||||
commitTyped(getCurrentInputConnection());
|
commitTyped(getCurrentInputConnection());
|
||||||
requestHideSelf(0);
|
requestHideSelf(0);
|
||||||
|
|
@ -1197,9 +1204,10 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
mComposingI.setLength(0);
|
mComposingI.setLength(0);
|
||||||
getCurrentInputConnection().finishComposingText();
|
getCurrentInputConnection().finishComposingText();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the status icon that is appropriate in current mode
|
* Set the status icon that is appropriate in current mode (based on
|
||||||
* (based on openwmm-legacy)
|
* openwmm-legacy)
|
||||||
*/
|
*/
|
||||||
private void updateKeyMode() {
|
private void updateKeyMode() {
|
||||||
int icon = 0;
|
int icon = 0;
|
||||||
|
|
@ -1248,7 +1256,6 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
showStatusIcon(icon);
|
showStatusIcon(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void pickSelectedCandidate(InputConnection ic) {
|
private void pickSelectedCandidate(InputConnection ic) {
|
||||||
pickSuggestionManually(-1, ic);
|
pickSuggestionManually(-1, ic);
|
||||||
}
|
}
|
||||||
|
|
@ -1261,7 +1268,8 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
// we will just commit the current text.
|
// we will just commit the current text.
|
||||||
if (!mSuggestionStrings.isEmpty()) {
|
if (!mSuggestionStrings.isEmpty()) {
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
//Log.d("pickSuggestMan", "picking SELECTED: " + mSuggestionStrings.get(mCandidateView.mSelectedIndex));
|
// Log.d("pickSuggestMan", "picking SELECTED: " +
|
||||||
|
// mSuggestionStrings.get(mCandidateView.mSelectedIndex));
|
||||||
// get and commit selected suggestion
|
// get and commit selected suggestion
|
||||||
ic.commitText(mSuggestionStrings.get(mCandidateView.mSelectedIndex), 1);
|
ic.commitText(mSuggestionStrings.get(mCandidateView.mSelectedIndex), 1);
|
||||||
if (mKeyMode == MODE_EN) {
|
if (mKeyMode == MODE_EN) {
|
||||||
|
|
@ -1282,28 +1290,33 @@ implements KeyboardView.OnKeyboardActionListener {
|
||||||
/**
|
/**
|
||||||
* Ignore this for now.
|
* Ignore this for now.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void swipeRight() {
|
public void swipeRight() {
|
||||||
// if (mPredictionOn) {
|
// if (mPredictionOn) {
|
||||||
// pickDefaultCandidate();
|
// pickDefaultCandidate();
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void swipeLeft() {
|
public void swipeLeft() {
|
||||||
handleBackspace();
|
handleBackspace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void swipeDown() {
|
public void swipeDown() {
|
||||||
handleClose();
|
handleClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void swipeUp() {
|
public void swipeUp() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onPress(int primaryCode) {
|
public void onPress(int primaryCode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onRelease(int primaryCode) {
|
public void onRelease(int primaryCode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,11 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private class LoadDictTask extends AsyncTask<String, Integer, Reply> {
|
private class LoadDictTask extends AsyncTask<String, Integer, Reply> {
|
||||||
/** The system calls this to perform work in a worker thread and
|
/**
|
||||||
* delivers it the parameters given to AsyncTask.execute() */
|
* The system calls this to perform work in a worker thread and delivers
|
||||||
|
* it the parameters given to AsyncTask.execute()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
protected Reply doInBackground(String... mode) {
|
protected Reply doInBackground(String... mode) {
|
||||||
Reply reply = new Reply();
|
Reply reply = new Reply();
|
||||||
SQLiteDatabase db;
|
SQLiteDatabase db;
|
||||||
|
|
@ -103,7 +106,6 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
db.setLockingEnabled(false);
|
db.setLockingEnabled(false);
|
||||||
|
|
||||||
InsertHelper wordhelp = new InsertHelper(db, T9DB.WORD_TABLE_NAME);
|
InsertHelper wordhelp = new InsertHelper(db, T9DB.WORD_TABLE_NAME);
|
||||||
|
|
@ -133,11 +135,11 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
reply.status = false;
|
reply.status = false;
|
||||||
reply.message = "Backup file not found: " + e.getMessage();
|
reply.message = "Backup file not found: " + e.getMessage();
|
||||||
db.close();
|
db.close();
|
||||||
closeStream(dictstream, reply); // this is silly but it stops IDE nagging at me.
|
closeStream(dictstream, reply); // this is silly but it
|
||||||
|
// stops IDE nagging at me.
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
try {
|
try {
|
||||||
dictstream = getAssets().open(dictname);
|
dictstream = getAssets().open(dictname);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
@ -183,8 +185,8 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
try {
|
try {
|
||||||
while (word != null) {
|
while (word != null) {
|
||||||
if (isCancelled()) {
|
if (isCancelled()) {
|
||||||
// this is useless because of dumb android bug that doesn't
|
// this is useless because of dumb android bug that
|
||||||
// call onCancelled after this method finishes.
|
// doesn't call onCancelled after this method finishes.
|
||||||
reply.status = false;
|
reply.status = false;
|
||||||
reply.message = "User cancelled.";
|
reply.message = "User cancelled.";
|
||||||
break;
|
break;
|
||||||
|
|
@ -231,7 +233,8 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
wordhelp.bind(freqColumn, freq);
|
wordhelp.bind(freqColumn, freq);
|
||||||
wordhelp.execute();
|
wordhelp.execute();
|
||||||
|
|
||||||
//System.out.println("Progress: " + pos + " Last: " + last + " fsize: " + fsize);
|
// System.out.println("Progress: " + pos + " Last: " + last
|
||||||
|
// + " fsize: " + fsize);
|
||||||
if ((pos - last) > 4096) {
|
if ((pos - last) > 4096) {
|
||||||
// Log.d("doInBackground", "line: " + linecount);
|
// Log.d("doInBackground", "line: " + linecount);
|
||||||
// Log.d("doInBackground", "word: " + word);
|
// Log.d("doInBackground", "word: " + word);
|
||||||
|
|
@ -264,40 +267,51 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void onProgressUpdate(Integer... progress) {
|
protected void onProgressUpdate(Integer... progress) {
|
||||||
if (pd.isShowing()) {
|
if (pd.isShowing()) {
|
||||||
pd.setProgress(progress[0]);
|
pd.setProgress(progress[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void onCancelled() {
|
protected void onCancelled() {
|
||||||
// Pointless callback. Thanks android.
|
// Pointless callback. Thanks android.
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The system calls this to perform work in the UI thread and delivers
|
/**
|
||||||
* the result from doInBackground() */
|
* The system calls this to perform work in the UI thread and delivers
|
||||||
|
* the result from doInBackground()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
protected void onPostExecute(Reply result) {
|
protected void onPostExecute(Reply result) {
|
||||||
if (pd == null) {
|
if (pd == null) {
|
||||||
// Log.d("onPostExecute", "pd");
|
// Log.d("onPostExecute", "pd");
|
||||||
} else {
|
} else {
|
||||||
// Log.d("onPostExecute", "pd");
|
// Log.d("onPostExecute", "pd");
|
||||||
|
if (pd.isShowing()) {
|
||||||
pd.dismiss();
|
pd.dismiss();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
// bad thing happened
|
// bad thing happened
|
||||||
Log.e("onPostExecute", "Bad things happen?");
|
Log.e("onPostExecute", "Bad things happen?");
|
||||||
} else {
|
} else {
|
||||||
Log.d("onPostExecute", "Result: " + result.status + " " + result.message);
|
Log.d("onPostExecute", "Result: " + result.status + " " + result.message);
|
||||||
if (!result.status) {
|
if (!result.status) {
|
||||||
showErrorDialog(caller.getResources().getString(R.string.pref_restore_title), result.message);
|
showErrorDialog(caller.getResources().getString(R.string.pref_restore_title),
|
||||||
|
result.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DumpDictTask extends AsyncTask<String, Integer, Reply> {
|
private class DumpDictTask extends AsyncTask<String, Integer, Reply> {
|
||||||
/** The system calls this to perform work in a worker thread and
|
/**
|
||||||
* delivers it the parameters given to AsyncTask.execute() */
|
* The system calls this to perform work in a worker thread and delivers
|
||||||
|
* it the parameters given to AsyncTask.execute()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
protected Reply doInBackground(String... ignore) {
|
protected Reply doInBackground(String... ignore) {
|
||||||
Reply reply = new Reply();
|
Reply reply = new Reply();
|
||||||
SQLiteDatabase db;
|
SQLiteDatabase db;
|
||||||
|
|
@ -306,7 +320,8 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
int current = 0;
|
int current = 0;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
int last = 0;
|
int last = 0;
|
||||||
File backupfile = new File(new File(Environment.getExternalStorageDirectory(), backupdir), backupname);
|
File backupfile = new File(new File(Environment.getExternalStorageDirectory(),
|
||||||
|
backupdir), backupname);
|
||||||
|
|
||||||
db.setLockingEnabled(false);
|
db.setLockingEnabled(false);
|
||||||
|
|
||||||
|
|
@ -320,7 +335,8 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
reply.status = false;
|
reply.status = false;
|
||||||
reply.message = "Backup file error: " + e.getMessage();
|
reply.message = "Backup file error: " + e.getMessage();
|
||||||
db.close();
|
db.close();
|
||||||
closeStream(dictstream, reply); // this is silly but it stops IDE nagging at me.
|
closeStream(dictstream, reply); // this is silly but it stops
|
||||||
|
// IDE nagging at me.
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -345,15 +361,15 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
cur.close();
|
cur.close();
|
||||||
|
|
||||||
while (current < entries) {
|
while (current < entries) {
|
||||||
q = "SELECT " + T9DB.COLUMN_ID + ", " + T9DB.COLUMN_WORD + ", " + T9DB.COLUMN_FREQUENCY +
|
q = "SELECT " + T9DB.COLUMN_ID + ", " + T9DB.COLUMN_WORD + ", "
|
||||||
" FROM " + T9DB.WORD_TABLE_NAME +
|
+ T9DB.COLUMN_FREQUENCY + " FROM " + T9DB.WORD_TABLE_NAME + " WHERE "
|
||||||
" WHERE " + T9DB.COLUMN_ID + ">" + current +
|
+ T9DB.COLUMN_ID + ">" + current + " ORDER BY " + T9DB.COLUMN_ID + " LIMIT "
|
||||||
" ORDER BY " + T9DB.COLUMN_ID +
|
+ BACKUP_Q_LIMIT;
|
||||||
" LIMIT " + BACKUP_Q_LIMIT;
|
|
||||||
cur = db.rawQuery(q, null);
|
cur = db.rawQuery(q, null);
|
||||||
for (cur.moveToFirst(); !cur.isAfterLast(); cur.moveToNext()) {
|
for (cur.moveToFirst(); !cur.isAfterLast(); cur.moveToNext()) {
|
||||||
if (isCancelled()) {
|
if (isCancelled()) {
|
||||||
// this is useless because of dumb android bug that doesn't
|
// this is useless because of dumb android bug that
|
||||||
|
// doesn't
|
||||||
// call onCancelled after this method finishes.
|
// call onCancelled after this method finishes.
|
||||||
reply.status = false;
|
reply.status = false;
|
||||||
reply.message = "User cancelled.";
|
reply.message = "User cancelled.";
|
||||||
|
|
@ -396,18 +412,23 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void onProgressUpdate(Integer... progress) {
|
protected void onProgressUpdate(Integer... progress) {
|
||||||
if (pd.isShowing()) {
|
if (pd.isShowing()) {
|
||||||
pd.setProgress(progress[0]);
|
pd.setProgress(progress[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void onCancelled() {
|
protected void onCancelled() {
|
||||||
// Pointless callback. Thanks android.
|
// Pointless callback. Thanks android.
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The system calls this to perform work in the UI thread and delivers
|
/**
|
||||||
* the result from doInBackground() */
|
* The system calls this to perform work in the UI thread and delivers
|
||||||
|
* the result from doInBackground()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
protected void onPostExecute(Reply result) {
|
protected void onPostExecute(Reply result) {
|
||||||
if (pd == null) {
|
if (pd == null) {
|
||||||
// Log.d("onPostExecute", "pd");
|
// Log.d("onPostExecute", "pd");
|
||||||
|
|
@ -421,15 +442,19 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
} else {
|
} else {
|
||||||
Log.d("onPostExecute", "Result: " + result.status + " " + result.message);
|
Log.d("onPostExecute", "Result: " + result.status + " " + result.message);
|
||||||
if (!result.status) {
|
if (!result.status) {
|
||||||
showErrorDialog(caller.getResources().getString(R.string.pref_backup_title), result.message);
|
showErrorDialog(caller.getResources().getString(R.string.pref_backup_title),
|
||||||
|
result.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NukeDictTask extends AsyncTask<String, Integer, Reply> {
|
private class NukeDictTask extends AsyncTask<String, Integer, Reply> {
|
||||||
/** The system calls this to perform work in a worker thread and
|
/**
|
||||||
* delivers it the parameters given to AsyncTask.execute() */
|
* The system calls this to perform work in a worker thread and delivers
|
||||||
|
* it the parameters given to AsyncTask.execute()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
protected Reply doInBackground(String... ignore) {
|
protected Reply doInBackground(String... ignore) {
|
||||||
Reply reply = new Reply();
|
Reply reply = new Reply();
|
||||||
Log.d("doInBakground", "Nuking dict...");
|
Log.d("doInBakground", "Nuking dict...");
|
||||||
|
|
@ -443,12 +468,16 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void onCancelled() {
|
protected void onCancelled() {
|
||||||
// Pointless callback. Thanks android.
|
// Pointless callback. Thanks android.
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The system calls this to perform work in the UI thread and delivers
|
/**
|
||||||
* the result from doInBackground() */
|
* The system calls this to perform work in the UI thread and delivers
|
||||||
|
* the result from doInBackground()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
protected void onPostExecute(Reply result) {
|
protected void onPostExecute(Reply result) {
|
||||||
if (pd == null) {
|
if (pd == null) {
|
||||||
// Log.d("onPostExecute", "pd");
|
// Log.d("onPostExecute", "pd");
|
||||||
|
|
@ -462,7 +491,8 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
} else {
|
} else {
|
||||||
Log.d("onPostExecute", "Result: " + result.status + " " + result.message);
|
Log.d("onPostExecute", "Result: " + result.status + " " + result.message);
|
||||||
if (!result.status) {
|
if (!result.status) {
|
||||||
showErrorDialog(caller.getResources().getString(R.string.pref_nuke_title), result.message);
|
showErrorDialog(caller.getResources().getString(R.string.pref_nuke_title),
|
||||||
|
result.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -472,7 +502,7 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
addPreferencesFromResource(R.xml.prefs);
|
addPreferencesFromResource(R.xml.prefs);
|
||||||
Preference button = (Preference)getPreferenceManager().findPreference("loaddict");
|
Preference button = getPreferenceManager().findPreference("loaddict");
|
||||||
if (button != null) {
|
if (button != null) {
|
||||||
button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -482,7 +512,7 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
button = (Preference)getPreferenceManager().findPreference("nukedict");
|
button = getPreferenceManager().findPreference("nukedict");
|
||||||
if (button != null) {
|
if (button != null) {
|
||||||
button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -493,7 +523,7 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
button = (Preference)getPreferenceManager().findPreference("backupdict");
|
button = getPreferenceManager().findPreference("backupdict");
|
||||||
if (button != null) {
|
if (button != null) {
|
||||||
button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -504,7 +534,7 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
button = (Preference)getPreferenceManager().findPreference("restoredict");
|
button = getPreferenceManager().findPreference("restoredict");
|
||||||
if (button != null) {
|
if (button != null) {
|
||||||
button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -515,7 +545,7 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
button = (Preference)getPreferenceManager().findPreference("querytest");
|
button = getPreferenceManager().findPreference("querytest");
|
||||||
if (button != null) {
|
if (button != null) {
|
||||||
button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -568,14 +598,14 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
|
|
||||||
private void nukeDict() {
|
private void nukeDict() {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setMessage(R.string.pref_nuke_warn)
|
builder.setMessage(R.string.pref_nuke_warn).setTitle(R.string.pref_nuke_title)
|
||||||
.setTitle(R.string.pref_nuke_title)
|
|
||||||
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
prenuke(R.string.pref_nukingdict);
|
prenuke(R.string.pref_nukingdict);
|
||||||
}
|
}
|
||||||
})
|
}).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||||
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
|
|
@ -598,14 +628,14 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
|
|
||||||
saveloc = new File(saveloc, backupname);
|
saveloc = new File(saveloc, backupname);
|
||||||
if (saveloc.exists()) {
|
if (saveloc.exists()) {
|
||||||
builder.setMessage(R.string.pref_backup_warn)
|
builder.setMessage(R.string.pref_backup_warn).setTitle(R.string.pref_backup_title)
|
||||||
.setTitle(R.string.pref_backup_title)
|
|
||||||
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
predumper(R.string.pref_savingbackup);
|
predumper(R.string.pref_savingbackup);
|
||||||
}
|
}
|
||||||
})
|
}).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||||
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
|
|
@ -625,9 +655,9 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showErrorDialog(AlertDialog.Builder builder, String title, String msg) {
|
private void showErrorDialog(AlertDialog.Builder builder, String title, String msg) {
|
||||||
builder.setMessage(msg)
|
builder.setMessage(msg).setTitle(title)
|
||||||
.setTitle(title)
|
|
||||||
.setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() {
|
.setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
|
|
@ -635,10 +665,11 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
AlertDialog dialog = builder.create();
|
AlertDialog dialog = builder.create();
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showErrorDialogID(AlertDialog.Builder builder, int titleid, int msgid) {
|
private void showErrorDialogID(AlertDialog.Builder builder, int titleid, int msgid) {
|
||||||
builder.setMessage(msgid)
|
builder.setMessage(msgid).setTitle(titleid)
|
||||||
.setTitle(titleid)
|
|
||||||
.setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() {
|
.setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
|
|
@ -651,18 +682,23 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
// Environment.MEDIA_MOUNTED_READ_ONLY;
|
// Environment.MEDIA_MOUNTED_READ_ONLY;
|
||||||
// Environment.MEDIA_MOUNTED;
|
// Environment.MEDIA_MOUNTED;
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(Environment.getExternalStorageState()) ||
|
if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(Environment.getExternalStorageState())
|
||||||
Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
|
|| Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
|
||||||
if ((new File(new File(Environment.getExternalStorageDirectory(), backupdir), backupname)).exists()) {
|
if ((new File(new File(Environment.getExternalStorageDirectory(), backupdir),
|
||||||
|
backupname)).exists()) {
|
||||||
Resources res = getResources();
|
Resources res = getResources();
|
||||||
builder.setMessage(res.getString(R.string.pref_restore_warn, res.getString(R.string.pref_nukedict)))
|
builder
|
||||||
|
.setMessage(
|
||||||
|
res.getString(R.string.pref_restore_warn,
|
||||||
|
res.getString(R.string.pref_nukedict)))
|
||||||
.setTitle(R.string.pref_restore_title)
|
.setTitle(R.string.pref_restore_title)
|
||||||
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
preloader(R.string.pref_loadingbackup, "backup");
|
preloader(R.string.pref_loadingbackup, "backup");
|
||||||
}
|
}
|
||||||
})
|
}).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||||
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
|
|
@ -670,7 +706,8 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
AlertDialog dialog = builder.create();
|
AlertDialog dialog = builder.create();
|
||||||
dialog.show();
|
dialog.show();
|
||||||
} else {
|
} else {
|
||||||
showErrorDialogID(builder, R.string.pref_restore_title, R.string.pref_restore_nofile);
|
showErrorDialogID(builder, R.string.pref_restore_title,
|
||||||
|
R.string.pref_restore_nofile);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showErrorDialogID(builder, R.string.pref_restore_title, R.string.pref_restore_noext);
|
showErrorDialogID(builder, R.string.pref_restore_title, R.string.pref_restore_noext);
|
||||||
|
|
@ -759,13 +796,13 @@ public class TraditionalT9Settings extends PreferenceActivity implements
|
||||||
Log.d("VALUES", "...");
|
Log.d("VALUES", "...");
|
||||||
size = freqs.size();
|
size = freqs.size();
|
||||||
for (int x = 0; x < size; x++) {
|
for (int x = 0; x < size; x++) {
|
||||||
Log.d("VALUES", "Word: " + words.get(x) + " id: " + ids.get(x) + " freq: " + freqs.get(x));
|
Log.d("VALUES",
|
||||||
|
"Word: " + words.get(x) + " id: " + ids.get(x) + " freq: " + freqs.get(x));
|
||||||
}
|
}
|
||||||
Log.d("queryTestSingle", "done.");
|
Log.d("queryTestSingle", "done.");
|
||||||
tdb.close();
|
tdb.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCancel(DialogInterface dint) {
|
public void onCancel(DialogInterface dint) {
|
||||||
task.cancel(false);
|
task.cancel(false);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue