diff --git a/xwords4/android/XWords4/res/layout/game_list_item.xml b/xwords4/android/XWords4/res/layout/game_list_item.xml index 0e6064e08..6466cf20c 100644 --- a/xwords4/android/XWords4/res/layout/game_list_item.xml +++ b/xwords4/android/XWords4/res/layout/game_list_item.xml @@ -11,4 +11,22 @@ android:textAppearance="?android:attr/textAppearanceMedium" /> + + + + + + diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java index e3c448d9d..2a3a2595a 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java @@ -50,7 +50,6 @@ public class GameListAdapter extends XWListAdapter { public Object getItem( int position ) { final View layout = m_factory.inflate( R.layout.game_list_item, null ); - TextView view = (TextView)layout.findViewById( R.id.players ); String path = Utils.gamesList(m_context)[position]; byte[] stream = open( path ); @@ -59,9 +58,22 @@ public class GameListAdapter extends XWListAdapter { XwJNI.gi_from_stream( gi, stream ); GameSummary summary = Utils.getSummary( m_context, path ); - String summaryTxt = gi.summarize( m_context, summary ); - view.setText( summaryTxt ); + TextView view = (TextView)layout.findViewById( R.id.players ); + view.setText( gi.summarizePlayers( m_context, summary ) ); + + view = (TextView)layout.findViewById( R.id.state ); + view.setText( gi.summarizeState( m_context, summary ) ); + view = (TextView)layout.findViewById( R.id.dict ); + view.setText( gi.dictName ); + + view = (TextView)layout.findViewById( R.id.role ); + String roleSummary = gi.summarizeRole( m_context, summary ); + if ( null != roleSummary ) { + view.setText( roleSummary ); + } else { + view.setVisibility( View.GONE ); + } } return layout; } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CurGameInfo.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CurGameInfo.java index cd0ae650a..70b89f9fd 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CurGameInfo.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CurGameInfo.java @@ -209,7 +209,7 @@ public class CurGameInfo { return names; } - public String summarize( Context context, GameSummary summary ) + public String summarizePlayers( Context context, GameSummary summary ) { StringBuffer sb = new StringBuffer(); String vsString = context.getString( R.string.vs ); @@ -223,7 +223,12 @@ public class CurGameInfo { } sb.append( String.format( " %s ", vsString ) ); } + return sb.toString(); + } + public String summarizeRole( Context context, GameSummary summary ) + { + String result = null; if ( null != summary ) { DeviceRole role = serverRole; if ( role != DeviceRole.SERVER_STANDALONE ) { @@ -253,30 +258,26 @@ public class CurGameInfo { : summaryID ); String roleStr = context.getString( roleID ); if ( justListening ) { - tmp = String.format( fmt, roleStr ); + result = String.format( fmt, roleStr ); } else { - tmp = String.format( fmt, roleStr, via ); + result = String.format( fmt, roleStr, via ); } - sb.append( tmp ); } } - - - if ( summary.gameOver ) { - tmp = context.getString( R.string.gameOver ); - } else { - tmp = String.format( context.getString(R.string.movesf), - summary.nMoves ); - } - sb.append( String.format( context.getString(R.string.statef), - tmp ) ); } + return result; + } - sb.append( String.format("\n%s %s", - context.getString( R.string.dictionary ), - dictName ) ); - - return sb.toString(); + public String summarizeState( Context context, GameSummary summary ) + { + String result = null; + if ( summary.gameOver ) { + result = context.getString( R.string.gameOver ); + } else { + result = String.format( context.getString(R.string.movesf), + summary.nMoves ); + } + return String.format( context.getString(R.string.statef), result ); } public boolean addPlayer()