diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java index 367f758f2..a23db96d8 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java @@ -90,8 +90,9 @@ public class DBUtils { public int m_maxShown; public int m_pos; public int m_top; - public int[] m_counts; + public String m_prefix; public int m_count; + public int[] m_counts; } public static GameSummary getSummary( Context context, long rowid, @@ -960,7 +961,8 @@ public class DBUtils { SQLiteDatabase db = s_dbHelper.getReadableDatabase(); String[] columns = { DBHelper.ITERPOS, DBHelper.ITERTOP, DBHelper.ITERMIN, DBHelper.ITERMAX, - DBHelper.WORDCOUNTS, DBHelper.WORDCOUNT }; + DBHelper.WORDCOUNTS, DBHelper.WORDCOUNT, + DBHelper.ITERPREFIX }; String selection = String.format( NAME_FMT, DBHelper.DICTNAME, name ); Cursor cursor = db.query( DBHelper.TABLE_NAME_DICTS, columns, selection, null, null, null, null ); @@ -976,6 +978,9 @@ public class DBUtils { result.m_maxShown = cursor.getInt( cursor .getColumnIndex(DBHelper.ITERMAX)); + result.m_prefix = + cursor.getString( cursor + .getColumnIndex(DBHelper.ITERPREFIX)); result.m_count = cursor.getInt( cursor.getColumnIndex(DBHelper.WORDCOUNT)); String counts = @@ -1007,6 +1012,7 @@ public class DBUtils { values.put( DBHelper.ITERTOP, state.m_top ); values.put( DBHelper.ITERMIN, state.m_minShown ); values.put( DBHelper.ITERMAX, state.m_maxShown ); + values.put( DBHelper.ITERPREFIX, state.m_prefix ); values.put( DBHelper.WORDCOUNT, state.m_count ); if ( null != state.m_counts ) { String[] nums = new String[state.m_counts.length]; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseActivity.java index 7f19aaece..47b08a19e 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseActivity.java @@ -239,6 +239,7 @@ public class DictBrowseActivity extends XWListActivity if ( null == m_browseState ) { m_browseState = DBUtils.dictsGetOffset( this, m_name ); } + showPrefix( true ); } @Override @@ -308,6 +309,20 @@ public class DictBrowseActivity extends XWListActivity EditText edit = (EditText)findViewById( R.id.word_edit ); String text = edit.getText().toString(); if ( null != text && 0 < text.length() ) { + m_browseState.m_prefix = text; + showPrefix( false ); + } + } + + private void showPrefix( boolean fillField ) + { + String text = m_browseState.m_prefix; + if ( null != text && 0 < text.length() ) { + if ( fillField ) { + EditText edit = (EditText)findViewById( R.id.word_edit ); + edit.setText( text ); + } + int pos = XwJNI.dict_iter_getStartsWith( m_dictClosure, text ); if ( 0 <= pos ) { getListView().setSelection( pos );