placeholder icons for up and down, and fix to show only when there's room to move

This commit is contained in:
Eric House 2013-10-19 22:09:07 -07:00
parent 93425fe1e7
commit b9afc47a25
2 changed files with 23 additions and 10 deletions

View file

@ -69,18 +69,22 @@
/>
<!-- Group items -->
<item android:id="@+id/list_group_moveup"
android:title="@string/list_group_moveup"
android:showAsAction="ifRoom"
android:icon="@drawable/up__gen"
/>
<item android:id="@+id/list_group_movedown"
android:title="@string/list_group_movedown"
android:showAsAction="ifRoom"
android:icon="@drawable/down__gen"
/>
<item android:id="@+id/list_group_default"
android:title="@string/list_group_default"
/>
<item android:id="@+id/list_group_rename"
android:title="@string/list_group_rename"
/>
<item android:id="@+id/list_group_moveup"
android:title="@string/list_group_moveup"
/>
<item android:id="@+id/list_group_movedown"
android:title="@string/list_group_movedown"
/>
<!-- Debug only menuitems -->
<item android:id="@+id/gamel_menu_checkupdates"

View file

@ -113,8 +113,6 @@ public class GamesList extends XWExpandableListActivity
private static final int[] ONEGROUP_ITEMS = {
R.id.list_group_rename,
R.id.list_group_moveup,
R.id.list_group_movedown,
};
private static boolean s_firstShown = false;
@ -643,16 +641,27 @@ public class GamesList extends XWExpandableListActivity
Utils.setItemVisible( menu, id, 1 == nGroupsSelected );
}
int selGroupPos = -1;
if ( 1 == nGroupsSelected ) {
selGroupPos = m_selectedGroups.iterator().next();
}
// You can't delete the default group, nor make it the default
boolean defaultAvail = 1 == nGroupsSelected;
if ( defaultAvail ) {
int selPos = m_selectedGroups.iterator().next();
long selID = m_adapter.getGroupIDFor( selPos );
long selID = m_adapter.getGroupIDFor( selGroupPos );
defaultAvail = selID != XWPrefs.getDefaultNewGameGroup( this );
}
Utils.setItemVisible( menu, R.id.list_group_default, defaultAvail );
Utils.setItemVisible( menu, R.id.list_group_delete, defaultAvail );
// Move up/down enabled for groups if not the top-most or bottommost
// selected
boolean enable = 0 < selGroupPos;
Utils.setItemVisible( menu, R.id.list_group_moveup, enable );
enable = 0 <= selGroupPos && selGroupPos + 1 < m_adapter.getGroupCount();
Utils.setItemVisible( menu, R.id.list_group_movedown, enable );
// New game available when nothing selected or one group
Utils.setItemVisible( menu, R.id.gamel_menu_newgame,
nothingSelected || 1 == nGroupsSelected );