Merge branch 'android_branch' into android_invite

This commit is contained in:
eehouse@eehouse.org 2011-06-06 22:08:49 -07:00 committed by Andy2
commit 484bb295d0
6 changed files with 52 additions and 31 deletions

View file

@ -349,11 +349,13 @@ and_util_warnIllegalWord( XW_UtilCtxt* uc, BadWordInfo* bwi,
jboolean result = XP_FALSE;
UTIL_CBK_HEADER("warnIllegalWord", "([Ljava/lang/String;IZ)Z" );
XP_ASSERT( bwi->nWords > 0 );
jobjectArray jwords = makeStringArray( env, bwi->nWords,
(const XP_UCHAR**)bwi->words );
result = (*env)->CallBooleanMethod( env, util->jutil, mid,
jwords, turn, turnLost );
(*env)->DeleteLocalRef( env, jwords );
if ( bwi->nWords > 0 ) {
jobjectArray jwords = makeStringArray( env, bwi->nWords,
(const XP_UCHAR**)bwi->words );
result = (*env)->CallBooleanMethod( env, util->jutil, mid,
jwords, turn, turnLost );
(*env)->DeleteLocalRef( env, jwords );
}
UTIL_CBK_TAIL();
return result;
}

View file

@ -564,4 +564,7 @@
%1$s. (If you don\'t have Crosswords: %2$s.)</string>
<string name="invite_chooser">Send invitation via</string>
<string name="no_download_warning">Unable to download. Do you have
a web browser installed?</string>
</resources>

View file

@ -448,7 +448,7 @@ public class BoardActivity extends XWActivity
case R.id.board_menu_done:
proc = new Runnable() {
public void run() {
m_jniThread.handle( JNIThread.JNICmd.CMD_COMMIT );
checkAndHandle( JNIThread.JNICmd.CMD_COMMIT );
}
};
showNotAgainDlgThen( R.string.not_again_done,
@ -1115,6 +1115,13 @@ public class BoardActivity extends XWActivity
}
} // loadGame
private void checkAndHandle( JNIThread.JNICmd cmd )
{
if ( null != m_jniThread ) {
m_jniThread.handle( cmd );
}
}
private void populateToolbar()
{
m_toolbar.setListener( Toolbar.BUTTON_HINT_PREV,
@ -1122,8 +1129,8 @@ public class BoardActivity extends XWActivity
R.string.key_notagain_hintprev,
new Runnable() {
public void run() {
m_jniThread.handle( JNIThread.JNICmd
.CMD_PREV_HINT );
checkAndHandle( JNIThread.JNICmd.
CMD_PREV_HINT );
}
} );
m_toolbar.setListener( Toolbar.BUTTON_HINT_NEXT,
@ -1132,8 +1139,8 @@ public class BoardActivity extends XWActivity
new Runnable() {
@Override
public void run() {
m_jniThread.handle( JNIThread.JNICmd
.CMD_NEXT_HINT );
checkAndHandle( JNIThread.JNICmd
.CMD_NEXT_HINT );
}
} );
m_toolbar.setListener( Toolbar.BUTTON_JUGGLE,
@ -1142,8 +1149,8 @@ public class BoardActivity extends XWActivity
new Runnable() {
@Override
public void run() {
m_jniThread.handle( JNIThread.JNICmd
.CMD_JUGGLE );
checkAndHandle( JNIThread.JNICmd
.CMD_JUGGLE );
}
} );
m_toolbar.setListener( Toolbar.BUTTON_FLIP,
@ -1152,8 +1159,8 @@ public class BoardActivity extends XWActivity
new Runnable() {
@Override
public void run() {
m_jniThread.handle( JNIThread.JNICmd
.CMD_FLIP );
checkAndHandle( JNIThread.JNICmd
.CMD_FLIP );
}
} );
m_toolbar.setListener( Toolbar.BUTTON_ZOOM,
@ -1162,8 +1169,8 @@ public class BoardActivity extends XWActivity
new Runnable() {
@Override
public void run() {
m_jniThread.handle( JNIThread.JNICmd
.CMD_TOGGLEZOOM );
checkAndHandle( JNIThread.JNICmd
.CMD_TOGGLEZOOM );
}
} );
m_toolbar.setListener( Toolbar.BUTTON_UNDO,
@ -1172,8 +1179,8 @@ public class BoardActivity extends XWActivity
new Runnable() {
@Override
public void run() {
m_jniThread.handle( JNIThread.JNICmd
.CMD_UNDO_CUR );
checkAndHandle( JNIThread.JNICmd
.CMD_UNDO_CUR );
}
});
m_toolbar.setListener( Toolbar.BUTTON_CHAT,

View file

@ -45,6 +45,7 @@ import android.view.MenuInflater;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
import android.widget.Toast;
import android.preference.PreferenceManager;
import android.net.Uri;
import junit.framework.Assert;
@ -494,7 +495,12 @@ public class DictsActivity extends ExpandableListActivity
private void startDownload( int lang, String name, boolean toSD )
{
DictImportActivity.setUseSD( toSD );
startActivity( mkDownloadIntent( this, lang, name ) );
try {
startActivity( mkDownloadIntent( this, lang, name ) );
} catch ( android.content.ActivityNotFoundException anfe ) {
Toast.makeText( this, R.string.no_download_warning,
Toast.LENGTH_SHORT).show();
}
}
private void mkListAdapter()

View file

@ -347,9 +347,10 @@ public class GameConfig extends XWActivity
Spinner spinner =
(Spinner)((Dialog)di).findViewById( R.id.dict_spinner );
int position = spinner.getSelectedItemPosition();
lp.dictName = DictLangCache.getHaveLang( this, m_gi.dictLang )[position];
Utils.logf( "reading name for player %d via position %d: %s",
m_whichPlayer, position, lp.dictName );
String[] dicts = DictLangCache.getHaveLang( this, m_gi.dictLang );
if ( position < dicts.length ) {
lp.dictName = dicts[position];
}
lp.setIsRobot( Utils.getChecked( dialog, R.id.robot_check ) );
lp.isLocal = !Utils.getChecked( dialog, R.id.remote_check );

View file

@ -1336,18 +1336,20 @@ readStreamHeader( ServerCtxt* XP_UNUSED(server),
static void
sendBadWordMsgs( ServerCtxt* server )
{
XWStreamCtxt* stream;
stream = messageStreamWithHeader( server, server->lastMoveSource,
XWPROTO_BADWORD_INFO );
stream_putBits( stream, PLAYERNUM_NBITS, server->nv.currentTurn );
XP_ASSERT( server->illegalWordInfo.nWords > 0 );
bwiToStream( stream, &server->illegalWordInfo );
stream_destroy( stream );
if ( server->illegalWordInfo.nWords > 0 ) { /* fail gracefully */
XWStreamCtxt* stream =
messageStreamWithHeader( server, server->lastMoveSource,
XWPROTO_BADWORD_INFO );
stream_putBits( stream, PLAYERNUM_NBITS, server->nv.currentTurn );
freeBWI( MPPARM(server->mpool) &server->illegalWordInfo );
bwiToStream( stream, &server->illegalWordInfo );
stream_destroy( stream );
freeBWI( MPPARM(server->mpool) &server->illegalWordInfo );
}
} /* sendBadWordMsgs */
#endif