From 8b90f211ed8519a7d92b92afe39b62f18ac28c34 Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 5 Aug 2015 07:18:22 -0700 Subject: [PATCH 1/7] progress: compares english and other languages use of format specifiers, but I think is missing mismatches in plurals still. --- xwords4/android/scripts/check_strings.py | 62 ++++++++++++++++-------- 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/xwords4/android/scripts/check_strings.py b/xwords4/android/scripts/check_strings.py index 563b6939f..d9aa06e94 100755 --- a/xwords4/android/scripts/check_strings.py +++ b/xwords4/android/scripts/check_strings.py @@ -4,6 +4,7 @@ import re, sys, os, getopt from lxml import etree g_formats = {} +g_verbose = 0 def usage(msg=''): print @@ -20,8 +21,6 @@ def associate( formats, name, fmt ): else: forName = set() formats[name] = forName - if fmt in forName: - print "Warning: %s duplicated in %s" % (fmt, name) forName.add(fmt) # print 'added', fmt, 'to', name @@ -40,39 +39,64 @@ def checkFormats( formats ): if not foundDigit: break if curSet == testSet: - print name, "is ok" + if 0 < g_verbose: print name, "is ok" else: - print 'ERROR: sets different for', name, curSet, testSet + print 'WARNING: sets different for', name, curSet, testSet + +def checkLangFormats( engData, langData, lang ): + for key in langData: + if not key in engData: + print 'WARNING: key', key, 'in', lang, 'but not in English' + elif not engData[key] == langData[key]: + print 'ERROR: set mismatch', key, 'from', lang, engData[key], 'vs', langData[key] sys.exit(1) +def getForElem( data, pat, elem, name ): + splits = re.split( pat, elem.text ) + nParts = len(splits) + if 1 < nParts: + for ii in range(nParts): + part = splits[ii] + if re.match( pat, part ): + associate( data, name, part ) + +def getFormats( doc, pat, lang ): + result = {} + for elem in doc.findall('string'): + getForElem( result, pat, elem, elem.get('name') ) + for elem in doc.findall('plurals'): + name = elem.get('name') + for elem in elem.findall('item'): + quantity = elem.get('quantity') + if not elem.text or 0 == len(elem.text): + print 'plurals', name, 'has empty quantity', quantity, \ + 'in file', lang + sys.exit(1) + else: + getForElem( result, pat, elem, name + '/' + quantity ) + return result + def main(): if 1 < len(sys.argv): usage() + parser = etree.XMLParser(remove_blank_text=True, encoding="utf-8") wd = os.path.dirname(sys.argv[0]) - path = wd + '/../XWords4/res/values/strings.xml' # Load English - engFormats = {} - parser = etree.XMLParser(remove_blank_text=True, encoding="utf-8") + path = wd + '/../XWords4/res/values/strings.xml' doc = etree.parse(path, parser) pat = re.compile( '(%\d\$[sd])', re.DOTALL | re.MULTILINE ) - for typ in ['string', 'item']: - for elem in doc.findall(typ): - splits = re.split( pat, elem.text ) - nParts = len(splits) - if 1 < nParts: - for ii in range(nParts): - part = splits[ii] - if re.match( pat, part ): - associate( engFormats, elem.get('name'), part ) + engFormats = getFormats( doc, pat, 'en' ) checkFormats( engFormats ) + path = wd + '/../XWords4/res_src' for subdir, dirs, files in os.walk(path): for file in [file for file in files if file == "strings.xml" \ and not subdir.endswith('/values')]: - print file, subdir - - + doc = etree.parse( subdir + '/' + file, parser ) + forLang = getFormats( doc, pat, subdir ) + checkLangFormats( engFormats, forLang, subdir ) + sys.exit(0) ############################################################################## if __name__ == '__main__': From 87e3108296439e8916a2ae9093b44f4af17fd17c Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 10 Aug 2015 06:23:24 -0700 Subject: [PATCH 2/7] cleanup: make work based on location if target not specified --- xwords4/android/scripts/cleanvariants.sh | 38 +++++++++++++++--------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/xwords4/android/scripts/cleanvariants.sh b/xwords4/android/scripts/cleanvariants.sh index 14351deae..c18fd98bc 100755 --- a/xwords4/android/scripts/cleanvariants.sh +++ b/xwords4/android/scripts/cleanvariants.sh @@ -2,25 +2,21 @@ set -u -e -DIRS="" -VARIANT="" +DIR="" usage() { [ $# -ge 1 ] && echo "ERROR: $1" - echo "usage: $0 [--dest-dir ]*" + echo "usage: $0 [--dir ]" + echo " uses variant parent of CWD as default if not provided" exit 1 } while [ $# -ge 1 ]; do echo "\"$1\"" case $1 in - --variant-name) + --dir) shift - VARIANT=$1 - ;; - --dest-dir) - shift - DIRS="$DIRS $1" + DIR="$DIR $1" ;; *) usage "unexpected param $1" @@ -29,12 +25,26 @@ while [ $# -ge 1 ]; do shift done -for DIR in $DIRS; do - for FILE in $(find $DIR -type f); do - if git ls-files $FILE --error-unmatch 2>/dev/null; then - echo "skipping $FILE; it's under version control within this variant" +if [ -z "$DIR" ]; then + while :; do + WD=$(pwd) + if [ "/" = "$WD" ]; then + echo "reached / without finding AndroidManifest.xml" + exit 1 + elif [ -e ${WD}/AndroidManifest.xml ]; then + DIR=$WD + break else - rm $FILE + cd .. fi done +fi + +for FILE in $(find $DIR -type f); do + if git ls-files $FILE --error-unmatch 2>/dev/null; then + echo "skipping $FILE; it's under version control within this variant" + else + echo "removing $FILE" + rm $FILE + fi done From 517cfe6fdaa5a6b9c44493e2e87387ef181af883 Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 10 Aug 2015 06:24:40 -0700 Subject: [PATCH 3/7] bring over saved file format change from relay_conn branch so builds from each will be able to open each other's files. --- xwords4/common/comms.c | 11 +++++------ xwords4/common/comtypes.h | 3 ++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/xwords4/common/comms.c b/xwords4/common/comms.c index 3151305ab..a3c2de639 100644 --- a/xwords4/common/comms.c +++ b/xwords4/common/comms.c @@ -632,7 +632,8 @@ comms_makeFromStream( MPFORMAL XWStreamCtxt* stream, XW_UtilCtxt* util, isServer = stream_getU8( stream ); addrFromStream( &addr, stream ); - if ( addr_hasType( &addr, COMMS_CONN_RELAY ) ) { + if ( version >= STREAM_VERS_DEVIDS + || addr_hasType( &addr, COMMS_CONN_RELAY ) ) { nPlayersHere = (XP_U16)stream_getBits( stream, 4 ); nPlayersTotal = (XP_U16)stream_getBits( stream, 4 ); } else { @@ -846,10 +847,8 @@ comms_writeToStream( CommsCtxt* comms, XWStreamCtxt* stream, stream_putU8( stream, (XP_U8)comms->isServer ); logAddr( comms, &comms->addr, __func__ ); addrToStream( stream, &comms->addr ); - if ( addr_hasType( &comms->addr, COMMS_CONN_RELAY ) ) { - stream_putBits( stream, 4, comms->rr.nPlayersHere ); - stream_putBits( stream, 4, comms->rr.nPlayersTotal ); - } + stream_putBits( stream, 4, comms->rr.nPlayersHere ); + stream_putBits( stream, 4, comms->rr.nPlayersTotal ); stream_putU32( stream, comms->connID ); stream_putU16( stream, comms->nextChannelNo ); @@ -1051,7 +1050,7 @@ comms_getConTypes( const CommsCtxt* comms ) XP_LOGF( "%s: returning COMMS_CONN_NONE for null comms", __func__ ); } return typ; -} /* comms_getConType */ +} /* comms_getConTypes */ XP_Bool comms_getIsServer( const CommsCtxt* comms ) diff --git a/xwords4/common/comtypes.h b/xwords4/common/comtypes.h index 094ddcbab..cca8f4476 100644 --- a/xwords4/common/comtypes.h +++ b/xwords4/common/comtypes.h @@ -47,6 +47,7 @@ #endif #define MAX_COLS MAX_ROWS +#define STREAM_VERS_DEVIDS 0x19 #define STREAM_VERS_MULTIADDR 0x18 #define STREAM_VERS_MODELDIVIDER 0x17 #define STREAM_VERS_COMMSBACKOFF 0x16 @@ -86,7 +87,7 @@ #define STREAM_VERS_405 0x01 /* search for FIX_NEXT_VERSION_CHANGE next time this is changed */ -#define CUR_STREAM_VERS STREAM_VERS_MULTIADDR +#define CUR_STREAM_VERS STREAM_VERS_DEVIDS typedef struct XP_Rect { XP_S16 left; From 2ef407320e1cc195020108fb37a9bff49fea1c54 Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 10 Aug 2015 06:43:19 -0700 Subject: [PATCH 4/7] pick package based on location --- xwords4/android/scripts/adb-uninstall.sh | 43 +++++++++++++----------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/xwords4/android/scripts/adb-uninstall.sh b/xwords4/android/scripts/adb-uninstall.sh index 9febf604e..4c5b38f37 100755 --- a/xwords4/android/scripts/adb-uninstall.sh +++ b/xwords4/android/scripts/adb-uninstall.sh @@ -3,35 +3,37 @@ set -e -u INDEX=0 +DRYRUN='' usage() { - echo "usage: $0 [--help] [-n ]" + [ $# -gt 0 ] && echo "ERROR: $1" + echo "usage: $0 [--dry-run] [--help] [-n ]" echo "uninstall crosswords from the th device" exit 0 } -if [ ! -e build.xml ]; then - usage "No build.xml; please run me from the top android directory" -fi +while :; do + WD=$(pwd) + if [ -e ${WD}/AndroidManifest.xml ]; then + break + elif [ ${WD} = '/' ]; then + usage "reached / without finding AndroidManifest.xml" + else + cd .. + fi +done -DIRNAME=$(basename $(pwd)) -case $DIRNAME in - XWords4-bt) - PKG=xw4bt - ;; - XWords4-dbg) - PKG=xw4dbg - ;; - XWords4) - PKG=xw4 - ;; - *) - usage "running in unexpected directory $DIRNAME" - ;; -esac +PACK=$(grep 'package=\".*\..*\.*\"' ${WD}/AndroidManifest.xml | sed 's,^.*package="\(.*\)".*$,\1,') + +if [ -z "${PACK}" ]; then + usage "unable to find package in ${WD}/AndroidManifest.xml" +fi while [ $# -ge 1 ]; do case $1 in + --dry-run) + DRYRUN=1 + ;; -n) shift INDEX=$1 @@ -44,4 +46,5 @@ done SERIAL="$(adb devices | grep 'device$' | sed -n "$((1+INDEX)) p" | awk '{print $1}')" -adb -s $SERIAL uninstall org.eehouse.android.${PKG} +echo "adb -s $SERIAL uninstall $PACK" +[ -z "$DRYRUN" ] && adb -s $SERIAL uninstall $PACK From c3aeefe706c6f3faa7b4e8b05accadbd4ced03c0 Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 10 Aug 2015 06:52:19 -0700 Subject: [PATCH 5/7] bring over changes for permissions etc --- .../android/XWords4-dbg/AndroidManifest.xml | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/xwords4/android/XWords4-dbg/AndroidManifest.xml b/xwords4/android/XWords4-dbg/AndroidManifest.xml index 6738f6632..9bc099a03 100644 --- a/xwords4/android/XWords4-dbg/AndroidManifest.xml +++ b/xwords4/android/XWords4-dbg/AndroidManifest.xml @@ -45,8 +45,10 @@ - + + + - @@ -120,7 +125,8 @@ - @@ -216,15 +219,22 @@ - - - + + + + + + + + + + - + From 1d14d4cc6569931fd4e7e3bc4d2912be97e62b0b Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 10 Aug 2015 06:52:31 -0700 Subject: [PATCH 6/7] ignore new files --- xwords4/android/XWords4-dbg/assets/.gitignore | 1 + xwords4/android/XWords4-dbg/img_src/.gitignore | 4 ++++ .../android/XWords4-dbg/res/drawable-hdpi/.gitignore | 4 ++++ .../android/XWords4-dbg/res/drawable-mdpi/.gitignore | 4 ++++ .../android/XWords4-dbg/res/drawable-xhdpi/.gitignore | 4 ++++ xwords4/android/XWords4-dbg/res/layout/.gitignore | 6 ++++++ .../src/org/eehouse/android/xw4dbg/.gitignore | 10 ++++++++++ .../src/org/eehouse/android/xw4dbg/jni/.gitignore | 1 + 8 files changed, 34 insertions(+) diff --git a/xwords4/android/XWords4-dbg/assets/.gitignore b/xwords4/android/XWords4-dbg/assets/.gitignore index e9a786d8d..7926bc1b2 100644 --- a/xwords4/android/XWords4-dbg/assets/.gitignore +++ b/xwords4/android/XWords4-dbg/assets/.gitignore @@ -1,3 +1,4 @@ BasEnglish2to8.xwd CollegeEng_2to8.xwd Top5000.xwd +changes.html diff --git a/xwords4/android/XWords4-dbg/img_src/.gitignore b/xwords4/android/XWords4-dbg/img_src/.gitignore index 06f44c2c1..177ab2ad1 100644 --- a/xwords4/android/XWords4-dbg/img_src/.gitignore +++ b/xwords4/android/XWords4-dbg/img_src/.gitignore @@ -19,3 +19,7 @@ up.svg clear_all.svg search.svg select_all.svg +content_new_net.svg +content_new_solo.svg +multigame.svg +sologame.svg diff --git a/xwords4/android/XWords4-dbg/res/drawable-hdpi/.gitignore b/xwords4/android/XWords4-dbg/res/drawable-hdpi/.gitignore index 597eff2ad..5fb73cd78 100644 --- a/xwords4/android/XWords4-dbg/res/drawable-hdpi/.gitignore +++ b/xwords4/android/XWords4-dbg/res/drawable-hdpi/.gitignore @@ -20,3 +20,7 @@ up__gen.png clear_all__gen.png search__gen.png select_all__gen.png +content_new_net__gen.png +content_new_solo__gen.png +multigame__gen.png +sologame__gen.png diff --git a/xwords4/android/XWords4-dbg/res/drawable-mdpi/.gitignore b/xwords4/android/XWords4-dbg/res/drawable-mdpi/.gitignore index 597eff2ad..5fb73cd78 100644 --- a/xwords4/android/XWords4-dbg/res/drawable-mdpi/.gitignore +++ b/xwords4/android/XWords4-dbg/res/drawable-mdpi/.gitignore @@ -20,3 +20,7 @@ up__gen.png clear_all__gen.png search__gen.png select_all__gen.png +content_new_net__gen.png +content_new_solo__gen.png +multigame__gen.png +sologame__gen.png diff --git a/xwords4/android/XWords4-dbg/res/drawable-xhdpi/.gitignore b/xwords4/android/XWords4-dbg/res/drawable-xhdpi/.gitignore index 597eff2ad..5fb73cd78 100644 --- a/xwords4/android/XWords4-dbg/res/drawable-xhdpi/.gitignore +++ b/xwords4/android/XWords4-dbg/res/drawable-xhdpi/.gitignore @@ -20,3 +20,7 @@ up__gen.png clear_all__gen.png search__gen.png select_all__gen.png +content_new_net__gen.png +content_new_solo__gen.png +multigame__gen.png +sologame__gen.png diff --git a/xwords4/android/XWords4-dbg/res/layout/.gitignore b/xwords4/android/XWords4-dbg/res/layout/.gitignore index 9d7a90a0d..03ac4e859 100644 --- a/xwords4/android/XWords4-dbg/res/layout/.gitignore +++ b/xwords4/android/XWords4-dbg/res/layout/.gitignore @@ -37,3 +37,9 @@ loc_main.xml loc_item_edit.xml import_dict_item.xml list_group.xml +conn_types_display.xml +expander_header.xml +msg_label_and_edit.xml +not_again_view.xml +remote_dict_details.xml +toolbar.xml diff --git a/xwords4/android/XWords4-dbg/src/org/eehouse/android/xw4dbg/.gitignore b/xwords4/android/XWords4-dbg/src/org/eehouse/android/xw4dbg/.gitignore index 4fa4ac2ec..1a3815e06 100644 --- a/xwords4/android/XWords4-dbg/src/org/eehouse/android/xw4dbg/.gitignore +++ b/xwords4/android/XWords4-dbg/src/org/eehouse/android/xw4dbg/.gitignore @@ -111,3 +111,13 @@ DwnldActivity.java DwnldDelegate.java GroupStateListener.java ListGroup.java +ConnViaViewLayout.java +Delegator.java +HeaderWithExpander.java +LangListPreference.java +ListDelegator.java +NagTurnReceiver.java +NotAgainView.java +OnBootReceiver.java +XWConnAddrPreference.java +XWExpListAdapter.java diff --git a/xwords4/android/XWords4-dbg/src/org/eehouse/android/xw4dbg/jni/.gitignore b/xwords4/android/XWords4-dbg/src/org/eehouse/android/xw4dbg/jni/.gitignore index 37a3f31cb..025de6a24 100644 --- a/xwords4/android/XWords4-dbg/src/org/eehouse/android/xw4dbg/jni/.gitignore +++ b/xwords4/android/XWords4-dbg/src/org/eehouse/android/xw4dbg/jni/.gitignore @@ -16,3 +16,4 @@ UtilCtxtImpl.java UtilCtxt.java XwJNI.java BoardDims.java +LastMoveInfo.java From 00e6a80fb0ec4f39aee762122728cb83845a03cb Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 10 Aug 2015 07:07:33 -0700 Subject: [PATCH 7/7] fix permission and other constants that need to be different in variant --- xwords4/android/XWords4-dbg/AndroidManifest.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xwords4/android/XWords4-dbg/AndroidManifest.xml b/xwords4/android/XWords4-dbg/AndroidManifest.xml index 9bc099a03..381e8e344 100644 --- a/xwords4/android/XWords4-dbg/AndroidManifest.xml +++ b/xwords4/android/XWords4-dbg/AndroidManifest.xml @@ -56,9 +56,9 @@ - - + @@ -247,7 +247,7 @@ - +