mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
cleanup; make original tiles-values choice the default
We've decided that on upgrade users shouldn't be surprised by a busy board and unaware of how to fix it. So keep it the way it's been and let the curious discover the new ability. Also, simplify code.
This commit is contained in:
parent
2492760426
commit
6c50fcb818
5 changed files with 33 additions and 44 deletions
|
@ -46,6 +46,7 @@ import android.widget.TextView;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -2495,36 +2496,34 @@ public class BoardDelegate extends DelegateBase
|
|||
|
||||
private void doValuesPopup( View button )
|
||||
{
|
||||
final int FAKE_GROUP = 100;
|
||||
final TileValueType selType = CommonPrefs.get(m_activity).tvType;
|
||||
PopupMenu popup = new PopupMenu( m_activity, button );
|
||||
popup.inflate( R.menu.tile_values );
|
||||
final int[][] map = { {R.id.values_faces, TileValueType.TVT_FACES.ordinal() },
|
||||
{R.id.values_values, TileValueType.TVT_VALUES.ordinal() },
|
||||
{R.id.values_both, TileValueType.TVT_BOTH.ordinal() },
|
||||
};
|
||||
Menu menu = popup.getMenu();
|
||||
|
||||
final Map<MenuItem, TileValueType> map = new HashMap<>();
|
||||
for ( TileValueType typ : TileValueType.values() ) {
|
||||
MenuItem item = menu.add( FAKE_GROUP, Menu.NONE, Menu.NONE, typ.getExpl() );
|
||||
map.put( item, typ );
|
||||
|
||||
if ( selType == typ ) {
|
||||
item.setChecked(true);
|
||||
}
|
||||
}
|
||||
menu.setGroupCheckable( FAKE_GROUP, true, true );
|
||||
|
||||
popup.setOnMenuItemClickListener( new PopupMenu.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick( MenuItem item ) {
|
||||
int menuId = item.getItemId();
|
||||
for ( int[] pair : map ) {
|
||||
if ( pair[0] == menuId ) {
|
||||
XWPrefs.setPrefsInt( m_activity,
|
||||
R.string.key_tile_valuetype,
|
||||
pair[1] );
|
||||
handleViaThread( JNICmd.CMD_PREFS_CHANGE );
|
||||
break;
|
||||
}
|
||||
}
|
||||
TileValueType typ = map.get( item );
|
||||
XWPrefs.setPrefsInt( m_activity,
|
||||
R.string.key_tile_valuetype,
|
||||
typ.ordinal() );
|
||||
handleViaThread( JNICmd.CMD_PREFS_CHANGE );
|
||||
return true;
|
||||
}
|
||||
} );
|
||||
|
||||
int curOrd = CommonPrefs.get(m_activity).tvType.ordinal();
|
||||
for ( int[] pair : map ) {
|
||||
if ( pair[1] == curOrd ) {
|
||||
popup.getMenu().findItem(pair[0]).setChecked(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
popup.show();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,10 +35,15 @@ import org.eehouse.android.xw4.loc.LocUtils;
|
|||
public class CommonPrefs extends XWPrefs {
|
||||
private static final String TAG = CommonPrefs.class.getSimpleName();
|
||||
|
||||
// Keep in sync with TileValueType enum in comtypes.h
|
||||
public enum TileValueType {
|
||||
TVT_BOTH,
|
||||
TVT_FACES,
|
||||
TVT_VALUES,
|
||||
TVT_FACES(R.string.values_faces),
|
||||
TVT_VALUES(R.string.values_values),
|
||||
TVT_BOTH(R.string.values_both);
|
||||
|
||||
private int mExplID;
|
||||
private TileValueType(int explID) { mExplID = explID ;}
|
||||
public int getExpl() { return mExplID; }
|
||||
};
|
||||
|
||||
public static final int COLOR_TILE_BACK = 0;
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<group android:checkableBehavior="single">
|
||||
<item android:id="@+id/values_both"
|
||||
android:title="@string/values_menu_both"
|
||||
/>
|
||||
<item android:id="@+id/values_faces"
|
||||
android:title="@string/values_menu_faces"
|
||||
/>
|
||||
<item android:id="@+id/values_values"
|
||||
android:title="@string/values_menu_values"
|
||||
/>
|
||||
</group>
|
||||
</menu>
|
|
@ -2673,8 +2673,8 @@
|
|||
<string name="newgame_configure_first">Configure first</string>
|
||||
|
||||
<!-- For the (new) popup menu for how tile displayed on board -->
|
||||
<string name="values_menu_faces">Letters only</string>
|
||||
<string name="values_menu_values">Values only</string>
|
||||
<string name="values_menu_both">Letters and Values</string>
|
||||
<string name="values_faces">Letters only</string>
|
||||
<string name="values_values">Values only</string>
|
||||
<string name="values_both">Letters and Values</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -217,9 +217,9 @@ typedef enum {
|
|||
} XWBonusType;
|
||||
|
||||
typedef enum _TileValueType {
|
||||
TVT_BOTH,
|
||||
TVT_FACES,
|
||||
TVT_VALUES,
|
||||
TVT_BOTH,
|
||||
|
||||
TVT_N_ENTRIES,
|
||||
} TileValueType;
|
||||
|
|
Loading…
Reference in a new issue