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:
parent
b40db96182
commit
161e27d8af
6 changed files with 21 additions and 11 deletions
|
|
@ -66,7 +66,7 @@ public class T9DB {
|
|||
|
||||
public static class DBSettings {
|
||||
public enum SETTING {
|
||||
INPUT_MODE("pref_inputmode", 1),
|
||||
INPUT_MODE("pref_inputmode", 0),
|
||||
LANG_SUPPORT("pref_lang_support", 1),
|
||||
MODE_NOTIFY("pref_mode_notify", 0),
|
||||
LAST_LANG("set_last_lang", 1),
|
||||
|
|
@ -514,10 +514,10 @@ public class T9DB {
|
|||
if (oldVersion == 2) {
|
||||
// ADDED SETTINGS, CHANGED LANG VALUE
|
||||
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 +
|
||||
" WHERE " + COLUMN_LANG + "=1");
|
||||
db.execSQL("UPDATE " + WORD_TABLE_NAME + " SET " + COLUMN_LANG + "=" + LANGUAGE.EN.id +
|
||||
" WHERE " + COLUMN_LANG + "=0");
|
||||
onCreate(db);
|
||||
}
|
||||
Log.i("T9DB.onUpgrade", "Done.");
|
||||
|
|
|
|||
|
|
@ -220,6 +220,7 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
//Utils.printFlags(attribute.inputType);
|
||||
|
||||
if (attribute.inputType == 0) {
|
||||
mLang = null;
|
||||
// don't do anything when not in any kind of edit field.
|
||||
// should also turn off input screen and stuff
|
||||
mEditing = NON_EDIT;
|
||||
|
|
@ -254,7 +255,8 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
|
||||
mKeyMode = MODE_TEXT;
|
||||
|
||||
boolean modenotify = settings[2].equals("1");
|
||||
boolean modenotify = settings[2].equals(1);
|
||||
|
||||
if (!modenotify && modeNotification != null) {
|
||||
modeNotification = null;
|
||||
} else if (modenotify && modeNotification == null){
|
||||
|
|
@ -384,8 +386,8 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
public void onFinishInput() {
|
||||
super.onFinishInput();
|
||||
// Log.d("onFinishInput", "When is this called?");
|
||||
db.storeSettingInt(SETTING.LAST_LANG, mLang.id);
|
||||
if (mEditing == EDITING) {
|
||||
if (mEditing == EDITING || mEditing == EDITING_NOSHOW) {
|
||||
db.storeSettingInt(SETTING.LAST_LANG, mLang.id);
|
||||
commitTyped();
|
||||
finish();
|
||||
}
|
||||
|
|
@ -1293,6 +1295,7 @@ public class TraditionalT9 extends InputMethodService implements
|
|||
}
|
||||
|
||||
private void modeNotify(String s) {
|
||||
Log.d("T9.modeNotify", "Notifying:"+s);
|
||||
modeNotification.setText(s);
|
||||
modeNotification.show();
|
||||
modeNotification.cancel(); // TODO: This will not always hide the Toast.
|
||||
|
|
|
|||
|
|
@ -38,4 +38,5 @@ public class Setting {
|
|||
public void setView(View view) {
|
||||
this.view = view;
|
||||
}
|
||||
public void init() {};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class SettingAdapter extends ArrayAdapter<Setting> {
|
|||
final ViewGroup widgetFrame = (ViewGroup) convertView.findViewById(R.id.widget_frame);
|
||||
layoutInflater.inflate(setting.widgetID, widgetFrame);
|
||||
}
|
||||
|
||||
setting.init();
|
||||
// Return the completed view to render on screen
|
||||
return convertView;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@ package org.nyanya.android.traditionalt9.settings;
|
|||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.CheckBox;
|
||||
|
||||
import org.nyanya.android.traditionalt9.R;
|
||||
import org.nyanya.android.traditionalt9.T9DB;
|
||||
|
||||
public class SettingCheck extends Setting {
|
||||
boolean value;
|
||||
|
|
@ -26,12 +28,18 @@ public class SettingCheck extends Setting {
|
|||
value = defaultValue;
|
||||
}
|
||||
widgetID = R.layout.checkbox;
|
||||
layout = R.layout.setting_widget;
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,9 +18,7 @@ public class SettingMultiList extends SettingList {
|
|||
public SettingMultiList (Context context, AttributeSet attrs, Object[] isettings) {
|
||||
super(context, attrs, isettings);
|
||||
selectedEntries = new boolean[entries.length];
|
||||
Log.d("Multi", "len:" + entries.length + " setting:" + isettings[1]);
|
||||
for (LangHelper.LANGUAGE l : LangHelper.buildLangs((Integer)isettings[1])) {
|
||||
Log.d("Multi", "index:" + l.index);
|
||||
selectedEntries[l.index] = true;
|
||||
}
|
||||
summary = buildItems();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue