diff --git a/xwords4/android/XWords4/res/raw/changes b/xwords4/android/XWords4/res/raw/changes
index 7019c3ddc..c64504047 100644
--- a/xwords4/android/XWords4/res/raw/changes
+++ b/xwords4/android/XWords4/res/raw/changes
@@ -12,8 +12,8 @@
Fix menu missing on some tablets
Disable in-game Chat feature. (It has bugs that cause games to
- stop syncing moves. I&ll fix eventually. Let me know if you
- use this feature and I&ll up the priority.)
+ stop syncing moves. I'll fix eventually. Let me know if you
+ use this feature and I'll up the priority.)
Fix crash triggered by resignation
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatActivity.java
index a76f94ba3..07cd83c01 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatActivity.java
@@ -40,32 +40,39 @@ public class ChatActivity extends XWActivity implements View.OnClickListener {
@Override
public void onCreate( Bundle savedInstanceState )
{
- super.onCreate( savedInstanceState );
+ if ( XWApp.CHAT_SUPPORTED ) {
+ super.onCreate( savedInstanceState );
- setContentView( R.layout.chat );
+ setContentView( R.layout.chat );
- m_rowid = getIntent().getLongExtra( GameUtils.INTENT_KEY_ROWID, -1 );
+ m_rowid = getIntent().getLongExtra( GameUtils.INTENT_KEY_ROWID, -1 );
- DBUtils.HistoryPair[] pairs = DBUtils.getChatHistory( this, m_rowid );
- if ( null != pairs ) {
- LinearLayout layout = (LinearLayout)findViewById( R.id.chat_history );
- LayoutInflater factory = LayoutInflater.from( this );
+ DBUtils.HistoryPair[] pairs = DBUtils.getChatHistory( this, m_rowid );
+ if ( null != pairs ) {
+ LinearLayout layout = (LinearLayout)
+ findViewById( R.id.chat_history );
+ LayoutInflater factory = LayoutInflater.from( this );
- for ( DBUtils.HistoryPair pair : pairs ) {
- TextView view =
- (TextView)factory.inflate( pair.sourceLocal
- ? R.layout.chat_history_local
- : R.layout.chat_history_remote,
- null );
- view.setText( pair.msg );
- layout.addView( view );
+ for ( DBUtils.HistoryPair pair : pairs ) {
+ TextView view = (TextView)factory
+ .inflate( pair.sourceLocal
+ ? R.layout.chat_history_local
+ : R.layout.chat_history_remote,
+ null );
+ view.setText( pair.msg );
+ layout.addView( view );
+ }
}
+
+ ((Button)findViewById( R.id.send_button ))
+ .setOnClickListener( this );
+
+ setTitle( getString( R.string.chat_titlef,
+ GameUtils.getName( this, m_rowid ) ) );
+ } else {
+ // Should really assert....
+ finish();
}
-
- ((Button)findViewById( R.id.send_button )).setOnClickListener( this );
-
- setTitle( getString( R.string.chat_titlef,
- GameUtils.getName( this, m_rowid ) ) );
}
@Override
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java
index 998173cf4..d401fd051 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java
@@ -855,15 +855,17 @@ public class DBUtils {
public static HistoryPair[] getChatHistory( Context context, long rowid )
{
HistoryPair[] result = null;
- final String localPrefix = context.getString( R.string.chat_local_id );
- String history = getChatHistoryStr( context, rowid );
- if ( null != history ) {
- String[] msgs = history.split( "\n" );
- result = new HistoryPair[msgs.length];
- for ( int ii = 0; ii < result.length; ++ii ) {
- String msg = msgs[ii];
- boolean isLocal = msg.startsWith( localPrefix );
- result[ii] = new HistoryPair( msg, isLocal );
+ if ( XWApp.CHAT_SUPPORTED ) {
+ final String localPrefix = context.getString( R.string.chat_local_id );
+ String history = getChatHistoryStr( context, rowid );
+ if ( null != history ) {
+ String[] msgs = history.split( "\n" );
+ result = new HistoryPair[msgs.length];
+ for ( int ii = 0; ii < result.length; ++ii ) {
+ String msg = msgs[ii];
+ boolean isLocal = msg.startsWith( localPrefix );
+ result[ii] = new HistoryPair( msg, isLocal );
+ }
}
}
return result;
@@ -1115,21 +1117,24 @@ public class DBUtils {
private static String getChatHistoryStr( Context context, long rowid )
{
String result = null;
- initDB( context );
- synchronized( s_dbHelper ) {
- SQLiteDatabase db = s_dbHelper.getReadableDatabase();
+ if ( XWApp.CHAT_SUPPORTED ) {
+ initDB( context );
+ synchronized( s_dbHelper ) {
+ SQLiteDatabase db = s_dbHelper.getReadableDatabase();
- String[] columns = { DBHelper.CHAT_HISTORY };
- String selection = String.format( ROW_ID_FMT, rowid );
- Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
- selection, null, null, null, null );
- if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
- result =
- cursor.getString( cursor
- .getColumnIndex(DBHelper.CHAT_HISTORY));
+ String[] columns = { DBHelper.CHAT_HISTORY };
+ String selection = String.format( ROW_ID_FMT, rowid );
+ Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
+ selection, null, null, null, null );
+ if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
+ result =
+ cursor.getString( cursor
+ .getColumnIndex(DBHelper
+ .CHAT_HISTORY));
+ }
+ cursor.close();
+ db.close();
}
- cursor.close();
- db.close();
}
return result;
}
@@ -1137,16 +1142,18 @@ public class DBUtils {
public static void appendChatHistory( Context context, long rowid,
String msg, boolean local )
{
- Assert.assertNotNull( msg );
- int id = local ? R.string.chat_local_id : R.string.chat_other_id;
- msg = context.getString( id ) + msg;
+ if ( XWApp.CHAT_SUPPORTED ) {
+ Assert.assertNotNull( msg );
+ int id = local ? R.string.chat_local_id : R.string.chat_other_id;
+ msg = context.getString( id ) + msg;
- String cur = getChatHistoryStr( context, rowid );
- if ( null != cur ) {
- msg = cur + "\n" + msg;
+ String cur = getChatHistoryStr( context, rowid );
+ if ( null != cur ) {
+ msg = cur + "\n" + msg;
+ }
+
+ saveChatHistory( context, rowid, msg );
}
-
- saveChatHistory( context, rowid, msg );
} // appendChatHistory
public static void clearChatHistory( Context context, long rowid )