mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-09 05:24:44 +01:00
Merge branch 'android_branch' into android_translate
# Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
This commit is contained in:
commit
81b8f9bcf6
3 changed files with 28 additions and 8 deletions
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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}.
|
||||
|
|
Loading…
Reference in a new issue