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">
<!-- 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"
android:alphabeticShortcut="D"
android:showAsAction="ifRoom"
android:icon="@drawable/save__gen"
/>
<item android:id="@+id/board_menu_trade"
android:title="@string/board_menu_trade"
android:alphabeticShortcut="T"

View file

@ -2168,4 +2168,6 @@
<string name="prefs_thumb">Thumbnails</string>
<string name="prefs_thumb_summary">Setting for game snapshots</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>

View file

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

View file

@ -176,6 +176,11 @@ public class BoardCanvas extends Canvas implements DrawCtx {
return m_trayOwner;
}
public int curPending()
{
return m_pendingScore;
}
public void setInTrade( boolean 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,
int flags, boolean clearBack )
{
boolean drew = true;
// boolean valHidden = (flags & CELL_VALHIDDEN) != 0;
boolean notEmpty = (flags & CELL_ISEMPTY) == 0;
boolean isCursor = (flags & CELL_ISCURSOR) != 0;
boolean canDraw = figureFontDims();
if ( canDraw ) {
// boolean valHidden = (flags & CELL_VALHIDDEN) != 0;
boolean notEmpty = (flags & CELL_ISEMPTY) == 0;
boolean isCursor = (flags & CELL_ISCURSOR) != 0;
save( Canvas.CLIP_SAVE_FLAG );
rect.top += 1;
clipRect( rect );
save( Canvas.CLIP_SAVE_FLAG );
rect.top += 1;
clipRect( rect );
if ( clearBack ) {
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.
if ( clearBack ) {
fillRectOther( rect, CommonPrefs.COLOR_BACKGRND );
}
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 ) {
drew = positionDrawTile( rect, text, val );
m_fillPaint.setColor( m_playerColors[m_trayOwner] );
Paint paint = getTileStrokePaint( rect );
drawRect( rect, paint ); // frame
if ( 0 != (flags & CELL_HIGHLIGHT) ) {
int width = (int)paint.getStrokeWidth();
rect.inset( width, width );
if ( notEmpty ) {
positionDrawTile( rect, text, val );
Paint paint = getTileStrokePaint( rect );
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 drew;
return canDraw;
} // drawTileImpl
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 );
}
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;
if ( null != text ) {
if ( null == m_letterRect ) {
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 );
}
final int offset = 2;
if ( null != text ) {
if ( null == m_letterRect ) {
m_letterRect = new Rect( 0, 0, rect.width() - offset,
rect.height() * 3 / 4 );
}
if ( val >= 0 ) {
int divisor = m_hasSmallScreen ? 3 : 4;
if ( null == m_valRect ) {
m_valRect = new Rect( 0, 0, rect.width() / divisor,
rect.height() / divisor );
m_valRect.inset( offset, offset );
}
m_valRect.offsetTo( rect.right - (rect.width() / divisor),
rect.bottom - (rect.height() / divisor) );
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 );
}
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 );
}
}
if ( val >= 0 ) {
int divisor = m_hasSmallScreen ? 3 : 4;
if ( null == m_valRect ) {
m_valRect = new Rect( 0, 0, rect.width() / divisor,
rect.height() / divisor );
m_valRect.inset( offset, offset );
}
m_valRect.offsetTo( rect.right - (rect.width() / divisor),
rect.bottom - (rect.height() / divisor) );
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 )

View file

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

View file

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

View file

@ -873,7 +873,9 @@ public class DictsActivity extends XWExpandableListActivity
.setOnMenuItemClickListener( listener );
// 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 );
for ( DictAndLoc dal : dals ) {

View file

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