mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
more studylist: add lookup-on-tap, show language in title bar, and add
menuitem to board menu too
This commit is contained in:
parent
253be9a48e
commit
32ecd1d026
10 changed files with 81 additions and 25 deletions
|
@ -9,7 +9,6 @@
|
|||
>
|
||||
|
||||
<Spinner android:id="@+id/pick_language"
|
||||
android:prompt="@string/pick_language_prompt"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawSelectorOnTop="true"
|
||||
|
|
|
@ -57,6 +57,10 @@
|
|||
android:title="@string/board_menu_game_resend" />
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
<item android:id="@+id/games_menu_study"
|
||||
android:title="@string/gamel_menu_study"
|
||||
/>
|
||||
|
||||
<item android:id="@+id/gamel_menu_checkmoves"
|
||||
android:title="@string/gamel_menu_checkmoves"
|
||||
|
|
|
@ -3,9 +3,12 @@
|
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/copy_all"
|
||||
android:title="@string/slmenu_copy_all"
|
||||
android:showAsAction="ifRoom"
|
||||
/>
|
||||
|
||||
<item android:id="@+id/clear_all"
|
||||
android:title="@string/slmenu_clear_all"
|
||||
android:icon="@drawable/content_discard__gen"
|
||||
android:showAsAction="ifRoom"
|
||||
/>
|
||||
</menu>
|
||||
|
|
|
@ -2204,18 +2204,17 @@
|
|||
<string name="menu_rateme">Rate Crosswords</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="add_to_studyf">Add %s to studylist</string>
|
||||
<string name="title_studyon">Enable studylists</string>
|
||||
<string name="summary_studyon">Offer to add to and display lists
|
||||
of words to remember</string>
|
||||
<string name="gamel_menu_study">Study list…</string>
|
||||
<string name="pick_language_prompt">Choose list language</string>
|
||||
<string name="gamel_menu_study">Studylist…</string>
|
||||
|
||||
<string name="slmenu_copy_all">Copy to clipboard</string>
|
||||
<string name="slmenu_clear_all">Clear all</string>
|
||||
<string name="confirm_studylist_clear">Are you sure you want to
|
||||
remove all the words in this list?\n\n(This action cannot be
|
||||
undone.)</string>
|
||||
delete this list?\n\n(This action cannot be undone.)</string>
|
||||
<string name="paste_donef">%d word[s] copied</string>
|
||||
<string name="studylist_titlef">Studylist for %s</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -804,6 +804,9 @@ public class BoardActivity extends XWActivity
|
|||
Utils.setItemVisible( menu, R.id.gamel_menu_checkmoves, false );
|
||||
}
|
||||
|
||||
boolean enable = 0 < DBUtils.studyListLangs( this ).length;
|
||||
Utils.setItemVisible( menu, R.id.games_menu_study, enable );
|
||||
|
||||
return true;
|
||||
} // onPrepareOptionsMenu
|
||||
|
||||
|
@ -867,6 +870,9 @@ public class BoardActivity extends XWActivity
|
|||
case R.id.board_menu_tray:
|
||||
cmd = JNICmd.CMD_TOGGLE_TRAY;
|
||||
break;
|
||||
case R.id.games_menu_study:
|
||||
StudyList.launch( this, m_gi.dictLang );
|
||||
break;
|
||||
case R.id.board_menu_undo_current:
|
||||
cmd = JNICmd.CMD_UNDO_CUR;
|
||||
break;
|
||||
|
|
|
@ -253,13 +253,9 @@ public class DlgDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
public void launchLookup( String[] words, int lang, boolean forceList )
|
||||
public void launchLookup( String[] words, int lang, boolean noStudyOption )
|
||||
{
|
||||
Intent intent = new Intent( m_activity, LookupActivity.class );
|
||||
intent.putExtra( LookupActivity.WORDS, words );
|
||||
intent.putExtra( LookupActivity.LANG, lang );
|
||||
|
||||
m_activity.startActivity( intent );
|
||||
LookupActivity.launch( m_activity, words, lang, noStudyOption );
|
||||
}
|
||||
|
||||
public void startProgress( int id )
|
||||
|
|
|
@ -790,7 +790,7 @@ public class GamesList extends XWExpandableListActivity
|
|||
break;
|
||||
|
||||
case R.id.games_menu_study:
|
||||
StudyList.launch( this );
|
||||
StudyList.launch( this, StudyList.NO_LANG );
|
||||
break;
|
||||
|
||||
case R.id.games_menu_about:
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
package org.eehouse.android.xw4;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
|
@ -41,6 +42,7 @@ public class LookupActivity extends XWListActivity
|
|||
|
||||
public static final String WORDS = "WORDS";
|
||||
public static final String LANG = "LANG";
|
||||
public static final String NOSTUDY = "NOSTUDY";
|
||||
private static final String FORCELIST = "FORCELIST";
|
||||
private static final String STATE = "STATE";
|
||||
private static final String WORDINDEX = "WORDINDEX";
|
||||
|
@ -83,6 +85,9 @@ public class LookupActivity extends XWListActivity
|
|||
setLang( intent.getIntExtra( LANG, -1 ) );
|
||||
m_forceList = intent.getBooleanExtra( FORCELIST, false );
|
||||
m_studyOn = XWPrefs.getStudyEnabled( this );
|
||||
if ( m_studyOn ) {
|
||||
m_studyOn = !intent.getBooleanExtra( NOSTUDY, false );
|
||||
}
|
||||
|
||||
m_state = STATE_DONE;
|
||||
adjustState( 1 );
|
||||
|
@ -195,7 +200,9 @@ public class LookupActivity extends XWListActivity
|
|||
m_doneButton.setText( txt );
|
||||
txt = Utils.format( this, R.string.add_to_studyf,
|
||||
m_words[m_wordIndex] );
|
||||
m_studyButton.setVisibility( View.VISIBLE );
|
||||
if ( m_studyOn ) {
|
||||
m_studyButton.setVisibility( View.VISIBLE );
|
||||
}
|
||||
m_studyButton.setText( txt );
|
||||
break;
|
||||
case STATE_LOOKUP:
|
||||
|
@ -263,4 +270,15 @@ public class LookupActivity extends XWListActivity
|
|||
String title = Utils.format( this, R.string.pick_url_titlef, word );
|
||||
m_summary.setText( title );
|
||||
}
|
||||
|
||||
public static void launch( Activity activity, String[] words, int lang,
|
||||
boolean noStudyOption )
|
||||
{
|
||||
Intent intent = new Intent( activity, LookupActivity.class );
|
||||
intent.putExtra( WORDS, words );
|
||||
intent.putExtra( LANG, lang );
|
||||
intent.putExtra( NOSTUDY, noStudyOption );
|
||||
|
||||
activity.startActivity( intent );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.eehouse.android.xw4;
|
||||
|
||||
import android.widget.ListView;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
@ -39,7 +40,10 @@ import junit.framework.Assert;
|
|||
public class StudyList extends XWListActivity
|
||||
implements OnItemSelectedListener {
|
||||
|
||||
public static final int NO_LANG = -1;
|
||||
|
||||
private static final int CLEAR_ACTION = 1;
|
||||
private static final String START_LANG = "START_LANG";
|
||||
|
||||
private Spinner m_spinner;
|
||||
private int[] m_langCodes;
|
||||
|
@ -54,7 +58,7 @@ public class StudyList extends XWListActivity
|
|||
setContentView( R.layout.studylist );
|
||||
|
||||
m_spinner = (Spinner)findViewById( R.id.pick_language );
|
||||
initOrFinish();
|
||||
initOrFinish( getIntent() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -101,7 +105,7 @@ public class StudyList extends XWListActivity
|
|||
switch ( id ) {
|
||||
case CLEAR_ACTION:
|
||||
DBUtils.studyListClear( this, m_langCodes[m_position] );
|
||||
initOrFinish();
|
||||
initOrFinish( null );
|
||||
break;
|
||||
default:
|
||||
Assert.fail();
|
||||
|
@ -110,6 +114,13 @@ public class StudyList extends XWListActivity
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListItemClick( ListView lv, View view, int position, long id )
|
||||
{
|
||||
String[] words = { m_words[position] };
|
||||
launchLookup( words, m_langCodes[m_position], true );
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// AdapterView.OnItemSelectedListener interface
|
||||
//////////////////////////////////////////////////
|
||||
|
@ -136,9 +147,13 @@ public class StudyList extends XWListActivity
|
|||
// adapter.sort();
|
||||
|
||||
setListAdapter( adapter );
|
||||
|
||||
String langName = DictLangCache.getLangNames( this )[lang];
|
||||
String title = getString( R.string.studylist_titlef, langName );
|
||||
setTitle( title );
|
||||
}
|
||||
|
||||
private void initOrFinish()
|
||||
private void initOrFinish( Intent startIntent )
|
||||
{
|
||||
m_langCodes = DBUtils.studyListLangs( this );
|
||||
if ( 0 == m_langCodes.length ) {
|
||||
|
@ -148,10 +163,20 @@ public class StudyList extends XWListActivity
|
|||
m_position = 0;
|
||||
loadList();
|
||||
} else {
|
||||
int startLang = NO_LANG;
|
||||
int startIndex = -1;
|
||||
if ( null != startIntent ) {
|
||||
startLang = startIntent.getIntExtra( START_LANG, NO_LANG );
|
||||
}
|
||||
|
||||
String[] names = DictLangCache.getLangNames( this );
|
||||
String[] myNames = new String[m_langCodes.length];
|
||||
for ( int ii = 0; ii < m_langCodes.length; ++ii ) {
|
||||
myNames[ii] = names[m_langCodes[ii]];
|
||||
int lang = m_langCodes[ii];
|
||||
myNames[ii] = names[lang];
|
||||
if ( lang == startLang ) {
|
||||
startIndex = ii;
|
||||
}
|
||||
}
|
||||
|
||||
ArrayAdapter<String> adapter = new
|
||||
|
@ -162,12 +187,18 @@ public class StudyList extends XWListActivity
|
|||
simple_spinner_dropdown_item );
|
||||
m_spinner.setAdapter( adapter );
|
||||
m_spinner.setOnItemSelectedListener( this );
|
||||
if ( -1 != startIndex ) {
|
||||
m_spinner.setSelection( startIndex );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void launch( Context context )
|
||||
public static void launch( Context context, int lang )
|
||||
{
|
||||
Intent intent = new Intent( context, StudyList.class );
|
||||
if ( NO_LANG != lang ) {
|
||||
intent.putExtra( START_LANG, lang );
|
||||
}
|
||||
context.startActivity( intent );
|
||||
}
|
||||
|
||||
|
|
|
@ -168,16 +168,16 @@ public class XWListActivity extends ListActivity
|
|||
Assert.fail();
|
||||
}
|
||||
|
||||
protected void launchLookup( String[] words, int lang, boolean noStudy )
|
||||
{
|
||||
m_delegate.launchLookup( words, lang, noStudy );
|
||||
}
|
||||
|
||||
protected void launchLookup( String[] words, int lang )
|
||||
{
|
||||
m_delegate.launchLookup( words, lang, false );
|
||||
}
|
||||
|
||||
protected void launchLookup( String[] words, int lang, boolean forceList )
|
||||
{
|
||||
m_delegate.launchLookup( words, lang, forceList );
|
||||
}
|
||||
|
||||
// MultiService.MultiEventListener interface
|
||||
public void eventOccurred( MultiService.MultiEvent event,
|
||||
final Object ... args )
|
||||
|
|
Loading…
Reference in a new issue