1
0
Fork 0

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:
Clam 2014-03-29 23:41:32 +11:00
parent 2ba6003ea9
commit 9150bf62d7
13 changed files with 226 additions and 97 deletions

View file

@ -3,7 +3,7 @@ buildscript {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:0.7.+' classpath 'com.android.tools.build:gradle:0.9.0'
} }
} }
apply plugin: 'android' apply plugin: 'android'

View file

@ -1,6 +1,6 @@
#Mon Jan 13 17:37:00 EST 2014 #Sat Mar 22 23:26:27 EST 2014
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-all.zip distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-all.zip

View file

@ -1,57 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
android:background="@drawable/bggradient"
android:baselineAligned="true"
android:gravity="bottom"
android:orientation="horizontal" >
<Button
android:id="@+id/main_leftold"
android:layout_width="190px"
android:layout_height="match_parent"
android:layout_marginLeft="1px"
android:layout_marginRight="1px"
android:background="@drawable/button_custom"
android:focusable="false"
android:longClickable="true"
android:text="@string/main_left_insert"
android:textColor="@color/button_text" />
<Button
android:id="@+id/main_mid"
android:layout_width="94px"
android:layout_height="match_parent"
android:layout_marginLeft="1px"
android:layout_marginRight="1px"
android:background="@drawable/button_custom"
android:focusable="false"
android:longClickable="true"
android:text="@string/main_mid"
android:textColor="@color/button_text" />
<RelativeLayout
android:id="@+id/main_right"
android:layout_width="190px"
android:layout_height="58dp"
android:layout_marginLeft="1px"
android:layout_marginTop="0dp"
android:background="@drawable/button_custom"
android:clickable="true"
android:focusable="false"
android:longClickable="true"
android:paddingLeft="2dp"
android:paddingTop="1dp" >
<include
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
layout="@layout/rbutton" />
</RelativeLayout>
</LinearLayout>

View file

@ -21,4 +21,73 @@
<item>0</item> <item>0</item>
<item>1</item> <item>1</item>
</string-array> </string-array>
<string-array name="smileyContentDescription">
<item>улыбка</item>
<item>клоун</item>
<item>дурачок</item>
<item>няшный</item>
<item>усатый смайл</item>
<item>злорадство</item>
<item>очень счастливый</item>
<item>счастливый</item>
<item>усатый</item>
<item>смеющийся</item>
<item>смеющийся с открытыми глазами</item>
<item>смеющийся с закрытыми глазами</item>
<item>восторг</item>
<item>крутой</item>
<item>ученый</item>
<item>хмурый взгляд</item>
<item>грустный</item>
<item>уныние</item>
<item>грустный клоун</item>
<item>растроенный усатый</item>
<item>плачущий</item>
<item>смех до слез</item>
<item>ругается</item>
<item>страх</item>
<item>ужас</item>
<item>кошмар</item>
<item>тревога</item>
<item>открыл рот от возмущения</item>
<item>шок</item>
<item>удивление</item>
<item>поцелуй</item>
<item>улыбка с подмигиванием</item>
<item>смеющийся с подмигиванием</item>
<item>игривый</item>
<item>показать язык</item>
<item>дразнится</item>
<item>киска с языком</item>
<item>раздражен</item>
<item>скептик</item>
<item>неопределился</item>
<item>не понял</item>
<item>зажмурил глаза</item>
<item>без чувств</item>
<item>рот закреполен скрепкой</item>
<item>рот на замке</item>
<item>Ношу подтяжки</item>
<item>банкир</item>
<item>лодырь</item>
<item>зубастый вампир</item>
<item>съел кислое</item>
<item>святой</item>
<item>невиновный</item>
<item>дьявол подмигивает</item>
<item>дьявол</item>
<item>подозрительный</item>
<item>день рождения</item>
<item>ура</item>
<item>сердце</item>
<item>разбитое сердце</item>
<item>милый</item>
</string-array>
</resources> </resources>

View file

@ -50,7 +50,13 @@
<string name="pref_help">О программе</string> <string name="pref_help">О программе</string>
<string name="symbol_next">Следущая страница</string> <string name="symbol_next">Следущая страница</string>
<string name="symbol_prev">Предыдущая страница</string> <string name="symbol_prev">Предыдущая страница</string>
<string name="symbol_insert">Вставить символ</string>
<string name="smiley_insert">Вставить смайл</string>
<string name="symbol_page">Стр: %1$s/%2$s</string>
<string name="title_activity_add_word">Добавить слово</string> <string name="title_activity_add_word">Добавить слово</string>
<string name="traditionalt9_settings">Traditional T9 настройки</string> <string name="traditionalt9_settings">Traditional T9 настройки</string>
<string name="pref_russiansupport">Включить поддержку Русского языка</string> <string name="pref_russiansupport">Включить поддержку Русского языка</string>
</resources> </resources>

View file

@ -22,4 +22,73 @@
<item >0</item> <item >0</item>
<item >1</item> <item >1</item>
</string-array> </string-array>
<string-array name="smileyContentDescription">
<item> Smile </item>
<item> Clown </item>
<item> Sharp grin </item>
<item> Cat </item>
<item> Half nose </item>
<item> Schadenfreude </item>
<item> Big eye sharp grin </item>
<item> Big eye smile </item>
<item> Cheeky smile </item>
<item> Laughing </item>
<item> Bug eye laughing </item>
<item> Laughing with eyes closed </item>
<item> Big eye laughing </item>
<item> Glasses pointy nose laughing </item>
<item> Pointed hat smile </item>
<item> Frown </item>
<item> Sad </item>
<item> Disheartened </item>
<item> Sad clown </item>
<item> Sad cheeky </item>
<item> Crying </item>
<item> Laughing to tears </item>
<item> Expletive </item>
<item> Shocked frown </item>
<item> Bug eye\'d frown </item>
<item> Sad with eyes closed </item>
<item> Crying with mouth open </item>
<item> Frown with mouth open </item>
<item> Shocked </item>
<item> Surprised </item>
<item> Kiss </item>
<item> Winking smile </item>
<item> Winking laugh </item>
<item> Cheeky tongue out </item>
<item> Tongue out </item>
<item> Teasing </item>
<item> Big eye\'d tongue out </item>
<item> Annoyed </item>
<item> Skeptic </item>
<item> Undecided </item>
<item> Confused </item>
<item> Closed eyes </item>
<item> Unimpressed </item>
<item> Bashful </item>
<item> Mouth shut </item>
<item> Censored </item>
<item> Banker </item>
<item> Very big sad mouth </item>
<item> Mischievous/sarcasm </item>
<item> Sour face </item>
<item> Innocent cat </item>
<item> Innocent smile </item>
<item> Evil wink </item>
<item> Evil grin </item>
<item> Shifty eyes </item>
<item> Party hat smile </item>
<item> Arms up cheering </item>
<item> Heart </item>
<item> Broken heart </item>
<item> big eye\'d cat </item>
</string-array>
</resources> </resources>

View file

@ -18,6 +18,10 @@
<string name="ricon_desc">Hold Icon</string> <string name="ricon_desc">Hold Icon</string>
<string name="symbol_next">Next Page</string> <string name="symbol_next">Next Page</string>
<string name="symbol_prev">Prev Page</string> <string name="symbol_prev">Prev Page</string>
<string name="symbol_insert">Insert Symbol</string>
<string name="smiley_insert">Insert Smiley</string>
<string name="symbol_page">Page: %1$s/%2$s</string>
<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="close">Close</string> <string name="close">Close</string>

View file

@ -10,6 +10,7 @@
android:dialogTitle="@string/pref_inputmode" android:dialogTitle="@string/pref_inputmode"
android:entries="@array/pref_inputmode_entries" android:entries="@array/pref_inputmode_entries"
android:entryValues="@array/pref_inputmode_values" android:entryValues="@array/pref_inputmode_values"
android:persistent="true"
android:defaultValue="0" android:summary="@string/pref_inputmode_desc"/> android:defaultValue="0" android:summary="@string/pref_inputmode_desc"/>
<pl.wavesoftware.widget.MultiSelectListPreference <pl.wavesoftware.widget.MultiSelectListPreference
android:defaultValue="@array/pref_lang_defaults" android:defaultValue="@array/pref_lang_defaults"

View file

@ -15,13 +15,12 @@ import java.util.Arrays;
public abstract class AbsSymDialog extends Dialog implements public abstract class AbsSymDialog extends Dialog implements
View.OnClickListener { View.OnClickListener {
private KeyboardView.OnKeyboardActionListener parent; protected Context context;
private View mainview; private View mainview;
private int pagenum = 1; private int pagenum = 1;
private int pageoffset = (pagenum - 1) * 10; private int pageoffset = (pagenum - 1) * 10;
private int MAX_PAGE; private int MAX_PAGE;
private String title;
private boolean started; private boolean started;
private static final int[] buttons = { private static final int[] buttons = {
@ -37,7 +36,7 @@ public abstract class AbsSymDialog extends Dialog implements
public AbsSymDialog(Context c, View mv) { public AbsSymDialog(Context c, View mv) {
super(c); super(c);
parent = (KeyboardView.OnKeyboardActionListener) c; context = c;
mainview = mv; mainview = mv;
started = true; started = true;
setContentView(mv); setContentView(mv);
@ -52,9 +51,11 @@ public abstract class AbsSymDialog extends Dialog implements
button.setOnClickListener(this); button.setOnClickListener(this);
} }
MAX_PAGE = getMaxPage(); 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 @Override
public void onClick(View v) { public void onClick(View v) {
// Log.d("SymbolPopup - onClick", "click happen: " + 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); // Log.d("SymbolDialog - sendChar", "Sending index: " + index);
if (index < getSymbolSize()) { if (index < getSymbolSize()) {
parent.onText(getSymbol(index)); ((KeyboardView.OnKeyboardActionListener) context).onText(getSymbol(index));
// then close // then close
pagenum = 1; pagenum = 1;
pageoffset = (pagenum - 1) * 10; pageoffset = (pagenum - 1) * 10;
@ -129,7 +130,8 @@ public abstract class AbsSymDialog extends Dialog implements
private void updateButtons() { private void updateButtons() {
// set page number text // 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 // update button labels
int symbx = pageoffset; int symbx = pageoffset;
int stop = symbx + 9; int stop = symbx + 9;
@ -138,14 +140,20 @@ public abstract class AbsSymDialog extends Dialog implements
if (nomore >= symsize - 1) { if (nomore >= symsize - 1) {
nomore = symsize - 1; nomore = symsize - 1;
} }
TextView tv;
String[] cd = getContentDescription();
for (int buttx = 0; symbx <= stop; symbx++) { for (int buttx = 0; symbx <= stop; symbx++) {
// Log.d("SymbolDialog - updateButtons", "buttx: " + buttx + // Log.d("SymbolDialog - updateButtons", "buttx: " + buttx +
// " symbx: " + symbx); // " 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])) tv = (TextView) mainview.findViewById(buttons[buttx]);
.setText(String.valueOf(getSymbol(symbx))); tv.setText(String.valueOf(getSymbol(symbx)));
if (cd != null) {
tv.setContentDescription(cd[symbx]);
}
} }
buttx++; buttx++;
} }

View file

@ -51,6 +51,14 @@ public class LangHelper {
iansize++; 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;
} }
} }

View file

@ -7,19 +7,23 @@ 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)", ":>", "=]", "=)", ":}", ":-D", ":D", "8-D", ":-)", ":o)", ":]", ":3", ":c)", ":>", "=]", "=)", ":}", ":-D",
"8D", "X-D", "XD", "=-D", "=D", "B^D", ">:[", ":-(", ":(", ":c", ":-<", ":<", ":-[", "8-D", "X-D", "=-D", "B^D", "<:-)", ">:-[", ":-(", ":-<", ":o(", ":{",
":[", ":{", ":'-(", ":'(", ":'-)", ":')", ":@", "D:<", "D:", "D8", "D;", "D=", "DX", ":'-(", ":'-)", ":@", "D:<", "D8", "v.v","D-':", ">:O", ":-O", "o_0",
"v.v", "D-':", ">:O", ":-O", ":O", ":O", "o_O", "o_0", "o.O", "8-0", ":*", ";-)", ";)", ":*", ";-)", ";-D", ">:-P", ":-P", "X-P", "=p", ">:-/", ":-/", ":-.",
";-]", ";]", ";D", ">:P", ":-P", ":P", "XP", "xp", ":-p", ":p", "=p", ":-b", ":b", ":S", ">.<", ":-|", ":$", ":-X", ":-#", ":-%", ":С", ":-E", ":-*",
">:\\", ">:/", ":-/", ":-.", ":/", ":\\", "=/", "=\\", ":L", "=L", ":S", ">.<", ":|", "0:-3", "0:-)", ">;-)", ">:-)", ">_>", "*<|:-)", "\\o/", "<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);
public SmileyDialog(Context c, View mv) { public SmileyDialog(Context c, View mv) {
super(c, mv); super(c, mv);
}
@Override
String[] getContentDescription() {
return context.getResources().getStringArray(R.array.smileyContentDescription);
} }
@Override @Override
@ -29,7 +33,7 @@ public class SmileyDialog extends AbsSymDialog {
@Override @Override
protected String getTitleText() { protected String getTitleText() {
return "Smiley"; return context.getString(R.string.smiley_insert);
} }
@Override @Override

View file

@ -14,6 +14,11 @@ public class SymbolDialog extends AbsSymDialog {
super(c, mv); super(c, mv);
} }
@Override
String[] getContentDescription() {
return null;
}
@Override @Override
protected String getSymbol(int index) { protected String getSymbol(int index) {
return String.valueOf(symbols[index]); return String.valueOf(symbols[index]);
@ -21,7 +26,7 @@ public class SymbolDialog extends AbsSymDialog {
@Override @Override
protected String getTitleText() { protected String getTitleText() {
return "Symbol"; return context.getString(R.string.symbol_insert);
} }
@Override @Override

View file

@ -112,12 +112,15 @@ public class TraditionalT9 extends InputMethodService implements
@Override @Override
public boolean onEvaluateInputViewShown() { public boolean onEvaluateInputViewShown() {
Log.d("T9.onEvaluateInputViewShown", "whatis"); 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) { if (mEditing == EDITING_NOSHOW) {
return false; return false;
} }
if (interfacehandler != null) { // TODO: Verify if need this:
interfacehandler.showView(); // if (interfacehandler != null) {
} // interfacehandler.showView();
// }
return true; return true;
} }
@ -196,17 +199,17 @@ public class TraditionalT9 extends InputMethodService implements
// sanitize lang and set index for cycling lang // 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 // 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) { private int sanitizeLang(int lang) {
mLangIndex = 0;
if (mLangsAvailable.length < 1 || lang == -1) { if (mLangsAvailable.length < 1 || lang == -1) {
Log.w("T9.sanitizeLang", "This shouldn't happen."); Log.e("T9.sanitizeLang", "This shouldn't happen.");
return 0; return 0;
} }
if (lang >= LangHelper.NLANGS) { if (lang >= LangHelper.NLANGS) {
Log.w("T9.sanitizeLang", "Previous lang not supported: " + lang + " langs: " + Arrays.toString(LangHelper.LANGS)); Log.w("T9.sanitizeLang", "Previous lang not supported: " + lang + " langs: " + Arrays.toString(LangHelper.LANGS));
return mLangsAvailable[0]; return mLangsAvailable[0];
} else { } else {
int index = Arrays.asList(mLangsAvailable).indexOf(lang); int index = LangHelper.findIndex(mLangsAvailable, lang);
if (index == -1) { if (index == -1) {
mLangIndex = 0;
return mLangsAvailable[mLangIndex]; return mLangsAvailable[mLangIndex];
} else { } else {
mLangIndex = index; mLangIndex = index;
@ -223,9 +226,9 @@ public class TraditionalT9 extends InputMethodService implements
@Override @Override
public void onStartInput(EditorInfo attribute, boolean restarting) { public void onStartInput(EditorInfo attribute, boolean restarting) {
super.onStartInput(attribute, restarting); super.onStartInput(attribute, restarting);
// Log.d("onStartInput", "attribute.inputType: " + attribute.inputType + Log.d("onStartInput", "attribute.inputType: " + attribute.inputType +
// " restarting? " + restarting); " restarting? " + restarting);
//Utils.printFlags(attribute.inputType); Utils.printFlags(attribute.inputType);
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.
@ -233,9 +236,10 @@ public class TraditionalT9 extends InputMethodService implements
mEditing = NON_EDIT; mEditing = NON_EDIT;
requestHideSelf(0); requestHideSelf(0);
hideStatusIcon(); hideStatusIcon();
if (interfacehandler != null) { // TODO: verify if need this
interfacehandler.hideView(); // if (interfacehandler != null) {
} // interfacehandler.hideView();
// }
return; return;
} }
mFirstPress = true; mFirstPress = true;
@ -248,6 +252,7 @@ public class TraditionalT9 extends InputMethodService implements
mLangsAvailable = LangHelper.buildLangs(pref.getString("pref_lang_support", null)); mLangsAvailable = LangHelper.buildLangs(pref.getString("pref_lang_support", null));
mLang = sanitizeLang(pref.getInt("last_lang", 0)); mLang = sanitizeLang(pref.getInt("last_lang", 0));
Log.d("onStartInput", "lang: " + mLang);
updateCandidates(); updateCandidates();
//TODO: Check if "restarting" variable will make things faster/more effecient //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")); 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 // handle filter list cases... do not hijack DPAD center and make
// sure back's go through proper // sure back's go through proper
if ((attribute.inputType & InputType.TYPE_TEXT_VARIATION_FILTER) != 0) { //if (variation == InputType.TYPE_TEXT_VARIATION_FILTER) {
mEditing = EDITING_NOSHOW; // mEditing = EDITING_NOSHOW;
} //}
// We also want to look at the current state of the editor // We also want to look at the current state of the editor
// to decide whether our alphabetic keyboard should start out // 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?"); // Log.d("onFinishInput", "When is this called?");
Editor prefedit = pref.edit(); Editor prefedit = pref.edit();
prefedit.putInt("last_lang", mLang); prefedit.putInt("last_lang", mLang);
Log.d("onFinishInput", "last_lang: " + mLang);
prefedit.commit(); prefedit.commit();
if (mEditing == EDITING) { if (mEditing == EDITING) {
commitTyped(); commitTyped();
@ -757,6 +764,9 @@ public class TraditionalT9 extends InputMethodService implements
// Log.d("onKeyUp", "showing window."); // Log.d("onKeyUp", "showing window.");
// //showWindow(true); // //showWindow(true);
// } // }
if (! isInputViewShown ()) {
showWindow (true);
}
onKey(keyCode, null); onKey(keyCode, null);
return true; return true;
default: default:
@ -1200,9 +1210,11 @@ public class TraditionalT9 extends InputMethodService implements
switch (keyCode) { switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_DOWN: case KeyEvent.KEYCODE_DPAD_DOWN:
mCandidateView.scrollSuggestion(1); mCandidateView.scrollSuggestion(1);
getCurrentInputConnection().setComposingText(mSuggestionStrings.get(mCandidateView.mSelectedIndex), 1);
return true; return true;
case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_UP:
mCandidateView.scrollSuggestion(-1); mCandidateView.scrollSuggestion(-1);
getCurrentInputConnection().setComposingText(mSuggestionStrings.get(mCandidateView.mSelectedIndex), 1);
return true; return true;
case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_LEFT:
case KeyEvent.KEYCODE_DPAD_RIGHT: case KeyEvent.KEYCODE_DPAD_RIGHT: