From 2bfe120014cf2cc953759c8f39c4fcc6336e1fd6 Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 23 Nov 2011 18:25:12 -0800 Subject: [PATCH 01/16] do away with need to accept out-of-bounds values in getTileRaw(). --- xwords4/common/model.c | 14 ++++++-------- xwords4/common/mscore.c | 16 +++++++++------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/xwords4/common/model.c b/xwords4/common/model.c index f6fc9fb49..e692c8545 100644 --- a/xwords4/common/model.c +++ b/xwords4/common/model.c @@ -90,7 +90,9 @@ model_make( MPFORMAL DictionaryCtxt* dict, XP_U16 nRows ) { ModelCtxt* result; - XP_U16 size = sizeof(*result) + TILES_SIZE(result, nCols); + XP_U16 size; + XP_ASSERT( nCols == nRows && nCols <= MAX_COLS ); + size = sizeof(*result) + TILES_SIZE(result, nCols); result = (ModelCtxt*)XP_MALLOC( mpool, size ); if ( result != NULL ) { XP_MEMSET( result, 0, sizeof(*result) ); @@ -700,15 +702,11 @@ setModelTileRaw( ModelCtxt* model, XP_U16 col, XP_U16 row, CellTile tile ) static CellTile getModelTileRaw( const ModelCtxt* model, XP_U16 col, XP_U16 row ) { - CellTile tile; XP_U16 nCols = model->nCols; XP_ASSERT( model->nRows == nCols ); - if ( col < nCols && row < nCols ) { - tile = model->tiles[(row*nCols) + col]; - } else { - tile = TILE_EMPTY_BIT; - } - return tile; + XP_ASSERT( col < nCols ); + XP_ASSERT( row < nCols ); + return model->tiles[(row*nCols) + col]; } /* getModelTileRaw */ static void diff --git a/xwords4/common/mscore.c b/xwords4/common/mscore.c index 4077f613c..1131b984a 100644 --- a/xwords4/common/mscore.c +++ b/xwords4/common/mscore.c @@ -318,10 +318,11 @@ static XP_Bool modelIsEmptyAt( const ModelCtxt* model, XP_U16 col, XP_U16 row ) { Tile tile; - XP_Bool found; - - found = model_getTile( model, col, row, XP_FALSE, -1, &tile, - NULL, NULL, NULL ); + XP_U16 nCols = model_numCols( model ); + XP_Bool found = col < nCols + && row < nCols + && model_getTile( model, col, row, XP_FALSE, -1, &tile, + NULL, NULL, NULL ); return !found; } /* modelIsEmptyAt */ @@ -722,11 +723,12 @@ find_end( const ModelCtxt* model, XP_U16 col, XP_U16 row, XP_Bool isHorizontal ) { XP_U16* incr = isHorizontal? &col: &row; - XP_U16 limit = isHorizontal? MAX_COLS-1:MAX_ROWS-1; + XP_U16 nCols = model_numCols( model ); + XP_U16 limit = nCols - 1; XP_U16 lastGood = *incr; - XP_ASSERT( col < MAX_COLS ); - XP_ASSERT( row < MAX_ROWS ); + XP_ASSERT( col < nCols ); + XP_ASSERT( row < nCols ); for ( ; ; ) { XP_ASSERT( *incr <= limit ); From c39487e0ccc9150c606ad7b0a462123377b1ddd9 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 29 Nov 2011 20:51:19 -0800 Subject: [PATCH 02/16] add ability to start out with mix of old and new versions and have old upgrade to new at random times. --- xwords4/linux/scripts/discon_ok2.sh | 49 ++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/xwords4/linux/scripts/discon_ok2.sh b/xwords4/linux/scripts/discon_ok2.sh index f33631893..420cd55da 100755 --- a/xwords4/linux/scripts/discon_ok2.sh +++ b/xwords4/linux/scripts/discon_ok2.sh @@ -16,8 +16,12 @@ MINRUN=2 ONE_PER_ROOM="" ALL_VIA_RQ=${ALL_VIA_RQ:-FALSE} SEED=${SEED:-""} -#BOARD_SIZES=(15 17) -BOARD_SIZES=(15) + +APP_NEW=${APP_NEW:-"./obj_linux_memdbg/xwords"} +APP_OLD=${APP_OLD:-""} + +BOARD_SIZES_OLD=(15) +BOARD_SIZES_NEW=(15 17) declare -a DICTS_ARR for DICT in $DICTS; do @@ -79,7 +83,8 @@ usage() { echo "usage: [env=val *] $0" 1>&2 echo " current env variables and their values: " 1>&2 for VAR in NGAMES NROOMS USE_GTK TIMEOUT HOST PORT DICTS SAVE_GOOD \ - MINDEVS MAXDEVS RESIGN_RATIO DROP_N ALL_VIA_RQ SEED; do + MINDEVS MAXDEVS RESIGN_RATIO DROP_N ALL_VIA_RQ SEED \ + APP_NEW APP_OLD; do echo "$VAR:" $(eval "echo \$${VAR}") 1>&2 done exit 1 @@ -120,6 +125,12 @@ check_room() { fi } +print_cmdline() { + local COUNTER=$1 + local LOG=${LOGS[$COUNTER]} + echo "New cmdline: ${APPS[$COUNTER]} ${ARGS[$COUNTER]}" >> $LOG +} + build_cmds() { COUNTER=0 for GAME in $(seq 1 $NGAMES); do @@ -141,15 +152,26 @@ build_cmds() { for DEV in $(seq $NDEVS); do FILE="${LOGDIR}/GAME_${GAME}_${DEV}.xwg" LOG=${LOGDIR}/${GAME}_${DEV}_LOG.txt + > $LOG # clear the log touch $LOG # so greps won't show errors - APPS[$COUNTER]=./obj_linux_memdbg/xwords + APPS[$COUNTER]="$APP_NEW" + if [ -n "$APP_OLD" ]; then + # 50% chance of starting out with old app + if [ 0 -eq $((RANDOM%2)) ]; then + APPS[$COUNTER]="$APP_OLD" + fi + fi PARAMS="--room $ROOM" PARAMS="$PARAMS --robot ${NAMES[$DEV]} --robot-iq $((1 + (RANDOM%100))) " PARAMS="$PARAMS $OTHERS --game-dict $DICT --port $PORT --host $HOST " PARAMS="$PARAMS --file $FILE --slow-robot 1:3 --skip-confirm" PARAMS="$PARAMS --drop-nth-packet $DROP_N $PLAT_PARMS" [ -n "$SEED" ] && PARAMS="$PARAMS --seed $RANDOM" - PARAMS="$PARAMS --board-size ${BOARD_SIZES[$((RANDOM%${#BOARD_SIZES[*]}))]}" + if [ -n "$APP_OLD" -a "${APPS[$COUNTER]}" = "$APP_OLD" ]; then + PARAMS="$PARAMS --board-size ${BOARD_SIZES_OLD[$((RANDOM%${#BOARD_SIZES_OLD[*]}))]}" + else + PARAMS="$PARAMS --board-size ${BOARD_SIZES_NEW[$((RANDOM%${#BOARD_SIZES_NEW[*]}))]}" + fi PARAMS="$PARAMS $PUBLIC" ARGS[$COUNTER]=$PARAMS ROOMS[$COUNTER]=$ROOM @@ -157,7 +179,7 @@ build_cmds() { LOGS[$COUNTER]=$LOG PIDS[$COUNTER]=0 - echo "${APPS[$COUNTER]} ${PARAMS}" > $LOG + print_cmdline $COUNTER COUNTER=$((COUNTER+1)) done @@ -268,6 +290,19 @@ maybe_resign() { fi } +try_upgrade() { + KEY=$1 + if [ -n "$APP_OLD" ]; then + if [ $APP_OLD = ${APPS[$KEY]} ]; then + # one in five chance of upgrading + if [ 0 -eq $((RANDOM%5)) ]; then + APPS[$KEY]=$APP_NEW + print_cmdline $KEY + fi + fi + fi +} + check_game() { KEY=$1 LOG=${LOGS[$KEY]} @@ -330,7 +365,6 @@ run_cmds() { ENDTIME=$(($(date +%s) + TIMEOUT)) while :; do COUNT=${#ARGS[*]} - echo "COUNT: $COUNT" [ 0 -ge $COUNT ] && break NOW=$(date '+%s') [ $NOW -ge $ENDTIME ] && break @@ -342,6 +376,7 @@ run_cmds() { if [ -n "$ONE_PER_ROOM" -a 0 -ne ${ROOM_PIDS[$ROOM]} ]; then continue fi + try_upgrade $KEY launch $KEY & PID=$! PIDS[$KEY]=$PID From 32f1dfa5dab85921900f2a81f2b803a488d09257 Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 30 Nov 2011 21:01:11 -0800 Subject: [PATCH 03/16] configure by passing params rather than setting ENV variables --- xwords4/linux/scripts/discon_ok2.sh | 259 +++++++++++++++++----------- 1 file changed, 163 insertions(+), 96 deletions(-) diff --git a/xwords4/linux/scripts/discon_ok2.sh b/xwords4/linux/scripts/discon_ok2.sh index 420cd55da..b7e4c1027 100755 --- a/xwords4/linux/scripts/discon_ok2.sh +++ b/xwords4/linux/scripts/discon_ok2.sh @@ -1,66 +1,27 @@ #!/bin/bash set -u -e -NGAMES=${NGAMES:-1} -NROOMS=${NROOMS:-$NGAMES} -HOST=${HOST:-localhost} -PORT=${PORT:-10997} -TIMEOUT=${TIMEOUT:-$((NGAMES*60+500))} -DICTS=${DICTS:-dict.xwd} -SAVE_GOOD=${SAVE_GOOD:-YES} -MINDEVS=${MINDEVS:-2} -MAXDEVS=${MAXDEVS:-4} -RESIGN_RATIO=${RESIGN_RATIO:-1000} -DROP_N=${DROP_N:-0} +APP_NEW="" +NGAMES="" +NROOMS="" +HOST="" +PORT="" +TIMEOUT="" +SAVE_GOOD="" +MINDEVS="" +MAXDEVS="" +RESIGN_RATIO="" +DROP_N="" MINRUN=2 ONE_PER_ROOM="" +USE_GTK="" ALL_VIA_RQ=${ALL_VIA_RQ:-FALSE} -SEED=${SEED:-""} - -APP_NEW=${APP_NEW:-"./obj_linux_memdbg/xwords"} -APP_OLD=${APP_OLD:-""} - +SEED="" BOARD_SIZES_OLD=(15) BOARD_SIZES_NEW=(15 17) - -declare -a DICTS_ARR -for DICT in $DICTS; do - DICTS_ARR[${#DICTS_ARR[*]}]=$DICT -done - NAMES=(UNUSED Brynn Ariela Kati Eric) [ -n "$SEED" ] && RANDOM=$SEED -LOGDIR=$(basename $0)_logs -RESUME="" -for FILE in $(ls $LOGDIR/*.{xwg,txt} 2>/dev/null); do - if [ -e $FILE ]; then - echo "Unfinished games found in $LOGDIR; continue with them (or discard)?" - read -p " " ANSWER - case "$ANSWER" in - y|yes|Y|YES) - RESUME=1 - ;; - *) - ;; - esac - fi - break -done - -if [ -z "$RESUME" -a -d $LOGDIR ];then - mv $LOGDIR /tmp/${LOGDIR}_$$ -fi -mkdir -p $LOGDIR - -if [ "$SAVE_GOOD" = YES ]; then - DONEDIR=$LOGDIR/done - mkdir -p $DONEDIR -fi -DEADDIR=$LOGDIR/dead -mkdir -p $DEADDIR - -USE_GTK=${USE_GTK:-FALSE} declare -A PIDS declare -A APPS @@ -70,43 +31,17 @@ declare -A FILES declare -A LOGS declare -A MINEND declare -A ROOM_PIDS -# if [ TRUE = "$ALL_VIA_RQ" ]; then -# declare -A PIPES -# fi +declare -a APPS_OLD +declare -A CHECKED_ROOMS -PLAT_PARMS="" -if [ $USE_GTK = FALSE ]; then - PLAT_PARMS="--curses --close-stdin" -fi - -usage() { - echo "usage: [env=val *] $0" 1>&2 - echo " current env variables and their values: " 1>&2 - for VAR in NGAMES NROOMS USE_GTK TIMEOUT HOST PORT DICTS SAVE_GOOD \ - MINDEVS MAXDEVS RESIGN_RATIO DROP_N ALL_VIA_RQ SEED \ - APP_NEW APP_OLD; do - echo "$VAR:" $(eval "echo \$${VAR}") 1>&2 - done - exit 1 -} - -connName() { +function connName() { LOG=$1 grep 'got_connect_cmd: connName' $LOG | \ tail -n 1 | \ sed 's,^.*connName: \"\(.*\)\"$,\1,' } -while [ "$#" -gt 0 ]; do - case $1 in - *) usage - ;; - esac - shift -done - -declare -A CHECKED_ROOMS -check_room() { +function check_room() { ROOM=$1 if [ -z ${CHECKED_ROOMS[$ROOM]:-""} ]; then NUM=$(echo "SELECT COUNT(*) FROM games "\ @@ -133,13 +68,18 @@ print_cmdline() { build_cmds() { COUNTER=0 + PLAT_PARMS="" + if [ $USE_GTK = FALSE ]; then + PLAT_PARMS="--curses --close-stdin" + fi + for GAME in $(seq 1 $NGAMES); do ROOM=$(printf "ROOM_%.3d" $((GAME % NROOMS))) ROOM_PIDS[$ROOM]=0 check_room $ROOM NDEVS=$(( $RANDOM % ($MAXDEVS-1) + 2 )) [ $NDEVS -lt $MINDEVS ] && NDEVS=$MINDEVS - DICT=${DICTS_ARR[$((GAME%${#DICTS_ARR[*]}))]} + DICT=${DICTS[$((GAME%${#DICTS[*]}))]} # make one in three games public PUBLIC="" [ $((RANDOM%3)) -eq 0 ] && PUBLIC="--make-public --join-public" @@ -154,24 +94,22 @@ build_cmds() { LOG=${LOGDIR}/${GAME}_${DEV}_LOG.txt > $LOG # clear the log touch $LOG # so greps won't show errors + PARAMS="" APPS[$COUNTER]="$APP_NEW" - if [ -n "$APP_OLD" ]; then + BOARD_SIZE="--board-size ${BOARD_SIZES_NEW[$((RANDOM%${#BOARD_SIZES_NEW[*]}))]}" + if [ xx = "${APPS_OLD+xx}" ]; then # 50% chance of starting out with old app if [ 0 -eq $((RANDOM%2)) ]; then - APPS[$COUNTER]="$APP_OLD" + APPS[$COUNTER]=${APPS_OLD[$((RANDOM%${#APPS_OLD[*]}))]} + BOARD_SIZE="--board-size ${BOARD_SIZES_OLD[$((RANDOM%${#BOARD_SIZES_OLD[*]}))]}" fi fi - PARAMS="--room $ROOM" + PARAMS="$PARAMS $BOARD_SIZE --room $ROOM" PARAMS="$PARAMS --robot ${NAMES[$DEV]} --robot-iq $((1 + (RANDOM%100))) " PARAMS="$PARAMS $OTHERS --game-dict $DICT --port $PORT --host $HOST " PARAMS="$PARAMS --file $FILE --slow-robot 1:3 --skip-confirm" PARAMS="$PARAMS --drop-nth-packet $DROP_N $PLAT_PARMS" [ -n "$SEED" ] && PARAMS="$PARAMS --seed $RANDOM" - if [ -n "$APP_OLD" -a "${APPS[$COUNTER]}" = "$APP_OLD" ]; then - PARAMS="$PARAMS --board-size ${BOARD_SIZES_OLD[$((RANDOM%${#BOARD_SIZES_OLD[*]}))]}" - else - PARAMS="$PARAMS --board-size ${BOARD_SIZES_NEW[$((RANDOM%${#BOARD_SIZES_NEW[*]}))]}" - fi PARAMS="$PARAMS $PUBLIC" ARGS[$COUNTER]=$PARAMS ROOMS[$COUNTER]=$ROOM @@ -292,8 +230,8 @@ maybe_resign() { try_upgrade() { KEY=$1 - if [ -n "$APP_OLD" ]; then - if [ $APP_OLD = ${APPS[$KEY]} ]; then + if [ xx = "${APPS_OLD+xx}" ]; then + if [ $APP_NEW != ${APPS[$KEY]} ]; then # one in five chance of upgrading if [ 0 -eq $((RANDOM%5)) ]; then APPS[$KEY]=$APP_NEW @@ -443,10 +381,140 @@ run_via_rq() { done } # run_via_rq -print_stats() { - : +function getArg() { + echo $* >&2 + [ 1 -lt "$#" ] || usage "$1 requires an argument" + echo $2 } +function usage() { + [ $# -gt 0 ] && echo "Error: $1" >&2 + echo "Usage: $(basename $0) \\" >&2 + echo " [--dict ]* \\" >&2 + echo " [--old-app &2 + echo " [--new-app &2 + echo " [--min-devs ] \\" >&2 + echo " [--max-devs ] \\" >&2 + echo " [--help] \\" >&2 + echo " [--num-games ] \\" >&2 + echo " [--num-rooms ] \\" >&2 + echo " [--host ] \\" >&2 + echo " [--port ] \\" >&2 + echo " [--seed ] \\" >&2 + echo " [--help] \\" >&2 + + exit 1 +} + +####################################################### +##################### MAIN begins ##################### +####################################################### + +while [ "$#" -gt 0 ]; do + case $1 in + --num-games) + NGAMES=$(getArg $*) + shift + ;; + --num-rooms) + NROOMS=$(getArg $*) + shift + ;; + --old-app) + APPS_OLD[${#APPS_OLD[@]}]=$(getArg $*) + shift + ;; + --new-app) + APP_NEW=$(getArg $*) + shift + ;; + --dict) + DICTS[${#DICTS[@]}]=$(getArg $*) + shift + ;; + --min-devs) + MINDEVS=$(getArg $*) + shift + ;; + --max-devs) + MAXDEVS=$(getArg $*) + shift + ;; + --host) + HOST=$(getArg $*) + shift + ;; + --port) + PORT=$(getArg $*) + shift + ;; + --seed) + SEED=$(getArg $*) + shift + ;; + --help) + usage + ;; + *) usage "unrecognized option $1" + ;; + esac + shift +done + +# Assign defaults +#[ 0 -eq ${#DICTS[@]} ] && DICTS=(dict.xwd) +[ xx = "${DICTS+xx}" ] || DICTS=(dict.xwd) +[ -z "$APP_NEW" ] && APP_NEW=./obj_linux_memdbg/xwords +[ -z "$MINDEVS" ] && MINDEVS=2 +[ -z "$MAXDEVS" ] && MAXDEVS=4 +[ -z "$NGAMES" ] && NGAMES=1 +[ -z "$NROOMS" ] && NROOMS=$NGAMES +[ -z "$HOST" ] && HOST=localhost +[ -z "$PORT" ] && PORT=10997 +[ -z "$TIMEOUT" ] && TIMEOUT=$((NGAMES*60+500)) +[ -z "$SAVE_GOOD" ] && SAVE_GOOD=YES +[ -z "$RESIGN_RATIO" ] && RESIGN_RATIO=1000 +[ -z "$DROP_N" ] && DROP_N=0 +[ -z "$USE_GTK" ] && USE_GTK=FALSE + + +LOGDIR=$(basename $0)_logs +RESUME="" +for FILE in $(ls $LOGDIR/*.{xwg,txt} 2>/dev/null); do + if [ -e $FILE ]; then + echo "Unfinished games found in $LOGDIR; continue with them (or discard)?" + read -p " " ANSWER + case "$ANSWER" in + y|yes|Y|YES) + RESUME=1 + ;; + *) + ;; + esac + fi + break +done + +if [ -z "$RESUME" -a -d $LOGDIR ];then + mv $LOGDIR /tmp/${LOGDIR}_$$ +fi +mkdir -p $LOGDIR + +if [ "$SAVE_GOOD" = YES ]; then + DONEDIR=$LOGDIR/done + mkdir -p $DONEDIR +fi +DEADDIR=$LOGDIR/dead +mkdir -p $DEADDIR + +for VAR in NGAMES NROOMS USE_GTK TIMEOUT HOST PORT SAVE_GOOD \ + MINDEVS MAXDEVS RESIGN_RATIO DROP_N ALL_VIA_RQ SEED \ + APP_NEW; do + echo "$VAR:" $(eval "echo \$${VAR}") 1>&2 +done +echo "DICTS: ${DICTS[*]}" +echo -n "APPS_OLD: "; [ xx = "${APPS_OLD[*]+xx}" ] && echo "APPS_OLD: ${APPS_OLD[*]}" || echo "" + echo "*********$0 starting: $(date)**************" STARTTIME=$(date +%s) [ -z "$RESUME" ] && build_cmds || read_resume_cmds @@ -455,7 +523,6 @@ if [ TRUE = "$ALL_VIA_RQ" ]; then else run_cmds fi -print_stats wait From b242d7002909b5bd8b47dff1e721e8d342232b44 Mon Sep 17 00:00:00 2001 From: Andy2 Date: Thu, 1 Dec 2011 05:40:50 -0800 Subject: [PATCH 04/16] up target SDK to pull in multitouch APIs --- xwords4/android/XWords4/AndroidManifest.xml | 2 +- xwords4/android/XWords4/project.properties | 2 +- xwords4/android/scripts/setup_local_props.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xwords4/android/XWords4/AndroidManifest.xml b/xwords4/android/XWords4/AndroidManifest.xml index 1e29f887d..3c1ec8310 100644 --- a/xwords4/android/XWords4/AndroidManifest.xml +++ b/xwords4/android/XWords4/AndroidManifest.xml @@ -34,7 +34,7 @@ - + Date: Thu, 1 Dec 2011 18:56:44 -0800 Subject: [PATCH 05/16] implement pinch-to-zoom on board -- and do it in such a way that class loader doesn't barf on older versions of the OS that don't provide the necessary APIs. Tested only on original Motorola Droid so far (and emulator running 1.6, which is too old.) --- .../android/xw4/BoardMultiHandler.java | 78 +++++++++++++++++++ .../org/eehouse/android/xw4/BoardView.java | 50 +++++++++++- 2 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardMultiHandler.java diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardMultiHandler.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardMultiHandler.java new file mode 100644 index 000000000..02164a323 --- /dev/null +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardMultiHandler.java @@ -0,0 +1,78 @@ +/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */ +/* + * Copyright 2009-2010 by Eric House (xwords@eehouse.org). All + * rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package org.eehouse.android.xw4; + +import android.view.MotionEvent; +import android.util.FloatMath; + +// DO NOT LOAD THIS on devices running prior to 2.0. It'll crash. +public class BoardMultiHandler implements BoardView.MultiHandlerIface { + + private int m_lastSpacing = -1; // negative means not in use + private int m_threshhold; + + public BoardMultiHandler( int threshhold ) + { + m_threshhold = threshhold; + } + + public int getSpacing( MotionEvent event ) + { + int result; + if ( 1 == event.getPointerCount() ) { + result = -1; + } else { + float xx = event.getX( 0 ) - event.getX( 1 ); + float yy = event.getY( 0 ) - event.getY( 1 ); + result = (int)FloatMath.sqrt( (xx * xx) + (yy * yy) ); + } + return result; + } + + public boolean inactive() + { + return 0 > m_lastSpacing; + } + + public void activate( MotionEvent event ) + { + m_lastSpacing = getSpacing( event ); + } + + public void deactivate() + { + m_lastSpacing = -1; + } + + public int figureZoom( MotionEvent event ) + { + int zoomDir = 0; + if ( 0 <= m_lastSpacing ) { + int newSpacing = getSpacing( event ); + int diff = Math.abs( newSpacing - m_lastSpacing ); + if ( diff > m_threshhold ) { + zoomDir = newSpacing < m_lastSpacing? -1 : 1; + m_lastSpacing = newSpacing; + } + } + return zoomDir; + } +} diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java index 866715509..f8f64f56e 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java @@ -34,6 +34,7 @@ import android.view.MotionEvent; import android.graphics.drawable.Drawable; import android.content.res.Resources; import android.graphics.Paint.FontMetricsInt; +import android.os.Build; import android.os.Handler; import java.nio.IntBuffer; @@ -41,10 +42,20 @@ import junit.framework.Assert; public class BoardView extends View implements DrawCtx, BoardHandler, SyncedDraw { + + public interface MultiHandlerIface { + boolean inactive(); + void activate( MotionEvent event ); + void deactivate(); + int figureZoom( MotionEvent event ); + int getSpacing( MotionEvent event ); + } + private static final float MIN_FONT_DIPS = 14.0f; private static Bitmap s_bitmap; // the board private static final int IN_TRADE_ALPHA = 0x3FFFFFFF; + private static final int PINCH_THRESHOLD = 40; private Context m_context; private Paint m_drawPaint; @@ -83,6 +94,8 @@ public class BoardView extends View implements DrawCtx, BoardHandler, private int m_pendingScore; private Handler m_viewHandler; + private MultiHandlerIface m_multiHandler = null; + // FontDims: exists to translate space available to the largest // font we can draw within that space taking advantage of our use // being limited to a known small subset of glyphs. We need two @@ -168,6 +181,15 @@ public class BoardView extends View implements DrawCtx, BoardHandler, } m_viewHandler = new Handler(); + + try { + int sdk_int = Integer.decode( Build.VERSION.SDK ); + if ( sdk_int >= Build.VERSION_CODES.ECLAIR ) { + m_multiHandler = new BoardMultiHandler( PINCH_THRESHOLD ); + } else { + Utils.logf( "OS version %d too old for multi-touch", sdk_int ); + } + } catch ( Exception ex ) {} } @Override @@ -179,17 +201,41 @@ public class BoardView extends View implements DrawCtx, BoardHandler, switch ( action ) { case MotionEvent.ACTION_DOWN: + if ( null != m_multiHandler ) { + m_multiHandler.deactivate(); + } m_jniThread.handle( JNIThread.JNICmd.CMD_PEN_DOWN, xx, yy ); break; case MotionEvent.ACTION_MOVE: - m_jniThread.handle( JNIThread.JNICmd.CMD_PEN_MOVE, xx, yy ); + if ( null == m_multiHandler || m_multiHandler.inactive() ) { + m_jniThread.handle( JNIThread.JNICmd.CMD_PEN_MOVE, xx, yy ); + } else { + int zoomBy = m_multiHandler.figureZoom( event ); + if ( 0 != zoomBy ) { + m_jniThread.handle( JNIThread.JNICmd.CMD_ZOOM, + zoomBy < 0 ? -2 : 2 ); + } + } break; case MotionEvent.ACTION_UP: m_jniThread.handle( JNIThread.JNICmd.CMD_PEN_UP, xx, yy ); break; + case MotionEvent.ACTION_POINTER_DOWN: + case MotionEvent.ACTION_POINTER_2_DOWN: + if ( null != m_multiHandler ) { + m_jniThread.handle( JNIThread.JNICmd.CMD_PEN_UP, xx, yy ); + m_multiHandler.activate( event ); + } + break; + case MotionEvent.ACTION_POINTER_UP: + case MotionEvent.ACTION_POINTER_2_UP: + if ( null != m_multiHandler ) { + m_multiHandler.deactivate(); + } + break; default: Utils.logf( "unknown action: %d", action ); - Utils.logf( event.toString() ); + break; } return true; // required to get subsequent events From 577c2c85380ef5a3a50f6db3ead912bcce08264c Mon Sep 17 00:00:00 2001 From: Andy2 Date: Thu, 1 Dec 2011 19:44:22 -0800 Subject: [PATCH 06/16] move MultiHandler implementation inside BoardView. --- .../android/xw4/BoardMultiHandler.java | 78 ------------------- .../org/eehouse/android/xw4/BoardView.java | 51 +++++++++++- 2 files changed, 50 insertions(+), 79 deletions(-) delete mode 100644 xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardMultiHandler.java diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardMultiHandler.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardMultiHandler.java deleted file mode 100644 index 02164a323..000000000 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardMultiHandler.java +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */ -/* - * Copyright 2009-2010 by Eric House (xwords@eehouse.org). All - * rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package org.eehouse.android.xw4; - -import android.view.MotionEvent; -import android.util.FloatMath; - -// DO NOT LOAD THIS on devices running prior to 2.0. It'll crash. -public class BoardMultiHandler implements BoardView.MultiHandlerIface { - - private int m_lastSpacing = -1; // negative means not in use - private int m_threshhold; - - public BoardMultiHandler( int threshhold ) - { - m_threshhold = threshhold; - } - - public int getSpacing( MotionEvent event ) - { - int result; - if ( 1 == event.getPointerCount() ) { - result = -1; - } else { - float xx = event.getX( 0 ) - event.getX( 1 ); - float yy = event.getY( 0 ) - event.getY( 1 ); - result = (int)FloatMath.sqrt( (xx * xx) + (yy * yy) ); - } - return result; - } - - public boolean inactive() - { - return 0 > m_lastSpacing; - } - - public void activate( MotionEvent event ) - { - m_lastSpacing = getSpacing( event ); - } - - public void deactivate() - { - m_lastSpacing = -1; - } - - public int figureZoom( MotionEvent event ) - { - int zoomDir = 0; - if ( 0 <= m_lastSpacing ) { - int newSpacing = getSpacing( event ); - int diff = Math.abs( newSpacing - m_lastSpacing ); - if ( diff > m_threshhold ) { - zoomDir = newSpacing < m_lastSpacing? -1 : 1; - m_lastSpacing = newSpacing; - } - } - return zoomDir; - } -} diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java index f8f64f56e..387b891f0 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java @@ -37,6 +37,7 @@ import android.graphics.Paint.FontMetricsInt; import android.os.Build; import android.os.Handler; import java.nio.IntBuffer; +import android.util.FloatMath; import junit.framework.Assert; @@ -185,7 +186,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler, try { int sdk_int = Integer.decode( Build.VERSION.SDK ); if ( sdk_int >= Build.VERSION_CODES.ECLAIR ) { - m_multiHandler = new BoardMultiHandler( PINCH_THRESHOLD ); + m_multiHandler = new MultiHandler(); } else { Utils.logf( "OS version %d too old for multi-touch", sdk_int ); } @@ -995,4 +996,52 @@ public class BoardView extends View implements DrawCtx, BoardHandler, } return color; } + + private class MultiHandler implements MultiHandlerIface { + private static final int INACTIVE = -1; + private int m_lastSpacing = INACTIVE; + + public boolean inactive() + { + return INACTIVE == m_lastSpacing; + } + + public void activate( MotionEvent event ) + { + m_lastSpacing = getSpacing( event ); + } + + public void deactivate() + { + m_lastSpacing = INACTIVE; + } + + public int getSpacing( MotionEvent event ) + { + int result; + if ( 1 == event.getPointerCount() ) { + result = INACTIVE; + } else { + float xx = event.getX( 0 ) - event.getX( 1 ); + float yy = event.getY( 0 ) - event.getY( 1 ); + result = (int)FloatMath.sqrt( (xx * xx) + (yy * yy) ); + } + return result; + } + + public int figureZoom( MotionEvent event ) + { + int zoomDir = 0; + if ( ! inactive() ) { + int newSpacing = getSpacing( event ); + int diff = Math.abs( newSpacing - m_lastSpacing ); + if ( diff > PINCH_THRESHOLD ) { + zoomDir = newSpacing < m_lastSpacing? -1 : 1; + m_lastSpacing = newSpacing; + } + } + return zoomDir; + } + } + } From 47884b8387ebcc7fd54d41526dcae13cc18e6f25 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 1 Dec 2011 19:50:22 -0800 Subject: [PATCH 07/16] ignore new tools-generated file --- xwords4/android/XWords4/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/xwords4/android/XWords4/.gitignore b/xwords4/android/XWords4/.gitignore index f421e79bf..4c12c0a29 100644 --- a/xwords4/android/XWords4/.gitignore +++ b/xwords4/android/XWords4/.gitignore @@ -4,3 +4,4 @@ local.properties bin gen libs +proguard.cfg From 9d42e3f4d06ade9d8a364522914fbefa4d1ff486 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 1 Dec 2011 19:51:02 -0800 Subject: [PATCH 08/16] move logf and showf into their own DbgUtils class --- .../eehouse/android/xw4/BoardActivity.java | 26 ++--- .../org/eehouse/android/xw4/BoardView.java | 34 +++--- .../eehouse/android/xw4/CommsTransport.java | 54 +++++----- .../src/org/eehouse/android/xw4/DBHelper.java | 2 +- .../src/org/eehouse/android/xw4/DBUtils.java | 6 +- .../src/org/eehouse/android/xw4/DbgUtils.java | 100 ++++++++++++++++++ .../android/xw4/DictBrowseActivity.java | 6 +- .../android/xw4/DictImportActivity.java | 14 +-- .../eehouse/android/xw4/DictLangCache.java | 2 +- .../org/eehouse/android/xw4/DictUtils.java | 34 +++--- .../eehouse/android/xw4/DictsActivity.java | 10 +- .../eehouse/android/xw4/DispatchNotify.java | 2 +- .../eehouse/android/xw4/FirstRunDialog.java | 6 +- .../org/eehouse/android/xw4/GameConfig.java | 12 +-- .../eehouse/android/xw4/GameListAdapter.java | 4 +- .../org/eehouse/android/xw4/GameUtils.java | 18 ++-- .../org/eehouse/android/xw4/GamesList.java | 2 +- .../org/eehouse/android/xw4/LookupView.java | 4 +- .../android/xw4/MountEventReceiver.java | 2 +- .../org/eehouse/android/xw4/NBSReceiver.java | 6 +- .../eehouse/android/xw4/NetLaunchInfo.java | 2 +- .../eehouse/android/xw4/NetStateCache.java | 4 +- .../src/org/eehouse/android/xw4/NetUtils.java | 12 +-- .../eehouse/android/xw4/PrefsActivity.java | 2 +- .../org/eehouse/android/xw4/ReceiveNBS.java | 4 +- .../eehouse/android/xw4/RefreshNamesTask.java | 14 +-- .../eehouse/android/xw4/RelayReceiver.java | 6 +- .../eehouse/android/xw4/StatusReceiver.java | 2 +- .../src/org/eehouse/android/xw4/Utils.java | 71 ------------- .../org/eehouse/android/xw4/XWActivity.java | 16 +-- .../src/org/eehouse/android/xw4/XWApp.java | 4 +- .../eehouse/android/xw4/XWListActivity.java | 16 +-- .../eehouse/android/xw4/jni/CommonPrefs.java | 2 +- .../eehouse/android/xw4/jni/CurGameInfo.java | 4 +- .../eehouse/android/xw4/jni/JNIThread.java | 8 +- .../eehouse/android/xw4/jni/JNIUtilsImpl.java | 4 +- .../eehouse/android/xw4/jni/UtilCtxtImpl.java | 6 +- 37 files changed, 275 insertions(+), 246 deletions(-) create mode 100644 xwords4/android/XWords4/src/org/eehouse/android/xw4/DbgUtils.java diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java index cb2ca06ac..9ed43aa79 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java @@ -652,7 +652,7 @@ public class BoardActivity extends XWActivity break; default: - Utils.logf( "menuitem %d not handled", id ); + DbgUtils.logf( "menuitem %d not handled", id ); handled = false; } @@ -978,8 +978,8 @@ public class BoardActivity extends XWActivity DeviceRole newRole = isServer? DeviceRole.SERVER_ISSERVER : DeviceRole.SERVER_ISCLIENT; if ( newRole != m_gi.serverRole ) { - Utils.logf( "new role: %s; old role: %s", - newRole.toString(), m_gi.serverRole.toString() ); + DbgUtils.logf( "new role: %s; old role: %s", + newRole.toString(), m_gi.serverRole.toString() ); m_gi.serverRole = newRole; if ( !isServer ) { m_jniThread.handle( JNIThread.JNICmd.CMD_SWITCHCLIENT ); @@ -1249,14 +1249,14 @@ public class BoardActivity extends XWActivity // public void yOffsetChange( int maxOffset, int oldOffset, int newOffset ) // { - // Utils.logf( "yOffsetChange(maxOffset=%d)", maxOffset ); + // DbgUtils.logf( "yOffsetChange(maxOffset=%d)", maxOffset ); // m_view.setVerticalScrollBarEnabled( maxOffset > 0 ); // } @Override public boolean warnIllegalWord( String[] words, int turn, boolean turnLost ) { - Utils.logf( "warnIllegalWord" ); + DbgUtils.logf( "warnIllegalWord" ); boolean accept = turnLost; StringBuffer sb = new StringBuffer(); @@ -1280,7 +1280,7 @@ public class BoardActivity extends XWActivity accept = 0 != waitBlockingDialog( QUERY_REQUEST_BLK, 0 ); } - Utils.logf( "warnIllegalWord=>%b", accept ); + DbgUtils.logf( "warnIllegalWord=>%b", accept ); return accept; } @@ -1464,7 +1464,7 @@ public class BoardActivity extends XWActivity { int result = cancelResult; if ( m_blockingDlgPosted ) { // this has been true; dunno why - Utils.logf( "waitBlockingDialog: dropping dlgID %d", dlgID ); + DbgUtils.logf( "waitBlockingDialog: dropping dlgID %d", dlgID ); } else { setBlockingThread(); m_resultCode = cancelResult; @@ -1480,7 +1480,7 @@ public class BoardActivity extends XWActivity m_forResultWait.acquire(); m_blockingDlgPosted = false; } catch ( java.lang.InterruptedException ie ) { - Utils.logf( "waitBlockingDialog: got %s", ie.toString() ); + DbgUtils.logf( "waitBlockingDialog: got %s", ie.toString() ); if ( m_blockingDlgPosted ) { dismissDialog( dlgID ); m_blockingDlgPosted = false; @@ -1601,7 +1601,7 @@ public class BoardActivity extends XWActivity if ( null == m_screenTimer ) { m_screenTimer = new Runnable() { public void run() { - Utils.logf( "run() called for setKeepScreenOn()" ); + DbgUtils.logf( "run() called for setKeepScreenOn()" ); if ( null != m_view ) { m_view.setKeepScreenOn( false ); } @@ -1619,7 +1619,7 @@ public class BoardActivity extends XWActivity if ( canPost ) { m_handler.post( runnable ); } else { - Utils.logf( "post: dropping because handler null" ); + DbgUtils.logf( "post: dropping because handler null" ); } return canPost; } @@ -1629,7 +1629,7 @@ public class BoardActivity extends XWActivity if ( null != m_handler ) { m_handler.postDelayed( runnable, when ); } else { - Utils.logf( "postDelayed: dropping %d because handler null", when ); + DbgUtils.logf( "postDelayed: dropping %d because handler null", when ); } } @@ -1638,8 +1638,8 @@ public class BoardActivity extends XWActivity if ( null != m_handler ) { m_handler.removeCallbacks( which ); } else { - Utils.logf( "removeCallbacks: dropping %h because handler null", - which ); + DbgUtils.logf( "removeCallbacks: dropping %h because handler null", + which ); } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java index 387b891f0..0e07c0541 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java @@ -107,20 +107,20 @@ public class BoardView extends View implements DrawCtx, BoardHandler, // future wantHt by. Ditto for the descent private class FontDims { FontDims( float askedHt, int topRow, int bottomRow, float width ) { - // Utils.logf( "FontDims(): askedHt=" + askedHt ); - // Utils.logf( "FontDims(): topRow=" + topRow ); - // Utils.logf( "FontDims(): bottomRow=" + bottomRow ); - // Utils.logf( "FontDims(): width=" + width ); + // DbgUtils.logf( "FontDims(): askedHt=" + askedHt ); + // DbgUtils.logf( "FontDims(): topRow=" + topRow ); + // DbgUtils.logf( "FontDims(): bottomRow=" + bottomRow ); + // DbgUtils.logf( "FontDims(): width=" + width ); float gotHt = bottomRow - topRow + 1; m_htProportion = gotHt / askedHt; Assert.assertTrue( (bottomRow+1) >= askedHt ); float descent = (bottomRow+1) - askedHt; - // Utils.logf( "descent: " + descent ); + // DbgUtils.logf( "descent: " + descent ); m_descentProportion = descent / askedHt; Assert.assertTrue( m_descentProportion >= 0 ); m_widthProportion = width / askedHt; - // Utils.logf( "m_htProportion: " + m_htProportion ); - // Utils.logf( "m_descentProportion: " + m_descentProportion ); + // DbgUtils.logf( "m_htProportion: " + m_htProportion ); + // DbgUtils.logf( "m_descentProportion: " + m_descentProportion ); } private float m_htProportion; private float m_descentProportion; @@ -235,7 +235,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler, } break; default: - Utils.logf( "unknown action: %d", action ); + DbgUtils.logf( "unknown action: %d", action ); break; } @@ -360,7 +360,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler, drew = XwJNI.board_draw( m_jniGamePtr ); } if ( !drew ) { - Utils.logf( "draw not complete" ); + DbgUtils.logf( "draw not complete" ); } } @@ -767,7 +767,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler, int height = rect.height() - 4; // borders and padding, 2 each descent = fontDims.descentFor( height ); textSize = fontDims.heightFor( height ); - // Utils.logf( "using descent: " + descent + " and textSize: " + // DbgUtils.logf( "using descent: " + descent + " and textSize: " // + textSize + " in height " + height ); } m_fillPaint.setTextSize( textSize ); @@ -876,13 +876,13 @@ public class BoardView extends View implements DrawCtx, BoardHandler, Canvas canvas = new Canvas( bitmap ); // FontMetrics fmi = paint.getFontMetrics(); - // Utils.logf( "ascent: " + fmi.ascent ); - // Utils.logf( "bottom: " + fmi.bottom ); - // Utils.logf( "descent: " + fmi.descent ); - // Utils.logf( "leading: " + fmi.leading ); - // Utils.logf( "top : " + fmi.top ); + // DbgUtils.logf( "ascent: " + fmi.ascent ); + // DbgUtils.logf( "bottom: " + fmi.bottom ); + // DbgUtils.logf( "descent: " + fmi.descent ); + // DbgUtils.logf( "leading: " + fmi.leading ); + // DbgUtils.logf( "top : " + fmi.top ); - // Utils.logf( "using as baseline: " + ht ); + // DbgUtils.logf( "using as baseline: " + ht ); Rect bounds = new Rect(); int maxWidth = 0; @@ -902,7 +902,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler, // int pixel = bitmap.getPixel( col, row ); // sb.append( pixel==0? "." : "X" ); // } - // Utils.logf( sb.append(row).toString() ); + // DbgUtils.logf( sb.append(row).toString() ); // } int topRow = 0; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/CommsTransport.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/CommsTransport.java index 4ede1149a..52de336eb 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/CommsTransport.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/CommsTransport.java @@ -91,11 +91,11 @@ public class CommsTransport implements TransportProcs, closeSocket(); } catch ( java.io.IOException ioe ) { - Utils.logf( ioe.toString() ); + DbgUtils.logf( ioe.toString() ); } catch ( UnresolvedAddressException uae ) { - Utils.logf( "bad address: name: %s; port: %s; exception: %s", - m_addr.ip_relay_hostName, m_addr.ip_relay_port, - uae.toString() ); + DbgUtils.logf( "bad address: name: %s; port: %s; exception: %s", + m_addr.ip_relay_hostName, m_addr.ip_relay_port, + uae.toString() ); } m_thread = null; @@ -118,15 +118,15 @@ public class CommsTransport implements TransportProcs, try { m_socketChannel = SocketChannel.open(); m_socketChannel.configureBlocking( false ); - Utils.logf( "connecting to %s:%d", - m_addr.ip_relay_hostName, - m_addr.ip_relay_port ); + DbgUtils.logf( "connecting to %s:%d", + m_addr.ip_relay_hostName, + m_addr.ip_relay_port ); InetSocketAddress isa = new InetSocketAddress(m_addr.ip_relay_hostName, m_addr.ip_relay_port ); m_socketChannel.connect( isa ); } catch ( java.io.IOException ioe ) { - Utils.logf( ioe.toString() ); + DbgUtils.logf( ioe.toString() ); failed = true; break outer_loop; } @@ -134,7 +134,7 @@ public class CommsTransport implements TransportProcs, if ( null != m_socketChannel ) { int ops = figureOps(); - // Utils.logf( "calling with ops=%x", ops ); + // DbgUtils.logf( "calling with ops=%x", ops ); m_socketChannel.register( m_selector, ops ); } } @@ -143,14 +143,14 @@ public class CommsTransport implements TransportProcs, // we get this when relay goes down. Need to notify! failed = true; closeSocket(); - Utils.logf( "exiting: %s", cce.toString() ); + DbgUtils.logf( "exiting: %s", cce.toString() ); break; // don't try again } catch ( java.io.IOException ioe ) { closeSocket(); - Utils.logf( "exiting: %s", ioe.toString() ); - Utils.logf( ioe.toString() ); + DbgUtils.logf( "exiting: %s", ioe.toString() ); + DbgUtils.logf( ioe.toString() ); } catch ( java.nio.channels.NoConnectionPendingException ncp ) { - Utils.logf( "%s", ncp.toString() ); + DbgUtils.logf( "%s", ncp.toString() ); closeSocket(); break; } @@ -168,7 +168,7 @@ public class CommsTransport implements TransportProcs, } if (key.isValid() && key.isReadable()) { m_bytesIn.clear(); // will wipe any pending data! - // Utils.logf( "socket is readable; buffer has space for " + // DbgUtils.logf( "socket is readable; buffer has space for " // + m_bytesIn.remaining() ); int nRead = channel.read( m_bytesIn ); if ( nRead == -1 ) { @@ -181,17 +181,17 @@ public class CommsTransport implements TransportProcs, getOut(); if ( null != m_bytesOut ) { int nWritten = channel.write( m_bytesOut ); - //Utils.logf( "wrote " + nWritten + " bytes" ); + //DbgUtils.logf( "wrote " + nWritten + " bytes" ); } } } catch ( java.io.IOException ioe ) { - Utils.logf( "%s: cancelling key", ioe.toString() ); + DbgUtils.logf( "%s: cancelling key", ioe.toString() ); key.cancel(); failed = true; break outer_loop; } catch ( java.nio.channels. NoConnectionPendingException ncp ) { - Utils.logf( "%s", ncp.toString() ); + DbgUtils.logf( "%s", ncp.toString() ); break outer_loop; } } @@ -240,7 +240,7 @@ public class CommsTransport implements TransportProcs, try { m_socketChannel.close(); } catch ( Exception e ) { - Utils.logf( "closing socket: %s", e.toString() ); + DbgUtils.logf( "closing socket: %s", e.toString() ); } m_socketChannel = null; } @@ -318,7 +318,7 @@ public class CommsTransport implements TransportProcs, try { m_thread.join(100); // wait up to 1/10 second } catch ( java.lang.InterruptedException ie ) { - Utils.logf( "got InterruptedException: %s", ie.toString() ); + DbgUtils.logf( "got InterruptedException: %s", ie.toString() ); } m_thread = null; } @@ -327,7 +327,7 @@ public class CommsTransport implements TransportProcs, // TransportProcs interface public int transportSend( byte[] buf, final CommsAddrRec faddr ) { - //Utils.logf( "CommsTransport::transportSend(nbytes=%d)", buf.length ); + //DbgUtils.logf( "CommsTransport::transportSend(nbytes=%d)", buf.length ); int nSent = -1; if ( null == m_addr ) { @@ -358,7 +358,7 @@ public class CommsTransport implements TransportProcs, // to verify. IFF the plan's to ship a version that // doesn't do SMS. - // Utils.logf( "sending via sms to %s:%d", + // DbgUtils.logf( "sending via sms to %s:%d", // m_addr.sms_phone, m_addr.sms_port ); // try { // Intent intent = new Intent( m_context, StatusReceiver.class); @@ -369,17 +369,17 @@ public class CommsTransport implements TransportProcs, // SmsManager.getDefault().sendTextMessage( m_addr.sms_phone, // null, "Hello world", // pi, pi ); - // Utils.logf( "called sendTextMessage" ); + // DbgUtils.logf( "called sendTextMessage" ); // } else { // SmsManager.getDefault(). // sendDataMessage( m_addr.sms_phone, (String)null, // (short)m_addr.sms_port, // buf, pi, pi ); - // Utils.logf( "called sendDataMessage" ); + // DbgUtils.logf( "called sendDataMessage" ); // } // nSent = buf.length; // } catch ( java.lang.IllegalArgumentException iae ) { - // Utils.logf( iae.toString() ); + // DbgUtils.logf( iae.toString() ); // } break; case COMMS_CONN_BT: @@ -391,17 +391,17 @@ public class CommsTransport implements TransportProcs, // Keep this while debugging why the resend_all that gets // fired on reconnect doesn't unstall a game but a manual // resend does. - Utils.logf( "transportSend(%d)=>%d", buf.length, nSent ); + DbgUtils.logf( "transportSend(%d)=>%d", buf.length, nSent ); return nSent; } public void relayStatus( CommsRelayState newState ) { - //Utils.logf( "relayStatus called; state=%s", newState.toString() ); + //DbgUtils.logf( "relayStatus called; state=%s", newState.toString() ); if ( null != m_jniThread ) { m_jniThread.handle( JNICmd.CMD_DRAW_CONNS_STATUS, newState ); } else { - Utils.logf( "can't draw status yet" ); + DbgUtils.logf( "can't draw status yet" ); } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBHelper.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBHelper.java index 1239b8a52..f3ded5232 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBHelper.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBHelper.java @@ -123,7 +123,7 @@ public class DBHelper extends SQLiteOpenHelper { @Override public void onUpgrade( SQLiteDatabase db, int oldVersion, int newVersion ) { - Utils.logf( "onUpgrade: old: %d; new: %d", oldVersion, newVersion ); + DbgUtils.logf( "onUpgrade: old: %d; new: %d", oldVersion, newVersion ); switch( oldVersion ) { case 5: diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java index 02f4ebbf4..a57c3ec4b 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java @@ -456,7 +456,7 @@ public class DBUtils { long result = db.replaceOrThrow( DBHelper.TABLE_NAME_OBITS, "", values ); } catch ( Exception ex ) { - Utils.logf( "ex: %s", ex.toString() ); + DbgUtils.logf( "ex: %s", ex.toString() ); } db.close(); } @@ -566,7 +566,7 @@ public class DBUtils { Assert.fail(); // values.put( DBHelper.FILE_NAME, path ); // rowid = db.insert( DBHelper.TABLE_NAME_SUM, null, values ); - // Utils.logf( "insert=>%d", rowid ); + // DbgUtils.logf( "insert=>%d", rowid ); // Assert.assertTrue( row >= 0 ); } db.close(); @@ -688,7 +688,7 @@ public class DBUtils { values, selection, null ); db.close(); if ( 0 == result ) { - Utils.logf( "setName(%d,%s) failed", rowid, name ); + DbgUtils.logf( "setName(%d,%s) failed", rowid, name ); } } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DbgUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DbgUtils.java new file mode 100644 index 000000000..aac95fd50 --- /dev/null +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DbgUtils.java @@ -0,0 +1,100 @@ +/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */ +/* + * Copyright 2009-2011 by Eric House (xwords@eehouse.org). All + * rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package org.eehouse.android.xw4; + +import java.lang.Thread; +import java.util.Formatter; + +import android.content.Context; +import android.content.SharedPreferences; +import android.preference.PreferenceManager; +import android.text.format.Time; +import android.util.Log; +import android.widget.Toast; + +public class DbgUtils { + static final String TAG = "XW4"; + static boolean s_doLog = true; + + private static Time s_time = new Time(); + + public static void logEnable( boolean enable ) + { + s_doLog = enable; + } + + public static void logEnable( Context context ) + { + SharedPreferences sp + = PreferenceManager.getDefaultSharedPreferences( context ); + String key = context.getString( R.string.key_logging_on ); + boolean on = sp.getBoolean( key, false ); + logEnable( on ); + } + + public static void logf( String msg ) + { + if ( s_doLog ) { + s_time.setToNow(); + String time = s_time.format("[%H:%M:%S]"); + long id = Thread.currentThread().getId(); + Log.d( TAG, time + "-" + id + "-" + msg ); + } + } // logf + + public static void logf( String format, Object... args ) + { + if ( s_doLog ) { + Formatter formatter = new Formatter(); + logf( formatter.format( format, args ).toString() ); + } + } // logf + + public static void showf( Context context, String format, Object... args ) + { + Formatter formatter = new Formatter(); + String msg = formatter.format( format, args ).toString(); + Toast.makeText( context, msg, Toast.LENGTH_SHORT ).show(); + } // showf + + public static void showf( Context context, int formatid, Object... args ) + { + showf( context, context.getString( formatid ), args ); + } // showf + + public static void printStack( StackTraceElement[] trace ) + { + if ( s_doLog ) { + for ( int ii = 0; ii < trace.length; ++ii ) { + DbgUtils.logf( "ste %d: %s", ii, trace[ii].toString() ); + } + } + } + + public static void printStack() + { + if ( s_doLog ) { + printStack( Thread.currentThread().getStackTrace() ); + } + } + + private DbgUtils() {} +} diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseActivity.java index 7983982a8..38a3d49f9 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseActivity.java @@ -214,7 +214,7 @@ public class DictBrowseActivity extends XWListActivity try { super.finalize(); } catch ( java.lang.Throwable err ){ - Utils.logf( "%s", err.toString() ); + DbgUtils.logf( "%s", err.toString() ); } } @@ -268,8 +268,8 @@ public class DictBrowseActivity extends XWListActivity if ( 0 <= pos ) { getListView().setSelection( pos ); } else { - Utils.showf( this, R.string.dict_browse_nowordsf, - m_name, text ); + DbgUtils.showf( this, R.string.dict_browse_nowordsf, + m_name, text ); } } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictImportActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictImportActivity.java index ea4f6f9fa..8a27459f3 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictImportActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictImportActivity.java @@ -56,7 +56,7 @@ public class DictImportActivity extends XWActivity { long totalSize = 0; for ( int ii = 0; ii < count; ii++ ) { Uri uri = uris[ii]; - Utils.logf( "trying %s", uri ); + DbgUtils.logf( "trying %s", uri ); try { URI jUri = new URI( uri.getScheme(), @@ -66,11 +66,11 @@ public class DictImportActivity extends XWActivity { m_saved = saveDict( is, uri.getPath() ); is.close(); } catch ( java.net.URISyntaxException use ) { - Utils.logf( "URISyntaxException: %s", use.toString() ); + DbgUtils.logf( "URISyntaxException: %s", use.toString() ); } catch ( java.net.MalformedURLException mue ) { - Utils.logf( "MalformedURLException: %s", mue.toString() ); + DbgUtils.logf( "MalformedURLException: %s", mue.toString() ); } catch ( java.io.IOException ioe ) { - Utils.logf( "IOException: %s", ioe.toString() ); + DbgUtils.logf( "IOException: %s", ioe.toString() ); } } return totalSize; @@ -79,7 +79,7 @@ public class DictImportActivity extends XWActivity { @Override protected void onPostExecute( Long result ) { - Utils.logf( "onPostExecute passed %d", result ); + DbgUtils.logf( "onPostExecute passed %d", result ); if ( null != m_saved ) { DictLangCache.inval( DictImportActivity.this, m_saved, s_saveWhere, true ); @@ -105,7 +105,7 @@ public class DictImportActivity extends XWActivity { if ( null != uri) { if ( null != intent.getType() && intent.getType().equals( "application/x-xwordsdict" ) ) { - Utils.logf( "based on MIME type" ); + DbgUtils.logf( "based on MIME type" ); new DownloadFilesTask().execute( uri ); } else if ( uri.toString().endsWith( XWConstants.DICT_EXTN ) ) { String fmt = getString( R.string.downloading_dictf ); @@ -114,7 +114,7 @@ public class DictImportActivity extends XWActivity { view.setText( txt ); new DownloadFilesTask().execute( uri ); } else { - Utils.logf( "bogus intent: %s/%s", intent.getType(), uri ); + DbgUtils.logf( "bogus intent: %s/%s", intent.getType(), uri ); finish(); } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictLangCache.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictLangCache.java index 2226df485..193f8bb43 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictLangCache.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictLangCache.java @@ -389,7 +389,7 @@ public class DictLangCache { s_nameToLang.put( dal, info ); } else { info = null; - Utils.logf( "getInfo(): unable to open dict %s", dal.name ); + DbgUtils.logf( "getInfo(): unable to open dict %s", dal.name ); } } return info; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictUtils.java index b2ea774cf..f6af4fe09 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictUtils.java @@ -242,9 +242,9 @@ public class DictUtils { success = true; } catch ( java.io.FileNotFoundException fnfe ) { - Utils.logf( "%s", fnfe.toString() ); + DbgUtils.logf( "%s", fnfe.toString() ); } catch ( java.io.IOException ioe ) { - Utils.logf( "%s", ioe.toString() ); + DbgUtils.logf( "%s", ioe.toString() ); } finally { try { // Order should match assignment order to above in @@ -252,7 +252,7 @@ public class DictUtils { channelIn.close(); channelOut.close(); } catch ( Exception e ) { - Utils.logf( "%s", e.toString() ); + DbgUtils.logf( "%s", e.toString() ); } } return success; @@ -305,13 +305,13 @@ public class DictUtils { bytes = new byte[len]; int nRead = dict.read( bytes, 0, len ); if ( nRead != len ) { - Utils.logf( "**** warning ****; read only %d of %d bytes.", - nRead, len ); + DbgUtils.logf( "**** warning ****; read only %d of %d bytes.", + nRead, len ); } // check that with len bytes we've read the whole file Assert.assertTrue( -1 == dict.read() ); } catch ( java.io.IOException ee ){ - Utils.logf( "%s failed to open; likely not built-in", name ); + DbgUtils.logf( "%s failed to open; likely not built-in", name ); } } @@ -323,7 +323,7 @@ public class DictUtils { if ( loc == DictLoc.UNKNOWN || loc == DictLoc.DOWNLOAD ) { File path = getDownloadsPathFor( name ); if ( null != path && path.exists() ) { - Utils.logf( "loading %s from Download", name ); + DbgUtils.logf( "loading %s from Download", name ); fis = new FileInputStream( path ); } } @@ -331,13 +331,13 @@ public class DictUtils { if ( loc == DictLoc.UNKNOWN || loc == DictLoc.EXTERNAL ) { File sdFile = getSDPathFor( context, name ); if ( null != sdFile && sdFile.exists() ) { - Utils.logf( "loading %s from SD", name ); + DbgUtils.logf( "loading %s from SD", name ); fis = new FileInputStream( sdFile ); } } if ( null == fis ) { if ( loc == DictLoc.UNKNOWN || loc == DictLoc.INTERNAL ) { - Utils.logf( "loading %s from private storage", name ); + DbgUtils.logf( "loading %s from private storage", name ); fis = context.openFileInput( name ); } } @@ -345,11 +345,11 @@ public class DictUtils { bytes = new byte[len]; fis.read( bytes, 0, len ); fis.close(); - Utils.logf( "Successfully loaded %s", name ); + DbgUtils.logf( "Successfully loaded %s", name ); } catch ( java.io.FileNotFoundException fnf ) { - Utils.logf( fnf.toString() ); + DbgUtils.logf( fnf.toString() ); } catch ( java.io.IOException ioe ) { - Utils.logf( ioe.toString() ); + DbgUtils.logf( ioe.toString() ); } } @@ -449,10 +449,10 @@ public class DictUtils { invalDictList(); success = true; } catch ( java.io.FileNotFoundException fnf ) { - Utils.logf( "saveDict: FileNotFoundException: %s", - fnf.toString() ); + DbgUtils.logf( "saveDict: FileNotFoundException: %s", + fnf.toString() ); } catch ( java.io.IOException ioe ) { - Utils.logf( "saveDict: IOException: %s", ioe.toString() ); + DbgUtils.logf( "saveDict: IOException: %s", ioe.toString() ); deleteDict( context, name ); } } @@ -498,7 +498,7 @@ public class DictUtils { AssetManager am = context.getAssets(); return am.list(""); } catch( java.io.IOException ioe ) { - Utils.logf( ioe.toString() ); + DbgUtils.logf( ioe.toString() ); return new String[0]; } } @@ -523,7 +523,7 @@ public class DictUtils { if ( !result.exists() ) { result.mkdirs(); if ( !result.exists() ) { - Utils.logf( "unable to create sd dir %s", packdir ); + DbgUtils.logf( "unable to create sd dir %s", packdir ); result = null; } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java index d1c4d4fd2..22439b6cc 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsActivity.java @@ -306,8 +306,8 @@ public class DictsActivity extends ExpandableListActivity rowView.cache( toLoc ); rowView.invalidate(); } else { - Utils.logf( "moveDict(%s) failed", - rowView.getText() ); + DbgUtils.logf( "moveDict(%s) failed", + rowView.getText() ); } } }; @@ -480,7 +480,7 @@ public class DictsActivity extends ExpandableListActivity getPackedPositionChild( packedPosition ); // int groupPosition = ExpandableListView. // getPackedPositionGroup( packedPosition ); - // Utils.logf( "onCreateContextMenu: group: %d; child: %d", + // DbgUtils.logf( "onCreateContextMenu: group: %d; child: %d", // groupPosition, childPosition ); // We don't have a menu yet for languages, just for their dict @@ -509,7 +509,7 @@ public class DictsActivity extends ExpandableListActivity try { info = (ExpandableListContextMenuInfo)item.getMenuInfo(); } catch (ClassCastException e) { - Utils.logf( "bad menuInfo: %s", e.toString() ); + DbgUtils.logf( "bad menuInfo: %s", e.toString() ); return false; } @@ -596,7 +596,7 @@ public class DictsActivity extends ExpandableListActivity // MountEventReceiver.SDCardNotifiee interface public void cardMounted( boolean nowMounted ) { - Utils.logf( "DictsActivity.cardMounted(%b)", nowMounted ); + DbgUtils.logf( "DictsActivity.cardMounted(%b)", nowMounted ); // post so other SDCardNotifiee implementations get a chance // to process first: avoid race conditions new Handler().post( new Runnable() { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DispatchNotify.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DispatchNotify.java index fee6956dd..4455b12a1 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DispatchNotify.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DispatchNotify.java @@ -64,7 +64,7 @@ public class DispatchNotify extends Activity { } if ( mustLaunch ) { - Utils.logf( "DispatchNotify: nothing running" ); + DbgUtils.logf( "DispatchNotify: nothing running" ); Intent intent = new Intent( this, GamesList.class ); /* Flags. Tried Intent.FLAG_ACTIVITY_NEW_TASK. I don't diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/FirstRunDialog.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/FirstRunDialog.java index 46539ca39..490b3aafb 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/FirstRunDialog.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/FirstRunDialog.java @@ -49,7 +49,7 @@ public class FirstRunDialog { thisVersion = context.getPackageManager() .getPackageInfo(context.getPackageName(), 0) .versionCode; - Utils.logf( "versionCode: %d", thisVersion ); + DbgUtils.logf( "versionCode: %d", thisVersion ); } catch ( Exception e ) { } } @@ -96,7 +96,7 @@ public class FirstRunDialog { page = stringBuilder.toString(); } catch ( IOException ioe ) { - Utils.logf( ioe.toString() ); + DbgUtils.logf( ioe.toString() ); } finally { // could just catch NPE.... @@ -104,7 +104,7 @@ public class FirstRunDialog { try { inputStream.close(); } catch ( IOException ioe ) { - Utils.logf( ioe.toString() ); + DbgUtils.logf( ioe.toString() ); } } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java index cbe7e8844..c55a196a6 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java @@ -613,7 +613,7 @@ public class GameConfig extends XWActivity } } else { - Utils.logf( "unknown v: " + view.toString() ); + DbgUtils.logf( "unknown v: " + view.toString() ); } } // onClick @@ -793,8 +793,8 @@ public class GameConfig extends XWActivity setting = 2; break; default: - Utils.logf( "setSmartnessSpinner got %d from getRobotSmartness()", - m_gi.getRobotSmartness() ); + DbgUtils.logf( "setSmartnessSpinner got %d from getRobotSmartness()", + m_gi.getRobotSmartness() ); Assert.fail(); } m_smartnessSpinner.setSelection( setting ); @@ -837,7 +837,7 @@ public class GameConfig extends XWActivity private void adjustPlayersLabel() { - Utils.logf( "adjustPlayersLabel()" ); + DbgUtils.logf( "adjustPlayersLabel()" ); String label; if ( m_notNetworkedGame ) { label = getString( R.string.players_label_standalone ); @@ -970,8 +970,8 @@ public class GameConfig extends XWActivity if ( !m_notNetworkedGame ) { m_car.ip_relay_seeksPublicRoom = m_joinPublicCheck.isChecked(); - Utils.logf( "ip_relay_seeksPublicRoom: %b", - m_car.ip_relay_seeksPublicRoom ); + DbgUtils.logf( "ip_relay_seeksPublicRoom: %b", + m_car.ip_relay_seeksPublicRoom ); m_car.ip_relay_advertiseRoom = Utils.getChecked( this, R.id.advertise_new_room_check ); if ( m_car.ip_relay_seeksPublicRoom ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java index 9e861ff1d..c39d13288 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java @@ -109,7 +109,7 @@ public class GameListAdapter extends XWListAdapter { @Override protected Void doInBackground( Void... unused ) { - // Utils.logf( "doInBackground(id=%d)", m_id ); + // DbgUtils.logf( "doInBackground(id=%d)", m_id ); View layout = m_factory.inflate( R.layout.game_list_item, null ); boolean hideTitle = false;//CommonPrefs.getHideTitleBar(m_context); GameSummary summary = DBUtils.getSummary( m_context, m_rowid, false ); @@ -221,7 +221,7 @@ public class GameListAdapter extends XWListAdapter { @Override protected void onPostExecute( Void unused ) { - // Utils.logf( "onPostExecute(id=%d)", m_id ); + // DbgUtils.logf( "onPostExecute(id=%d)", m_id ); if ( -1 != m_rowid ) { m_cb.itemLoaded( m_rowid ); } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java index 58e96324e..574788e00 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java @@ -68,7 +68,7 @@ public class GameUtils { m_rowid = rowid; m_isForWrite = isForWrite; m_lockCount = 0; - // Utils.logf( "GameLock.GameLock(%s,%s) done", m_path, + // DbgUtils.logf( "GameLock.GameLock(%s,%s) done", m_path, // m_isForWrite?"T":"F" ); } @@ -101,18 +101,18 @@ public class GameUtils { public GameLock lock() { long stopTime = System.currentTimeMillis() + 1000; - // Utils.logf( "GameLock.lock(%s)", m_path ); + // DbgUtils.logf( "GameLock.lock(%s)", m_path ); // Utils.printStack(); for ( ; ; ) { if ( tryLock() ) { break; } - // Utils.logf( "GameLock.lock() failed; sleeping" ); + // DbgUtils.logf( "GameLock.lock() failed; sleeping" ); // Utils.printStack(); try { Thread.sleep( 25 ); // milliseconds } catch( InterruptedException ie ) { - Utils.logf( "GameLock.lock(): %s", ie.toString() ); + DbgUtils.logf( "GameLock.lock(): %s", ie.toString() ); break; } if ( System.currentTimeMillis() >= stopTime ) { @@ -120,13 +120,13 @@ public class GameUtils { Assert.fail(); } } - // Utils.logf( "GameLock.lock(%s) done", m_path ); + // DbgUtils.logf( "GameLock.lock(%s) done", m_path ); return this; } public void unlock() { - // Utils.logf( "GameLock.unlock(%s)", m_path ); + // DbgUtils.logf( "GameLock.unlock(%s)", m_path ); synchronized( s_locks ) { Assert.assertTrue( this == s_locks.get(m_rowid) ); if ( 1 == m_lockCount ) { @@ -136,7 +136,7 @@ public class GameUtils { } --m_lockCount; } - // Utils.logf( "GameLock.unlock(%s) done", m_path ); + // DbgUtils.logf( "GameLock.unlock(%s) done", m_path ); } public long getRowid() @@ -310,7 +310,7 @@ public class GameUtils { String[] dictNames = gi.dictNames(); DictUtils.DictPairs pairs = DictUtils.openDicts( context, dictNames ); if ( pairs.anyMissing( dictNames ) ) { - Utils.logf( "loadMakeGame() failing: dict unavailable" ); + DbgUtils.logf( "loadMakeGame() failing: dict unavailable" ); } else { gamePtr = XwJNI.initJNI(); @@ -606,7 +606,7 @@ public class GameUtils { lock.unlock(); } } - Utils.logf( "feedMessages=>%b", draw ); + DbgUtils.logf( "feedMessages=>%b", draw ); return draw; } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java index 354d6f6d2..66f621a9b 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java @@ -491,7 +491,7 @@ public class GamesList extends XWListActivity try { info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); } catch (ClassCastException e) { - Utils.logf( "bad menuInfo: %s", e.toString() ); + DbgUtils.logf( "bad menuInfo: %s", e.toString() ); return false; } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/LookupView.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/LookupView.java index 25bbfa994..302efcd5c 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/LookupView.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/LookupView.java @@ -189,7 +189,7 @@ public class LookupView extends LinearLayout private void lookupWord( String word, String fmt ) { if ( false ) { - Utils.logf( "skipping lookupWord(%s)", word ); + DbgUtils.logf( "skipping lookupWord(%s)", word ); } else { String langCode = s_langCodes[s_lang]; String dict_url = String.format( fmt, langCode, word ); @@ -200,7 +200,7 @@ public class LookupView extends LinearLayout try { m_context.startActivity( intent ); } catch ( android.content.ActivityNotFoundException anfe ) { - Utils.logf( "%s", anfe.toString() ); + DbgUtils.logf( "%s", anfe.toString() ); } } } // lookupWord diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/MountEventReceiver.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/MountEventReceiver.java index f3c9652f0..d2ed4c2ef 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/MountEventReceiver.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/MountEventReceiver.java @@ -37,7 +37,7 @@ public class MountEventReceiver extends BroadcastReceiver { @Override public void onReceive( Context context, Intent intent ) { - Utils.logf( "MountEventReceiver.onReceive(%s)", intent.getAction() ); + DbgUtils.logf( "MountEventReceiver.onReceive(%s)", intent.getAction() ); synchronized( s_procs ) { do { if ( s_procs.isEmpty() ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NBSReceiver.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NBSReceiver.java index 471200df5..ad4e544fa 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NBSReceiver.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NBSReceiver.java @@ -31,7 +31,7 @@ // @Override // public void onReceive( Context context, Intent intent ) // { -// Utils.logf( "NBSReceiver::onReceive(intent=%s)!!!!", +// DbgUtils.logf( "NBSReceiver::onReceive(intent=%s)!!!!", // intent.toString() ); // } @@ -46,9 +46,9 @@ // data, null, null ); // // PendingIntent sentIntent, // // PendingIntent deliveryIntent ); -// Utils.logf( "sendDataMessage finished" ); +// DbgUtils.logf( "sendDataMessage finished" ); // } catch ( IllegalArgumentException iae ) { -// Utils.logf( "%s", iae.toString() ); +// DbgUtils.logf( "%s", iae.toString() ); // } // } // } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetLaunchInfo.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetLaunchInfo.java index 79f56e489..362995abe 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetLaunchInfo.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetLaunchInfo.java @@ -84,7 +84,7 @@ public class NetLaunchInfo { nPlayers = Integer.decode( np ); m_valid = true; } catch ( Exception e ) { - Utils.logf( "unable to parse \"%s\"", data.toString() ); + DbgUtils.logf( "unable to parse \"%s\"", data.toString() ); } } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetStateCache.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetStateCache.java index 84beb91a5..b50f11d1e 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetStateCache.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetStateCache.java @@ -100,8 +100,8 @@ public class NetStateCache { NetworkInfo ni = (NetworkInfo)intent. getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO); - Utils.logf( "CommsBroadcastReceiver.onReceive: %s", - ni.getState().toString() ); + DbgUtils.logf( "CommsBroadcastReceiver.onReceive: %s", + ni.getState().toString() ); boolean netAvail; switch ( ni.getState() ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetUtils.java index 560600c35..ed2313a5b 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetUtils.java @@ -56,9 +56,9 @@ public class NetUtils { socket.setSoTimeout( timeoutMillis ); } catch ( java.net.UnknownHostException uhe ) { - Utils.logf( uhe.toString() ); + DbgUtils.logf( uhe.toString() ); } catch( java.io.IOException ioe ) { - Utils.logf( ioe.toString() ); + DbgUtils.logf( ioe.toString() ); } return socket; } @@ -105,7 +105,7 @@ public class NetUtils { DBUtils.clearObits( m_context, m_obits ); } } catch ( java.io.IOException ioe ) { - Utils.logf( ioe.toString() ); + DbgUtils.logf( ioe.toString() ); } } } @@ -190,11 +190,11 @@ public class NetUtils { } } catch( java.net.UnknownHostException uhe ) { - Utils.logf( uhe.toString() ); + DbgUtils.logf( uhe.toString() ); } catch( java.io.IOException ioe ) { - Utils.logf( ioe.toString() ); + DbgUtils.logf( ioe.toString() ); } catch( NullPointerException npe ) { - Utils.logf( npe.toString() ); + DbgUtils.logf( npe.toString() ); } } return result; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java index b39453d6b..63c77576b 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java @@ -146,7 +146,7 @@ public class PrefsActivity extends PreferenceActivity public void onSharedPreferenceChanged( SharedPreferences sp, String key ) { if ( key.equals( m_keyLogging ) ) { - Utils.logEnable( sp.getBoolean( key, false ) ); + DbgUtils.logEnable( sp.getBoolean( key, false ) ); } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ReceiveNBS.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ReceiveNBS.java index 924d2aac9..55fb101e1 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ReceiveNBS.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ReceiveNBS.java @@ -31,7 +31,7 @@ public class ReceiveNBS extends BroadcastReceiver { @Override public void onReceive( Context context, Intent intent ) { - Utils.logf( "onReceive called: %s", intent.toString() ); + DbgUtils.logf( "onReceive called: %s", intent.toString() ); Bundle bundle = intent.getExtras(); SmsMessage[] smsarr = null; @@ -40,7 +40,7 @@ public class ReceiveNBS extends BroadcastReceiver { smsarr = new SmsMessage[pdus.length]; for ( int ii = 0; ii < pdus.length; ii++){ smsarr[ii] = SmsMessage.createFromPdu((byte[])pdus[ii]); - Utils.logf( "from %s", smsarr[ii].getOriginatingAddress() ); + DbgUtils.logf( "from %s", smsarr[ii].getOriginatingAddress() ); // buf.append( smsarr[ii].getMessageBody() ); // XwJni.handle( XwJni.JNICmd.CMD_RECEIVE, // smsarr[ii].getMessageBody() ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/RefreshNamesTask.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/RefreshNamesTask.java index 64c75c427..c219f74d0 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/RefreshNamesTask.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/RefreshNamesTask.java @@ -67,7 +67,7 @@ public class RefreshNamesTask extends AsyncTask { protected String[] doInBackground( Void...unused ) { ArrayList names = new ArrayList(); - Utils.logf( "doInBackground()" ); + DbgUtils.logf( "doInBackground()" ); try { Socket socket = NetUtils.MakeProxySocket( m_context, 15000 ); @@ -87,7 +87,7 @@ public class RefreshNamesTask extends AsyncTask { new DataInputStream(socket.getInputStream()); short len = dis.readShort(); short nRooms = dis.readShort(); - Utils.logf( "%s: got %d rooms", "doInBackground", nRooms ); + DbgUtils.logf( "%s: got %d rooms", "doInBackground", nRooms ); // Can't figure out how to read a null-terminated string // from DataInputStream so parse it myself. @@ -101,16 +101,16 @@ public class RefreshNamesTask extends AsyncTask { ++index; } String name = new String( bytes, lastIndex, index - lastIndex ); - Utils.logf( "got public room name: %s", name ); + DbgUtils.logf( "got public room name: %s", name ); int indx = name.lastIndexOf( "/" ); indx = name.lastIndexOf( "/", indx-1 ); names.add( name.substring(0, indx ) ); } } } catch ( java.io.IOException ioe ) { - Utils.logf( "%s", ioe.toString() ); + DbgUtils.logf( "%s", ioe.toString() ); } - Utils.logf( "doInBackground() returning" ); + DbgUtils.logf( "doInBackground() returning" ); return names.toArray( new String[names.size()] ); } @@ -121,7 +121,7 @@ public class RefreshNamesTask extends AsyncTask { @Override protected void onPostExecute( String[] result ) { - Utils.logf( "onPostExecute()" ); + DbgUtils.logf( "onPostExecute()" ); ArrayAdapter adapter = new ArrayAdapter( m_context, android.R.layout.simple_spinner_item, @@ -136,6 +136,6 @@ public class RefreshNamesTask extends AsyncTask { m_nnf.NoNameFound(); } - Utils.logf( "onPostExecute() done" ); + DbgUtils.logf( "onPostExecute() done" ); } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayReceiver.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayReceiver.java index 04429a758..be86580d1 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayReceiver.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayReceiver.java @@ -49,10 +49,10 @@ public class RelayReceiver extends BroadcastReceiver { { if ( null != intent && null != intent.getAction() && intent.getAction().equals( Intent.ACTION_BOOT_COMPLETED ) ) { - Utils.logf( "launching timer on boot" ); + DbgUtils.logf( "launching timer on boot" ); RestartTimer( context ); } else { - // Utils.logf( "RelayReceiver::onReceive()" ); + // DbgUtils.logf( "RelayReceiver::onReceive()" ); // if ( XWConstants.s_showProxyToast ) { // Toast.makeText(context, "RelayReceiver: fired", // Toast.LENGTH_SHORT).show(); @@ -83,7 +83,7 @@ public class RelayReceiver extends BroadcastReceiver { PendingIntent pi = PendingIntent.getBroadcast( context, 0, intent, 0 ); if ( interval_millis > 0 || force ) { - // Utils.logf( "setting alarm for %d millis", interval_millis ); + // DbgUtils.logf( "setting alarm for %d millis", interval_millis ); am.setInexactRepeating( AlarmManager.ELAPSED_REALTIME_WAKEUP, 0, // first firing interval_millis, pi ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/StatusReceiver.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/StatusReceiver.java index f4495e9ab..ad5b73e55 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/StatusReceiver.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/StatusReceiver.java @@ -29,7 +29,7 @@ public class StatusReceiver extends BroadcastReceiver { @Override public void onReceive( Context context, Intent intent ) { - Utils.logf( "StatusReceiver.onReceive called: %s", intent.toString() ); + DbgUtils.logf( "StatusReceiver.onReceive called: %s", intent.toString() ); } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java index 3923d283e..b2e6b5294 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java @@ -20,98 +20,27 @@ package org.eehouse.android.xw4; -import android.util.Log; -import java.lang.Thread; import android.app.Activity; import android.app.Dialog; import android.content.DialogInterface; import android.content.Context; import android.content.Intent; -import android.content.SharedPreferences; -import android.preference.PreferenceManager; import android.widget.CheckBox; import android.widget.Toast; import android.widget.EditText; import android.widget.TextView; import android.view.LayoutInflater; import android.view.View; -import android.text.format.Time; -import java.util.Formatter; import junit.framework.Assert; import org.eehouse.android.xw4.jni.*; public class Utils { - static final String TAG = "XW4"; - static final String DB_PATH = "XW_GAMES"; - static boolean s_doLog = true; - - private static Time s_time = new Time(); private Utils() {} - public static void logEnable( boolean enable ) - { - s_doLog = enable; - } - - public static void logEnable( Context context ) - { - SharedPreferences sp - = PreferenceManager.getDefaultSharedPreferences( context ); - String key = context.getString( R.string.key_logging_on ); - boolean on = sp.getBoolean( key, false ); - logEnable( on ); - } - - public static void logf( String msg ) - { - if ( s_doLog ) { - s_time.setToNow(); - String time = s_time.format("[%H:%M:%S]"); - long id = Thread.currentThread().getId(); - Log.d( TAG, time + "-" + id + "-" + msg ); - } - } // logf - - public static void logf( String format, Object... args ) - { - if ( s_doLog ) { - Formatter formatter = new Formatter(); - logf( formatter.format( format, args ).toString() ); - } - } // logf - - public static void showf( Context context, String format, Object... args ) - { - Formatter formatter = new Formatter(); - String msg = formatter.format( format, args ).toString(); - Toast.makeText( context, msg, Toast.LENGTH_SHORT ).show(); - } // showf - - public static void showf( Context context, int formatid, Object... args ) - { - showf( context, context.getString( formatid ), args ); - } // showf - - public static void printStack( StackTraceElement[] trace ) - { - if ( s_doLog ) { - for ( int ii = 0; ii < trace.length; ++ii ) { - Utils.logf( "ste %d: %s", ii, trace[ii].toString() ); - } - } - } - - public static void printStack() - { - if ( s_doLog ) { - printStack( Thread.currentThread().getStackTrace() ); - } - } - public static void notImpl( Context context ) { CharSequence text = "Feature coming soon"; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java index eb5167c70..ed57383b0 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java @@ -40,7 +40,7 @@ public class XWActivity extends Activity @Override protected void onCreate( Bundle savedInstanceState ) { - Utils.logf( "%s.onCreate(this=%H)", getClass().getName(), this ); + DbgUtils.logf( "%s.onCreate(this=%H)", getClass().getName(), this ); super.onCreate( savedInstanceState ); m_delegate = new DlgDelegate( this, this, savedInstanceState ); } @@ -48,7 +48,7 @@ public class XWActivity extends Activity @Override protected void onStart() { - Utils.logf( "%s.onStart(this=%H)", getClass().getName(), this ); + DbgUtils.logf( "%s.onStart(this=%H)", getClass().getName(), this ); super.onStart(); DispatchNotify.SetRunning( this ); } @@ -56,21 +56,21 @@ public class XWActivity extends Activity @Override protected void onResume() { - Utils.logf( "%s.onResume(this=%H)", getClass().getName(), this ); + DbgUtils.logf( "%s.onResume(this=%H)", getClass().getName(), this ); super.onResume(); } @Override protected void onPause() { - Utils.logf( "%s.onPause(this=%H)", getClass().getName(), this ); + DbgUtils.logf( "%s.onPause(this=%H)", getClass().getName(), this ); super.onPause(); } @Override protected void onStop() { - Utils.logf( "%s.onStop(this=%H)", getClass().getName(), this ); + DbgUtils.logf( "%s.onStop(this=%H)", getClass().getName(), this ); DispatchNotify.ClearRunning( this ); super.onStop(); } @@ -78,8 +78,8 @@ public class XWActivity extends Activity @Override protected void onDestroy() { - Utils.logf( "%s.onDestroy(this=%H); isFinishing=%b", - getClass().getName(), this, isFinishing() ); + DbgUtils.logf( "%s.onDestroy(this=%H); isFinishing=%b", + getClass().getName(), this, isFinishing() ); super.onDestroy(); } @@ -95,7 +95,7 @@ public class XWActivity extends Activity { Dialog dialog = super.onCreateDialog( id ); if ( null == dialog ) { - Utils.logf( "%s.onCreateDialog() called", getClass().getName() ); + DbgUtils.logf( "%s.onCreateDialog() called", getClass().getName() ); dialog = m_delegate.onCreateDialog( id ); } return dialog; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWApp.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWApp.java index d3d4ea873..28cd3515b 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWApp.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWApp.java @@ -27,8 +27,8 @@ public class XWApp extends Application { @Override public void onCreate() { - Utils.logEnable( this ); - Utils.logf( "XWApp.onCreate(); svn_rev=%s", getString(R.string.git_rev_gen) ); + DbgUtils.logEnable( this ); + DbgUtils.logf( "XWApp.onCreate(); svn_rev=%s", getString(R.string.git_rev_gen) ); super.onCreate(); } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListActivity.java index 7ae6f6d12..7c3533306 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListActivity.java @@ -37,7 +37,7 @@ public class XWListActivity extends ListActivity @Override protected void onCreate( Bundle savedInstanceState ) { - Utils.logf( "%s.onCreate(this=%H)", getClass().getName(), this ); + DbgUtils.logf( "%s.onCreate(this=%H)", getClass().getName(), this ); super.onCreate( savedInstanceState ); m_delegate = new DlgDelegate( this, this, savedInstanceState ); } @@ -45,7 +45,7 @@ public class XWListActivity extends ListActivity @Override protected void onStart() { - Utils.logf( "%s.onStart(this=%H)", getClass().getName(), this ); + DbgUtils.logf( "%s.onStart(this=%H)", getClass().getName(), this ); super.onStart(); DispatchNotify.SetRunning( this ); } @@ -53,21 +53,21 @@ public class XWListActivity extends ListActivity @Override protected void onResume() { - Utils.logf( "%s.onResume(this=%H)", getClass().getName(), this ); + DbgUtils.logf( "%s.onResume(this=%H)", getClass().getName(), this ); super.onResume(); } @Override protected void onPause() { - Utils.logf( "%s.onPause(this=%H)", getClass().getName(), this ); + DbgUtils.logf( "%s.onPause(this=%H)", getClass().getName(), this ); super.onPause(); } @Override protected void onStop() { - Utils.logf( "%s.onStop(this=%H)", getClass().getName(), this ); + DbgUtils.logf( "%s.onStop(this=%H)", getClass().getName(), this ); DispatchNotify.ClearRunning( this ); super.onStop(); } @@ -75,8 +75,8 @@ public class XWListActivity extends ListActivity @Override protected void onDestroy() { - Utils.logf( "%s.onDestroy(this=%H); isFinishing=%b", - getClass().getName(), this, isFinishing() ); + DbgUtils.logf( "%s.onDestroy(this=%H); isFinishing=%b", + getClass().getName(), this, isFinishing() ); super.onDestroy(); } @@ -90,7 +90,7 @@ public class XWListActivity extends ListActivity @Override protected Dialog onCreateDialog( final int id ) { - Utils.logf( "%s.onCreateDialog() called", getClass().getName() ); + DbgUtils.logf( "%s.onCreateDialog() called", getClass().getName() ); Dialog dialog = m_delegate.onCreateDialog( id ); if ( null == dialog ) { dialog = super.onCreateDialog( id ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CommonPrefs.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CommonPrefs.java index 22081769b..e600236ab 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CommonPrefs.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CommonPrefs.java @@ -164,7 +164,7 @@ public class CommonPrefs { result = Integer.parseInt( val ); } catch ( Exception ex ) { } - // Utils.logf( "getDefaultProxyPort=>%d", result ); + // DbgUtils.logf( "getDefaultProxyPort=>%d", result ); return result; } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CurGameInfo.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CurGameInfo.java index 9eec87d35..12ac91f58 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CurGameInfo.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CurGameInfo.java @@ -26,7 +26,7 @@ import java.util.HashSet; import java.util.Arrays; import junit.framework.Assert; -import org.eehouse.android.xw4.Utils; +import org.eehouse.android.xw4.DbgUtils; import org.eehouse.android.xw4.DictUtils; import org.eehouse.android.xw4.R; import org.eehouse.android.xw4.DictLangCache; @@ -216,7 +216,7 @@ public class CurGameInfo { ++count; } } - Utils.logf( "remoteCount()=>%d", count ); + DbgUtils.logf( "remoteCount()=>%d", count ); return count; } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java index 06b5021e5..c0de0bc36 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java @@ -21,7 +21,6 @@ package org.eehouse.android.xw4.jni; -import org.eehouse.android.xw4.Utils; import android.content.Context; import java.lang.InterruptedException; import java.util.concurrent.LinkedBlockingQueue; @@ -32,6 +31,7 @@ import android.graphics.Paint; import android.graphics.Rect; import org.eehouse.android.xw4.R; +import org.eehouse.android.xw4.DbgUtils; import org.eehouse.android.xw4.BoardDims; import org.eehouse.android.xw4.GameUtils; import org.eehouse.android.xw4.DBUtils; @@ -163,7 +163,7 @@ public class JNIThread extends Thread { join(); // Assert.assertFalse( isAlive() ); } catch ( java.lang.InterruptedException ie ) { - Utils.logf( "JNIThread.waitToStop() got %s", ie.toString() ); + DbgUtils.logf( "JNIThread.waitToStop() got %s", ie.toString() ); } } @@ -290,7 +290,7 @@ public class JNIThread extends Thread { try { elem = m_queue.take(); } catch ( InterruptedException ie ) { - Utils.logf( "interrupted; killing thread" ); + DbgUtils.logf( "interrupted; killing thread" ); break; } boolean draw = false; @@ -565,7 +565,7 @@ public class JNIThread extends Thread { public void handle( JNICmd cmd, boolean isUI, Object... args ) { QueueElem elem = new QueueElem( cmd, isUI, args ); - // Utils.logf( "adding: %s", cmd.toString() ); + // DbgUtils.logf( "adding: %s", cmd.toString() ); m_queue.add( elem ); } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIUtilsImpl.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIUtilsImpl.java index 1e9deb4f6..c64c391b1 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIUtilsImpl.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIUtilsImpl.java @@ -56,7 +56,7 @@ public class JNIUtilsImpl implements JNIUtils { try { isr = new InputStreamReader( bais, isUTF8? "UTF8" : "ISO8859_1" ); } catch( java.io.UnsupportedEncodingException uee ) { - Utils.logf( "splitFaces: %s", uee.toString() ); + DbgUtils.logf( "splitFaces: %s", uee.toString() ); isr = new InputStreamReader( bais ); } @@ -67,7 +67,7 @@ public class JNIUtilsImpl implements JNIUtils { try { chr = isr.read(); } catch ( java.io.IOException ioe ) { - Utils.logf( ioe.toString() ); + DbgUtils.logf( ioe.toString() ); } if ( -1 == chr ) { break; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/UtilCtxtImpl.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/UtilCtxtImpl.java index 5a559e7f5..3ebb1110f 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/UtilCtxtImpl.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/UtilCtxtImpl.java @@ -22,7 +22,7 @@ package org.eehouse.android.xw4.jni; import android.content.Context; -import org.eehouse.android.xw4.Utils; +import org.eehouse.android.xw4.DbgUtils; import org.eehouse.android.xw4.R; public class UtilCtxtImpl implements UtilCtxt { @@ -173,7 +173,7 @@ public class UtilCtxtImpl implements UtilCtxt { id = R.string.strd_turn_score; break; default: - Utils.logf( "no such stringCode: %d", stringCode ); + DbgUtils.logf( "no such stringCode: %d", stringCode ); } String result; @@ -227,7 +227,7 @@ public class UtilCtxtImpl implements UtilCtxt { } private void subclassOverride( String name ) { - Utils.logf( "%s::%s() called", getClass().getName(), name ); + DbgUtils.logf( "%s::%s() called", getClass().getName(), name ); } } From 7da7dbc7312345201f2f4782cb72b44279ff84a4 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 1 Dec 2011 19:54:56 -0800 Subject: [PATCH 09/16] shoulda tried compiling before committing a large merge.... --- .../android/XWords4/src/org/eehouse/android/xw4/BoardView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java index 0e07c0541..d78afe512 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java @@ -188,7 +188,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler, if ( sdk_int >= Build.VERSION_CODES.ECLAIR ) { m_multiHandler = new MultiHandler(); } else { - Utils.logf( "OS version %d too old for multi-touch", sdk_int ); + DbgUtils.logf( "OS version %d too old for multi-touch", sdk_int ); } } catch ( Exception ex ) {} } From 0065f5078e7f540fe915d25fdbeefa465f1a941e Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 1 Dec 2011 20:16:09 -0800 Subject: [PATCH 10/16] add variable controlling odds of "upgrading" -- which still needs tweaking. --- xwords4/linux/scripts/discon_ok2.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xwords4/linux/scripts/discon_ok2.sh b/xwords4/linux/scripts/discon_ok2.sh index b7e4c1027..7a7fbbb3e 100755 --- a/xwords4/linux/scripts/discon_ok2.sh +++ b/xwords4/linux/scripts/discon_ok2.sh @@ -3,6 +3,7 @@ set -u -e APP_NEW="" NGAMES="" +UPGRADE_ODDS="" NROOMS="" HOST="" PORT="" @@ -233,7 +234,7 @@ try_upgrade() { if [ xx = "${APPS_OLD+xx}" ]; then if [ $APP_NEW != ${APPS[$KEY]} ]; then # one in five chance of upgrading - if [ 0 -eq $((RANDOM%5)) ]; then + if [ 0 -eq $((RANDOM % UPGRADE_ODDS)) ]; then APPS[$KEY]=$APP_NEW print_cmdline $KEY fi @@ -382,7 +383,6 @@ run_via_rq() { } # run_via_rq function getArg() { - echo $* >&2 [ 1 -lt "$#" ] || usage "$1 requires an argument" echo $2 } @@ -476,7 +476,9 @@ done [ -z "$RESIGN_RATIO" ] && RESIGN_RATIO=1000 [ -z "$DROP_N" ] && DROP_N=0 [ -z "$USE_GTK" ] && USE_GTK=FALSE - +[ -z "$UPGRADE_ODDS" ] && UPGRADE_ODDS=10 +#$((NGAMES/50)) +[ 0 -eq $UPGRADE_ODDS ] && UPGRADE_ODDS=1 LOGDIR=$(basename $0)_logs RESUME="" From 4a32942e5738c7aabd4f523b3eb8b1bb453c5c90 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 1 Dec 2011 20:22:16 -0800 Subject: [PATCH 11/16] two fixes that seem to allow old- and new-proto devices to play games with 15x15 and 17x17 (and presumably larger) with the old games being upgraded mid-game: when server's new and wants to use a larger board but not all clients are capable, shrink the board; and, when new server is opening state saved by pre-upgrade code, assume a non-0 proto version for clients that registered earlier (as old code didn't save the client's proto version.) --- xwords4/common/server.c | 62 ++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/xwords4/common/server.c b/xwords4/common/server.c index 4b4b34c29..f023a1bc7 100644 --- a/xwords4/common/server.c +++ b/xwords4/common/server.c @@ -292,9 +292,8 @@ getNV( XWStreamCtxt* stream, ServerNonvolatiles* nv, XP_U16 nPlayers ) nv->addresses[ii].channelNo = (XP_PlayerAddr)stream_getBits( stream, 16 ); #ifdef STREAM_VERS_BIGBOARD - if ( STREAM_VERS_BIGBOARD <= version ) { - nv->addresses[ii].streamVersion = stream_getBits( stream, 8 ); - } + nv->addresses[ii].streamVersion = STREAM_VERS_BIGBOARD <= version ? + stream_getBits( stream, 8 ) : STREAM_SAVE_PREVWORDS; #endif } #ifdef STREAM_VERS_BIGBOARD @@ -641,8 +640,20 @@ setStreamVersion( ServerCtxt* server ) XP_LOGF( "%s: setting streamVersion: %d", __func__, streamVersion ); server->nv.streamVersion = streamVersion; } + +static void +checkResizeBoard( ServerCtxt* server ) +{ + CurGameInfo* gi = server->vol.gi; + if ( STREAM_VERS_BIGBOARD > server->nv.streamVersion && gi->boardSize > 15) { + XP_LOGF( "%s: dropping board size from %d to 15", __func__, gi->boardSize ); + gi->boardSize = 15; + model_setSize( server->vol.model, 15 ); + } +} # else # define setStreamVersion(s) +# define checkResizeBoard(s) # endif static XP_Bool @@ -691,6 +702,7 @@ handleRegistrationMsg( ServerCtxt* server, XWStreamCtxt* stream ) if ( server->nv.pendingRegistrations == 0 ) { XP_ASSERT( ii == playersInMsg ); /* otherwise malformed */ setStreamVersion( server ); + checkResizeBoard( server ); assignTilesToAll( server ); SETSTATE( server, XWSTATE_RECEIVED_ALL_REG ); } @@ -1164,7 +1176,7 @@ client_readInitialMessage( ServerCtxt* server, XWStreamCtxt* stream ) DictionaryCtxt* curDict; XP_U16 nPlayers, nCols; XP_PlayerAddr channelNo; - short i; + XP_U16 ii; ModelCtxt* model = server->vol.model; CurGameInfo* gi = server->vol.gi; CurGameInfo localGI; @@ -1175,6 +1187,7 @@ client_readInitialMessage( ServerCtxt* server, XWStreamCtxt* stream ) XP_U8 streamVersion = stream_getU8( stream ); XP_LOGF( "%s: set streamVersion to %d", __func__, streamVersion ); stream_setVersion( stream, streamVersion ); + // XP_ASSERT( streamVersion <= CUR_STREAM_VERS ); /* else do what? */ gameID = stream_getU32( stream ); XP_LOGF( "read gameID of %lx; calling comms_setConnID", gameID ); @@ -1231,21 +1244,21 @@ client_readInitialMessage( ServerCtxt* server, XWStreamCtxt* stream ) /* now read the assigned tiles for each player from the stream, and remove them from the newly-created local pool. */ - for ( i = 0; i < nPlayers; ++i ) { + for ( ii = 0; ii < nPlayers; ++ii ) { TrayTileSet tiles; traySetFromStream( stream, &tiles ); XP_ASSERT( tiles.nTiles <= MAX_TRAY_TILES ); - XP_STATUSF( "got %d tiles for player %d", tiles.nTiles, i ); + XP_LOGF( "%s: got %d tiles for player %d", __func__, tiles.nTiles, ii ); - model_assignPlayerTiles( model, i, &tiles ); + model_assignPlayerTiles( model, ii, &tiles ); /* remove what the server's assigned so we won't conflict later. */ pool_removeTiles( pool, &tiles ); - sortTilesIf( server, i ); + sortTilesIf( server, ii ); } syncPlayers( server ); @@ -1277,25 +1290,25 @@ makeSendableGICopy( ServerCtxt* server, CurGameInfo* giCopy, { XP_U16 nPlayers; LocalPlayer* clientPl; - XP_U16 i; + XP_U16 ii; + XP_MEMCPY( giCopy, server->vol.gi, sizeof(*giCopy) ); nPlayers = giCopy->nPlayers; - for ( clientPl = giCopy->players, i = 0; - i < nPlayers; ++clientPl, ++i ) { + for ( clientPl = giCopy->players, ii = 0; + ii < nPlayers; ++clientPl, ++ii ) { /* adjust isLocal to client's perspective */ - clientPl->isLocal = server->players[i].deviceIndex == deviceIndex; + clientPl->isLocal = server->players[ii].deviceIndex == deviceIndex; } - giCopy->dictName = (XP_UCHAR*)NULL; /* so we don't sent the bytes; Isn't this - a leak? PENDING */ + giCopy->dictName = (XP_UCHAR*)NULL; /* so we don't sent the bytes */ } /* makeSendableGICopy */ static void server_sendInitialMessage( ServerCtxt* server ) { - short i; + XP_U16 ii; XP_U16 deviceIndex; ModelCtxt* model = server->vol.model; XP_U16 nPlayers = server->vol.gi->nPlayers; @@ -1313,7 +1326,12 @@ server_sendInitialMessage( ServerCtxt* server ) stream_open( stream ); writeProto( server, stream, XWPROTO_CLIENT_SETUP ); +#ifdef STREAM_VERS_BIGBOARD + XP_ASSERT( 0 < server->nv.streamVersion ); + stream_putU8( stream, server->nv.streamVersion ); +#else stream_putU8( stream, CUR_STREAM_VERS ); +#endif XP_LOGF( "putting gameID %lx into msg", gameID ); stream_putU32( stream, gameID ); @@ -1324,8 +1342,8 @@ server_sendInitialMessage( ServerCtxt* server ) dict_writeToStream( dict, stream ); /* send tiles currently in tray */ - for ( i = 0; i < nPlayers; ++i ) { - model_trayToStream( model, i, stream ); + for ( ii = 0; ii < nPlayers; ++ii ) { + model_trayToStream( model, ii, stream ); } stream_destroy( stream ); @@ -1686,7 +1704,7 @@ static void assignTilesToAll( ServerCtxt* server ) { XP_U16 numAssigned; - short i; + XP_U16 ii; ModelCtxt* model = server->vol.model; XP_U16 nPlayers = server->vol.gi->nPlayers; @@ -1706,11 +1724,11 @@ assignTilesToAll( ServerCtxt* server ) if ( numAssigned > MAX_TRAY_TILES ) { numAssigned = MAX_TRAY_TILES; } - for ( i = 0; i < nPlayers; ++i ) { + for ( ii = 0; ii < nPlayers; ++ii ) { TrayTileSet newTiles; - fetchTiles( server, i, numAssigned, NULL, &newTiles ); - model_assignPlayerTiles( model, i, &newTiles ); - sortTilesIf( server, i ); + fetchTiles( server, ii, numAssigned, NULL, &newTiles ); + model_assignPlayerTiles( model, ii, &newTiles ); + sortTilesIf( server, ii ); } } /* assignTilesToAll */ From cbd455148d5bab0ccac79f76250da8a58c7bc093 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 1 Dec 2011 20:23:58 -0800 Subject: [PATCH 12/16] comment only. I tracked down the most recent network proto change from before which devices probably can't upgrade mid-game once the MAX_COLS=32 change is enabled and wanted to record it. --- xwords4/common/comtypes.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xwords4/common/comtypes.h b/xwords4/common/comtypes.h index 6f2707316..36bd2d310 100644 --- a/xwords4/common/comtypes.h +++ b/xwords4/common/comtypes.h @@ -52,6 +52,11 @@ #endif #define STREAM_SAVE_PREVWORDS 0x11 #define STREAM_VERS_SERVER_SAVES_TOSHOW 0x10 +/* STREAM_VERS_PLAYERDICTS affects stream sent between devices. May not be + able to upgrade somebody who's this far back to something with + STREAM_VERS_BIGBOARD defined. It was added in rev 3b7b4802, on 2011-04-01, + which makes it part of android_beta_25 (tag added Apr 29 2011). + */ #define STREAM_VERS_PLAYERDICTS 0x0F #define STREAM_SAVE_PREVMOVE 0x0E /* server saves prev move explanation */ #define STREAM_VERS_ROBOTIQ STREAM_SAVE_PREVMOVE /* robots have different smarts */ From 85fdb950bb8c4df8794ec134b62c8447b12af638 Mon Sep 17 00:00:00 2001 From: Andy2 Date: Thu, 1 Dec 2011 21:04:18 -0800 Subject: [PATCH 13/16] init board so deeper scrolling possible --- xwords4/linux/gtkmain.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xwords4/linux/gtkmain.c b/xwords4/linux/gtkmain.c index 092d5740c..ece53ab1f 100644 --- a/xwords4/linux/gtkmain.c +++ b/xwords4/linux/gtkmain.c @@ -560,7 +560,7 @@ configure_event( GtkWidget* widget, GdkEventConfigure* XP_UNUSED(event), /* move tray up if part of board's meant to be hidden */ trayTop -= vscale * globals->cGlobals.params->nHidden; board_setPos( globals->cGlobals.game.board, GTK_BOARD_LEFT, boardTop, - hscale * nCols, vscale * nRows, hscale * 2, XP_FALSE ); + hscale * nCols, vscale * nRows, hscale * 4, XP_FALSE ); /* board_setScale( globals->cGlobals.game.board, hscale, vscale ); */ globals->gridOn = XP_TRUE; @@ -1056,9 +1056,11 @@ disenable_buttons( GtkAppGlobals* globals ) gtk_widget_set_sensitive( globals->prevhint_button, canHing ); gtk_widget_set_sensitive( globals->nexthint_button, canHing ); +#ifdef XWFEATURE_CHAT XP_Bool canChat = !!globals->cGlobals.game.comms && comms_canChat( globals->cGlobals.game.comms ); gtk_widget_set_sensitive( globals->chat_button, canChat ); +#endif } static gboolean From 3e21b7845a4611300bd8a158e215a05b59adb7a3 Mon Sep 17 00:00:00 2001 From: Andy2 Date: Thu, 1 Dec 2011 21:04:31 -0800 Subject: [PATCH 14/16] comment --- xwords4/common/board.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xwords4/common/board.c b/xwords4/common/board.c index 81b24d304..f2569f81f 100644 --- a/xwords4/common/board.c +++ b/xwords4/common/board.c @@ -65,7 +65,7 @@ #include "dragdrpp.h" #include "dbgutil.h" -#ifndef MAX_BOARD_ZOOM +#ifndef MAX_BOARD_ZOOM /* width in cells visible at max zoom */ /* too big looks bad */ # define MAX_BOARD_ZOOM 4 #endif From fc001023844b6343c9c5be16cdb08b46c20b64d8 Mon Sep 17 00:00:00 2001 From: Andy2 Date: Thu, 1 Dec 2011 21:09:37 -0800 Subject: [PATCH 15/16] don't leak/fail to install zoom-out button when chat enabled --- xwords4/linux/gtkmain.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xwords4/linux/gtkmain.c b/xwords4/linux/gtkmain.c index ece53ab1f..38225ba87 100644 --- a/xwords4/linux/gtkmain.c +++ b/xwords4/linux/gtkmain.c @@ -1896,12 +1896,13 @@ makeVerticalBar( GtkAppGlobals* globals, GtkWidget* XP_UNUSED(window) ) gtk_box_pack_start( GTK_BOX(vbox), button, FALSE, TRUE, 0 ); button = makeShowButtonFromBitmap( globals, "../done.xpm", "-", G_CALLBACK(handle_zoomout_button) ); + gtk_box_pack_start( GTK_BOX(vbox), button, FALSE, TRUE, 0 ); #ifdef XWFEATURE_CHAT button = makeShowButtonFromBitmap( globals, "", "chat", G_CALLBACK(handle_chat_button) ); globals->chat_button = button; -#endif gtk_box_pack_start( GTK_BOX(vbox), button, FALSE, TRUE, 0 ); +#endif gtk_widget_show( vbox ); return vbox; From 4c320a52e7909c9001483db7d57dcd6a0f798a85 Mon Sep 17 00:00:00 2001 From: Andy2 Date: Thu, 1 Dec 2011 21:10:04 -0800 Subject: [PATCH 16/16] allow scrolling to go a bit deeper --- .../android/XWords4/src/org/eehouse/android/xw4/BoardView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java index d78afe512..6f7ae697c 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java @@ -262,7 +262,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler, int nCells = gi.boardSize; int cellSize = width / nCells; - int maxCellSize = 3 * m_defaultFontHt; + int maxCellSize = 4 * m_defaultFontHt; if ( cellSize > maxCellSize ) { cellSize = maxCellSize;