Merge branch 'android_branch' into send_in_background

This commit is contained in:
eehouse@eehouse.org 2011-08-21 12:20:25 -07:00 committed by Andy2
commit d7d5d85ec2
11 changed files with 103 additions and 82 deletions

View file

@ -22,7 +22,7 @@
to come from a domain that you own or have control over. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.eehouse.android.xw4"
android:versionCode="25"
android:versionCode="26"
android:versionName="@string/app_version"
>

View file

@ -38,6 +38,7 @@
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
/>

View file

@ -6,27 +6,33 @@
</head>
<body>
<b>Crosswords 4.4 beta 32 release</b>
<p><em>32's a quickie to fix a crash introduced in 31. So I'll leave the
older changes in place</em></p>
<b>Crosswords 4.4 beta 33 release</b>
<ul>
<li>Give choice between sending invites as TEXT or HTML, then format
differently depending</li>
<li>Use the term "wordlist" instead of "dictionary" to not imply that
there are definitions provided.</li>
<li>include link in invites to install Crosswords</li>
<li>Change how downloaded wordlists are opened to consume much less
Java memory. Downside: wordlists on external storage are not
available when that storage is mounted on a computer over USB.</li>
<li>Add expand/contract buttons to games list</li>
<li>In the Wordlists screen, hide wordlists stored on external media
when the media's not available. Notice when it becomes available
and redraw the list.</li>
<li>Add ability to rename games</li>
<li>Make a game's language one of several configurable attributes
that can be displayed along with the game</li>
<li>Don't crash when user chooses "Copy"</li>
<li>Fix rename of games to work when keyboard opened while dialog
up.</li>
<li>Add icons to games list display so it's easier to tell networked
from standalone. These are placeholders until I can get an artist
to help out. :-)</li>
</ul>
<p>Please remember that this is beta software. Please let me know (at
eehouse@eehouse.org) what's broken and what features you'd most like
to see.</p>

View file

@ -78,7 +78,7 @@
<!-- <string name="default_host">10.0.2.2</string> -->
<string name="dict_url">http://eehouse.org/and_dicts_hh</string>
<string name="app_version">4.4 beta 32</string>
<string name="app_version">4.4 beta 33</string>
<string name="game_url_pathf">//%1$s/redir.php</string>
<!-- Debugging stuff. No point in localizing it. -->

View file

@ -25,10 +25,10 @@
<string name="play">Play game</string>
<string name="title_games_list">Crosswords</string>
<string name="title_dicts_list">Dictionaries</string>
<string name="title_dicts_list">Installed Crosswords Wordlists</string>
<string name="title_langs_list">Languages (based on installed
dictionaries)</string>
wordlists)</string>
<string name="lang_label">Game language</string>
<string name="title_game_configf">%s settings</string>
<string name="title_gamenet_configf">%s settings (networked)</string>
@ -124,6 +124,7 @@
<string name="str_local_name">%s</string>
<string name="str_nonlocal_name">(remote)</string>
<string name="str_nonlocal_namef">%s (remote)</string>
<string name="vs_join">\u0020vs.\u0020</string>
<string name="str_game_namef">%1$s (%2$s)</string>
<string name="str_bonus_all">Bonus for using all tiles: 50\n</string>
<string name="strd_turn_score">Score for turn: %d\n</string>
@ -143,7 +144,7 @@
<string name="str_cant_hint_while_disabled">The hint feature is disabled for this game. Enable it for a new game using the Settings dialog.</string>
<string name="str_no_peek_remote_tiles">No peeking at remote players\' tiles!</string>
<string name="str_reg_unexpected_user">Refused attempt to register unexpected user[s]</string>
<string name="str_server_dict_wins">Conflict between Host and Guest dictionaries; Host wins.</string>
<string name="str_server_dict_wins">Conflict between Host and Guest wordlists; Host wins.</string>
<string name="str_reg_server_sans_remote">At least one player must be marked \"Remote\" for a game started as Host.</string>
<string name="remote_label">Off-device player</string>
@ -161,18 +162,18 @@
<string name="button_add_player">Add player</string>
<string name="button_juggle_players">Shuffle players</string>
<string name="dicts_item_move">Move dictionary</string>
<string name="dicts_item_move">Move wordlist</string>
<string name="dicts_item_select">Make default</string>
<string name="dicts_item_details">Details</string>
<string name="move_dictf">Move dictionary %1$s from %2$s to %3$s?</string>
<string name="move_dictf">Move wordlist %1$s from %2$s to %3$s?</string>
<string name="set_default_messagef">For what players should this
dictionary (and the language %s) be the default for new
games?</string>
wordlist be the default for new games? (The language %s will be
the default for both.)</string>
<string name="button_default_human">Human</string>
<string name="button_default_robot">Robot</string>
<string name="button_default_both">Both</string>
<string name="dict_lang_labelf">Dictionary (in %s)</string>
<string name="dict_lang_labelf">Wordlist (in %s)</string>
<string name="connect_label">Connection (via internet)</string>
<string name="room_public">Make new room public</string>
<string name="join_room">Join public room</string>
@ -213,10 +214,10 @@
<string name="confirm_delete_dictf">Are you sure you want to
delete %s?</string>
<string name="confirm_deleteonly_dictf">\u0020It is the only %s
dictionary installed. One or more games will be unopenable
wordlist installed. One or more games will be unopenable
without it.</string>
<string name="confirm_deletemore_dictf">\u0020One game (at least)
is using it (but there is another %s dictionary installed that
is using it (but there is another %s wordlist installed that
can replace it.)</string>
<string name="hints_allowed">Allow hints</string>
@ -254,8 +255,8 @@
<string name="peek_other_summary">Tapping on scoreboard name shows
that player\'s tiles</string>
<string name="storeWhereTitle">Dictionary storage</string>
<string name="storeWhereMsg">Store downloaded dictionaries using
<string name="storeWhereTitle">Wordlist storage</string>
<string name="storeWhereMsg">Store downloaded wordlists using
internal or external (SD card) memory? (You can always move them
later.)</string>
<string name="button_internal">Internal</string>
@ -270,7 +271,7 @@
<string name="robot_smartest">Smartest robot</string>
<string name="menu_prefs">Settings</string>
<string name="gamel_menu_dicts">Dictionaries</string>
<string name="gamel_menu_dicts">Wordlists</string>
<string name="menu_revert_all">Restore all</string>
<string name="menu_revert_colors">Restore colors</string>
<string name="confirm_revert_colors">Are you sure you want to
@ -299,14 +300,14 @@
<string name="pref_player4_name">Fourth player</string>
<string name="tell_unused">Not used yet...</string>
<string name="prefs_dicts">Dictionaries</string>
<string name="prefs_dicts_summary">Default dictionaries</string>
<string name="default_dict">Dictionary for humans</string>
<string name="default_robodict">Dictionary for robots</string>
<string name="prefs_dicts">Wordlists</string>
<string name="prefs_dicts_summary">Default wordlists</string>
<string name="default_dict">Wordlist for humans</string>
<string name="default_robodict">Wordlist for robots</string>
<string name="default_phonies">Handle phonies</string>
<string name="phonies_spinner_prompt">How to handle \"phonies\"
(words not in dictionary)</string>
(words not in wordlist)</string>
<string name="board_size">Board size</string>
<string name="prefs_colors">Individual colors</string>
@ -349,7 +350,7 @@
another device. You will not be able to play any
further.</string>
<string name="ids_badwords">Word[s] %s not found in dictionary.</string>
<string name="ids_badwords">Word[s] %s not found in wordlist.</string>
<string name="badwords_accept"> Do you still want to accept this move?</string>
<string name="badwords_lost"> Turn lost.</string>
<string name="badwords_title">Illegal word[s]</string>
@ -383,24 +384,24 @@
credits pending permission.</string>
<string name="downloading_dictf">Downloading Crosswords
dictionary %s...</string>
<string name="no_dict_title">Dictionary not found</string>
wordlist %s...</string>
<string name="no_dict_title">Wordlist not found</string>
<string name="button_download">Download</string>
<string name="subst_dict_title">Substitute dictionary (wordcount)</string>
<string name="subst_dict_title">Substitute wordlist (wordcount)</string>
<string name="button_substdict">Substitute</string>
<string name="button_close_game">Close game</string>
<string name="no_dict_finish">A dictionary this game is using has
<string name="no_dict_finish">A wordlist this game is using has
disappeared. (Usually this means it\'s on an external card that
is no longer available.)</string>
<string name="no_dictf">Unable to open game \"%1$s\" because no
%2$s dictionary found. (It may have been deleted, or stored on
%2$s wordlist found. (It may have been deleted, or stored on
an external card that is no longer available.)</string>
<string name="no_dict_substf">Unable to open game \"%1$s\" because
dictionary %2$s not found. (It may have been deleted, or stored
wordlist %2$s not found. (It may have been deleted, or stored
on an external card that is no longer available.) You can
download a replacement or substitute another %3$s
dictionary.</string>
wordlist.</string>
<string name="msg_ask_password">Password for \"%s\":</string>
@ -513,12 +514,12 @@
game on the relay. You will be notified when the remaining
device[s] have joined your room and play can begin.</string>
<string name="not_again_dicts">Crosswords dictionaries, which are
<string name="not_again_dicts">Crosswords wordlists, which are
just compressed lists of words plus tile information, determine
what language a game is played in and how \"smart\" the robot is.
You can download different sized dictionaries in many languages
here. Email me at eehouse@eehouse.org for information on building
and installing your own dictionaries.</string>
what language a game is played in and how \"smart\" the robot
is. You can download different sized wordlists in many
languages here. Email me at eehouse@eehouse.org for information
on building and installing your own wordlists.</string>
<string name="not_again_arrow">Moving tiles to the board:\nYou can
drag tiles between the rack and the board, or you can tap an

View file

@ -107,7 +107,7 @@ public class DBUtils {
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
summary = new GameSummary();
summary = new GameSummary( context );
summary.nMoves = cursor.getInt(cursor.
getColumnIndex(DBHelper.NUM_MOVES));
summary.nPlayers =
@ -223,7 +223,7 @@ public class DBUtils {
values.put( DBHelper.TURN, summary.turn );
values.put( DBHelper.GIFLAGS, summary.giflags() );
values.put( DBHelper.PLAYERS,
summary.summarizePlayers(context) );
summary.summarizePlayers() );
values.put( DBHelper.DICTLANG, summary.dictLang );
values.put( DBHelper.GAME_OVER, summary.gameOver );

View file

@ -377,6 +377,9 @@ public class DictsActivity extends ExpandableListActivity
|| ! GameUtils.haveWriteableSD() ) {
menu.removeItem( R.id.dicts_item_move );
}
String fmt = getString(R.string.game_item_menu_titlef );
menu.setHeaderTitle( String.format( fmt, row.getText() ) );
}
}

View file

@ -118,7 +118,7 @@ public class GameListAdapter extends XWListAdapter {
} else {
//Assert.assertNotNull( summary );
String state = summary.summarizeState( m_context );
String state = summary.summarizeState();
TextView view = (TextView)layout.findViewById( R.id.game_name );
if ( hideTitle ) {
@ -134,7 +134,7 @@ public class GameListAdapter extends XWListAdapter {
summary.dictLang );
break;
case R.string.game_summary_field_opponents:
value = "vs Kati +2";
value = summary.playerNames();
break;
case R.string.game_summary_field_state:
value = state;
@ -168,7 +168,7 @@ public class GameListAdapter extends XWListAdapter {
View tmp = m_factory.inflate( R.layout.player_list_elem,
null );
view = (TextView)tmp.findViewById( R.id.item_name );
view.setText( summary.summarizePlayer( m_context, ii ) );
view.setText( summary.summarizePlayer( ii ) );
view = (TextView)tmp.findViewById( R.id.item_score );
view.setText( String.format( " %d", summary.scores[ii] ) );
if ( summary.isNextToPlay( ii ) ) {
@ -200,7 +200,7 @@ public class GameListAdapter extends XWListAdapter {
marker.setImageResource( iconID );
view = (TextView)layout.findViewById( R.id.role );
String roleSummary = summary.summarizeRole( m_context );
String roleSummary = summary.summarizeRole();
if ( null != roleSummary ) {
view.setText( roleSummary );
} else {

View file

@ -258,7 +258,7 @@ public class GameUtils {
int gamePtr, CurGameInfo gi,
FeedUtilsImpl feedImpl )
{
GameSummary summary = new GameSummary( gi );
GameSummary summary = new GameSummary( context, gi );
XwJNI.game_summarize( gamePtr, summary );
if ( null != feedImpl ) {
@ -990,7 +990,7 @@ public class GameUtils {
saveGame( context, gamePtr, gi, lock, false );
GameSummary summary = new GameSummary( gi );
GameSummary summary = new GameSummary( context, gi );
XwJNI.game_summarize( gamePtr, summary );
DBUtils.saveSummary( context, lock, summary );

View file

@ -21,6 +21,7 @@
package org.eehouse.android.xw4.jni;
import android.content.Context;
import android.text.TextUtils;
import junit.framework.Assert;
import org.eehouse.android.xw4.R;
import org.eehouse.android.xw4.Utils;
@ -59,14 +60,16 @@ public class GameSummary {
private int m_giFlags;
private String m_playersSummary;
private CurGameInfo m_gi;
private Context m_context;
public GameSummary(){
public GameSummary( Context context ) {
m_context = context;
pendingMsgLevel = 0;
}
public GameSummary( CurGameInfo gi )
public GameSummary( Context context, CurGameInfo gi )
{
this();
this( context );
nPlayers = gi.nPlayers;
dictLang = gi.dictLang;
serverRole = gi.serverRole;
@ -78,28 +81,17 @@ public class GameSummary {
return null != relayID;
}
public String summarizePlayers( Context context )
public String summarizePlayers()
{
String result;
if ( null == m_gi ) {
result = m_playersSummary;
} else {
StringBuffer sb = new StringBuffer();
for ( int ii = 0; ; ) {
int score = 0;
try {
// scores can be null, but I've seen array OOB too.
score = scores[ii];
} catch ( Exception ex ){}
sb.append( m_gi.players[ii].name );
if ( ++ii >= nPlayers ) {
break;
String[] names = new String[nPlayers];
for ( int ii = 0; ii < nPlayers; ++ii ) {
names[ii] = m_gi.players[ii].name;
}
sb.append( "\n" );
}
result = sb.toString();
result = TextUtils.join( "\n", names );
m_playersSummary = result;
}
return result;
@ -110,25 +102,25 @@ public class GameSummary {
m_playersSummary = summary;
}
public String summarizeState( Context context )
public String summarizeState()
{
String result = null;
if ( gameOver ) {
result = context.getString( R.string.gameOver );
result = m_context.getString( R.string.gameOver );
} else {
result = String.format( context.getString(R.string.movesf),
result = String.format( m_context.getString(R.string.movesf),
nMoves );
}
return result;
}
public String summarizeRole( Context context )
public String summarizeRole()
{
String result = null;
if ( isRelayGame() ) {
Assert.assertTrue( CommsAddrRec.CommsConnType.COMMS_CONN_RELAY
== conType );
String fmt = context.getString( R.string.summary_fmt_relay );
String fmt = m_context.getString( R.string.summary_fmt_relay );
result = String.format( fmt, roomName );
}
return result;
@ -175,14 +167,14 @@ public class GameSummary {
m_giFlags = flags;
}
public String summarizePlayer( Context context, int indx )
public String summarizePlayer( int indx )
{
String player = players[indx];
int formatID = 0;
if ( !isLocal(indx) ) {
boolean isMissing = 0 != ((1 << indx) & missingPlayers);
if ( isMissing ) {
player = context.getString( R.string.missing_player );
player = m_context.getString( R.string.missing_player );
} else {
formatID = R.string.str_nonlocal_namef;
}
@ -191,12 +183,30 @@ public class GameSummary {
}
if ( 0 != formatID ) {
String format = context.getString( formatID );
String format = m_context.getString( formatID );
player = String.format( format, player );
}
return player;
}
public String playerNames()
{
String[] names = null;
if ( null != m_gi ) {
names = m_gi.visibleNames();
} else if ( null != m_playersSummary ) {
names = TextUtils.split( m_playersSummary, "\n" );
}
String result = null;
if ( null != names && 0 < names.length ) {
String joiner = m_context.getString( R.string.vs_join );
result = TextUtils.join( joiner, names );
}
return result;
}
public boolean isNextToPlay( int indx ) {
return indx == turn && isLocal(indx);
}

View file

@ -264,7 +264,7 @@ public class JNIThread extends Thread {
XwJNI.server_do( m_jniGamePtr );
XwJNI.game_getGi( m_jniGamePtr, m_gi );
GameSummary summary = new GameSummary( m_gi );
GameSummary summary = new GameSummary( m_context, m_gi );
XwJNI.game_summarize( m_jniGamePtr, summary );
byte[] state = XwJNI.game_saveToStream( m_jniGamePtr, null );
GameUtils.saveGame( m_context, state, m_lock, false );