From 5cf9472642cf5d734f6f46cd1713e05b32fb9288 Mon Sep 17 00:00:00 2001 From: eehouse Date: Wed, 17 Feb 2010 15:10:10 +0000 Subject: [PATCH] translate error codes into alerts or toasts where appropriate. --- .../android/XWords4/res/values/strings.xml | 5 +++ .../eehouse/android/xw4/CommsTransport.java | 37 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml index 811fd81ef..ff43e8db9 100644 --- a/xwords4/android/XWords4/res/values/strings.xml +++ b/xwords4/android/XWords4/res/values/strings.xml @@ -216,6 +216,11 @@ All players are here. Connection status. + Connection error + You are providing more players than the host expects. + No host has registered a room by that name. + Another host has already registered a room using that name. Rename yours or retry later. + The relay has lost contact with another device in this game. key_color_tiles diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/CommsTransport.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/CommsTransport.java index 6c2e31afe..28228f953 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/CommsTransport.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/CommsTransport.java @@ -313,5 +313,42 @@ public class CommsTransport extends Thread implements TransportProcs { public void relayErrorProc( XWRELAY_ERROR relayErr ) { Utils.logf( "relayErrorProc called; got " + relayErr.toString() ); + + int strID = 0; + int how = TOAST; + + switch ( relayErr ) { + case TOO_MANY: + strID = R.string.msg_too_many; + how = DIALOG; + break; + case NO_ROOM: + strID = R.string.msg_no_room; + how = DIALOG; + break; + case DUP_ROOM: + strID = R.string.msg_dup_room; + how = DIALOG; + break; + case LOST_OTHER: + case OTHER_DISCON: + strID = R.string.msg_lost_other; + break; + + case OLDFLAGS: + case BADPROTO: + case RELAYBUSY: + case SHUTDOWN: + case TIMEOUT: + case HEART_YOU: + case HEART_OTHER: + break; + } + + if ( 0 != strID ) { + String str = m_context.getString( strID ); + Message.obtain( m_handler, how, R.string.relay_alert, + 0, str ).sendToTarget(); + } } }