From 9827ea1b39fad103bf8443dde18b9009aab1feee Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 6 Jun 2012 06:48:55 -0700 Subject: [PATCH] add menus for small-screen devices to provide functionality others get from toolbar. --- .../XWords4/res/menu-small/board_menu.xml | 89 +++++++++++++++++++ .../android/XWords4/res/values/strings.xml | 11 +++ .../eehouse/android/xw4/BoardActivity.java | 66 ++++++++++++-- 3 files changed, 157 insertions(+), 9 deletions(-) create mode 100644 xwords4/android/XWords4/res/menu-small/board_menu.xml diff --git a/xwords4/android/XWords4/res/menu-small/board_menu.xml b/xwords4/android/XWords4/res/menu-small/board_menu.xml new file mode 100644 index 000000000..e5f2cae90 --- /dev/null +++ b/xwords4/android/XWords4/res/menu-small/board_menu.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 );