Merge remote branch 'origin/android_branch' into android_branch

This commit is contained in:
Eric House 2013-10-09 20:09:31 -07:00
commit 6cbfc03228
11 changed files with 76 additions and 31 deletions

View file

@ -6,6 +6,7 @@
<!-- title set in BoardActivity -->
<item android:id="@+id/board_menu_done"
android:alphabeticShortcut="D"
android:showAsAction="ifRoom"
/>
<item android:id="@+id/board_menu_trade"
android:title="@string/board_menu_trade"
@ -21,7 +22,8 @@
<item android:id="@+id/board_menu_tray"
/>
<item android:title="@string/board_submenu_game">
<item android:id="@+id/board_submenu_game"
android:title="@string/board_submenu_game">
<menu>
<item android:id="@+id/board_menu_game_counts"
android:title="@string/board_menu_game_counts" />

View file

@ -125,7 +125,7 @@
<CheckBoxPreference android:key="@string/key_hide_title"
android:title="@string/hide_title"
android:summary="@string/hide_title_summary"
android:defaultValue="true"
android:defaultValue="false"
/>
<CheckBoxPreference android:key="@string/key_show_arrow"
android:title="@string/show_arrow"

View file

@ -738,15 +738,22 @@ public class BoardActivity extends XWActivity
item.setTitle( strId );
}
Utils.setItemVisible( menu, R.id.board_menu_undo_last, !inTrade );
Utils.setItemVisible( menu, R.id.board_menu_tray, !inTrade );
Utils.setItemVisible( menu, R.id.board_submenu_game, !inTrade );
if ( !inTrade ) {
boolean enabled = null == m_gsi || m_gsi.curTurnSelected;
item = menu.findItem( R.id.board_menu_done );
if ( 0 >= m_view.curPending() ) {
strId = R.string.board_menu_pass;
} else {
strId = R.string.board_menu_done;
item.setVisible( enabled );
if ( enabled ) {
if ( 0 >= m_view.curPending() ) {
strId = R.string.board_menu_pass;
} else {
strId = R.string.board_menu_done;
}
item.setTitle( strId );
}
item.setTitle( strId );
item.setEnabled( null == m_gsi || m_gsi.curTurnSelected );
}
if ( m_gameOver || DBUtils.gameOver( this, m_rowid ) ) {
@ -772,8 +779,15 @@ public class BoardActivity extends XWActivity
int id = item.getItemId();
switch ( id ) {
case R.id.board_menu_done:
showNotAgainDlgThen( R.string.not_again_done,
R.string.key_notagain_done, COMMIT_ACTION );
int nTiles = XwJNI.model_getNumTilesInTray( m_jniGamePtr,
m_view.getCurPlayer() );
DbgUtils.logf( "getNumTilesInTray=>%d", nTiles );
if ( XWApp.MAX_TRAY_TILES > nTiles ) {
showNotAgainDlgThen( R.string.not_again_done,
R.string.key_notagain_done, COMMIT_ACTION );
} else {
dlgButtonClicked( COMMIT_ACTION, AlertDialog.BUTTON_POSITIVE );
}
break;
case R.id.board_menu_trade_commit:
@ -1789,6 +1803,8 @@ public class BoardActivity extends XWActivity
m_view.setInTrade( m_inTrade );
}
adjustTradeVisibility();
Activity self = BoardActivity.this;
Utils.invalidateOptionsMenuIf( self );
}
break;
case JNIThread.GOT_WORDS:

View file

@ -24,7 +24,6 @@ import android.content.Context;
import android.graphics.Canvas;
import android.os.AsyncTask;
import android.os.Handler;
// import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageButton;
@ -34,7 +33,6 @@ import android.widget.TextView;
import java.text.DateFormat;
import java.util.Date;
import java.util.HashSet;
// import java.util.Iterator;
import org.eehouse.android.xw4.jni.GameSummary;
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
@ -205,7 +203,7 @@ public class GameListItem extends LinearLayout
private void setData( final GameSummary summary )
{
if ( null != summary ) {
TextView view;
TextView tview;
String state = setName();
setOnClickListener( new View.OnClickListener() {
@ -224,10 +222,10 @@ public class GameListItem extends LinearLayout
for ( int ii = 0; ii < summary.nPlayers; ++ii ) {
ExpiringLinearLayout tmp = (ExpiringLinearLayout)
Utils.inflate( m_context, R.layout.player_list_elem );
view = (TextView)tmp.findViewById( R.id.item_name );
view.setText( summary.summarizePlayer( ii ) );
view = (TextView)tmp.findViewById( R.id.item_score );
view.setText( String.format( " %d", summary.scores[ii] ) );
tview = (TextView)tmp.findViewById( R.id.item_name );
tview.setText( summary.summarizePlayer( ii ) );
tview = (TextView)tmp.findViewById( R.id.item_score );
tview.setText( String.format( " %d", summary.scores[ii] ) );
boolean thisHasTurn = summary.isNextToPlay( ii, isLocal );
if ( thisHasTurn ) {
haveATurn = true;
@ -240,15 +238,15 @@ public class GameListItem extends LinearLayout
list.addView( tmp, ii );
}
view = (TextView)findViewById( R.id.state );
view.setText( state );
view = (TextView)findViewById( R.id.modtime );
tview = (TextView)findViewById( R.id.state );
tview.setText( state );
tview = (TextView)findViewById( R.id.modtime );
long lastMoveTime = summary.lastMoveTime;
lastMoveTime *= 1000;
DateFormat df = DateFormat.getDateTimeInstance( DateFormat.SHORT,
DateFormat.SHORT );
view.setText( df.format( new Date( lastMoveTime ) ) );
tview.setText( df.format( new Date( lastMoveTime ) ) );
int iconID;
ImageView marker =
@ -265,12 +263,12 @@ public class GameListItem extends LinearLayout
}
marker.setImageResource( iconID );
view = (TextView)findViewById( R.id.role );
tview = (TextView)findViewById( R.id.role );
String roleSummary = summary.summarizeRole();
if ( null != roleSummary ) {
view.setText( roleSummary );
tview.setText( roleSummary );
} else {
view.setVisibility( View.GONE );
tview.setVisibility( View.GONE );
}
boolean expanded = DBUtils.getExpanded( m_context, m_rowid );

View file

@ -72,6 +72,24 @@ public class Utils {
private static Boolean s_hasSmallScreen = null;
private static Random s_random = new Random();
private static interface SafeInvalOptionsMenu {
public void doInval( Activity activity );
}
private static class SafeInvalOptionsMenuImpl
implements SafeInvalOptionsMenu {
public void doInval( Activity activity ) {
activity.invalidateOptionsMenu();
}
}
private static SafeInvalOptionsMenu s_safeInval = null;
static {
int sdkVersion = Integer.valueOf( android.os.Build.VERSION.SDK );
if ( 11 <= sdkVersion ) {
s_safeInval = new SafeInvalOptionsMenuImpl();
}
}
private Utils() {}
public static int nextRandomInt()
@ -358,6 +376,13 @@ public class Utils {
item.setEnabled( enabled );
}
public static void invalidateOptionsMenuIf( Activity activity )
{
if ( null != s_safeInval ) {
s_safeInval.doInval( activity );
}
}
public static boolean hasSmallScreen( Context context )
{
if ( null == s_hasSmallScreen ) {

View file

@ -40,6 +40,7 @@ public class XWApp extends Application {
public static final boolean UDP_ENABLED = true;
public static final String SMS_PUBLIC_HEADER = "-XW4";
public static final int MAX_TRAY_TILES = 7; // comtypes.h
private static UUID s_UUID = null;
private static Boolean s_onEmulator = null;

View file

@ -78,7 +78,7 @@ XLOC_HEADER:0x8C00
1 10 {"L·L|L-L|ĿL|l·l|l-l|ŀl"}
3 2 'M|m'
6 1 'N|n'
1 10 {"ny|ny"}
1 10 {"NY|ny"}
5 1 'O|o'
2 3 'P|p'
1 8 {"QU|qu"}

View file

@ -25,7 +25,9 @@ byodfiles.tar:
rm -f $@ langinfo
tar cvf $@ ./dict2dawg.cpp ./par.pl ./xloc.pl ./xloc.pm
for dir in $$(ls .); do \
if [ -f $$dir/info.txt ] && [ -f $$dir/Makefile ]; then \
if [ $$dir = "Hëx" ]; then \
:; \
elif [ -f $$dir/info.txt ] && [ -f $$dir/Makefile ]; then \
mkdir -p langinfo/$$dir; \
(cd $$dir; make TARGET_TYPE=PALM table.bin values.bin palmvalues.bin); \
(cd $$dir; make TARGET_TYPE=FRANK frankspecials.bin); \

View file

@ -163,7 +163,7 @@ sub TileFace($) {
my $str = ${$tileR}[2];
if ( $str =~ /\'(.)\'/ ) {
if ( $str =~ /\'(.(\|.)*)\'/ ) {
return $1;
} elsif ( $str =~ /\"(.+)\"/ ) {
return $1;

View file

@ -118,7 +118,7 @@ summarize( CommonGlobals* cGlobals )
XP_S16 nMoves = model_getNMoves( cGlobals->game.model );
XP_Bool gameOver = server_getGameIsOver( cGlobals->game.server );
XP_S16 turn = server_getCurrentTurn( cGlobals->game.server );
XP_U16 seed = comms_getChannelSeed( cGlobals->game.comms );
XP_U16 seed = 0;
XP_S16 nMissing = 0;
CommsAddrRec addr = {0};
gchar* room = "";
@ -129,6 +129,7 @@ summarize( CommonGlobals* cGlobals )
if ( COMMS_CONN_RELAY == addr.conType ) {
room = addr.u.ip_relay.invite;
}
seed = comms_getChannelSeed( cGlobals->game.comms );
}
const char* fmt = "UPDATE games "

View file

@ -333,9 +333,9 @@ hostNameToIP( const XP_UCHAR* name )
static ssize_t
sendIt( RelayConStorage* storage, const XP_U8* msgbuf, XP_U16 len )
{
ssize_t nSent = sendto( storage->socket, msgbuf, len, 0, /* flags */
(struct sockaddr*)&storage->saddr,
sizeof(storage->saddr) );
ssize_t nSent = sendto( storage->socket, msgbuf, len, 0, /* flags */
(struct sockaddr*)&storage->saddr,
sizeof(storage->saddr) );
XP_LOGF( "%s()=>%d", __func__, nSent );
return nSent;
}