mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-01 19:57:11 +01:00
rough out UI for adding selected or played words to study list DB. Next: add a UI for displaying it etc.
This commit is contained in:
parent
af035962e6
commit
49d26dab07
9 changed files with 98 additions and 10 deletions
|
@ -19,6 +19,10 @@
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<Button android:id="@+id/button_study"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
/>
|
||||||
<Button android:id="@+id/button_done"
|
<Button android:id="@+id/button_done"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
<string name="key_enable_sms">key_enable_sms</string>
|
<string name="key_enable_sms">key_enable_sms</string>
|
||||||
<string name="key_keep_screenon">key_keep_screenon</string>
|
<string name="key_keep_screenon">key_keep_screenon</string>
|
||||||
<string name="key_thumbsize">key_thumbsize3</string>
|
<string name="key_thumbsize">key_thumbsize3</string>
|
||||||
|
<string name="key_studyon">key_studyon</string>
|
||||||
|
|
||||||
<string name="key_summary_field">key_summary_field</string>
|
<string name="key_summary_field">key_summary_field</string>
|
||||||
<string name="key_default_loc">key_default_loc</string>
|
<string name="key_default_loc">key_default_loc</string>
|
||||||
|
|
|
@ -1788,10 +1788,13 @@
|
||||||
<!-- New strings that need to be documented and found a home
|
<!-- New strings that need to be documented and found a home
|
||||||
above. -->
|
above. -->
|
||||||
<string name="button_lookup">Look up words</string>
|
<string name="button_lookup">Look up words</string>
|
||||||
|
<string name="button_lookup_study">Look up/study words</string>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<string name="button_lookupf">Look up %s</string>
|
<string name="button_lookupf">Look up %s</string>
|
||||||
|
<string name="button_lookup_studyf">Look up/study %s</string>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<string name="title_lookup">Tap to look up</string>
|
<string name="title_lookup">Tap to look up</string>
|
||||||
|
<string name="title_lookup_study">Tap to look up or study</string>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<string name="button_done">Done</string>
|
<string name="button_done">Done</string>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
|
@ -2200,4 +2203,10 @@
|
||||||
|
|
||||||
<string name="menu_rateme">Rate Crosswords</string>
|
<string name="menu_rateme">Rate Crosswords</string>
|
||||||
<string name="no_market">Google Play app not found</string>
|
<string name="no_market">Google Play app not found</string>
|
||||||
|
|
||||||
|
<string name="add_to_studyf">Add %s to study list</string>
|
||||||
|
<string name="title_studyon">Enable study lists</string>
|
||||||
|
<string name="summary_studyon">Offer to add to and display lists
|
||||||
|
of words to remember</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -246,6 +246,11 @@
|
||||||
android:summary="@string/summary_sort_tiles"
|
android:summary="@string/summary_sort_tiles"
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
/>
|
/>
|
||||||
|
<CheckBoxPreference android:key="@string/key_studyon"
|
||||||
|
android:title="@string/title_studyon"
|
||||||
|
android:summary="@string/summary_studyon"
|
||||||
|
android:defaultValue="false"
|
||||||
|
/>
|
||||||
<CheckBoxPreference android:key="@string/key_ringer_zoom"
|
<CheckBoxPreference android:key="@string/key_ringer_zoom"
|
||||||
android:title="@string/ringer_zoom"
|
android:title="@string/ringer_zoom"
|
||||||
android:summary="@string/ringer_zoom_summary"
|
android:summary="@string/ringer_zoom_summary"
|
||||||
|
|
|
@ -393,12 +393,16 @@ public class BoardActivity extends XWActivity
|
||||||
} else if ( DLG_SCORES_BLK == id ) {
|
} else if ( DLG_SCORES_BLK == id ) {
|
||||||
if ( null != m_words && m_words.length > 0 ) {
|
if ( null != m_words && m_words.length > 0 ) {
|
||||||
String buttonTxt;
|
String buttonTxt;
|
||||||
|
boolean studyOn = XWPrefs.getStudyEnabled( this );
|
||||||
if ( m_words.length == 1 ) {
|
if ( m_words.length == 1 ) {
|
||||||
buttonTxt = Utils.format( this,
|
int resID = studyOn
|
||||||
R.string.button_lookupf,
|
? R.string.button_lookup_studyf
|
||||||
m_words[0] );
|
: R.string.button_lookupf;
|
||||||
|
buttonTxt = Utils.format( this, resID, m_words[0] );
|
||||||
} else {
|
} else {
|
||||||
buttonTxt = getString( R.string.button_lookup );
|
int resID = studyOn ? R.string.button_lookup_study
|
||||||
|
: R.string.button_lookup;
|
||||||
|
buttonTxt = getString( resID );
|
||||||
}
|
}
|
||||||
lstnr = new DialogInterface.OnClickListener() {
|
lstnr = new DialogInterface.OnClickListener() {
|
||||||
public void onClick( DialogInterface dialog,
|
public void onClick( DialogInterface dialog,
|
||||||
|
|
|
@ -36,8 +36,9 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
public static final String TABLE_NAME_DICTBROWSE = "dictbrowse";
|
public static final String TABLE_NAME_DICTBROWSE = "dictbrowse";
|
||||||
public static final String TABLE_NAME_DICTINFO = "dictinfo";
|
public static final String TABLE_NAME_DICTINFO = "dictinfo";
|
||||||
public static final String TABLE_NAME_GROUPS = "groups";
|
public static final String TABLE_NAME_GROUPS = "groups";
|
||||||
|
public static final String TABLE_NAME_STUDYLIST = "study";
|
||||||
private static final String DB_NAME = "xwdb";
|
private static final String DB_NAME = "xwdb";
|
||||||
private static final int DB_VERSION = 18;
|
private static final int DB_VERSION = 19;
|
||||||
|
|
||||||
public static final String GAME_NAME = "GAME_NAME";
|
public static final String GAME_NAME = "GAME_NAME";
|
||||||
public static final String VISID = "VISID";
|
public static final String VISID = "VISID";
|
||||||
|
@ -87,6 +88,9 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
public static final String GROUPNAME = "GROUPNAME";
|
public static final String GROUPNAME = "GROUPNAME";
|
||||||
public static final String EXPANDED = "EXPANDED";
|
public static final String EXPANDED = "EXPANDED";
|
||||||
|
|
||||||
|
public static final String WORD = "WORD";
|
||||||
|
public static final String LANGUAGE = "LANGUAGE";
|
||||||
|
|
||||||
private Context m_context;
|
private Context m_context;
|
||||||
|
|
||||||
private static final String[][] s_summaryColsAndTypes = {
|
private static final String[][] s_summaryColsAndTypes = {
|
||||||
|
@ -153,6 +157,12 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
,{ EXPANDED, "INTEGER(1)" }
|
,{ EXPANDED, "INTEGER(1)" }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static final String[][] s_studySchema = {
|
||||||
|
{ WORD, "TEXT" }
|
||||||
|
,{ LANGUAGE, "INTEGER(1)" }
|
||||||
|
,{ "UNIQUE", "(" + WORD + ", " + LANGUAGE + ")" }
|
||||||
|
};
|
||||||
|
|
||||||
public DBHelper( Context context )
|
public DBHelper( Context context )
|
||||||
{
|
{
|
||||||
super( context, DB_NAME, null, DB_VERSION );
|
super( context, DB_NAME, null, DB_VERSION );
|
||||||
|
@ -173,6 +183,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
createTable( db, TABLE_NAME_DICTBROWSE, s_dictBrowseColsAndTypes );
|
createTable( db, TABLE_NAME_DICTBROWSE, s_dictBrowseColsAndTypes );
|
||||||
forceRowidHigh( db, TABLE_NAME_SUM );
|
forceRowidHigh( db, TABLE_NAME_SUM );
|
||||||
createGroupsTable( db );
|
createGroupsTable( db );
|
||||||
|
createStudyTable( db );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -217,6 +228,9 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
addSumColumn( db, THUMBNAIL );
|
addSumColumn( db, THUMBNAIL );
|
||||||
// nothing yet
|
// nothing yet
|
||||||
break;
|
break;
|
||||||
|
case 18:
|
||||||
|
createStudyTable( db );
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
db.execSQL( "DROP TABLE " + TABLE_NAME_SUM + ";" );
|
db.execSQL( "DROP TABLE " + TABLE_NAME_SUM + ";" );
|
||||||
if ( oldVersion >= 6 ) {
|
if ( oldVersion >= 6 ) {
|
||||||
|
@ -278,6 +292,11 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
XWPrefs.setDefaultNewGameGroup( m_context, newGroup );
|
XWPrefs.setDefaultNewGameGroup( m_context, newGroup );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createStudyTable( SQLiteDatabase db )
|
||||||
|
{
|
||||||
|
createTable( db, TABLE_NAME_STUDYLIST, s_studySchema );
|
||||||
|
}
|
||||||
|
|
||||||
// Move all existing games to the row previously named "cur games'
|
// Move all existing games to the row previously named "cur games'
|
||||||
private void moveToCurGames( SQLiteDatabase db )
|
private void moveToCurGames( SQLiteDatabase db )
|
||||||
{
|
{
|
||||||
|
|
|
@ -1565,6 +1565,21 @@ public class DBUtils {
|
||||||
return colNames;
|
return colNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void addToStudyList( Context context, String word,
|
||||||
|
int lang )
|
||||||
|
{
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put( DBHelper.WORD, word );
|
||||||
|
values.put( DBHelper.LANGUAGE, lang );
|
||||||
|
|
||||||
|
initDB( context );
|
||||||
|
synchronized( s_dbHelper ) {
|
||||||
|
SQLiteDatabase db = s_dbHelper.getWritableDatabase();
|
||||||
|
db.insert( DBHelper.TABLE_NAME_STUDYLIST, null, values );
|
||||||
|
db.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void copyGameDB( Context context, boolean toSDCard )
|
private static void copyGameDB( Context context, boolean toSDCard )
|
||||||
{
|
{
|
||||||
String name = DBHelper.getDBName();
|
String name = DBHelper.getDBName();
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class LookupActivity extends XWListActivity
|
||||||
|
|
||||||
public static final String WORDS = "WORDS";
|
public static final String WORDS = "WORDS";
|
||||||
public static final String LANG = "LANG";
|
public static final String LANG = "LANG";
|
||||||
public static final String FORCELIST = "FORCELIST";
|
private static final String FORCELIST = "FORCELIST";
|
||||||
private static final String STATE = "STATE";
|
private static final String STATE = "STATE";
|
||||||
private static final String WORDINDEX = "WORDINDEX";
|
private static final String WORDINDEX = "WORDINDEX";
|
||||||
private static final String URLINDEX = "URLINDEX";
|
private static final String URLINDEX = "URLINDEX";
|
||||||
|
@ -62,11 +62,13 @@ public class LookupActivity extends XWListActivity
|
||||||
|
|
||||||
private String[] m_words;
|
private String[] m_words;
|
||||||
private boolean m_forceList;
|
private boolean m_forceList;
|
||||||
|
private boolean m_studyOn;
|
||||||
private int m_wordIndex = 0;
|
private int m_wordIndex = 0;
|
||||||
private int m_urlIndex = 0;
|
private int m_urlIndex = 0;
|
||||||
private int m_state;
|
private int m_state;
|
||||||
private ArrayAdapter<String> m_wordsAdapter;
|
private ArrayAdapter<String> m_wordsAdapter;
|
||||||
private Button m_doneButton;
|
private Button m_doneButton;
|
||||||
|
private Button m_studyButton;
|
||||||
private TextView m_summary;
|
private TextView m_summary;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -80,6 +82,7 @@ public class LookupActivity extends XWListActivity
|
||||||
m_words = intent.getStringArrayExtra( WORDS );
|
m_words = intent.getStringArrayExtra( WORDS );
|
||||||
setLang( intent.getIntExtra( LANG, -1 ) );
|
setLang( intent.getIntExtra( LANG, -1 ) );
|
||||||
m_forceList = intent.getBooleanExtra( FORCELIST, false );
|
m_forceList = intent.getBooleanExtra( FORCELIST, false );
|
||||||
|
m_studyOn = XWPrefs.getStudyEnabled( this );
|
||||||
|
|
||||||
m_state = STATE_DONE;
|
m_state = STATE_DONE;
|
||||||
adjustState( 1 );
|
adjustState( 1 );
|
||||||
|
@ -90,6 +93,12 @@ public class LookupActivity extends XWListActivity
|
||||||
|
|
||||||
m_doneButton = (Button)findViewById( R.id.button_done );
|
m_doneButton = (Button)findViewById( R.id.button_done );
|
||||||
m_doneButton.setOnClickListener( this );
|
m_doneButton.setOnClickListener( this );
|
||||||
|
m_studyButton = (Button)findViewById( R.id.button_study );
|
||||||
|
if ( m_studyOn ) {
|
||||||
|
m_studyButton.setOnClickListener( this );
|
||||||
|
} else {
|
||||||
|
m_studyButton.setVisibility( View.GONE );
|
||||||
|
}
|
||||||
|
|
||||||
m_summary = (TextView)findViewById( R.id.summary );
|
m_summary = (TextView)findViewById( R.id.summary );
|
||||||
|
|
||||||
|
@ -120,7 +129,11 @@ public class LookupActivity extends XWListActivity
|
||||||
/* View.OnClickListener -- just the Done button */
|
/* View.OnClickListener -- just the Done button */
|
||||||
public void onClick( View view )
|
public void onClick( View view )
|
||||||
{
|
{
|
||||||
switchState( -1 );
|
if ( view == m_doneButton ) {
|
||||||
|
switchState( -1 );
|
||||||
|
} else if ( view == m_studyButton ) {
|
||||||
|
addToList( m_words[m_wordIndex] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* AdapterView.OnItemClickListener */
|
/* AdapterView.OnItemClickListener */
|
||||||
|
@ -146,7 +159,7 @@ public class LookupActivity extends XWListActivity
|
||||||
m_state += incr;
|
m_state += incr;
|
||||||
}
|
}
|
||||||
if ( STATE_URLS == m_state &&
|
if ( STATE_URLS == m_state &&
|
||||||
( 1 >= s_lookupUrls.length && !m_forceList ) ) {
|
( 1 >= s_lookupUrls.length && !m_forceList && !m_studyOn ) ) {
|
||||||
m_state += incr;
|
m_state += incr;
|
||||||
}
|
}
|
||||||
if ( m_state == curState ) {
|
if ( m_state == curState ) {
|
||||||
|
@ -169,8 +182,10 @@ public class LookupActivity extends XWListActivity
|
||||||
break;
|
break;
|
||||||
case STATE_WORDS:
|
case STATE_WORDS:
|
||||||
getListView().setAdapter( m_wordsAdapter );
|
getListView().setAdapter( m_wordsAdapter );
|
||||||
setSummary( R.string.title_lookup );
|
setSummary( m_studyOn ?
|
||||||
|
R.string.title_lookup_study : R.string.title_lookup );
|
||||||
m_doneButton.setText( R.string.button_done );
|
m_doneButton.setText( R.string.button_done );
|
||||||
|
m_studyButton.setVisibility( View.GONE );
|
||||||
break;
|
break;
|
||||||
case STATE_URLS:
|
case STATE_URLS:
|
||||||
getListView().setAdapter( s_urlsAdapter );
|
getListView().setAdapter( s_urlsAdapter );
|
||||||
|
@ -178,6 +193,10 @@ public class LookupActivity extends XWListActivity
|
||||||
String txt = Utils.format( this, R.string.button_donef,
|
String txt = Utils.format( this, R.string.button_donef,
|
||||||
m_words[m_wordIndex] );
|
m_words[m_wordIndex] );
|
||||||
m_doneButton.setText( txt );
|
m_doneButton.setText( txt );
|
||||||
|
txt = Utils.format( this, R.string.add_to_studyf,
|
||||||
|
m_words[m_wordIndex] );
|
||||||
|
m_studyButton.setVisibility( View.VISIBLE );
|
||||||
|
m_studyButton.setText( txt );
|
||||||
break;
|
break;
|
||||||
case STATE_LOOKUP:
|
case STATE_LOOKUP:
|
||||||
lookupWord( m_words[m_wordIndex], s_lookupUrls[m_urlIndex] );
|
lookupWord( m_words[m_wordIndex], s_lookupUrls[m_urlIndex] );
|
||||||
|
@ -244,4 +263,11 @@ public class LookupActivity extends XWListActivity
|
||||||
String title = Utils.format( this, R.string.pick_url_titlef, word );
|
String title = Utils.format( this, R.string.pick_url_titlef, word );
|
||||||
m_summary.setText( title );
|
m_summary.setText( title );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addToList( String word )
|
||||||
|
{
|
||||||
|
String msg = String.format("Wants to study %s", word );
|
||||||
|
Utils.showToast( this, msg );
|
||||||
|
DBUtils.addToStudyList( this, word, s_lang );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -370,6 +370,11 @@ public class XWPrefs {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean getStudyEnabled( Context context )
|
||||||
|
{
|
||||||
|
return getPrefsBoolean( context, R.string.key_studyon, false );
|
||||||
|
}
|
||||||
|
|
||||||
protected static String getPrefsString( Context context, int keyID )
|
protected static String getPrefsString( Context context, int keyID )
|
||||||
{
|
{
|
||||||
String key = context.getString( keyID );
|
String key = context.getString( keyID );
|
||||||
|
|
Loading…
Add table
Reference in a new issue