Merge branch 'android_branch' into android_sms_kitkat

This commit is contained in:
Eric House 2013-12-05 20:03:47 -08:00
commit 1f3bd63769
53 changed files with 430 additions and 116 deletions

View file

@ -1,8 +1,7 @@
tags:
etags $$(find . \
-name '*.java' -print \
-o -name '*.c' -print \
etags $$(find . -name '*.c' -print \
-o -name '*.h' -print \
-o -name '*.cpp' -print \
)
)
find android/XWords4/src/ -name '*.java' | xargs etags -a

View file

@ -2,6 +2,5 @@
local.properties
bin
gen
libs
proguard.cfg
obj

View file

@ -22,10 +22,22 @@
to come from a domain that you own or have control over. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.eehouse.android.xw4bt"
android:versionCode="35"
android:versionCode="68"
android:versionName="@string/app_version"
>
<!-- BE SURE TO MODIFY project.project AND the variable TARGET in
../scripts/setup_local_props.sh if targetSdkVersion changes!!!
-->
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="14" />
<supports-screens android:resizeable="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
@ -37,7 +49,19 @@
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="7" />
<uses-feature android:name="android.hardware.telephony"
android:required = "false"
/>
<uses-feature android:name="android.hardware.nfc" android:required="false" />
<!-- GCM stuff -->
<permission android:name="org.eehouse.android.xw4.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="org.eehouse.android.xw4.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.NFC" />
<application android:icon="@drawable/icon48x48"
android:label="@string/app_name"
@ -47,17 +71,24 @@
<activity android:name="GamesList"
android:label="@string/app_name"
android:launchMode="standard"
android:configChanges="keyboardHidden|orientation"
android:configChanges="keyboardHidden|orientation|screenSize"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="@string/xwords_nfc_mime" />
</intent-filter>
</activity>
<activity android:name="DictsActivity"
android:label="@string/title_dicts_list"
android:configChanges="keyboardHidden|orientation"
android:configChanges="keyboardHidden|orientation|screenSize"
/>
<activity android:name="NewGameActivity"
@ -65,17 +96,17 @@
/>
<activity android:name="BTInviteActivity"
android:theme="@android:style/Theme.Dialog"
android:configChanges="keyboardHidden|orientation"
android:configChanges="keyboardHidden|orientation|screenSize"
/>
<activity android:name="SMSInviteActivity"
android:theme="@android:style/Theme.Dialog"
android:configChanges="keyboardHidden|orientation"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait"
/>
<activity android:name="GameConfig"
android:screenOrientation="sensor"
android:configChanges="keyboardHidden|orientation"
android:configChanges="keyboardHidden|orientation|screenSize"
>
<intent-filter>
<action android:name="android.intent.action.EDIT" />
@ -85,18 +116,16 @@
<activity android:name="PrefsActivity"
android:label="@string/title_prefs"
android:screenOrientation="sensor"
>
</activity>
android:configChanges="keyboardHidden|orientation|screenSize"
/>
<activity android:name="BoardActivity"
android:theme="@android:style/Theme.Light"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden"
>
</activity>
/>
<activity android:name="LookupActivity"
android:configChanges="keyboardHidden|orientation"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="@android:style/Theme.Dialog"
/>
@ -106,8 +135,13 @@
</intent-filter>
</receiver>
<activity android:name="DispatchNotify"
>
<receiver android:name="UpdateCheckReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
<activity android:name="DispatchNotify">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
@ -115,6 +149,24 @@
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="newxwgame"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http"
android:host="@string/invite_host"
android:pathPrefix="@string/invite_prefix"
/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="@string/invite_mime" />
</intent-filter>
</activity>
<!-- downloading dicts -->
@ -136,10 +188,10 @@
<activity android:name="RelayGameActivity"/>
<activity android:name="DictBrowseActivity"
android:configChanges="keyboardHidden|orientation"
android:configChanges="keyboardHidden|orientation|screenSize"
/>
<activity android:name="ChatActivity"
android:configChanges="keyboardHidden|orientation"
android:configChanges="keyboardHidden|orientation|screenSize"
/>
<service android:name="RelayService"/>
@ -174,5 +226,16 @@
<service android:name="SMSService"/>
<receiver android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="org.eehouse.android.xw4" />
</intent-filter>
</receiver>
<service android:name=".GCMIntentService" />
</application>
</manifest>

View file

@ -45,19 +45,32 @@
unless="sdk.dir"
/>
<target name="-pre-clean">
<exec dir="." executable="../scripts/ndkbuild.sh" output="/dev/null">
<arg value="clean"/>
</exec>
</target>
<!-- extension targets. Uncomment the ones where you want to do custom work
in between standard targets -->
<property name="INITIAL_CLIENT_VERS" value="3"/>
<target name="-pre-clean">
<exec dir="." executable="../scripts/ndksetup.sh" output="/dev/null">
<arg value="${build.target}"/>
</exec>
<exec dir="." executable="../scripts/ndkbuild.sh" output="/dev/null">
<arg value="clean"/>
</exec>
<exec dir="." executable="../scripts/mkimages.sh"
failonerror="true" >
<arg value="--clean"/>
</exec>
</target>
<target name="-pre-build">
<exec dir="." executable="../scripts/mkvariant.sh" output="/dev/null">
<exec dir="." executable="../scripts/mkvariant.sh" failonerror="true"
output="/dev/null">
<arg value="--variant-name"/>
<arg value="xw4bt"/>
<arg value="--app-name"/>
<arg value="cWords-BT"/>
<arg value="--dest-dir"/>
<arg value="./res"/>
<arg value="--dest-dir"/>
@ -66,15 +79,40 @@
<arg value="./jni"/>
<arg value="--dest-dir"/>
<arg value="./assets"/>
<arg value="--dest-dir"/>
<arg value="./img_src"/>
</exec>
<exec dir="." executable="../scripts/ndkbuild.sh" output="/dev/null">
<exec dir="." executable="../scripts/ndksetup.sh" output="/dev/null">
<arg value="${build.target}"/>
</exec>
<property name="CHAT_ENABLED" value="true" />
<property name="THUMBNAIL_ENABLED" value="true" />
<exec dir="." executable="../scripts/ndkbuild.sh" failonerror="true">
<arg value="BUILD_TARGET=${build.target}" />
<arg value="-j3"/>
<arg value="INITIAL_CLIENT_VERS=${INITIAL_CLIENT_VERS}" />
<arg value="CHAT_ENABLED=${CHAT_ENABLED}" />
<arg value="THUMBNAIL_ENABLED=${THUMBNAIL_ENABLED}" />
</exec>
<exec dir="." executable="../scripts/mkimages.sh"
failonerror="true" output="/dev/null"
/>
<exec dir="." executable="../scripts/gen_gcmid.sh"
output="src/org/eehouse/android/xw4bt/GCMConsts.java"
failonerror="true" logError="true"
>
<arg value="xw4bt"/>
</exec>
<exec dir=".." executable="./scripts/genvers.sh" output="/dev/null">
<arg value="XWords4-bt"/>
<arg value="xw4bt"/>
<arg value="${INITIAL_CLIENT_VERS}" />
<arg value="${CHAT_ENABLED}" />
<arg value="${THUMBNAIL_ENABLED}" />
</exec>
</target>
<!--
<target name="-pre-compile">

View file

@ -17,3 +17,4 @@ xportwrapper.h
xptypes.h
xwjni.c
#paths.h#
Application.mk

View file

@ -4,40 +4,52 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
COMMON_PATH=../../../common
local_C_INCLUDES+= \
LOCAL_C_INCLUDES+= \
-I$(LOCAL_PATH)/$(COMMON_PATH) \
-I$(LOCAL_PATH)/../../../relay \
local_LDLIBS += -llog
LOCAL_LDLIBS += -llog
local_DEBUG = -DMEM_DEBUG -DDEBUG -DENABLE_LOGGING
local_DEFINES += \
$(local_DEBUG) \
ifeq ($(BUILD_TARGET),debug)
LOCAL_DEBUG = -DMEM_DEBUG -DDEBUG -DENABLE_LOGGING -DCOMMS_CHECKSUM -Wno-unused-but-set-variable
endif
LOCAL_DEFINES += \
$(LOCAL_DEBUG) \
-DXWFEATURE_RELAY \
-DXWFEATURE_BLUETOOTH \
-DXWFEATURE_SMS \
-DXWFEATURE_COMMSACK \
-DXWFEATURE_TURNCHANGENOTIFY \
-DXWFEATURE_CHAT \
-DCOMMS_XPORT_FLAGSPROC \
-DKEY_SUPPORT \
-DXWFEATURE_CROSSHAIRS \
-DPOINTER_SUPPORT \
-DSCROLL_DRAG_THRESHHOLD=1 \
-DDROP_BITMAPS \
-DDISABLE_EMPTYTRAY_UNDO \
-DXWFEATURE_TRAYUNDO_ONE \
-DDISABLE_TILE_SEL \
-DXWFEATURE_BOARDWORDS \
-DXWFEATURE_WALKDICT \
-DXWFEATURE_WALKDICT_FILTER \
-DXWFEATURE_DICTSANITY \
-DFEATURE_TRAY_EDIT \
-DXWFEATURE_BONUSALL \
-DMAX_ROWS=32 \
-DINITIAL_CLIENT_VERS=2 \
-DRELAY_ROOM_DEFAULT=\"\"\
-DHASH_STREAM \
-DXWFEATURE_BASE64 \
-DXWFEATURE_DEVID \
-DCOMMON_LAYOUT \
-DINITIAL_CLIENT_VERS=${INITIAL_CLIENT_VERS} \
-DRELAY_ROOM_DEFAULT=\"\" \
-D__LITTLE_ENDIAN \
ifeq ($(CHAT_ENABLED),true)
LOCAL_DEFINES += -DXWFEATURE_CHAT
endif
local_SRC_FILES += \
# -DXWFEATURE_SCOREONEPASS \
LOCAL_SRC_FILES += \
xwjni.c \
utilwrapper.c \
drawwrapper.c \
@ -48,7 +60,7 @@ local_SRC_FILES += \
COMMON_PATH=../../../common
common_SRC_FILES += \
COMMON_SRC_FILES += \
$(COMMON_PATH)/boarddrw.c \
$(COMMON_PATH)/scorebdp.c \
$(COMMON_PATH)/dragdrpp.c \
@ -71,11 +83,12 @@ common_SRC_FILES += \
$(COMMON_PATH)/dbgutil.c \
LOCAL_CFLAGS+=$(local_C_INCLUDES) $(local_DEFINES) -Wall
LOCAL_SRC_FILES := $(linux_SRC_FILES) $(local_SRC_FILES) $(common_SRC_FILES)
LOCAL_CFLAGS+=$(LOCAL_C_INCLUDES) $(LOCAL_DEFINES) -Wall
LOCAL_SRC_FILES := $(linux_SRC_FILES) $(LOCAL_SRC_FILES) $(COMMON_SRC_FILES)
LOCAL_MODULE := xwjni
LOCAL_LDLIBS := -L${SYSROOT}/usr/lib -llog -lz
LOCAL_LDLIBS := -L${SYSROOT}/usr/lib -llog -lz
include $(BUILD_SHARED_LIBRARY)
COMMON_SRC_FILES :=
COMMON_PATH :=

View file

@ -0,0 +1 @@
/armeabi

Binary file not shown.

View file

@ -8,4 +8,4 @@
# project structure.
# Project target.
target=android-8
target=Google Inc.:Google APIs:14

View file

@ -0,0 +1,16 @@
back__gen.png
content_discard__gen.png
content_edit.png
content_new__gen.png
dict__gen.png
down__gen.png
download__gen.png
edit__gen.png
email__gen.png
new_group__gen.png
prefs__gen.png
relabel__gen.png
reset__gen.png
save__gen.png
send__gen.png
up__gen.png

View file

@ -0,0 +1,16 @@
back__gen.png
content_discard__gen.png
content_edit.png
content_new__gen.png
dict__gen.png
down__gen.png
download__gen.png
edit__gen.png
email__gen.png
new_group__gen.png
prefs__gen.png
relabel__gen.png
reset__gen.png
save__gen.png
send__gen.png
up__gen.png

View file

@ -0,0 +1,16 @@
back__gen.png
content_discard__gen.png
content_edit.png
content_new__gen.png
dict__gen.png
down__gen.png
download__gen.png
edit__gen.png
email__gen.png
new_group__gen.png
prefs__gen.png
relabel__gen.png
reset__gen.png
save__gen.png
send__gen.png
up__gen.png

View file

@ -23,3 +23,7 @@ stat_notify_sync.png
undo.png
values.png
zoom.png
in_arrow_active.png
in_arrow.png
out_arrow_active.png
out_arrow.png

View file

@ -0,0 +1 @@
board.xml

View file

@ -29,3 +29,5 @@ rename_game.xml
select_dialog_item.xml
smsinviter_item.xml
smsinviter.xml
confirm_sms.xml
game_list_group.xml

View file

@ -0,0 +1 @@
board_menu.xml

View file

@ -3,3 +3,4 @@ chat_menu.xml
dicts_item_menu.xml
games_list_item_menu.xml
games_list_menu.xml
dicts_menu.xml

View file

@ -0,0 +1 @@
styles.xml

View file

@ -0,0 +1 @@
strings.xml

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">CrossW-BT</string>
<string name="app_version">4.4-bt beta 76</string>
</resources>

View file

@ -55,3 +55,26 @@ SMSListItem.java
SMSReceiver.java
SMSService.java
MultiService.java
ABUtils.java
BoardCanvas.java
BuildConstants.java
ConnStatusHandler.java
DlgState.java
ExpiringDelegate.java
ExpiringLinearLayout.java
ExpiringTextView.java
GameListGroup.java
GameListItem.java
GameLock.java
GCMConsts.java
GCMIntentService.java
NFCUtils.java
SelectableItem.java
SMSCheckBoxPreference.java
ThumbCanvas.java
UpdateCheckReceiver.java
XWExpandableListActivity.java
XWPrefs.java
XWService.java
XWSumListPreference.java
XWThumbListPreference.java

View file

@ -22,6 +22,7 @@ package org.eehouse.android.xw4bt;
import android.app.Application;
import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import java.util.UUID;
@ -31,7 +32,17 @@ public class XWApp extends Application {
public static final boolean BTSUPPORTED = true;
public static final boolean SMSSUPPORTED = true;
public static final String SMS_PUBLIC_HEADER = "-XW4b";
public static final boolean GCMSUPPORTED = true;
public static final boolean ATTACH_SUPPORTED = true;
public static final boolean REMATCH_SUPPORTED = false;
public static final boolean DEBUG_LOCKS = false;
public static final boolean DEBUG_EXP_TIMERS = false;
public static final boolean GCM_IGNORED = false;
public static final boolean UDP_ENABLED = true;
public static final String SMS_PUBLIC_HEADER = "-XW4";
public static final int MAX_TRAY_TILES = 7; // comtypes.h
public static final int SEL_COLOR = Color.argb( 0xFF, 0x09, 0x70, 0x93 );
private static UUID s_UUID = null;
private static Boolean s_onEmulator = null;
@ -48,8 +59,15 @@ public class XWApp extends Application {
getString( R.string.git_rev ) );
DbgUtils.logEnable( this );
ConnStatusHandler.loadState( this );
RelayReceiver.RestartTimer( this );
UpdateCheckReceiver.restartTimer( this );
BTService.startService( this );
SMSService.checkForInvites( this );
RelayService.startService( this );
GCMIntentService.init( this );
}
public static UUID getAppUUID()
@ -68,10 +86,8 @@ public class XWApp extends Application {
public static boolean onEmulator()
{
if ( null == s_onEmulator ) {
DbgUtils.logf( "Build.MODEL: %s", Build.MODEL );
s_onEmulator = new Boolean( Build.MODEL.contains("sdk") );
s_onEmulator = new Boolean( "google_sdk".equals(Build.MODEL) );
}
return s_onEmulator;
}
}

View file

@ -15,3 +15,4 @@ TransportProcs.java
UtilCtxtImpl.java
UtilCtxt.java
XwJNI.java
BoardDims.java

View file

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

View file

@ -85,15 +85,16 @@
<exec dir="." executable="../scripts/gen_gcmid.sh"
output="src/org/eehouse/android/xw4/GCMConsts.java"
logError="true"
/>
logError="true" failonerror="true"
>
<arg value="xw4"/>
</exec>
<exec dir=".." executable="./scripts/genvers.sh" output="ant_out.txt">
<arg value="XWords4"/>
<arg value="xw4"/>
<arg value="${INITIAL_CLIENT_VERS}" />
<arg value="${CHAT_ENABLED}" />
<arg value="${THUMBNAIL_ENABLED}" />
<arg value="${build.target}" />
</exec>
</target>
<!--

View file

@ -1409,6 +1409,7 @@ static const SetInfo gsi_ints[] = {
};
static const SetInfo gsi_bools[] = {
ARR_MEMBER( GameStateInfo,canHint ),
ARR_MEMBER( GameStateInfo, canUndo ),
ARR_MEMBER( GameStateInfo, canRedo ),
ARR_MEMBER( GameStateInfo, inTrade ),
ARR_MEMBER( GameStateInfo, tradeTilesSelected ),
@ -1416,6 +1417,7 @@ static const SetInfo gsi_bools[] = {
ARR_MEMBER( GameStateInfo, canShuffle ),
ARR_MEMBER( GameStateInfo, curTurnSelected ),
ARR_MEMBER( GameStateInfo, canHideRack ),
ARR_MEMBER( GameStateInfo, canTrade ),
};
JNIEXPORT void JNICALL

View file

@ -5,10 +5,10 @@
</style>
</head>
<body>
<b>Crosswords 4.4 beta 75 release</b>
<b>Crosswords 4.4 beta 76 release</b>
<p>(Betas 74 and 75 fix a couple of crashing bugs but add nothing
new, so the previous notes remain in place.)</p>
<p>(Betas 74 through 76 fix bugs but add nothing new, so the previous
notes remain in place.)</p>
<p>Beta 73 adds two new features, snapshots of in-progress games
displayed as part of the main Games List screen, and the ability to

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_version">4.4 beta 75</string>
<string name="app_version">4.4 beta 76</string>
</resources>

View file

@ -73,6 +73,7 @@ public class BTService extends XWService {
private static final String GAMEID_STR = "GMI";
private static final String LANG_STR = "LNG";
private static final String DICT_STR = "DCT";
private static final String NTO_STR = "TOT";
private static final String NHE_STR = "HER";
@ -102,16 +103,17 @@ public class BTService extends XWService {
String m_gameName;
int m_gameID;
int m_lang;
String m_dict;
int m_nPlayersT;
int m_nPlayersH;
public BTQueueElem( BTCmd cmd ) { m_cmd = cmd; m_failCount = 0; }
public BTQueueElem( BTCmd cmd, String targetName, String targetAddr,
int gameID, String gameName, int lang,
int nPlayersT, int nPlayersH ) {
String dict, int nPlayersT, int nPlayersH ) {
this( cmd, null, targetName, targetAddr, gameID );
m_lang = lang; m_nPlayersT = nPlayersT; m_nPlayersH = nPlayersH;
m_gameName = gameName;
m_lang = lang; m_dict = dict; m_nPlayersT = nPlayersT;
m_nPlayersH = nPlayersH; m_gameName = gameName;
}
public BTQueueElem( BTCmd cmd, byte[] buf, String targetName,
String targetAddr, int gameID ) {
@ -166,7 +168,7 @@ public class BTService extends XWService {
public static void inviteRemote( Context context, String hostName,
int gameID, String initialName,
int lang, int nPlayersT,
int lang, String dict, int nPlayersT,
int nPlayersH )
{
Intent intent = getIntentTo( context, INVITE );
@ -175,6 +177,7 @@ public class BTService extends XWService {
Assert.assertNotNull( initialName );
intent.putExtra( GAMENAME_STR, initialName );
intent.putExtra( LANG_STR, lang );
intent.putExtra( DICT_STR, dict );
intent.putExtra( NTO_STR, nPlayersT );
intent.putExtra( NHE_STR, nPlayersH );
@ -258,11 +261,12 @@ public class BTService extends XWService {
String gameName = intent.getStringExtra( GAMENAME_STR );
String addr = addrFor( target );
int lang = intent.getIntExtra( LANG_STR, -1 );
String dict = intent.getStringExtra( DICT_STR );
int nPlayersT = intent.getIntExtra( NTO_STR, -1 );
int nPlayersH = intent.getIntExtra( NHE_STR, -1 );
m_sender.add( new BTQueueElem( BTCmd.INVITE, target, addr,
gameID, gameName, lang,
nPlayersT, nPlayersH ) );
dict, nPlayersT, nPlayersH ) );
break;
case SEND:
byte[] buf = intent.getByteArrayExtra( MSG_STR );
@ -404,6 +408,7 @@ public class BTService extends XWService {
int gameID = is.readInt();
String gameName = is.readUTF();
int lang = is.readInt();
String dict = is.readUTF();
int nPlayersT = is.readInt();
int nPlayersH = is.readInt();
@ -415,7 +420,8 @@ public class BTService extends XWService {
String sender = host.getName();
CommsAddrRec addr = new CommsAddrRec( sender, host.getAddress() );
long rowid = GameUtils.makeNewBTGame( context, gameID, addr,
lang, nPlayersT, nPlayersH );
lang, dict, nPlayersT,
nPlayersH );
if ( DBUtils.ROWID_NOTFOUND == rowid ) {
result = BTCmd.INVITE_FAILED;
} else {
@ -680,6 +686,7 @@ public class BTService extends XWService {
outStream.writeInt( elem.m_gameID );
outStream.writeUTF( elem.m_gameName );
outStream.writeInt( elem.m_lang );
outStream.writeUTF( elem.m_dict );
outStream.writeInt( elem.m_nPlayersT );
outStream.writeInt( elem.m_nPlayersH );
outStream.flush();

View file

@ -762,16 +762,18 @@ public class BoardActivity extends XWActivity
&& m_gsi.canChat );
Utils.setItemVisible( menu, R.id.board_menu_tray,
!inTrade && m_gsi.canHideRack );
Utils.setItemVisible( menu, R.id.board_menu_trade,
m_gsi.canTrade );
Utils.setItemVisible( menu, R.id.board_menu_undo_last,
m_gsi.canUndo );
}
Utils.setItemVisible( menu, R.id.board_menu_invite, 0 < m_missing );
Utils.setItemVisible( menu, R.id.board_menu_undo_last, !inTrade );
Utils.setItemVisible( menu, R.id.board_menu_trade_cancel, inTrade );
Utils.setItemVisible( menu, R.id.board_menu_trade_commit,
inTrade && m_gsi.tradeTilesSelected );
Utils.setItemVisible( menu, R.id.board_menu_trade,
0 == m_missing && !m_gameOver && !inTrade );
inTrade && m_gsi.tradeTilesSelected
&& m_gsi.curTurnSelected );
Utils.setItemVisible( menu, R.id.board_menu_game_resign, !inTrade );
if ( !inTrade ) {
@ -2159,7 +2161,8 @@ public class BoardActivity extends XWActivity
case COMMS_CONN_BT:
BTService.inviteRemote( this, dev, m_gi.gameID,
gameName, m_gi.dictLang,
m_gi.nPlayers, 1 );
m_gi.dictName, m_gi.nPlayers,
1 );
break;
case COMMS_CONN_SMS:
SMSService.inviteRemote( this, dev, m_gi.gameID,

View file

@ -844,7 +844,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
if ( !useDark ) {
Bitmap src = ((BitmapDrawable)arrow).getBitmap();
Bitmap bitmap = src.copy( Bitmap.Config.RGB_565, true );
Bitmap bitmap = src.copy( Bitmap.Config.ARGB_8888, true );
for ( int xx = 0; xx < bitmap.getWidth(); ++xx ) {
for( int yy = 0; yy < bitmap.getHeight(); ++yy ) {
if ( BLACK == bitmap.getPixel( xx, yy ) ) {

View file

@ -229,7 +229,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
if ( null == s_bitmap ) {
s_bitmap = Bitmap.createBitmap( bmWidth, bmHeight,
Bitmap.Config.RGB_565 );
Bitmap.Config.ARGB_8888 );
}
if ( null == m_canvas ) {
m_canvas = new BoardCanvas( m_parent, s_bitmap, m_jniThread,

View file

@ -991,10 +991,11 @@ public class DBUtils {
if ( null == s_groupsCache ) {
HashMap<Long,GameGroupInfo> result =
new HashMap<Long,GameGroupInfo>();
initDB( context );
String[] columns = { ROW_ID, DBHelper.GROUPNAME,
DBHelper.EXPANDED };
String limit = 0 == nRows ? null : String.format( "%d", nRows );
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_GROUPS, columns,
@ -1576,6 +1577,7 @@ public class DBUtils {
FileOutputStream dest =
new FileOutputStream( toSDCard? sdcardDB : gamesDB );
copyFileStream( dest, src );
invalGroupsCache();
}
} catch( java.io.FileNotFoundException fnfe ) {
DbgUtils.loge( fnfe );

View file

@ -42,7 +42,7 @@ import junit.framework.Assert;
public class DbgUtils {
private static final String TAG = "XW4";
private static boolean s_doLog = BuildConstants.IS_DEBUG_BUILD;
private static boolean s_doLog = BuildConfig.DEBUG;
private static Time s_time = new Time();
@ -53,7 +53,7 @@ public class DbgUtils {
public static void logEnable( Context context )
{
boolean on = BuildConstants.IS_DEBUG_BUILD ||
boolean on = BuildConfig.DEBUG ||
XWPrefs.getPrefsBoolean( context, R.string.key_logging_on, false );
logEnable( on );
}

View file

@ -179,7 +179,7 @@ public class ExpiringDelegate {
private Drawable mkBackground( int pct )
{
Assert.assertTrue( 0 <= pct && pct <= 100 );
Bitmap bm = Bitmap.createBitmap( 100, 1, Bitmap.Config.RGB_565 );
Bitmap bm = Bitmap.createBitmap( 100, 1, Bitmap.Config.ARGB_8888 );
Canvas canvas = new Canvas(bm);
Paint paint = new Paint();

View file

@ -329,7 +329,8 @@ public class GameListAdapter implements ExpandableListAdapter {
long[] positions = getGroupPositions();
String[] names = new String[ positions.length ];
for ( int ii = 0; ii < names.length; ++ii ) {
names[ii] = info.get(positions[ii]).m_name;
GameGroupInfo ggi = info.get( positions[ii] );
names[ii] = ggi.m_name;
}
return names;
}
@ -486,10 +487,14 @@ public class GameListAdapter implements ExpandableListAdapter {
long[] result = positions;
if ( null != positions ) {
Set<Long> posns = gameInfo().keySet();
for ( long id : positions ) {
if ( ! posns.contains( id ) ) {
result = null;
break;
if ( positions.length != posns.size() ) {
result = null;
} else {
for ( long id : positions ) {
if ( ! posns.contains( id ) ) {
result = null;
break;
}
}
}
}

View file

@ -343,7 +343,7 @@ public class GameUtils {
int size = dim - (dim % nCols);
thumb = Bitmap.createBitmap( size, size,
Bitmap.Config.RGB_565 );
Bitmap.Config.ARGB_8888 );
XwJNI.board_figureLayout( gamePtr, gi, 0, 0, size, size,
0, 0, 0, 20, 20, false, null );
@ -479,24 +479,28 @@ public class GameUtils {
public static long makeNewBTGame( Context context, int gameID,
CommsAddrRec addr, int lang,
int nPlayersT, int nPlayersH )
String dict, int nPlayersT,
int nPlayersH )
{
return makeNewBTGame( context, DBUtils.GROUPID_UNSPEC, gameID, addr,
lang, nPlayersT, nPlayersH );
lang, dict, nPlayersT, nPlayersH );
}
public static long makeNewBTGame( Context context, long groupID,
int gameID, CommsAddrRec addr, int lang,
int nPlayersT, int nPlayersH )
String dict, int nPlayersT, int nPlayersH )
{
long rowid = -1;
int[] langa = { lang };
String[] dicta = { dict };
boolean isHost = null == addr;
if ( isHost ) {
addr = new CommsAddrRec( null, null );
}
return makeNewMultiGame( context, groupID, addr, langa, null,
nPlayersT, nPlayersH, null, gameID, isHost );
String inviteID = GameUtils.formatGameID( gameID );
return makeNewMultiGame( context, groupID, addr, langa, dicta,
nPlayersT, nPlayersH, inviteID, gameID,
isHost );
}
public static long makeNewSMSGame( Context context, int gameID,

View file

@ -385,15 +385,9 @@ public class GamesList extends XWExpandableListActivity
}
PreferenceManager.setDefaultValues( this, R.xml.xwprefs, isUpgrade );
String field = CommonPrefs.getSummaryField( this );
long[] positions = XWPrefs.getGroupPositions( this );
m_adapter = new GameListAdapter( this, listview, new Handler(),
this, positions, field );
setListAdapter( m_adapter );
m_adapter = makeNewAdapter();
listview.setOnItemLongClickListener( this );
m_adapter.expandGroups( listview );
NetUtils.informOfDeaths( this );
tryStartsFromIntent( getIntent() );
@ -671,7 +665,7 @@ public class GamesList extends XWExpandableListActivity
if ( m_menuPrepared ) {
boolean nothingSelected = 0 == (nGroupsSelected + nGamesSelected);
boolean showDbg = BuildConstants.IS_DEBUG_BUILD
boolean showDbg = BuildConfig.DEBUG
|| XWPrefs.getDebugEnabled( this );
showItemsIf( DEBUG_ITEMS, menu, nothingSelected && showDbg );
Utils.setItemVisible( menu, R.id.games_menu_loaddb,
@ -786,6 +780,8 @@ public class GamesList extends XWExpandableListActivity
case R.id.games_menu_loaddb:
DBUtils.loadDB( this );
XWPrefs.clearGroupPositions( this );
m_adapter = makeNewAdapter();
changeContent = true;
break;
case R.id.games_menu_storedb:
@ -1349,6 +1345,19 @@ public class GamesList extends XWExpandableListActivity
}
}
private GameListAdapter makeNewAdapter()
{
ExpandableListView listview = getExpandableListView();
String field = CommonPrefs.getSummaryField( this );
long[] positions = XWPrefs.getGroupPositions( this );
GameListAdapter adapter =
new GameListAdapter( this, listview, new Handler(),
this, positions, field );
setListAdapter( adapter );
adapter.expandGroups( listview );
return adapter;
}
public static void onGameDictDownload( Context context, Intent intent )
{
intent.setClass( context, GamesList.class );

View file

@ -230,7 +230,7 @@ public class NewGameActivity extends XWActivity {
if ( m_nameForBT ) {
BTService.inviteRemote( thiz, m_remoteDev,
m_gameID, m_gameName,
m_lang, 2, 1 );
m_lang, m_dict, 2, 1 );
startProgress( R.string.invite_progress );
} else {
SMSService.inviteRemote( thiz, m_remoteDev,
@ -294,7 +294,7 @@ public class NewGameActivity extends XWActivity {
long rowid =
GameUtils.makeNewBTGame( NewGameActivity.this,
m_groupID, gameID, null,
m_lang, 2, 1 );
m_lang, m_dict, 2, 1 );
DBUtils.setName( NewGameActivity.this,
rowid, m_gameName );
GameUtils.launchGame( NewGameActivity.this,
@ -365,7 +365,7 @@ public class NewGameActivity extends XWActivity {
if ( !useDefaults ) {
m_newRowID = GameUtils.makeNewBTGame( NewGameActivity.this,
m_groupID, gameID, null,
m_lang, 2, 1 );
m_lang, m_dict, 2, 1 );
Intent intent = new Intent( this, GameConfig.class );
intent.setAction( Intent.ACTION_EDIT );
intent.putExtra( GameUtils.INTENT_KEY_ROWID, m_newRowID );

View file

@ -319,6 +319,11 @@ public class XWPrefs {
setPrefsLong( context, R.string.key_default_group, val );
}
public static void clearGroupPositions( Context context )
{
setPrefsString( context, R.string.key_group_posns, null );
}
public static void setGroupPositions( Context context, long[] posns )
{
String[] asStrs = new String[posns.length];

View file

@ -40,8 +40,7 @@ public class XWSumListPreference extends XWListPreference {
{
super.onAttachedToActivity();
if ( BuildConstants.IS_DEBUG_BUILD ||
XWPrefs.getDebugEnabled( m_context ) ) {
if ( BuildConfig.DEBUG || XWPrefs.getDebugEnabled( m_context ) ) {
CharSequence[] entries = getEntries();
CharSequence lastRow = entries[entries.length - 1];
boolean done = false;

View file

@ -105,6 +105,7 @@ public class JNIThread extends Thread {
public int visTileCount;
public int trayVisState;
public boolean canHint;
public boolean canUndo;
public boolean canRedo;
public boolean inTrade;
public boolean tradeTilesSelected;
@ -112,6 +113,7 @@ public class JNIThread extends Thread {
public boolean canShuffle;
public boolean curTurnSelected;
public boolean canHideRack;
public boolean canTrade;
public GameStateInfo clone() {
GameStateInfo obj = null;
try {

View file

@ -8,10 +8,12 @@ if [ -z "$GCM_SENDER_ID" ]; then
echo "GCM_SENDER_ID empty; GCM use will be disabled" >&2
fi
PKG=$1
cat <<EOF
// Auto-generated: DO NOT CHECK THIS IN until questions about
// obscuring the id are cleared up
package org.eehouse.android.xw4;
package org.eehouse.android.$PKG;
public class GCMConsts {
public static final String SENDER_ID = "${GCM_SENDER_ID}";

View file

@ -7,7 +7,6 @@ VARIANT=$2
CLIENT_VERS_RELAY=$3
CHAT_SUPPORTED=$4
THUMBNAIL_SUPPORTED=$5
BUILD_TARGET=$6
cd $(dirname $0)
cd ../../
@ -38,7 +37,6 @@ class BuildConstants {
public static final short CLIENT_VERS_RELAY = $CLIENT_VERS_RELAY;
public static final boolean CHAT_SUPPORTED = $CHAT_SUPPORTED;
public static final boolean THUMBNAIL_SUPPORTED = $THUMBNAIL_SUPPORTED;
public static final boolean IS_DEBUG_BUILD = "$BUILD_TARGET".equals("debug");
}
EOF

View file

@ -2,14 +2,30 @@
set -u -e
APK=./bin/XWords4-debug.apk
usage() {
[ $# -ge 1 ] && echo "Error: $1"
echo "usage: $(basename $0) [-e|-d] [-p /path/to/.apk]"
exit 1
}
if [ ! -e build.xml ]; then
usage "No build.xml; please run me from the top android directory"
fi
APK=./bin/XWords4-debug.apk
DIRNAME=$(basename $(pwd))
case $DIRNAME in
XWords4-bt)
PKG=xw4bt
;;
XWords4)
PKG=xw4
;;
*)
usage "running in unexpected directory $DIRNAME"
;;
esac
DEVICES=''
while [ $# -ge 1 ]; do
@ -47,6 +63,8 @@ COUNT=0
for DEVICE in $DEVICES; do
echo $DEVICE
adb -s $DEVICE install -r $APK
adb -s $DEVICE shell am start \
-n org.eehouse.android.${PKG}/org.eehouse.android.${PKG}.GamesList
COUNT=$((COUNT+1))
done

View file

@ -9,11 +9,22 @@ fi
CLEAN=""
if [ $# -gt 1 ]; then
if [ $1 = '--clean' ]; then
CLEAN=1
fi
fi
usage() {
echo "usage: $0 [--clean]"
exit 1
}
while [ $# -ge 1 ]; do
case $1 in
--clean)
CLEAN=1
;;
*)
usage
;;
esac
shift
done
# There needs to be target in the makefile for each of these (giving
# the output .png size)

View file

@ -0,0 +1,6 @@
#!/bin/sh
WD=$(dirname $0)
$WD/uninstall.sh $*
$WD/install-all.sh $*

View file

@ -114,6 +114,7 @@ static XP_Bool setArrowVisibleFor( BoardCtxt* board, XP_U16 player,
static XP_Bool board_moveArrow( BoardCtxt* board, XP_Key cursorKey );
static XP_Bool board_setXOffset( BoardCtxt* board, XP_U16 offset );
static XP_Bool preflight( BoardCtxt* board, XP_Bool reveal );
#ifdef KEY_SUPPORT
@ -703,11 +704,20 @@ board_canShuffle( const BoardCtxt* board )
XP_Bool
board_canHideRack( const BoardCtxt* board )
{
XP_Bool result = board->boardObscuresTray || !board->gameOver;
XP_Bool result = 0 <= server_getCurrentTurn( board->server )
&& (board->boardObscuresTray || !board->gameOver);
LOG_RETURNF( "%d", result );
return result;
}
XP_Bool
board_canTrade( BoardCtxt* board )
{
XP_Bool result = preflight( board, XP_FALSE )
&& MIN_TRADE_TILES <= server_countTilesInPool( board->server );
return result;
}
XP_Bool
board_canTogglePending( const BoardCtxt* board )
{
@ -1923,11 +1933,11 @@ board_redoReplacedTiles( BoardCtxt* board )
/* There are a few conditions that must be true for any of several actions
to be allowed. Check them here. */
static XP_Bool
preflight( BoardCtxt* board )
preflight( BoardCtxt* board, XP_Bool reveal )
{
return !board->gameOver
&& server_getCurrentTurn(board->server) >= 0
&& checkRevealTray( board )
&& ( !reveal || checkRevealTray( board ) )
&& !TRADE_IN_PROGRESS(board);
} /* preflight */
@ -1960,7 +1970,7 @@ board_requestHint( BoardCtxt* board,
const TrayTileSet* tileSet;
ModelCtxt* model = board->model;
if ( !!engine && preflight( board ) ) {
if ( !!engine && preflight( board, XP_TRUE ) ) {
/* undo any current move. otherwise we won't pass the full tray
to the engine. Would it be better, though, to pass the whole
@ -2361,7 +2371,7 @@ board_beginTrade( BoardCtxt* board )
{
XP_Bool result;
result = preflight( board );
result = preflight( board, XP_TRUE );
if ( result ) {
if ( server_countTilesInPool(board->server) < MIN_TRADE_TILES){
util_userError( board->util, ERR_TOO_FEW_TILES_LEFT_TO_TRADE );

View file

@ -123,6 +123,7 @@ XP_Bool board_curTurnSelected( const BoardCtxt* board );
XP_U16 board_visTileCount( const BoardCtxt* board );
XP_Bool board_canShuffle( const BoardCtxt* board );
XP_Bool board_canHideRack( const BoardCtxt* board );
XP_Bool board_canTrade( BoardCtxt* board );
XP_Bool board_canTogglePending( const BoardCtxt* board );
XP_Bool board_canHint( const BoardCtxt* board );

View file

@ -321,11 +321,13 @@ game_getState( const XWGame* game, GameStateInfo* gsi )
gsi->trayVisState = board_getTrayVisState( board );
gsi->visTileCount = board_visTileCount( board );
gsi->canHint = !gameOver && board_canHint( board );
gsi->canUndo = model_canUndo( game->model );
gsi->canRedo = board_canTogglePending( board );
gsi->inTrade = board_inTrade( board, &gsi->tradeTilesSelected );
gsi->canChat = !!game->comms && comms_canChat( game->comms );
gsi->canShuffle = board_canShuffle( board );
gsi->canHideRack = board_canHideRack( board );
gsi->canTrade = board_canTrade( board );
}
void

View file

@ -36,6 +36,7 @@ typedef struct _GameStateInfo {
XP_U16 visTileCount;
XW_TrayVisState trayVisState;
XP_Bool canHint;
XP_Bool canUndo;
XP_Bool canRedo;
XP_Bool inTrade;
XP_Bool tradeTilesSelected;
@ -43,6 +44,7 @@ typedef struct _GameStateInfo {
XP_Bool canShuffle;
XP_Bool curTurnSelected;
XP_Bool canHideRack;
XP_Bool canTrade;
} GameStateInfo;
typedef struct XWGame {

View file

@ -822,6 +822,18 @@ model_rejectPreviousMove( ModelCtxt* model, PoolContext* pool, XP_U16* turn )
*turn = entry.playerNum;
} /* model_rejectPreviousMove */
XP_Bool
model_canUndo( const ModelCtxt* model )
{
const StackCtxt* stack = model->vol.stack;
XP_U16 nStackEntries = stack_getNEntries( stack );
/* More than just tile assignment? */
XP_Bool result = nStackEntries > model->nPlayers;
LOG_RETURNF( "%d", result );
return result;
}
/* Undo a move, but only if it's the move we're expecting to undo (as
* indicated by *moveNumP, if >= 0).
*/

View file

@ -192,7 +192,7 @@ void model_commitRejectedPhony( ModelCtxt* model, XP_S16 player );
void model_makeTileTrade( ModelCtxt* model, XP_S16 player,
const TrayTileSet* oldTiles,
const TrayTileSet* newTiles );
XP_Bool model_canUndo( const ModelCtxt* model );
XP_Bool model_undoLatestMoves( ModelCtxt* model, PoolContext* pool,
XP_U16 nMovesSought, XP_U16* turn,
XP_S16* moveNum );