Fixed some bugs, and added some things:
* Updated gradle * Composed text now changes on selection change * Added content description for smileys and trimmed smiley list * Added localization for symbol/smiley dialog
This commit is contained in:
parent
2ba6003ea9
commit
9150bf62d7
13 changed files with 226 additions and 97 deletions
|
|
@ -15,13 +15,12 @@ import java.util.Arrays;
|
|||
public abstract class AbsSymDialog extends Dialog implements
|
||||
View.OnClickListener {
|
||||
|
||||
private KeyboardView.OnKeyboardActionListener parent;
|
||||
protected Context context;
|
||||
private View mainview;
|
||||
private int pagenum = 1;
|
||||
private int pageoffset = (pagenum - 1) * 10;
|
||||
|
||||
private int MAX_PAGE;
|
||||
private String title;
|
||||
private boolean started;
|
||||
|
||||
private static final int[] buttons = {
|
||||
|
|
@ -37,7 +36,7 @@ public abstract class AbsSymDialog extends Dialog implements
|
|||
|
||||
public AbsSymDialog(Context c, View mv) {
|
||||
super(c);
|
||||
parent = (KeyboardView.OnKeyboardActionListener) c;
|
||||
context = c;
|
||||
mainview = mv;
|
||||
started = true;
|
||||
setContentView(mv);
|
||||
|
|
@ -52,9 +51,11 @@ public abstract class AbsSymDialog extends Dialog implements
|
|||
button.setOnClickListener(this);
|
||||
}
|
||||
MAX_PAGE = getMaxPage();
|
||||
title = getTitleText();
|
||||
}
|
||||
|
||||
// must return a string array the same size as the length of the button string array.
|
||||
abstract String[] getContentDescription();
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// Log.d("SymbolPopup - onClick", "click happen: " + v);
|
||||
|
|
@ -108,7 +109,7 @@ public abstract class AbsSymDialog extends Dialog implements
|
|||
// Log.d("SymbolDialog - sendChar", "Sending index: " + index);
|
||||
|
||||
if (index < getSymbolSize()) {
|
||||
parent.onText(getSymbol(index));
|
||||
((KeyboardView.OnKeyboardActionListener) context).onText(getSymbol(index));
|
||||
// then close
|
||||
pagenum = 1;
|
||||
pageoffset = (pagenum - 1) * 10;
|
||||
|
|
@ -129,7 +130,8 @@ public abstract class AbsSymDialog extends Dialog implements
|
|||
|
||||
private void updateButtons() {
|
||||
// set page number text
|
||||
setTitle("Insert " + title + "\t\tPage " + pagenum + "/" + MAX_PAGE);
|
||||
setTitle(String.format("%s\t\t%s", getTitleText(),
|
||||
context.getResources().getString(R.string.symbol_page, pagenum, MAX_PAGE)));
|
||||
// update button labels
|
||||
int symbx = pageoffset;
|
||||
int stop = symbx + 9;
|
||||
|
|
@ -138,14 +140,20 @@ public abstract class AbsSymDialog extends Dialog implements
|
|||
if (nomore >= symsize - 1) {
|
||||
nomore = symsize - 1;
|
||||
}
|
||||
TextView tv;
|
||||
String[] cd = getContentDescription();
|
||||
|
||||
for (int buttx = 0; symbx <= stop; symbx++) {
|
||||
// Log.d("SymbolDialog - updateButtons", "buttx: " + buttx +
|
||||
// " symbx: " + symbx);
|
||||
if (symbx > nomore) {
|
||||
((TextView) mainview.findViewById(buttons[buttx])).setText("");
|
||||
} else {
|
||||
((TextView) mainview.findViewById(buttons[buttx]))
|
||||
.setText(String.valueOf(getSymbol(symbx)));
|
||||
tv = (TextView) mainview.findViewById(buttons[buttx]);
|
||||
tv.setText(String.valueOf(getSymbol(symbx)));
|
||||
if (cd != null) {
|
||||
tv.setContentDescription(cd[symbx]);
|
||||
}
|
||||
}
|
||||
buttx++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,14 @@ public class LangHelper {
|
|||
iansize++;
|
||||
}
|
||||
}
|
||||
return ian;
|
||||
return ian;
|
||||
}
|
||||
|
||||
protected static int findIndex(int[] ia, int target) {
|
||||
for (int x=0; x<ia.length; x++) {
|
||||
if (ia[x] == target)
|
||||
return x;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,19 +7,23 @@ public class SmileyDialog extends AbsSymDialog {
|
|||
|
||||
private static final String[] symbols = {
|
||||
// lol wiki http://en.wikipedia.org/wiki/List_of_emoticons
|
||||
":-)", ":)", ":o)", ":]", ":3", ":c)", ":>", "=]", "=)", ":}", ":-D", ":D", "8-D",
|
||||
"8D", "X-D", "XD", "=-D", "=D", "B^D", ">:[", ":-(", ":(", ":c", ":-<", ":<", ":-[",
|
||||
":[", ":{", ":'-(", ":'(", ":'-)", ":')", ":@", "D:<", "D:", "D8", "D;", "D=", "DX",
|
||||
"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",
|
||||
">:\\", ">:/", ":-/", ":-.", ":/", ":\\", "=/", "=\\", ":L", "=L", ":S", ">.<", ":|",
|
||||
":-|", ":$", ":-X", ":X", ":-#", ":#", "O:-)", "0:-3", "0:3", "0:-)", "0:)", ">:)",
|
||||
">;)", ">:-)", ">_>", "<_<", "\\o/", "<3", "</3", "=-3", "=3", };
|
||||
":-)", ":o)", ":]", ":3", ":c)", ":>", "=]", "=)", ":}", ":-D",
|
||||
"8-D", "X-D", "=-D", "B^D", "<:-)", ">:-[", ":-(", ":-<", ":o(", ":{",
|
||||
":'-(", ":'-)", ":@", "D:<", "D8", "v.v","D-':", ">:O", ":-O", "o_0",
|
||||
":*", ";-)", ";-D", ">:-P", ":-P", "X-P", "=p", ">:-/", ":-/", ":-.",
|
||||
":S", ">.<", ":-|", ":$", ":-X", ":-#", ":-%", ":С", ":-E", ":-*",
|
||||
"0:-3", "0:-)", ">;-)", ">:-)", ">_>", "*<|:-)", "\\o/", "<3", "</3", "=-3", };
|
||||
|
||||
private static final int MAX_PAGE = (int) Math.ceil(symbols.length / 10.0);
|
||||
|
||||
public SmileyDialog(Context c, View mv) {
|
||||
super(c, mv);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
String[] getContentDescription() {
|
||||
return context.getResources().getStringArray(R.array.smileyContentDescription);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -29,7 +33,7 @@ public class SmileyDialog extends AbsSymDialog {
|
|||
|
||||
@Override
|
||||
protected String getTitleText() {
|
||||
return "Smiley";
|
||||
return context.getString(R.string.smiley_insert);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import android.view.View;
|
|||
|
||||
public class SymbolDialog extends AbsSymDialog {
|
||||
|
||||
private static final char[] symbols = {
|
||||
'.', ',', '!', '?', '$', '&', '%', '#', '@', '"', '\'', ':', ';', '(', ')', '/', '\\',
|
||||
private static final char[] symbols = {
|
||||
'.', ',', '!', '?', '$', '&', '%', '#', '@', '"', '\'', ':', ';', '(', ')', '/', '\\',
|
||||
'-', '+', '=', '*', '<', '>', '[', ']', '{', '}', '^', '|', '_', '~', '`' }; // 32
|
||||
private static final int MAX_PAGE = (int) Math.ceil(symbols.length / 10.0);
|
||||
|
||||
|
|
@ -14,6 +14,11 @@ public class SymbolDialog extends AbsSymDialog {
|
|||
super(c, mv);
|
||||
}
|
||||
|
||||
@Override
|
||||
String[] getContentDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSymbol(int index) {
|
||||
return String.valueOf(symbols[index]);
|
||||
|
|
@ -21,7 +26,7 @@ public class SymbolDialog extends AbsSymDialog {
|
|||
|
||||
@Override
|
||||
protected String getTitleText() {
|
||||
return "Symbol";
|
||||
return context.getString(R.string.symbol_insert);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -34,4 +39,4 @@ public class SymbolDialog extends AbsSymDialog {
|
|||
return MAX_PAGE;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,12 +112,15 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
@Override
|
||||
public boolean onEvaluateInputViewShown() {
|
||||
Log.d("T9.onEvaluateInputViewShown", "whatis");
|
||||
Log.d("T9.onEval", "fullscreen?: " + isFullscreenMode() + " isshow?: " + isInputViewShown() + " isrequestedshow?: " + isShowInputRequested());
|
||||
Log.d("T9.onEval", "noshow?: " + mEditing);
|
||||
if (mEditing == EDITING_NOSHOW) {
|
||||
return false;
|
||||
}
|
||||
if (interfacehandler != null) {
|
||||
interfacehandler.showView();
|
||||
}
|
||||
// TODO: Verify if need this:
|
||||
// if (interfacehandler != null) {
|
||||
// interfacehandler.showView();
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -196,17 +199,17 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
// sanitize lang and set index for cycling lang
|
||||
// Need to check if last lang is available, if not, set index to -1 and set lang to default to 0
|
||||
private int sanitizeLang(int lang) {
|
||||
mLangIndex = 0;
|
||||
if (mLangsAvailable.length < 1 || lang == -1) {
|
||||
Log.w("T9.sanitizeLang", "This shouldn't happen.");
|
||||
Log.e("T9.sanitizeLang", "This shouldn't happen.");
|
||||
return 0;
|
||||
}
|
||||
if (lang >= LangHelper.NLANGS) {
|
||||
Log.w("T9.sanitizeLang", "Previous lang not supported: " + lang + " langs: " + Arrays.toString(LangHelper.LANGS));
|
||||
return mLangsAvailable[0];
|
||||
} else {
|
||||
int index = Arrays.asList(mLangsAvailable).indexOf(lang);
|
||||
int index = LangHelper.findIndex(mLangsAvailable, lang);
|
||||
if (index == -1) {
|
||||
mLangIndex = 0;
|
||||
return mLangsAvailable[mLangIndex];
|
||||
} else {
|
||||
mLangIndex = index;
|
||||
|
|
@ -223,9 +226,9 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
@Override
|
||||
public void onStartInput(EditorInfo attribute, boolean restarting) {
|
||||
super.onStartInput(attribute, restarting);
|
||||
// Log.d("onStartInput", "attribute.inputType: " + attribute.inputType +
|
||||
// " restarting? " + restarting);
|
||||
//Utils.printFlags(attribute.inputType);
|
||||
Log.d("onStartInput", "attribute.inputType: " + attribute.inputType +
|
||||
" restarting? " + restarting);
|
||||
Utils.printFlags(attribute.inputType);
|
||||
|
||||
if (attribute.inputType == 0) {
|
||||
// don't do anything when not in any kind of edit field.
|
||||
|
|
@ -233,9 +236,10 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
mEditing = NON_EDIT;
|
||||
requestHideSelf(0);
|
||||
hideStatusIcon();
|
||||
if (interfacehandler != null) {
|
||||
interfacehandler.hideView();
|
||||
}
|
||||
// TODO: verify if need this
|
||||
// if (interfacehandler != null) {
|
||||
// interfacehandler.hideView();
|
||||
// }
|
||||
return;
|
||||
}
|
||||
mFirstPress = true;
|
||||
|
|
@ -248,6 +252,7 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
mLangsAvailable = LangHelper.buildLangs(pref.getString("pref_lang_support", null));
|
||||
mLang = sanitizeLang(pref.getInt("last_lang", 0));
|
||||
|
||||
Log.d("onStartInput", "lang: " + mLang);
|
||||
updateCandidates();
|
||||
|
||||
//TODO: Check if "restarting" variable will make things faster/more effecient
|
||||
|
|
@ -305,11 +310,12 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
mKeyMode = Integer.parseInt(pref.getString("pref_inputmode", "0"));
|
||||
}
|
||||
|
||||
// TODO: Do we need the following:
|
||||
// handle filter list cases... do not hijack DPAD center and make
|
||||
// sure back's go through proper
|
||||
if ((attribute.inputType & InputType.TYPE_TEXT_VARIATION_FILTER) != 0) {
|
||||
mEditing = EDITING_NOSHOW;
|
||||
}
|
||||
//if (variation == InputType.TYPE_TEXT_VARIATION_FILTER) {
|
||||
// mEditing = EDITING_NOSHOW;
|
||||
//}
|
||||
|
||||
// We also want to look at the current state of the editor
|
||||
// to decide whether our alphabetic keyboard should start out
|
||||
|
|
@ -372,6 +378,7 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
// Log.d("onFinishInput", "When is this called?");
|
||||
Editor prefedit = pref.edit();
|
||||
prefedit.putInt("last_lang", mLang);
|
||||
Log.d("onFinishInput", "last_lang: " + mLang);
|
||||
prefedit.commit();
|
||||
if (mEditing == EDITING) {
|
||||
commitTyped();
|
||||
|
|
@ -757,6 +764,9 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
// Log.d("onKeyUp", "showing window.");
|
||||
// //showWindow(true);
|
||||
// }
|
||||
if (! isInputViewShown ()) {
|
||||
showWindow (true);
|
||||
}
|
||||
onKey(keyCode, null);
|
||||
return true;
|
||||
default:
|
||||
|
|
@ -1200,9 +1210,11 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
switch (keyCode) {
|
||||
case KeyEvent.KEYCODE_DPAD_DOWN:
|
||||
mCandidateView.scrollSuggestion(1);
|
||||
getCurrentInputConnection().setComposingText(mSuggestionStrings.get(mCandidateView.mSelectedIndex), 1);
|
||||
return true;
|
||||
case KeyEvent.KEYCODE_DPAD_UP:
|
||||
mCandidateView.scrollSuggestion(-1);
|
||||
getCurrentInputConnection().setComposingText(mSuggestionStrings.get(mCandidateView.mSelectedIndex), 1);
|
||||
return true;
|
||||
case KeyEvent.KEYCODE_DPAD_LEFT:
|
||||
case KeyEvent.KEYCODE_DPAD_RIGHT:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue