only show lookup menuitem when there's a single word selected, and include that word in the menu title

This commit is contained in:
Eric House 2014-03-22 10:37:48 -07:00
parent e2cd275459
commit 73a1083dff
3 changed files with 11 additions and 5 deletions

View file

@ -2,7 +2,6 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/slmenu_lookup_sel"
android:title="@string/slmenu_lookup_sel"
android:icon="@drawable/search__gen"
android:showAsAction="ifRoom"
/>

View file

@ -2230,6 +2230,5 @@
<string name="slmenu_select_all">Select all</string>
<string name="slmenu_deselect_all">Unselect all</string>
<string name="sel_itemsf">Selected: %d</string>
<string name="slmenu_lookup_sel">Look up</string>
</resources>

View file

@ -98,9 +98,16 @@ public class StudyList extends XWListActivity
int nSel = m_checkeds.size();
Utils.setItemVisible( menu, R.id.slmenu_copy_sel, 0 < nSel );
Utils.setItemVisible( menu, R.id.slmenu_clear_sel, 0 < nSel );
Utils.setItemVisible( menu, R.id.slmenu_select_all, m_words.length > nSel );
Utils.setItemVisible( menu, R.id.slmenu_select_all,
m_words.length > nSel );
Utils.setItemVisible( menu, R.id.slmenu_deselect_all, 0 < nSel );
Utils.setItemVisible( menu, R.id.slmenu_lookup_sel, 0 < nSel );
boolean enable = 1 == nSel;
if ( enable ) {
String title =
getString( R.string.button_lookupf, getSelWords()[0] );
menu.findItem( R.id.slmenu_lookup_sel ).setTitle( title );
}
Utils.setItemVisible( menu, R.id.slmenu_lookup_sel, enable );
return super.onPrepareOptionsMenu( menu );
}
@ -130,7 +137,8 @@ public class StudyList extends XWListActivity
clearSels();
break;
case R.id.slmenu_lookup_sel:
launchLookup( getSelWords(), m_langCodes[m_langPosition], true );
String[] oneWord = new String[]{ getSelWords()[0] };
launchLookup( oneWord, m_langCodes[m_langPosition], true );
break;
default:
handled = false;