From b8822f72bc002897d76d01d194c9d2d1594cbf95 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 17 Sep 2015 06:51:15 -0700 Subject: [PATCH 1/2] Change return types to match recent signature change. Apparently the NDK's compiler is configured to be stricter than Ubuntu's. --- xwords4/common/engine.c | 2 +- xwords4/common/model.c | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/xwords4/common/engine.c b/xwords4/common/engine.c index 18a513696..5ccee2232 100644 --- a/xwords4/common/engine.c +++ b/xwords4/common/engine.c @@ -1092,7 +1092,7 @@ considerMove( EngineCtxt* engine, Tile* tiles, XP_S16 tileLength, } } /* considerMove */ -static XP_Bool +static void countWords( const XP_UCHAR* XP_UNUSED(word), XP_Bool isLegal, const DictionaryCtxt* XP_UNUSED(dict), #ifdef XWFEATURE_BOARDWORDS diff --git a/xwords4/common/model.c b/xwords4/common/model.c index a2818113a..2fb803b46 100644 --- a/xwords4/common/model.c +++ b/xwords4/common/model.c @@ -2190,7 +2190,7 @@ typedef struct _FirstWordData { XP_UCHAR word[32]; } FirstWordData; -static XP_Bool +static void getFirstWord( const XP_UCHAR* word, XP_Bool XP_UNUSED(isLegal), const DictionaryCtxt* XP_UNUSED(dict), #ifdef XWFEATURE_BOARDWORDS @@ -2203,7 +2203,6 @@ getFirstWord( const XP_UCHAR* word, XP_Bool XP_UNUSED(isLegal), if ( '\0' == data->word[0] && '\0' != word[0] ) { XP_STRCAT( data->word, word ); } - return XP_TRUE; } static void @@ -2312,7 +2311,7 @@ typedef struct _ListWordsThroughInfo { XP_U16 nWords; } ListWordsThroughInfo; -static XP_Bool +static void listWordsThrough( const XP_UCHAR* word, XP_Bool XP_UNUSED(isLegal), const DictionaryCtxt* XP_UNUSED(dict), const MoveInfo* movei, XP_U16 start, XP_U16 end, @@ -2330,8 +2329,6 @@ listWordsThrough( const XP_UCHAR* word, XP_Bool XP_UNUSED(isLegal), if ( contained ) { appendWithCR( info->stream, word, &info->nWords ); } - - return XP_TRUE; } /* List every word played that includes the tile on {col,row}. From db1f569430340c5521049df7f060d22b855d17b7 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 17 Sep 2015 06:59:02 -0700 Subject: [PATCH 2/2] in chat window, don't show send menu item unless text is non-empty --- .../org/eehouse/android/xw4/ChatDelegate.java | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java index b4bdd2b6d..48e8cd607 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatDelegate.java @@ -24,6 +24,9 @@ import android.app.Activity; import android.app.AlertDialog; import android.content.Intent; import android.os.Bundle; +import android.text.Editable; +import android.text.TextWatcher; +import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.EditText; @@ -37,6 +40,7 @@ public class ChatDelegate extends DelegateBase { private long m_rowid; private Activity m_activity; + private EditText mEdit; public ChatDelegate( Delegator delegator, Bundle savedInstanceState ) { @@ -48,6 +52,17 @@ public class ChatDelegate extends DelegateBase { protected void init( Bundle savedInstanceState ) { if ( BuildConstants.CHAT_SUPPORTED ) { + mEdit = (EditText)findViewById( R.id.chat_edit ); + mEdit.addTextChangedListener( new TextWatcher() { + public void afterTextChanged( Editable s ) { + invalidateOptionsMenuIf(); + } + public void beforeTextChanged( CharSequence s, int st, + int cnt, int a ) {} + public void onTextChanged( CharSequence s, int start, + int before, int count ) {} + } ); + m_rowid = getIntent().getLongExtra( GameUtils.INTENT_KEY_ROWID, -1 ); DBUtils.HistoryPair[] pairs = DBUtils.getChatHistory( m_activity, m_rowid ); @@ -82,6 +97,15 @@ public class ChatDelegate extends DelegateBase { } } + @Override + public boolean onPrepareOptionsMenu( Menu menu ) + { + String text = mEdit.getText().toString(); + boolean haveText = null != text && 0 < text.length(); + Utils.setItemVisible( menu, R.id.chat_menu_send, haveText ); + return true; + } + @Override public boolean onOptionsItemSelected( MenuItem item ) { @@ -93,8 +117,7 @@ public class ChatDelegate extends DelegateBase { } break; case R.id.chat_menu_send: - EditText edit = (EditText)findViewById( R.id.chat_edit ); - String text = edit.getText().toString(); + String text = mEdit.getText().toString(); if ( null == text || text.length() == 0 ) { setResult( Activity.RESULT_CANCELED ); } else {