Merge branch 'android_branch' into android_translate

This commit is contained in:
Eric House 2015-07-28 20:35:30 -07:00
commit 5bf674ca76
13 changed files with 79 additions and 12 deletions

View file

@ -2435,6 +2435,7 @@ public final class R {
placed, i.e. they do not form a single word.
*/
public static final int str_no_empties_in_turn=0x7f05017d;
public static final int str_no_hint_found=0x7f05030a;
/** Same as above, but used when you try to show tiles belonging
to a player on another device (a remote player.)
*/

View file

@ -2529,4 +2529,6 @@
<string name="not_again_comms_bt">Use Bluetooth to play against a
nearby device that\'s \"paired\" with yours.</string>
<string name="str_no_hint_found">Cannot find any moves</string>
</resources>

View file

@ -2178,4 +2178,5 @@
i.e. yreve reirrac ni eht dlrow tpecxe Nozirev dna Tnirps.</string>
<string name="not_again_comms_bt">Esu Htooteulb ot yalp tsniaga a
ybraen ecived taht\'s \"deriap\" htiw sruoy.</string>
<string name="str_no_hint_found">Tonnac dnif yna sevom</string>
</resources>

View file

@ -2178,4 +2178,5 @@
I.E. EVERY CARRIER IN THE WORLD EXCEPT VERIZON AND SPRINT.</string>
<string name="not_again_comms_bt">USE BLUETOOTH TO PLAY AGAINST A
NEARBY DEVICE THAT\'S \"PAIRED\" WITH YOURS.</string>
<string name="str_no_hint_found">CANNOT FIND ANY MOVES</string>
</resources>

View file

@ -1719,6 +1719,7 @@ public class BoardDelegate extends DelegateBase
public void userError( int code )
{
int resid = 0;
boolean asToast = false;
switch( code ) {
case UtilCtxt.ERR_TILES_NOT_IN_LINE:
resid = R.string.str_tiles_not_in_line;
@ -1764,10 +1765,23 @@ public class BoardDelegate extends DelegateBase
case ERR_REG_SERVER_SANS_REMOTE:
resid = R.string.str_reg_server_sans_remote;
break;
case ERR_NO_HINT_FOUND:
resid = R.string.str_no_hint_found;
asToast = true;
break;
}
if ( resid != 0 ) {
nonBlockingDialog( DlgID.DLG_OKONLY, getString( resid ) );
if ( asToast ) {
final int residf = resid;
runOnUiThread( new Runnable() {
public void run() {
showToast( residf );
}
} );
} else {
nonBlockingDialog( DlgID.DLG_OKONLY, getString( resid ) );
}
}
} // userError

View file

@ -1598,6 +1598,7 @@ public class GamesListDelegate extends ListDelegateBase
for ( long row : rows ) {
m_selGames.remove( row );
}
invalidateOptionsMenuIf();
setTitleBar();
}
}

View file

@ -125,7 +125,9 @@ public interface UtilCtxt {
static final int ERR_NO_EMPTY_TRADE = 13;
static final int ERR_CANT_UNDO_TILEASSIGN = 14;
static final int ERR_CANT_HINT_WHILE_DISABLED = 15;
static final int ERR_RELAY_BASE = 16;
static final int ERR_NO_HINT_FOUND = 16;
static final int ERR_RELAY_BASE = 17;
void userError( int id );
void informMove( String expl, String words );

View file

@ -110,4 +110,16 @@
</exec>
</target>
<target name="-post-build" >
<if condition="${build.is.packaging.debug}">
<then>
<exec executable="git" outputproperty="git-rev" >
<arg value="describe" />
</exec>
<copy file="bin/XWords4-debug.apk" tofile="XWords4-debug-${git-rev}.apk"/>
<echo>Created XWords4-debug-${git-rev}.apk</echo>
</then>
</if>
</target>
</project>

View file

@ -1,7 +1,7 @@
#!/usr/bin/python
# Script meant to be installed on eehouse.org.
import logging, shelve, hashlib, sys, json, subprocess, glob, os, struct, random
import logging, shelve, hashlib, sys, json, subprocess, glob, os, struct, random, string
import mk_for_download, mygit
import xwconfig
@ -161,10 +161,13 @@ def getDictSums():
openShelf()
return s_shelf[k_SUMS]
def getOrderedApks( path ):
def getOrderedApks( path, debug ):
# logging.debug( "getOrderedApks(" + path + ")" )
apks = []
pattern = path + "/XWords4-release_*android_beta_*.apk"
pattern = path
if debug: pattern += "/XWords4-debug-android_*.apk"
else: pattern += "/XWords4-release_*android_beta_*.apk"
files = ((os.stat(apk).st_mtime, apk) for apk in glob.glob(pattern))
for mtime, file in sorted(files, reverse=True):
@ -173,6 +176,14 @@ def getOrderedApks( path ):
return apks
def getVariantDir( name ):
result = ''
splits = string.split( name, '.' )
last = splits[-1]
if not last == 'xw4': result = last + '/'
# logging.debug( 'getVariantDir(' + name + ") => " + result )
return result
# public, but deprecated
def curVersion( req, name, avers = 41, gvers = None, installer = None ):
global k_versions
@ -218,12 +229,22 @@ def getApp( params, name ):
if k_NAME in params:
name = params[k_NAME]
if name:
variantDir = getVariantDir( name )
# If we're a dev device, always push the latest
if k_DEBUG in params and params[k_DEBUG]:
url = k_urlbase + '/' + k_apkDir + 'XWords4-debug.apk'
result = {k_URL: url}
dir = k_filebase + k_apkDir + variantDir
apks = getOrderedApks( dir, True )
if 0 < len(apks):
apk = apks[0]
curApk = params[k_GVERS] + '.apk'
if curApk in apk:
logging.debug( "already have " + curApk )
else:
url = k_urlbase + '/' + k_apkDir + variantDir + apk[len(dir):]
logging.debug("url: " + url)
result = {k_URL: url}
elif k_DEVOK in params and params[k_DEVOK]:
apks = getOrderedApks( k_filebase + k_apkDir )
apks = getOrderedApks( k_filebase + k_apkDir, False )
if 0 < len(apks):
apk = apks[0]
# Does path NOT contain name of installed file
@ -439,7 +460,6 @@ def getUpdates( req, params ):
else:
logging.debug( "NOT FOUND xlate info" )
logging.debug( 'getUpdates done:', )
result = json.dumps( result )
# logging.debug( result )
return result
@ -494,7 +514,7 @@ def main():
if argc >= 4: usage()
path = ""
if argc >= 3: path = sys.argv[2]
apks = getOrderedApks( path )
apks = getOrderedApks( path, False )
if 0 == len(apks): print "No apks in", path
for apk in apks:
print apk

View file

@ -2107,6 +2107,7 @@ board_requestHint( BoardCtxt* board,
if ( searchComplete && canMove ) {
model_makeTurnFromMoveInfo( model, selPlayer, &newMove);
} else {
result = XP_FALSE;
XP_STATUSF( "unable to complete hint request\n" );
}
*workRemainsP = !searchComplete;
@ -2122,6 +2123,10 @@ board_requestHint( BoardCtxt* board,
setArrowVisible( board, wasVisible );
}
}
if ( !result ) {
util_userError( board->util, ERR_NO_HINT_FOUND );
}
}
return result || redraw;
} /* board_requestHint */

View file

@ -393,6 +393,7 @@ engine_findMove( EngineCtxt* engine, const ModelCtxt* model,
{
XP_Bool result = XP_TRUE;
XP_U16 star_row;
XP_Bool canMove = XP_FALSE;
engine->nTilesMax = XP_MIN( MAX_TRAY_TILES, nTiles );
#ifdef XWFEATURE_BONUSALL
@ -445,9 +446,9 @@ engine_findMove( EngineCtxt* engine, const ModelCtxt* model,
dictionary's emtpy or there are no tiles, still return TRUE so we don't
get scheduled again. Fixes infinite loop with empty dict and a
robot. */
*canMoveP = NULL != dict_getTopEdge(engine->dict)
canMove = NULL != dict_getTopEdge(engine->dict)
&& initTray( engine, tiles, nTiles );
if ( *canMoveP ) {
if ( canMove ) {
util_engineStarting( engine->util,
engine->rack[engine->blankTile] );
@ -528,6 +529,7 @@ engine_findMove( EngineCtxt* engine, const ModelCtxt* model,
XP_MEMCPY( newMove, &move->moveInfo, sizeof(*newMove) );
} else {
newMove->nTiles = 0;
canMove = XP_FALSE;
}
result = XP_TRUE;
}
@ -540,6 +542,7 @@ engine_findMove( EngineCtxt* engine, const ModelCtxt* model,
newMove->nTiles = 0;
}
*canMoveP = canMove;
return result;
} /* engine_findMove */

View file

@ -58,6 +58,7 @@ typedef enum {
/* ERR_NOT_YOUR_TURN_TO_MOVE, */
ERR_CANT_UNDO_TILEASSIGN,
ERR_CANT_HINT_WHILE_DISABLED,
ERR_NO_HINT_FOUND, /* not really an error... */
ERR_RELAY_BASE,
ERR_RELAY_END = ERR_RELAY_BASE + XWRELAY_ERROR_LASTERR

View file

@ -492,6 +492,10 @@ linux_getErrString( UtilErrID id, XP_Bool* silent )
message = "No tiles selected; trade cancelled.";
break;
case ERR_NO_HINT_FOUND:
message = "Unable to suggest any moves.";
break;
case ERR_CANT_UNDO_TILEASSIGN:
message = "Tile assignment can't be undone.";
break;