in popup from dict icon in game toolbar, show only those wordlists in

same language as game, and show "wordlist browser" item last rather
than first.
This commit is contained in:
Eric House 2015-05-13 06:56:23 -07:00
parent 1d6d8e46a3
commit 520611399b
2 changed files with 12 additions and 8 deletions

View file

@ -937,7 +937,8 @@ public class BoardDelegate extends DelegateBase
String curDict = m_gi.dictName( m_view.getCurPlayer() );
View button = m_toolbar.getViewFor( Toolbar.BUTTON_BROWSE_DICT );
if ( Action.BUTTON_BROWSEALL_ACTION == action &&
DictsActivity.handleDictsPopup( m_activity, button, curDict ) ) {
DictsActivity.handleDictsPopup( m_activity, button,
curDict, m_gi.dictLang ) ){
break;
}
DictBrowseDelegate.launch( m_activity, curDict );

View file

@ -36,7 +36,8 @@ import org.eehouse.android.xw4.loc.LocUtils;
public class DictsActivity extends XWListActivity {
private static interface SafePopup {
public void doPopup( Context context, View button, String curDict );
public void doPopup( Context context, View button,
String curDict, int lang );
}
private static SafePopup s_safePopup = null;
// I can't provide a subclass of MenuItem to hold DictAndLoc, so
@ -61,7 +62,7 @@ public class DictsActivity extends XWListActivity {
private static class SafePopupImpl implements SafePopup {
public void doPopup( final Context context, View button,
String curDict ) {
String curDict, int lang ) {
MenuItem.OnMenuItemClickListener listener =
new MenuItem.OnMenuItemClickListener() {
@ -83,8 +84,6 @@ public class DictsActivity extends XWListActivity {
s_itemData = new HashMap<MenuItem, DictAndLoc>();
PopupMenu popup = new PopupMenu( context, button );
Menu menu = popup.getMenu();
menu.add( R.string.show_wordlist_browser )
.setOnMenuItemClickListener( listener );
// Add at top but save until have dal info
MenuItem curItem =
@ -92,19 +91,23 @@ public class DictsActivity extends XWListActivity {
R.string.cur_menu_marker_fmt,
curDict ) );
DictAndLoc[] dals = DictUtils.dictList( context );
DictAndLoc[] dals = DictLangCache.getDALsHaveLang( context, lang );
for ( DictAndLoc dal : dals ) {
MenuItem item = dal.name.equals(curDict)
? curItem : menu.add( dal.name );
item.setOnMenuItemClickListener( listener );
s_itemData.put( item, dal );
}
menu.add( R.string.show_wordlist_browser )
.setOnMenuItemClickListener( listener );
popup.show();
}
}
public static boolean handleDictsPopup( Context context, View button,
String curDict )
String curDict, int lang )
{
if ( null == s_safePopup ) {
int sdkVersion = Integer.valueOf( android.os.Build.VERSION.SDK );
@ -115,7 +118,7 @@ public class DictsActivity extends XWListActivity {
boolean canHandle = null != s_safePopup;
if ( canHandle ) {
s_safePopup.doPopup( context, button, curDict );
s_safePopup.doPopup( context, button, curDict, lang );
}
return canHandle;
}