mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +01:00
add pref for choosing what goes in parens along with the game name
(where <language> was before.) opponent name still needs to not be hard-coded; the rest works.
This commit is contained in:
parent
ceb2d1ac63
commit
e2ef25ae90
6 changed files with 97 additions and 17 deletions
|
@ -51,6 +51,7 @@
|
|||
<string name="key_notify_vibrate">key_notify_vibrate</string>
|
||||
<string name="key_hide_intro">key_hide_intro</string>
|
||||
<string name="key_keep_screenon">key_keep_screenon</string>
|
||||
<string name="key_summary_field">key_summary_field</string>
|
||||
|
||||
<string name="key_notagain_sync">key_notagain_sync</string>
|
||||
<string name="key_notagain_chat">key_notagain_chat</string>
|
||||
|
@ -162,4 +163,11 @@
|
|||
<item>Slovak</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="game_summary_values">
|
||||
<item>@string/game_summary_field_empty</item>
|
||||
<item>@string/game_summary_field_language</item>
|
||||
<item>@string/game_summary_field_opponents</item>
|
||||
<item>@string/game_summary_field_state</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -189,6 +189,12 @@
|
|||
<string name="loc_external">External</string>
|
||||
<string name="loc_downloads">Downloads</string>
|
||||
|
||||
<string name="summary_field">Include in game listing</string>
|
||||
<string name="game_summary_field_empty">\u003cNothing\u003E</string>
|
||||
<string name="game_summary_field_language">Game language</string>
|
||||
<string name="game_summary_field_opponents">Opponent name[s]</string>
|
||||
<string name="game_summary_field_state">Game state</string>
|
||||
<string name="game_summary_opponents_pending">Not here yet</string>
|
||||
|
||||
<string name="confirm_save_title">Confirm save</string>
|
||||
<string name="confirm_save">This game is in play. If you
|
||||
|
|
|
@ -100,6 +100,13 @@
|
|||
<PreferenceScreen android:title="@string/prefs_appearance"
|
||||
android:summary="@string/prefs_appearance_summary"
|
||||
>
|
||||
<org.eehouse.android.xw4.XWListPreference
|
||||
android:key="@string/key_summary_field"
|
||||
android:title="@string/summary_field"
|
||||
android:entries="@array/game_summary_values"
|
||||
android:entryValues="@array/game_summary_values"
|
||||
android:defaultValue="@string/game_summary_field_opponents"
|
||||
/>
|
||||
<CheckBoxPreference android:key="@string/key_hide_intro"
|
||||
android:title="@string/hide_intro"
|
||||
android:summary="@string/hide_intro_summary"
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.eehouse.android.xw4.jni.CurGameInfo.DeviceRole;
|
|||
public class GameListAdapter extends XWListAdapter {
|
||||
private Context m_context;
|
||||
private LayoutInflater m_factory;
|
||||
private int m_fieldID;
|
||||
private static final int TURN_COLOR = 0x7F00FF00;
|
||||
|
||||
private class ViewInfo implements View.OnClickListener {
|
||||
|
@ -117,17 +118,40 @@ public class GameListAdapter extends XWListAdapter {
|
|||
} else {
|
||||
//Assert.assertNotNull( summary );
|
||||
|
||||
String state = summary.summarizeState( m_context );
|
||||
|
||||
TextView view = (TextView)layout.findViewById( R.id.game_name );
|
||||
if ( hideTitle ) {
|
||||
view.setVisibility( View.GONE );
|
||||
} else {
|
||||
String value = null;
|
||||
switch ( m_fieldID ) {
|
||||
case R.string.game_summary_field_empty:
|
||||
break;
|
||||
case R.string.game_summary_field_language:
|
||||
value =
|
||||
DictLangCache.getLangName( m_context,
|
||||
summary.dictLang );
|
||||
break;
|
||||
case R.string.game_summary_field_opponents:
|
||||
value = "vs Kati +2";
|
||||
break;
|
||||
case R.string.game_summary_field_state:
|
||||
value = state;
|
||||
break;
|
||||
}
|
||||
|
||||
String name = GameUtils.getName( m_context, m_rowid );
|
||||
String format =
|
||||
m_context.getString( R.string.str_game_namef );
|
||||
String lang =
|
||||
DictLangCache.getLangName( m_context,
|
||||
summary.dictLang );
|
||||
view.setText( String.format( format, name, lang ) );
|
||||
|
||||
if ( null != value ) {
|
||||
value = String.format( format, name, value );
|
||||
} else {
|
||||
value = name;
|
||||
}
|
||||
|
||||
view.setText( value );
|
||||
}
|
||||
|
||||
layout.setOnClickListener( new View.OnClickListener() {
|
||||
|
@ -157,7 +181,7 @@ public class GameListAdapter extends XWListAdapter {
|
|||
}
|
||||
|
||||
view = (TextView)layout.findViewById( R.id.state );
|
||||
view.setText( summary.summarizeState( m_context ) );
|
||||
view.setText( state );
|
||||
view = (TextView)layout.findViewById( R.id.modtime );
|
||||
view.setText( m_df.format( new Date( summary.modtime ) ) );
|
||||
|
||||
|
@ -273,4 +297,26 @@ public class GameListAdapter extends XWListAdapter {
|
|||
m_viewsCache.remove( rowid );
|
||||
}
|
||||
}
|
||||
|
||||
public void setField( String field )
|
||||
{
|
||||
int[] ids = {
|
||||
R.string.game_summary_field_empty
|
||||
,R.string.game_summary_field_language
|
||||
,R.string.game_summary_field_opponents
|
||||
,R.string.game_summary_field_state
|
||||
};
|
||||
int result = -1;
|
||||
for ( int id : ids ) {
|
||||
if ( m_context.getString( id ).equals( field ) ) {
|
||||
result = id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( m_fieldID != result ) {
|
||||
m_viewsCache.clear();
|
||||
m_fieldID = result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -71,18 +71,7 @@ public class GamesList extends XWListActivity
|
|||
private String[] m_sameLangDicts;
|
||||
private int m_missingDictLang;
|
||||
private long m_rowid;
|
||||
|
||||
// private XWPhoneStateListener m_phoneStateListener;
|
||||
// private class XWPhoneStateListener extends PhoneStateListener {
|
||||
// @Override
|
||||
// public void onDataConnectionStateChanged( int state )
|
||||
// {
|
||||
// Utils.logf( "onDataConnectionStateChanged(%d)", state );
|
||||
// if ( TelephonyManager.DATA_CONNECTED == state ) {
|
||||
// NetUtils.informOfDeaths( GamesList.this );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
private String m_nameField;
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog( int id )
|
||||
|
@ -350,6 +339,15 @@ public class GamesList extends XWListActivity
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged( boolean hasFocus )
|
||||
{
|
||||
super.onWindowFocusChanged( hasFocus );
|
||||
if ( hasFocus ) {
|
||||
updateField();
|
||||
}
|
||||
}
|
||||
|
||||
// DispatchNotify.HandleRelaysIface interface
|
||||
public void HandleRelaysIDs( final String[] relayIDs )
|
||||
{
|
||||
|
@ -699,4 +697,14 @@ public class GamesList extends XWListActivity
|
|||
}
|
||||
}
|
||||
|
||||
private void updateField()
|
||||
{
|
||||
String newField = CommonPrefs.getSummaryField( this );
|
||||
if ( ! newField.equals( m_nameField ) ) {
|
||||
m_nameField = newField;
|
||||
m_adapter.setField( newField );
|
||||
onContentChanged();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -316,6 +316,11 @@ public class CommonPrefs {
|
|||
return getPrefsBoolean( context, R.string.key_keep_screenon, false );
|
||||
}
|
||||
|
||||
public static String getSummaryField( Context context )
|
||||
{
|
||||
return getString( context, R.string.key_summary_field );
|
||||
}
|
||||
|
||||
public static boolean getPrefsBoolean( Context context, int keyID,
|
||||
boolean defaultValue )
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue