Merge branch 'android_branch' into android_nfc

This commit is contained in:
Eric House 2013-11-12 18:39:31 -08:00
commit e63e5b6102
9 changed files with 99 additions and 73 deletions

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="120"
height="120" xml:space="preserve">
<g
id="g12"
transform="matrix(1.25,0,0,-1.25,0,120)">
<g transform='translate(20.24,20.6)' id='g1090'>
<path style='fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none' d='M 0,0 5.287,24.92 38.6,27.24 38.6,27.57 5.287,29.89 0,54.81 55.52,27.4 0,0 z' id='path1092'/>
</g></g>
</svg>

After

Width:  |  Height:  |  Size: 584 B

View file

@ -4,10 +4,18 @@
<group android:id="@+id/group_done"> <group android:id="@+id/group_done">
<!-- title set in BoardActivity --> <!-- title set in BoardActivity -->
<item android:id="@+id/board_menu_invite"
android:title="@string/board_menu_invite"
android:showAsAction="ifRoom"
android:icon="@drawable/send__gen"
/>
<item android:id="@+id/board_menu_done" <item android:id="@+id/board_menu_done"
android:alphabeticShortcut="D" android:alphabeticShortcut="D"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:icon="@drawable/save__gen"
/> />
<item android:id="@+id/board_menu_trade" <item android:id="@+id/board_menu_trade"
android:title="@string/board_menu_trade" android:title="@string/board_menu_trade"
android:alphabeticShortcut="T" android:alphabeticShortcut="T"

View file

@ -2168,4 +2168,6 @@
<string name="prefs_thumb">Thumbnails</string> <string name="prefs_thumb">Thumbnails</string>
<string name="prefs_thumb_summary">Setting for game snapshots</string> <string name="prefs_thumb_summary">Setting for game snapshots</string>
<string name="dropped_dupe">Invitation ignored: already used</string> <string name="dropped_dupe">Invitation ignored: already used</string>
<string name="cur_menu_markerf">%1$s (yours)</string>
<string name="board_menu_invite">Invite</string>
</resources> </resources>

View file

@ -744,6 +744,7 @@ public class BoardActivity extends XWActivity
item.setTitle( strId ); item.setTitle( strId );
} }
Utils.setItemVisible( menu, R.id.board_menu_invite, 0 < m_missing );
Utils.setItemVisible( menu, R.id.board_menu_undo_last, !inTrade ); 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_menu_tray, !inTrade );
@ -843,7 +844,9 @@ public class BoardActivity extends XWActivity
case R.id.board_menu_undo_last: case R.id.board_menu_undo_last:
showConfirmThen( R.string.confirm_undo_last, UNDO_LAST_ACTION ); showConfirmThen( R.string.confirm_undo_last, UNDO_LAST_ACTION );
break; break;
case R.id.board_menu_invite:
showDialog( DLG_INVITE );
break;
// small devices only // small devices only
case R.id.board_menu_dict: case R.id.board_menu_dict:
String dictName = m_gi.dictName( m_view.getCurPlayer() ); String dictName = m_gi.dictName( m_view.getCurPlayer() );
@ -1294,6 +1297,7 @@ public class BoardActivity extends XWActivity
m_room = room; m_room = room;
m_missing = nMissing; m_missing = nMissing;
showDialog( DLG_INVITE ); showDialog( DLG_INVITE );
Utils.invalidateOptionsMenuIf( this );
} else { } else {
toastStr = getString( R.string.msg_relay_waiting, devOrder, toastStr = getString( R.string.msg_relay_waiting, devOrder,
room, nMissing ); room, nMissing );

View file

@ -176,6 +176,11 @@ public class BoardCanvas extends Canvas implements DrawCtx {
return m_trayOwner; return m_trayOwner;
} }
public int curPending()
{
return m_pendingScore;
}
public void setInTrade( boolean inTrade ) public void setInTrade( boolean inTrade )
{ {
if ( m_inTrade != inTrade ) { if ( m_inTrade != inTrade ) {
@ -549,7 +554,8 @@ public class BoardCanvas extends Canvas implements DrawCtx {
private boolean drawTileImpl( Rect rect, String text, int val, private boolean drawTileImpl( Rect rect, String text, int val,
int flags, boolean clearBack ) int flags, boolean clearBack )
{ {
boolean drew = true; boolean canDraw = figureFontDims();
if ( canDraw ) {
// boolean valHidden = (flags & CELL_VALHIDDEN) != 0; // boolean valHidden = (flags & CELL_VALHIDDEN) != 0;
boolean notEmpty = (flags & CELL_ISEMPTY) == 0; boolean notEmpty = (flags & CELL_ISEMPTY) == 0;
boolean isCursor = (flags & CELL_ISCURSOR) != 0; boolean isCursor = (flags & CELL_ISCURSOR) != 0;
@ -573,7 +579,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
m_fillPaint.setColor( m_playerColors[m_trayOwner] ); m_fillPaint.setColor( m_playerColors[m_trayOwner] );
if ( notEmpty ) { if ( notEmpty ) {
drew = positionDrawTile( rect, text, val ); positionDrawTile( rect, text, val );
Paint paint = getTileStrokePaint( rect ); Paint paint = getTileStrokePaint( rect );
drawRect( rect, paint ); // frame drawRect( rect, paint ); // frame
@ -585,7 +591,8 @@ public class BoardCanvas extends Canvas implements DrawCtx {
} }
} }
restoreToCount(1); // in case new canvas.... restoreToCount(1); // in case new canvas....
return drew; }
return canDraw;
} // drawTileImpl } // drawTileImpl
private void drawCrosshairs( final Rect rect, final int flags ) private void drawCrosshairs( final Rect rect, final int flags )
@ -662,10 +669,8 @@ public class BoardCanvas extends Canvas implements DrawCtx {
drawBitmap( bitmap, null, rect, m_drawPaint ); drawBitmap( bitmap, null, rect, m_drawPaint );
} }
private boolean positionDrawTile( final Rect rect, String text, int val ) private void positionDrawTile( final Rect rect, String text, int val )
{ {
boolean canDraw = figureFontDims();
if ( canDraw ) {
final int offset = 2; final int offset = 2;
if ( null != text ) { if ( null != text ) {
if ( null == m_letterRect ) { if ( null == m_letterRect ) {
@ -698,8 +703,6 @@ public class BoardCanvas extends Canvas implements DrawCtx {
} }
} }
} }
return canDraw;
}
private void fillRectOther( Rect rect, int index ) private void fillRectOther( Rect rect, int index )
{ {

View file

@ -60,7 +60,6 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
private JNIThread m_jniThread; private JNIThread m_jniThread;
private XWActivity m_parent; private XWActivity m_parent;
private Rect m_boundsScratch; private Rect m_boundsScratch;
private int m_pendingScore;
private boolean m_measuredFromDims = false; private boolean m_measuredFromDims = false;
private BoardDims m_dims; private BoardDims m_dims;
private CommsAddrRec.CommsConnType m_connType = private CommsAddrRec.CommsConnType m_connType =
@ -200,7 +199,6 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
{ {
synchronized( this ) { synchronized( this ) {
if ( layoutBoardOnce() && m_measuredFromDims ) { if ( layoutBoardOnce() && m_measuredFromDims ) {
DbgUtils.logf( "BoardCanvas.onDraw() copying bitmap" );
canvas.drawBitmap( s_bitmap, 0, 0, m_drawPaint ); canvas.drawBitmap( s_bitmap, 0, 0, m_drawPaint );
ConnStatusHandler.draw( m_context, canvas, getResources(), ConnStatusHandler.draw( m_context, canvas, getResources(),
0, 0, m_connType ); 0, 0, m_connType );
@ -212,7 +210,6 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
private boolean layoutBoardOnce() private boolean layoutBoardOnce()
{ {
DbgUtils.logf( "layoutBoardOnce()" );
final int width = getWidth(); final int width = getWidth();
final int height = getHeight(); final int height = getHeight();
boolean layoutDone = width == m_layoutWidth && height == m_layoutHeight; boolean layoutDone = width == m_layoutWidth && height == m_layoutHeight;
@ -244,13 +241,10 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
} }
if ( null == s_bitmap ) { if ( null == s_bitmap ) {
DbgUtils.logf( "making %dx%d static bitmap", bmWidth, bmHeight );
s_bitmap = Bitmap.createBitmap( bmWidth, bmHeight, s_bitmap = Bitmap.createBitmap( bmWidth, bmHeight,
Bitmap.Config.ARGB_8888 ); Bitmap.Config.ARGB_8888 );
} }
if ( null == m_canvas ) { if ( null == m_canvas ) {
DbgUtils.logf( "layoutBoardOnce: allocating canvas for %d, %d",
bmWidth, bmHeight );
m_canvas = new BoardCanvas( m_parent, s_bitmap, m_jniThread, m_canvas = new BoardCanvas( m_parent, s_bitmap, m_jniThread,
m_dims ); m_dims );
} else { } else {
@ -264,7 +258,6 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
m_layoutHeight = height; m_layoutHeight = height;
layoutDone = true; layoutDone = true;
} }
DbgUtils.logf( "layoutBoardOnce()=>%b", layoutDone );
return layoutDone; return layoutDone;
} // layoutBoardOnce } // layoutBoardOnce
@ -337,7 +330,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
public int curPending() public int curPending()
{ {
return m_pendingScore; return null == m_canvas? 0 : m_canvas.curPending();
} }
private int getSpacing( MotionEvent event ) private int getSpacing( MotionEvent event )

View file

@ -256,7 +256,7 @@ public class DBUtils {
db.close(); db.close();
} }
if ( null == summary ) { if ( null == summary && lock.canWrite() ) {
summary = GameUtils.summarize( context, lock ); summary = GameUtils.summarize( context, lock );
saveSummary( context, lock, summary ); saveSummary( context, lock, summary );
} }

View file

@ -873,7 +873,9 @@ public class DictsActivity extends XWExpandableListActivity
.setOnMenuItemClickListener( listener ); .setOnMenuItemClickListener( listener );
// Add at top but save until have dal info // Add at top but save until have dal info
MenuItem curItem = menu.add( curDict ); MenuItem curItem =
menu.add( context.getString( R.string.cur_menu_markerf,
curDict ) );
DictAndLoc[] dals = DictUtils.dictList( context ); DictAndLoc[] dals = DictUtils.dictList( context );
for ( DictAndLoc dal : dals ) { for ( DictAndLoc dal : dals ) {

View file

@ -193,10 +193,13 @@ public class GameUtils {
public static GameSummary summarize( Context context, GameLock lock ) public static GameSummary summarize( Context context, GameLock lock )
{ {
GameSummary result = null;
CurGameInfo gi = new CurGameInfo( context ); CurGameInfo gi = new CurGameInfo( context );
int gamePtr = loadMakeGame( context, gi, lock ); int gamePtr = loadMakeGame( context, gi, lock );
if ( 0 < gamePtr ) {
return summarizeAndClose( context, lock, gamePtr, gi ); result = summarizeAndClose( context, lock, gamePtr, gi );
}
return result;
} }
public static long dupeGame( Context context, long rowidIn ) public static long dupeGame( Context context, long rowidIn )