From 1d52a9afea0b7494e9704bc4918d56bc9fb2b985 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 10 Aug 2013 23:24:46 -0700 Subject: [PATCH] add reset button to ConnStatusHandler on-click dialog that calls to stubbed-out function in RelayService --- .../android/XWords4/res/values/strings.xml | 2 ++ .../eehouse/android/xw4/BoardActivity.java | 32 +++++++++++-------- .../org/eehouse/android/xw4/RelayService.java | 5 +++ 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml index 4e5adf768..9524db792 100644 --- a/xwords4/android/XWords4/res/values/strings.xml +++ b/xwords4/android/XWords4/res/values/strings.xml @@ -2161,6 +2161,8 @@ just ended. --> Rematch + Reconnect + Square rack tiles Even if they can be taller diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java index f713391f4..5160fcebb 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java @@ -51,6 +51,7 @@ import android.content.res.Configuration; import android.content.pm.ActivityInfo; import org.eehouse.android.xw4.jni.*; +import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType; import org.eehouse.android.xw4.jni.JNIThread.*; import org.eehouse.android.xw4.jni.CurGameInfo.DeviceRole; @@ -77,6 +78,7 @@ public class BoardActivity extends XWActivity private static final int DLG_USEDICT = DLG_OKONLY + 12; private static final int DLG_GETDICT = DLG_OKONLY + 13; private static final int GAME_OVER = DLG_OKONLY + 14; + private static final int DLG_CONNSTAT = DLG_OKONLY + 15; private static final int CHAT_REQUEST = 1; private static final int BT_INVITE_RESULT = 2; @@ -136,8 +138,7 @@ public class BoardActivity extends XWActivity private int m_dlgTitle; private String m_dlgTitleStr; private String[] m_texts; - private CommsAddrRec.CommsConnType m_connType = - CommsAddrRec.CommsConnType.COMMS_CONN_NONE; + private CommsConnType m_connType = CommsConnType.COMMS_CONN_NONE; private String[] m_missingDevs; private String m_curTiles; private boolean m_canUndoTiles; @@ -276,6 +277,7 @@ public class BoardActivity extends XWActivity case DLG_BADWORDS: case DLG_RETRY: case GAME_OVER: + case DLG_CONNSTAT: ab = new AlertDialog.Builder( this ) .setTitle( m_dlgTitle ) .setMessage( m_dlgBytes ) @@ -296,6 +298,15 @@ public class BoardActivity extends XWActivity } }; ab.setNegativeButton( R.string.button_rematch, lstnr ); + } else if ( DLG_CONNSTAT == id && + CommsConnType.COMMS_CONN_RELAY == m_connType ) { + lstnr = new DialogInterface.OnClickListener() { + public void onClick( DialogInterface dlg, + int whichButton ) { + RelayService.reset( BoardActivity.this ); + } + }; + ab.setNegativeButton( R.string.button_reconnect, lstnr ); } dialog = ab.create(); Utils.setRemoveOnDismiss( this, dialog, id ); @@ -974,15 +985,9 @@ public class BoardActivity extends XWActivity switch( event ) { case MESSAGE_ACCEPTED: case MESSAGE_REFUSED: - // if ( null != m_jniThread ) { - // boolean accepted = - // MultiService.MultiEvent.MESSAGE_ACCEPTED == event; - // m_jniThread.handle( JNICmd.CMD_DRAW_BT_STATUS, accepted ); - // } ConnStatusHandler. - updateStatusIn(this, this, - CommsAddrRec.CommsConnType.COMMS_CONN_BT, - MultiService.MultiEvent.MESSAGE_ACCEPTED == event); + updateStatusIn( this, this, CommsConnType.COMMS_CONN_BT, + MultiService.MultiEvent.MESSAGE_ACCEPTED == event); break; case MESSAGE_NOGAME: int gameID = (Integer)args[0]; @@ -1140,7 +1145,9 @@ public class BoardActivity extends XWActivity final String msg = ConnStatusHandler.getStatusText( this, m_connType ); post( new Runnable() { public void run() { - showOKOnlyDialog( msg ); + m_dlgBytes = msg; + m_dlgTitle = R.string.info_title; + showDialog( DLG_CONNSTAT ); } } ); } @@ -1566,8 +1573,7 @@ public class BoardActivity extends XWActivity } // userError @Override - public void informMissing( boolean isServer, - CommsAddrRec.CommsConnType connType, + public void informMissing( boolean isServer, CommsConnType connType, final int nMissingPlayers ) { m_connType = connType; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayService.java index b3e86a4cc..db576a6bc 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayService.java @@ -114,6 +114,11 @@ public class RelayService extends XWService { context.startService( intent ); } + public static void reset( Context context ) + { + DbgUtils.logf( "RelayService.reset() called" ); + } + public static int sendPacket( Context context, long rowid, byte[] msg ) { Intent intent = getIntentTo( context, SEND )