diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTUtils.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTUtils.java index ecb7939ef..d7019eda9 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTUtils.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTUtils.java @@ -1376,14 +1376,6 @@ public class BTUtils { mReturnAddr = addr; } - @Override - void postNotification( String device, int gameID, long rowid ) - { - Context context = XWApp.getContext(); - String body = LocUtils.getString( context, R.string.new_game_body ); - GameUtils.postInvitedNotification( context, gameID, body, rowid ); - } - private void receiveMessage( long rowid, MultiMsgSink sink, byte[] msg ) { Log.d( TAG, "receiveMessage(rowid=%d, len=%d)", rowid, msg.length ); diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MQTTUtils.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MQTTUtils.java index 428d723a0..d25cd9064 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MQTTUtils.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MQTTUtils.java @@ -610,24 +610,28 @@ public class MQTTUtils extends Thread implements IMqttActionListener, MqttCallba } } + public static void makeOrNotify( Context context, NetLaunchInfo nli ) + { + new MQTTServiceHelper( context ).handleInvitation( nli ); + } + private static class MQTTServiceHelper extends XWServiceHelper { private CommsAddrRec mReturnAddr; - private Context mContext; + + MQTTServiceHelper( Context context ) + { + super( context ); + } MQTTServiceHelper( Context context, CommsAddrRec from ) { - super( context ); - mContext = context; + this( context ); mReturnAddr = from; } - @Override - void postNotification( String device, int gameID, long rowid ) + private void handleInvitation( NetLaunchInfo nli ) { - Assert.failDbg(); - // Context context = getContext(); - // String body = LocUtils.getString( mContext, R.string.new_relay_body ); - // GameUtils.postInvitedNotification( mContext, gameID, body, rowid ); + handleInvitation( nli, null, MultiService.DictFetchOwner.OWNER_MQTT ); } private void receiveMessage( long rowid, MultiMsgSink sink, byte[] msg ) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MultiService.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MultiService.java index 42f87c7f2..79208b3db 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MultiService.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MultiService.java @@ -59,6 +59,7 @@ public class MultiService { OWNER_RELAY, OWNER_BT, OWNER_P2P, + OWNER_MQTT, }; private static final String ACTION_FETCH_DICT = "_afd"; @@ -213,8 +214,11 @@ public class MultiService { break; case OWNER_RELAY: case OWNER_BT: + case OWNER_MQTT: GamesListDelegate.onGameDictDownload( context, intent ); break; + default: + Assert.failDbg(); } } } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayService.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayService.java index c865cde74..bfbc3637b 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayService.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayService.java @@ -1843,11 +1843,9 @@ public class RelayService extends XWJIService } private class RelayServiceHelper extends XWServiceHelper { - - private Service mService; - RelayServiceHelper( Service service ) { - super( service ); - mService = service; + RelayServiceHelper( Context context ) + { + super( context ); } @Override @@ -1855,12 +1853,5 @@ public class RelayService extends XWJIService { return new RelayMsgSink().setRowID( rowid ); } - - @Override - void postNotification( String device, int gameID, long rowid ) - { - String body = LocUtils.getString( mService, R.string.new_game_body ); - GameUtils.postInvitedNotification( mService, gameID, body, rowid ); - } } } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWServiceHelper.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWServiceHelper.java index 42a9bf6da..bb065594b 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWServiceHelper.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWServiceHelper.java @@ -32,6 +32,7 @@ import org.eehouse.android.xw4.jni.JNIThread; import org.eehouse.android.xw4.jni.UtilCtxt; import org.eehouse.android.xw4.jni.UtilCtxtImpl; import org.eehouse.android.xw4.jni.XwJNI.GamePtr; +import org.eehouse.android.xw4.loc.LocUtils; import java.util.HashMap; import java.util.Map; @@ -55,7 +56,12 @@ abstract class XWServiceHelper { return new MultiMsgSink( getContext(), rowid ); } - abstract void postNotification( String device, int gameID, long rowid ); + void postNotification( String device, int gameID, long rowid ) + { + Context context = getContext(); + String body = LocUtils.getString( context, R.string.new_game_body ); + GameUtils.postInvitedNotification( context, gameID, body, rowid ); + } protected ReceiveResult receiveMessage( int gameID, MultiMsgSink sink, byte[] msg, diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/DUtilCtxt.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/DUtilCtxt.java index 83fc3c770..e3efe99f2 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/DUtilCtxt.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/DUtilCtxt.java @@ -344,7 +344,7 @@ public class DUtilCtxt { public void onInviteReceived( NetLaunchInfo nli ) { Log.d( TAG, "onInviteReceived(%s)", nli ); - GamesListDelegate.postReceivedInvite( m_context, nli.asByteArray() ); + MQTTUtils.makeOrNotify( m_context, nli ); } public void onMessageReceived( int gameID, CommsAddrRec from, byte[] msg )