From 00102ec20a16e3c3359d823fe7efcfbb6857a3a6 Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 30 May 2012 22:16:43 -0700 Subject: [PATCH 01/19] include stylesheet in generated index.html --- xwords4/dawg/mkindex.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xwords4/dawg/mkindex.sh b/xwords4/dawg/mkindex.sh index 64badff9f..19696db00 100755 --- a/xwords4/dawg/mkindex.sh +++ b/xwords4/dawg/mkindex.sh @@ -55,7 +55,13 @@ for DIR in $(ls); do done -echo "" +cat < + + + + +EOF echo "

Download dictionaries for:" for DIR in $DIRS; do From d7f576d6b7eff06975eeff5941cf4fee13ada687 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 5 Jun 2012 07:38:58 -0700 Subject: [PATCH 02/19] fix board dimensioning for small (needs-scrolling) screens. Since this effects larger screens needs some testing. --- .../org/eehouse/android/xw4/BoardView.java | 45 +++++++++++++------ .../eehouse/android/xw4/jni/JNIThread.java | 8 +++- 2 files changed, 37 insertions(+), 16 deletions(-) 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 366bace3c..f41929e8d 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java @@ -256,24 +256,41 @@ public class BoardView extends View implements DrawCtx, BoardHandler, } result.maxCellSize = maxCellSize; - result.trayHt = cellSize * 3; - result.scoreHt = 2 * m_defaultFontHt; - int wantHt = result.trayHt + result.scoreHt + (cellSize * nCells); - int nToScroll = 0; + // Now determine if vertical scrolling will be necessary. + // There's a minimum tray and scoreboard height. If we can + // fit them and all cells no scrolling's needed. Otherwise + // determine the minimum number that must be hidden to fit. + // Finally grow scoreboard and tray to use whatever's left. + int trayHt = (5 * cellSize) / 2; + int scoreHt = (cellSize * 3) / 2; + int wantHt = trayHt + scoreHt + (cellSize * nCells); + int nToScroll; if ( wantHt <= height ) { - result.top = (height - wantHt) / 2; + nToScroll = 0; } else { - int minTray = 3 * m_defaultFontHt; - nToScroll = - nCells - ((height - minTray - result.scoreHt) / cellSize); - result.trayHt = - height - result.scoreHt - (cellSize * (nCells-nToScroll)); - result.top = 0; + nToScroll = nCells - ((height - trayHt - scoreHt) / cellSize); } - result.boardHt = cellSize * (nCells-nToScroll); - result.trayTop = result.scoreHt + result.boardHt; - result.height = result.scoreHt + result.boardHt + result.trayHt; + int heightUsed = trayHt + scoreHt + (nCells - nToScroll) * cellSize; + int heightLeft = height - heightUsed; + if ( 0 < heightLeft ) { + if ( heightLeft > (cellSize * 3 / 2) ) { + heightLeft = cellSize * 3 / 2; + } + heightLeft /= 3; + trayHt += heightLeft * 2; + scoreHt += heightLeft; + } + heightUsed = trayHt + scoreHt + ((nCells - nToScroll) * cellSize); + heightLeft = height - heightUsed; + result.top = heightLeft / 2; + + result.trayHt = trayHt; + result.scoreHt = scoreHt; + + result.boardHt = cellSize * nCells; + result.trayTop = scoreHt + (cellSize * (nCells-nToScroll)); + result.height = heightUsed; result.cellSize = cellSize; if ( gi.timerEnabled ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java index 50c1a9f8f..c5a13473e 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java @@ -233,12 +233,16 @@ public class JNIThread extends Thread { XwJNI.board_setScoreboardLoc( m_jniGamePtr, 0, 0, scoreWidth, dims.scoreHt, true ); + // Have no idea why I was doing -1 below, but it breaks layout + // for small (QVGA) boards. If it needs to be done, do it + // early in figureBoardDims so the calculations that follow + // are consistent. XwJNI.board_setPos( m_jniGamePtr, 0, dims.scoreHt, - dims.width-1, dims.boardHt, dims.maxCellSize, + dims.width/*-1*/, dims.boardHt, dims.maxCellSize, false ); XwJNI.board_setTrayLoc( m_jniGamePtr, 0, dims.trayTop, - dims.width-1, dims.trayHt, kMinDivWidth ); + dims.width/*-1*/, dims.trayHt, kMinDivWidth ); XwJNI.board_invalAll( m_jniGamePtr ); } From 1e9928e7f3eba609bbf8cb97546b9297d555b39d Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 5 Jun 2012 07:41:00 -0700 Subject: [PATCH 03/19] add commented-out toString() for debugging --- .../src/org/eehouse/android/xw4/BoardDims.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDims.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDims.java index f04c1fe58..4a113609d 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDims.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDims.java @@ -30,4 +30,18 @@ public class BoardDims { public int trayTop, trayHt; public int cellSize, maxCellSize; public int timerWidth; + + // public String toString() + // { + // return "width: " + width + // + " height: " + height + // + " left: " + left + // + " top: " + top + // + " scoreHt: " + scoreHt + // + " boardHt: " + boardHt + // + " trayTop: " + trayTop + // + " trayHt: " + trayHt + // + " cellSize: " + cellSize + // + " maxCellSize: " + maxCellSize; + // } } From b78ea03ea691953ea063a8983cab89257807eb95 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 5 Jun 2012 07:42:39 -0700 Subject: [PATCH 04/19] add board layout for small case that doesn't include toolbar or exchange-state buttons, and check for presence of Views that may now be missing. With this checkin small screen devices don't have access to toolbar functionality -- new and expanded menu will be required for them. --- .../XWords4/res/layout-small/board.xml | 20 +++++++++++++++++++ .../eehouse/android/xw4/BoardActivity.java | 14 +++++++++---- .../src/org/eehouse/android/xw4/Toolbar.java | 12 ++++++++--- 3 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 xwords4/android/XWords4/res/layout-small/board.xml diff --git a/xwords4/android/XWords4/res/layout-small/board.xml b/xwords4/android/XWords4/res/layout-small/board.xml new file mode 100644 index 000000000..610c8df8f --- /dev/null +++ b/xwords4/android/XWords4/res/layout-small/board.xml @@ -0,0 +1,20 @@ + + + + + + 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 af1ffbdf9..a4765c162 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java @@ -457,9 +457,13 @@ public class BoardActivity extends XWActivity m_view = (BoardView)findViewById( R.id.board_view ); m_tradeButtons = findViewById( R.id.exchange_buttons ); m_exchCommmitButton = (Button)findViewById( R.id.exchange_commit ); - m_exchCommmitButton.setOnClickListener( this ); + if ( null != m_exchCommmitButton ) { + m_exchCommmitButton.setOnClickListener( this ); + } m_exchCancelButton = (Button)findViewById( R.id.exchange_cancel ); - m_exchCancelButton.setOnClickListener( this ); + if ( null != m_exchCancelButton ) { + m_exchCancelButton.setOnClickListener( this ); + } m_volKeysZoom = CommonPrefs.getVolKeysZoom( this ); Intent intent = getIntent(); @@ -1815,8 +1819,10 @@ public class BoardActivity extends XWActivity private void adjustTradeVisibility() { m_toolbar.setVisibility( m_inTrade? View.GONE : View.VISIBLE ); - m_tradeButtons.setVisibility( m_inTrade? View.VISIBLE : View.GONE ); - if ( m_inTrade ) { + if ( null != m_tradeButtons ) { + m_tradeButtons.setVisibility( m_inTrade? View.VISIBLE : View.GONE ); + } + if ( m_inTrade && null != m_exchCommmitButton ) { m_exchCommmitButton.setEnabled( m_gsi.tradeTilesSelected ); } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Toolbar.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Toolbar.java index 2dc545229..e36322a14 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Toolbar.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Toolbar.java @@ -87,14 +87,18 @@ public class Toolbar { public void setVisibility( int vis ) { - m_me.setVisibility( vis ); + if ( null != m_me ) { + m_me.setVisibility( vis ); + } } public void setListener( int index, View.OnClickListener listener ) { TBButtonInfo info = s_buttonInfo[index]; ImageButton button = (ImageButton)m_activity.findViewById( info.m_id ); - button.setOnClickListener( listener ); + if ( null != button ) { + button.setOnClickListener( listener ); + } } public void setListener( int index, final int msgID, final int prefsKey, @@ -114,7 +118,9 @@ public class Toolbar { int vis = enable ? View.VISIBLE : View.GONE; ImageButton button = (ImageButton)m_activity.findViewById( info.m_id ); - button.setVisibility( vis ); + if ( null != button ) { + button.setVisibility( vis ); + } } } From fcf76aba0f4784b6e1c2160b7e7f8203e9b5bec9 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 5 Jun 2012 22:13:26 -0700 Subject: [PATCH 05/19] include trayVisState in GameStateInfo --- xwords4/common/game.c | 1 + xwords4/common/game.h | 1 + 2 files changed, 2 insertions(+) diff --git a/xwords4/common/game.c b/xwords4/common/game.c index 83cbd2d02..f85892ae9 100644 --- a/xwords4/common/game.c +++ b/xwords4/common/game.c @@ -285,6 +285,7 @@ void game_getState( const XWGame* game, GameStateInfo* gsi ) { gsi->curTurnSelected = board_curTurnSelected( game->board ); + gsi->trayVisState = board_getTrayVisState( game->board ); gsi->visTileCount = board_visTileCount( game->board ); gsi->canHint = board_canHint( game->board ); gsi->canRedo = board_canTogglePending( game->board ); diff --git a/xwords4/common/game.h b/xwords4/common/game.h index 7cc6c783d..c1bc42c3a 100644 --- a/xwords4/common/game.h +++ b/xwords4/common/game.h @@ -67,6 +67,7 @@ typedef struct CurGameInfo { typedef struct _GameStateInfo { XP_U16 visTileCount; + XW_TrayVisState trayVisState; XP_Bool canHint; XP_Bool canRedo; XP_Bool inTrade; From 78dfd6267c3997257fd11989763b92fb0b62512a Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 5 Jun 2012 22:13:58 -0700 Subject: [PATCH 06/19] include trayVisState in GameStateInfo on the java side --- xwords4/android/XWords4/jni/xwjni.c | 1 + .../XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java | 1 + 2 files changed, 2 insertions(+) diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c index 43c1e60ff..03c67b46a 100644 --- a/xwords4/android/XWords4/jni/xwjni.c +++ b/xwords4/android/XWords4/jni/xwjni.c @@ -1256,6 +1256,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1getState game_getState( &state->game, &info ); setInt( env, jgsi, "visTileCount", info.visTileCount ); + setInt( env, jgsi, "trayVisState", info.trayVisState ); setBool( env, jgsi, "canHint", info.canHint ); setBool( env, jgsi, "canRedo", info.canRedo); setBool( env, jgsi, "inTrade", info.inTrade ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java index c5a13473e..cf776ad6d 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java @@ -96,6 +96,7 @@ public class JNIThread extends Thread { public class GameStateInfo implements Cloneable { public int visTileCount; + public int trayVisState; public boolean canHint; public boolean canRedo; public boolean inTrade; From 5d9381e1bc6f24e1ddcb535e82d205b4947722f8 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 5 Jun 2012 22:19:44 -0700 Subject: [PATCH 07/19] change text of menu from hide rack to show rack depending on hidden state --- xwords4/android/XWords4/res/menu/board_menu.xml | 2 -- xwords4/android/XWords4/res/values/strings.xml | 3 ++- .../src/org/eehouse/android/xw4/BoardActivity.java | 13 +++++++++++-- .../src/org/eehouse/android/xw4/jni/UtilCtxt.java | 4 ++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/xwords4/android/XWords4/res/menu/board_menu.xml b/xwords4/android/XWords4/res/menu/board_menu.xml index d5b86a1bf..eb888921e 100644 --- a/xwords4/android/XWords4/res/menu/board_menu.xml +++ b/xwords4/android/XWords4/res/menu/board_menu.xml @@ -19,8 +19,6 @@ /> diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml index 381e0a0e5..06f9e1428 100644 --- a/xwords4/android/XWords4/res/values/strings.xml +++ b/xwords4/android/XWords4/res/values/strings.xml @@ -655,7 +655,8 @@ room for the full board and tray to be shown then hiding the tray just "turns it over", i.e. shows tiles with '?' characters.--> - Hide rack + Hide rack + Show rack + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ + + + + + + + + + + + + + diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml index 06f9e1428..b78e778d7 100644 --- a/xwords4/android/XWords4/res/values/strings.xml +++ b/xwords4/android/XWords4/res/values/strings.xml @@ -1930,4 +1930,15 @@ account with unlimited texting? Click cancel if you are not. Remote device undid a turn. + + Prev hint + Next hint + Undo/Redo + Juggle rack + Flip board + Zoom in/out + Chat + Toggle values + + 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 ea0b43530..5cdf9a3ba 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java @@ -617,9 +617,12 @@ public class BoardActivity extends XWActivity MenuItem item; int strId; + updateMenus( menu ); + if ( null != m_gsi ) { inTrade = m_gsi.inTrade; menu.setGroupVisible( R.id.group_done, !inTrade ); + menu.setGroupVisible( R.id.group_exchange, inTrade ); if ( UtilCtxt.TRAY_REVEALED == m_gsi.trayVisState ) { strId = R.string.board_menu_tray_hide; @@ -656,12 +659,36 @@ public class BoardActivity extends XWActivity showNotAgainDlgThen( R.string.not_again_done, R.string.key_notagain_done, COMMIT_ACTION ); break; - // case R.id.board_menu_juggle: - // cmd = JNIThread.JNICmd.CMD_JUGGLE; - // break; - // case R.id.board_menu_flip: - // cmd = JNIThread.JNICmd.CMD_FLIP; - // break; + + case R.id.board_menu_trade_commit: + cmd = JNIThread.JNICmd.CMD_COMMIT; + break; + case R.id.board_menu_trade_cancel: + cmd = JNIThread.JNICmd.CMD_CANCELTRADE; + break; + + case R.id.board_menu_hint_prev: + cmd = JNIThread.JNICmd.CMD_PREV_HINT; + break; + case R.id.board_menu_hint_next: + cmd = JNIThread.JNICmd.CMD_NEXT_HINT; + break; + case R.id.board_menu_juggle: + cmd = JNIThread.JNICmd.CMD_JUGGLE; + break; + case R.id.board_menu_flip: + cmd = JNIThread.JNICmd.CMD_FLIP; + break; + case R.id.board_menu_zoom: + cmd = JNIThread.JNICmd.CMD_TOGGLEZOOM; + break; + case R.id.board_menu_chat: + startChatActivity(); + break; + case R.id.board_menu_toggle: + cmd = JNIThread.JNICmd.CMD_VALUES; + break; + case R.id.board_menu_trade: showNotAgainDlgThen( R.string.not_again_trading, R.string.key_notagain_trading, @@ -671,9 +698,9 @@ public class BoardActivity extends XWActivity case R.id.board_menu_tray: cmd = JNIThread.JNICmd.CMD_TOGGLE_TRAY; break; - // case R.id.board_menu_undo_current: - // cmd = JNIThread.JNICmd.CMD_UNDO_CUR; - // break; + case R.id.board_menu_undo_current: + cmd = JNIThread.JNICmd.CMD_UNDO_CUR; + break; case R.id.board_menu_undo_last: showConfirmThen( R.string.confirm_undo_last, UNDO_LAST_ACTION ); break; @@ -1825,6 +1852,27 @@ public class BoardActivity extends XWActivity null != m_gi.dictName( m_view.getCurPlayer() ) ); } + private void hideShowItem( Menu menu, int id, boolean visible ) + { + MenuItem item = menu.findItem( id ); + if ( null != item ) { + item.setVisible( visible ); + } + } + + private void updateMenus( Menu menu ) + { + if ( null != m_gsi ) { + hideShowItem( menu, R.id.board_menu_flip, m_gsi.visTileCount >= 1 ); + hideShowItem( menu, R.id.board_menu_toggle, m_gsi.visTileCount >= 1 ); + hideShowItem( menu, R.id.board_menu_juggle, m_gsi.canShuffle ); + hideShowItem( menu, R.id.board_menu_undo_current, m_gsi.canRedo ); + hideShowItem( menu, R.id.board_menu_hint_prev, m_gsi.canHint ); + hideShowItem( menu, R.id.board_menu_hint_next, m_gsi.canHint ); + hideShowItem( menu, R.id.board_menu_chat, m_gsi.gameIsConnected ); + } + } + private void adjustTradeVisibility() { m_toolbar.setVisibility( m_inTrade? View.GONE : View.VISIBLE ); From 2e2df3dc17f545d23ed907c5659fdf87d806582a Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 9 Jun 2012 10:01:41 -0700 Subject: [PATCH 10/19] add hasSmallScreen() --- .../src/org/eehouse/android/xw4/Utils.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java index 8a6858a34..074d89e55 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java @@ -32,6 +32,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences.Editor; import android.content.SharedPreferences; +import android.content.res.Configuration; import android.database.Cursor; import android.net.Uri; import android.provider.ContactsContract.PhoneLookup; @@ -56,6 +57,7 @@ public class Utils { private static HashMap s_phonesHash = new HashMap(); private static int s_nextCode = 0; // keep PendingIntents unique + private static Boolean s_hasSmallScreen = null; private Utils() {} @@ -285,6 +287,19 @@ public class Utils { } } + public static boolean hasSmallScreen( Context context ) + { + if ( null == s_hasSmallScreen ) { + int screenLayout = context.getResources(). + getConfiguration().screenLayout; + boolean hasSmallScreen = + (screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) + == Configuration.SCREENLAYOUT_SIZE_SMALL; + s_hasSmallScreen = new Boolean( hasSmallScreen ); + } + return s_hasSmallScreen; + } + public static String format( Context context, int id, Object... args ) { String fmt = context.getString( id ); From d46c827b4cd38c084bfe5de745f1a48d228a74cb Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 11 Jun 2012 07:01:36 -0700 Subject: [PATCH 11/19] reduce min tray height to twice cell height, and tweak layout on small-screen devices to make the value readable. --- .../org/eehouse/android/xw4/BoardView.java | 47 ++++++++++++++----- 1 file changed, 34 insertions(+), 13 deletions(-) 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 f41929e8d..f2a56b9b1 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java @@ -75,6 +75,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler, private Drawable m_downArrow; private boolean m_blackArrow; private boolean m_inTrade = false; + private boolean m_hasSmallScreen; // m_backgroundUsed: alpha not set ensures inequality private int m_backgroundUsed = 0x00000000; private boolean m_darkOnLight; @@ -144,6 +145,8 @@ public class BoardView extends View implements DrawCtx, BoardHandler, super( context, attrs ); m_context = context; + m_hasSmallScreen = Utils.hasSmallScreen( context ); + final float scale = getResources().getDisplayMetrics().density; m_defaultFontHt = (int)(MIN_FONT_DIPS * scale + 0.5f); m_mediumFontHt = m_defaultFontHt * 3 / 2; @@ -261,7 +264,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler, // fit them and all cells no scrolling's needed. Otherwise // determine the minimum number that must be hidden to fit. // Finally grow scoreboard and tray to use whatever's left. - int trayHt = (5 * cellSize) / 2; + int trayHt = 2 * cellSize; int scoreHt = (cellSize * 3) / 2; int wantHt = trayHt + scoreHt + (cellSize * nCells); int nToScroll; @@ -760,6 +763,12 @@ public class BoardView extends View implements DrawCtx, BoardHandler, } // drawTileImpl private void drawCentered( String text, Rect rect, FontDims fontDims ) + { + drawIn( text, rect, fontDims, Paint.Align.CENTER ); + } + + private void drawIn( String text, Rect rect, FontDims fontDims, + Paint.Align align ) { int descent = -1; int textSize; @@ -784,9 +793,12 @@ public class BoardView extends View implements DrawCtx, BoardHandler, drawScaled( text, rect, descent ); } else { int bottom = rect.bottom - descent; - int center = rect.left + ( rect.width() / 2 ); - m_fillPaint.setTextAlign( Paint.Align.CENTER ); - m_canvas.drawText( text, center, bottom, m_fillPaint ); + int origin = rect.left; + if ( Paint.Align.CENTER == align ) { + origin += rect.width() / 2; + } + m_fillPaint.setTextAlign( align ); + m_canvas.drawText( text, origin, bottom, m_fillPaint ); } } // drawCentered @@ -810,23 +822,32 @@ public class BoardView extends View implements DrawCtx, BoardHandler, private void positionDrawTile( final Rect rect, String text, int val ) { if ( figureFontDims() ) { + int offset = m_hasSmallScreen ? 1 : 2; if ( null != text ) { if ( null == m_letterRect ) { - m_letterRect = new Rect( 0, 0, rect.width() * 3 / 4, - rect.height() * 3 / 4 ); + int width = rect.width(); + int height = rect.height(); + if ( m_hasSmallScreen ) { + height = height * 2 / 3; + } else { + height = height * 3 / 4; + } + width -= offset; + m_letterRect = new Rect( 0, 0, width, height ); } - m_letterRect.offsetTo( rect.left+2, rect.top+2 ); - drawCentered( text, m_letterRect, m_fontDims ); + m_letterRect.offsetTo( rect.left + offset, rect.top + offset ); + drawIn( text, m_letterRect, m_fontDims, Paint.Align.LEFT ); } if ( val >= 0 ) { + int divisor = m_hasSmallScreen ? 3 : 4; if ( null == m_valRect ) { - m_valRect = new Rect( 0, 0, rect.width() / 4, - rect.height() / 4 ); - m_valRect.inset( 2, 2 ); + m_valRect = new Rect( 0, 0, rect.width() / divisor, + rect.height() / divisor ); + m_valRect.inset( offset, offset ); } - m_valRect.offsetTo( rect.right - (rect.width() / 4), - rect.bottom - (rect.height() / 4) ); + 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 ); From 545cf9166f46577e0c8731df11409bae318d77e5 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 12 Jun 2012 07:19:18 -0700 Subject: [PATCH 12/19] show green border in contracted view too when appropriate, and not only for net games. --- .../eehouse/android/xw4/GameListAdapter.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java index 517a973dd..181f89d6b 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java @@ -52,15 +52,16 @@ public class GameListAdapter extends XWListAdapter { private View m_view; private View m_hideable; private View m_name; - private boolean m_expanded, m_haveTurn; + private boolean m_expanded, m_haveTurn, m_haveTurnLocal; private long m_rowid; private ImageButton m_expandButton; public ViewInfo( View view, long rowid, boolean expanded, - boolean haveTurn ) { + boolean haveTurn, boolean haveTurnLocal ) { m_view = view; m_rowid = rowid; m_expanded = expanded; m_haveTurn = haveTurn; + m_haveTurnLocal = haveTurnLocal; m_hideable = (LinearLayout)view.findViewById( R.id.hideable ); m_name = (TextView)m_view.findViewById( R.id.game_name ); m_expandButton = (ImageButton)view.findViewById( R.id.expander ); @@ -75,8 +76,14 @@ public class GameListAdapter extends XWListAdapter { R.drawable.expander_ic_minimized); m_hideable.setVisibility( m_expanded? View.VISIBLE : View.GONE ); - m_name.setBackgroundColor( m_haveTurn && !m_expanded ? TURN_COLOR : - android.R.color.transparent ); + m_name.setBackgroundColor( android.R.color.transparent ); + if ( !m_expanded ) { + if ( m_haveTurnLocal ) { + m_name.setBackgroundColor( TURN_COLOR ); + } else if ( m_haveTurn ) { + m_name.setBackgroundResource( R.drawable.green_border ); + } + } } public void onClick( View view ) { @@ -164,7 +171,8 @@ public class GameListAdapter extends XWListAdapter { LinearLayout list = (LinearLayout)layout.findViewById( R.id.player_list ); - boolean haveNetTurn = false; + boolean haveTurn = false; + boolean haveTurnLocal = false; boolean[] isLocal = new boolean[1]; for ( int ii = 0; ii < summary.nPlayers; ++ii ) { View tmp = m_factory.inflate( R.layout.player_list_elem, @@ -174,14 +182,13 @@ public class GameListAdapter extends XWListAdapter { view = (TextView)tmp.findViewById( R.id.item_score ); view.setText( String.format( " %d", summary.scores[ii] ) ); if ( summary.isNextToPlay( ii, isLocal ) ) { + haveTurn = true; if ( isLocal[0] ) { + haveTurnLocal = true; tmp.setBackgroundColor( TURN_COLOR ); } else { tmp.setBackgroundResource( R.drawable.green_border ); } - if ( summary.isMultiGame() ) { - haveNetTurn = true; - } } list.addView( tmp, ii ); } @@ -216,7 +223,7 @@ public class GameListAdapter extends XWListAdapter { boolean expanded = DBUtils.getExpanded( m_context, m_rowid ); ViewInfo vi = new ViewInfo( layout, m_rowid, - expanded, haveNetTurn ); + expanded, haveTurn, haveTurnLocal ); synchronized( m_viewsCache ) { m_viewsCache.put( m_rowid, vi ); From 4cd8f8bfd1717734f53e4e027c28c30884c92634 Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 13 Jun 2012 20:07:28 -0700 Subject: [PATCH 13/19] change toast to not imply game to start immediately. --- xwords4/android/XWords4/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml index b78e778d7..10b6e69d2 100644 --- a/xwords4/android/XWords4/res/values/strings.xml +++ b/xwords4/android/XWords4/res/values/strings.xml @@ -1922,7 +1922,7 @@ Are you sure you want to delete the checked phone number[s]? - Invitation accepted. + Invitation received. Connection (via SMS/text) Connected number[s]: Game in play with %s From c34f70f9ebe8c9178db26bcd34ab7fd32b58817f Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 15 Jun 2012 06:26:40 -0700 Subject: [PATCH 14/19] fix bug where current player's scoreboard would disappear if other players' names were too long by giving all a the same proportion of what they request and passing in the percent given in case draw implementation wants to use it as a cue to truncate. --- xwords4/android/XWords4/jni/drawwrapper.c | 10 +- .../org/eehouse/android/xw4/BoardView.java | 12 +-- .../org/eehouse/android/xw4/jni/DrawCtx.java | 3 +- xwords4/common/draw.h | 5 +- xwords4/common/scorebdp.c | 95 ++++++++----------- xwords4/linux/cursesdraw.c | 3 +- xwords4/linux/gtkdraw.c | 3 +- 7 files changed, 59 insertions(+), 72 deletions(-) diff --git a/xwords4/android/XWords4/jni/drawwrapper.c b/xwords4/android/XWords4/jni/drawwrapper.c index 7aef50ddb..5f93d70f2 100644 --- a/xwords4/android/XWords4/jni/drawwrapper.c +++ b/xwords4/android/XWords4/jni/drawwrapper.c @@ -185,20 +185,20 @@ and_draw_drawRemText( DrawCtx* dctx, const XP_Rect* rInner, } static void -and_draw_score_drawPlayer( DrawCtx* dctx, - const XP_Rect* rInner, - const XP_Rect* rOuter, +and_draw_score_drawPlayer( DrawCtx* dctx, const XP_Rect* rInner, + const XP_Rect* rOuter, XP_U16 gotPct, const DrawScoreInfo* dsi ) { DRAW_CBK_HEADER("score_drawPlayer", - "(Landroid/graphics/Rect;Landroid/graphics/Rect;" + "(Landroid/graphics/Rect;Landroid/graphics/Rect;I" "L" PKG_PATH("jni/DrawScoreInfo") ";)V" ); jobject jrinner = makeJRect( draw, JCACHE_RECT0, rInner ); jobject jrouter = makeJRect( draw, JCACHE_RECT1, rOuter ); jobject jdsi = makeDSI( draw, JCACHE_DSI, dsi ); - (*env)->CallVoidMethod( env, draw->jdraw, mid, jrinner, jrouter, jdsi ); + (*env)->CallVoidMethod( env, draw->jdraw, mid, jrinner, jrouter, gotPct, + jdsi ); } /* and_draw_score_drawPlayer */ static void 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 f2a56b9b1..8dbaf00d9 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java @@ -484,7 +484,8 @@ public class BoardView extends View implements DrawCtx, BoardHandler, height[0] = r.height(); } - public void score_drawPlayer( Rect rInner, Rect rOuter, DrawScoreInfo dsi ) + public void score_drawPlayer( Rect rInner, Rect rOuter, + int gotPct, DrawScoreInfo dsi ) { if ( 0 != (dsi.flags & CELL_ISCURSOR) ) { fillRectOther( rOuter, CommonPrefs.COLOR_FOCUS ); @@ -496,12 +497,11 @@ public class BoardView extends View implements DrawCtx, BoardHandler, } m_fillPaint.setColor( color ); - Rect rect = new Rect( rOuter ); - int height = rect.height() / texts.length; - rect.bottom = rect.top + height; + int height = rOuter.height() / texts.length; + rOuter.bottom = rOuter.top + height; for ( String text : texts ) { - drawCentered( text, rect, null ); - rect.offset( 0, height ); + drawCentered( text, rOuter, null ); + rOuter.offset( 0, height ); } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/DrawCtx.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/DrawCtx.java index 8148aa3d3..e007984a8 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/DrawCtx.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/DrawCtx.java @@ -47,7 +47,8 @@ public interface DrawCtx { void measureRemText( Rect r, int nTilesLeft, int[] width, int[] height ); void measureScoreText( Rect r, DrawScoreInfo dsi, int[] width, int[] height ); void drawRemText( Rect rInner, Rect rOuter, int nTilesLeft, boolean focussed ); - void score_drawPlayer( Rect rInner, Rect rOuter, DrawScoreInfo dsi ); + void score_drawPlayer( Rect rInner, Rect rOuter, int gotPct, + DrawScoreInfo dsi ); void drawTimer( Rect rect, int player, int secondsLeft ); boolean boardBegin( Rect rect, int cellWidth, int cellHeight ); diff --git a/xwords4/common/draw.h b/xwords4/common/draw.h index 4c63f00b3..5b71c76a2 100644 --- a/xwords4/common/draw.h +++ b/xwords4/common/draw.h @@ -149,6 +149,7 @@ typedef struct DrawCtxVTable { void DRAW_VTABLE_NAME(score_drawPlayer) ( DrawCtx* dctx, const XP_Rect* rInner, const XP_Rect* rOuter, + XP_U16 gotPct, const DrawScoreInfo* dsi ); void DRAW_VTABLE_NAME(score_pendingScore) ( DrawCtx* dctx, @@ -276,8 +277,8 @@ struct DrawCtx { CALL_DRAW_NAME4(drawRemText, (dc), (ri), (ro), (n), (f) ) #define draw_measureScoreText(dc,r,dsi,wp,hp) \ CALL_DRAW_NAME4(measureScoreText,(dc),(r),(dsi),(wp),(hp)) -#define draw_score_drawPlayer(dc, ri, ro, dsi) \ - CALL_DRAW_NAME3(score_drawPlayer,(dc),(ri),(ro),(dsi)) +#define draw_score_drawPlayer(dc, ri, ro, gp, dsi) \ + CALL_DRAW_NAME4(score_drawPlayer,(dc),(ri),(ro),(gp),(dsi)) #define draw_score_pendingScore(dc, r, s, p, f ) \ CALL_DRAW_NAME4(score_pendingScore,(dc), (r), (s), (p), (f)) #define draw_drawTimer( dc, r, plyr, sec ) \ diff --git a/xwords4/common/scorebdp.c b/xwords4/common/scorebdp.c index dbe06ee98..e74e2e275 100644 --- a/xwords4/common/scorebdp.c +++ b/xwords4/common/scorebdp.c @@ -70,13 +70,11 @@ drawScoreBoard( BoardCtxt* board ) XP_Rect scoreRect = board->scoreBdBounds; XP_S16* adjustDim; XP_S16* adjustPt; - XP_U16 totalDim; /* don't really need this */ - XP_U16 extra, remWidth, remHeight, remDim; + XP_U16 remWidth, remHeight, remDim; DrawScoreData* dp; DrawScoreData datum[MAX_NUM_PLAYERS]; ScoresArray scores; XP_Bool isVertical = !board->scoreSplitHor; - XP_Bool skipCurTurn; /* skip the guy whose turn it is this pass? */ XP_Bool remFocussed = XP_FALSE; XP_Bool focusAll = XP_FALSE; #ifdef KEYBOARD_NAV @@ -106,6 +104,8 @@ drawScoreBoard( BoardCtxt* board ) if ( draw_scoreBegin( board->draw, &board->scoreBdBounds, nPlayers, scores.arr, nTilesInPool, dfsFor( board, OBJ_SCORE ) ) ) { + XP_U16 totalDim = 0; /* not counting rem */ + XP_U16 gotPct; /* Let platform decide whether the rem: string should be given any space once there are no tiles left. On Palm that space @@ -125,8 +125,6 @@ drawScoreBoard( BoardCtxt* board ) } *adjustDim -= remDim; - totalDim = remDim; - /* Give as much room as possible to the entry for the player whose turn it is so name can be drawn. Do that by formatting that player's score last, and passing each time @@ -136,64 +134,49 @@ drawScoreBoard( BoardCtxt* board ) /* figure spacing for each scoreboard entry */ XP_MEMSET( &datum, 0, sizeof(datum) ); - for ( skipCurTurn = XP_TRUE; ; skipCurTurn = XP_FALSE ) { - for ( dp = datum, ii = 0; ii < nPlayers; ++ii, ++dp ) { - LocalPlayer* lp; - XP_U16 dim; + totalDim = 0; + for ( dp = datum, ii = 0; ii < nPlayers; ++ii, ++dp ) { + LocalPlayer* lp = &board->gi->players[ii]; - if ( skipCurTurn == (ii == curTurn) ) { - continue; - } - - lp = &board->gi->players[ii]; - - /* This is a hack! */ - dp->dsi.lsc = board_ScoreCallback; - dp->dsi.lscClosure = model; + /* This is a hack! */ + dp->dsi.lsc = board_ScoreCallback; + dp->dsi.lscClosure = model; #ifdef KEYBOARD_NAV - if ( (ii == cursorIndex) || focusAll ) { - dp->dsi.flags |= CELL_ISCURSOR; - } -#endif - dp->dsi.playerNum = ii; - dp->dsi.totalScore = scores.arr[ii]; - dp->dsi.isTurn = (ii == curTurn); - dp->dsi.name = emptyStringIfNull(lp->name); - dp->dsi.selected = board->trayVisState != TRAY_HIDDEN - && ii==selPlayer; - dp->dsi.isRobot = LP_IS_ROBOT(lp); - dp->dsi.isRemote = !lp->isLocal; - dp->dsi.nTilesLeft = (nTilesInPool > 0)? -1: - model_getNumTilesTotal( model, ii ); - - draw_measureScoreText( board->draw, &scoreRect, - &dp->dsi, &dp->width, - &dp->height ); - - XP_ASSERT( dp->width <= scoreRect.width ); - XP_ASSERT( dp->height <= scoreRect.height ); - dim = isVertical ? dp->height : dp->width; - totalDim += dim; - *adjustDim -= dim; + if ( (ii == cursorIndex) || focusAll ) { + dp->dsi.flags |= CELL_ISCURSOR; } +#endif + dp->dsi.playerNum = ii; + dp->dsi.totalScore = scores.arr[ii]; + dp->dsi.isTurn = (ii == curTurn); + dp->dsi.name = emptyStringIfNull(lp->name); + dp->dsi.selected = board->trayVisState != TRAY_HIDDEN + && ii==selPlayer; + dp->dsi.isRobot = LP_IS_ROBOT(lp); + dp->dsi.isRemote = !lp->isLocal; + dp->dsi.nTilesLeft = (nTilesInPool > 0)? -1: + model_getNumTilesTotal( model, ii ); - if ( !skipCurTurn ) { /* exit 2nd time through */ - break; + draw_measureScoreText( board->draw, &scoreRect, + &dp->dsi, &dp->width, + &dp->height ); + + XP_ASSERT( dp->width <= scoreRect.width ); + XP_ASSERT( dp->height <= scoreRect.height ); + totalDim += isVertical ? dp->height : dp->width; + } + + gotPct = (*adjustDim * 100) / totalDim; + for ( dp = datum, ii = 0; ii < nPlayers; ++ii, ++dp ) { + if ( isVertical ) { + dp->height = (dp->height * gotPct) / 100; + } else { + dp->width = (dp->width * gotPct) / 100; } } scoreRect = board->scoreBdBounds; /* reset */ - /* break extra space into chunks, one to follow REM and - another to preceed the timer, and then one for each player. - Generally the player's score will be centered in the rect - it's given, so in effect we're putting half the chunk on - either side. The goal here is for the scores to be closer - to each other than they are to the rem: string and timer on - the ends. */ - XP_ASSERT( *adjustDim >= totalDim ); /* ???? */ - extra = (*adjustDim - totalDim) / nPlayers; - /* at this point, the scoreRect should be anchored at the scoreboard rect's upper left. */ @@ -218,11 +201,11 @@ drawScoreBoard( BoardCtxt* board ) for ( dp = datum, ii = 0; ii < nPlayers; ++dp, ++ii ) { XP_Rect innerRect; XP_U16 dim = isVertical? dp->height:dp->width; - *adjustDim = board->pti[ii].scoreDims = dim + extra; + *adjustDim = board->pti[ii].scoreDims = dim; centerIn( &innerRect, &scoreRect, dp->width, dp->height ); draw_score_drawPlayer( board->draw, &innerRect, &scoreRect, - &dp->dsi ); + gotPct, &dp->dsi ); #ifdef KEYBOARD_NAV XP_MEMCPY( &board->pti[ii].scoreRects, &scoreRect, sizeof(scoreRect) ); diff --git a/xwords4/linux/cursesdraw.c b/xwords4/linux/cursesdraw.c index 8ae097bf3..2d2e0ab13 100644 --- a/xwords4/linux/cursesdraw.c +++ b/xwords4/linux/cursesdraw.c @@ -277,7 +277,8 @@ curses_draw_objFinished( DrawCtx* p_dctx, BoardObjectType XP_UNUSED(typ), static void curses_draw_score_drawPlayer( DrawCtx* p_dctx, const XP_Rect* rInner, - const XP_Rect* rOuter, const DrawScoreInfo* dsi ) + const XP_Rect* rOuter, + XP_U16 XP_UNUSED(gotPct), const DrawScoreInfo* dsi ) { CursesDrawCtx* dctx = (CursesDrawCtx*)p_dctx; char buf[100]; diff --git a/xwords4/linux/gtkdraw.c b/xwords4/linux/gtkdraw.c index 6451b5c15..b52404de7 100644 --- a/xwords4/linux/gtkdraw.c +++ b/xwords4/linux/gtkdraw.c @@ -1013,7 +1013,8 @@ gtk_draw_measureScoreText( DrawCtx* p_dctx, const XP_Rect* bounds, static void gtk_draw_score_drawPlayer( DrawCtx* p_dctx, const XP_Rect* rInner, - const XP_Rect* rOuter, const DrawScoreInfo* dsi ) + const XP_Rect* rOuter, + XP_U16 XP_UNUSED(gotPct), const DrawScoreInfo* dsi ) { GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx; XP_Bool hasCursor = (dsi->flags & CELL_ISCURSOR) != 0; From 9d8e1ec261c84f8ac022a8a803257bb77c4f9c64 Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 15 Jun 2012 06:43:54 -0700 Subject: [PATCH 15/19] cleanup: one-letter variables are bad. --- .../XWords4/src/org/eehouse/android/xw4/BoardView.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 8dbaf00d9..070f6b1c8 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java @@ -442,7 +442,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler, drawCentered( m_remText, rInner, null ); } - public void measureScoreText( Rect r, DrawScoreInfo dsi, + public void measureScoreText( Rect rect, DrawScoreInfo dsi, int[] width, int[] height ) { String[] scoreInfo = new String[dsi.isTurn?1:2]; @@ -466,7 +466,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler, scoreInfo[indx] = sb.toString(); m_scores[dsi.playerNum] = scoreInfo; - m_fillPaint.setTextSize( dsi.isTurn? r.height() : m_defaultFontHt ); + m_fillPaint.setTextSize( dsi.isTurn? rect.height() : m_defaultFontHt ); int needWidth = 0; for ( int ii = 0; ii < scoreInfo.length; ++ii ) { @@ -476,12 +476,12 @@ public class BoardView extends View implements DrawCtx, BoardHandler, needWidth = m_boundsScratch.width(); } } - if ( needWidth > r.width() ) { - needWidth = r.width(); + if ( needWidth > rect.width() ) { + needWidth = rect.width(); } width[0] = needWidth; - height[0] = r.height(); + height[0] = rect.height(); } public void score_drawPlayer( Rect rInner, Rect rOuter, From bb5cd677ab55fb93f8ef8e9c38137526a235ed41 Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 15 Jun 2012 06:44:39 -0700 Subject: [PATCH 16/19] make turn color public so can be used from board too (though I'm not doing that yet.) --- .../XWords4/src/org/eehouse/android/xw4/GameListAdapter.java | 5 ++--- .../android/XWords4/src/org/eehouse/android/xw4/Utils.java | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java index 181f89d6b..60f0b95cc 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java @@ -46,7 +46,6 @@ public class GameListAdapter extends XWListAdapter { private Context m_context; private LayoutInflater m_factory; private int m_fieldID; - private static final int TURN_COLOR = 0x7F00FF00; private class ViewInfo implements View.OnClickListener { private View m_view; @@ -79,7 +78,7 @@ public class GameListAdapter extends XWListAdapter { m_name.setBackgroundColor( android.R.color.transparent ); if ( !m_expanded ) { if ( m_haveTurnLocal ) { - m_name.setBackgroundColor( TURN_COLOR ); + m_name.setBackgroundColor( Utils.TURN_COLOR ); } else if ( m_haveTurn ) { m_name.setBackgroundResource( R.drawable.green_border ); } @@ -185,7 +184,7 @@ public class GameListAdapter extends XWListAdapter { haveTurn = true; if ( isLocal[0] ) { haveTurnLocal = true; - tmp.setBackgroundColor( TURN_COLOR ); + tmp.setBackgroundColor( Utils.TURN_COLOR ); } else { tmp.setBackgroundResource( R.drawable.green_border ); } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java index 074d89e55..be266e1da 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java @@ -48,6 +48,8 @@ import junit.framework.Assert; import org.eehouse.android.xw4.jni.*; public class Utils { + public static final int TURN_COLOR = 0x7F00FF00; + private static final String DB_PATH = "XW_GAMES"; private static final String HIDDEN_PREFS = "xwprefs_hidden"; private static final String SHOWN_VERSION_KEY = "SHOWN_VERSION_KEY"; From 964c4cecd87d0eb5c3ec7ee663eb19a3f36ee4a7 Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 15 Jun 2012 07:00:18 -0700 Subject: [PATCH 17/19] add dict-browse menuitem to small-screen board menu and on same move undo/redo up per user request --- .../android/XWords4/res/menu-small/board_menu.xml | 12 ++++++++---- xwords4/android/XWords4/res/values/strings.xml | 2 ++ .../src/org/eehouse/android/xw4/BoardActivity.java | 7 +++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/xwords4/android/XWords4/res/menu-small/board_menu.xml b/xwords4/android/XWords4/res/menu-small/board_menu.xml index e5f2cae90..d5fe70b11 100644 --- a/xwords4/android/XWords4/res/menu-small/board_menu.xml +++ b/xwords4/android/XWords4/res/menu-small/board_menu.xml @@ -31,8 +31,16 @@ /> + + + + @@ -40,10 +48,6 @@ android:title="@string/menu_flip" /> - - diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml index 10b6e69d2..315870ef5 100644 --- a/xwords4/android/XWords4/res/values/strings.xml +++ b/xwords4/android/XWords4/res/values/strings.xml @@ -1940,5 +1940,7 @@ Chat Toggle values + + Browse wordlist 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 5cdf9a3ba..aaa2fb5c2 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java @@ -704,6 +704,13 @@ public class BoardActivity extends XWActivity case R.id.board_menu_undo_last: showConfirmThen( R.string.confirm_undo_last, UNDO_LAST_ACTION ); break; + + // small devices only + case R.id.board_menu_dict: + String dictName = m_gi.dictName( m_view.getCurPlayer() ); + DictBrowseActivity.launch( this, dictName ); + break; + case R.id.board_menu_game_counts: m_jniThread.handle( JNIThread.JNICmd.CMD_COUNTS_VALUES, R.string.counts_values_title ); From df907f6cb33ba0750f6b43e55a96767818b9abe6 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 19 Jun 2012 07:36:32 -0700 Subject: [PATCH 18/19] up version strings and changelog --- xwords4/android/XWords4/AndroidManifest.xml | 2 +- xwords4/android/XWords4/res/raw/changes | 6 ++---- xwords4/android/XWords4/res/values/common_rsrc.xml | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/xwords4/android/XWords4/AndroidManifest.xml b/xwords4/android/XWords4/AndroidManifest.xml index 5e0dd5d57..4d8738b96 100644 --- a/xwords4/android/XWords4/AndroidManifest.xml +++ b/xwords4/android/XWords4/AndroidManifest.xml @@ -22,7 +22,7 @@ to come from a domain that you own or have control over. --> diff --git a/xwords4/android/XWords4/res/raw/changes b/xwords4/android/XWords4/res/raw/changes index 3be915a21..f37d09d82 100644 --- a/xwords4/android/XWords4/res/raw/changes +++ b/xwords4/android/XWords4/res/raw/changes @@ -5,12 +5,10 @@ -Crosswords 4.4 beta 45 release +Crosswords 4.4 beta 46 release
    -
  • Turn on undo for multi-device games
  • - -
  • UI tweaks, e.g. frame in green the remote player whose turn it is
  • +
  • Improve board layout for small-screen phones, e.g. Samsung Galaxy Y
diff --git a/xwords4/android/XWords4/res/values/common_rsrc.xml b/xwords4/android/XWords4/res/values/common_rsrc.xml index 4d4025606..716d0f438 100644 --- a/xwords4/android/XWords4/res/values/common_rsrc.xml +++ b/xwords4/android/XWords4/res/values/common_rsrc.xml @@ -3,7 +3,7 @@ - 4.4 beta 45 + 4.4 beta 46 key_color_tiles From c2c1fe4f894e20b4ce6ef54c2070c4e666f0ae6d Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 19 Jun 2012 07:44:26 -0700 Subject: [PATCH 19/19] attempt to improve scoreboard drawing when names are long or numerous enough to crowd by using same math to figure height when measuring as when drawing, but it still needs work. --- .../org/eehouse/android/xw4/BoardView.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) 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 070f6b1c8..66898d4f1 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java @@ -54,6 +54,8 @@ public class BoardView extends View implements DrawCtx, BoardHandler, private static Bitmap s_bitmap; // the board private static final int IN_TRADE_ALPHA = 0x3FFFFFFF; private static final int PINCH_THRESHOLD = 40; + private static final int SCORE_HT_DROP = 2; + private static final boolean DEBUG_DRAWFRAMES = false; private Context m_context; private Paint m_drawPaint; @@ -466,7 +468,15 @@ public class BoardView extends View implements DrawCtx, BoardHandler, scoreInfo[indx] = sb.toString(); m_scores[dsi.playerNum] = scoreInfo; - m_fillPaint.setTextSize( dsi.isTurn? rect.height() : m_defaultFontHt ); + int rectHt = rect.height(); + if ( !dsi.isTurn ) { + rectHt /= 2; + } + int textHeight = rectHt - SCORE_HT_DROP; + if ( textHeight < m_defaultFontHt ) { + textHeight = m_defaultFontHt; + } + m_fillPaint.setTextSize( textHeight ); int needWidth = 0; for ( int ii = 0; ii < scoreInfo.length; ++ii ) { @@ -489,6 +499,8 @@ public class BoardView extends View implements DrawCtx, BoardHandler, { if ( 0 != (dsi.flags & CELL_ISCURSOR) ) { fillRectOther( rOuter, CommonPrefs.COLOR_FOCUS ); + } else if ( DEBUG_DRAWFRAMES && dsi.selected ) { + fillRectOther( rOuter, CommonPrefs.COLOR_FOCUS ); } String[] texts = m_scores[dsi.playerNum]; int color = m_playerColors[dsi.playerNum]; @@ -503,6 +515,10 @@ public class BoardView extends View implements DrawCtx, BoardHandler, drawCentered( text, rOuter, null ); rOuter.offset( 0, height ); } + if ( DEBUG_DRAWFRAMES ) { + m_strokePaint.setColor( BLACK ); + m_canvas.drawRect( rInner, m_strokePaint ); + } } public void drawTimer( Rect rect, int player, int secondsLeft ) @@ -773,7 +789,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler, int descent = -1; int textSize; if ( null == fontDims ) { - textSize = rect.height() - 2; + textSize = rect.height() - SCORE_HT_DROP; } else { int height = rect.height() - 4; // borders and padding, 2 each descent = fontDims.descentFor( height );