From 9c670804f27fbcdb2fd5b3e486ab5ec5380b8e97 Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 25 Jul 2012 23:26:24 -0700 Subject: [PATCH] draw status icon background red when SMS turned off. --- .../org/eehouse/android/xw4/BoardView.java | 4 ++-- .../android/xw4/ConnStatusHandler.java | 22 +++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java index bed6116c5..eea07b086 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java @@ -321,8 +321,8 @@ public class BoardView extends View implements DrawCtx, BoardHandler, synchronized( this ) { if ( layoutBoardOnce() ) { canvas.drawBitmap( s_bitmap, 0, 0, m_drawPaint ); - ConnStatusHandler.draw( canvas, getResources(), 0, 0, - m_connType ); + ConnStatusHandler.draw( m_context, canvas, getResources(), + 0, 0, m_connType ); } } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ConnStatusHandler.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ConnStatusHandler.java index 6ac0dea80..e485f726e 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ConnStatusHandler.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ConnStatusHandler.java @@ -253,7 +253,7 @@ public class ConnStatusHandler { showSuccess( handler, false ); } - public static void draw( Canvas canvas, Resources res, + public static void draw( Context context, Canvas canvas, Resources res, int offsetX, int offsetY, CommsConnType connType ) { synchronized( s_lockObj ) { @@ -282,16 +282,19 @@ public class ConnStatusHandler { if ( CommsConnType.COMMS_CONN_NONE != connType ) { int saveTop = rect.top; SuccessRecord record; + boolean enabled = connTypeEnabled( context, connType ); // Do the background coloring rect.bottom = rect.top + quarterHeight * 2; record = recordFor( connType, false ); - s_fillPaint.setColor( record.successNewer ? GREEN : RED ); + s_fillPaint.setColor( enabled && record.successNewer + ? GREEN : RED ); canvas.drawRect( rect, s_fillPaint ); rect.top = rect.bottom; rect.bottom = rect.top + quarterHeight * 2; record = recordFor( connType, true ); - s_fillPaint.setColor( record.successNewer ? GREEN : RED ); + s_fillPaint.setColor( enabled && record.successNewer + ? GREEN : RED ); canvas.drawRect( rect, s_fillPaint ); // now the icons @@ -458,5 +461,16 @@ public class ConnStatusHandler { s_needsSave = false; } } - + + private static boolean connTypeEnabled( Context context, + CommsConnType connType ) + { + boolean result = true; + switch( connType ) { + case COMMS_CONN_SMS: + result = XWApp.SMSSUPPORTED && XWPrefs.getSMSEnabled( context ); + break; + } + return result; + } }