mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-08 05:24:39 +01:00
handle mqtt invites same as others
Invitations over MQTT were handled by different code that always opened the new game on top of any other open one. Use instead existing code that puts up a notification instead where appropriate.
This commit is contained in:
parent
3fbb2bbd7c
commit
1019271c94
6 changed files with 28 additions and 31 deletions
|
@ -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 );
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 )
|
||||
|
|
Loading…
Reference in a new issue