mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
add relay status icon
This commit is contained in:
parent
e73c6d1234
commit
04e454f922
7 changed files with 60 additions and 0 deletions
BIN
xwords4/android/XWords4/res/drawable/netarrow_allconn.png
Normal file
BIN
xwords4/android/XWords4/res/drawable/netarrow_allconn.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 172 B |
BIN
xwords4/android/XWords4/res/drawable/netarrow_someconn.png
Normal file
BIN
xwords4/android/XWords4/res/drawable/netarrow_someconn.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 179 B |
BIN
xwords4/android/XWords4/res/drawable/netarrow_unconn.png
Normal file
BIN
xwords4/android/XWords4/res/drawable/netarrow_unconn.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 178 B |
|
@ -248,6 +248,21 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
}
|
||||
}
|
||||
|
||||
public void doIconDraw( int resID, final Rect rect )
|
||||
{
|
||||
synchronized( this ) {
|
||||
if ( null != m_canvas ) {
|
||||
if ( 0 == resID ) {
|
||||
clearToBack( rect );
|
||||
} else {
|
||||
Drawable icon = getResources().getDrawable( resID );
|
||||
icon.setBounds( rect );
|
||||
icon.draw( m_canvas );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void prefsChanged()
|
||||
{
|
||||
synchronized( this ) {
|
||||
|
|
|
@ -294,6 +294,11 @@ public class CommsTransport extends Thread implements TransportProcs {
|
|||
public void relayStatus( CommsRelayState newState )
|
||||
{
|
||||
Utils.logf( "relayStatus called; state=%s", newState.toString() );
|
||||
if ( null != m_jniThread ) {
|
||||
m_jniThread.handle( JNICmd.CMD_DRAW_CONNS_STATUS, newState );
|
||||
} else {
|
||||
Utils.logf( "can't draw status yet" );
|
||||
}
|
||||
}
|
||||
|
||||
public void relayConnd( boolean allHere, int nMissing )
|
||||
|
|
|
@ -46,6 +46,7 @@ public class JNIThread extends Thread {
|
|||
CMD_FINAL,
|
||||
CMD_ENDGAME,
|
||||
CMD_POST_OVER,
|
||||
CMD_DRAW_CONNS_STATUS
|
||||
};
|
||||
|
||||
public static final int RUNNING = 1;
|
||||
|
@ -60,6 +61,8 @@ public class JNIThread extends Thread {
|
|||
private SyncedDraw m_drawer;
|
||||
private static final int kMinDivWidth = 10;
|
||||
private boolean m_keyDown = false;
|
||||
private Rect m_connsIconRect;
|
||||
private int m_connsIconID = 0;
|
||||
|
||||
LinkedBlockingQueue<QueueElem> m_queue;
|
||||
|
||||
|
@ -141,6 +144,13 @@ public class JNIThread extends Thread {
|
|||
}
|
||||
|
||||
int scoreWidth = nCells * cellSize;
|
||||
|
||||
if ( DeviceRole.SERVER_STANDALONE != m_gi.serverRole ) {
|
||||
scoreWidth -= cellSize;
|
||||
m_connsIconRect = new Rect( scoreWidth, 0,
|
||||
scoreWidth + cellSize, cellSize );
|
||||
}
|
||||
|
||||
if ( m_gi.timerEnabled ) {
|
||||
Paint paint = new Paint();
|
||||
paint.setTextSize( scoreHt );
|
||||
|
@ -390,6 +400,30 @@ public class JNIThread extends Thread {
|
|||
XwJNI.server_writeFinalScores( m_jniGamePtr ) );
|
||||
break;
|
||||
|
||||
case CMD_DRAW_CONNS_STATUS:
|
||||
int newID = 0;
|
||||
switch( (TransportProcs.CommsRelayState)(args[0]) ) {
|
||||
case COMMS_RELAYSTATE_UNCONNECTED:
|
||||
case COMMS_RELAYSTATE_DENIED:
|
||||
case COMMS_RELAYSTATE_CONNECT_PENDING:
|
||||
newID = R.drawable.netarrow_unconn;
|
||||
break;
|
||||
case COMMS_RELAYSTATE_CONNECTED:
|
||||
case COMMS_RELAYSTATE_RECONNECTED:
|
||||
newID = R.drawable.netarrow_someconn;
|
||||
break;
|
||||
case COMMS_RELAYSTATE_ALLCONNECTED:
|
||||
newID = R.drawable.netarrow_allconn;
|
||||
break;
|
||||
default:
|
||||
newID = 0;
|
||||
}
|
||||
if ( m_connsIconID != newID ) {
|
||||
draw = true;
|
||||
m_connsIconID = newID;
|
||||
}
|
||||
break;
|
||||
|
||||
case CMD_TIMER_FIRED:
|
||||
draw = XwJNI.timerFired( m_jniGamePtr,
|
||||
((Integer)args[0]).intValue(),
|
||||
|
@ -403,6 +437,9 @@ public class JNIThread extends Thread {
|
|||
// where it can be synchronized with that class's use
|
||||
// of the same bitmap for blitting.
|
||||
m_drawer.doJNIDraw();
|
||||
if ( null != m_connsIconRect ) {
|
||||
m_drawer.doIconDraw( m_connsIconID, m_connsIconRect );
|
||||
}
|
||||
|
||||
// main UI thread has to invalidate view as it created
|
||||
// it.
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
|
||||
package org.eehouse.android.xw4.jni;
|
||||
|
||||
import android.graphics.Rect;
|
||||
|
||||
public interface SyncedDraw {
|
||||
void doJNIDraw();
|
||||
void doIconDraw( int resID, final Rect rect );
|
||||
void prefsChanged();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue