Merge branch 'android_branch' into android_translate

This commit is contained in:
Eric House 2016-12-21 08:29:06 -08:00
commit e945bde663
170 changed files with 5312 additions and 2622 deletions

View file

@ -3,3 +3,4 @@
-/xwords4/linux/discon_ok2.sh_logs
-/xwords4/android/XWords4/res_src/values-pt/strings.xml
-/xwords4/android/XWords4/res_src/values-ba_CK/strings.xml
-/xwords4/relay/xwrelay.log

View file

@ -6,7 +6,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.xw4dbg"
android:versionCode="104"
android:versionCode="109"
android:versionName="@string/app_version"
>
@ -32,7 +32,11 @@
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- Added for wifi-direct; don't ship until move to 23!!! -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-feature android:name="android.hardware.telephony"
android:required = "false"
@ -54,7 +58,6 @@
<application android:icon="@drawable/icon48x48"
android:label="@string/app_name"
android:name=".XWApp"
android:debuggable="false"
>
<activity android:name="MainActivity"
@ -74,10 +77,6 @@
</intent-filter>
</activity>
<activity android:name="FragActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
/>
<activity android:name="DictsActivity"
android:label="@string/title_dicts_list"
android:configChanges="keyboardHidden|orientation|screenSize"
@ -96,6 +95,10 @@
android:label="@string/relay_invite_title"
android:configChanges="keyboardHidden|orientation|screenSize"
/>
<activity android:name="WiDirInviteActivity"
android:label="@string/p2p_invite_title"
android:configChanges="keyboardHidden|orientation|screenSize"
/>
<activity android:name="GameConfigActivity"
android:screenOrientation="sensor"
@ -197,6 +200,9 @@
/>
<service android:name="RelayService"/>
<service android:name="BTService"/>
<service android:name="WiDirService"/>
<service android:name="SMSService"/>
<receiver android:name=".MountEventReceiver">
<intent-filter>
@ -218,8 +224,6 @@
</intent-filter>
</receiver>
<service android:name="BTService"/>
<receiver android:name="SMSReceiver" >
<intent-filter>
<action android:name="android.intent.action.DATA_SMS_RECEIVED" />
@ -230,8 +234,6 @@
</receiver>
<service android:name="SMSService"/>
<receiver android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>

View file

@ -58,6 +58,7 @@
<property name="INITIAL_CLIENT_VERS" value="8"/>
<property name="VARIANT_NAME" value="xw4dbg"/>
<property name="APP_NAME" value="CrossDbg"/>
<property name="WIDIR_ENABLED" value="true" />
<target name="-pre-clean">
<antcall target="my-pre-clean" />

View file

@ -8,4 +8,4 @@
# project structure.
# Project target.
target=android-19
target=android-23

View file

@ -25,12 +25,8 @@ prefs_w_buttons.xml
relay_game_config.xml
rename_game.xml
select_dialog_item.xml
btinviter_item.xml
btinviter.xml
confirm_sms.xml
game_list_group.xml
smsinviter_item.xml
smsinviter.xml
studylist.xml
loc_list_item.xml
loc_main.xml
@ -49,3 +45,10 @@ fragact.xml
main.xml
dualcontainer.xml
dict_browser_list.xml
inviter_item.xml
inviter.xml
bt_buttons.xml
relay_buttons.xml
sms_buttons.xml
inviter_item_frame.xml
two_strs_item.xml

View file

@ -61,7 +61,6 @@ RelayReceiver.java
RelayService.java
SMSCheckBoxPreference.java
SMSInviteActivity.java
SMSListItem.java
SMSReceiver.java
SMSService.java
SelectableItem.java
@ -140,3 +139,10 @@ MainActivity.java
DictsFrag.java
DualpaneDelegate.java
BoardContainer.java
BiDiSockWrap.java
WiDirService.java
WiDirInviteActivity.java
WiDirInviteDelegate.java
XWPacket.java
TwoStrsItem.java
Perms23.java

View file

@ -1,19 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- -*- compile-command: "ant install"; -*- -->
<!-- Copyright (C) 2007 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Declare the contents of this Android application. The namespace
attribute brings in the Android platform namespace, and the package
@ -22,14 +7,14 @@
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="107"
android:versionCode="109"
android:versionName="@string/app_version"
>
<!-- BE SURE TO MODIFY project.project AND the variable TARGET in
<!-- BE SURE TO MODIFY project.properties AND the variable TARGET in
../scripts/setup_local_props.sh if targetSdkVersion changes!!!
-->
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="19" />
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="23" />
<supports-screens android:resizeable="true"
android:smallScreens="true"
@ -48,7 +33,11 @@
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- Added for wifi-direct; don't ship until move to 23!!! -->
<!-- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> -->
<!-- <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> -->
<uses-feature android:name="android.hardware.telephony"
android:required = "false"
@ -69,7 +58,7 @@
android:name=".XWApp"
>
<activity android:name="MainActivity"
<activity android:name="MainActivity"
android:label="@string/app_name"
android:launchMode="standard"
android:configChanges="keyboardHidden|orientation|screenSize"
@ -104,6 +93,10 @@
android:label="@string/relay_invite_title"
android:configChanges="keyboardHidden|orientation|screenSize"
/>
<activity android:name="WiDirInviteActivity"
android:label="@string/p2p_invite_title"
android:configChanges="keyboardHidden|orientation|screenSize"
/>
<activity android:name="GameConfigActivity"
android:screenOrientation="sensor"
@ -205,6 +198,8 @@
/>
<service android:name="RelayService"/>
<service android:name="BTService"/>
<service android:name="SMSService"/>
<receiver android:name=".MountEventReceiver">
<intent-filter>
@ -226,8 +221,6 @@
</intent-filter>
</receiver>
<service android:name="BTService"/>
<receiver android:name="SMSReceiver" >
<intent-filter>
<action android:name="android.intent.action.DATA_SMS_RECEIVED" />
@ -238,8 +231,6 @@
</receiver>
<service android:name="SMSService"/>
<receiver android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>

View file

@ -15,11 +15,11 @@ dependencies {
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 7
targetSdkVersion 19
targetSdkVersion 23
}
// Rename all output artifacts to include version information

File diff suppressed because it is too large Load diff

View file

@ -13,10 +13,10 @@
</style>
</head>
<body>
<h2>Crosswords 4.4.112 release</h2>
<h2>Crosswords 4.4.114 release</h2>
<p>This release fixes a crash introduced by the previous release
that occurred on some devices when creating new games.</p>
<p>This release fixes a drawing problem on Android Nougat version
only.</p>
<div id="survey">
<p>Please <a href="https://www.surveymonkey.com/s/GX3XLHR">take
@ -26,7 +26,11 @@
<h3>New with this release</h3>
<ul>
<li>Fix crash attempting to configure new network games</li>
<li>Fix (or work around) board drawing weirdness introduced with
Nougat. It showed most often when using the hint
feature.</li>
<li>Fix a couple of crashes reported via the Play Store --
thanks!</li>
</ul>
<p>(The full changelog
@ -34,6 +38,7 @@
<h3>Next up</h3>
<ul>
<li>Support WiFi Direct (currently working sporadically)</li>
<li>Take advantage of Marshmallow's new permissions model (where
the app only asks for permission, e.g. to send SMS, when it
needs it.)

View file

@ -26,8 +26,8 @@ subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 19
buildToolsVersion '22.0.1'
compileSdkVersion 23
buildToolsVersion "23.0.2"
}
}
}

View file

@ -59,6 +59,7 @@
<property name="VARIANT_NAME" value="xw4"/>
<property name="APP_NAME" value="Crosswords"/>
<property name="SKIP_LANGS" value="values-de"/>
<property name="WIDIR_ENABLED" value="false" />
<target name="-pre-clean">
<antcall target="my-pre-clean" />

View file

@ -10,7 +10,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit

View file

@ -18,6 +18,7 @@ LOCAL_DEFINES += \
-DXWFEATURE_RELAY \
-DXWFEATURE_BLUETOOTH \
-DXWFEATURE_SMS \
-DXWFEATURE_P2P \
-DXWFEATURE_COMMSACK \
-DXWFEATURE_TURNCHANGENOTIFY \
-DCOMMS_XPORT_FLAGSPROC \

View file

@ -490,6 +490,9 @@ setJAddrRec( JNIEnv* env, jobject jaddr, const CommsAddrRec* addr )
setString( env, jaddr, "bt_hostName", addr->u.bt.hostName );
setString( env, jaddr, "bt_btAddr", addr->u.bt.btAddr.chars );
break;
case COMMS_CONN_P2P:
setString( env, jaddr, "p2p_addr", addr->u.p2p.mac_addr );
break;
default:
XP_ASSERT(0);
}
@ -577,6 +580,10 @@ getJAddrRec( JNIEnv* env, CommsAddrRec* addr, jobject jaddr )
getString( env, jaddr, "bt_btAddr", addr->u.bt.btAddr.chars,
VSIZE(addr->u.bt.btAddr.chars) );
break;
case COMMS_CONN_P2P:
getString( env, jaddr, "p2p_addr", addr->u.p2p.mac_addr,
VSIZE(addr->u.p2p.mac_addr) );
break;
default:
XP_ASSERT(0);
}

View file

@ -45,11 +45,16 @@ typedef struct _AndDraw {
MPSLOT
} AndDraw;
#define CHECKOUT_MARKER ((jobject)-1)
static jobject
makeJRect( AndDraw* draw, int indx, const XP_Rect* rect )
{
JNIEnv* env = ENVFORME( draw->ti );
jobject robj = draw->jCache[indx];
#ifdef DEBUG
XP_ASSERT( CHECKOUT_MARKER != robj );
#endif
int right = rect->left + rect->width;
int bottom = rect->top + rect->height;
@ -70,9 +75,23 @@ makeJRect( AndDraw* draw, int indx, const XP_Rect* rect )
setInt( env, robj, "bottom", bottom );
}
#ifdef DEBUG
draw->jCache[indx] = CHECKOUT_MARKER;
#endif
return robj;
} /* makeJRect */
#ifdef DEBUG
static void
returnJRect( AndDraw* draw, int indx, jobject used )
{
XP_ASSERT( CHECKOUT_MARKER == draw->jCache[indx] );
draw->jCache[indx] = used;
}
#else
# define returnJRect( draw, indx, used )
#endif
#ifdef XWFEATURE_SCOREONEPASS
static void
readJRect( JNIEnv* env, XP_Rect* rect, jobject jrect )
@ -214,6 +233,7 @@ and_draw_scoreBegin( DrawCtx* dctx, const XP_Rect* rect,
result = (*env)->CallBooleanMethod( env, draw->jdraw, mid,
jrect, numPlayers, jscores, remCount );
returnJRect( draw, JCACHE_RECT0, jrect );
deleteLocalRef( env, jscores );
return result;
}
@ -231,6 +251,7 @@ and_draw_drawRemText( DrawCtx* dctx, XP_S16 nTilesLeft,
if ( result ) {
readJRect( env, rect, jrect );
}
returnJRect( draw, JCACHE_RECT0, jrect );
return result;
}
@ -252,6 +273,7 @@ and_draw_score_drawPlayers( DrawCtx* dctx, const XP_Rect* scoreRect,
jobject jrect = (*env)->GetObjectArrayElement( env, jrects, ii );
readJRect( env, &playerRects[ii], jrect );
}
returnJRect( draw, JCACHE_RECT0, jrect );
}
#else
@ -274,6 +296,7 @@ and_draw_measureRemText( DrawCtx* dctx, const XP_Rect* rect,
*width = getIntFromArray( env, widthArray, true );
*height = getIntFromArray( env, heightArray, true );
}
returnJRect( draw, JCACHE_RECT0, jrect );
return result;
} /* and_draw_measureRemText */
@ -290,6 +313,8 @@ and_draw_drawRemText( DrawCtx* dctx, const XP_Rect* rInner,
(*env)->CallVoidMethod( env, draw->jdraw, mid, jrinner, jrouter,
nTilesLeft, focussed );
returnJRect( draw, JCACHE_RECT0, jrinner );
returnJRect( draw, JCACHE_RECT1, jrouter );
}
static void
@ -310,6 +335,7 @@ and_draw_measureScoreText( DrawCtx* dctx,
(*env)->CallVoidMethod( env, draw->jdraw, mid, jrect, jdsi,
widthArray, heightArray );
returnJRect( draw, JCACHE_RECT0, jrect );
*width = getIntFromArray( env, widthArray, true );
*height = getIntFromArray( env, heightArray, true );
@ -330,6 +356,8 @@ and_draw_score_drawPlayer( DrawCtx* dctx, const XP_Rect* rInner,
(*env)->CallVoidMethod( env, draw->jdraw, mid, jrinner, jrouter, gotPct,
jdsi );
returnJRect( draw, JCACHE_RECT0, jrinner );
returnJRect( draw, JCACHE_RECT1, jrouter );
} /* and_draw_score_drawPlayer */
#endif
@ -345,6 +373,7 @@ and_draw_drawTimer( DrawCtx* dctx, const XP_Rect* rect, XP_U16 player,
jobject jrect = makeJRect( draw, JCACHE_RECT0, rect );
(*env)->CallVoidMethod( env, draw->jdraw, mid,
jrect, player, secondsLeft );
returnJRect( draw, JCACHE_RECT0, jrect );
}
}
@ -353,17 +382,11 @@ static XP_Bool and_draw_beginDraw( DrawCtx* XP_UNUSED(dctx) ) {return XP_TRUE;}
static void and_draw_endDraw( DrawCtx* XP_UNUSED(dctx) ) {}
static XP_Bool
and_draw_boardBegin( DrawCtx* dctx, const XP_Rect* rect,
XP_U16 cellWidth, XP_U16 cellHeight,
and_draw_boardBegin( DrawCtx* XP_UNUSED(dctx), const XP_Rect* XP_UNUSED(rect),
XP_U16 XP_UNUSED(cellWidth), XP_U16 XP_UNUSED(cellHeight),
DrawFocusState XP_UNUSED(dfs) )
{
DRAW_CBK_HEADER( "boardBegin", "(Landroid/graphics/Rect;II)Z" );
jobject jrect = makeJRect( draw, JCACHE_RECT0, rect );
jboolean result = (*env)->CallBooleanMethod( env, draw->jdraw, mid,
jrect, cellWidth, cellHeight );
return result;
return XP_TRUE;
}
static XP_Bool
@ -387,6 +410,7 @@ and_draw_drawCell( DrawCtx* dctx, const XP_Rect* rect, const XP_UCHAR* text,
jrect, jtext, tile, value,
owner, bonus, hintAtts,
flags );
returnJRect( draw, JCACHE_RECT0, jrect );
deleteLocalRef( env, jtext );
return result;
@ -401,6 +425,7 @@ and_draw_drawBoardArrow(DrawCtx* dctx, const XP_Rect* rect, XWBonusType bonus,
jobject jrect = makeJRect( draw, JCACHE_RECT0, rect );
(*env)->CallVoidMethod( env, draw->jdraw, mid,
jrect, bonus, vert, hintAtts, flags );
returnJRect( draw, JCACHE_RECT0, jrect );
}
static XP_Bool
@ -422,6 +447,7 @@ and_draw_trayBegin( DrawCtx* dctx, const XP_Rect* rect, XP_U16 owner,
jboolean result = (*env)->CallBooleanMethod( env, draw->jdraw, mid,
jrect, owner, score );
returnJRect( draw, JCACHE_RECT0, jrect );
return result;
}
@ -440,7 +466,7 @@ and_draw_drawTile( DrawCtx* dctx, const XP_Rect* rect, const XP_UCHAR* text,
result = (*env)->CallBooleanMethod( env, draw->jdraw, mid,
jrect, jtext, val, flags );
returnJRect( draw, JCACHE_RECT0, jrect );
deleteLocalRef( env, jtext );
return result;
}
@ -462,7 +488,7 @@ and_draw_drawTileMidDrag( DrawCtx* dctx, const XP_Rect* rect,
result = (*env)->CallBooleanMethod( env, draw->jdraw, mid,
jrect, jtext, val, owner, flags );
returnJRect( draw, JCACHE_RECT0, jrect );
deleteLocalRef( env, jtext );
return result;
}
@ -474,7 +500,9 @@ and_draw_drawTileBack( DrawCtx* dctx, const XP_Rect* rect, CellFlags flags )
jobject jrect = makeJRect( draw, JCACHE_RECT0, rect );
return (*env)->CallBooleanMethod( env, draw->jdraw, mid, jrect, flags );
XP_Bool result = (*env)->CallBooleanMethod( env, draw->jdraw, mid, jrect, flags );
returnJRect( draw, JCACHE_RECT0, jrect );
return result;
}
static void
@ -486,6 +514,7 @@ and_draw_drawTrayDivider( DrawCtx* dctx, const XP_Rect* rect, CellFlags flags )
(*env)->CallVoidMethod( env, draw->jdraw, mid,
jrect, flags );
returnJRect( draw, JCACHE_RECT0, jrect );
}
static void
@ -499,6 +528,7 @@ and_draw_score_pendingScore( DrawCtx* dctx, const XP_Rect* rect,
(*env)->CallVoidMethod( env, draw->jdraw, mid,
jrect, score, playerNum, curTurn, flags );
returnJRect( draw, JCACHE_RECT0, jrect );
}
static void
@ -512,6 +542,7 @@ and_draw_objFinished( DrawCtx* dctx, BoardObjectType typ,
jobject jrect = makeJRect( draw, JCACHE_RECT0, rect );
(*env)->CallVoidMethod( env, draw->jdraw, mid,
(jint)typ, jrect );
returnJRect( draw, JCACHE_RECT0, jrect );
#endif
}
@ -588,7 +619,7 @@ and_draw_drawMiniWindow( DrawCtx* dctx, const XP_UCHAR* text,
(*env)->CallVoidMethod( env, draw->jdraw, mid,
jstr, jrect );
returnJRect( draw, JCACHE_RECT0, jrect );
deleteLocalRef( env, jstr );
}
#endif

View file

@ -1693,19 +1693,23 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1summarize
setString( env, jsummary, "roomName", addr.u.ip_relay.invite );
}
break;
#if defined XWFEATURE_BLUETOOTH || defined XWFEATURE_SMS
#if defined XWFEATURE_BLUETOOTH || defined XWFEATURE_SMS || defined XWFEATURE_P2P
case COMMS_CONN_BT:
case COMMS_CONN_P2P:
case COMMS_CONN_SMS: {
XP_Bool isBT = COMMS_CONN_BT == typ;
CommsAddrRec addrs[MAX_NUM_PLAYERS];
XP_U16 count = VSIZE(addrs);
comms_getAddrs( comms, addrs, &count );
const XP_UCHAR* addrps[count];
for ( int ii = 0; ii < count; ++ii ) {
addrps[ii] = isBT ? (XP_UCHAR*)&addrs[ii].u.bt.btAddr :
(XP_UCHAR*)&addrs[ii].u.sms.phone;
XP_LOGF( "%s: adding btaddr/phone %s", __func__, addrps[ii] );
switch ( typ ) {
case COMMS_CONN_BT: addrps[ii] = (XP_UCHAR*)&addrs[ii].u.bt.btAddr; break;
case COMMS_CONN_P2P: addrps[ii] = (XP_UCHAR*)&addrs[ii].u.p2p.mac_addr; break;
case COMMS_CONN_SMS: addrps[ii] = (XP_UCHAR*)&addrs[ii].u.sms.phone; break;
default: XP_ASSERT(0); break;
}
XP_LOGF( "%s: adding btaddr/phone/mac %s", __func__, addrps[ii] );
}
jobjectArray jaddrs = makeStringArray( env, count, addrps );
setObject( env, jsummary, "remoteDevs", "[Ljava/lang/String;",
@ -1880,7 +1884,6 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1resendAll
( JNIEnv* env, jclass C, GamePtrType gamePtr, jboolean force, jobject jFilter,
jboolean thenAck )
{
LOG_FUNC();
jint result;
XWJNI_START();
CommsCtxt* comms = state->game.comms;
@ -1894,7 +1897,6 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1resendAll
#endif
}
XWJNI_END();
LOG_RETURNF( "%d", result );
return result;
}

View file

@ -11,4 +11,4 @@
# proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-19
target=android-23

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<Button android:id="@+id/button_add"
android:text="@string/bt_pick_addall_button"
style="@style/evenly_spaced_horizontal"
/>
<Button android:id="@+id/button_clear"
android:text="@string/bt_pick_clear_button"
style="@style/evenly_spaced_horizontal"
/>
</LinearLayout>

View file

@ -1,50 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView android:id="@+id/invite_desc"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:padding="8dp"
/>
<ListView android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false"
android:layout_weight="1"
android:padding="8dp"
/>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<Button android:id="@+id/button_rescan"
android:text="@string/bt_pick_addall_button"
style="@style/evenly_spaced_horizontal"
/>
<!-- <Button android:id="@+id/button_reconfigure" -->
<!-- android:text="@string/bt_pick_reconfig_button" -->
<!-- android:layout_width="wrap_content" -->
<!-- android:layout_height="wrap_content" -->
<!-- android:layout_weight="1" -->
<!-- /> -->
<Button android:id="@+id/button_clear"
android:text="@string/bt_pick_clear_button"
style="@style/evenly_spaced_horizontal"
/>
</LinearLayout>
<Button android:id="@+id/button_invite"
android:text="@string/button_invite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>

View file

@ -10,7 +10,7 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:padding="8dp"
android:padding="8dp"
/>
<ListView android:id="@id/android:list"
@ -24,29 +24,18 @@
<TextView android:id="@android:id/empty"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/empty_relay_inviter"
android:padding="20dp"
/>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<Button android:id="@+id/button_add"
android:text="@string/button_relay_add"
style="@style/evenly_spaced_horizontal"
/>
<Button android:id="@+id/button_clear"
android:text="@string/bt_pick_clear_button"
style="@style/evenly_spaced_horizontal"
/>
</LinearLayout>
<FrameLayout android:id="@+id/button_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<Button android:id="@+id/button_invite"
android:text="@string/button_invite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"
/>
</LinearLayout>

View file

@ -7,14 +7,21 @@
>
<CheckBox android:id="@+id/inviter_check"
style="@style/evenly_spaced_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Spinner android:id="@+id/nperdev_spinner"
style="@style/evenly_spaced_horizontal"
android:prompt="@string/nplayers_prompt"
android:drawSelectorOnTop="true"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<FrameLayout android:id="@+id/frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<Button android:id="@+id/button_relay_add"
android:text="@string/button_relay_add"
style="@style/evenly_spaced_horizontal"
/>
<ImageButton android:id="@+id/manual_add_button"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:src="@android:drawable/ic_input_add"
android:clickable="false"
/>
add_self_button
<Button android:id="@+id/button_clear"
android:text="@string/bt_pick_clear_button"
style="@style/evenly_spaced_horizontal"
/>
</LinearLayout>

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<Button android:id="@+id/button_add"
android:text="@string/button_sms_add"
style="@style/evenly_spaced_horizontal"
/>
<ImageButton android:id="@+id/manual_add_button"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:src="@android:drawable/ic_input_add"
android:clickable="false"
/>
<Button android:id="@+id/button_clear"
android:text="@string/bt_pick_clear_button"
style="@style/evenly_spaced_horizontal"
/>
</LinearLayout>

View file

@ -1,57 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView android:id="@+id/invite_desc"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:padding="8dp"
/>
<ListView android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false"
android:layout_weight="1"
android:padding="8dp"
/>
<TextView android:id="@android:id/empty"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/empty_sms_inviter"
android:padding="20dp"
/>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<Button android:id="@+id/button_add"
android:text="@string/button_sms_add"
style="@style/evenly_spaced_horizontal"
/>
<ImageButton android:id="@+id/manual_add_button"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:src="@android:drawable/ic_input_add"
android:clickable="false"
/>
<Button android:id="@+id/button_clear"
android:text="@string/bt_pick_clear_button"
style="@style/evenly_spaced_horizontal"
/>
</LinearLayout>
<Button android:id="@+id/button_invite"
android:text="@string/button_invite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>

View file

@ -1,42 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<org.eehouse.android.xw4.SMSListItem
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="8dp"
android:paddingRight="8dp"
>
<CheckBox android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView android:id="@+id/name"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<TextView android:id="@+id/number"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
</LinearLayout>
<Spinner android:id="@+id/nperdev_spinner"
style="@style/evenly_spaced_horizontal"
android:prompt="@string/nplayers_prompt"
android:drawSelectorOnTop="true"
android:visibility="gone"
/>
</LinearLayout>
</org.eehouse.android.xw4.SMSListItem>

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<org.eehouse.android.xw4.TwoStrsItem
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="8dp"
android:paddingRight="8dp"
>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView android:id="@+id/text1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<TextView android:id="@+id/text2"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
</LinearLayout>
</org.eehouse.android.xw4.TwoStrsItem>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_version">4.4.112</string>
<string name="app_version">4.4.114</string>
</resources>

View file

@ -125,6 +125,7 @@
<string name="key_nag_intervals">key_nag_intervals</string>
<string name="key_download_path">key_download_path</string>
<string name="key_got_langdict">key_got_langdict</string>
<string name="key_notagain_missing_perms">key_notagain_missing_perms</string>
<string name="key_xlations_locale">key_xlations_locale</string>
<string name="key_xlations_enabled">key_xlations_enabled</string>
<string name="key_invite_multi">key_invite_multi</string>
@ -133,6 +134,7 @@
<string name="key_notagain_dfltname">key_notagain_dfltname</string>
<string name="key_na_comms_bt">key_na_comms_bt</string>
<string name="key_na_comms_p2p">key_na_comms_p2p</string>
<string name="key_na_comms_sms">key_na_comms_sms</string>
<string name="key_na_comms_relay">key_na_comms_relay</string>

View file

@ -403,7 +403,7 @@
when user attempts to play word not in the wordlist. -->
<string name="phonies_disallow">Disallow phonies</string>
<!-- Shown when using the the Game configure screen to configure a
<!-- Shown when using the Game configure screen to configure a
networked game and you try to make all players local. -->
<string name="str_reg_server_sans_remote">At least one player must
be marked \"Remote\" for a game started as Host.</string>
@ -975,7 +975,7 @@
<string name="prefs_colors_summary">Edit colors used on the board</string>
<!-- The remaining strings (down to the color edit dialog below)
are showns as the names of editable colors and as the the
are showns as the names of editable colors and as the
title of the color editor that comes up when the name is
tapped. -->
<!-- (color for) double-letter bonus squares on the board -->
@ -1205,6 +1205,7 @@
<string name="invite_choice_bt">Bluetooth</string>
<string name="invite_choice_nfc">NFC (\"Android beaming\")</string>
<string name="invite_choice_relay">Internet/Relay</string>
<string name="invite_choice_p2p">Wifi Direct</string>
<string name="invite_choice_title">Inviting players: How?</string>
<!-- <string name="sms_or_email">Send invitation using SMS (texting) or -->
<!-- via email?</string> -->
@ -1899,11 +1900,11 @@
<string name="new_move_body">One or more moves has arrived</string>
<!-- -->
<plurals name="invite_bt_desc_fmt">
<item quantity="one">Please select the device
you want to include in this game. Use the \"%2$s\"
<item quantity="one">Please check the device
you want to include in this game.\n\nUse the \"%2$s\"
button if you don\'t see the device you expect.</item>
<item quantity="other">Please select up to %1$d device[s]
you want to include in this game. Use the \"%2$s\"
<item quantity="other">Please check up to %1$d device[s]
you want to include in this game.\n\nUse the \"%2$s\"
button if you don\'t see a device you expect.</item>
</plurals>
<!-- -->
@ -1920,6 +1921,7 @@
<!-- Title of phone number picker during invitation to a game via SMS -->
<string name="sms_invite_title">SMS Invitation</string>
<string name="relay_invite_title">Relay Invitation</string>
<string name="p2p_invite_title">WiFi Direct Invitation</string>
<!-- -->
<string name="game_btname_title">Bluetooth game name</string>
@ -1956,7 +1958,19 @@
to your new game, then tap \"%2$s\".</item>
</plurals>
<!-- -->
<string name="manual_owner_name">(Not in contacts)</string>
<plurals name="invite_p2p_desc_fmt">
<item quantity="one">Please select the name of the
WiFiDirect device you want to invite to your new game, then tap
\"%2$s\".</item>
<item quantity="other">Please select the %1$d WiFiDirect device names you
want to invite to your new game, then tap \"%2$s\".</item>
</plurals>
<string name="invite_p2p_desc_extra">Only devices that are
currently available are shown. If a nearby device isn\'t showing
up please make sure that WiFi is turned on, that Crosswords is
installed, and that play via WiFi Direct is enabled.</string>
<!-- -->
<string name="warn_nomobile_fmt">The number %1$s for %2$s is not
a \"mobile\" number. Import anyway?</string>
@ -1964,6 +1978,11 @@
<string name="empty_sms_inviter">This phone list is empty. Use the
\"Import contact\" button to add people you want to invite, the +
button to enter numbers directly.</string>
<!-- Shows in WiFiDirect Invite dialog when no known peers -->
<string name="empty_p2p_inviter">There are currently no devices
reachable via WiFiDirect that have Crosswords installed.</string>
<!-- -->
<string name="empty_relay_inviter">This list of devices is
empty. Use the \"Scan games\" button to scan your old games
@ -2627,6 +2646,9 @@
<string name="not_again_comms_bt">Use Bluetooth to play against a
nearby device that\'s \"paired\" with yours.</string>
<string name="not_again_comms_p2p">Use WiFi Direct to play against a
nearby WiFi Direct-capable device with Crosswords installed.</string>
<string name="str_no_hint_found">Cannot find any moves</string>
<string name="not_again_rematch_two_only">Rematch is limited to
@ -2694,4 +2716,27 @@
<string name="dualpane_restart">Exiting app…</string>
<string name="after_restart">This change will not take effect until
you restart Crosswords.</string>
<string name="not_again_missing_perms">This game is configured to
communicate via SMS but Crosswords does not have permission to do
so. You can still open the game, but it may not be able to send or
receive moves.\n\nYou can re-open it to be asked for permission
again. Or you can remove the SMS communication setting.</string>
<string name="phone_state_rationale">Crosswords wants to determine
whether your phone can send SMS \"data\" messages to give you the
option of playing that way. If you don\'t ever want to play via SMS,
e.g. because you pay for each message or have a Verizon phone, it\'s
safe to permanently deny permission.
</string>
<string name="contacts_rationale">Crosswords want access to your
contacts in order to put a name to phone numbers that send you
invitations via SMS. You\'ll still be able to receive invitations if
you don\'t grant this permission, but only the phone number of the
sender will be displayed.</string>
<string name="remove_sms">Remove SMS</string>
<string name="contact_not_found">Not in Contacts</string>
</resources>

View file

@ -342,7 +342,7 @@
<!-- Don't warn, but simply force to skip turn (give 0 points)
when user attempts to play word not in the wordlist. -->
<string name="phonies_disallow">Wollasid seinohp</string>
<!-- Shown when using the the Game configure screen to configure a
<!-- Shown when using the Game configure screen to configure a
networked game and you try to make all players local. -->
<string name="str_reg_server_sans_remote">Ta tsael eno reyalp tsum
eb dekram \"Etomer\" rof a emag detrats sa Tsoh.</string>
@ -839,7 +839,7 @@
<!-- clarification of the above -->
<string name="prefs_colors_summary">Tide sroloc desu no eht draob</string>
<!-- The remaining strings (down to the color edit dialog below)
are showns as the names of editable colors and as the the
are showns as the names of editable colors and as the
title of the color editor that comes up when the name is
tapped. -->
<!-- (color for) double-letter bonus squares on the board -->
@ -1039,6 +1039,7 @@
<string name="invite_choice_bt">Htooteulb</string>
<string name="invite_choice_nfc">CFN (\"Diordna gnimaeb\")</string>
<string name="invite_choice_relay">Yaler/tenRetni</string>
<string name="invite_choice_p2p">Ifiw Tcerid</string>
<string name="invite_choice_title">Gnitivni sreyalp: ?woh</string>
<!-- <string name="sms_or_email">Send invitation using SMS (texting) or -->
<!-- via email?</string> -->
@ -1636,11 +1637,11 @@
<string name="new_move_body">Eno ro erom sevom sah devirra</string>
<!-- -->
<plurals name="invite_bt_desc_fmt">
<item quantity="one">Esaelp tceles eht ecived
uoy tnaw ot edulcni ni siht emag. Esu eht \"%2$s\"
<item quantity="one">Esaelp kcehc eht ecived
uoy tnaw ot edulcni ni siht emag.\n\nEsu eht \"%2$s\"
nottub fi uoy nod\'t ees eht ecived uoy tcepxe.</item>
<item quantity="other">Esaelp tceles pu ot %1$d ]s[ecived
uoy tnaw ot edulcni ni siht emag. Esu eht \"%2$s\"
<item quantity="other">Esaelp kcehc pu ot %1$d ]s[ecived
uoy tnaw ot edulcni ni siht emag.\n\nEsu eht \"%2$s\"
nottub fi uoy nod\'t ees a ecived uoy tcepxe.</item>
</plurals>
<!-- -->
@ -1656,6 +1657,7 @@
<!-- Title of phone number picker during invitation to a game via SMS -->
<string name="sms_invite_title">SMS Noitativni</string>
<string name="relay_invite_title">Yaler Noitativni</string>
<string name="p2p_invite_title">IfIw Tcerid Noitativni</string>
<!-- -->
<string name="game_btname_title">Htooteulb emag eman</string>
<!-- -->
@ -1691,7 +1693,17 @@
ot ruoy wen ,emag neht pat \"%2$s\".</item>
</plurals>
<!-- -->
<string name="manual_owner_name">tOn( ni )stcatnoc</string>
<plurals name="invite_p2p_desc_fmt">
<item quantity="one">Esaelp tceles eht eman fo eht
TcErIdifiw ecived uoy tnaw ot etivni ot ruoy wen ,emag neht pat
\"%2$s\".</item>
<item quantity="other">Esaelp tceles eht %1$d TcErIdifiw ecived seman uoy
tnaw ot etivni ot ruoy wen ,emag neht pat \"%2$s\".</item>
</plurals>
<string name="invite_p2p_desc_extra">Ylno secived taht era
yltnerruc elbaliava era nwohs. Fi a ybraen ecived nsi\'t gniwohs
pu esaelp ekam erus taht IfIw si denrut ,no taht Sdrowssorc si
,dellatsni dna taht yalp aiv IfIw Tcerid si delbane.</string>
<!-- -->
<string name="warn_nomobile_fmt">Eht rebmun %1$s rof %2$s si ton
a \"elibom\" rebmun. Tropmi ?yawyna</string>
@ -1699,6 +1711,9 @@
<string name="empty_sms_inviter">Siht enohp tsil si ytpme. Esu eht
\"Tropmi tcatnoc\" nottub ot dda elpoep uoy tnaw ot ,etivni eht +
nottub ot retne srebmun yltcerid.</string>
<!-- Shows in WiFiDirect Invite dialog when no known peers -->
<string name="empty_p2p_inviter">Ereht era yltnerruc on secived
elbahcaer aiv TcErIdifiw taht evah Sdrowssorc dellatsni.</string>
<!-- -->
<string name="empty_relay_inviter">Siht tsil fo secived si
ytpme. Esu eht \"Nacs semag\" nottub ot nacs ruoy dlo semag
@ -2248,6 +2263,8 @@
i.e. yreve reirrac ni eht dlrow tpecxe Nozirev dna Tnirps.</string>
<string name="not_again_comms_bt">Esu Htooteulb ot yalp tsniaga a
ybraen ecived taht\'s \"deriap\" htiw sruoy.</string>
<string name="not_again_comms_p2p">Esu IfIw Tcerid ot yalp tsniaga a
ybraen IfIw Elbapac-tcerid ecived htiw Sdrowssorc dellatsni.</string>
<string name="str_no_hint_found">Tonnac dnif yna sevom</string>
<string name="not_again_rematch_two_only">Hctamer si detimil ot
nosrep-owt ,semag ta tsael rof ,won esuaceb ti\'s redrah htiw erom
@ -2302,4 +2319,22 @@
<string name="dualpane_restart">Gnitixe ppa…</string>
<string name="after_restart">Siht egnahc lliw ton ekat tceffe litnu
uoy tratser Sdrowssorc.</string>
<string name="not_again_missing_perms">Siht emag si derugifnoc ot
etacinummoc aiv SMS tub Sdrowssorc seod ton evah noissimrep ot od
os. Uoy nac llits nepo eht ,emag tub ti yam ton eb elba ot dnes ro
eviecer sevom.\n\nUoy nac nepo-er ti ot eb deksa rof noissimrep
niaga. Ro uoy nac evomer eht SMS noitacinummoc gnittes.</string>
<string name="phone_state_rationale">Sdrowssorc stnaw ot enimreted
rehtehw ruoy enohp nac dnes SMS \"atad\" segassem ot evig uoy eht
noitpo fo gniyalp taht yaw. Fi uoy nod\'t reve tnaw ot yalp aiv ,SMs
e.g. esuaceb uoy yap rof hcae egassem ro evah a Nozirev ,enohp ti\'s
efas ot yltnenamrep yned noissimrep.
</string>
<string name="contacts_rationale">Sdrowssorc tnaw ssecca ot ruoy
stcatnoc ni redro ot tup a eman ot enohp srebmun taht dnes uoy
snoitativni aiv SMS. Uoy\'ll llits eb elba ot eviecer snoitativni fi
uoy nod\'t tnarg siht ,noissimrep tub ylno eht enohp rebmun fo eht
rednes lliw eb deyalpsid.</string>
<string name="remove_sms">Evomer SMS</string>
<string name="contact_not_found">Ton ni Stcatnoc</string>
</resources>

View file

@ -342,7 +342,7 @@
<!-- Don't warn, but simply force to skip turn (give 0 points)
when user attempts to play word not in the wordlist. -->
<string name="phonies_disallow">DISALLOW PHONIES</string>
<!-- Shown when using the the Game configure screen to configure a
<!-- Shown when using the Game configure screen to configure a
networked game and you try to make all players local. -->
<string name="str_reg_server_sans_remote">AT LEAST ONE PLAYER MUST
BE MARKED \"REMOTE\" FOR A GAME STARTED AS HOST.</string>
@ -839,7 +839,7 @@
<!-- clarification of the above -->
<string name="prefs_colors_summary">EDIT COLORS USED ON THE BOARD</string>
<!-- The remaining strings (down to the color edit dialog below)
are showns as the names of editable colors and as the the
are showns as the names of editable colors and as the
title of the color editor that comes up when the name is
tapped. -->
<!-- (color for) double-letter bonus squares on the board -->
@ -1039,6 +1039,7 @@
<string name="invite_choice_bt">BLUETOOTH</string>
<string name="invite_choice_nfc">NFC (\"ANDROID BEAMING\")</string>
<string name="invite_choice_relay">INTERNET/RELAY</string>
<string name="invite_choice_p2p">WIFI DIRECT</string>
<string name="invite_choice_title">INVITING PLAYERS: HOW?</string>
<!-- <string name="sms_or_email">Send invitation using SMS (texting) or -->
<!-- via email?</string> -->
@ -1636,11 +1637,11 @@
<string name="new_move_body">ONE OR MORE MOVES HAS ARRIVED</string>
<!-- -->
<plurals name="invite_bt_desc_fmt">
<item quantity="one">PLEASE SELECT THE DEVICE
YOU WANT TO INCLUDE IN THIS GAME. USE THE \"%2$s\"
<item quantity="one">PLEASE CHECK THE DEVICE
YOU WANT TO INCLUDE IN THIS GAME.\n\nUSE THE \"%2$s\"
BUTTON IF YOU DON\'T SEE THE DEVICE YOU EXPECT.</item>
<item quantity="other">PLEASE SELECT UP TO %1$d DEVICE[S]
YOU WANT TO INCLUDE IN THIS GAME. USE THE \"%2$s\"
<item quantity="other">PLEASE CHECK UP TO %1$d DEVICE[S]
YOU WANT TO INCLUDE IN THIS GAME.\n\nUSE THE \"%2$s\"
BUTTON IF YOU DON\'T SEE A DEVICE YOU EXPECT.</item>
</plurals>
<!-- -->
@ -1656,6 +1657,7 @@
<!-- Title of phone number picker during invitation to a game via SMS -->
<string name="sms_invite_title">SMS INVITATION</string>
<string name="relay_invite_title">RELAY INVITATION</string>
<string name="p2p_invite_title">WIFI DIRECT INVITATION</string>
<!-- -->
<string name="game_btname_title">BLUETOOTH GAME NAME</string>
<!-- -->
@ -1691,7 +1693,17 @@
TO YOUR NEW GAME, THEN TAP \"%2$s\".</item>
</plurals>
<!-- -->
<string name="manual_owner_name">(NOT IN CONTACTS)</string>
<plurals name="invite_p2p_desc_fmt">
<item quantity="one">PLEASE SELECT THE NAME OF THE
WIFIDIRECT DEVICE YOU WANT TO INVITE TO YOUR NEW GAME, THEN TAP
\"%2$s\".</item>
<item quantity="other">PLEASE SELECT THE %1$d WIFIDIRECT DEVICE NAMES YOU
WANT TO INVITE TO YOUR NEW GAME, THEN TAP \"%2$s\".</item>
</plurals>
<string name="invite_p2p_desc_extra">ONLY DEVICES THAT ARE
CURRENTLY AVAILABLE ARE SHOWN. IF A NEARBY DEVICE ISN\'T SHOWING
UP PLEASE MAKE SURE THAT WIFI IS TURNED ON, THAT CROSSWORDS IS
INSTALLED, AND THAT PLAY VIA WIFI DIRECT IS ENABLED.</string>
<!-- -->
<string name="warn_nomobile_fmt">THE NUMBER %1$s FOR %2$s IS NOT
A \"MOBILE\" NUMBER. IMPORT ANYWAY?</string>
@ -1699,6 +1711,9 @@
<string name="empty_sms_inviter">THIS PHONE LIST IS EMPTY. USE THE
\"IMPORT CONTACT\" BUTTON TO ADD PEOPLE YOU WANT TO INVITE, THE +
BUTTON TO ENTER NUMBERS DIRECTLY.</string>
<!-- Shows in WiFiDirect Invite dialog when no known peers -->
<string name="empty_p2p_inviter">THERE ARE CURRENTLY NO DEVICES
REACHABLE VIA WIFIDIRECT THAT HAVE CROSSWORDS INSTALLED.</string>
<!-- -->
<string name="empty_relay_inviter">THIS LIST OF DEVICES IS
EMPTY. USE THE \"SCAN GAMES\" BUTTON TO SCAN YOUR OLD GAMES
@ -2248,6 +2263,8 @@
I.E. EVERY CARRIER IN THE WORLD EXCEPT VERIZON AND SPRINT.</string>
<string name="not_again_comms_bt">USE BLUETOOTH TO PLAY AGAINST A
NEARBY DEVICE THAT\'S \"PAIRED\" WITH YOURS.</string>
<string name="not_again_comms_p2p">USE WIFI DIRECT TO PLAY AGAINST A
NEARBY WIFI DIRECT-CAPABLE DEVICE WITH CROSSWORDS INSTALLED.</string>
<string name="str_no_hint_found">CANNOT FIND ANY MOVES</string>
<string name="not_again_rematch_two_only">REMATCH IS LIMITED TO
TWO-PERSON GAMES, AT LEAST FOR NOW, BECAUSE IT\'S HARDER WITH MORE
@ -2302,4 +2319,22 @@
<string name="dualpane_restart">EXITING APP…</string>
<string name="after_restart">THIS CHANGE WILL NOT TAKE EFFECT UNTIL
YOU RESTART CROSSWORDS.</string>
<string name="not_again_missing_perms">THIS GAME IS CONFIGURED TO
COMMUNICATE VIA SMS BUT CROSSWORDS DOES NOT HAVE PERMISSION TO DO
SO. YOU CAN STILL OPEN THE GAME, BUT IT MAY NOT BE ABLE TO SEND OR
RECEIVE MOVES.\n\nYOU CAN RE-OPEN IT TO BE ASKED FOR PERMISSION
AGAIN. OR YOU CAN REMOVE THE SMS COMMUNICATION SETTING.</string>
<string name="phone_state_rationale">CROSSWORDS WANTS TO DETERMINE
WHETHER YOUR PHONE CAN SEND SMS \"DATA\" MESSAGES TO GIVE YOU THE
OPTION OF PLAYING THAT WAY. IF YOU DON\'T EVER WANT TO PLAY VIA SMS,
E.G. BECAUSE YOU PAY FOR EACH MESSAGE OR HAVE A VERIZON PHONE, IT\'S
SAFE TO PERMANENTLY DENY PERMISSION.
</string>
<string name="contacts_rationale">CROSSWORDS WANT ACCESS TO YOUR
CONTACTS IN ORDER TO PUT A NAME TO PHONE NUMBERS THAT SEND YOU
INVITATIONS VIA SMS. YOU\'LL STILL BE ABLE TO RECEIVE INVITATIONS IF
YOU DON\'T GRANT THIS PERMISSION, BUT ONLY THE PHONE NUMBER OF THE
SENDER WILL BE DISPLAYED.</string>
<string name="remove_sms">REMOVE SMS</string>
<string name="contact_not_found">NOT IN CONTACTS</string>
</resources>

View file

@ -1,3 +1,4 @@
/GitVersion.java
BuildConstants.java
GCMConsts.java
nohup.out

View file

@ -23,6 +23,7 @@ package org.eehouse.android.xw4;
import android.os.Bundle;
public class BTInviteActivity extends InviteActivity {
private static final String TAG = BTInviteActivity.class.getSimpleName();
@Override
protected void onCreate( Bundle savedInstanceState )

View file

@ -26,13 +26,14 @@ import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import junit.framework.Assert;
@ -46,12 +47,11 @@ import java.util.Map;
import java.util.Set;
public class BTInviteDelegate extends InviteDelegate {
private static final String TAG = BTInviteDelegate.class.getSimpleName();
private static final int[] BUTTONIDS = { R.id.button_add,
R.id.button_clear,
};
private Activity m_activity;
private Set<LinearLayout> m_checked;
private Map<String, Integer> m_counts;
private boolean m_setChecked;
private BTDevsAdapter m_adapter;
public static void launchForResult( Activity activity, int nMissing,
SentInvitesInfo info,
@ -71,24 +71,34 @@ public class BTInviteDelegate extends InviteDelegate {
protected BTInviteDelegate( Delegator delegator, Bundle savedInstanceState )
{
super( delegator, savedInstanceState, R.layout.btinviter );
super( delegator, savedInstanceState );
m_activity = delegator.getActivity();
}
@Override
protected void init( Bundle savedInstanceState )
{
m_checked = new HashSet<LinearLayout>();
m_counts = new HashMap<String, Integer>();
String msg = getString( R.string.bt_pick_addall_button );
msg = getQuantityString( R.plurals.invite_bt_desc_fmt, m_nMissing,
m_nMissing, msg );
super.init( R.id.button_invite, R.id.button_rescan,
R.id.button_clear, R.id.invite_desc, msg );
super.init( msg, 0 );
addButtonBar( R.layout.bt_buttons, BUTTONIDS );
BTService.clearDevices( m_activity, null ); // will return names
}
@Override
protected void onBarButtonClicked( int id )
{
switch( id ) {
case R.id.button_add:
scan();
break;
case R.id.button_clear:
Utils.notImpl( m_activity );
break;
}
}
// MultiService.MultiEventListener interface
@Override
public void eventOccurred( MultiService.MultiEvent event, final Object ... args )
@ -99,23 +109,13 @@ public class BTInviteDelegate extends InviteDelegate {
public void run() {
synchronized( BTInviteDelegate.this ) {
String[] btDevAddrs = null;
String[] btDevNames = null;
TwoStringPair[] pairs = null;
if ( 0 < args.length ) {
btDevAddrs = (String[])(args[0]);
btDevNames = (String[])(args[1]);
if ( null != btDevNames
&& 0 == btDevNames.length ) {
btDevNames = null;
btDevAddrs = null;
}
pairs = TwoStringPair.make( (String[])(args[0]),
(String[])(args[1]) );
}
m_setChecked = null != btDevNames
&& m_nMissing == btDevNames.length;
m_adapter = new BTDevsAdapter( btDevAddrs, btDevNames );
setListAdapter( m_adapter );
m_checked.clear();
updateListAdapter( pairs );
tryEnable();
}
}
@ -126,7 +126,25 @@ public class BTInviteDelegate extends InviteDelegate {
}
}
protected void scan()
@Override
protected void onChildAdded( View child, InviterItem data )
{
TwoStrsItem item = (TwoStrsItem)child; // change class name!
TwoStringPair pair = (TwoStringPair)data;
((TwoStrsItem)child).setStrings( pair.str2, pair.str1 );
}
@Override
protected void listSelected( InviterItem[] selected, String[] devs )
{
for ( int ii = 0; ii < selected.length; ++ii ) {
TwoStringPair rec = (TwoStringPair)selected[ii];
devs[ii] = rec.str1;
DbgUtils.logd( TAG, "selecting address %s", devs[ii] );
}
}
private void scan()
{
int count = BTService.getPairedCount( m_activity );
if ( 0 < count ) {
@ -139,127 +157,15 @@ public class BTInviteDelegate extends InviteDelegate {
}
}
protected void clearSelected()
{
String[][] selected = new String[1][];
listSelected( selected, null );
BTService.clearDevices( m_activity, selected[0] );
}
// @Override
// protected void clearSelected( Integer[] itemIndices )
// {
// // String[][] selected = new String[1][];
// // listSelected( selected, null );
// // BTService.clearDevices( m_activity, selected[0] );
protected void listSelected( String[][] devsP, int[][] countsP )
{
int size = m_checked.size();
int[] counts = null;
String[] devs = new String[size];
devsP[0] = devs;
if ( null != countsP ) {
counts = new int[size];
countsP[0] = counts;
}
int nxt = 0;
for ( Iterator<LinearLayout> iter = m_checked.iterator();
iter.hasNext(); ) {
LinearLayout layout = iter.next();
CheckBox box = (CheckBox)layout.findViewById( R.id.inviter_check );
String btAddr = (String)box.getTag();
devs[nxt] = btAddr;
if ( null != counts ) {
counts[nxt] = m_counts.get( btAddr );
}
++nxt;
}
}
protected void tryEnable()
{
String[][] devs = new String[1][];
int[][] counts = new int[1][];
listSelected( devs, counts );
m_clearButton.setEnabled( 0 < devs[0].length );
int count = 0;
for ( int one : counts[0] ) {
count += one;
}
m_okButton.setEnabled( 0 < count && count <= m_nMissing );
}
private class BTDevsAdapter extends XWListAdapter {
private String[] m_devAddrs;
private String[] m_devNames;
public BTDevsAdapter( String[] btAddrs, String[] btNames )
{
super( null == btAddrs? 0 : btAddrs.length );
m_devAddrs = btAddrs;
m_devNames = btNames;
}
public Object getItem( int position ) { return m_devNames[position]; }
public View getView( int position, View convertView, ViewGroup parent ) {
final String btAddr = m_devAddrs[position];
final LinearLayout layout = (LinearLayout)inflate( R.layout.btinviter_item );
CheckBox box = (CheckBox)layout.findViewById( R.id.inviter_check );
box.setText( m_devNames[position] );
box.setTag( btAddr );
m_counts.put( btAddr, 1 );
if ( XWPrefs.getCanInviteMulti( m_activity ) && 1 < m_nMissing ) {
Spinner spinner = (Spinner)
layout.findViewById(R.id.nperdev_spinner);
ArrayAdapter<String> adapter =
new ArrayAdapter<String>( m_activity, android.R.layout
.simple_spinner_item );
for ( int ii = 1; ii <= m_nMissing; ++ii ) {
String str = getQuantityString( R.plurals.nplayers_fmt, ii, ii );
adapter.add( str );
}
spinner.setAdapter( adapter );
spinner.setVisibility( View.VISIBLE );
spinner.setOnItemSelectedListener( new OnItemSelectedListener() {
public void onItemSelected( AdapterView<?> parent,
View view, int pos,
long id )
{
m_counts.put( btAddr, 1 + pos );
tryEnable();
}
public void onNothingSelected( AdapterView<?> parent ) {}
} );
}
CompoundButton.OnCheckedChangeListener listener =
new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged( CompoundButton buttonView,
boolean isChecked ) {
if ( isChecked ) {
m_checked.add( layout );
} else {
m_checked.remove( layout );
// User's now making changes; don't check new views
m_setChecked = false;
}
tryEnable();
}
};
box.setOnCheckedChangeListener( listener );
if ( m_setChecked || m_checked.contains( layout ) ) {
box.setChecked( true );
} else if ( null != m_lastDev && m_lastDev.equals( btAddr ) ) {
m_lastDev = null;
box.setChecked( true );
}
return layout;
}
public String getBTAddr( CheckBox box ) { return (String)box.getTag(); }
public String getBTName( CheckBox box ) { return box.getText().toString(); }
}
// // super.clearSelected( itemIndices );
// }
// DlgDelegate.DlgClickNotify interface
@Override

View file

@ -27,13 +27,14 @@ import android.content.Context;
import android.content.Intent;
public class BTReceiver extends BroadcastReceiver {
private static final String TAG = BTReceiver.class.getSimpleName();
@Override
public void onReceive( Context context, Intent intent )
{
if ( XWApp.BTSUPPORTED ) {
String action = intent.getAction();
DbgUtils.logd( getClass(), "BTReceiver.onReceive(action=%s, intent=%s)",
DbgUtils.logd( TAG, "BTReceiver.onReceive(action=%s, intent=%s)",
action, intent.toString() );
if ( action.equals( BluetoothDevice.ACTION_ACL_CONNECTED ) ) {

View file

@ -53,6 +53,7 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
public class BTService extends XWService {
private static final String TAG = BTService.class.getSimpleName();
private static final String BOGUS_MARSHMALLOW_ADDR = "02:00:00:00:00:00";
private static final long RESEND_TIMEOUT = 5; // seconds
@ -120,7 +121,6 @@ public class BTService extends XWService {
int m_lang;
String m_dict;
int m_nPlayersT;
int m_nPlayersH;
NetLaunchInfo m_nli;
public BTQueueElem( BTCmd cmd ) { m_cmd = cmd; m_failCount = 0; }
@ -301,16 +301,17 @@ public class BTService extends XWService {
}
if ( -1 == nSent ) {
DbgUtils.logi( BTService.class, "enqueueFor(): can't send to %s",
DbgUtils.logi( TAG, "enqueueFor(): can't send to %s",
targetAddr.bt_hostName );
}
return nSent;
}
public static void gameDied( Context context, int gameID )
public static void gameDied( Context context, String btAddr, int gameID )
{
Intent intent = getIntentTo( context, BTAction.REMOVE );
intent.putExtra( GAMEID_KEY, gameID );
intent.putExtra( ADDR_KEY, btAddr );
context.startService( intent );
}
@ -328,13 +329,13 @@ public class BTService extends XWService {
? BluetoothAdapter.getDefaultAdapter() : null;
if ( null != adapter && adapter.isEnabled() ) {
m_adapter = adapter;
DbgUtils.logi( getClass(), "onCreate(); bt name = %s; bt addr = %s",
DbgUtils.logi( TAG, "onCreate(); bt name = %s; bt addr = %s",
adapter.getName(), adapter.getAddress() );
initAddrs();
startListener();
startSender();
} else {
DbgUtils.logw( getClass(), "not starting threads: BT not available" );
DbgUtils.logw( TAG, "not starting threads: BT not available" );
stopSelf();
}
}
@ -348,11 +349,11 @@ public class BTService extends XWService {
if ( -1 == ordinal ) {
// Drop it
} else if ( null == m_sender ) {
DbgUtils.logw( getClass(), "exiting: m_queue is null" );
DbgUtils.logw( TAG, "exiting: m_queue is null" );
stopSelf();
} else {
BTAction cmd = BTAction.values()[ordinal];
DbgUtils.logi( getClass(), "onStartCommand; cmd=%s", cmd.toString() );
DbgUtils.logi( TAG, "onStartCommand; cmd=%s", cmd.toString() );
switch( cmd ) {
case CLEAR:
String[] btAddrs = intent.getStringArrayExtra( CLEAR_KEY );
@ -365,7 +366,7 @@ public class BTService extends XWService {
case INVITE:
String jsonData = intent.getStringExtra( GAMEDATA_KEY );
NetLaunchInfo nli = new NetLaunchInfo( this, jsonData );
DbgUtils.logi( getClass(), "onStartCommand: nli: %s", nli.toString() );
DbgUtils.logi( TAG, "onStartCommand: nli: %s", nli.toString() );
String btAddr = intent.getStringExtra( ADDR_KEY );
m_sender.add( new BTQueueElem( BTCmd.INVITE, nli, btAddr ) );
break;
@ -401,7 +402,7 @@ public class BTService extends XWService {
boolean cameOn = intent.getBooleanExtra( RADIO_KEY, false );
MultiEvent evt = cameOn? MultiEvent.BT_ENABLED
: MultiEvent.BT_DISABLED;
sendResult( evt );
postEvent( evt );
if ( cameOn ) {
GameUtils.resendAllIf( this, CommsConnType.COMMS_CONN_BT,
false );
@ -416,6 +417,8 @@ public class BTService extends XWService {
break;
case REMOVE:
gameID = intent.getIntExtra( GAMEID_KEY, -1 );
btAddr = intent.getStringExtra( ADDR_KEY );
m_sender.add( new BTQueueElem( BTCmd.MESG_GAMEGONE, btAddr, gameID ) );
break;
default:
Assert.fail();
@ -461,11 +464,15 @@ public class BTService extends XWService {
receiveInvitation( proto, inStream, socket );
break;
case MESG_SEND:
receiveMessage( inStream, socket );
receiveMessage( cmd, inStream, socket );
break;
case MESG_GAMEGONE:
receiveMessage( cmd, inStream, socket );
break;
default:
DbgUtils.loge( getClass(), "unexpected msg %s", cmd.toString());
DbgUtils.loge( TAG, "unexpected msg %s", cmd.toString());
break;
}
updateStatusIn( true );
@ -479,7 +486,7 @@ public class BTService extends XWService {
sendBadProto( socket );
}
} catch ( IOException ioe ) {
DbgUtils.logw( getClass(), "trying again..." );
DbgUtils.logw( TAG, "trying again..." );
logIOE( ioe);
continue;
}
@ -557,35 +564,48 @@ public class BTService extends XWService {
socket.close();
} // receiveInvitation
private void receiveMessage( DataInputStream dis, BluetoothSocket socket )
private void receiveMessage( BTCmd cmd, DataInputStream dis, BluetoothSocket socket )
{
try {
BTCmd result = null;
int gameID = dis.readInt();
short len = dis.readShort();
byte[] buffer = new byte[len];
int nRead = dis.read( buffer, 0, len );
if ( nRead == len ) {
BluetoothDevice host = socket.getRemoteDevice();
addAddr( host );
switch ( cmd ) {
case MESG_SEND:
short len = dis.readShort();
byte[] buffer = new byte[len];
int nRead = dis.read( buffer, 0, len );
if ( nRead == len ) {
BluetoothDevice host = socket.getRemoteDevice();
addAddr( host );
CommsAddrRec addr = new CommsAddrRec( host.getName(),
host.getAddress() );
ReceiveResult rslt
= BTService.this.receiveMessage( BTService.this, gameID,
m_btMsgSink, buffer, addr );
CommsAddrRec addr = new CommsAddrRec( host.getName(),
host.getAddress() );
ReceiveResult rslt
= BTService.this.receiveMessage( BTService.this,
gameID, m_btMsgSink,
buffer, addr );
BTCmd result = rslt == ReceiveResult.GAME_GONE ?
BTCmd.MESG_GAMEGONE : BTCmd.MESG_ACCPT;
DataOutputStream os =
new DataOutputStream( socket.getOutputStream() );
os.writeByte( result.ordinal() );
os.flush();
socket.close();
} else {
DbgUtils.loge( getClass(), "receiveMessages: read only %d of %d bytes",
nRead, len );
result = rslt == ReceiveResult.GAME_GONE ?
BTCmd.MESG_GAMEGONE : BTCmd.MESG_ACCPT;
} else {
DbgUtils.loge( TAG, "receiveMessage(): read only "
+ "%d of %d bytes", nRead, len );
}
break;
case MESG_GAMEGONE:
postEvent( MultiEvent.MESSAGE_NOGAME, gameID );
result = BTCmd.MESG_ACCPT;
break;
default:
result = BTCmd.BAD_PROTO;
break;
}
DataOutputStream os =
new DataOutputStream( socket.getOutputStream() );
os.writeByte( result.ordinal() );
os.flush();
socket.close();
} catch ( IOException ioe ) {
logIOE( ioe );
}
@ -685,7 +705,7 @@ public class BTService extends XWService {
try {
elem = m_queue.poll( timeout, TimeUnit.SECONDS );
} catch ( InterruptedException ie ) {
DbgUtils.logw( getClass(), "interrupted; killing thread" );
DbgUtils.logw( TAG, "interrupted; killing thread" );
break;
}
@ -712,12 +732,17 @@ public class BTService extends XWService {
break;
case MESG_SEND:
boolean success = doAnyResends( elem.m_btAddr )
&& sendMsg( elem );
&& sendElem( elem );
if ( !success ) {
addToResends( elem );
}
updateStatusOut( success );
break;
case MESG_GAMEGONE:
sendElem( elem );
break;
default:
Assert.fail();
break;
@ -739,7 +764,7 @@ public class BTService extends XWService {
if ( sendPing( dev, 0 ) ) { // did we get a reply?
addAddr( dev );
if ( null != event ) {
sendResult( event, dev.getName() );
postEvent( event, dev.getName() );
}
}
}
@ -768,7 +793,7 @@ public class BTService extends XWService {
} else {
gotReply = BTCmd.PONG == reply;
if ( gotReply && is.readBoolean() ) {
sendResult( MultiEvent.MESSAGE_NOGAME, gameID );
postEvent( MultiEvent.MESSAGE_NOGAME, gameID );
}
}
@ -812,7 +837,7 @@ public class BTService extends XWService {
outStream.writeShort( nliData.length );
outStream.write( nliData, 0, nliData.length );
}
DbgUtils.logi( getClass(), "<eeh>sending invite for %d players", elem.m_nPlayersH );
DbgUtils.logi( TAG, "<eeh>sending invite" );
outStream.flush();
DataInputStream inStream =
@ -821,20 +846,20 @@ public class BTService extends XWService {
}
if ( null == reply ) {
sendResult( MultiEvent.APP_NOT_FOUND_BT, dev.getName() );
postEvent( MultiEvent.APP_NOT_FOUND_BT, dev.getName() );
} else {
switch ( reply ) {
case BAD_PROTO:
sendBadProto( socket );
break;
case INVITE_ACCPT:
sendResult( MultiEvent.NEWGAME_SUCCESS, elem.m_gameID );
postEvent( MultiEvent.NEWGAME_SUCCESS, elem.m_gameID );
break;
case INVITE_DUPID:
sendResult( MultiEvent.NEWGAME_DUP_REJECTED, dev.getName() );
postEvent( MultiEvent.NEWGAME_DUP_REJECTED, dev.getName() );
break;
default:
sendResult( MultiEvent.NEWGAME_FAILURE, elem.m_gameID );
postEvent( MultiEvent.NEWGAME_FAILURE, elem.m_gameID );
break;
}
}
@ -846,7 +871,7 @@ public class BTService extends XWService {
}
} // sendInvite
private boolean sendMsg( BTQueueElem elem )
private boolean sendElem( BTQueueElem elem )
{
boolean success = false;
// synchronized( m_deadGames ) {
@ -855,7 +880,7 @@ public class BTService extends XWService {
MultiEvent evt;
if ( success ) {
evt = MultiEvent.MESSAGE_DROPPED;
DbgUtils.logw( getClass(), "sendMsg: dropping message %s because game %X dead",
DbgUtils.logw( TAG, "sendElem: dropping message %s because game %X dead",
elem.m_cmd, elem.m_gameID );
} else {
evt = MultiEvent.MESSAGE_REFUSED;
@ -868,13 +893,22 @@ public class BTService extends XWService {
createRfcommSocketToServiceRecord( XWApp.getAppUUID() );
if ( null != socket ) {
DataOutputStream outStream =
connect( socket, BTCmd.MESG_SEND );
connect( socket, elem.m_cmd );
if ( null != outStream ) {
outStream.writeInt( elem.m_gameID );
short len = (short)elem.m_msg.length;
outStream.writeShort( len );
outStream.write( elem.m_msg, 0, elem.m_msg.length );
switch ( elem.m_cmd ) {
case MESG_SEND:
short len = (short)elem.m_msg.length;
outStream.writeShort( len );
outStream.write( elem.m_msg, 0, elem.m_msg.length );
break;
case MESG_GAMEGONE:
// gameID's all we need
break;
default:
Assert.fail();
}
outStream.flush();
Thread killer = killSocketIn( socket );
@ -908,15 +942,15 @@ public class BTService extends XWService {
if ( null != evt ) {
String btName = nameForAddr( m_adapter, elem.m_btAddr );
sendResult( evt, elem.m_gameID, 0, btName );
postEvent( evt, elem.m_gameID, 0, btName );
if ( ! success ) {
int failCount = elem.incrFailCount();
sendResult( MultiEvent.MESSAGE_RESEND, btName,
postEvent( MultiEvent.MESSAGE_RESEND, btName,
RESEND_TIMEOUT, failCount );
}
}
return success;
} // sendMsg
} // sendElem
private boolean doAnyResends( LinkedList<BTQueueElem> resends )
{
@ -926,12 +960,12 @@ public class BTService extends XWService {
ListIterator<BTQueueElem> iter = resends.listIterator();
while ( iter.hasNext() && success ) {
BTQueueElem elem = iter.next();
success = sendMsg( elem );
success = sendElem( elem );
if ( success ) {
iter.remove();
} else if ( elem.failCountExceeded() ) {
String btName = nameForAddr( m_adapter, elem.m_btAddr );
sendResult( MultiEvent.MESSAGE_FAILOUT, btName );
postEvent( MultiEvent.MESSAGE_FAILOUT, btName );
iter.remove();
}
}
@ -1002,7 +1036,7 @@ public class BTService extends XWService {
for ( int ii = 0; ii < size; ++ii ) {
btNames[ii] = nameForAddr( m_adapter, btAddrs[ii] );
}
sendResult( MultiEvent.SCAN_DONE, (Object)btAddrs, (Object)btNames );
postEvent( MultiEvent.SCAN_DONE, (Object)btAddrs, (Object)btNames );
}
private void initAddrs()
@ -1050,7 +1084,7 @@ public class BTService extends XWService {
try {
m_listener.join( 100 );
} catch ( InterruptedException ie ) {
DbgUtils.logex( ie );
DbgUtils.logex( TAG, ie );
}
m_listener = null;
}
@ -1061,7 +1095,7 @@ public class BTService extends XWService {
try {
m_sender.join( 100 );
} catch ( InterruptedException ie ) {
DbgUtils.logex( ie );
DbgUtils.logex( TAG, ie );
}
m_sender = null;
}
@ -1112,7 +1146,7 @@ public class BTService extends XWService {
GameUtils.postInvitedNotification( this, nli.gameID(), body,
rowid );
sendResult( MultiEvent.BT_GAME_CREATED, rowid );
postEvent( MultiEvent.BT_GAME_CREATED, rowid );
}
} else {
result = BTCmd.INVITE_DUPID;
@ -1133,10 +1167,10 @@ public class BTService extends XWService {
dos = new DataOutputStream( socket.getOutputStream() );
dos.writeByte( BT_PROTO );
dos.writeByte( cmd.ordinal() );
DbgUtils.logi( getClass(), "connect() to %s successful", name );
DbgUtils.logi( TAG, "connect() to %s successful", name );
} catch ( IOException ioe ) {
dos = null;
DbgUtils.logw( getClass(), "BTService.connect() to %s failed", name );
DbgUtils.logw( TAG, "BTService.connect() to %s failed", name );
// logIOE( ioe );
}
return dos;
@ -1144,16 +1178,16 @@ public class BTService extends XWService {
private void logIOE( IOException ioe )
{
DbgUtils.logex( ioe );
DbgUtils.logex( TAG, ioe );
++s_errCount;
// if ( 0 == s_errCount % 10 ) {
sendResult( MultiEvent.BT_ERR_COUNT, s_errCount );
postEvent( MultiEvent.BT_ERR_COUNT, s_errCount );
// }
}
private void sendBadProto( BluetoothSocket socket )
{
sendResult( MultiEvent.BAD_PROTO_BT, socket.getRemoteDevice().getName() );
postEvent( MultiEvent.BAD_PROTO_BT, socket.getRemoteDevice().getName() );
}
private void updateStatusOut( boolean success )
@ -1181,13 +1215,13 @@ public class BTService extends XWService {
try {
Thread.sleep( millis );
} catch ( InterruptedException ie ) {
DbgUtils.logw( getClass(), "killSocketIn: killed by owner" );
DbgUtils.logw( TAG, "killSocketIn: killed by owner" );
return;
}
try {
socket.close();
} catch( IOException ioe ) {
DbgUtils.logex( ioe );
DbgUtils.logex( TAG, ioe );
}
}
} );
@ -1204,7 +1238,7 @@ public class BTService extends XWService {
{
int nSent = -1;
if ( null == m_sender ) {
DbgUtils.logw( getClass(), "sendViaBluetooth(): no send thread" );
DbgUtils.logw( TAG, "sendViaBluetooth(): no send thread" );
} else {
String btAddr = getSafeAddr( addr );
if ( null != btAddr && 0 < btAddr.length() ) {
@ -1212,7 +1246,7 @@ public class BTService extends XWService {
gameID ) );
nSent = buf.length;
} else {
DbgUtils.logi( BTService.class, "sendViaBluetooth(): no addr for dev %s",
DbgUtils.logi( TAG, "sendViaBluetooth(): no addr for dev %s",
addr.bt_hostName );
}
}

View file

@ -0,0 +1,206 @@
/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
/*
* Copyright 2016 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.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.util.concurrent.LinkedBlockingQueue;
import org.json.JSONObject;
import junit.framework.Assert;
public class BiDiSockWrap {
private static final String TAG = BiDiSockWrap.class.getSimpleName();
interface Iface {
void gotPacket( BiDiSockWrap wrap, byte[] bytes );
void onWriteSuccess( BiDiSockWrap wrap );
void connectStateChanged( BiDiSockWrap wrap, boolean nowConnected );
}
private Socket mSocket;
private Iface mIface;
private LinkedBlockingQueue<byte[]> mQueue;
private Thread mReadThread;
private Thread mWriteThread;
private boolean mRunThreads;
private boolean mActive;
private InetAddress mAddress;
private int mPort;
// For sockets that came from accept() on a ServerSocket
public BiDiSockWrap( Socket socket, Iface iface )
{
mIface = iface;
init( socket );
}
// For creating sockets that will connect to a remote ServerSocket. Must
// call connect() afterwards.
public BiDiSockWrap( InetAddress address, int port, Iface iface )
{
mIface = iface;
mAddress = address;
mPort = port;
}
public BiDiSockWrap connect()
{
mActive = true;
new Thread( new Runnable() {
public void run() {
long waitMillis = 1000;
while ( mActive ) {
try {
Thread.sleep( waitMillis );
DbgUtils.logd( TAG, "trying to connect..." );
Socket socket = new Socket( mAddress, mPort );
DbgUtils.logd( TAG, "connected!!!" );
init( socket );
mIface.connectStateChanged( BiDiSockWrap.this, true );
break;
} catch ( java.net.UnknownHostException uhe ) {
DbgUtils.logex( TAG, uhe );
} catch ( IOException ioe ) {
DbgUtils.logex( TAG, ioe );
} catch ( InterruptedException ie ) {
DbgUtils.logex( TAG, ie );
}
waitMillis = Math.min( waitMillis * 2, 1000 * 60 );
}
}
} ).start();
return this;
}
public Socket getSocket() { return mSocket; }
public boolean isConnected() { return null != getSocket(); }
private void send( String packet )
{
try {
send( packet.getBytes( "UTF-8" ) );
} catch ( java.io.UnsupportedEncodingException uee ) {
DbgUtils.logex( TAG, uee );
}
}
public void send( JSONObject obj )
{
send( obj.toString() );
}
public void send( XWPacket packet )
{
send( packet.toString() );
}
public void send( byte[] packet )
{
Assert.assertNotNull( packet );
Assert.assertTrue( packet.length > 0 );
mQueue.add( packet );
}
private void init( Socket socket )
{
mSocket = socket;
mQueue = new LinkedBlockingQueue<byte[]>();
startThreads();
}
private void closeSocket()
{
DbgUtils.logd( TAG, "closeSocket()" );
mRunThreads = false;
mActive = false;
try {
mSocket.close();
} catch ( IOException ioe ) {
DbgUtils.logex( TAG, ioe );
}
mIface.connectStateChanged( this, false );
mQueue.add( new byte[0] );
}
private void startThreads()
{
mRunThreads = true;
mWriteThread = new Thread( new Runnable() {
@Override
public void run() {
DbgUtils.logd( TAG, "write thread starting" );
try {
DataOutputStream outStream
= new DataOutputStream( mSocket.getOutputStream() );
while ( mRunThreads ) {
byte[] packet = mQueue.take();
DbgUtils.logd( TAG,
"write thread got packet of len %d",
packet.length );
Assert.assertNotNull( packet );
if ( 0 == packet.length ) {
closeSocket();
break;
}
outStream.writeShort( packet.length );
outStream.write( packet, 0, packet.length );
mIface.onWriteSuccess( BiDiSockWrap.this );
}
} catch ( IOException ioe ) {
DbgUtils.logex( TAG, ioe );
closeSocket();
} catch ( InterruptedException ie ) {
Assert.fail();
}
DbgUtils.logd( TAG, "write thread exiting" );
}
} );
mWriteThread.start();
mReadThread = new Thread( new Runnable() {
@Override
public void run() {
DbgUtils.logd( TAG, "read thread starting" );
try {
DataInputStream inStream
= new DataInputStream( mSocket.getInputStream() );
while ( mRunThreads ) {
short len = inStream.readShort();
DbgUtils.logd( TAG, "got len: %d", len );
byte[] packet = new byte[len];
inStream.read( packet );
mIface.gotPacket( BiDiSockWrap.this, packet );
}
} catch( IOException ioe ) {
DbgUtils.logex( TAG, ioe );
closeSocket();
}
DbgUtils.logd( TAG, "read thread exiting" );
}
} );
mReadThread.start();
}
}

View file

@ -28,6 +28,7 @@ import android.view.Window;
import org.eehouse.android.xw4.jni.CommonPrefs;
public class BoardActivity extends XWActivity {
private static final String TAG = BoardActivity.class.getSimpleName();
private BoardDelegate m_dlgt;

View file

@ -43,6 +43,7 @@ import org.eehouse.android.xw4.jni.XwJNI.DictWrapper;
import org.eehouse.android.xw4.loc.LocUtils;
public class BoardCanvas extends Canvas implements DrawCtx {
private static final String TAG = BoardCanvas.class.getSimpleName();
private static final int BLACK = 0xFF000000;
private static final int WHITE = 0xFFFFFFFF;
private static final int FRAME_GREY = 0xFF101010;
@ -55,7 +56,6 @@ public class BoardCanvas extends Canvas implements DrawCtx {
private Activity m_activity;
private Context m_context;
private Bitmap m_bitmap;
private JNIThread m_jniThread;
private Paint m_fillPaint;
private Paint m_strokePaint;
@ -141,7 +141,6 @@ public class BoardCanvas extends Canvas implements DrawCtx {
super( bitmap );
m_context = context;
m_activity = activity;
m_bitmap = bitmap;
m_jniThread = jniThread;
m_dict = new DictWrapper();
@ -182,7 +181,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
DbgUtils.assertOnUIThread();
if ( null == jniThread ) {
} else if ( ! jniThread.equals( m_jniThread ) ) {
DbgUtils.logw( getClass(), "changing threads" );
DbgUtils.logw( TAG, "changing threads" );
}
m_jniThread = jniThread;
}
@ -345,14 +344,8 @@ public class BoardCanvas extends Canvas implements DrawCtx {
}
}
public boolean boardBegin( Rect rect, int cellWidth, int cellHeight )
{
return true;
}
public boolean drawCell( final Rect rect, String text, int tile, int value,
int owner, int bonus, int hintAtts,
final int flags )
public boolean drawCell( Rect rect, String text, int tile, int value,
int owner, int bonus, int hintAtts, int flags )
{
boolean canDraw = figureFontDims();
if ( canDraw ) {

View file

@ -32,6 +32,7 @@ import android.graphics.Rect;
import junit.framework.Assert;
public class BoardContainer extends ViewGroup {
private static final String TAG = BoardContainer.class.getSimpleName();
// If the ratio of height/width exceeds this, use portrait layout
private static final int PORTRAIT_THRESHHOLD = 105;
@ -54,7 +55,7 @@ public class BoardContainer extends ViewGroup {
void sizeChanged( int width, int height, boolean isPortrait );
}
private static WeakReference<SizeChangeListener> s_scl;
public static void registerSizeChangeListener(SizeChangeListener scl)
{
s_scl = new WeakReference<SizeChangeListener>(scl);
@ -62,7 +63,7 @@ public class BoardContainer extends ViewGroup {
}
public static boolean getIsPortrait() { return s_isPortrait; }
public BoardContainer( Context context, AttributeSet as ) {
super( context, as );
s_height = s_width = 0;
@ -91,7 +92,7 @@ public class BoardContainer extends ViewGroup {
measureChild( s_isPortrait ? HBAR_INDX : VBAR_INDX, m_toolsBounds );
adjustBounds();
View child = getChildAt( s_isPortrait ? HBAR_INDX : VBAR_INDX );
DbgUtils.logi( getClass(), "measured %s; passed ht: %d; got back ht: %d",
DbgUtils.logi( TAG, "measured %s; passed ht: %d; got back ht: %d",
child.toString(), m_toolsBounds.height(),
child.getMeasuredHeight() );
@ -158,7 +159,7 @@ public class BoardContainer extends ViewGroup {
.setVisibility( s_isPortrait ? VISIBLE : GONE );
findViewById( R.id.tbar_parent_vert )
.setVisibility( s_isPortrait ? GONE : VISIBLE );
callSCL();
}
}

View file

@ -42,38 +42,43 @@ import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Semaphore;
import junit.framework.Assert;
import org.eehouse.android.xw4.DBUtils.SentInvitesInfo;
import org.eehouse.android.xw4.DlgDelegate.Action;
import org.eehouse.android.xw4.DlgDelegate.ActionPair;
import org.eehouse.android.xw4.Toolbar.Buttons;
import org.eehouse.android.xw4.jni.CommonPrefs;
import org.eehouse.android.xw4.jni.CommsAddrRec;
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnTypeSet;
import org.eehouse.android.xw4.jni.CurGameInfo;
import org.eehouse.android.xw4.jni.CommsAddrRec;
import org.eehouse.android.xw4.jni.CurGameInfo.DeviceRole;
import org.eehouse.android.xw4.jni.CurGameInfo;
import org.eehouse.android.xw4.jni.GameSummary;
import org.eehouse.android.xw4.jni.JNIThread;
import org.eehouse.android.xw4.jni.JNIThread.JNICmd;
import org.eehouse.android.xw4.jni.JNIThread;
import org.eehouse.android.xw4.jni.JNIUtils;
import org.eehouse.android.xw4.jni.JNIUtilsImpl;
import org.eehouse.android.xw4.jni.LastMoveInfo;
import org.eehouse.android.xw4.jni.TransportProcs;
import org.eehouse.android.xw4.jni.UtilCtxt;
import org.eehouse.android.xw4.jni.UtilCtxtImpl;
import org.eehouse.android.xw4.jni.XwJNI;
import org.eehouse.android.xw4.jni.XwJNI.GamePtr;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.concurrent.Semaphore;
import org.eehouse.android.xw4.jni.XwJNI;
public class BoardDelegate extends DelegateBase
implements TransportProcs.TPMsgHandler, View.OnClickListener,
DwnldDelegate.DownloadFinishedListener,
ConnStatusHandler.ConnStatusCBacks,
NFCUtils.NFCActor {
private static final String TAG = BoardDelegate.class.getSimpleName();
public static final String INTENT_KEY_CHAT = "chat";
@ -104,7 +109,7 @@ public class BoardDelegate extends DelegateBase
private Button m_exchCommmitButton;
private Button m_exchCancelButton;
private SentInvitesInfo m_sentInfo;
private Perms23.PermCbck m_permCbck;
private ArrayList<String> m_pendingChats;
private String m_dlgBytes = null;
@ -123,7 +128,6 @@ public class BoardDelegate extends DelegateBase
private JNIUtils m_jniu;
private boolean m_inTrade; // save this in bundle?
private BoardUtilCtxt m_utils;
private int m_invitesPending;
private boolean m_gameOver = false;
// call startActivityForResult synchronously
@ -201,12 +205,19 @@ public class BoardDelegate extends DelegateBase
ab.setNegativeButton( R.string.button_rematch, lstnr );
} else if ( DlgID.DLG_CONNSTAT == dlgID
&& BuildConfig.DEBUG && null != m_connTypes
&& m_connTypes.contains( CommsConnType.COMMS_CONN_RELAY ) ) {
&& (m_connTypes.contains( CommsConnType.COMMS_CONN_RELAY )
|| m_connTypes.contains( CommsConnType.COMMS_CONN_P2P )) ) {
lstnr = new OnClickListener() {
public void onClick( DialogInterface dlg,
int whichButton ) {
NetStateCache.reset( m_activity );
RelayService.reset( m_activity );
if ( m_connTypes.contains( CommsConnType.COMMS_CONN_RELAY ) ) {
RelayService.reset( m_activity );
}
if ( m_connTypes.contains( CommsConnType.COMMS_CONN_P2P ) ) {
WiDirService.reset( m_activity );
}
}
};
ab.setNegativeButton( R.string.button_reconnect, lstnr );
@ -395,8 +406,8 @@ public class BoardDelegate extends DelegateBase
if ( self.m_summary.hasRematchInfo() ) {
self.tryRematchInvites( true );
} else {
self.showInviteChoicesThen( Action.LAUNCH_INVITE_ACTION,
self.m_sentInfo );
self.callInviteChoices( Action.LAUNCH_INVITE_ACTION,
self.m_sentInfo, true );
}
} else {
self.askDropRelay();
@ -471,7 +482,7 @@ public class BoardDelegate extends DelegateBase
without.remove( CommsConnType.COMMS_CONN_RELAY );
message += "\n\n"
+ getString( R.string.drop_relay_warning_fmt,
without.toString( m_activity ) );
without.toString( m_activity, true ) );
buttonTxt = R.string.newgame_drop_relay;
}
} else {
@ -568,7 +579,7 @@ public class BoardDelegate extends DelegateBase
Bundle args = getArguments();
m_rowid = args.getLong( GameUtils.INTENT_KEY_ROWID, -1 );
DbgUtils.logi( getClass(), "opening rowid %d", m_rowid );
DbgUtils.logi( TAG, "opening rowid %d", m_rowid );
m_haveInvited = args.getBoolean( GameUtils.INVITED, false );
m_overNotShown = true;
@ -659,7 +670,8 @@ public class BoardDelegate extends DelegateBase
}
@Override
protected void onActivityResult( RequestCode requestCode, int resultCode, Intent data )
protected void onActivityResult( RequestCode requestCode, int resultCode,
Intent data )
{
if ( Activity.RESULT_CANCELED != resultCode ) {
InviteMeans missingMeans = null;
@ -673,6 +685,9 @@ public class BoardDelegate extends DelegateBase
case RELAY_INVITE_RESULT:
missingMeans = InviteMeans.RELAY;
break;
case P2P_INVITE_RESULT:
missingMeans = InviteMeans.WIFIDIRECT;
break;
}
if ( null != missingMeans ) {
@ -700,10 +715,47 @@ public class BoardDelegate extends DelegateBase
}
}
// Invitations need to check phone state to decide whether to offer SMS
// invitation. Complexity (showRationale) boolean is to prevent infinite
// loop of showing the rationale over and over. Android will always tell
// us to show the rationale, but if we've done it already we need to go
// straight to asking for the permission.
private void callInviteChoices( final Action action,
final DBUtils.SentInvitesInfo info,
boolean showRationale )
{
Perms23.Builder builder =
new Perms23.Builder( Perms23.Perm.READ_PHONE_STATE );
if ( showRationale ) {
builder.setOnShowRationale( new Perms23.OnShowRationale() {
@Override
public void onShouldShowRationale( Set<Perms23.Perm> perms )
{
makeOkOnlyBuilder( R.string.phone_state_rationale )
.setAction( Action.RETRY_PHONE_STATE_ACTION )
.setParams( action, info )
.show();
}
} );
}
builder.asyncQuery( m_activity, new Perms23.PermCbck() {
@Override
public void onPermissionResult( Map<Perms23.Perm,
Boolean> perms )
{
// Do the work regardless of result; just won't have
// SMS option
showInviteChoicesThen( action, info );
}
});
}
@Override
public void orientationChanged()
{
DbgUtils.logd( getClass(), "BoardDelegate.orientationChanged()" );
DbgUtils.logd( TAG, "BoardDelegate.orientationChanged()" );
initToolbar();
m_view.orientationChanged();
}
@ -957,7 +1009,7 @@ public class BoardDelegate extends DelegateBase
break;
default:
DbgUtils.logw( getClass(), "menuitem %d not handled", id );
DbgUtils.logw( TAG, "menuitem %d not handled", id );
handled = false;
}
@ -976,7 +1028,7 @@ public class BoardDelegate extends DelegateBase
{
boolean handled = false;
boolean positive = AlertDialog.BUTTON_POSITIVE == which;
DbgUtils.logd( getClass(), "BoardDelegate.dlgButtonClicked(%s, %b)",
DbgUtils.logd( TAG, "BoardDelegate.dlgButtonClicked(%s, %b)",
action.toString(), positive );
if ( Action.ENABLE_RELAY_DO_OR == action ) {
@ -992,6 +1044,10 @@ public class BoardDelegate extends DelegateBase
}
}, 10 );
}
} else if ( Action.RETRY_PHONE_STATE_ACTION == action ) {
Action stateAction = (Action)params[0];
DBUtils.SentInvitesInfo info = (DBUtils.SentInvitesInfo)params[1];
callInviteChoices( stateAction, info, false );
} else if ( positive ) {
handled = true;
JNICmd cmd = JNICmd.CMD_NONE;
@ -1055,8 +1111,12 @@ public class BoardDelegate extends DelegateBase
GamesListDelegate.sendNFCToSelf( m_activity, makeNFCMessage() );
break;
case DROP_RELAY_ACTION:
dropRelayAndRestart();
dropConViaAndRestart(CommsConnType.COMMS_CONN_RELAY);
break;
case DROP_SMS_ACTION:
dropConViaAndRestart(CommsConnType.COMMS_CONN_SMS);
break;
case DELETE_AND_EXIT:
deleteAndClose();
break;
@ -1114,6 +1174,11 @@ public class BoardDelegate extends DelegateBase
RelayInviteDelegate.launchForResult( m_activity, m_nMissing,
RequestCode.RELAY_INVITE_RESULT );
break;
case WIFIDIRECT:
WiDirInviteDelegate.launchForResult( m_activity,
m_nMissing,
RequestCode.P2P_INVITE_RESULT );
break;
case EMAIL:
case CLIPBOARD:
NetLaunchInfo nli = new NetLaunchInfo( m_summary, m_gi, 1,
@ -1180,7 +1245,7 @@ public class BoardDelegate extends DelegateBase
// This can be BT or SMS. In BT case there's a progress
// thing going. Not in SMS case.
case NEWGAME_FAILURE:
DbgUtils.logw( getClass(), "failed to create game" );
DbgUtils.logw( TAG, "failed to create game" );
break;
case NEWGAME_DUP_REJECTED:
if ( m_progressShown ) {
@ -1334,8 +1399,11 @@ public class BoardDelegate extends DelegateBase
case COMMS_CONN_SMS:
nli.addSMSInfo( m_activity );
break;
case COMMS_CONN_P2P:
nli.addP2PInfo( m_activity );
break;
default:
DbgUtils.logw( getClass(), "Not doing NFC join for conn type %s",
DbgUtils.logw( TAG, "Not doing NFC join for conn type %s",
typ.toString() );
}
}
@ -1415,10 +1483,11 @@ public class BoardDelegate extends DelegateBase
makeConfirmThenBuilder( msg, Action.DROP_RELAY_ACTION ).show();
}
private void dropRelayAndRestart() {
private void dropConViaAndRestart( CommsConnType typ )
{
CommsAddrRec addr = new CommsAddrRec();
XwJNI.comms_getAddr( m_jniGamePtr, addr );
addr.remove( CommsConnType.COMMS_CONN_RELAY );
addr.remove( typ );
XwJNI.comms_setAddr( m_jniGamePtr, addr );
finish();
@ -1557,7 +1626,7 @@ public class BoardDelegate extends DelegateBase
}
if ( null != toastStr ) {
DbgUtils.logi( getClass(), "handleConndMessage(): toastStr: %s", toastStr );
DbgUtils.logi( TAG, "handleConndMessage(): toastStr: %s", toastStr );
m_toastStr = toastStr;
if ( naMsg == 0 ) {
dlgButtonClicked( Action.SHOW_EXPL_ACTION,
@ -2028,7 +2097,7 @@ public class BoardDelegate extends DelegateBase
m_handler = new Handler();
m_blockingDlgID = DlgID.NONE;
m_jniThreadRef.configure( m_activity, m_view, m_utils, this,
m_jniThreadRef.configure( m_activity, m_view, m_utils, this,
makeJNIHandler() );
m_jniGamePtr = m_jniThreadRef.getGamePtr();
Assert.assertNotNull( m_jniGamePtr );
@ -2140,6 +2209,8 @@ public class BoardDelegate extends DelegateBase
Utils.cancelNotification( m_activity, (int)m_rowid );
askPermissions();
if ( m_gi.serverRole != DeviceRole.SERVER_STANDALONE ) {
warnIfNoTransport();
trySendChats();
@ -2149,6 +2220,31 @@ public class BoardDelegate extends DelegateBase
}
} // resumeGame
private void askPermissions()
{
if ( m_summary.conTypes.contains( CommsConnType.COMMS_CONN_SMS )
&& null == m_permCbck ) { // already asked?
m_permCbck = new Perms23.PermCbck() {
@Override
public void onPermissionResult( Map<Perms23.Perm,
Boolean> perms )
{
ActionPair pair = new ActionPair( Action.DROP_SMS_ACTION,
R.string.remove_sms );
if ( ! perms.get(Perms23.Perm.SEND_SMS) ) {
makeNotAgainBuilder( R.string.not_again_missing_perms,
R.string.key_notagain_missing_perms )
.setActionPair( pair )
.show();
}
}
};
new Perms23.Builder(Perms23.Perm.SEND_SMS)
.asyncQuery( m_activity, m_permCbck );
}
}
private void tickle( boolean force )
{
for ( Iterator<CommsConnType> iter = m_connTypes.iterator();
@ -2160,9 +2256,10 @@ public class BoardDelegate extends DelegateBase
break;
case COMMS_CONN_RELAY:
case COMMS_CONN_SMS:
case COMMS_CONN_P2P:
break;
default:
DbgUtils.logw( getClass(), "tickle: unexpected type %s",
DbgUtils.logw( TAG, "tickle: unexpected type %s",
typ.toString() );
Assert.fail();
}
@ -2258,7 +2355,7 @@ public class BoardDelegate extends DelegateBase
int result = cancelResult;
// this has been true; dunno why
if ( DlgID.NONE != m_blockingDlgID ) {
DbgUtils.logw( getClass(), "waitBlockingDialog: dropping dlgID %d b/c %d set",
DbgUtils.logw( TAG, "waitBlockingDialog: dropping dlgID %d b/c %d set",
dlgID, m_blockingDlgID );
} else {
setBlockingThread();
@ -2274,12 +2371,12 @@ public class BoardDelegate extends DelegateBase
try {
m_forResultWait.acquire();
} catch ( java.lang.InterruptedException ie ) {
DbgUtils.logex( ie );
DbgUtils.logex( TAG, ie );
if ( DlgID.NONE != m_blockingDlgID ) {
try {
dismissDialog( m_blockingDlgID );
} catch ( java.lang.IllegalArgumentException iae ) {
DbgUtils.logex( iae );
DbgUtils.logex( TAG, iae );
}
}
}
@ -2378,7 +2475,7 @@ public class BoardDelegate extends DelegateBase
private void warnIfNoTransport()
{
if ( m_connTypes.contains( CommsConnType.COMMS_CONN_SMS ) ) {
if ( XWApp.SMSSUPPORTED && !XWPrefs.getSMSEnabled( m_activity ) ) {
if ( !XWPrefs.getSMSEnabled( m_activity ) ) {
makeConfirmThenBuilder( R.string.warn_sms_disabled,
Action.ENABLE_SMS_ASK )
.setPosButton( R.string.button_enable_sms )
@ -2415,7 +2512,6 @@ public class BoardDelegate extends DelegateBase
} else if ( null != m_missingDevs ) {
Assert.assertNotNull( m_missingMeans );
String gameName = GameUtils.getName( m_activity, m_rowid );
m_invitesPending = m_missingDevs.length;
for ( int ii = 0; ii < m_missingDevs.length; ++ii ) {
String dev = m_missingDevs[ii];
int nPlayers = m_missingCounts[ii];
@ -2453,9 +2549,12 @@ public class BoardDelegate extends DelegateBase
RelayService.inviteRemote( m_activity, destDevID,
null, nli );
} catch (NumberFormatException nfi) {
DbgUtils.logex( nfi );
DbgUtils.logex( TAG, nfi );
}
break;
case WIFIDIRECT:
WiDirService.inviteRemote( m_activity, dev, nli );
break;
}
if ( null != dev ) {
@ -2534,8 +2633,8 @@ public class BoardDelegate extends DelegateBase
if ( canPost ) {
m_handler.post( runnable );
} else {
DbgUtils.logw( getClass(), "post(): dropping b/c handler null" );
DbgUtils.printStack();
DbgUtils.logw( TAG, "post(): dropping b/c handler null" );
DbgUtils.printStack( TAG );
}
return canPost;
}
@ -2545,7 +2644,7 @@ public class BoardDelegate extends DelegateBase
if ( null != m_handler ) {
m_handler.postDelayed( runnable, when );
} else {
DbgUtils.logw( getClass(), "postDelayed: dropping %d because handler null", when );
DbgUtils.logw( TAG, "postDelayed: dropping %d because handler null", when );
}
}
@ -2554,7 +2653,7 @@ public class BoardDelegate extends DelegateBase
if ( null != m_handler ) {
m_handler.removeCallbacks( which );
} else {
DbgUtils.logw( getClass(), "removeCallbacks: dropping %h because handler null",
DbgUtils.logw( TAG, "removeCallbacks: dropping %h because handler null",
which );
}
}
@ -2595,7 +2694,8 @@ public class BoardDelegate extends DelegateBase
CommsConnTypeSet connTypes = summary.conTypes;
supported = connTypes.contains( CommsConnType.COMMS_CONN_BT )
|| connTypes.contains( CommsConnType.COMMS_CONN_SMS )
|| connTypes.contains( CommsConnType.COMMS_CONN_RELAY );
|| connTypes.contains( CommsConnType.COMMS_CONN_RELAY )
|| connTypes.contains( CommsConnType.COMMS_CONN_P2P );
}
} else if ( null != context ) {
// show the button if people haven't dismissed the hint yet
@ -2621,6 +2721,7 @@ public class BoardDelegate extends DelegateBase
String phone = null;
String btAddr = null;
String relayID = null;
String p2pMacAddress = null;
if ( DeviceRole.SERVER_STANDALONE == gi.serverRole ) {
// nothing to do??
} else if ( 2 != gi.nPlayers ) {
@ -2647,6 +2748,10 @@ public class BoardDelegate extends DelegateBase
Assert.assertNull( relayID );
relayID = XwJNI.comms_formatRelayID( jniGamePtr, ii );
}
if ( addr.contains( CommsConnType.COMMS_CONN_P2P ) ) {
Assert.assertNull( p2pMacAddress );
p2pMacAddress = addr.p2p_addr;
}
}
}
@ -2655,7 +2760,7 @@ public class BoardDelegate extends DelegateBase
String newName = summary.getRematchName();
Intent intent = GamesListDelegate
.makeRematchIntent( activity, rowid, gi, connTypes, btAddr,
phone, relayID, newName );
phone, relayID, p2pMacAddress, newName );
if ( null != intent ) {
activity.startActivity( intent );
}
@ -2686,7 +2791,7 @@ public class BoardDelegate extends DelegateBase
doRematchIf( activity, null, rowID, summary, gi, gamePtr );
gamePtr.release();
} else {
DbgUtils.logw( BoardDelegate.class, "setupRematchFor(): unable to lock game" );
DbgUtils.logw( TAG, "setupRematchFor(): unable to lock game" );
}
if ( null != thread ) {
@ -2726,6 +2831,11 @@ public class BoardDelegate extends DelegateBase
RelayService.inviteRemote( m_activity, 0, value, nli );
recordInviteSent( InviteMeans.RELAY, value );
}
value = m_summary.getStringExtra( GameSummary.EXTRA_REMATCH_P2P );
if ( null != value ) {
WiDirService.inviteRemote( m_activity, value, nli );
recordInviteSent( InviteMeans.WIFIDIRECT, value );
}
showToast( R.string.rematch_sent_toast );
}
@ -2756,7 +2866,7 @@ public class BoardDelegate extends DelegateBase
sendSMSInviteIf( (String)params[1], (NetLaunchInfo)params[0],
false );
} else {
DbgUtils.logw( getClass(), "retrySMSInvites: tests failed" );
DbgUtils.logw( TAG, "retrySMSInvites: tests failed" );
}
}
@ -2768,8 +2878,8 @@ public class BoardDelegate extends DelegateBase
private void handleViaThread( JNICmd cmd, Object... args )
{
if ( null == m_jniThread ) {
DbgUtils.logw( getClass(), "not calling handle(%s)", cmd.toString() );
DbgUtils.printStack();
DbgUtils.logw( TAG, "not calling handle(%s)", cmd.toString() );
DbgUtils.printStack( TAG );
} else {
m_jniThread.handle( cmd, args );
}

View file

@ -23,6 +23,7 @@ package org.eehouse.android.xw4;
import android.os.Bundle;
public class BoardFrag extends XWFragment {
private static final String TAG = BoardFrag.class.getSimpleName();
public BoardFrag() {}

View file

@ -26,8 +26,8 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Build;
import android.util.AttributeSet;
import android.util.FloatMath;
import android.view.MotionEvent;
import android.view.View;
@ -42,9 +42,11 @@ import org.eehouse.android.xw4.jni.SyncedDraw;
import org.eehouse.android.xw4.jni.XwJNI;
public class BoardView extends View implements BoardHandler, SyncedDraw {
private static final String TAG = BoardView.class.getSimpleName();
private static final float MIN_FONT_DIPS = 10.0f;
private static final int MULTI_INACTIVE = -1;
private static final int VERSION_CODES_N = 24; // until we're building on SDK 24...
private static boolean s_isFirstDraw;
private static int s_curGameID;
@ -107,7 +109,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
} else if ( XwJNI.board_containsPt( m_jniGamePtr, xx, yy ) ) {
handle( JNIThread.JNICmd.CMD_PEN_DOWN, xx, yy );
} else {
DbgUtils.logd( getClass(), "BoardView.onTouchEvent(): in white space" );
DbgUtils.logd( TAG, "BoardView.onTouchEvent(): in white space" );
}
break;
case MotionEvent.ACTION_MOVE:
@ -140,7 +142,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
m_lastSpacing = MULTI_INACTIVE;
break;
default:
DbgUtils.logw( getClass(), "onTouchEvent: unknown action: %d", action );
DbgUtils.logw( TAG, "onTouchEvent: unknown action: %d", action );
break;
}
}
@ -158,7 +160,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
if ( BoardContainer.getIsPortrait() != (m_dims.height > m_dims.width) ) {
// square possible; will break above!
Assert.assertTrue( m_dims.height != m_dims.width );
DbgUtils.logd( getClass(), "BoardView.onMeasure: discarding m_dims" );
DbgUtils.logd( TAG, "BoardView.onMeasure: discarding m_dims" );
if ( ++m_dimsTossCount < 4 ) {
m_dims = null;
m_layoutWidth = m_layoutHeight = 0;
@ -185,7 +187,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
width = minWidth;
}
setMeasuredDimension( width, height );
DbgUtils.logd( getClass(), "BoardView.onMeasure: calling setMeasuredDimension( width=%d, height=%d )",
DbgUtils.logd( TAG, "BoardView.onMeasure: calling setMeasuredDimension( width=%d, height=%d )",
width, height );
}
@ -203,11 +205,16 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
{
synchronized( this ) {
if ( layoutBoardOnce() && m_measuredFromDims ) {
canvas.drawBitmap( s_bitmap, 0, 0, new Paint() );
Bitmap bitmap = s_bitmap;
if ( Build.VERSION.SDK_INT >= VERSION_CODES_N ) {
bitmap = Bitmap.createBitmap(bitmap);
}
canvas.drawBitmap( bitmap, 0, 0, new Paint() );
ConnStatusHandler.draw( m_context, canvas, getResources(),
m_connTypes, m_isSolo );
} else {
DbgUtils.logd( getClass(), "BoardView.onDraw(): board not laid out yet" );
DbgUtils.logd( TAG, "BoardView.onDraw(): board not laid out yet" );
}
}
}
@ -218,15 +225,15 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
final int height = getHeight();
boolean layoutDone = width == m_layoutWidth && height == m_layoutHeight;
if ( layoutDone ) {
DbgUtils.logd( getClass(), "layoutBoardOnce(): layoutDone true" );
DbgUtils.logd( TAG, "layoutBoardOnce(): layoutDone true" );
} else if ( null == m_gi ) {
// nothing to do either
DbgUtils.logd( getClass(), "layoutBoardOnce(): no m_gi" );
DbgUtils.logd( TAG, "layoutBoardOnce(): no m_gi" );
} else if ( null == m_jniThread ) {
// nothing to do either
DbgUtils.logd( getClass(), "layoutBoardOnce(): no m_jniThread" );
DbgUtils.logd( TAG, "layoutBoardOnce(): no m_jniThread" );
} else if ( null == m_dims ) {
DbgUtils.logd( getClass(), "layoutBoardOnce(): null m_dims" );
DbgUtils.logd( TAG, "layoutBoardOnce(): null m_dims" );
// m_canvas = null;
// need to synchronize??
Paint paint = new Paint();
@ -237,13 +244,13 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
int timerWidth = scratch.width();
int fontWidth =
Math.min(m_defaultFontHt, timerWidth / timerTxt.length());
DbgUtils.logd( getClass(), "layoutBoardOnce(): posting JNICmd.CMD_LAYOUT(w=%d, h=%d)",
DbgUtils.logd( TAG, "layoutBoardOnce(): posting JNICmd.CMD_LAYOUT(w=%d, h=%d)",
width, height );
handle( JNIThread.JNICmd.CMD_LAYOUT, width, height,
fontWidth, m_defaultFontHt );
// We'll be back....
} else {
DbgUtils.logd( getClass(), "layoutBoardOnce(): DOING IT" );
DbgUtils.logd( TAG, "layoutBoardOnce(): DOING IT" );
// If board size has changed we need a new bitmap
int bmHeight = 1 + m_dims.height;
int bmWidth = 1 + m_dims.width;
@ -277,7 +284,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
m_layoutHeight = height;
layoutDone = true;
}
DbgUtils.logd( getClass(), "layoutBoardOnce()=>%b", layoutDone );
DbgUtils.logd( TAG, "layoutBoardOnce()=>%b", layoutDone );
return layoutDone;
} // layoutBoardOnce
@ -290,7 +297,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
public void startHandling( Activity parent, JNIThread thread,
CommsConnTypeSet connTypes )
{
DbgUtils.logd( getClass(), "startHandling(thread=%H)", thread );
DbgUtils.logd( TAG, "startHandling(thread=%H)", thread );
m_parent = parent;
m_jniThread = thread;
m_jniGamePtr = thread.getGamePtr();
@ -340,7 +347,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
public void dimsChanged( BoardDims dims )
{
DbgUtils.logd( getClass(), "dimsChanged(%s)", dims.toString() );
DbgUtils.logd( TAG, "dimsChanged(%s)", dims.toString() );
m_dims = dims;
m_parent.runOnUiThread( new Runnable() {
public void run()
@ -383,7 +390,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
} 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) );
result = (int)Math.sqrt( (xx * xx) + (yy * yy) );
}
return result;
}
@ -405,8 +412,8 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
private void handle( JNIThread.JNICmd cmd, Object... args )
{
if ( null == m_jniThread ) {
DbgUtils.logw( getClass(), "not calling handle(%s)", cmd.toString() );
DbgUtils.printStack();
DbgUtils.logw( TAG, "not calling handle(%s)", cmd.toString() );
DbgUtils.printStack( TAG );
} else {
m_jniThread.handle( cmd, args );
}

View file

@ -23,6 +23,7 @@ package org.eehouse.android.xw4;
import android.os.Bundle;
public class ChatActivity extends XWActivity {
private static final String TAG = ChatActivity.class.getSimpleName();
@Override
public void onCreate( Bundle savedInstanceState )

View file

@ -43,6 +43,7 @@ import org.eehouse.android.xw4.DlgDelegate.Action;
import org.eehouse.android.xw4.jni.JNIThread;
public class ChatDelegate extends DelegateBase {
private static final String TAG = ChatDelegate.class.getSimpleName();
private static final String INTENT_KEY_PLAYER = "intent_key_player";
private static final String INTENT_KEY_NAMES = "intent_key_names";
@ -129,7 +130,7 @@ public class ChatDelegate extends DelegateBase {
super.onResume();
m_jniThreadRef = JNIThread.getRetained( m_rowid );
if ( null == m_jniThreadRef ) {
DbgUtils.logw( getClass(), "onResume(): m_jniThreadRef null; exiting" );
DbgUtils.logw( TAG, "onResume(): m_jniThreadRef null; exiting" );
finish();
} else {
s_visibleThis = this;

View file

@ -22,6 +22,7 @@ package org.eehouse.android.xw4;
import android.os.Bundle;
public class ChatFrag extends XWFragment {
private static final String TAG = ChatFrag.class.getSimpleName();
public ChatFrag() {}

View file

@ -43,6 +43,7 @@ import java.util.Vector;
public class CommsTransport implements TransportProcs,
NetStateCache.StateChangedIf {
private static final String TAG = CommsTransport.class.getSimpleName();
private Selector m_selector;
private SocketChannel m_socketChannel;
private CommsAddrRec m_relayAddr;
@ -94,9 +95,9 @@ public class CommsTransport implements TransportProcs,
closeSocket();
} catch ( java.io.IOException ioe ) {
DbgUtils.logex( ioe );
DbgUtils.logex( TAG, ioe );
} catch ( UnresolvedAddressException uae ) {
DbgUtils.logw( getClass(), "bad address: name: %s; port: %s; exception: %s",
DbgUtils.logw( TAG, "bad address: name: %s; port: %s; exception: %s",
m_useHost, m_relayAddr.ip_relay_port,
uae.toString() );
}
@ -124,7 +125,7 @@ public class CommsTransport implements TransportProcs,
try {
m_socketChannel = SocketChannel.open();
m_socketChannel.configureBlocking( false );
DbgUtils.logi( getClass(), "connecting to %s:%d",
DbgUtils.logi( TAG, "connecting to %s:%d",
m_useHost,
m_relayAddr.ip_relay_port );
InetSocketAddress isa = new
@ -132,7 +133,7 @@ public class CommsTransport implements TransportProcs,
m_relayAddr.ip_relay_port );
m_socketChannel.connect( isa );
} catch ( java.io.IOException ioe ) {
DbgUtils.logex( ioe );
DbgUtils.logex( TAG, ioe );
failed = true;
break outer_loop;
}
@ -149,14 +150,14 @@ public class CommsTransport implements TransportProcs,
// we get this when relay goes down. Need to notify!
failed = true;
closeSocket();
DbgUtils.logw( getClass(), "exiting: %s", cce.toString() );
DbgUtils.logw( TAG, "exiting: %s", cce.toString() );
break; // don't try again
} catch ( java.io.IOException ioe ) {
closeSocket();
DbgUtils.logw( getClass(), "exiting: %s", ioe.toString() );
DbgUtils.logw( getClass(), ioe.toString() );
DbgUtils.logw( TAG, "exiting: %s", ioe.toString() );
DbgUtils.logw( TAG, ioe.toString() );
} catch ( java.nio.channels.NoConnectionPendingException ncp ) {
DbgUtils.logex( ncp );
DbgUtils.logex( TAG, ncp );
closeSocket();
break;
}
@ -198,13 +199,13 @@ public class CommsTransport implements TransportProcs,
}
}
} catch ( java.io.IOException ioe ) {
DbgUtils.logw( getClass(), "%s: cancelling key", ioe.toString() );
DbgUtils.logw( TAG, "%s: cancelling key", ioe.toString() );
key.cancel();
failed = true;
break outer_loop;
} catch ( java.nio.channels.
NoConnectionPendingException ncp ) {
DbgUtils.logex( ncp );
DbgUtils.logex( TAG, ncp );
break outer_loop;
}
}
@ -228,7 +229,7 @@ public class CommsTransport implements TransportProcs,
//////////////////////////////////////////////////////////////////////
// NetStateCache.StateChangedIf interface
//////////////////////////////////////////////////////////////////////
public void netAvail( boolean nowAvailable )
public void onNetAvail( boolean nowAvailable )
{
if ( !nowAvailable ) {
waitToStopImpl();
@ -260,7 +261,7 @@ public class CommsTransport implements TransportProcs,
try {
m_socketChannel.close();
} catch ( Exception e ) {
DbgUtils.logw( getClass(), "closing socket: %s", e.toString() );
DbgUtils.logw( TAG, "closing socket: %s", e.toString() );
}
m_socketChannel = null;
}
@ -341,7 +342,7 @@ public class CommsTransport implements TransportProcs,
try {
m_thread.join(100); // wait up to 1/10 second
} catch ( java.lang.InterruptedException ie ) {
DbgUtils.logex( ie );
DbgUtils.logex( TAG, ie );
}
m_thread = null;
}
@ -355,7 +356,7 @@ public class CommsTransport implements TransportProcs,
public int transportSend( byte[] buf, String msgNo, CommsAddrRec addr,
CommsConnType conType, int gameID )
{
DbgUtils.logd( getClass(), "transportSend(len=%d, typ=%s)",
DbgUtils.logd( TAG, "transportSend(len=%d, typ=%s)",
buf.length, conType.toString() );
int nSent = -1;
Assert.assertNotNull( addr );
@ -384,13 +385,13 @@ 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.
DbgUtils.logd( getClass(), "transportSend(%d)=>%d", buf.length, nSent );
DbgUtils.logd( TAG, "transportSend(%d)=>%d", buf.length, nSent );
return nSent;
}
public void relayStatus( CommsRelayState newState )
{
DbgUtils.logi( getClass(), "relayStatus called; state=%s", newState.toString() );
DbgUtils.logi( TAG, "relayStatus called; state=%s", newState.toString() );
switch( newState ) {
case COMMS_RELAYSTATE_UNCONNECTED:
@ -448,6 +449,10 @@ public class CommsTransport implements TransportProcs,
case COMMS_CONN_BT:
nSent = BTService.enqueueFor( context, buf, addr, gameID );
break;
case COMMS_CONN_P2P:
nSent = WiDirService
.sendPacket( context, addr.p2p_addr, gameID, buf );
break;
default:
Assert.fail();
break;

View file

@ -47,6 +47,7 @@ import java.util.HashMap;
import java.util.Iterator;
public class ConnStatusHandler {
private static final String TAG = ConnStatusHandler.class.getSimpleName();
public interface ConnStatusCBacks {
public void invalidateParent();
@ -186,14 +187,9 @@ public class ConnStatusHandler {
synchronized( s_lockObj ) {
sb.append( LocUtils.getString( context,
R.string.connstat_net_fmt,
connTypes.toString( context )));
connTypes.toString( context, true )));
for ( CommsConnType typ : connTypes.getTypes() ) {
String did = "";
if ( BuildConfig.DEBUG
&& CommsConnType.COMMS_CONN_RELAY == typ ) {
did = String.format( "(DevID: %d) ",
DevID.getRelayDevIDInt(context) );
}
String did = addDebugInfo( context, typ );
sb.append( String.format( "\n\n*** %s %s***\n",
typ.longName( context ), did ) );
SuccessRecord record = recordFor( typ, false );
@ -391,7 +387,7 @@ public class ConnStatusHandler {
// } catch ( java.lang.ClassNotFoundException cnfe ) {
// DbgUtils.logf( "loadState: %s", cnfe.toString() );
} catch ( Exception ex ) {
DbgUtils.logex( ex );
DbgUtils.logex( TAG, ex );
}
}
}
@ -510,7 +506,7 @@ public class ConnStatusHandler {
XWPrefs.setPrefsString( context, R.string.key_connstat_data,
as64 );
} catch ( java.io.IOException ioe ) {
DbgUtils.logex( ioe );
DbgUtils.logex( TAG, ioe );
}
s_needsSave = false;
}
@ -532,7 +528,7 @@ public class ConnStatusHandler {
boolean result = true;
switch( connType ) {
case COMMS_CONN_SMS:
result = XWApp.SMSSUPPORTED && XWPrefs.getSMSEnabled( context )
result = XWPrefs.getSMSEnabled( context )
&& !getAirplaneModeOn( context );
break;
case COMMS_CONN_BT:
@ -545,8 +541,11 @@ public class ConnStatusHandler {
result = RelayService.relayEnabled( context )
&& NetStateCache.netAvail( context );
break;
case COMMS_CONN_P2P:
result = WiDirService.connecting();
break;
default:
DbgUtils.logw( ConnStatusHandler.class, "connTypeEnabled: %s not handled",
DbgUtils.logw( TAG, "connTypeEnabled: %s not handled",
connType.toString() );
break;
}
@ -560,4 +559,22 @@ public class ConnStatusHandler {
Settings.System.AIRPLANE_MODE_ON, 0 );
return result;
}
private static String addDebugInfo( Context context, CommsConnType typ )
{
String result = "";
if ( BuildConfig.DEBUG ) {
switch ( typ ) {
case COMMS_CONN_RELAY:
result = String.format( "(DevID: %d) ", DevID.getRelayDevIDInt(context) );
break;
case COMMS_CONN_P2P:
result = WiDirService.formatNetStateInfo();
break;
default:
break;
}
}
return result;
}
}

View file

@ -20,13 +20,16 @@
package org.eehouse.android.xw4;
import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import java.util.Map;
import junit.framework.Assert;
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
@ -34,8 +37,10 @@ import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnTypeSet;
import org.eehouse.android.xw4.loc.LocUtils;
public class ConnViaViewLayout extends LinearLayout {
private static final String TAG = ConnViaViewLayout.class.getSimpleName();
private CommsConnTypeSet m_curSet;
private DlgDelegate.HasDlgDelegate m_dlgDlgt;
private Activity m_activity;
public interface CheckEnabledWarner {
public void warnDisabled( CommsConnType typ );
@ -51,6 +56,8 @@ public class ConnViaViewLayout extends LinearLayout {
super( context, as );
}
public void setActivity( Activity activity ) { m_activity = activity; }
protected void configure( CommsConnTypeSet types,
CheckEnabledWarner cew,
SetEmptyWarner sew,
@ -71,6 +78,23 @@ public class ConnViaViewLayout extends LinearLayout {
}
private void addConnections()
{
// We need SMS and PHONE permission to check if we can support SMS. So
// ask for it here. When we get what we're getting, proceed to
// actually check for what's supported. Those methods will return
// false if they don't have the permission they need.
new Perms23.Builder( Perms23.Perm.READ_PHONE_STATE )
.asyncQuery( m_activity, new Perms23.PermCbck() {
@Override
public void onPermissionResult( Map<Perms23.Perm,
Boolean> granted ) {
addConnectionsPostPermCheck();
}
} );
}
private void addConnectionsPostPermCheck()
{
LinearLayout list = (LinearLayout)findViewById( R.id.conn_types );
list.removeAllViews(); // in case being reused
@ -79,12 +103,10 @@ public class ConnViaViewLayout extends LinearLayout {
CommsConnTypeSet supported = CommsConnTypeSet.getSupported( context );
for ( CommsConnType typ : supported.getTypes() ) {
LinearLayout item = (LinearLayout)
LocUtils.inflate( context, R.layout.btinviter_item );
CheckBox box = (CheckBox)item.findViewById( R.id.inviter_check );
CheckBox box = new CheckBox( context );
box.setText( typ.longName( context ) );
box.setChecked( m_curSet.contains( typ ) );
list.addView( item );
list.addView( box );
final CommsConnType typf = typ;
box.setOnCheckedChangeListener( new OnCheckedChangeListener() {
@ -119,6 +141,9 @@ public class ConnViaViewLayout extends LinearLayout {
case COMMS_CONN_RELAY:
enabled = RelayService.relayEnabled( context );
break;
case COMMS_CONN_P2P:
enabled = WiDirService.supported();
break;
default:
Assert.fail();
break;
@ -147,6 +172,10 @@ public class ConnViaViewLayout extends LinearLayout {
msgID = R.string.not_again_comms_bt;
keyID = R.string.key_na_comms_bt;
break;
case COMMS_CONN_P2P:
msgID = R.string.not_again_comms_p2p;
keyID = R.string.key_na_comms_p2p;
break;
default:
Assert.fail();
break;

View file

@ -33,6 +33,7 @@ import java.util.ArrayList;
import java.util.Arrays;
public class DBHelper extends SQLiteOpenHelper {
private static final String TAG = DBHelper.class.getSimpleName();
public static final String TABLE_NAME_SUM = "summaries";
public static final String TABLE_NAME_OBITS = "obits";
@ -117,7 +118,8 @@ public class DBHelper extends SQLiteOpenHelper {
public static final String SENDER = "SENDER";
public static final String MESSAGE = "MESSAGE";
public static final String TAG = "TAG";
// TAG is a thing in Android; don't wear it out
public static final String TAGG = "TAG";
private Context m_context;
@ -224,7 +226,7 @@ public class DBHelper extends SQLiteOpenHelper {
private static final String[][] s_logsSchema = {
{ TIMESTAMP, "DATETIME DEFAULT CURRENT_TIMESTAMP" },
{ MESSAGE, "TEXT" },
{ TAG, "TEXT" },
{ TAGG, "TEXT" },
};
public DBHelper( Context context )
@ -259,7 +261,7 @@ public class DBHelper extends SQLiteOpenHelper {
@SuppressWarnings("fallthrough")
public void onUpgrade( SQLiteDatabase db, int oldVersion, int newVersion )
{
DbgUtils.logi( getClass(), false, "onUpgrade: old: %d; new: %d",
DbgUtils.logi( TAG, false, "onUpgrade: old: %d; new: %d",
oldVersion, newVersion );
boolean madeSumTable = false;

View file

@ -61,6 +61,7 @@ import java.util.Set;
import java.util.StringTokenizer;
public class DBUtils {
private static final String TAG = DBUtils.class.getSimpleName();
public static final int ROWID_NOTFOUND = -1;
public static final int ROWIDS_ALL = -2;
public static final int GROUPID_UNSPEC = -1;
@ -219,7 +220,8 @@ public class DBUtils {
for ( Iterator<CommsConnType> iter = summary.conTypes.iterator();
iter.hasNext(); ) {
switch ( iter.next() ) {
CommsConnType typ = iter.next();
switch ( typ ) {
case COMMS_CONN_RELAY:
col = cursor.getColumnIndex( DBHelper.ROOMNAME );
if ( col >= 0 ) {
@ -234,7 +236,7 @@ public class DBUtils {
case COMMS_CONN_SMS:
col = cursor.getColumnIndex( DBHelper.REMOTEDEVS );
if ( col >= 0 ) {
summary.setRemoteDevs( context,
summary.setRemoteDevs( context, typ,
cursor.getString( col ) );
}
break;
@ -355,7 +357,7 @@ public class DBUtils {
} // saveSummary
public static void addRematchInfo( Context context, long rowid, String btAddr,
String phone, String relayID )
String phone, String relayID, String p2pAddr )
{
GameLock lock = new GameLock( rowid, true ).lock();
GameSummary summary = getSummary( context, lock );
@ -368,6 +370,9 @@ public class DBUtils {
if ( null != relayID ) {
summary.putStringExtra( GameSummary.EXTRA_REMATCH_RELAY, relayID );
}
if ( null != p2pAddr ) {
summary.putStringExtra( GameSummary.EXTRA_REMATCH_P2P, p2pAddr );
}
saveSummary( context, lock, summary );
lock.unlock();
}
@ -414,6 +419,34 @@ public class DBUtils {
return result;
}
public static int countOpenGamesUsingRelay( Context context )
{
int result = 0;
String[] columns = { DBHelper.CONTYPE };
String selection = String.format( "%s = 0", DBHelper.GAME_OVER );
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null );
int indx = cursor.getColumnIndex( DBHelper.CONTYPE );
while ( cursor.moveToNext() ) {
CommsConnTypeSet typs = new CommsConnTypeSet( cursor.getInt(indx) );
if ( typs.contains( CommsConnType.COMMS_CONN_RELAY ) ) {
++result;
}
}
cursor.close();
db.close();
}
// DbgUtils.logd( TAG, "countOpenGamesUsingRelay() => %d", result );
return result;
}
public static class SentInvitesInfo {
public long m_rowid;
private ArrayList<InviteMeans> m_means;
@ -787,7 +820,7 @@ public class DBUtils {
db.close();
}
if ( null != result && 1 < result.length ) {
DbgUtils.logi( DBUtils.class, "getRowIDsFor(%x)=>length %d array", gameID,
DbgUtils.logi( TAG, "getRowIDsFor(%x)=>length %d array", gameID,
result.length );
}
return result;
@ -835,7 +868,7 @@ public class DBUtils {
int gameID = cursor.getInt( col );
col = cursor.getColumnIndex( DBHelper.REMOTEDEVS );
String devs = cursor.getString( col );
DbgUtils.logi( DBUtils.class, "gameid %d has remote[s] %s", gameID, devs );
DbgUtils.logi( TAG, "gameid %d has remote[s] %s", gameID, devs );
if ( null != devs && 0 < devs.length() ) {
for ( String dev : TextUtils.split( devs, "\n" ) ) {
@ -951,7 +984,7 @@ public class DBUtils {
long result = db.replaceOrThrow( DBHelper.TABLE_NAME_OBITS,
"", values );
} catch ( Exception ex ) {
DbgUtils.logex( ex );
DbgUtils.logex( TAG, ex );
}
db.close();
}
@ -1086,7 +1119,7 @@ public class DBUtils {
result = cursor.getBlob( cursor
.getColumnIndex(DBHelper.SNAPSHOT));
} else {
DbgUtils.loge( DBUtils.class, "loadGame: none for rowid=%d",
DbgUtils.loge( TAG, "loadGame: none for rowid=%d",
rowid );
}
cursor.close();
@ -1104,7 +1137,7 @@ public class DBUtils {
deleteGame( context, lock );
lock.unlock();
} else {
DbgUtils.loge( DBUtils.class, "deleteGame: unable to lock rowid %d", rowid );
DbgUtils.loge( TAG, "deleteGame: unable to lock rowid %d", rowid );
if ( BuildConfig.DEBUG ) {
Assert.fail();
}
@ -1195,15 +1228,15 @@ public class DBUtils {
HistoryPair[] result = null;
String oldHistory = getChatHistoryStr( context, rowid );
if ( null != oldHistory ) {
DbgUtils.logd( DBUtils.class, "convertChatString(): got string: %s", oldHistory );
DbgUtils.logd( TAG, "convertChatString(): got string: %s", oldHistory );
ArrayList<ContentValues> valuess = new ArrayList<ContentValues>();
ArrayList<HistoryPair> pairs = new ArrayList<HistoryPair>();
String localPrefix = LocUtils.getString( context, R.string.chat_local_id );
String rmtPrefix = LocUtils.getString( context, R.string.chat_other_id );
DbgUtils.logd( DBUtils.class, "convertChatString(): prefixes: \"%s\" and \"%s\"", localPrefix, rmtPrefix );
DbgUtils.logd( TAG, "convertChatString(): prefixes: \"%s\" and \"%s\"", localPrefix, rmtPrefix );
String[] msgs = oldHistory.split( "\n" );
DbgUtils.logd( DBUtils.class, "convertChatString(): split into %d", msgs.length );
DbgUtils.logd( TAG, "convertChatString(): split into %d", msgs.length );
int localPlayerIndx = -1;
int remotePlayerIndx = -1;
for ( int ii = playersLocal.length - 1; ii >= 0; --ii ) {
@ -1214,24 +1247,24 @@ public class DBUtils {
}
}
for ( String msg : msgs ) {
DbgUtils.logd( DBUtils.class, "convertChatString(): msg: %s", msg );
DbgUtils.logd( TAG, "convertChatString(): msg: %s", msg );
int indx = -1;
String prefix = null;
if ( msg.startsWith( localPrefix ) ) {
DbgUtils.logd( DBUtils.class, "convertChatString(): msg: %s starts with %s", msg, localPrefix );
DbgUtils.logd( TAG, "convertChatString(): msg: %s starts with %s", msg, localPrefix );
prefix = localPrefix;
indx = localPlayerIndx;
} else if ( msg.startsWith( rmtPrefix ) ) {
DbgUtils.logd( DBUtils.class, "convertChatString(): msg: %s starts with %s", msg, rmtPrefix );
DbgUtils.logd( TAG, "convertChatString(): msg: %s starts with %s", msg, rmtPrefix );
prefix = rmtPrefix;
indx = remotePlayerIndx;
} else {
DbgUtils.logd( DBUtils.class, "convertChatString(): msg: %s starts with neither", msg );
DbgUtils.logd( TAG, "convertChatString(): msg: %s starts with neither", msg );
}
if ( -1 != indx ) {
DbgUtils.logd( DBUtils.class, "convertChatString(): removing substring %s; was: %s", prefix, msg );
DbgUtils.logd( TAG, "convertChatString(): removing substring %s; was: %s", prefix, msg );
msg = msg.substring( prefix.length(), msg.length() );
DbgUtils.logd( DBUtils.class, "convertChatString(): removED substring; now %s", msg );
DbgUtils.logd( TAG, "convertChatString(): removED substring; now %s", msg );
valuess.add( cvForChat( rowid, msg, indx ) );
HistoryPair pair = new HistoryPair(msg, indx );
@ -1301,7 +1334,7 @@ public class DBUtils {
startAndEndOut[1] = Math.min( result.length(),
Integer.parseInt( parts[1] ) );
}
DbgUtils.logd( DBUtils.class, "getCurChat(): => %s [%d,%d]", result,
DbgUtils.logd( TAG, "getCurChat(): => %s [%d,%d]", result,
startAndEndOut[0], startAndEndOut[1] );
return result;
}
@ -1823,7 +1856,7 @@ public class DBUtils {
ArrayList<ContentValues> valuess = new ArrayList<ContentValues>();
valuess.add( cvForChat( rowid, msg, fromPlayer ) );
appendChatHistory( context, valuess );
DbgUtils.logi( DBUtils.class, "appendChatHistory: inserted \"%s\" from player %d",
DbgUtils.logi( TAG, "appendChatHistory: inserted \"%s\" from player %d",
msg, fromPlayer );
} // appendChatHistory
@ -1884,13 +1917,13 @@ public class DBUtils {
channelSrc.transferTo( 0, channelSrc.size(), channelDest );
success = true;
} catch( java.io.IOException ioe ) {
DbgUtils.logex( ioe );
DbgUtils.logex( TAG, ioe );
} finally {
try {
channelSrc.close();
channelDest.close();
} catch( java.io.IOException ioe ) {
DbgUtils.logex( ioe );
DbgUtils.logex( TAG, ioe );
}
}
return success;
@ -2248,7 +2281,7 @@ public class DBUtils {
try {
updateStmt.execute();
} catch ( Exception ex ) {
DbgUtils.logex( ex );
DbgUtils.logex( TAG, ex );
Assert.fail();
}
}
@ -2453,10 +2486,7 @@ public class DBUtils {
public static void appendLog( String tag, String msg )
{
Context context = XWApp.getContext();
if ( null != context ) {
appendLog( context, msg );
}
appendLog( XWApp.getContext(), msg );
}
private static void appendLog( Context context, String msg )
@ -2475,7 +2505,7 @@ public class DBUtils {
String.format( "not rowid in (select rowid from %s order by TIMESTAMP desc limit %d)",
DBHelper.TABLE_NAME_LOGS, LOGLIMIT );
int nGone = db.delete( DBHelper.TABLE_NAME_LOGS, where, null );
DbgUtils.logi( DBUtils.class, false, "appendLog(): deleted %d rows", nGone );
DbgUtils.logi( TAG, false, "appendLog(): deleted %d rows", nGone );
}
db.close();
}
@ -2506,7 +2536,7 @@ public class DBUtils {
invalGroupsCache();
}
} catch( java.io.FileNotFoundException fnfe ) {
DbgUtils.logex( fnfe );
DbgUtils.logex( TAG, fnfe );
}
}
@ -2550,7 +2580,7 @@ public class DBUtils {
int result = updateRowImpl( db, table, rowid, values );
db.close();
if ( 0 == result ) {
DbgUtils.logw( DBUtils.class, "updateRow failed" );
DbgUtils.logw( TAG, "updateRow failed" );
}
}
}

View file

@ -35,7 +35,7 @@ import org.eehouse.android.xw4.loc.LocUtils;
import java.util.Formatter;
public class DbgUtils {
private static final String TAG = BuildConstants.DBG_TAG;
private static final String TAG = DbgUtils.class.getSimpleName();
private static boolean s_doLog = BuildConfig.DEBUG;
private enum LogType { ERROR, WARN, DEBUG, INFO };
@ -54,42 +54,59 @@ public class DbgUtils {
logEnable( on );
}
private static void callLog( LogType lt, Class claz, String fmt, Object... args )
private static void callLog( LogType lt, String tag, String fmt,
Object... args )
{
if ( s_doLog ) {
String tag = claz.getSimpleName();
String msg = new Formatter().format( fmt, args ).toString();
switch( lt ) {
case DEBUG:
Log.d( tag, msg );
break;
case WARN:
Log.w( tag, msg );
break;
case INFO:
Log.i( tag, msg );
break;
case ERROR:
Log.e( tag, msg );
break;
default:
Assert.fail();
break;
}
}
}
public static void logd( Class claz, String fmt, Object... args )
{
callLog( LogType.DEBUG, claz, fmt, args );
public static void logd( String tag, String fmt, Object... args ) {
callLog( LogType.DEBUG, tag, fmt, args );
}
public static void loge( Class claz, String fmt, Object... args )
public static void loge( String tag, String fmt, Object... args )
{
callLog( LogType.ERROR, claz, fmt, args );
callLog( LogType.ERROR, tag, fmt, args );
}
public static void logi( Class claz, String fmt, Object... args )
public static void logi( String tag, String fmt, Object... args )
{
logi( claz, true, fmt, args );
logi( tag, true, fmt, args );
}
public static void logi( Class claz, boolean persist, String fmt, Object... args )
public static void logi( String tag, boolean persist, String fmt,
Object... args )
{
callLog( LogType.INFO, claz, fmt, args );
callLog( LogType.INFO, tag, fmt, args );
}
public static void logw( Class claz, String fmt, Object... args )
public static void logw( String tag, String fmt, Object... args )
{
callLog( LogType.WARN, claz, fmt, args );
callLog( LogType.WARN, tag, fmt, args );
}
public static void showf( String format, Object... args )
{
showf( XWApp.getContext(), format, args );
}
public static void showf( Context context, String format, Object... args )
@ -104,10 +121,10 @@ public class DbgUtils {
showf( context, LocUtils.getString( context, formatid ), args );
} // showf
public static void logex( Exception exception )
public static void logex( String tag, Exception exception )
{
logw( DbgUtils.class, "Exception: %s", exception.toString() );
printStack( exception.getStackTrace() );
logw( TAG, "Exception: %s", exception.toString() );
printStack( tag, exception.getStackTrace() );
}
public static void assertOnUIThread()
@ -115,20 +132,20 @@ public class DbgUtils {
Assert.assertTrue( Looper.getMainLooper().equals(Looper.myLooper()) );
}
public static void printStack( StackTraceElement[] trace )
public static void printStack( String tag, StackTraceElement[] trace )
{
if ( s_doLog && null != trace ) {
// 2: skip printStack etc.
for ( int ii = 2; ii < trace.length; ++ii ) {
DbgUtils.logi( DbgUtils.class, "ste %d: %s", ii, trace[ii].toString() );
// 1: skip printStack etc.
for ( int ii = 1; ii < trace.length; ++ii ) {
DbgUtils.logd( tag, "ste %d: %s", ii, trace[ii].toString() );
}
}
}
public static void printStack()
public static void printStack( String tag )
{
if ( s_doLog ) {
printStack( Thread.currentThread().getStackTrace() );
printStack( tag, Thread.currentThread().getStackTrace() );
}
}
@ -152,7 +169,7 @@ public class DbgUtils {
{
if ( s_doLog ) {
String dump = DatabaseUtils.dumpCursorToString( cursor );
logi( DbgUtils.class, "cursor: %s", dump );
logi( TAG, "cursor: %s", dump );
}
}

View file

@ -58,6 +58,7 @@ import java.util.Map;
public class DelegateBase implements DlgClickNotify,
DlgDelegate.HasDlgDelegate,
MultiService.MultiEventListener {
private static final String TAG = DelegateBase.class.getSimpleName();
private DlgDelegate m_dlgDelegate;
private Delegator m_delegator;
@ -118,14 +119,14 @@ public class DelegateBase implements DlgClickNotify,
protected void onActivityResult( RequestCode requestCode, int resultCode,
Intent data )
{
DbgUtils.logi( getClass(), "onActivityResult(): subclass responsibility!!!" );
DbgUtils.logi( TAG, "onActivityResult(): subclass responsibility!!!" );
}
protected void onStart()
{
Class clazz = getClass();
if ( s_instances.containsKey( clazz ) ) {
DbgUtils.logd( getClass(), "onStart(): replacing curThis" );
DbgUtils.logd( TAG, "onStart(): replacing curThis" );
}
s_instances.put( clazz, new WeakReference<DelegateBase>(this) );
}
@ -160,7 +161,7 @@ public class DelegateBase implements DlgClickNotify,
result = ref.get();
}
if ( this != result ) {
DbgUtils.logd( getClass(), "%s.curThis() => " + result, this.toString() );
DbgUtils.logd( TAG, "%s.curThis() => " + result, this.toString() );
}
return result;
}
@ -570,12 +571,12 @@ public class DelegateBase implements DlgClickNotify,
protected boolean canHandleNewIntent( Intent intent )
{
DbgUtils.logd( getClass(), "canHandleNewIntent() => false" );
DbgUtils.logd( TAG, "canHandleNewIntent() => false" );
return false;
}
protected void handleNewIntent( Intent intent ) {
DbgUtils.logd( getClass(), "handleNewIntent(%s): not handling",
DbgUtils.logd( TAG, "handleNewIntent(%s): not handling",
intent.toString() );
}
@ -594,7 +595,7 @@ public class DelegateBase implements DlgClickNotify,
switch( event ) {
case BT_ERR_COUNT:
int count = (Integer)args[0];
DbgUtils.logi( getClass(), "Bluetooth error count: %d", count );
DbgUtils.logi( TAG, "Bluetooth error count: %d", count );
break;
case BAD_PROTO_BT:
fmtId = R.string.bt_bad_proto_fmt;
@ -609,7 +610,7 @@ public class DelegateBase implements DlgClickNotify,
m_dlgDelegate.eventOccurred( event, args );
break;
default:
DbgUtils.logd( getClass(), "eventOccurred(event=%s) (DROPPED)",
DbgUtils.logd( TAG, "eventOccurred(event=%s) (DROPPED)",
event.toString() );
break;
}
@ -671,7 +672,7 @@ public class DelegateBase implements DlgClickNotify,
Assert.fail();
break;
}
DbgUtils.logi( getClass(), "dlgButtonClicked(action=%s button=%s): UNHANDLED",
DbgUtils.logi( TAG, "dlgButtonClicked(action=%s button=%s): UNHANDLED",
action.toString(), buttonName );
}
}

View file

@ -34,6 +34,7 @@ import android.content.Context;
import com.google.android.gcm.GCMRegistrar;
public class DevID {
private static final String TAG = DevID.class.getSimpleName();
private static final String DEVID_KEY = "DevID.devid_key";
private static final String DEVID_ACK_KEY = "key_relay_regid_ackd";
@ -84,18 +85,18 @@ public class DevID {
s_relayDevID = asStr;
}
}
DbgUtils.logd( DevID.class, "getRelayDevID() => %s", s_relayDevID );
DbgUtils.logd( TAG, "getRelayDevID() => %s", s_relayDevID );
return s_relayDevID;
}
public static void setRelayDevID( Context context, String devID )
{
DbgUtils.logd( DevID.class, "setRelayDevID()" );
DbgUtils.logd( TAG, "setRelayDevID()" );
if ( BuildConfig.DEBUG ) {
String oldID = getRelayDevID( context );
if ( null != oldID && 0 < oldID.length()
&& ! devID.equals( oldID ) ) {
DbgUtils.logd( DevID.class, "devID changing!!!: %s => %s", oldID, devID );
DbgUtils.logd( TAG, "devID changing!!!: %s => %s", oldID, devID );
}
}
DBUtils.setStringFor( context, DEVID_KEY, devID );
@ -107,7 +108,7 @@ public class DevID {
public static void clearRelayDevID( Context context )
{
DbgUtils.logi( DevID.class, "clearRelayDevID()" );
DbgUtils.logi( TAG, "clearRelayDevID()" );
DBUtils.setStringFor( context, DEVID_KEY, "" );
// DbgUtils.printStack();
}

View file

@ -23,6 +23,7 @@ package org.eehouse.android.xw4;
import android.os.Bundle;
public class DictBrowseActivity extends XWActivity {
private static final String TAG = DictBrowseActivity.class.getSimpleName();
private DictBrowseDelegate m_dlgt;

View file

@ -47,6 +47,7 @@ import java.util.Arrays;
public class DictBrowseDelegate extends DelegateBase
implements View.OnClickListener, OnItemSelectedListener {
private static final String TAG = DictBrowseDelegate.class.getSimpleName();
private static final String DICT_NAME = "DICT_NAME";
private static final String DICT_LOC = "DICT_LOC";
@ -258,7 +259,7 @@ public class DictBrowseDelegate extends DelegateBase
try {
super.finalize();
} catch ( java.lang.Throwable err ){
DbgUtils.logi( getClass(), "%s", err.toString() );
DbgUtils.logi( TAG, "%s", err.toString() );
}
}
@ -453,7 +454,7 @@ public class DictBrowseDelegate extends DelegateBase
DictUtils.DictLoc loc
= DictUtils.getDictLoc( delegator.getActivity(), name );
if ( null == loc ) {
DbgUtils.logw( DictBrowseDelegate.class, "launch(): DictLoc null; try again?" );
DbgUtils.logw( TAG, "launch(): DictLoc null; try again?" );
} else {
launch( delegator, name, loc );
}

View file

@ -22,6 +22,7 @@ package org.eehouse.android.xw4;
import android.os.Bundle;
public class DictBrowseFrag extends XWFragment {
private static final String TAG = DictBrowseFrag.class.getSimpleName();
public DictBrowseFrag() {}

View file

@ -45,6 +45,7 @@ import java.util.Map;
import java.util.Set;
public class DictLangCache {
private static final String TAG = DictLangCache.class.getSimpleName();
private static String[] s_langNames;
private static HashMap<String, Integer> s_langCodes;
@ -361,7 +362,7 @@ public class DictLangCache {
for ( DictAndLoc dal : dals ) {
String name = getLangName( context, dal.name );
if ( null == name || 0 == name.length() ) {
DbgUtils.logw( DictLangCache.class, "bad lang name for dal name %s", dal.name );
DbgUtils.logw( TAG, "bad lang name for dal name %s", dal.name );
// Assert.fail();
}
langs.add( name );
@ -473,7 +474,7 @@ public class DictLangCache {
// Tmp test that recovers from problem with new background download code
if ( null != info && 0 == info.langCode ) {
DbgUtils.logw( DictLangCache.class, "getInfo: dropping info for %s b/c lang code wrong",
DbgUtils.logw( TAG, "getInfo: dropping info for %s b/c lang code wrong",
dal.name );
info = null;
}
@ -493,7 +494,7 @@ public class DictLangCache {
DBUtils.dictsSetInfo( context, dal, info );
} else {
info = null;
DbgUtils.logi( DictLangCache.class,
DbgUtils.logi( TAG,
"getInfo(): unable to open dict %s", dal.name );
}
}

View file

@ -26,6 +26,7 @@ import android.util.AttributeSet;
import java.util.ArrayList;
public class DictListPreference extends XWListPreference {
private static final String TAG = DictListPreference.class.getSimpleName();
public DictListPreference( Context context, AttributeSet attrs )
{

View file

@ -38,6 +38,7 @@ import java.util.ArrayList;
import java.util.HashMap;
public class DictUtils {
private static final String TAG = DictUtils.class.getSimpleName();
public interface DownProgListener {
void progressMade( int nBytes );
@ -194,7 +195,7 @@ public class DictUtils {
} catch ( java.io.FileNotFoundException fnf ) {
// DbgUtils.logex( fnf );
} catch ( java.io.IOException ioe ) {
DbgUtils.logex( ioe );
DbgUtils.logex( TAG, ioe );
}
}
@ -263,7 +264,7 @@ public class DictUtils {
success = DBUtils.copyFileStream( fos, fis );
} catch ( java.io.FileNotFoundException fnfe ) {
DbgUtils.logex( fnfe );
DbgUtils.logex( TAG, fnfe );
}
return success;
} // copyDict
@ -360,11 +361,11 @@ public class DictUtils {
bytes = new byte[len];
fis.read( bytes, 0, len );
fis.close();
DbgUtils.logi( DictUtils.class, "Successfully loaded %s", name );
DbgUtils.logi( TAG, "Successfully loaded %s", name );
} catch ( java.io.FileNotFoundException fnf ) {
// DbgUtils.logex( fnf );
} catch ( java.io.IOException ioe ) {
DbgUtils.logex( ioe );
DbgUtils.logex( TAG, ioe );
}
}
@ -477,9 +478,9 @@ public class DictUtils {
invalDictList();
}
} catch ( java.io.FileNotFoundException fnf ) {
DbgUtils.logex( fnf );
DbgUtils.logex( TAG, fnf );
} catch ( java.io.IOException ioe ) {
DbgUtils.logex( ioe );
DbgUtils.logex( TAG, ioe );
tmpFile.delete();
}
}
@ -564,7 +565,7 @@ public class DictUtils {
AssetManager am = context.getAssets();
return am.list("");
} catch( java.io.IOException ioe ) {
DbgUtils.logex( ioe );
DbgUtils.logex( TAG, ioe );
return new String[0];
}
}
@ -589,7 +590,7 @@ public class DictUtils {
if ( !result.exists() ) {
result.mkdirs();
if ( !result.exists() ) {
DbgUtils.logw( DictUtils.class, "unable to create sd dir %s", packdir );
DbgUtils.logw( TAG, "unable to create sd dir %s", packdir );
result = null;
}
}

View file

@ -23,6 +23,7 @@ package org.eehouse.android.xw4;
import android.os.Bundle;
public class DictsActivity extends XWActivity {
private static final String TAG = DictsActivity.class.getSimpleName();
// I can't provide a subclass of MenuItem to hold DictAndLoc, so
// settle for a hash on the side.

View file

@ -72,6 +72,7 @@ public class DictsDelegate extends ListDelegateBase
SelectableItem, MountEventReceiver.SDCardNotifiee,
DlgDelegate.DlgClickNotify, GroupStateListener,
DownloadFinishedListener, XWListItem.ExpandedListener {
private static final String TAG = DictsDelegate.class.getSimpleName();
protected static final String DICT_SHOWREMOTE = "do_launch";
protected static final String DICT_LANG_EXTRA = "use_lang";
@ -329,7 +330,7 @@ public class DictsDelegate extends ListDelegateBase
}
}
} else {
DbgUtils.logw( getClass(), "No remote info for lang %s", langName );
DbgUtils.logw( TAG, "No remote info for lang %s", langName );
}
}
@ -383,9 +384,9 @@ public class DictsDelegate extends ListDelegateBase
DictLoc fromLoc = (DictLoc)selItem.getCached();
String name = selItem.getText();
if ( fromLoc == toLoc ) {
DbgUtils.logw( getClass(), "not moving %s: same loc", name );
DbgUtils.logw( TAG, "not moving %s: same loc", name );
} else if ( DictUtils.moveDict( self.m_activity,
name, fromLoc,
name, fromLoc,
toLoc ) ) {
selItem.setComment( self.m_locNames[toLoc.ordinal()] );
selItem.setCached( toLoc );
@ -393,7 +394,7 @@ public class DictsDelegate extends ListDelegateBase
DBUtils.dictsMoveInfo( self.m_activity, name,
fromLoc, toLoc );
} else {
DbgUtils.logw( getClass(), "moveDict(%s) failed", name );
DbgUtils.logw( TAG, "moveDict(%s) failed", name );
}
}
}
@ -851,7 +852,7 @@ public class DictsDelegate extends ListDelegateBase
//////////////////////////////////////////////////////////////////////
public void cardMounted( boolean nowMounted )
{
DbgUtils.logi( getClass(), "cardMounted(%b)", nowMounted );
DbgUtils.logi( TAG, "cardMounted(%b)", nowMounted );
// post so other SDCardNotifiee implementations get a chance
// to process first: avoid race conditions
post( new Runnable() {
@ -986,7 +987,7 @@ public class DictsDelegate extends ListDelegateBase
Assert.fail();
}
}
DbgUtils.logi( getClass(), "countSelDicts() => {loc: %d; remote: %d}",
DbgUtils.logi( TAG, "countSelDicts() => {loc: %d; remote: %d}",
results[SEL_LOCAL], results[SEL_REMOTE] );
return results;
}
@ -1149,7 +1150,7 @@ public class DictsDelegate extends ListDelegateBase
public void itemClicked( SelectableItem.LongClickHandler clicked,
GameSummary summary )
{
DbgUtils.logi( getClass(), "itemClicked not implemented" );
DbgUtils.logi( TAG, "itemClicked not implemented" );
}
public void itemToggled( SelectableItem.LongClickHandler toggled,
@ -1242,7 +1243,7 @@ public class DictsDelegate extends ListDelegateBase
}
} catch ( JSONException ex ) {
DbgUtils.logex( ex );
DbgUtils.logex( TAG, ex );
theOne = null;
}
}
@ -1340,7 +1341,7 @@ public class DictsDelegate extends ListDelegateBase
new HashSet<String>( Arrays.asList( m_langs ) );
// DictLangCache hits the DB hundreds of times below. Fix!
DbgUtils.logw( getClass(), "Fix me I'm stupid" );
DbgUtils.logw( TAG, "Fix me I'm stupid" );
try {
// DbgUtils.logf( "data: %s", jsonData );
JSONObject obj = new JSONObject( jsonData );
@ -1422,7 +1423,7 @@ public class DictsDelegate extends ListDelegateBase
success = true;
} catch ( JSONException ex ) {
DbgUtils.logex( ex );
DbgUtils.logex( TAG, ex );
}
}

View file

@ -22,6 +22,7 @@ package org.eehouse.android.xw4;
import android.os.Bundle;
public class DictsFrag extends XWFragment {
private static final String TAG = DictsFrag.class.getSimpleName();
public DictsFrag() {}

View file

@ -25,6 +25,7 @@ import android.net.Uri;
import android.os.Bundle;
public class DispatchNotify extends Activity {
private static final String TAG = DispatchNotify.class.getSimpleName();
@Override
protected void onCreate( Bundle savedInstanceState )

View file

@ -51,6 +51,7 @@ import java.util.Iterator;
import java.util.Map;
public class DlgDelegate {
private static final String TAG = DlgDelegate.class.getSimpleName();
public static enum Action {
SKIP_CALLBACK,
@ -91,6 +92,8 @@ public class DlgDelegate {
BUTTON_BROWSEALL_ACTION,
NFC_TO_SELF,
DROP_RELAY_ACTION,
DROP_SMS_ACTION,
RETRY_PHONE_STATE_ACTION,
// Dict Browser
FINISH_ACTION,
@ -109,6 +112,7 @@ public class DlgDelegate {
CLEAR_ACTION,
USE_IMMOBILE_ACTION,
POST_WARNING_ACTION,
RETRY_CONTACTS_ACTION,
// BT Invite
OPEN_BT_PREFS_ACTION,
@ -195,7 +199,7 @@ public class DlgDelegate {
@Override
public void show()
{
showOKOnlyDialogThen( m_msgString, m_action );
showOKOnlyDialogThen( m_msgString, m_action, m_params );
}
}
@ -290,7 +294,7 @@ public class DlgDelegate {
// These are stored in the INVITES table. Don't change order
// gratuitously
public static enum InviteMeans {
SMS, EMAIL, NFC, BLUETOOTH, CLIPBOARD, RELAY,
SMS, EMAIL, NFC, BLUETOOTH, CLIPBOARD, RELAY, WIFIDIRECT,
};
void dlgButtonClicked( Action action, int button, Object[] params );
void inviteChoiceMade( Action action, InviteMeans means, Object[] params );
@ -406,10 +410,13 @@ public class DlgDelegate {
}
}
private void showOKOnlyDialogThen( String msg, Action action )
private void showOKOnlyDialogThen( String msg, Action action,
Object[] params )
{
// Assert.assertNull( m_dlgStates );
DlgState state = new DlgState( DlgID.DIALOG_OKONLY ).setMsg( msg )
DlgState state = new DlgState( DlgID.DIALOG_OKONLY )
.setMsg( msg )
.setParams( params )
.setAction(action);
addState( state );
showDialog( DlgID.DIALOG_OKONLY );
@ -488,6 +495,7 @@ public class DlgDelegate {
if ( (XWApp.SMS_INVITE_ENABLED && Utils.deviceSupportsSMS( m_activity ))
|| XWPrefs.getNFCToSelfEnabled( m_activity )
|| NFCUtils.nfcAvail( m_activity )[0]
|| WiDirService.supported()
|| BTService.BTAvailable() ) {
DlgState state = new DlgState( DlgID.INVITE_CHOICES_THEN )
.setAction( action )
@ -582,7 +590,7 @@ public class DlgDelegate {
break;
default:
DbgUtils.loge( getClass(), "eventOccurred: unhandled event %s", event.toString() );
DbgUtils.loge( TAG, "eventOccurred: unhandled event %s", event.toString() );
}
if ( null != msg ) {
@ -640,9 +648,14 @@ public class DlgDelegate {
private Dialog createLookupDialog()
{
Dialog result = null;
DlgState state = findForID( DlgID.LOOKUP );
Bundle bundle = (Bundle)state.m_params[0];
return LookupAlert.makeDialog( m_activity, bundle );
// state is null per a play store crash report.
if ( null != state ) {
Bundle bundle = (Bundle)state.m_params[0];
result = LookupAlert.makeDialog( m_activity, bundle );
}
return result;
}
private Dialog createOKDialog( DlgState state, DlgID dlgID )
@ -726,15 +739,19 @@ public class DlgDelegate {
items.add( getString( R.string.invite_choice_bt ) );
means.add( DlgClickNotify.InviteMeans.BLUETOOTH );
}
if ( XWApp.RELAYINVITE_SUPPORTED ) {
items.add( getString( R.string.invite_choice_relay ) );
means.add( DlgClickNotify.InviteMeans.RELAY );
}
if ( WiDirService.supported() ) {
items.add( getString( R.string.invite_choice_p2p ) );
means.add( DlgClickNotify.InviteMeans.WIFIDIRECT );
}
if ( XWPrefs.getNFCToSelfEnabled( m_activity )
|| NFCUtils.nfcAvail( m_activity )[0] ) {
items.add( getString( R.string.invite_choice_nfc ) );
means.add( DlgClickNotify.InviteMeans.NFC );
}
if ( XWApp.RELAYINVITE_SUPPORTED ) {
items.add( getString( R.string.invite_choice_relay ) );
means.add( DlgClickNotify.InviteMeans.RELAY );
}
items.add( getString( R.string.slmenu_copy_sel ) );
means.add( DlgClickNotify.InviteMeans.CLIPBOARD );
@ -994,7 +1011,7 @@ public class DlgDelegate {
if ( null == oneBase ) {
iter.remove(); // no point in keeping it
} else if ( base.equals( oneBase ) ) {
DbgUtils.logd( DlgDelegate.class, "removing alert %s for %s", dlgID.toString(),
DbgUtils.logd( TAG, "removing alert %s for %s", dlgID.toString(),
oneBase.toString() );
activity.removeDialog( dlgID.ordinal() );
iter.remove(); // no point in keeping this either

View file

@ -27,6 +27,7 @@ import org.eehouse.android.xw4.DlgDelegate.Action;
import org.eehouse.android.xw4.DlgDelegate.ActionPair;
public class DlgState implements Parcelable {
private static final String TAG = DlgState.class.getSimpleName();
public DlgID m_id;
public String m_msg;
public int m_posButton;

View file

@ -30,6 +30,7 @@ import android.view.MenuItem;
import android.view.View;
public class DualpaneDelegate extends DelegateBase {
private static final String TAG = DualpaneDelegate.class.getSimpleName();
private Activity m_activity;
public DualpaneDelegate( Delegator delegator, Bundle sis )
@ -60,7 +61,7 @@ public class DualpaneDelegate extends DelegateBase {
{
MainActivity main = (MainActivity)m_activity;
main.dispatchNewIntent( intent );
DbgUtils.logi( getClass(), "handleNewIntent()" );
DbgUtils.logi( TAG, "handleNewIntent()" );
}
@Override
@ -68,7 +69,7 @@ public class DualpaneDelegate extends DelegateBase {
{
MainActivity main = (MainActivity)m_activity;
boolean handled = main.dispatchBackPressed();
DbgUtils.logi( getClass(), "handleBackPressed() => %b", handled );
DbgUtils.logi( TAG, "handleBackPressed() => %b", handled );
return handled;
}
@ -80,7 +81,7 @@ public class DualpaneDelegate extends DelegateBase {
}
@Override
protected void onCreateContextMenu( ContextMenu menu, View view,
protected void onCreateContextMenu( ContextMenu menu, View view,
ContextMenuInfo menuInfo )
{
MainActivity main = (MainActivity)m_activity;

View file

@ -24,6 +24,7 @@ import android.os.Bundle;
import android.view.Window;
public class DwnldActivity extends XWActivity {
private static final String TAG = DwnldActivity.class.getSimpleName();
@Override
protected void onCreate( Bundle savedInstanceState )

View file

@ -47,6 +47,7 @@ import java.util.List;
import java.util.Map;
public class DwnldDelegate extends ListDelegateBase {
private static final String TAG = DwnldDelegate.class.getSimpleName();
// URIs coming in in intents
private static final String APK_EXTRA = "APK";
@ -137,11 +138,11 @@ public class DwnldDelegate extends ListDelegateBase {
}
is.close();
} catch ( java.net.URISyntaxException use ) {
DbgUtils.logex( use );
DbgUtils.logex( TAG, use );
} catch ( java.net.MalformedURLException mue ) {
DbgUtils.logex( mue );
DbgUtils.logex( TAG, mue );
} catch ( java.io.IOException ioe ) {
DbgUtils.logex( ioe );
DbgUtils.logex( TAG, ioe );
}
return null;
}
@ -217,9 +218,9 @@ public class DwnldDelegate extends ListDelegateBase {
fos.close();
success = !cancelled;
} catch ( java.io.FileNotFoundException fnf ) {
DbgUtils.logex( fnf );
DbgUtils.logex( TAG, fnf );
} catch ( java.io.IOException ioe ) {
DbgUtils.logex( ioe );
DbgUtils.logex( TAG, ioe );
}
if ( !success ) {

View file

@ -36,6 +36,7 @@ import android.widget.SeekBar;
import org.eehouse.android.xw4.loc.LocUtils;
public class EditColorPreference extends DialogPreference {
private static final String TAG = EditColorPreference.class.getSimpleName();
private Context m_context;
private int m_curColor;

View file

@ -39,6 +39,7 @@ import java.util.Iterator;
import java.util.Set;
public class ExpiringDelegate {
private static final String TAG = ExpiringDelegate.class.getSimpleName();
private static final long INTERVAL_SECS = 3 * 24 * 60 * 60;
// private static final long INTERVAL_SECS = 60 * 10; // for testing
@ -91,7 +92,7 @@ public class ExpiringDelegate {
}
}
DbgUtils.logd( getClass(), "ref had %d refs, now has %d expiringdelegate views",
DbgUtils.logd( TAG, "ref had %d refs, now has %d expiringdelegate views",
sizeBefore, dlgts.size() );
for ( ExpiringDelegate dlgt : dlgts ) {
@ -120,7 +121,7 @@ public class ExpiringDelegate {
private void setHandler( Handler handler )
{
if ( handler != m_handler ) {
DbgUtils.logd( getClass(), "handler changing from %H to %H",
DbgUtils.logd( TAG, "handler changing from %H to %H",
m_handler, handler );
m_handler = handler;
reschedule();

View file

@ -26,6 +26,7 @@ import android.util.AttributeSet;
import android.widget.LinearLayout;
public class ExpiringLinearLayout extends LinearLayout {
private static final String TAG = ExpiringLinearLayout.class.getSimpleName();
private ExpiringDelegate m_delegate;
public ExpiringLinearLayout( Context context, AttributeSet as ) {

View file

@ -30,6 +30,7 @@ import com.google.android.gcm.GCMRegistrar;
import org.json.JSONArray;
public class GCMIntentService extends GCMBaseIntentService {
private static final String TAG = GCMIntentService.class.getSimpleName();
public GCMIntentService()
{
@ -39,13 +40,13 @@ public class GCMIntentService extends GCMBaseIntentService {
@Override
protected void onError( Context context, String error )
{
DbgUtils.logd( getClass(), "onError(%s)", error );
DbgUtils.logd( TAG, "onError(%s)", error );
}
@Override
protected void onRegistered( Context context, String regId )
{
DbgUtils.logd( getClass(), "onRegistered(%s)", regId );
DbgUtils.logd( TAG, "onRegistered(%s)", regId );
DevID.setGCMDevID( context, regId );
notifyRelayService( context, true );
}
@ -53,7 +54,7 @@ public class GCMIntentService extends GCMBaseIntentService {
@Override
protected void onUnregistered( Context context, String regId )
{
DbgUtils.logd( getClass(), "onUnregistered(%s)", regId );
DbgUtils.logd( TAG, "onUnregistered(%s)", regId );
DevID.clearGCMDevID( context );
RelayService.devIDChanged();
notifyRelayService( context, false );
@ -62,13 +63,13 @@ public class GCMIntentService extends GCMBaseIntentService {
@Override
protected void onMessage( Context context, Intent intent )
{
DbgUtils.logd( getClass(), "onMessage()" );
DbgUtils.logd( TAG, "onMessage()" );
notifyRelayService( context, true );
String value;
boolean ignoreIt = XWApp.GCM_IGNORED;
if ( ignoreIt ) {
DbgUtils.logd( getClass(), "received GCM but ignoring it" );
DbgUtils.logd( TAG, "received GCM but ignoring it" );
} else {
value = intent.getStringExtra( "checkUpdates" );
if ( null != value && Boolean.parseBoolean( value ) ) {
@ -95,7 +96,7 @@ public class GCMIntentService extends GCMBaseIntentService {
RelayService.processGameMsgs( context, connname, strs64 );
}
} catch (org.json.JSONException jse ) {
DbgUtils.logex( jse );
DbgUtils.logex( TAG, jse );
}
}
@ -129,10 +130,10 @@ public class GCMIntentService extends GCMBaseIntentService {
GCMRegistrar.register( app, BuildConstants.GCM_SENDER_ID );
}
} catch ( UnsupportedOperationException uoe ) {
DbgUtils.logw( GCMIntentService.class, "Device can't do GCM." );
DbgUtils.logw( TAG, "Device can't do GCM." );
} catch ( Exception whatever ) {
// funky devices could do anything
DbgUtils.logex( whatever );
DbgUtils.logex( TAG, whatever );
}
}
}

View file

@ -23,6 +23,7 @@ package org.eehouse.android.xw4;
import android.os.Bundle;
public class GameConfigActivity extends XWActivity {
private static final String TAG = GameConfigActivity.class.getSimpleName();
@Override
public void onCreate( Bundle savedInstanceState )

View file

@ -61,6 +61,7 @@ public class GameConfigDelegate extends DelegateBase
implements View.OnClickListener
,XWListItem.DeleteCallback
,RefreshNamesTask.NoNameFound {
private static final String TAG = GameConfigDelegate.class.getSimpleName();
private static final String INTENT_FORRESULT_NEWGAME = "newgame";
@ -229,7 +230,7 @@ public class GameConfigDelegate extends DelegateBase
self.showToast( R.string.forced_consistent );
self.loadPlayersList();
} else {
DbgUtils.logw( getClass(), "onDismiss(): "
DbgUtils.logw( TAG, "onDismiss(): "
+ "no visible self" );
}
}
@ -287,6 +288,7 @@ public class GameConfigDelegate extends DelegateBase
LinearLayout layout = (LinearLayout)inflate( R.layout.conn_types_display );
final ConnViaViewLayout items = (ConnViaViewLayout)
layout.findViewById( R.id.conn_types );
items.setActivity( m_activity );
final CheckBox cb = (CheckBox)layout
.findViewById(R.id.default_check);
cb.setVisibility( View.VISIBLE );
@ -774,13 +776,13 @@ public class GameConfigDelegate extends DelegateBase
}
} else {
DbgUtils.logw( getClass(), "unknown v: " + view.toString() );
DbgUtils.logw( TAG, "unknown v: " + view.toString() );
}
} // onClick
private void saveAndClose( boolean forceNew )
{
DbgUtils.logi( getClass(), "saveAndClose(forceNew=%b)", forceNew );
DbgUtils.logi( TAG, "saveAndClose(forceNew=%b)", forceNew );
applyChanges( forceNew );
finishAndLaunch();
@ -1030,7 +1032,7 @@ public class GameConfigDelegate extends DelegateBase
setting = 2;
break;
default:
DbgUtils.logw( getClass(), "setSmartnessSpinner got %d from getRobotSmartness()",
DbgUtils.logw( TAG, "setSmartnessSpinner got %d from getRobotSmartness()",
m_gi.getRobotSmartness() );
Assert.fail();
}
@ -1072,7 +1074,7 @@ public class GameConfigDelegate extends DelegateBase
private void adjustPlayersLabel()
{
DbgUtils.logi( getClass(), "adjustPlayersLabel()" );
DbgUtils.logi( TAG, "adjustPlayersLabel()" );
String label;
if ( localOnlyGame() ) {
label = getString( R.string.players_label_standalone );
@ -1295,7 +1297,7 @@ public class GameConfigDelegate extends DelegateBase
m_connLabel.setVisibility( View.GONE );
m_changeConnButton.setVisibility( View.GONE );
} else {
String connString = m_conTypes.toString( m_activity );
String connString = m_conTypes.toString( m_activity, true );
m_connLabel.setText( getString( R.string.connect_label_fmt, connString ) );
}
}

View file

@ -22,6 +22,7 @@ package org.eehouse.android.xw4;
import android.os.Bundle;
public class GameConfigFrag extends XWFragment {
private static final String TAG = GameConfigFrag.class.getSimpleName();
public GameConfigFrag() {}

View file

@ -46,6 +46,7 @@ import java.util.concurrent.LinkedBlockingQueue;
public class GameListItem extends LinearLayout
implements View.OnClickListener, SelectableItem.LongClickHandler {
private static final String TAG = GameListItem.class.getSimpleName();
private static final int SUMMARY_WAIT_MSECS = 1000;
@ -259,6 +260,9 @@ public class GameListItem extends LinearLayout
case R.string.game_summary_field_state:
value = state;
break;
case R.string.title_addrs_pref:
value = m_summary.conTypes.toString( m_context, false );
break;
}
String name = GameUtils.getName( m_context, m_rowid );
@ -455,7 +459,7 @@ public class GameListItem extends LinearLayout
try {
elem = s_queue.take();
} catch ( InterruptedException ie ) {
DbgUtils.logw( getClass(), "interrupted; killing "
DbgUtils.logw( TAG, "interrupted; killing "
+ "s_thumbThread" );
break;
}

View file

@ -28,6 +28,7 @@ import java.util.HashMap;
// obtainable when other read locks are granted but not when a
// write lock is. Write-locks are exclusive.
public class GameLock {
private static final String TAG = GameLock.class.getSimpleName();
private static final boolean DEBUG_LOCKS = false;
private static final boolean THROW_ON_LOCKED = true;
private static final int SLEEP_TIME = 100;
@ -55,9 +56,9 @@ public class GameLock {
m_isForWrite = isForWrite;
m_lockCount = 0;
if ( DEBUG_LOCKS ) {
DbgUtils.logi( getClass(), "GameLock(rowid:%d,isForWrite:%b)=>"
DbgUtils.logi( TAG, "GameLock(rowid:%d,isForWrite:%b)=>"
+ "this: %H", rowid, isForWrite, this );
DbgUtils.printStack();
DbgUtils.printStack( TAG );
}
}
@ -91,19 +92,19 @@ public class GameLock {
}
} else if ( this == owner && ! m_isForWrite ) {
if ( DEBUG_LOCKS ) {
DbgUtils.logi( getClass(), "tryLock(): incrementing lock count" );
DbgUtils.logi( TAG, "tryLock(): incrementing lock count" );
}
Assert.assertTrue( 0 == m_lockCount );
++m_lockCount;
gotIt = true;
owner = null;
} else if ( DEBUG_LOCKS ) {
DbgUtils.logi( getClass(), "tryLock(): rowid %d already held by lock %H",
DbgUtils.logi( TAG, "tryLock(): rowid %d already held by lock %H",
m_rowid, owner );
}
}
if ( DEBUG_LOCKS ) {
DbgUtils.logi( getClass(), "tryLock %H (rowid=%d) => %b",
DbgUtils.logi( TAG, "tryLock %H (rowid=%d) => %b",
this, m_rowid, gotIt );
}
return owner;
@ -124,7 +125,7 @@ public class GameLock {
long sleptTime = 0;
if ( DEBUG_LOCKS ) {
DbgUtils.logi( getClass(), "lock %H (rowid:%d, maxMillis=%d)", this, m_rowid,
DbgUtils.logi( TAG, "lock %H (rowid:%d, maxMillis=%d)", this, m_rowid,
maxMillis );
}
@ -135,24 +136,24 @@ public class GameLock {
break;
}
if ( DEBUG_LOCKS ) {
DbgUtils.logi( getClass(), "lock() %H failed; sleeping", this );
DbgUtils.logi( TAG, "lock() %H failed; sleeping", this );
if ( 0 == sleptTime || sleptTime + SLEEP_TIME >= ASSERT_TIME ) {
DbgUtils.logi( getClass(), "lock %H seeking stack:", curOwner );
DbgUtils.printStack( curOwner.m_lockTrace );
DbgUtils.logi( getClass(), "lock %H seeking stack:", this );
DbgUtils.printStack();
DbgUtils.logi( TAG, "lock %H seeking stack:", curOwner );
DbgUtils.printStack( TAG, curOwner.m_lockTrace );
DbgUtils.logi( TAG, "lock %H seeking stack:", this );
DbgUtils.printStack( TAG );
}
}
try {
Thread.sleep( SLEEP_TIME ); // milliseconds
sleptTime += SLEEP_TIME;
} catch( InterruptedException ie ) {
DbgUtils.logex( ie );
DbgUtils.logex( TAG, ie );
break;
}
if ( DEBUG_LOCKS ) {
DbgUtils.logi( getClass(), "lock() %H awake; "
DbgUtils.logi( TAG, "lock() %H awake; "
+ "sleptTime now %d millis", this, sleptTime );
}
@ -162,7 +163,7 @@ public class GameLock {
throw new GameLockedException();
} else if ( sleptTime >= ASSERT_TIME ) {
if ( DEBUG_LOCKS ) {
DbgUtils.logi( getClass(), "lock %H overlocked", this );
DbgUtils.logi( TAG, "lock %H overlocked", this );
}
Assert.fail();
}
@ -188,7 +189,7 @@ public class GameLock {
--m_lockCount;
if ( DEBUG_LOCKS ) {
DbgUtils.logi( getClass(), "unlock: this: %H (rowid:%d) unlocked",
DbgUtils.logi( TAG, "unlock: this: %H (rowid:%d) unlocked",
this, m_rowid );
}
}
@ -204,7 +205,7 @@ public class GameLock {
{
boolean result = m_isForWrite && 1 == m_lockCount;
if ( !result ) {
DbgUtils.logw( getClass(), "canWrite(): %H, returning false", this );
DbgUtils.logw( TAG, "canWrite(): %H, returning false", this );
}
return result;
}

View file

@ -30,6 +30,7 @@ import android.widget.TextView;
import org.eehouse.android.xw4.loc.LocUtils;
public class GameNamer extends LinearLayout {
private static final String TAG = GameNamer.class.getSimpleName();
private Context m_context;

View file

@ -59,6 +59,7 @@ import java.util.HashSet;
import java.util.Iterator;
public class GameUtils {
private static final String TAG = GameUtils.class.getSimpleName();
public static final String INVITED = "invited";
public static final String INTENT_KEY_ROWID = "rowid";
@ -72,7 +73,7 @@ public class GameUtils {
public static class NoSuchGameException extends RuntimeException {
public NoSuchGameException() {
DbgUtils.logi( getClass(), "NoSuchGameException()");
DbgUtils.logi( TAG, "NoSuchGameException()");
}
}
@ -167,7 +168,7 @@ public class GameUtils {
Utils.cancelNotification( context, (int)rowidIn );
success = true;
} else {
DbgUtils.logw( GameUtils.class, "resetGame: unable to open rowid %d", rowidIn );
DbgUtils.logw( TAG, "resetGame: unable to open rowid %d", rowidIn );
}
return success;
}
@ -224,7 +225,7 @@ public class GameUtils {
try {
lock = new GameLock( rowid, false ).lock( maxMillis );
} catch ( GameLock.GameLockedException gle ) {
DbgUtils.logex( gle );
DbgUtils.logex( TAG, gle );
}
}
@ -268,7 +269,7 @@ public class GameUtils {
lockSrc.unlock();
}
} else {
DbgUtils.logd( GameUtils.class, "dupeGame: unable to open rowid %d",
DbgUtils.logd( TAG, "dupeGame: unable to open rowid %d",
rowidIn );
}
return rowid;
@ -292,7 +293,7 @@ public class GameUtils {
lock.unlock();
success = true;
} else {
DbgUtils.logw( GameUtils.class, "deleteGame: unable to delete rowid %d", rowid );
DbgUtils.logw( TAG, "deleteGame: unable to delete rowid %d", rowid );
success = false;
}
return success;
@ -328,6 +329,11 @@ public class GameUtils {
return LocUtils.getString( context, R.string.game_fmt, count );
}
public static GamePtr loadMakeGame( Context context, GameLock lock )
{
return loadMakeGame( context, new CurGameInfo( context ), lock );
}
public static GamePtr loadMakeGame( Context context, CurGameInfo gi,
TransportProcs tp, GameLock lock )
{
@ -335,7 +341,7 @@ public class GameUtils {
}
public static GamePtr loadMakeGame( Context context, CurGameInfo gi,
GameLock lock )
GameLock lock )
{
return loadMakeGame( context, gi, null, null, lock );
}
@ -355,13 +361,13 @@ public class GameUtils {
GamePtr gamePtr = null;
if ( null == stream ) {
DbgUtils.logw( GameUtils.class, "loadMakeGame: no saved game!");
DbgUtils.logw( TAG, "loadMakeGame: no saved game!");
} else {
XwJNI.gi_from_stream( gi, stream );
String[] dictNames = gi.dictNames();
DictUtils.DictPairs pairs = DictUtils.openDicts( context, dictNames );
if ( pairs.anyMissing( dictNames ) ) {
DbgUtils.logw( GameUtils.class, "loadMakeGame() failing: dicts %s unavailable",
DbgUtils.logw( TAG, "loadMakeGame() failing: dicts %s unavailable",
TextUtils.join( ",", dictNames ) );
} else {
String langName = gi.langName();
@ -443,7 +449,7 @@ public class GameUtils {
long oldest = s_sendTimes[s_sendTimes.length - 1];
long age = now - oldest;
force = RESEND_INTERVAL_SECS < age;
DbgUtils.logd( GameUtils.class, "resendAllIf(): based on last send age of %d sec, doit = %b",
DbgUtils.logd( TAG, "resendAllIf(): based on last send age of %d sec, doit = %b",
age, force );
}
@ -523,7 +529,7 @@ public class GameUtils {
public static long makeNewMultiGame( Context context, NetLaunchInfo nli,
MultiMsgSink sink, UtilCtxt util )
{
DbgUtils.logd( GameUtils.class, "makeNewMultiGame(nli=%s)", nli.toString() );
DbgUtils.logd( TAG, "makeNewMultiGame(nli=%s)", nli.toString() );
CommsAddrRec addr = nli.makeAddrRec( context );
return makeNewMultiGame( context, sink, util, DBUtils.GROUPID_UNSPEC,
@ -853,7 +859,7 @@ public class GameUtils {
}
allHere = 0 == missingSet.size();
} else {
DbgUtils.logw( GameUtils.class, "gameDictsHere: game has no dicts!" );
DbgUtils.logw( TAG, "gameDictsHere: game has no dicts!" );
}
if ( null != missingNames ) {
missingNames[0] =
@ -1054,7 +1060,7 @@ public class GameUtils {
lock.unlock();
} else {
DbgUtils.logw( GameUtils.class, "replaceDicts: unable to open rowid %d", rowid );
DbgUtils.logw( TAG, "replaceDicts: unable to open rowid %d", rowid );
}
return success;
} // replaceDicts
@ -1140,7 +1146,7 @@ public class GameUtils {
do {
rint = Utils.nextRandomInt();
} while ( 0 == rint );
DbgUtils.logi( GameUtils.class, "newGameID()=>%X (%d)", rint, rint );
DbgUtils.logi( TAG, "newGameID()=>%X (%d)", rint, rint );
return rint;
}
@ -1176,7 +1182,7 @@ public class GameUtils {
Utils.postNotification( context, intent, title, msg, (int)rowid );
}
} else {
DbgUtils.logd( GameUtils.class, "postMoveNotification(): posting nothing for lack"
DbgUtils.logd( TAG, "postMoveNotification(): posting nothing for lack"
+ " of brm" );
}
}
@ -1193,22 +1199,33 @@ public class GameUtils {
boolean informNow )
{
GameSummary summary = DBUtils.getSummary( context, lock );
for ( Iterator<CommsConnType> iter = summary.conTypes.iterator();
iter.hasNext(); ) {
switch( iter.next() ) {
case COMMS_CONN_RELAY:
tellRelayDied( context, summary, informNow );
break;
case COMMS_CONN_BT:
BTService.gameDied( context, summary.gameID );
break;
case COMMS_CONN_SMS:
if ( null != summary.remoteDevs ) {
for ( String dev : summary.remoteDevs ) {
SMSService.gameDied( context, summary.gameID, dev );
if ( DeviceRole.SERVER_STANDALONE != summary.serverRole ) {
int gameID = summary.gameID;
GamePtr gamePtr = loadMakeGame( context, lock );
if ( null != gamePtr ) {
CommsAddrRec[] addrs = XwJNI.comms_getAddrs( gamePtr );
for ( CommsAddrRec addr : addrs ) {
CommsConnTypeSet conTypes = addr.conTypes;
for ( CommsConnType typ : conTypes ) {
switch ( typ ) {
case COMMS_CONN_RELAY:
tellRelayDied( context, summary, informNow );
break;
case COMMS_CONN_BT:
BTService.gameDied( context, addr.bt_btAddr, gameID );
break;
case COMMS_CONN_SMS:
SMSService.gameDied( context, gameID, addr.sms_phone );
break;
case COMMS_CONN_P2P:
WiDirService.gameDied( addr.p2p_addr, gameID );
break;
}
}
}
break;
gamePtr.release();
}
}
}
@ -1237,7 +1254,7 @@ public class GameUtils {
fos.close();
result = file;
} catch ( Exception ex ) {
DbgUtils.logex( ex );
DbgUtils.logex( TAG, ex );
}
}
return result;
@ -1283,17 +1300,24 @@ public class GameUtils {
int nSent = XwJNI.comms_resendAll( gamePtr, true,
m_filter, false );
gamePtr.release();
DbgUtils.logd( getClass(), "ResendTask.doInBackground(): sent %d "
DbgUtils.logd( TAG, "ResendTask.doInBackground(): sent %d "
+ "messages for rowid %d", nSent, rowid );
} else {
DbgUtils.logd( getClass(), "ResendTask.doInBackground(): loadMakeGame()"
DbgUtils.logd( TAG, "ResendTask.doInBackground(): loadMakeGame()"
+ " failed for rowid %d", rowid );
}
lock.unlock();
} else {
DbgUtils.logw( ResendTask.class,
"ResendTask.doInBackground: unable to unlock %d",
rowid );
JNIThread jniThread = JNIThread.getRetained( rowid, false );
if ( null != jniThread ) {
jniThread.handle( JNIThread.JNICmd.CMD_RESEND, false,
false, false );
jniThread.release();
} else {
DbgUtils.logw( TAG,
"ResendTask.doInBackground: unable to unlock %d",
rowid );
}
}
}
return null;

View file

@ -74,6 +74,7 @@ public class GamesListDelegate extends ListDelegateBase
DBUtils.DBChangeListener, SelectableItem,
DownloadFinishedListener, DlgDelegate.HasDlgDelegate,
GroupStateListener {
private static final String TAG = GamesListDelegate.class.getSimpleName();
private static final String SAVE_ROWID = "SAVE_ROWID";
@ -94,7 +95,7 @@ public class GamesListDelegate extends ListDelegateBase
private static final String REMATCH_BTADDR_EXTRA = "rm_btaddr";
private static final String REMATCH_PHONE_EXTRA = "rm_phone";
private static final String REMATCH_RELAYID_EXTRA = "rm_relayid";
private static final String REMATCH_P2PADDR_EXTRA = "rm_p2pma";
private static final String ALERT_MSG = "alert_msg";
@ -274,7 +275,7 @@ public class GamesListDelegate extends ListDelegateBase
}
}
if ( -1 == posn ) {
DbgUtils.logd( getClass(), "getGroupPosition: group %d not found", groupID );
DbgUtils.logd( TAG, "getGroupPosition: group %d not found", groupID );
}
return posn;
}
@ -336,7 +337,7 @@ public class GamesListDelegate extends ListDelegateBase
boolean changed = false;
int newID = fieldToID( newField );
if ( -1 == newID ) {
DbgUtils.logd( getClass(), "setField(): unable to match"
DbgUtils.logd( TAG, "setField(): unable to match"
+ " fieldName %s", newField );
} else if ( m_fieldID != newID ) {
m_fieldID = newID;
@ -432,7 +433,7 @@ public class GamesListDelegate extends ListDelegateBase
private ArrayList<Object> removeRange( ArrayList<Object> list,
int start, int len )
{
DbgUtils.logd( getClass(), "removeRange(start=%d, len=%d)", start, len );
DbgUtils.logd( TAG, "removeRange(start=%d, len=%d)", start, len );
ArrayList<Object> result = new ArrayList<Object>(len);
for ( int ii = 0; ii < len; ++ii ) {
result.add( list.remove( start ) );
@ -503,8 +504,9 @@ public class GamesListDelegate extends ListDelegateBase
R.string.game_summary_field_rowid,
R.string.game_summary_field_gameid,
R.string.game_summary_field_npackets,
R.string.title_addrs_pref,
};
int result = -1;
int result = ids[0]; // need a default in case set changes
for ( int id : ids ) {
if ( LocUtils.getString( m_activity, id ).equals( fieldName )){
result = id;
@ -1313,6 +1315,7 @@ public class GamesListDelegate extends ListDelegateBase
m_newGameParams = params;
askDefaultName();
break;
default:
Assert.fail();
}
@ -1338,7 +1341,7 @@ public class GamesListDelegate extends ListDelegateBase
switch ( requestCode ) {
case REQUEST_LANG_GL:
if ( !cancelled ) {
DbgUtils.logd( getClass(), "lang need met" );
DbgUtils.logd( TAG, "lang need met" );
if ( checkWarnNoDict( m_missingDictRowId ) ) {
launchGameIf();
}
@ -1467,7 +1470,7 @@ public class GamesListDelegate extends ListDelegateBase
Assert.assertTrue( m_menuPrepared );
} else {
DbgUtils.logd( getClass(), "onPrepareOptionsMenu: incomplete so bailing" );
DbgUtils.logd( TAG, "onPrepareOptionsMenu: incomplete so bailing" );
}
return m_menuPrepared;
} // onPrepareOptionsMenu
@ -1480,7 +1483,6 @@ public class GamesListDelegate extends ListDelegateBase
String msg;
int itemID = item.getItemId();
boolean handled = true;
boolean changeContent = false;
int groupPos = getSelGroupPos();
long groupID = DBUtils.GROUPID_UNSPEC;
if ( 0 <= groupPos ) {
@ -1558,14 +1560,34 @@ public class GamesListDelegate extends ListDelegateBase
break;
case R.id.games_menu_loaddb:
DBUtils.loadDB( m_activity );
XWPrefs.clearGroupPositions( m_activity );
mkListAdapter();
changeContent = true;
new Perms23.Builder( Perms23.Perm.STORAGE )
.asyncQuery( m_activity, new Perms23.PermCbck() {
@Override
public void onPermissionResult( Map<Perms23.Perm,
Boolean> granted )
{
Assert.assertTrue( granted.containsKey(Perms23.Perm.STORAGE) );
if ( granted.get(Perms23.Perm.STORAGE) ) {
DBUtils.loadDB( m_activity );
XWPrefs.clearGroupPositions( m_activity );
mkListAdapter();
}
}
} );
break;
case R.id.games_menu_storedb:
DBUtils.saveDB( m_activity );
showToast( R.string.db_store_done );
new Perms23.Builder( Perms23.Perm.STORAGE )
.asyncQuery( m_activity, new Perms23.PermCbck() {
@Override
public void onPermissionResult( Map<Perms23.Perm, Boolean> granted )
{
Assert.assertTrue( granted.containsKey( Perms23.Perm.STORAGE ) );
if ( granted.get( Perms23.Perm.STORAGE ) ) {
DBUtils.saveDB( m_activity );
showToast( R.string.db_store_done );
}
}
} );
break;
default:
@ -1573,10 +1595,6 @@ public class GamesListDelegate extends ListDelegateBase
|| handleSelGroupsItem( itemID, getSelGroupIDs() );
}
if ( changeContent ) {
mkListAdapter();
}
return handled;// || super.onOptionsItemSelected( item );
}
@ -1592,7 +1610,7 @@ public class GamesListDelegate extends ListDelegateBase
AdapterView.AdapterContextMenuInfo info
= (AdapterView.AdapterContextMenuInfo)menuInfo;
View targetView = info.targetView;
DbgUtils.logd( getClass(), "onCreateContextMenu(t=%s)",
DbgUtils.logd( TAG, "onCreateContextMenu(t=%s)",
targetView.getClass().getSimpleName() );
if ( targetView instanceof GameListItem ) {
item = (GameListItem)targetView;
@ -1801,7 +1819,7 @@ public class GamesListDelegate extends ListDelegateBase
// DEBUG only
case R.id.games_game_invites:
msg = GameUtils.getSummary( m_activity, selRowIDs[0] )
.conTypes.toString( m_activity );
.conTypes.toString( m_activity, true );
msg = getString( R.string.invites_net_fmt, msg );
SentInvitesInfo info = DBUtils.getInvitesFor( m_activity,
@ -2143,6 +2161,7 @@ public class GamesListDelegate extends ListDelegateBase
String btAddr = intent.getStringExtra( REMATCH_BTADDR_EXTRA );
String phone = intent.getStringExtra( REMATCH_PHONE_EXTRA );
String relayID = intent.getStringExtra( REMATCH_RELAYID_EXTRA );
String p2pMacAddress = intent.getStringExtra( REMATCH_P2PADDR_EXTRA );
String dict = intent.getStringExtra( REMATCH_DICT_EXTRA );
int lang = intent.getIntExtra( REMATCH_LANG_EXTRA, -1 );
String json = intent.getStringExtra( REMATCH_PREFS_EXTRA );
@ -2150,7 +2169,8 @@ public class GamesListDelegate extends ListDelegateBase
CommsConnTypeSet addrs = new CommsConnTypeSet( bits );
long newid;
if ( null == btAddr && null == phone && null == relayID ) {
if ( null == btAddr && null == phone && null == relayID
&& null == p2pMacAddress ) {
newid = GameUtils.dupeGame( m_activity, srcRowID );
if ( DBUtils.ROWID_NOTFOUND != newid ) {
DBUtils.setName( m_activity, newid, gameName );
@ -2160,7 +2180,7 @@ public class GamesListDelegate extends ListDelegateBase
newid = GameUtils.makeNewMultiGame( m_activity, groupID, dict,
lang, json, addrs, gameName );
DBUtils.addRematchInfo( m_activity, newid, btAddr, phone,
relayID );
relayID, p2pMacAddress );
}
launchGame( newid );
}
@ -2373,7 +2393,7 @@ public class GamesListDelegate extends ListDelegateBase
private void launchGame( long rowid, boolean invited )
{
if ( DBUtils.ROWID_NOTFOUND == rowid ) {
DbgUtils.logd( getClass(), "launchGame(): dropping bad rowid" );
DbgUtils.logd( TAG, "launchGame(): dropping bad rowid" );
} else if ( ! m_launchedGames.contains( rowid ) ) {
m_launchedGames.add( rowid );
if ( m_adapter.inExpandedGroup( rowid ) ) {
@ -2408,7 +2428,7 @@ public class GamesListDelegate extends ListDelegateBase
private void doOpenGame( Object[] params )
{
GameSummary summary = (GameSummary)params[1];
long rowid = (Long)params[0];
final long rowid = (Long)params[0];
if ( summary.conTypes.contains( CommsAddrRec.CommsConnType.COMMS_CONN_RELAY )
&& summary.roomName.length() == 0 ) {
@ -2419,7 +2439,7 @@ public class GamesListDelegate extends ListDelegateBase
launchGame( rowid );
}
} catch ( GameLock.GameLockedException gle ) {
DbgUtils.logex( gle );
DbgUtils.logex( TAG, gle );
finish();
}
}
@ -2626,7 +2646,8 @@ public class GamesListDelegate extends ListDelegateBase
CurGameInfo gi,
CommsConnTypeSet addrTypes,
String btAddr, String phone,
String relayID, String newName )
String relayID, String p2pMacAddress,
String newName )
{
Intent intent = null;
intent = makeSelfIntent( context );
@ -2647,6 +2668,9 @@ public class GamesListDelegate extends ListDelegateBase
if ( null != relayID ) {
intent.putExtra( REMATCH_RELAYID_EXTRA, relayID );
}
if ( null != p2pMacAddress ) {
intent.putExtra( REMATCH_P2PADDR_EXTRA, p2pMacAddress );
}
}
return intent;
}

View file

@ -23,6 +23,7 @@ package org.eehouse.android.xw4;
import android.os.Bundle;
public class GamesListFrag extends XWFragment {
private static final String TAG = GamesListFrag.class.getSimpleName();
public GamesListFrag() {}

View file

@ -23,4 +23,3 @@ package org.eehouse.android.xw4;
public interface GroupStateListener {
void onGroupExpandedChanged( Object groupObj, boolean expanded );
}

View file

@ -25,13 +25,54 @@ import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.FrameLayout;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import junit.framework.Assert;
abstract class InviteDelegate extends ListDelegateBase
implements View.OnClickListener,
ViewGroup.OnHierarchyChangeListener {
private static final String TAG = InviteDelegate.class.getSimpleName();
protected interface InviterItem {
}
protected static class TwoStringPair implements InviterItem {
public String str1;
public String str2;
public TwoStringPair( String str1, String str2 ) {
this.str1 = str1; this.str2 = str2;
}
public static TwoStringPair[] make( String[] names, String[] addrs )
{
TwoStringPair[] pairs = new TwoStringPair[names.length];
for ( int ii = 0; ii < pairs.length; ++ii ) {
pairs[ii] = new TwoStringPair( names[ii], addrs[ii] );
}
return pairs;
}
}
// Children implement ...
abstract void onChildAdded( View child, InviterItem item );
abstract void listSelected( InviterItem[] selected, String[] devs );
public static final String DEVS = "DEVS";
public static final String COUNTS = "COUNTS";
@ -40,39 +81,42 @@ abstract class InviteDelegate extends ListDelegateBase
protected int m_nMissing;
protected String m_lastDev;
protected Button m_okButton;
protected Button m_inviteButton;
protected Button m_rescanButton;
protected Button m_clearButton;
private Activity m_activity;
private ListView m_lv;
private View m_ev;
private TextView m_ev;
private boolean m_showAddrs;
private InviteItemsAdapter m_adapter;
protected Map<InviterItem, Integer> m_counts;
protected Set<Integer> m_checked;
private boolean m_setChecked;
// private LinearLayout[] m_items;
public InviteDelegate( Delegator delegator, Bundle savedInstanceState,
int layoutID )
public InviteDelegate( Delegator delegator, Bundle savedInstanceState )
{
super( delegator, savedInstanceState, layoutID, R.menu.empty );
super( delegator, savedInstanceState, R.layout.inviter, R.menu.empty );
m_activity = delegator.getActivity();
Intent intent = getIntent();
m_nMissing = intent.getIntExtra( INTENT_KEY_NMISSING, -1 );
m_lastDev = intent.getStringExtra( INTENT_KEY_LASTDEV );
m_counts = new HashMap<InviterItem, Integer>();
m_checked = new HashSet<Integer>();
}
protected void init( int button_invite, int button_rescan,
int button_clear, int desc_id, String descTxt )
protected void init( String descTxt, int emptyMsgId )
{
m_okButton = (Button)findViewById( button_invite );
m_okButton.setOnClickListener( this );
m_rescanButton = (Button)findViewById( button_rescan );
m_rescanButton.setOnClickListener( this );
m_clearButton = (Button)findViewById( button_clear );
m_clearButton.setOnClickListener( this );
m_inviteButton = (Button)findViewById( R.id.button_invite );
m_inviteButton.setOnClickListener( this );
TextView descView = (TextView)findViewById( desc_id );
TextView descView = (TextView)findViewById( R.id.invite_desc );
descView.setText( descTxt );
m_lv = (ListView)findViewById( android.R.id.list );
m_ev = findViewById( android.R.id.empty );
if ( null != m_lv && null != m_ev ) {
m_ev = (TextView)findViewById( android.R.id.empty );
if ( null != m_lv && null != m_ev && 0 != emptyMsgId ) {
m_ev.setText( getString( emptyMsgId ) );
m_lv.setOnHierarchyChangeListener( this );
showEmptyIfEmpty();
}
@ -80,27 +124,81 @@ abstract class InviteDelegate extends ListDelegateBase
tryEnable();
}
// Subclasses are meant to call this
protected void addButtonBar( int buttonBarId, int[] buttonBarItemIds )
{
FrameLayout container = (FrameLayout)findViewById( R.id.button_bar );
ViewGroup bar = (ViewGroup)inflate( buttonBarId );
container.addView( bar );
View.OnClickListener listener = new View.OnClickListener() {
@Override
public void onClick( View view ) {
onBarButtonClicked( view.getId() );
}
};
for ( int id : buttonBarItemIds ) {
bar.findViewById( id ).setOnClickListener( listener );
}
}
protected void updateListAdapter( InviterItem[] items )
{
updateListAdapter( R.layout.two_strs_item, items );
}
protected void updateListAdapter( int itemId, InviterItem[] items )
{
// m_items = items;
m_adapter = new InviteItemsAdapter( itemId, items );
setListAdapter( m_adapter );
}
protected void onBarButtonClicked( int id )
{
Assert.fail(); // subclass must implement
}
// Subclasses can do something here
protected void addToButtonBar( FrameLayout container ) {}
////////////////////////////////////////
// View.OnClickListener
////////////////////////////////////////
public void onClick( View view )
{
if ( m_okButton == view ) {
if ( m_inviteButton == view ) {
int len = m_checked.size();
String[] devs = new String[len];
InviterItem[] items = getSelItems();
listSelected( items, devs );
int[] counts = new int[len];
for ( int ii = 0; ii < len; ++ii ) {
counts[ii] = m_counts.get( items[ii] );
}
Intent intent = new Intent();
String[][] devs = new String[1][];
int[][] counts = new int[1][];
listSelected( devs, counts );
intent.putExtra( DEVS, devs[0] );
intent.putExtra( COUNTS, counts[0] );
intent.putExtra( DEVS, devs );
intent.putExtra( COUNTS, counts );
setResult( Activity.RESULT_OK, intent );
finish();
} else if ( m_rescanButton == view ) {
scan();
} else if ( m_clearButton == view ) {
clearSelected();
}
}
private InviterItem[] getSelItems()
{
int ii = 0;
InviterItem[] result = new InviterItem[m_checked.size()];
InviterItem[] src = getAdapter().getItems();
for ( int checked : m_checked ) {
result[ii++] = src[checked];
}
return result;
}
////////////////////////////////////////
// ViewGroup.OnHierarchyChangeListener
////////////////////////////////////////
@ -119,8 +217,132 @@ abstract class InviteDelegate extends ListDelegateBase
? View.VISIBLE : View.GONE );
}
abstract void tryEnable() ;
abstract void listSelected( String[][] devsP, int[][] countsP );
abstract void scan();
abstract void clearSelected();
protected void tryEnable()
{
int count = m_checked.size();
m_inviteButton.setEnabled( count > 0 && count <= m_nMissing );
}
final Set<Integer> getChecked() { return m_checked; }
protected void clearChecked() { m_checked.clear(); }
// protected void scan() {}
// callbacks made by InviteItemsAdapter
protected void onItemChecked( int index, boolean checked )
{
DbgUtils.logd( TAG, "onItemChecked(%d, %b)", index, checked );
if ( checked ) {
m_checked.add( index );
} else {
m_checked.remove( index );
}
}
protected InviteItemsAdapter getAdapter()
{
return m_adapter;
}
private Integer[] makeCheckedArray()
{
return m_checked.toArray( new Integer[m_checked.size()] );
}
private class InviteItemsAdapter extends XWListAdapter {
private InviterItem[] m_items;
private int m_itemId;
public InviteItemsAdapter( int itemID, InviterItem[] items )
{
super( null == items? 0 : items.length );
m_itemId = itemID;
m_items = items;
// m_items = new LinearLayout[getCount()];
}
public InviterItem[] getItems() { return m_items; }
// public String[] getAddrs() { return m_devAddrs; }
@Override
public Object getItem( int position ) { return m_items[position]; }
@Override
public View getView( final int position, View convertView,
ViewGroup parent )
{
final InviterItem item = m_items[position];
final LinearLayout layout = (LinearLayout)
inflate( R.layout.inviter_item_frame );
CheckBox box = (CheckBox)layout.findViewById( R.id.inviter_check );
// Give subclass a chance to install and populate its view
FrameLayout frame = (FrameLayout)layout.findViewById( R.id.frame );
View child = inflate( m_itemId );
frame.addView( child );
onChildAdded( child, m_items[position] );
m_counts.put( item, 1 );
if ( XWPrefs.getCanInviteMulti( m_activity ) && 1 < m_nMissing ) {
Spinner spinner = (Spinner)
layout.findViewById(R.id.nperdev_spinner);
ArrayAdapter<String> adapter =
new ArrayAdapter<String>( m_activity, android.R.layout
.simple_spinner_item );
for ( int ii = 1; ii <= m_nMissing; ++ii ) {
String str = getQuantityString( R.plurals.nplayers_fmt, ii, ii );
adapter.add( str );
}
spinner.setAdapter( adapter );
spinner.setVisibility( View.VISIBLE );
spinner.setOnItemSelectedListener( new OnItemSelectedListener() {
public void onItemSelected( AdapterView<?> parent,
View view, int pos,
long id )
{
m_counts.put( item, 1 + pos );
tryEnable();
}
public void onNothingSelected( AdapterView<?> parent ) {}
} );
}
CompoundButton.OnCheckedChangeListener listener =
new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged( CompoundButton buttonView,
boolean isChecked ) {
if ( !isChecked ) {
m_setChecked = false;
}
if ( isChecked ) {
m_checked.add( position );
} else {
m_checked.remove( position );
// // User's now making changes; don't check new views
// m_setChecked = false;
}
onItemChecked( position, isChecked );
tryEnable();
}
};
box.setOnCheckedChangeListener( listener );
if ( m_setChecked || m_checked.contains( position ) ) {
box.setChecked( true );
} else if ( null != m_lastDev && m_lastDev.equals( item ) ) {
m_lastDev = null;
box.setChecked( true );
}
// m_items[position] = layout;
return layout;
}
public String getAddr( CheckBox box ) { return (String)box.getTag(); }
public String getName( CheckBox box ) { return box.getText().toString(); }
}
}

View file

@ -26,6 +26,7 @@ import android.util.AttributeSet;
import org.eehouse.android.xw4.loc.LocUtils;
public class LangListPreference extends XWListPreference {
private static final String TAG = LangListPreference.class.getSimpleName();
private Context m_context;
public LangListPreference( Context context, AttributeSet attrs )

View file

@ -26,6 +26,7 @@ import android.widget.ListAdapter;
import android.widget.ListView;
public class ListDelegateBase extends DelegateBase {
private static final String TAG = ListDelegateBase.class.getSimpleName();
private Activity m_activity;
private Delegator m_delegator;

View file

@ -46,6 +46,7 @@ import java.util.ArrayList;
public class LookupAlert extends LinearLayout
implements View.OnClickListener, Dialog.OnKeyListener,
AdapterView.OnItemClickListener {
private static final String TAG = LookupAlert.class.getSimpleName();
public static final String WORDS = "WORDS";
public static final String LANG = "LANG";
@ -277,7 +278,7 @@ public class LookupAlert extends LinearLayout
private static void lookupWord( Context context, String word, String fmt )
{
if ( false ) {
DbgUtils.logw( LookupAlert.class, "skipping lookupWord(%s)", word );
DbgUtils.logw( TAG, "skipping lookupWord(%s)", word );
} else {
String langCode = s_langCodes[s_lang];
String dict_url = String.format( fmt, langCode, word );
@ -288,7 +289,7 @@ public class LookupAlert extends LinearLayout
try {
context.startActivity( intent );
} catch ( android.content.ActivityNotFoundException anfe ) {
DbgUtils.logex( anfe );
DbgUtils.logex( TAG, anfe );
}
}
} // lookupWord

View file

@ -43,6 +43,7 @@ import java.util.Map;
public class MainActivity extends XWActivity
implements FragmentManager.OnBackStackChangedListener {
private static final String TAG = MainActivity.class.getSimpleName();
private static final int MAX_PANES_LANDSCAPE = 2;
private static final boolean LOG_IDS = true;
@ -122,11 +123,11 @@ public class MainActivity extends XWActivity
boolean isPortrait
= Configuration.ORIENTATION_PORTRAIT == newConfig.orientation;
DbgUtils.logi( getClass(), "onConfigurationChanged(isPortrait=%b)",
DbgUtils.logi( TAG, "onConfigurationChanged(isPortrait=%b)",
isPortrait );
m_isPortrait = isPortrait;
if ( isPortrait != (rect.width() <= rect.height()) ) {
DbgUtils.logd( getClass(), "onConfigurationChanged(): isPortrait:"
DbgUtils.logd( TAG, "onConfigurationChanged(): isPortrait:"
+ " %b; width: %d; height: %d",
isPortrait, rect.width(), rect.height() );
}
@ -184,9 +185,9 @@ public class MainActivity extends XWActivity
break;
}
String name = frag.getClass().getSimpleName();
DbgUtils.logd( getClass(), "popIntoView(): popping %d: %s", top, name );
DbgUtils.logd( TAG, "popIntoView(): popping %d: %s", top, name );
fm.popBackStackImmediate();
DbgUtils.logd( getClass(), "popIntoView(): DONE popping %s",
DbgUtils.logd( TAG, "popIntoView(): DONE popping %s",
name );
}
}
@ -211,14 +212,14 @@ public class MainActivity extends XWActivity
frag.getDelegate().handleNewIntent( intent );
}
} else {
DbgUtils.logd( getClass(), "no fragment for child %s indx %d",
DbgUtils.logd( TAG, "no fragment for child %s indx %d",
child.getClass().getSimpleName(), ii );
}
}
if ( BuildConfig.DEBUG && !handled ) {
// DbgUtils.showf( this, "dropping intent %s", intent.toString() );
DbgUtils.logd( getClass(), "dropping intent %s", intent.toString() );
DbgUtils.logd( TAG, "dropping intent %s", intent.toString() );
// DbgUtils.printStack();
// setIntent( intent ); -- look at handling this in onPostResume()?
m_newIntent = intent;
@ -237,7 +238,7 @@ public class MainActivity extends XWActivity
return handled;
}
protected void dispatchOnActivityResult( RequestCode requestCode,
protected void dispatchOnActivityResult( RequestCode requestCode,
int resultCode, Intent data )
{
XWFragment frag = getTopFragment();
@ -245,7 +246,7 @@ public class MainActivity extends XWActivity
if ( null != frag ) {
frag.onActivityResult( requestCode.ordinal(), resultCode, data );
} else {
DbgUtils.logd( getClass(), "dispatchOnActivityResult(): can't dispatch %s",
DbgUtils.logd( TAG, "dispatchOnActivityResult(): can't dispatch %s",
requestCode.toString() );
}
}
@ -337,14 +338,14 @@ public class MainActivity extends XWActivity
{
// make sure the right-most are visible
int fragCount = getSupportFragmentManager().getBackStackEntryCount();
DbgUtils.logi( getClass(), "onBackStackChanged(); count now %d", fragCount );
DbgUtils.logi( TAG, "onBackStackChanged(); count now %d", fragCount );
if ( 0 == fragCount ) {
finish();
} else {
if ( fragCount == m_root.getChildCount() - 1 ) {
View child = m_root.getChildAt( fragCount );
if ( LOG_IDS ) {
DbgUtils.logi( getClass(), "onBackStackChanged(): removing view with id %x",
DbgUtils.logi( TAG, "onBackStackChanged(): removing view with id %x",
child.getId() );
}
m_root.removeView( child );
@ -355,7 +356,7 @@ public class MainActivity extends XWActivity
if ( null != m_pendingResult ) {
Fragment target = m_pendingResult.getTarget();
if ( null != target ) {
DbgUtils.logi( getClass(),"onBackStackChanged(): calling onActivityResult()" );
DbgUtils.logi( TAG,"onBackStackChanged(): calling onActivityResult()" );
target.onActivityResult( m_pendingResult.m_request,
m_pendingResult.m_result,
m_pendingResult.m_data );
@ -404,7 +405,7 @@ public class MainActivity extends XWActivity
int id = frame.getId();
Fragment frag = fm.findFragmentById( id );
if ( null == frag ) {
DbgUtils.logw( getClass(),"tellOrienationChanged: NO FRAG at %d, id=%d", ii, id );
DbgUtils.logw( TAG,"tellOrienationChanged: NO FRAG at %d, id=%d", ii, id );
} else if ( frag instanceof XWFragment ) {
((XWFragment)frag).getDelegate().orientationChanged();
}
@ -432,7 +433,7 @@ public class MainActivity extends XWActivity
for ( int ii = 0; ii < nPanes; ++ii ) {
View child = m_root.getChildAt( ii );
boolean visible = ii >= nPanes - m_maxPanes;
DbgUtils.logi( getClass(), "pane %d: visible=%b", ii, visible );
DbgUtils.logi( TAG, "pane %d: visible=%b", ii, visible );
child.setVisibility( visible ? View.VISIBLE : View.GONE );
setMenuVisibility( child, visible );
if ( visible ) {
@ -448,7 +449,7 @@ public class MainActivity extends XWActivity
if ( null != frag ) {
frag.setTitle();
} else {
DbgUtils.logd( getClass(), "trySetTitle(): no fragment for id %x",
DbgUtils.logd( TAG, "trySetTitle(): no fragment for id %x",
view.getId() );
}
}
@ -498,7 +499,7 @@ public class MainActivity extends XWActivity
FragmentManager fm = getSupportFragmentManager();
int fragCount = fm.getBackStackEntryCount();
int containerCount = m_root.getChildCount();
DbgUtils.logi( getClass(), "fragCount: %d; containerCount: %d", fragCount, containerCount );
DbgUtils.logi( TAG, "fragCount: %d; containerCount: %d", fragCount, containerCount );
// Assert.assertTrue( fragCount == containerCount );
// Replace IF we're adding something of the same class at right OR if
@ -528,7 +529,7 @@ public class MainActivity extends XWActivity
int id = --m_nextID;
cont.setId( id );
if ( LOG_IDS ) {
DbgUtils.logi( getClass(), "assigning id %x to view with name %s", id, newName );
DbgUtils.logi( TAG, "assigning id %x to view with name %s", id, newName );
}
m_root.addView( cont, replace ? containerCount - 1 : containerCount );
@ -539,7 +540,7 @@ public class MainActivity extends XWActivity
setMenuVisibility( child, false );
DbgUtils.logi( getClass(), "hiding %dth container", indx );
DbgUtils.logi( TAG, "hiding %dth container", indx );
}
fm.beginTransaction()

View file

@ -28,6 +28,7 @@ import java.util.HashSet;
import java.util.Iterator;
public class MountEventReceiver extends BroadcastReceiver {
private static final String TAG = MountEventReceiver.class.getSimpleName();
public interface SDCardNotifiee {
void cardMounted( boolean nowMounted );
@ -38,7 +39,7 @@ public class MountEventReceiver extends BroadcastReceiver {
@Override
public void onReceive( Context context, Intent intent )
{
DbgUtils.logi( getClass(), "onReceive(%s)", intent.getAction() );
DbgUtils.logi( TAG, "onReceive(%s)", intent.getAction() );
synchronized( s_procs ) {
do {
if ( s_procs.isEmpty() ) {

View file

@ -32,6 +32,7 @@ import java.util.HashSet;
import java.util.Set;
public class MultiMsgSink implements TransportProcs {
private static final String TAG = MultiMsgSink.class.getSimpleName();
private long m_rowid;
private Context m_context;
// Use set to count so message sent over both BT and Relay is counted only
@ -72,6 +73,12 @@ public class MultiMsgSink implements TransportProcs {
return SMSService.sendPacket( m_context, addr.sms_phone, gameID, buf );
}
public int sendViaP2P( byte[] buf, int gameID, CommsAddrRec addr )
{
return WiDirService
.sendPacket( m_context, addr.p2p_addr, gameID, buf );
}
public int numSent()
{
return m_sentSet.size();
@ -95,14 +102,17 @@ public class MultiMsgSink implements TransportProcs {
case COMMS_CONN_SMS:
nSent = sendViaSMS( buf, gameID, addr );
break;
case COMMS_CONN_P2P:
nSent = sendViaP2P( buf, gameID, addr );
break;
default:
Assert.fail();
break;
}
DbgUtils.logi( getClass(), "transportSend(): sent %d via %s",
DbgUtils.logi( TAG, "transportSend(): sent %d via %s",
nSent, typ.toString() );
if ( 0 < nSent ) {
DbgUtils.logd( getClass(), "transportSend: adding %s", msgNo );
DbgUtils.logd( TAG, "transportSend: adding %s", msgNo );
m_sentSet.add( msgNo );
}
@ -129,7 +139,7 @@ public class MultiMsgSink implements TransportProcs {
relayID, buf );
boolean success = buf.length == nSent;
if ( success ) {
DbgUtils.logd( getClass(), "relayNoConnProc: adding %s", msgNo );
DbgUtils.logd( TAG, "relayNoConnProc: adding %s", msgNo );
m_sentSet.add( msgNo );
}
return success;

View file

@ -31,6 +31,7 @@ import junit.framework.Assert;
import org.eehouse.android.xw4.loc.LocUtils;
public class MultiService {
private static final String TAG = MultiService.class.getSimpleName();
public static final String FORCECHANNEL = "FC";
public static final String LANG = "LANG";
@ -45,17 +46,20 @@ public class MultiService {
private static final String OWNER = "OWNER";
public static final String BT_NAME = "BT_NAME";
public static final String BT_ADDRESS = "BT_ADDRESS";
public static final String P2P_MAC_ADDRESS = "P2P_MAC_ADDRESS";
private static final String NLI_DATA = "nli";
public enum DictFetchOwner { _NONE,
OWNER_SMS,
OWNER_RELAY,
OWNER_BT,
OWNER_P2P,
};
private static final String ACTION_FETCH_DICT = "_afd";
private static final String FOR_MISSING_DICT = "_fmd";
// Shouldn't this be a Set?
private MultiEventListener m_li;
// these do not currently pass between devices so they can change.
@ -102,7 +106,7 @@ public class MultiService {
}
}
public void sendResult( MultiEvent event, Object ... args )
public void postEvent( MultiEvent event, Object ... args )
{
synchronized( this ) {
if ( null != m_li ) {
@ -189,7 +193,7 @@ public class MultiService {
if ( downloaded ) {
int ordinal = intent.getIntExtra( OWNER, -1 );
if ( -1 == ordinal ) {
DbgUtils.logw( DBUtils.class, "unexpected OWNER" );
DbgUtils.logw( TAG, "unexpected OWNER" );
} else {
DictFetchOwner owner = DictFetchOwner.values()[ordinal];
switch ( owner ) {

View file

@ -38,6 +38,7 @@ import java.util.Date;
import java.util.Iterator;
public class NagTurnReceiver extends BroadcastReceiver {
private static final String TAG = NagTurnReceiver.class.getSimpleName();
private static final long INTERVAL_MILLIS = 1000 * 30; // every half minute for now
private static final long[] NAG_INTERVAL_SECONDS = {// 2*60, // two minutes (for testing)
@ -177,7 +178,7 @@ public class NagTurnReceiver extends BroadcastReceiver {
al.add(value);
}
} catch ( Exception ex ) {
DbgUtils.logex(ex);
DbgUtils.logex( TAG, ex );
}
}
if ( 0 < al.size() ) {

View file

@ -41,6 +41,7 @@ import java.io.InputStream;
import java.util.Iterator;
public class NetLaunchInfo {
private static final String TAG = NetLaunchInfo.class.getSimpleName();
private static final String ADDRS_KEY = "ad";
private static final String PHONE_KEY = "phn";
private static final String GSM_KEY = "gsm";
@ -56,6 +57,7 @@ public class NetLaunchInfo {
private static final String GID_KEY = "gid";
private static final String FORCECHANNEL_KEY = "fc";
private static final String NAME_KEY = "nm";
private static final String P2P_MAC_KEY = "p2";
protected String gameName;
protected String dict;
@ -66,6 +68,7 @@ public class NetLaunchInfo {
protected String room; // relay
protected String btName;
protected String btAddress;
protected String p2pMacAddress;
// SMS
protected String phone;
protected boolean isGSM;
@ -102,6 +105,7 @@ public class NetLaunchInfo {
gameID = bundle.getInt( MultiService.GAMEID );
btName = bundle.getString( MultiService.BT_NAME );
btAddress = bundle.getString( MultiService.BT_ADDRESS );
p2pMacAddress = bundle.getString( MultiService.P2P_MAC_ADDRESS );
m_addrs = new CommsConnTypeSet( bundle.getInt( ADDRS_KEY ) );
}
@ -173,6 +177,10 @@ public class NetLaunchInfo {
}
doAdd = !hasAddrs && null != phone;
break;
case COMMS_CONN_P2P:
p2pMacAddress = data.getQueryParameter( P2P_MAC_KEY );
doAdd = !hasAddrs && null != p2pMacAddress;
break;
default:
doAdd = false;
Assert.fail();
@ -199,7 +207,7 @@ public class NetLaunchInfo {
}
calcValid();
} catch ( Exception e ) {
DbgUtils.loge( getClass(), "unable to parse \"%s\"", data.toString() );
DbgUtils.loge( TAG, "unable to parse \"%s\"", data.toString() );
}
}
calcValid();
@ -245,6 +253,9 @@ public class NetLaunchInfo {
case COMMS_CONN_SMS:
addSMSInfo( summary.getContext() );
break;
case COMMS_CONN_P2P:
addP2PInfo( summary.getContext() );
break;
default:
Assert.fail();
break;
@ -277,7 +288,7 @@ public class NetLaunchInfo {
int result = gameID;
if ( 0 == result ) {
Assert.assertNotNull( inviteID );
DbgUtils.logi( getClass(), "gameID(): looking at inviteID: %s", inviteID );
DbgUtils.logi( TAG, "gameID(): looking at inviteID: %s", inviteID );
result = Integer.parseInt( inviteID, 16 );
// DbgUtils.logf( "gameID(): gameID -1 so substituting %d", result );
gameID = result;
@ -298,6 +309,7 @@ public class NetLaunchInfo {
bundle.putInt( MultiService.GAMEID, gameID() );
bundle.putString( MultiService.BT_NAME, btName );
bundle.putString( MultiService.BT_ADDRESS, btAddress );
bundle.putString( MultiService.P2P_MAC_ADDRESS, p2pMacAddress );
bundle.putInt( MultiService.FORCECHANNEL, forceChannel );
int flags = m_addrs.toInt();
@ -332,10 +344,13 @@ public class NetLaunchInfo {
.put( GSM_KEY, isGSM )
.put( OSVERS_KEY, osVers );
}
if ( m_addrs.contains( CommsConnType.COMMS_CONN_P2P ) ) {
obj.put( P2P_MAC_KEY, p2pMacAddress );
}
result = obj.toString();
} catch ( org.json.JSONException jse ) {
DbgUtils.logex( jse );
DbgUtils.logex( TAG, jse );
}
// DbgUtils.logf( "makeLaunchJSON() => %s", result );
return result;
@ -358,6 +373,9 @@ public class NetLaunchInfo {
case COMMS_CONN_SMS:
result.setSMSParams( phone );
break;
case COMMS_CONN_P2P:
result.setP2PParams( p2pMacAddress );
break;
default:
Assert.fail();
break;
@ -409,6 +427,10 @@ public class NetLaunchInfo {
osVers = json.optInt( OSVERS_KEY, 0 );
doAdd = !hasAddrs && !phone.isEmpty();
break;
case COMMS_CONN_P2P:
p2pMacAddress = json.optString( P2P_MAC_KEY );
doAdd = !hasAddrs && null != p2pMacAddress;
break;
default:
doAdd = false;
Assert.fail();
@ -419,7 +441,7 @@ public class NetLaunchInfo {
}
} catch ( JSONException jse ) {
DbgUtils.logex( jse );
DbgUtils.logex( TAG, jse );
}
removeUnsupported( supported );
@ -466,10 +488,13 @@ public class NetLaunchInfo {
appendInt( ub, GSM_KEY, (isGSM? 1 : 0) );
appendInt( ub, OSVERS_KEY, osVers );
}
if ( m_addrs.contains( CommsConnType.COMMS_CONN_P2P ) ) {
ub.appendQueryParameter( P2P_MAC_KEY, p2pMacAddress );
}
Uri result = ub.build();
if ( BuildConfig.DEBUG ) { // Test...
DbgUtils.logi( getClass(), "testing %s...", result.toString() );
DbgUtils.logi( TAG, "testing %s...", result.toString() );
NetLaunchInfo instance = new NetLaunchInfo( context, result );
Assert.assertTrue( instance.isValid() );
}
@ -492,7 +517,7 @@ public class NetLaunchInfo {
btAddress = got[1];
m_addrs.add( CommsConnType.COMMS_CONN_BT );
} else {
DbgUtils.logw( getClass(), "addBTInfo(): no BT info available" );
DbgUtils.logw( TAG, "addBTInfo(): no BT info available" );
}
}
@ -507,6 +532,12 @@ public class NetLaunchInfo {
m_addrs.add( CommsConnType.COMMS_CONN_SMS );
}
public void addP2PInfo( Context context )
{
p2pMacAddress = WiDirService.getMyMacAddress( context );
m_addrs.add( CommsConnType.COMMS_CONN_P2P );
}
public boolean isValid()
{
// DbgUtils.logf( "NetLaunchInfo(%s).isValid() => %b", toString(), m_valid );

View file

@ -38,10 +38,11 @@ import java.util.Iterator;
import java.util.concurrent.atomic.AtomicBoolean;
public class NetStateCache {
private static final String TAG = NetStateCache.class.getSimpleName();
private static final long WAIT_STABLE_MILLIS = 2 * 1000;
public interface StateChangedIf {
public void netAvail( boolean nowAvailable );
public void onNetAvail( boolean nowAvailable );
}
private static AtomicBoolean s_haveReceiver = new AtomicBoolean( false );
@ -83,7 +84,7 @@ public class NetStateCache {
boolean netAvail = getIsConnected( context );
if ( netAvail ) {
DbgUtils.logi( NetStateCache.class, "netAvail(): second-guessing successful!!!" );
DbgUtils.logi( TAG, "netAvail(): second-guessing successful!!!" );
s_netAvail = true;
if ( null != s_receiver ) {
s_receiver.notifyStateChanged( context );
@ -93,7 +94,7 @@ public class NetStateCache {
}
boolean result = s_netAvail || s_onSDKSim;
DbgUtils.logd( NetStateCache.class, "netAvail() => %b", result );
DbgUtils.logd( TAG, "netAvail() => %b", result );
return result;
}
@ -123,7 +124,7 @@ public class NetStateCache {
if ( null != ni && ni.isConnectedOrConnecting() ) {
result = true;
}
DbgUtils.logi( NetStateCache.class, "NetStateCache.getConnected() => %b", result );
DbgUtils.logi( TAG, "NetStateCache.getConnected() => %b", result );
return result;
}
@ -164,7 +165,7 @@ public class NetStateCache {
boolean connectedReal = activeNetwork != null &&
activeNetwork.isConnectedOrConnecting();
if ( connectedReal != connectedCached ) {
DbgUtils.logw( NetStateCache.class, "connected: cached: %b; actual: %b",
DbgUtils.logw( TAG, "connected: cached: %b; actual: %b",
connectedCached, connectedReal );
}
}
@ -193,7 +194,7 @@ public class NetStateCache {
NetworkInfo ni = (NetworkInfo)intent.
getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
NetworkInfo.State state = ni.getState();
DbgUtils.logd( getClass(), "onReceive(state=%s)", state.toString() );
DbgUtils.logd( TAG, "onReceive(state=%s)", state.toString() );
boolean netAvail;
switch ( state ) {
@ -214,13 +215,13 @@ public class NetStateCache {
s_netAvail = netAvail; // keep current in case we're asked
notifyStateChanged( context );
} else {
DbgUtils.logd( getClass(), "onReceive: no change; "
DbgUtils.logd( TAG, "onReceive: no change; "
+ "doing nothing; s_netAvail=%b", s_netAvail );
}
}
}
public void notifyStateChanged( final Context context )
private void notifyStateChanged( final Context context )
{
// We want to wait for WAIT_STABLE_MILLIS of inactivity
// before informing listeners. So each time there's a
@ -239,13 +240,13 @@ public class NetStateCache {
Assert.assertTrue( mLastStateSent != s_netAvail );
mLastStateSent = s_netAvail;
DbgUtils.logi( getClass(), "notifyStateChanged(%b)",
DbgUtils.logi( TAG, "notifyStateChanged(%b)",
s_netAvail );
synchronized( s_ifs ) {
Iterator<StateChangedIf> iter = s_ifs.iterator();
while ( iter.hasNext() ) {
iter.next().netAvail( s_netAvail );
iter.next().onNetAvail( s_netAvail );
}
}

View file

@ -47,6 +47,7 @@ import java.util.Map;
import javax.net.SocketFactory;
public class NetUtils {
private static final String TAG = NetUtils.class.getSimpleName();
public static final String k_PARAMS = "params";
public static final byte PROTOCOL_VERSION = 0;
@ -71,9 +72,9 @@ public class NetUtils {
socket.setSoTimeout( timeoutMillis );
} catch ( java.net.UnknownHostException uhe ) {
DbgUtils.logex( uhe );
DbgUtils.logex( TAG, uhe );
} catch( java.io.IOException ioe ) {
DbgUtils.logex( ioe );
DbgUtils.logex( TAG, ioe );
}
return socket;
}
@ -128,7 +129,7 @@ public class NetUtils {
DBUtils.clearObits( m_context, m_obits );
}
} catch ( java.io.IOException ioe ) {
DbgUtils.logex( ioe );
DbgUtils.logex( TAG, ioe );
}
}
}
@ -192,13 +193,13 @@ public class NetUtils {
}
if ( 0 != dis.available() ) {
msgs = null;
DbgUtils.loge( NetUtils.class, "format error: bytes left over in stream" );
DbgUtils.loge( TAG, "format error: bytes left over in stream" );
}
socket.close();
}
} catch( Exception npe ) {
DbgUtils.logex( npe );
DbgUtils.logex( TAG, npe );
}
return msgs;
} // queryRelay
@ -224,10 +225,10 @@ public class NetUtils {
result = (HttpURLConnection)new URL(url).openConnection();
} catch ( java.net.MalformedURLException mue ) {
Assert.assertNull( result );
DbgUtils.logex( mue );
DbgUtils.logex( TAG, mue );
} catch ( java.io.IOException ioe ) {
Assert.assertNull( result );
DbgUtils.logex( ioe );
DbgUtils.logex( TAG, ioe );
}
return result;
}
@ -272,12 +273,12 @@ public class NetUtils {
}
result = new String( bas.toByteArray() );
} else {
DbgUtils.logw( NetUtils.class, "runConn: responseCode: %d", responseCode );
DbgUtils.logw( TAG, "runConn: responseCode: %d", responseCode );
}
} catch ( java.net.ProtocolException pe ) {
DbgUtils.logex( pe );
DbgUtils.logex( TAG, pe );
} catch( java.io.IOException ioe ) {
DbgUtils.logex( ioe );
DbgUtils.logex( TAG, ioe );
}
}
@ -298,7 +299,7 @@ public class NetUtils {
}
result = TextUtils.join( "&", pairs );
} catch ( java.io.UnsupportedEncodingException uee ) {
DbgUtils.logex( uee );
DbgUtils.logex( TAG, uee );
}
return result;

View file

@ -28,6 +28,7 @@ import android.widget.ScrollView;
import android.widget.TextView;
public class NotAgainView extends ScrollView {
private static final String TAG = NotAgainView.class.getSimpleName();
public NotAgainView( Context cx, AttributeSet as ) {
super( cx, as );

View file

@ -25,13 +25,14 @@ import android.content.Context;
import android.content.Intent;
public class OnBootReceiver extends BroadcastReceiver {
private static final String TAG = OnBootReceiver.class.getSimpleName();
@Override
public void onReceive( Context context, Intent intent )
{
if ( null != intent && null != intent.getAction()
&& intent.getAction().equals( Intent.ACTION_BOOT_COMPLETED ) ) {
DbgUtils.logd( getClass(), "got ACTION_BOOT_COMPLETED" );
DbgUtils.logd( TAG, "got ACTION_BOOT_COMPLETED" );
startTimers( context );
}
}

Some files were not shown because too many files have changed in this diff Show more