Merge branch 'android_branch' into send_in_background

This commit is contained in:
eehouse@eehouse.org 2011-10-18 06:47:38 -07:00 committed by Andy2
commit b8adbd94c1
14 changed files with 201 additions and 142 deletions

View file

@ -22,7 +22,7 @@
to come from a domain that you own or have control over. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.eehouse.android.xw4"
android:versionCode="28"
android:versionCode="29"
android:versionName="@string/app_version"
>

View file

@ -1,37 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" -->
<!-- android:layout_width="fill_parent" -->
<!-- android:layout_height="fill_parent" -->
<!-- android:orientation="vertical" -->
<!-- > -->
<org.eehouse.android.xw4.LookupView
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<org.eehouse.android.xw4.LookupView
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView android:id="@+id/summary"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textAppearance="?android:attr/textAppearanceMedium"
android:gravity="center"
android:textColor="#FFFFFFFF"
/>
<TextView android:id="@+id/summary"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textAppearance="?android:attr/textAppearanceMedium"
android:gravity="center"
/>
<ListView android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false"
android:layout_weight="1"
/>
<ListView android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false"
android:layout_weight="1"
/>
<Button android:id="@+id/button_done"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<Button android:id="@+id/button_done"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<!-- android:text="@string/button_done" -->
</org.eehouse.android.xw4.LookupView>
<!-- </ScrollView> -->
</org.eehouse.android.xw4.LookupView>

View file

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/* //device/apps/common/res/layout/select_dialog_item.xml
**
** Copyright 2006, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<!--
This layout file is used by the AlertDialog when displaying a list of items.
This layout file is inflated and used as the TextView to display individual
items.
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_vertical"
android:paddingLeft="14dip"
android:paddingRight="15dip"
android:ellipsize="marquee"
android:textColor="#FFFFFFFF"
/>
<!-- this guy's private -->
<!-- android:textColor="@android:color/bright_foreground_light" -->

View file

@ -6,19 +6,17 @@
</head>
<body>
<b>Crosswords 4.4 beta 36 release</b>
<p><em>(There was no beta 35)</em></p>
<b>Crosswords 4.4 beta 37 release</b>
<ul>
<li>Add ability to look up words played by opponents via online
dictionary sites. The list of sites is hard-coded, and I don't have
them for most languages. Suggestions welcomed (including improvements
for English)!
</li>
<li>Extend ability to look up words to include those already on the
board. Hold your finger on any played tile to look up any of the
words that use it. </li>
<li>Rename 'Turn done' menuitem to 'Pass' when no points will be
scored
</li>
<li>Fix password dialog crashes</li>
<li>Show wordlist along with player name in Game Config screen, and
move below Language since it changes when language changes.</li>
</ul>

View file

@ -3,7 +3,7 @@
<!-- Resources in this file do not require localization -->
<resources>
<string name="app_version">4.4 beta 36</string>
<string name="app_version">4.4 beta 37</string>
<!-- prefs keys -->
<string name="key_color_tiles">key_color_tiles</string>
@ -74,7 +74,6 @@
<string name="key_notagain_turnchanged">key_notagain_turnchanged</string>
<string name="key_notagain_newfrom">key_notagain_newfrom</string>
<string name="key_notagain_trading">key_notagain_trading</string>
<string name="key_na_needUrlsForLang">key_na_needUrlsForLang</string>
<string name="key_na_lookup">key_na_lookup</string>
<!-- Name is not localized -->

View file

@ -1778,11 +1778,6 @@
<string name="board_menu_pass">Pass</string>
<string name="not_again_needUrlsForLang">Google is the only word
lookup site I have for this language. If you have suggestions
for word-lookup sites please email eehouse@eehouse.org
.</string>
<string name="not_again_lookup">This button lets you look up the
words just played online. (Note that not all languages are
supported yet.)</string>

View file

@ -292,8 +292,16 @@ public class GameConfig extends XWActivity
private void setPlayerSettings( final Dialog dialog )
{
// Hide remote option if in standalone mode...
boolean isServer = !m_notNetworkedGame;
// Independent of other hide/show logic, these guys are
// information-only if the game's locked. (Except that in a
// local game you can always toggle a player's robot state.)
Utils.setEnabled( dialog, R.id.remote_check, !m_isLocked );
Utils.setEnabled( dialog, R.id.player_name_edit, !m_isLocked );
Utils.setEnabled( dialog, R.id.robot_check, !m_isLocked || !isServer );
// Hide remote option if in standalone mode...
LocalPlayer lp = m_gi.players[m_whichPlayer];
Utils.setText( dialog, R.id.player_name_edit, lp.name );
Utils.setText( dialog, R.id.password_edit, lp.password );
@ -654,10 +662,8 @@ public class GameConfig extends XWActivity
view.setOnClickListener( lstnr );
m_playerLayout.addView( view );
view.setEnabled( !m_isLocked );
View divider = factory.inflate( R.layout.divider_view, null );
divider.setVisibility( View.VISIBLE );
m_playerLayout.addView( divider );
}
@ -875,12 +881,6 @@ public class GameConfig extends XWActivity
View view = findViewById( id );
view.setEnabled( !m_isLocked );
}
if ( null != m_playerLayout ) {
for ( int ii = m_playerLayout.getChildCount()-1; ii >= 0; --ii ) {
View view = m_playerLayout.getChildAt( ii );
view.setEnabled( !m_isLocked );
}
}
}
private int connTypeToPos( CommsAddrRec.CommsConnType typ )

View file

@ -55,8 +55,10 @@ public class LookupView extends LinearLayout
private static String[] s_lookupNames;
private static String[] s_lookupUrls;
private static ArrayAdapter<String> s_urlsAdapter;
private static final int LIST_LAYOUT = android.R.layout.simple_list_item_1;
private static final int LIST_LAYOUT = // android.R.layout.simple_list_item_1;
// android.R.layout.select_dialog_item;
R.layout.select_dialog_item;
private static int s_lang = -1;
private String[] m_words;

View file

@ -169,6 +169,12 @@ public class Utils {
setText( activity, id, str );
}
public static void setEnabled( Dialog dialog, int id, boolean enabled )
{
View view = dialog.findViewById( id );
view.setEnabled( enabled );
}
public static boolean getChecked( Activity activity, int id )
{
CheckBox cbx = (CheckBox)activity.findViewById( id );

View file

@ -38,9 +38,9 @@ extern "C" {
#define MAX_PASSES 2 /* how many times can all players pass? */
/****************************** prototypes ******************************/
typedef void (*MovePrintFuncPre)(ModelCtxt*, XP_U16, StackEntry*, void*);
typedef void (*MovePrintFuncPost)(ModelCtxt*, XP_U16, StackEntry*, XP_S16,
void*);
typedef void (*MovePrintFuncPre)(ModelCtxt*, XP_U16, const StackEntry*, void*);
typedef void (*MovePrintFuncPost)(ModelCtxt*, XP_U16, const StackEntry*,
XP_S16, void*);
static void incrPendingTileCountAt( ModelCtxt* model, XP_U16 col,
XP_U16 row );
@ -61,9 +61,10 @@ static void setModelTileRaw( ModelCtxt* model, XP_U16 col, XP_U16 row,
static void assignPlayerTiles( ModelCtxt* model, XP_S16 turn,
const TrayTileSet* tiles );
static void makeTileTrade( ModelCtxt* model, XP_S16 player,
TrayTileSet* oldTiles, TrayTileSet* newTiles );
const TrayTileSet* oldTiles,
const TrayTileSet* newTiles );
static XP_S16 commitTurn( ModelCtxt* model, XP_S16 turn,
TrayTileSet* newTiles, XWStreamCtxt* stream,
const TrayTileSet* newTiles, XWStreamCtxt* stream,
WordNotifierInfo* wni, XP_Bool useStack );
static void buildModelFromStack( ModelCtxt* model, StackCtxt* stack,
XP_Bool useStack, XP_U16 initial,
@ -143,7 +144,8 @@ model_makeFromStream( MPFORMAL XWStreamCtxt* stream, DictionaryCtxt* dict,
buildModelFromStack( model, model->vol.stack, XP_FALSE, 0,
(XWStreamCtxt*)NULL, (WordNotifierInfo*)NULL,
(MovePrintFuncPre)NULL, (MovePrintFuncPost)NULL, NULL );
(MovePrintFuncPre)NULL, (MovePrintFuncPost)NULL,
NULL );
for ( i = 0; i < model->nPlayers; ++i ) {
loadPlayerCtxt( stream, version, &model->players[i] );
@ -249,6 +251,53 @@ model_destroy( ModelCtxt* model )
XP_FREE( model->vol.mpool, model );
} /* model_destroy */
static void
modelAddEntry( ModelCtxt* model, XP_U16 indx, const StackEntry* entry,
XP_Bool useStack, XWStreamCtxt* stream,
WordNotifierInfo* wni, MovePrintFuncPre mpf_pre,
MovePrintFuncPost mpf_post, void* closure )
{
XP_S16 moveScore = 0; /* keep compiler happy */
if ( !!mpf_pre ) {
(*mpf_pre)( model, indx, entry, closure );
}
switch ( entry->moveType ) {
case MOVE_TYPE:
model_makeTurnFromMoveInfo( model, entry->playerNum,
&entry->u.move.moveInfo);
moveScore = commitTurn( model, entry->playerNum,
&entry->u.move.newTiles,
stream, wni, useStack );
break;
case TRADE_TYPE:
makeTileTrade( model, entry->playerNum, &entry->u.trade.oldTiles,
&entry->u.trade.newTiles );
break;
case ASSIGN_TYPE:
assignPlayerTiles( model, entry->playerNum,
&entry->u.assign.tiles );
break;
case PHONY_TYPE: /* nothing to add */
model_makeTurnFromMoveInfo( model, entry->playerNum,
&entry->u.phony.moveInfo);
/* do something here to cause it to print */
(void)getCurrentMoveScoreIfLegal( model, entry->playerNum, stream,
wni, &moveScore );
moveScore = 0;
model_resetCurrentTurn( model, entry->playerNum );
break;
default:
XP_ASSERT(0);
}
if ( !!mpf_post ) {
(*mpf_post)( model, indx, entry, moveScore, closure );
}
} /* modelAddEntry */
static void
buildModelFromStack( ModelCtxt* model, StackCtxt* stack, XP_Bool useStack,
XP_U16 initial, XWStreamCtxt* stream,
@ -257,48 +306,10 @@ buildModelFromStack( ModelCtxt* model, StackCtxt* stack, XP_Bool useStack,
{
StackEntry entry;
XP_U16 ii;
XP_S16 moveScore = 0; /* keep compiler happy */
for ( ii = initial; stack_getNthEntry( stack, ii, &entry ); ++ii ) {
if ( !!mpf_pre ) {
(*mpf_pre)( model, ii, &entry, closure );
}
switch ( entry.moveType ) {
case MOVE_TYPE:
model_makeTurnFromMoveInfo( model, entry.playerNum,
&entry.u.move.moveInfo);
moveScore = commitTurn( model, entry.playerNum,
&entry.u.move.newTiles,
stream, wni, useStack );
break;
case TRADE_TYPE:
makeTileTrade( model, entry.playerNum, &entry.u.trade.oldTiles,
&entry.u.trade.newTiles );
break;
case ASSIGN_TYPE:
assignPlayerTiles( model, entry.playerNum,
&entry.u.assign.tiles );
break;
case PHONY_TYPE: /* nothing to add */
model_makeTurnFromMoveInfo( model, entry.playerNum,
&entry.u.phony.moveInfo);
/* do something here to cause it to print */
(void)getCurrentMoveScoreIfLegal( model, entry.playerNum, stream,
wni, &moveScore );
moveScore = 0;
model_resetCurrentTurn( model, entry.playerNum );
break;
default:
XP_ASSERT(0);
}
if ( !!mpf_post ) {
(*mpf_post)( model, ii, &entry, moveScore, closure );
}
modelAddEntry( model, ii, &entry, useStack, stream, wni,
mpf_pre, mpf_post, closure );
}
} /* buildModelFromStack */
@ -789,7 +800,7 @@ model_undoLatestMoves( ModelCtxt* model, PoolContext* pool,
while ( nMovesUndone-- ) {
/* undo isn't enough here: pool's got tiles in it!! */
XP_ASSERT( 0 );
stack_redo( stack );
(void)stack_redo( stack, NULL );
}
}
@ -1401,7 +1412,7 @@ putBackOtherPlayersTiles( ModelCtxt* model, XP_U16 notMyTurn,
* in their trays.
*/
static XP_S16
commitTurn( ModelCtxt* model, XP_S16 turn, TrayTileSet* newTiles,
commitTurn( ModelCtxt* model, XP_S16 turn, const TrayTileSet* newTiles,
XWStreamCtxt* stream, WordNotifierInfo* wni, XP_Bool useStack )
{
XP_U16 ii;
@ -1409,7 +1420,7 @@ commitTurn( ModelCtxt* model, XP_S16 turn, TrayTileSet* newTiles,
PendingTile* pt;
XP_S16 score;
XP_Bool inLine, isHorizontal;
Tile* newTilesP;
const Tile* newTilesP;
XP_U16 nTiles;
nTiles = newTiles->nTiles;
@ -1495,8 +1506,8 @@ model_commitTurn( ModelCtxt* model, XP_S16 turn, TrayTileSet* newTiles )
* in-place change.
*/
static void
makeTileTrade( ModelCtxt* model, XP_S16 player, TrayTileSet* oldTiles,
TrayTileSet* newTiles )
makeTileTrade( ModelCtxt* model, XP_S16 player, const TrayTileSet* oldTiles,
const TrayTileSet* newTiles )
{
XP_U16 i;
XP_U16 nTiles;
@ -1755,7 +1766,7 @@ typedef struct MovePrintClosure {
} MovePrintClosure;
static void
printMovePre( ModelCtxt* model, XP_U16 XP_UNUSED(moveN), StackEntry* entry,
printMovePre( ModelCtxt* model, XP_U16 XP_UNUSED(moveN), const StackEntry* entry,
void* p_closure )
{
XWStreamCtxt* stream;
@ -1779,7 +1790,7 @@ printMovePre( ModelCtxt* model, XP_U16 XP_UNUSED(moveN), StackEntry* entry,
XP_UCHAR letter[2] = {'\0','\0'};
XP_Bool isHorizontal = entry->u.move.moveInfo.isHorizontal;
XP_U16 col, row;
MoveInfo* mi;
const MoveInfo* mi;
XP_Bool isPass = XP_FALSE;
if ( entry->moveType == PHONY_TYPE ) {
@ -1827,8 +1838,9 @@ printMovePre( ModelCtxt* model, XP_U16 XP_UNUSED(moveN), StackEntry* entry,
} /* printMovePre */
static void
printMovePost( ModelCtxt* model, XP_U16 XP_UNUSED(moveN), StackEntry* entry,
XP_S16 XP_UNUSED(score), void* p_closure )
printMovePost( ModelCtxt* model, XP_U16 XP_UNUSED(moveN),
const StackEntry* entry, XP_S16 XP_UNUSED(score),
void* p_closure )
{
MovePrintClosure* closure = (MovePrintClosure*)p_closure;
XWStreamCtxt* stream = closure->stream;
@ -1839,7 +1851,7 @@ printMovePost( ModelCtxt* model, XP_U16 XP_UNUSED(moveN), StackEntry* entry,
XP_UCHAR buf[100];
XP_UCHAR traybuf1[MAX_TRAY_TILES+1];
XP_UCHAR traybuf2[MAX_TRAY_TILES+1];
MoveInfo* mi;
const MoveInfo* mi;
if ( entry->moveType == ASSIGN_TYPE ) {
return;
@ -2112,12 +2124,19 @@ model_listWordsThrough( ModelCtxt* model, XP_U16 col, XP_U16 row,
{
XP_ASSERT( !!stream );
StackCtxt* stack = model->vol.stack;
StackCtxt* tmpStack = stack_copy( stack );
XP_U16 nEntriesBefore = stack_getNEntries( stack );
XP_U16 nEntriesAfter;
XP_U16 nPlayers = model->nPlayers;
XP_U16 nEntries = stack_getNEntries( stack ) - nPlayers; /* skip assignments */
/* Loop until we undo the move that placed the tile. */
while ( model_undoLatestMoves( model, NULL, 1, NULL, NULL ) ) {
if ( 0 != (TILE_EMPTY_BIT & getModelTileRaw( model, col, row ) ) ) {
break;
}
}
if ( model_undoLatestMoves( model, NULL, nEntries, NULL, NULL ) ) {
nEntriesAfter = stack_getNEntries( stack );
XP_ASSERT( nEntriesAfter < nEntriesBefore );
if ( nEntriesAfter < nEntriesBefore ) {
ListWordsThroughInfo lwtInfo = { .stream = stream, .col = col,
.row = row, .nWords = 0,
};
@ -2125,12 +2144,17 @@ model_listWordsThrough( ModelCtxt* model, XP_U16 col, XP_U16 row,
/* Now push the undone moves back into the model one at a time.
recordWord() will add each played word to the stream as it's
scored */
buildModelFromStack( model, tmpStack, XP_TRUE, nPlayers,
(XWStreamCtxt*)NULL, &ni, (MovePrintFuncPre)NULL,
(MovePrintFuncPost)NULL, NULL );
while ( nEntriesAfter < nEntriesBefore ) {
StackEntry entry;
if ( ! stack_redo( stack, &entry ) ) {
XP_ASSERT( 0 );
break;
}
modelAddEntry( model, nEntriesAfter++, &entry, XP_FALSE, NULL, &ni,
NULL, NULL, NULL );
}
}
stack_destroy( tmpStack );
}
} /* model_listWordsThrough */
#endif
XP_Bool

View file

@ -265,8 +265,8 @@ readEntry( StackCtxt* stack, StackEntry* entry )
} /* readEntry */
void
stack_addMove( StackCtxt* stack, XP_U16 turn, MoveInfo* moveInfo,
TrayTileSet* newTiles )
stack_addMove( StackCtxt* stack, XP_U16 turn, const MoveInfo* moveInfo,
const TrayTileSet* newTiles )
{
StackEntry move;
@ -387,14 +387,19 @@ stack_popEntry( StackCtxt* stack, StackEntry* entry )
return found;
} /* stack_popEntry */
void
stack_redo( StackCtxt* stack )
XP_Bool
stack_redo( StackCtxt* stack, StackEntry* entry )
{
if( (stack->nEntries + 1) <= stack->highWaterMark ) {
XP_Bool canRedo = (stack->nEntries + 1) <= stack->highWaterMark;
if ( canRedo ) {
++stack->nEntries;
if ( NULL != entry ) {
stack_getNthEntry( stack, stack->nEntries-1, entry );
}
setCacheReadyFor( stack, stack->nEntries );
stack->top = stack->cachedPos;
}
return canRedo;
} /* stack_redo */
#ifdef CPLUS

View file

@ -75,8 +75,8 @@ void stack_loadFromStream( StackCtxt* stack, XWStreamCtxt* stream );
void stack_writeToStream( const StackCtxt* stack, XWStreamCtxt* stream );
StackCtxt* stack_copy( const StackCtxt* stack );
void stack_addMove( StackCtxt* stack, XP_U16 turn, MoveInfo* moveInfo,
TrayTileSet* newTiles );
void stack_addMove( StackCtxt* stack, XP_U16 turn, const MoveInfo* moveInfo,
const TrayTileSet* newTiles );
void stack_addPhony( StackCtxt* stack, XP_U16 turn, MoveInfo* moveInfo );
void stack_addTrade( StackCtxt* stack, XP_U16 turn,
TrayTileSet* oldTiles, TrayTileSet* newTiles );
@ -88,8 +88,8 @@ XP_U16 stack_getNEntries( StackCtxt* stack );
XP_Bool stack_getNthEntry( StackCtxt* stack, XP_U16 n, StackEntry* entry );
XP_Bool stack_popEntry( StackCtxt* stack, StackEntry* entry );
void stack_redo( StackCtxt* stack );
XP_Bool stack_redo( StackCtxt* stack, StackEntry* entry );
#ifdef CPLUS
}
#endif

View file

@ -2381,11 +2381,11 @@ sendUndoToClientsExcept( ServerCtxt* server, XP_U16 skip,
}
} /* sendUndoToClientsExcept */
/* This is unused on Android where I've disabled undo in networked games. */
static XP_Bool
reflectUndos( ServerCtxt* server, XWStreamCtxt* stream, XW_Proto code )
{
XP_U16 nUndone, lastUndone;
XP_S16 moveNum;
XP_U16 turn;
ModelCtxt* model = server->vol.model;
XP_Bool success = XP_TRUE;
@ -2393,13 +2393,9 @@ reflectUndos( ServerCtxt* server, XWStreamCtxt* stream, XW_Proto code )
nUndone = stream_getU16( stream );
lastUndone = stream_getU16( stream );
moveNum = lastUndone + nUndone - 1;
success = model_undoLatestMoves(model, server->pool, nUndone, &turn,
&moveNum);
success = model_undoLatestMoves( model, server->pool, nUndone, &turn,
NULL );
if ( success ) {
XP_ASSERT( moveNum == lastUndone );
if ( code == XWPROTO_UNDO_INFO_CLIENT ) { /* need to inform */
XP_U16 sourceClientIndex =

View file

@ -1725,7 +1725,8 @@ static void
gtk_util_cellSquareHeld( XW_UtilCtxt* uc, XWStreamCtxt* words )
{
XP_USE( uc );
XP_USE( words );
catOnClose( words, NULL );
fprintf( stderr, "\n" );
}
#endif