diff --git a/xwords4/android/XWords4/img_src/send.svg b/xwords4/android/XWords4/img_src/send.svg new file mode 100644 index 000000000..1488968ee --- /dev/null +++ b/xwords4/android/XWords4/img_src/send.svg @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/xwords4/android/XWords4/res/menu/board_menu.xml b/xwords4/android/XWords4/res/menu/board_menu.xml index 9c1093c7c..9bc13f55f 100644 --- a/xwords4/android/XWords4/res/menu/board_menu.xml +++ b/xwords4/android/XWords4/res/menu/board_menu.xml @@ -4,10 +4,18 @@ + + + Thumbnails Setting for game snapshots Invitation ignored: already used + %1$s (yours) + Invite diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java index eb860b9cf..3470dca87 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java @@ -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 ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardCanvas.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardCanvas.java index eeb509387..faf80aee5 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardCanvas.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardCanvas.java @@ -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 ) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java index 6c570e67f..a4dac1b38 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java @@ -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 ) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java index 4a4b32ca7..e77420fae 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java @@ -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 ); } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java index 0c3dc9e70..c2bf31dc0 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java @@ -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 ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java index 59e482470..b6e3606cb 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java @@ -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 )