1
0
Fork 0

Fixed bugs, finished settings:

* Checkbox wasn't complete, completed it.
* Fixed DB crash on update due to bad ordering of update stmts
* Fixed crash on boot due to saving lang status
This commit is contained in:
Clam 2014-11-04 14:16:56 +11:00
parent b40db96182
commit 161e27d8af
6 changed files with 21 additions and 11 deletions

View file

@ -66,7 +66,7 @@ public class T9DB {
public static class DBSettings { public static class DBSettings {
public enum SETTING { public enum SETTING {
INPUT_MODE("pref_inputmode", 1), INPUT_MODE("pref_inputmode", 0),
LANG_SUPPORT("pref_lang_support", 1), LANG_SUPPORT("pref_lang_support", 1),
MODE_NOTIFY("pref_mode_notify", 0), MODE_NOTIFY("pref_mode_notify", 0),
LAST_LANG("set_last_lang", 1), LAST_LANG("set_last_lang", 1),
@ -514,10 +514,10 @@ public class T9DB {
if (oldVersion == 2) { if (oldVersion == 2) {
// ADDED SETTINGS, CHANGED LANG VALUE // ADDED SETTINGS, CHANGED LANG VALUE
db.execSQL("DROP INDEX IF EXISTS idx"); db.execSQL("DROP INDEX IF EXISTS idx");
db.execSQL("UPDATE " + WORD_TABLE_NAME + " SET " + COLUMN_LANG + "=" + LANGUAGE.EN.id +
" WHERE " + COLUMN_LANG + "=0");
db.execSQL("UPDATE " + WORD_TABLE_NAME + " SET " + COLUMN_LANG + "=" + LANGUAGE.RU.id + db.execSQL("UPDATE " + WORD_TABLE_NAME + " SET " + COLUMN_LANG + "=" + LANGUAGE.RU.id +
" WHERE " + COLUMN_LANG + "=1"); " WHERE " + COLUMN_LANG + "=1");
db.execSQL("UPDATE " + WORD_TABLE_NAME + " SET " + COLUMN_LANG + "=" + LANGUAGE.EN.id +
" WHERE " + COLUMN_LANG + "=0");
onCreate(db); onCreate(db);
} }
Log.i("T9DB.onUpgrade", "Done."); Log.i("T9DB.onUpgrade", "Done.");

View file

@ -220,6 +220,7 @@ public class TraditionalT9 extends InputMethodService implements
//Utils.printFlags(attribute.inputType); //Utils.printFlags(attribute.inputType);
if (attribute.inputType == 0) { if (attribute.inputType == 0) {
mLang = null;
// 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
mEditing = NON_EDIT; mEditing = NON_EDIT;
@ -254,7 +255,8 @@ public class TraditionalT9 extends InputMethodService implements
mKeyMode = MODE_TEXT; mKeyMode = MODE_TEXT;
boolean modenotify = settings[2].equals("1"); boolean modenotify = settings[2].equals(1);
if (!modenotify && modeNotification != null) { if (!modenotify && modeNotification != null) {
modeNotification = null; modeNotification = null;
} else if (modenotify && modeNotification == null){ } else if (modenotify && modeNotification == null){
@ -384,8 +386,8 @@ public class TraditionalT9 extends InputMethodService implements
public void onFinishInput() { public void onFinishInput() {
super.onFinishInput(); super.onFinishInput();
// Log.d("onFinishInput", "When is this called?"); // Log.d("onFinishInput", "When is this called?");
if (mEditing == EDITING || mEditing == EDITING_NOSHOW) {
db.storeSettingInt(SETTING.LAST_LANG, mLang.id); db.storeSettingInt(SETTING.LAST_LANG, mLang.id);
if (mEditing == EDITING) {
commitTyped(); commitTyped();
finish(); finish();
} }
@ -1293,6 +1295,7 @@ public class TraditionalT9 extends InputMethodService implements
} }
private void modeNotify(String s) { private void modeNotify(String s) {
Log.d("T9.modeNotify", "Notifying:"+s);
modeNotification.setText(s); modeNotification.setText(s);
modeNotification.show(); modeNotification.show();
modeNotification.cancel(); // TODO: This will not always hide the Toast. modeNotification.cancel(); // TODO: This will not always hide the Toast.

View file

@ -38,4 +38,5 @@ public class Setting {
public void setView(View view) { public void setView(View view) {
this.view = view; this.view = view;
} }
public void init() {};
} }

View file

@ -38,7 +38,7 @@ public class SettingAdapter extends ArrayAdapter<Setting> {
final ViewGroup widgetFrame = (ViewGroup) convertView.findViewById(R.id.widget_frame); final ViewGroup widgetFrame = (ViewGroup) convertView.findViewById(R.id.widget_frame);
layoutInflater.inflate(setting.widgetID, widgetFrame); layoutInflater.inflate(setting.widgetID, widgetFrame);
} }
setting.init();
// Return the completed view to render on screen // Return the completed view to render on screen
return convertView; return convertView;
} }

View file

@ -3,8 +3,10 @@ package org.nyanya.android.traditionalt9.settings;
import android.content.Context; import android.content.Context;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.widget.CheckBox;
import org.nyanya.android.traditionalt9.R; import org.nyanya.android.traditionalt9.R;
import org.nyanya.android.traditionalt9.T9DB;
public class SettingCheck extends Setting { public class SettingCheck extends Setting {
boolean value; boolean value;
@ -26,12 +28,18 @@ public class SettingCheck extends Setting {
value = defaultValue; value = defaultValue;
} }
widgetID = R.layout.checkbox; widgetID = R.layout.checkbox;
layout = R.layout.setting_widget;
} }
@Override @Override
public void clicked(Context context) { public void clicked(Context context) {
value = !value;
T9DB.getInstance(context).storeSettingInt(T9DB.DBSettings.SETTING.get(id), value ? 1 : 0);
((CheckBox)view.findViewById(R.id.checkbox)).setChecked(value);
} }
@Override
public void init(){
((CheckBox)view.findViewById(R.id.checkbox)).setChecked(value);
}
} }

View file

@ -18,9 +18,7 @@ public class SettingMultiList extends SettingList {
public SettingMultiList (Context context, AttributeSet attrs, Object[] isettings) { public SettingMultiList (Context context, AttributeSet attrs, Object[] isettings) {
super(context, attrs, isettings); super(context, attrs, isettings);
selectedEntries = new boolean[entries.length]; selectedEntries = new boolean[entries.length];
Log.d("Multi", "len:" + entries.length + " setting:" + isettings[1]);
for (LangHelper.LANGUAGE l : LangHelper.buildLangs((Integer)isettings[1])) { for (LangHelper.LANGUAGE l : LangHelper.buildLangs((Integer)isettings[1])) {
Log.d("Multi", "index:" + l.index);
selectedEntries[l.index] = true; selectedEntries[l.index] = true;
} }
summary = buildItems(); summary = buildItems();