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,43 +554,45 @@ 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();
// boolean valHidden = (flags & CELL_VALHIDDEN) != 0; if ( canDraw ) {
boolean notEmpty = (flags & CELL_ISEMPTY) == 0; // boolean valHidden = (flags & CELL_VALHIDDEN) != 0;
boolean isCursor = (flags & CELL_ISCURSOR) != 0; boolean notEmpty = (flags & CELL_ISEMPTY) == 0;
boolean isCursor = (flags & CELL_ISCURSOR) != 0;
save( Canvas.CLIP_SAVE_FLAG ); save( Canvas.CLIP_SAVE_FLAG );
rect.top += 1; rect.top += 1;
clipRect( rect ); clipRect( rect );
if ( clearBack ) { if ( clearBack ) {
fillRectOther( rect, CommonPrefs.COLOR_BACKGRND ); fillRectOther( rect, CommonPrefs.COLOR_BACKGRND );
}
if ( isCursor || notEmpty ) {
int color = m_otherColors[isCursor? CommonPrefs.COLOR_FOCUS
: CommonPrefs.COLOR_TILE_BACK];
if ( !clearBack ) {
color &= 0x7FFFFFFF; // translucent if being dragged.
} }
fillRect( rect, color );
m_fillPaint.setColor( m_playerColors[m_trayOwner] ); if ( isCursor || notEmpty ) {
int color = m_otherColors[isCursor? CommonPrefs.COLOR_FOCUS
: CommonPrefs.COLOR_TILE_BACK];
if ( !clearBack ) {
color &= 0x7FFFFFFF; // translucent if being dragged.
}
fillRect( rect, color );
if ( notEmpty ) { m_fillPaint.setColor( m_playerColors[m_trayOwner] );
drew = positionDrawTile( rect, text, val );
Paint paint = getTileStrokePaint( rect ); if ( notEmpty ) {
drawRect( rect, paint ); // frame positionDrawTile( rect, text, val );
if ( 0 != (flags & CELL_HIGHLIGHT) ) {
int width = (int)paint.getStrokeWidth(); Paint paint = getTileStrokePaint( rect );
rect.inset( width, width );
drawRect( rect, paint ); // frame drawRect( rect, paint ); // frame
if ( 0 != (flags & CELL_HIGHLIGHT) ) {
int width = (int)paint.getStrokeWidth();
rect.inset( width, width );
drawRect( rect, paint ); // frame
}
} }
} }
restoreToCount(1); // in case new canvas....
} }
restoreToCount(1); // in case new canvas.... return canDraw;
return drew;
} // drawTileImpl } // drawTileImpl
private void drawCrosshairs( final Rect rect, final int flags ) private void drawCrosshairs( final Rect rect, final int flags )
@ -662,43 +669,39 @@ 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(); final int offset = 2;
if ( canDraw ) { if ( null != text ) {
final int offset = 2; if ( null == m_letterRect ) {
if ( null != text ) { m_letterRect = new Rect( 0, 0, rect.width() - offset,
if ( null == m_letterRect ) { rect.height() * 3 / 4 );
m_letterRect = new Rect( 0, 0, rect.width() - offset,
rect.height() * 3 / 4 );
}
m_letterRect.offsetTo( rect.left + offset, rect.top + offset );
drawIn( text, m_letterRect, m_fontDims, Paint.Align.LEFT );
if ( FRAME_TRAY_RECTS ) {
drawRect( m_letterRect, m_strokePaint );
}
} }
m_letterRect.offsetTo( rect.left + offset, rect.top + offset );
if ( val >= 0 ) { drawIn( text, m_letterRect, m_fontDims, Paint.Align.LEFT );
int divisor = m_hasSmallScreen ? 3 : 4; if ( FRAME_TRAY_RECTS ) {
if ( null == m_valRect ) { drawRect( m_letterRect, m_strokePaint );
m_valRect = new Rect( 0, 0, rect.width() / divisor, }
rect.height() / divisor ); }
m_valRect.inset( offset, offset );
} if ( val >= 0 ) {
m_valRect.offsetTo( rect.right - (rect.width() / divisor), int divisor = m_hasSmallScreen ? 3 : 4;
rect.bottom - (rect.height() / divisor) ); if ( null == m_valRect ) {
text = String.format( "%d", val ); m_valRect = new Rect( 0, 0, rect.width() / divisor,
m_fillPaint.setTextSize( m_valRect.height() ); rect.height() / divisor );
m_fillPaint.setTextAlign( Paint.Align.RIGHT ); m_valRect.inset( offset, offset );
drawText( text, m_valRect.right, m_valRect.bottom, }
m_fillPaint ); m_valRect.offsetTo( rect.right - (rect.width() / divisor),
if ( FRAME_TRAY_RECTS ) { rect.bottom - (rect.height() / divisor) );
drawRect( m_valRect, m_strokePaint ); text = String.format( "%d", val );
} m_fillPaint.setTextSize( m_valRect.height() );
m_fillPaint.setTextAlign( Paint.Align.RIGHT );
drawText( text, m_valRect.right, m_valRect.bottom,
m_fillPaint );
if ( FRAME_TRAY_RECTS ) {
drawRect( m_valRect, m_strokePaint );
} }
} }
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 )