From 520611399b3909f3d9c4a63b2efeb3316ede0d7b Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 13 May 2015 06:56:23 -0700 Subject: [PATCH] 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. --- .../org/eehouse/android/xw4/BoardDelegate.java | 3 ++- .../org/eehouse/android/xw4/DictsActivity.java | 17 ++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java index e8d0879f5..5d86ba995 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java @@ -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 ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java index ec477fbd9..4c3542ecf 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java @@ -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(); 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; }