mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-09 05:24:44 +01:00
Merge branch 'android_branch' into android_translate
This commit is contained in:
commit
f22868e5f4
19 changed files with 153 additions and 32 deletions
|
@ -67,7 +67,7 @@ android {
|
||||||
flavorDimensions "variant"//, "abi"
|
flavorDimensions "variant"//, "abi"
|
||||||
productFlavors {
|
productFlavors {
|
||||||
all {
|
all {
|
||||||
buildConfigField "String", "DB_NAME", "\"xwdb\"";
|
buildConfigField "String", "DB_NAME", "\"xwdb\""
|
||||||
buildConfigField "String", "BUILD_INFO_NAME", "\"${BUILD_INFO_NAME}\""
|
buildConfigField "String", "BUILD_INFO_NAME", "\"${BUILD_INFO_NAME}\""
|
||||||
buildConfigField "boolean", "IS_TAGGED_BUILD", "${CURTAG}" == '' ? "false" : "true"
|
buildConfigField "boolean", "IS_TAGGED_BUILD", "${CURTAG}" == '' ? "false" : "true"
|
||||||
resValue "string", "invite_prefix", "/and/"
|
resValue "string", "invite_prefix", "/and/"
|
||||||
|
@ -75,6 +75,7 @@ android {
|
||||||
buildConfigField "boolean", "REPORT_LOCKS", "false"
|
buildConfigField "boolean", "REPORT_LOCKS", "false"
|
||||||
buildConfigField "boolean", "LOG_LIFECYLE", "false"
|
buildConfigField "boolean", "LOG_LIFECYLE", "false"
|
||||||
buildConfigField "boolean", "MOVE_VIA_NFC", "false"
|
buildConfigField "boolean", "MOVE_VIA_NFC", "false"
|
||||||
|
buildConfigField "boolean", "ATTACH_SUPPORTED", "false"
|
||||||
}
|
}
|
||||||
|
|
||||||
xw4NoSMS {
|
xw4NoSMS {
|
||||||
|
@ -256,7 +257,7 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
SUPPORT_LIB_VERSION = '27.1.1'
|
SUPPORT_LIB_VERSION = '28.0.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -269,10 +270,10 @@ dependencies {
|
||||||
// 2.6.8 is probably as far forward as I can go without upping my
|
// 2.6.8 is probably as far forward as I can go without upping my
|
||||||
// min-supported SDK version
|
// min-supported SDK version
|
||||||
xw4dImplementation('com.crashlytics.sdk.android:crashlytics:2.6.3@aar') { // rm-for-fdroid
|
xw4dImplementation('com.crashlytics.sdk.android:crashlytics:2.6.3@aar') { // rm-for-fdroid
|
||||||
transitive = true; // rm-for-fdroid
|
transitive = true // rm-for-fdroid
|
||||||
} // rm-for-fdroid
|
} // rm-for-fdroid
|
||||||
xw4dNoSMSImplementation('com.crashlytics.sdk.android:crashlytics:2.6.3@aar') { // rm-for-fdroid
|
xw4dNoSMSImplementation('com.crashlytics.sdk.android:crashlytics:2.6.3@aar') { // rm-for-fdroid
|
||||||
transitive = true; // rm-for-fdroid
|
transitive = true // rm-for-fdroid
|
||||||
} // rm-for-fdroid
|
} // rm-for-fdroid
|
||||||
|
|
||||||
implementation 'com.google.firebase:firebase-messaging:17.3.4' // rm-for-fdroid
|
implementation 'com.google.firebase:firebase-messaging:17.3.4' // rm-for-fdroid
|
||||||
|
@ -319,7 +320,7 @@ task mkXml(type: Exec) {
|
||||||
}
|
}
|
||||||
|
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
ArrayList<String> cleanCmdLst = new ArrayList<>(["rm", "-rf"]);
|
ArrayList<String> cleanCmdLst = new ArrayList<>(["rm", "-rf"])
|
||||||
android.applicationVariants.all { variant ->
|
android.applicationVariants.all { variant ->
|
||||||
// print "variant: " + variant.name + "\n"
|
// print "variant: " + variant.name + "\n"
|
||||||
String BUILD = variant.getBuildType().getName()
|
String BUILD = variant.getBuildType().getName()
|
||||||
|
|
|
@ -37,6 +37,7 @@ public class Assert {
|
||||||
Log.e( TAG, "firing assert!" );
|
Log.e( TAG, "firing assert!" );
|
||||||
DbgUtils.printStack( TAG );
|
DbgUtils.printStack( TAG );
|
||||||
assert false;
|
assert false;
|
||||||
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -677,21 +677,27 @@ public class BTService extends XWJIService {
|
||||||
if ( BOGUS_MARSHMALLOW_ADDR.equals( btAddr ) ) {
|
if ( BOGUS_MARSHMALLOW_ADDR.equals( btAddr ) ) {
|
||||||
String btName = addr.bt_hostName;
|
String btName = addr.bt_hostName;
|
||||||
if ( null == s_namesToAddrs ) {
|
if ( null == s_namesToAddrs ) {
|
||||||
s_namesToAddrs = new HashMap<String, String>();
|
s_namesToAddrs = new HashMap<>();
|
||||||
}
|
}
|
||||||
if ( ! s_namesToAddrs.containsKey( btName ) ) {
|
|
||||||
|
if ( s_namesToAddrs.containsKey( btName ) ) {
|
||||||
|
btAddr = s_namesToAddrs.get( btName );
|
||||||
|
} else {
|
||||||
|
btAddr = null;
|
||||||
|
}
|
||||||
|
if ( null == btAddr ) {
|
||||||
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
if ( null != adapter ) {
|
if ( null != adapter ) {
|
||||||
Set<BluetoothDevice> devs = adapter.getBondedDevices();
|
for ( BluetoothDevice dev : adapter.getBondedDevices() ) {
|
||||||
Iterator<BluetoothDevice> iter = devs.iterator();
|
Log.d( TAG, "%s => %s", dev.getName(), dev.getAddress() );
|
||||||
while ( iter.hasNext() ) {
|
if ( btName.equals( dev.getName() ) ) {
|
||||||
BluetoothDevice dev = iter.next();
|
btAddr = dev.getAddress();
|
||||||
s_namesToAddrs.put( dev.getName(), dev.getAddress() );
|
s_namesToAddrs.put( btName, btAddr );
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
btAddr = s_namesToAddrs.get( btName );
|
|
||||||
}
|
}
|
||||||
return btAddr;
|
return btAddr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1490,6 +1490,13 @@ public class BoardDelegate extends DelegateBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tpmCountChanged( int newCount )
|
||||||
|
{
|
||||||
|
Log.d( TAG, "tpmCountChanged(%d)", newCount );
|
||||||
|
ConnStatusHandler.updateMoveCount( m_activity, newCount );
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
// DwnldActivity.DownloadFinishedListener interface
|
// DwnldActivity.DownloadFinishedListener interface
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
|
|
|
@ -416,9 +416,15 @@ public class CommsTransport implements TransportProcs,
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int sendForAddr( Context context, CommsAddrRec addr,
|
@Override
|
||||||
CommsConnType conType, long rowID,
|
public void countChanged( int newCount )
|
||||||
int gameID, byte[] buf, String msgID )
|
{
|
||||||
|
m_tpHandler.tpmCountChanged( newCount );
|
||||||
|
}
|
||||||
|
|
||||||
|
private int sendForAddr( Context context, CommsAddrRec addr,
|
||||||
|
CommsConnType conType, long rowID,
|
||||||
|
int gameID, byte[] buf, String msgID )
|
||||||
{
|
{
|
||||||
int nSent = -1;
|
int nSent = -1;
|
||||||
switch ( conType ) {
|
switch ( conType ) {
|
||||||
|
@ -437,6 +443,8 @@ public class CommsTransport implements TransportProcs,
|
||||||
nSent = WiDirService
|
nSent = WiDirService
|
||||||
.sendPacket( context, addr.p2p_addr, gameID, buf );
|
.sendPacket( context, addr.p2p_addr, gameID, buf );
|
||||||
break;
|
break;
|
||||||
|
case COMMS_CONN_NFC:
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -23,6 +23,7 @@ package org.eehouse.android.xw4;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
@ -61,8 +62,14 @@ public class ConnStatusHandler {
|
||||||
private static Rect s_rect;
|
private static Rect s_rect;
|
||||||
private static boolean s_downOnMe = false;
|
private static boolean s_downOnMe = false;
|
||||||
private static ConnStatusCBacks s_cbacks;
|
private static ConnStatusCBacks s_cbacks;
|
||||||
private static Paint s_fillPaint = new Paint( Paint.ANTI_ALIAS_FLAG );
|
private static Paint s_fillPaint;
|
||||||
|
static {
|
||||||
|
s_fillPaint = new Paint( Paint.ANTI_ALIAS_FLAG );
|
||||||
|
s_fillPaint.setTextAlign( Paint.Align.CENTER );
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean[] s_showSuccesses = { false, false };
|
private static boolean[] s_showSuccesses = { false, false };
|
||||||
|
private static int s_moveCount = 0;
|
||||||
|
|
||||||
private static class SuccessRecord implements java.io.Serializable {
|
private static class SuccessRecord implements java.io.Serializable {
|
||||||
public long lastSuccess;
|
public long lastSuccess;
|
||||||
|
@ -122,6 +129,7 @@ public class ConnStatusHandler {
|
||||||
public static void setRect( int left, int top, int right, int bottom )
|
public static void setRect( int left, int top, int right, int bottom )
|
||||||
{
|
{
|
||||||
s_rect = new Rect( left, top, right, bottom );
|
s_rect = new Rect( left, top, right, bottom );
|
||||||
|
s_fillPaint.setTextSize( s_rect.height()/2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearRect()
|
public static void clearRect()
|
||||||
|
@ -229,6 +237,10 @@ public class ConnStatusHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( BuildConfig.DEBUG ) {
|
||||||
|
sb.append("\n").append( XwJNI.comms_getStats( gamePtr ) );
|
||||||
|
}
|
||||||
msg = sb.toString();
|
msg = sb.toString();
|
||||||
}
|
}
|
||||||
return msg;
|
return msg;
|
||||||
|
@ -330,6 +342,14 @@ public class ConnStatusHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void updateMoveCount( Context context, int newCount )
|
||||||
|
{
|
||||||
|
if ( BuildConfig.DEBUG ) {
|
||||||
|
s_moveCount = newCount;
|
||||||
|
invalidateParent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void updateStatus( Context context, ConnStatusCBacks cbacks,
|
public static void updateStatus( Context context, ConnStatusCBacks cbacks,
|
||||||
CommsConnType connType, boolean success )
|
CommsConnType connType, boolean success )
|
||||||
{
|
{
|
||||||
|
@ -436,6 +456,14 @@ public class ConnStatusHandler {
|
||||||
|| 1 >= Math.abs(scratchR.width()
|
|| 1 >= Math.abs(scratchR.width()
|
||||||
- scratchR.height()) );
|
- scratchR.height()) );
|
||||||
drawIn( canvas, res, R.drawable.multigame__gen, scratchR );
|
drawIn( canvas, res, R.drawable.multigame__gen, scratchR );
|
||||||
|
|
||||||
|
if ( BuildConfig.DEBUG && 0 < s_moveCount ) {
|
||||||
|
String str = String.format( "%d", s_moveCount );
|
||||||
|
s_fillPaint.setColor( Color.BLACK );
|
||||||
|
canvas.drawText( str, s_rect.left + (s_rect.width() / 2),
|
||||||
|
s_rect.top + (s_rect.height()*2/3),
|
||||||
|
s_fillPaint );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -622,6 +650,9 @@ public class ConnStatusHandler {
|
||||||
case COMMS_CONN_P2P:
|
case COMMS_CONN_P2P:
|
||||||
result = WiDirService.connecting();
|
result = WiDirService.connecting();
|
||||||
break;
|
break;
|
||||||
|
case COMMS_CONN_NFC:
|
||||||
|
result = NFCUtils.nfcAvail( context )[1];
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Log.w( TAG, "connTypeEnabled: %s not handled", connType.toString() );
|
Log.w( TAG, "connTypeEnabled: %s not handled", connType.toString() );
|
||||||
break;
|
break;
|
||||||
|
@ -649,10 +680,7 @@ public class ConnStatusHandler {
|
||||||
result = String.format( "DevID: %d; host: %s; latest FCM: %s",
|
result = String.format( "DevID: %d; host: %s; latest FCM: %s",
|
||||||
DevID.getRelayDevIDInt(context),
|
DevID.getRelayDevIDInt(context),
|
||||||
XWPrefs.getDefaultRelayHost(context),
|
XWPrefs.getDefaultRelayHost(context),
|
||||||
fcmMsg )
|
fcmMsg );
|
||||||
+ "\n"
|
|
||||||
+ XwJNI.comms_getStats( gamePtr );
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case COMMS_CONN_P2P:
|
case COMMS_CONN_P2P:
|
||||||
result = WiDirService.formatNetStateInfo();
|
result = WiDirService.formatNetStateInfo();
|
||||||
|
|
|
@ -730,7 +730,7 @@ public class GameUtils {
|
||||||
intent.putExtra( Intent.EXTRA_TEXT, Html.fromHtml(message) );
|
intent.putExtra( Intent.EXTRA_TEXT, Html.fromHtml(message) );
|
||||||
|
|
||||||
File attach = null;
|
File attach = null;
|
||||||
File tmpdir = XWApp.ATTACH_SUPPORTED ?
|
File tmpdir = BuildConfig.ATTACH_SUPPORTED ?
|
||||||
DictUtils.getDownloadDir( activity ) : null;
|
DictUtils.getDownloadDir( activity ) : null;
|
||||||
if ( null != tmpdir ) { // no attachment
|
if ( null != tmpdir ) { // no attachment
|
||||||
attach = makeJsonFor( tmpdir, nli );
|
attach = makeJsonFor( tmpdir, nli );
|
||||||
|
@ -1321,7 +1321,7 @@ public class GameUtils {
|
||||||
private static File makeJsonFor( File dir, NetLaunchInfo nli )
|
private static File makeJsonFor( File dir, NetLaunchInfo nli )
|
||||||
{
|
{
|
||||||
File result = null;
|
File result = null;
|
||||||
if ( XWApp.ATTACH_SUPPORTED ) {
|
if ( BuildConfig.ATTACH_SUPPORTED ) {
|
||||||
byte[] data = nli.makeLaunchJSON().getBytes();
|
byte[] data = nli.makeLaunchJSON().getBytes();
|
||||||
|
|
||||||
File file = new File( dir, String.format("invite_%d", nli.gameID() ));
|
File file = new File( dir, String.format("invite_%d", nli.gameID() ));
|
||||||
|
|
|
@ -56,24 +56,24 @@ public class MultiMsgSink implements TransportProcs {
|
||||||
|
|
||||||
// These will be overridden by e.g. BTService which for sendViaBluetooth()
|
// These will be overridden by e.g. BTService which for sendViaBluetooth()
|
||||||
// can just insert a message into its queue
|
// can just insert a message into its queue
|
||||||
public int sendViaRelay( byte[] buf, String msgID, int gameID )
|
int sendViaRelay( byte[] buf, String msgID, int gameID )
|
||||||
{
|
{
|
||||||
Assert.assertTrue( BuildConfig.UDP_ENABLED );
|
Assert.assertTrue( BuildConfig.UDP_ENABLED );
|
||||||
return RelayService.sendPacket( m_context, getRowID(), buf, msgID );
|
return RelayService.sendPacket( m_context, getRowID(), buf, msgID );
|
||||||
}
|
}
|
||||||
|
|
||||||
public int sendViaBluetooth( byte[] buf, String msgID, int gameID,
|
int sendViaBluetooth( byte[] buf, String msgID, int gameID,
|
||||||
CommsAddrRec addr )
|
CommsAddrRec addr )
|
||||||
{
|
{
|
||||||
return BTService.sendPacket( m_context, buf, msgID, addr, gameID );
|
return BTService.sendPacket( m_context, buf, msgID, addr, gameID );
|
||||||
}
|
}
|
||||||
|
|
||||||
public int sendViaSMS( byte[] buf, String msgID, int gameID, CommsAddrRec addr )
|
int sendViaSMS( byte[] buf, String msgID, int gameID, CommsAddrRec addr )
|
||||||
{
|
{
|
||||||
return NBSProto.sendPacket( m_context, addr.sms_phone, gameID, buf, msgID );
|
return NBSProto.sendPacket( m_context, addr.sms_phone, gameID, buf, msgID );
|
||||||
}
|
}
|
||||||
|
|
||||||
public int sendViaP2P( byte[] buf, int gameID, CommsAddrRec addr )
|
int sendViaP2P( byte[] buf, int gameID, CommsAddrRec addr )
|
||||||
{
|
{
|
||||||
return WiDirService
|
return WiDirService
|
||||||
.sendPacket( m_context, addr.p2p_addr, gameID, buf );
|
.sendPacket( m_context, addr.p2p_addr, gameID, buf );
|
||||||
|
@ -106,6 +106,9 @@ public class MultiMsgSink implements TransportProcs {
|
||||||
case COMMS_CONN_P2P:
|
case COMMS_CONN_P2P:
|
||||||
nSent = sendViaP2P( buf, gameID, addr );
|
nSent = sendViaP2P( buf, gameID, addr );
|
||||||
break;
|
break;
|
||||||
|
case COMMS_CONN_NFC:
|
||||||
|
Log.d( TAG, "transportSend(): got for NFC" );
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
break;
|
break;
|
||||||
|
@ -133,6 +136,12 @@ public class MultiMsgSink implements TransportProcs {
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void countChanged( int newCount )
|
||||||
|
{
|
||||||
|
Log.d( TAG, "countChanged(new=%d); dropping", newCount );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean relayNoConnProc( byte[] buf, String msgNo, String relayID )
|
public boolean relayNoConnProc( byte[] buf, String msgNo, String relayID )
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,7 +40,6 @@ import java.util.List;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
|
||||||
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
||||||
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnTypeSet;
|
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnTypeSet;
|
||||||
import org.eehouse.android.xw4.jni.CommsAddrRec;
|
import org.eehouse.android.xw4.jni.CommsAddrRec;
|
||||||
|
@ -155,7 +154,7 @@ public class NetLaunchInfo implements Serializable {
|
||||||
String nliData = dis.readUTF();
|
String nliData = dis.readUTF();
|
||||||
nli = NetLaunchInfo.makeFrom( context, nliData );
|
nli = NetLaunchInfo.makeFrom( context, nliData );
|
||||||
} catch ( java.io.IOException ex ) {
|
} catch ( java.io.IOException ex ) {
|
||||||
Assert.assertFalse( BuildConfig.DEBUG );
|
Log.d( TAG, "not an nli" );
|
||||||
}
|
}
|
||||||
return nli;
|
return nli;
|
||||||
}
|
}
|
||||||
|
@ -294,6 +293,8 @@ public class NetLaunchInfo implements Serializable {
|
||||||
case COMMS_CONN_P2P:
|
case COMMS_CONN_P2P:
|
||||||
addP2PInfo( context );
|
addP2PInfo( context );
|
||||||
break;
|
break;
|
||||||
|
case COMMS_CONN_NFC:
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
break;
|
break;
|
||||||
|
@ -448,6 +449,8 @@ public class NetLaunchInfo implements Serializable {
|
||||||
case COMMS_CONN_P2P:
|
case COMMS_CONN_P2P:
|
||||||
result.setP2PParams( p2pMacAddress );
|
result.setP2PParams( p2pMacAddress );
|
||||||
break;
|
break;
|
||||||
|
case COMMS_CONN_NFC:
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
break;
|
break;
|
||||||
|
@ -503,6 +506,9 @@ public class NetLaunchInfo implements Serializable {
|
||||||
p2pMacAddress = json.optString( P2P_MAC_KEY );
|
p2pMacAddress = json.optString( P2P_MAC_KEY );
|
||||||
doAdd = !hasAddrs && null != p2pMacAddress;
|
doAdd = !hasAddrs && null != p2pMacAddress;
|
||||||
break;
|
break;
|
||||||
|
case COMMS_CONN_NFC:
|
||||||
|
doAdd = NFCUtils.nfcAvail( context )[0];
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
doAdd = false;
|
doAdd = false;
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
|
|
|
@ -270,7 +270,7 @@ public class Utils {
|
||||||
though the docs say that param's ignored.
|
though the docs say that param's ignored.
|
||||||
*/
|
*/
|
||||||
PendingIntent pi = null == intent ? null
|
PendingIntent pi = null == intent ? null
|
||||||
: PendingIntent.getActivity( context, Utils.nextRandomInt(), intent,
|
: PendingIntent.getActivity( context, nextRandomInt(), intent,
|
||||||
PendingIntent.FLAG_ONE_SHOT );
|
PendingIntent.FLAG_ONE_SHOT );
|
||||||
|
|
||||||
int defaults = Notification.FLAG_AUTO_CANCEL;
|
int defaults = Notification.FLAG_AUTO_CANCEL;
|
||||||
|
|
|
@ -46,7 +46,6 @@ public class XWApp extends Application
|
||||||
private static final String TAG = XWApp.class.getSimpleName();
|
private static final String TAG = XWApp.class.getSimpleName();
|
||||||
|
|
||||||
public static final boolean BTSUPPORTED = true;
|
public static final boolean BTSUPPORTED = true;
|
||||||
public static final boolean ATTACH_SUPPORTED = false;
|
|
||||||
public static final boolean DEBUG_EXP_TIMERS = false;
|
public static final boolean DEBUG_EXP_TIMERS = false;
|
||||||
public static final boolean LOCUTILS_ENABLED = false;
|
public static final boolean LOCUTILS_ENABLED = false;
|
||||||
public static final boolean CONTEXT_MENUS_ENABLED = true;
|
public static final boolean CONTEXT_MENUS_ENABLED = true;
|
||||||
|
|
|
@ -403,6 +403,8 @@ public class CommsAddrRec {
|
||||||
case COMMS_CONN_P2P:
|
case COMMS_CONN_P2P:
|
||||||
p2p_addr = WiDirService.getMyMacAddress( context );
|
p2p_addr = WiDirService.getMyMacAddress( context );
|
||||||
break;
|
break;
|
||||||
|
case COMMS_CONN_NFC:
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,8 @@ public interface TransportProcs {
|
||||||
|
|
||||||
void relayConnd( String room, int devOrder, boolean allHere, int nMissing );
|
void relayConnd( String room, int devOrder, boolean allHere, int nMissing );
|
||||||
|
|
||||||
|
void countChanged( int newCount );
|
||||||
|
|
||||||
public static enum XWRELAY_ERROR { NONE
|
public static enum XWRELAY_ERROR { NONE
|
||||||
,OLDFLAGS
|
,OLDFLAGS
|
||||||
,BADPROTO
|
,BADPROTO
|
||||||
|
@ -66,5 +68,6 @@ public interface TransportProcs {
|
||||||
public void tpmRelayConnd( String room, int devOrder, boolean allHere,
|
public void tpmRelayConnd( String room, int devOrder, boolean allHere,
|
||||||
int nMissing );
|
int nMissing );
|
||||||
public void tpmRelayErrorProc( XWRELAY_ERROR relayErr );
|
public void tpmRelayErrorProc( XWRELAY_ERROR relayErr );
|
||||||
|
public void tpmCountChanged( int newCount );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,6 +145,19 @@ and_xport_sendNoConn( const XP_U8* buf, XP_U16 len, const XP_UCHAR* msgNo,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
and_xport_countChanged( void* closure, XP_U16 count )
|
||||||
|
{
|
||||||
|
XP_LOGF( "%s(count=%d)", __func__, count );
|
||||||
|
AndTransportProcs* aprocs = (AndTransportProcs*)closure;
|
||||||
|
if ( NULL != aprocs && NULL != aprocs->jxport ) {
|
||||||
|
JNIEnv* env = ENVFORME( aprocs->ti );
|
||||||
|
const char* sig = "(I)V";
|
||||||
|
jmethodID mid = getMethodID( env, aprocs->jxport, "countChanged", sig );
|
||||||
|
(*env)->CallVoidMethod( env, aprocs->jxport, mid, count );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
and_xport_relayError( void* closure, XWREASON relayErr )
|
and_xport_relayError( void* closure, XWREASON relayErr )
|
||||||
{
|
{
|
||||||
|
@ -185,6 +198,7 @@ makeXportProcs( MPFORMAL EnvThreadInfo* ti, jobject jxport )
|
||||||
aprocs->tp.rconnd = and_xport_relayConnd;
|
aprocs->tp.rconnd = and_xport_relayConnd;
|
||||||
aprocs->tp.rerror = and_xport_relayError;
|
aprocs->tp.rerror = and_xport_relayError;
|
||||||
aprocs->tp.sendNoConn = and_xport_sendNoConn;
|
aprocs->tp.sendNoConn = and_xport_sendNoConn;
|
||||||
|
aprocs->tp.countChanged = and_xport_countChanged;
|
||||||
aprocs->tp.closure = aprocs;
|
aprocs->tp.closure = aprocs;
|
||||||
|
|
||||||
return (TransportProcs*)aprocs;
|
return (TransportProcs*)aprocs;
|
||||||
|
|
|
@ -203,6 +203,7 @@ static void freeElem( const CommsCtxt* comms, MsgQueueElem* elem );
|
||||||
|
|
||||||
static XP_U16 countAddrRecs( const CommsCtxt* comms );
|
static XP_U16 countAddrRecs( const CommsCtxt* comms );
|
||||||
static void sendConnect( CommsCtxt* comms, XP_Bool breakExisting );
|
static void sendConnect( CommsCtxt* comms, XP_Bool breakExisting );
|
||||||
|
static void notifyQueueChanged( const CommsCtxt* comms );
|
||||||
#if 0 < COMMS_VERSION
|
#if 0 < COMMS_VERSION
|
||||||
static XP_U16 makeFlags( const CommsCtxt* comms );
|
static XP_U16 makeFlags( const CommsCtxt* comms );
|
||||||
#endif
|
#endif
|
||||||
|
@ -750,6 +751,8 @@ comms_makeFromStream( MPFORMAL XWStreamCtxt* stream, XW_UtilCtxt* util,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
notifyQueueChanged( comms );
|
||||||
|
|
||||||
return comms;
|
return comms;
|
||||||
} /* comms_makeFromStream */
|
} /* comms_makeFromStream */
|
||||||
|
|
||||||
|
@ -1244,6 +1247,13 @@ comms_send( CommsCtxt* comms, XWStreamCtxt* stream )
|
||||||
return result;
|
return result;
|
||||||
} /* comms_send */
|
} /* comms_send */
|
||||||
|
|
||||||
|
static void
|
||||||
|
notifyQueueChanged( const CommsCtxt* comms )
|
||||||
|
{
|
||||||
|
XP_U16 count = comms->queueLen;
|
||||||
|
(*comms->procs.countChanged)( comms->procs.closure, count );
|
||||||
|
}
|
||||||
|
|
||||||
/* Add new message to the end of the list. The list needs to be kept in order
|
/* Add new message to the end of the list. The list needs to be kept in order
|
||||||
* by ascending msgIDs within each channel since if there's a resend that's
|
* by ascending msgIDs within each channel since if there's a resend that's
|
||||||
* the order in which they need to be sent.
|
* the order in which they need to be sent.
|
||||||
|
@ -1272,6 +1282,7 @@ addToQueue( CommsCtxt* comms, MsgQueueElem* newElem )
|
||||||
|
|
||||||
if ( newElem == asAdded ) {
|
if ( newElem == asAdded ) {
|
||||||
++comms->queueLen;
|
++comms->queueLen;
|
||||||
|
notifyQueueChanged( comms );
|
||||||
}
|
}
|
||||||
XP_ASSERT( comms->queueLen <= 128 ); /* reasonable limit in testing */
|
XP_ASSERT( comms->queueLen <= 128 ); /* reasonable limit in testing */
|
||||||
return asAdded;
|
return asAdded;
|
||||||
|
@ -1388,6 +1399,7 @@ removeFromQueue( CommsCtxt* comms, XP_PlayerAddr channelNo, MsgID msgID )
|
||||||
elem = asAdded; /* for non-assert case */
|
elem = asAdded; /* for non-assert case */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
notifyQueueChanged( comms );
|
||||||
}
|
}
|
||||||
|
|
||||||
XP_LOGF( "%s: queueLen now %d", __func__, comms->queueLen );
|
XP_LOGF( "%s: queueLen now %d", __func__, comms->queueLen );
|
||||||
|
|
|
@ -147,6 +147,8 @@ typedef void (*RelayRequestJoinProc)( void* closure, const XP_UCHAR* devID,
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef void (*MsgCountChange)( void* closure, XP_U16 msgCount );
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
COMMS_XPORT_FLAGS_NONE = 0
|
COMMS_XPORT_FLAGS_NONE = 0
|
||||||
,COMMS_XPORT_FLAGS_HASNOCONN = 1
|
,COMMS_XPORT_FLAGS_HASNOCONN = 1
|
||||||
|
@ -174,6 +176,7 @@ typedef struct _TransportProcs {
|
||||||
# ifdef RELAY_VIA_HTTP
|
# ifdef RELAY_VIA_HTTP
|
||||||
RelayRequestJoinProc requestJoin;
|
RelayRequestJoinProc requestJoin;
|
||||||
# endif
|
# endif
|
||||||
|
MsgCountChange countChanged;
|
||||||
#endif
|
#endif
|
||||||
void* closure;
|
void* closure;
|
||||||
} TransportProcs;
|
} TransportProcs;
|
||||||
|
|
|
@ -1872,6 +1872,12 @@ smsMsgReceivedCurses( void* closure, const CommsAddrRec* from,
|
||||||
/* } */
|
/* } */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
curses_countChanged( void* XP_UNUSED(closure), XP_U16 newCount )
|
||||||
|
{
|
||||||
|
XP_LOGF( "%s(newCount=%d)", __func__, newCount );
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cursesmain( XP_Bool isServer, LaunchParams* params )
|
cursesmain( XP_Bool isServer, LaunchParams* params )
|
||||||
{
|
{
|
||||||
|
@ -1965,6 +1971,7 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
|
||||||
#ifdef RELAY_VIA_HTTP
|
#ifdef RELAY_VIA_HTTP
|
||||||
.requestJoin = relay_requestJoin_curses,
|
.requestJoin = relay_requestJoin_curses,
|
||||||
#endif
|
#endif
|
||||||
|
.countChanged = curses_countChanged,
|
||||||
|
|
||||||
# ifdef COMMS_XPORT_FLAGSPROC
|
# ifdef COMMS_XPORT_FLAGSPROC
|
||||||
.getFlags = curses_getFlags,
|
.getFlags = curses_getFlags,
|
||||||
|
|
|
@ -484,6 +484,15 @@ gtk_getFlags( void* closure )
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void
|
||||||
|
countChanged_gtk( void* closure, XP_U16 newCount )
|
||||||
|
{
|
||||||
|
GtkGameGlobals* globals = (GtkGameGlobals*)closure;
|
||||||
|
gchar buf[128];
|
||||||
|
snprintf( buf, VSIZE(buf), "pending count: %d", newCount );
|
||||||
|
gtk_label_set_text( GTK_LABEL(globals->countLabel), buf );
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setTransportProcs( TransportProcs* procs, GtkGameGlobals* globals )
|
setTransportProcs( TransportProcs* procs, GtkGameGlobals* globals )
|
||||||
{
|
{
|
||||||
|
@ -503,6 +512,7 @@ setTransportProcs( TransportProcs* procs, GtkGameGlobals* globals )
|
||||||
# ifdef RELAY_VIA_HTTP
|
# ifdef RELAY_VIA_HTTP
|
||||||
procs->requestJoin = relay_requestJoin_gtk;
|
procs->requestJoin = relay_requestJoin_gtk;
|
||||||
# endif
|
# endif
|
||||||
|
procs->countChanged = countChanged_gtk;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2815,6 +2825,10 @@ initGlobals( GtkGameGlobals* globals, LaunchParams* params, CurGameInfo* gi )
|
||||||
|
|
||||||
gtk_box_pack_start( GTK_BOX(vbox), hbox/* drawing_area */, TRUE, TRUE, 0);
|
gtk_box_pack_start( GTK_BOX(vbox), hbox/* drawing_area */, TRUE, TRUE, 0);
|
||||||
|
|
||||||
|
GtkWidget* label = globals->countLabel = gtk_label_new( "" );
|
||||||
|
gtk_box_pack_start( GTK_BOX(vbox), label, TRUE, TRUE, 0);
|
||||||
|
gtk_widget_show( label );
|
||||||
|
|
||||||
id = g_signal_connect( drawing_area, "configure-event",
|
id = g_signal_connect( drawing_area, "configure-event",
|
||||||
G_CALLBACK(configure_event), globals );
|
G_CALLBACK(configure_event), globals );
|
||||||
XP_ASSERT( id > 0 );
|
XP_ASSERT( id > 0 );
|
||||||
|
|
|
@ -117,6 +117,7 @@ typedef struct GtkGameGlobals {
|
||||||
#ifdef XWFEATURE_CHAT
|
#ifdef XWFEATURE_CHAT
|
||||||
GtkWidget* chat_button;
|
GtkWidget* chat_button;
|
||||||
#endif
|
#endif
|
||||||
|
GtkWidget* countLabel;
|
||||||
|
|
||||||
EngineCtxt* engine;
|
EngineCtxt* engine;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue