From ec96a00b464c88c099d52f675970ef9dcae26f9e Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 29 Jul 2016 07:32:50 -0700 Subject: [PATCH] remove compile-time enabling of chat: it's not coming out --- xwords4/android/XWords4/app/build.gradle | 2 +- xwords4/android/XWords4/jni/Android.mk | 5 +- .../eehouse/android/xw4/BoardDelegate.java | 62 +++++++--------- .../org/eehouse/android/xw4/ChatActivity.java | 6 +- .../src/org/eehouse/android/xw4/DBUtils.java | 74 +++++++++---------- xwords4/android/scripts/common_targets.xml | 6 +- xwords4/android/scripts/genvers.sh | 9 +-- 7 files changed, 66 insertions(+), 98 deletions(-) diff --git a/xwords4/android/XWords4/app/build.gradle b/xwords4/android/XWords4/app/build.gradle index 414341c4f..3d90e4e09 100644 --- a/xwords4/android/XWords4/app/build.gradle +++ b/xwords4/android/XWords4/app/build.gradle @@ -134,7 +134,7 @@ dependencies { task genVers(type: Exec) { workingDir '../' commandLine '../scripts/genvers.sh', '--variant', VARIANT_NAME, - '--client-vers', INITIAL_CLIENT_VERS, '--chat-enabled', CHAT_ENABLED, + '--client-vers', INITIAL_CLIENT_VERS, '--thumbnail-enabled', THUMBNAIL_ENABLED, '--vers-outfile', "assets/gitvers.txt" } diff --git a/xwords4/android/XWords4/jni/Android.mk b/xwords4/android/XWords4/jni/Android.mk index f33d7dd9b..c88334119 100644 --- a/xwords4/android/XWords4/jni/Android.mk +++ b/xwords4/android/XWords4/jni/Android.mk @@ -38,6 +38,7 @@ LOCAL_DEFINES += \ -DHASH_STREAM \ -DXWFEATURE_BASE64 \ -DXWFEATURE_DEVID \ + -DXWFEATURE_CHAT \ -DCOMMON_LAYOUT \ -DNATIVE_NLI \ -DCOMMS_VERSION=1 \ @@ -46,10 +47,6 @@ LOCAL_DEFINES += \ -DRELAY_ROOM_DEFAULT=\"\" \ -D__LITTLE_ENDIAN \ -ifeq ($(CHAT_ENABLED),true) - LOCAL_DEFINES += -DXWFEATURE_CHAT -endif - # -DXWFEATURE_SCOREONEPASS \ LOCAL_SRC_FILES += \ diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java index 3c8cc7db9..8e7034421 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java @@ -540,9 +540,7 @@ public class BoardDelegate extends DelegateBase { getBundledData( savedInstanceState ); - if ( BuildConstants.CHAT_SUPPORTED ) { - m_pendingChats = new ArrayList(); - } + m_pendingChats = new ArrayList(); m_utils = new BoardUtilCtxt(); m_jniu = JNIUtilsImpl.get( m_activity ); @@ -788,8 +786,7 @@ public class BoardDelegate extends DelegateBase Utils.setItemVisible( menu, R.id.board_menu_hint_next, m_gsi.canHint ); Utils.setItemVisible( menu, R.id.board_menu_chat, - BuildConstants.CHAT_SUPPORTED - && m_gsi.canChat ); + m_gsi.canChat ); Utils.setItemVisible( menu, R.id.board_menu_tray, !inTrade && m_gsi.canHideRack ); Utils.setItemVisible( menu, R.id.board_menu_trade, @@ -2013,18 +2010,16 @@ public class BoardDelegate extends DelegateBase public void showChat( final String msg, final int fromIndx, String fromPlayer ) { - if ( BuildConstants.CHAT_SUPPORTED ) { - runOnUiThread( new Runnable() { - public void run() { - DBUtils.appendChatHistory( m_activity, m_rowid, msg, - fromIndx ); - if ( ! ChatDelegate.append( m_rowid, msg, - fromIndx ) ) { - startChatActivity(); - } + runOnUiThread( new Runnable() { + public void run() { + DBUtils.appendChatHistory( m_activity, m_rowid, msg, + fromIndx ); + if ( ! ChatDelegate.append( m_rowid, msg, + fromIndx ) ) { + startChatActivity(); } - } ); - } + } + } ); } } // class BoardUtilCtxt @@ -2247,12 +2242,10 @@ public class BoardDelegate extends DelegateBase R.string.not_again_undo, R.string.key_notagain_undo, Action.UNDO_ACTION ); - if ( BuildConstants.CHAT_SUPPORTED ) { - m_toolbar.setListener( Toolbar.BUTTON_CHAT, - R.string.not_again_chat, - R.string.key_notagain_chat, - Action.CHAT_ACTION ); - } + m_toolbar.setListener( Toolbar.BUTTON_CHAT, + R.string.not_again_chat, + R.string.key_notagain_chat, + Action.CHAT_ACTION ); } } // populateToolbar @@ -2340,13 +2333,11 @@ public class BoardDelegate extends DelegateBase private void startChatActivity() { - if ( BuildConstants.CHAT_SUPPORTED ) { - int curPlayer = XwJNI.board_getSelPlayer( m_jniGamePtr ); - String[] names = m_gi.playerNames(); - boolean[] locs = m_gi.playersLocal(); // to convert old histories - ChatDelegate.start( getDelegator(), m_rowid, curPlayer, - names, locs ); - } + int curPlayer = XwJNI.board_getSelPlayer( m_jniGamePtr ); + String[] names = m_gi.playerNames(); + boolean[] locs = m_gi.playersLocal(); // to convert old histories + ChatDelegate.start( getDelegator(), m_rowid, curPlayer, + names, locs ); } private void closeIfFinishing( boolean force ) @@ -2414,13 +2405,11 @@ public class BoardDelegate extends DelegateBase private void trySendChats() { - if ( BuildConstants.CHAT_SUPPORTED && null != m_jniThread ) { - Iterator iter = m_pendingChats.iterator(); - while ( iter.hasNext() ) { - handleViaThread( JNICmd.CMD_SENDCHAT, iter.next() ); - } - m_pendingChats.clear(); + Iterator iter = m_pendingChats.iterator(); + while ( iter.hasNext() ) { + handleViaThread( JNICmd.CMD_SENDCHAT, iter.next() ); } + m_pendingChats.clear(); } private void tryInvites() @@ -2492,8 +2481,7 @@ public class BoardDelegate extends DelegateBase m_toolbar.update( Toolbar.BUTTON_UNDO, m_gsi.canRedo ); m_toolbar.update( Toolbar.BUTTON_HINT_PREV, m_gsi.canHint ); m_toolbar.update( Toolbar.BUTTON_HINT_NEXT, m_gsi.canHint ); - m_toolbar.update( Toolbar.BUTTON_CHAT, - BuildConstants.CHAT_SUPPORTED && m_gsi.canChat ); + m_toolbar.update( Toolbar.BUTTON_CHAT, m_gsi.canChat ); m_toolbar.update( Toolbar.BUTTON_BROWSE_DICT, null != m_gi.dictName( m_view.getCurPlayer() ) ); } 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 845e0282b..dc3843d7b 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ChatActivity.java @@ -27,9 +27,7 @@ public class ChatActivity extends XWActivity { @Override public void onCreate( Bundle savedInstanceState ) { - if ( BuildConstants.CHAT_SUPPORTED ) { - ChatDelegate dlgt = new ChatDelegate( this, savedInstanceState ); - super.onCreate( savedInstanceState, dlgt ); - } + ChatDelegate dlgt = new ChatDelegate( this, savedInstanceState ); + super.onCreate( savedInstanceState, dlgt ); } } 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 990349f2a..692bdbdc2 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java @@ -1268,32 +1268,30 @@ public class DBUtils { boolean[] playersLocal ) { HistoryPair[] result = null; - if ( BuildConstants.CHAT_SUPPORTED ) { - String[] columns = { DBHelper.SENDER, DBHelper.MESSAGE }; - String selection = String.format( "%s=%d", DBHelper.ROW, rowid ); - initDB( context ); - synchronized( s_dbHelper ) { - SQLiteDatabase db = s_dbHelper.getReadableDatabase(); - Cursor cursor = db.query( DBHelper.TABLE_NAME_CHAT, columns, - selection, null, null, null, null ); - if ( 0 < cursor.getCount() ) { - result = new HistoryPair[cursor.getCount()]; - int msgIndex = cursor.getColumnIndex( DBHelper.MESSAGE ); - int plyrIndex = cursor.getColumnIndex( DBHelper.SENDER ); - for ( int ii = 0; cursor.moveToNext(); ++ii ) { - String msg = cursor.getString( msgIndex ); - int plyr = cursor.getInt( plyrIndex ); - HistoryPair pair = new HistoryPair(msg, plyr ); - result[ii] = pair; - } + String[] columns = { DBHelper.SENDER, DBHelper.MESSAGE }; + String selection = String.format( "%s=%d", DBHelper.ROW, rowid ); + initDB( context ); + synchronized( s_dbHelper ) { + SQLiteDatabase db = s_dbHelper.getReadableDatabase(); + Cursor cursor = db.query( DBHelper.TABLE_NAME_CHAT, columns, + selection, null, null, null, null ); + if ( 0 < cursor.getCount() ) { + result = new HistoryPair[cursor.getCount()]; + int msgIndex = cursor.getColumnIndex( DBHelper.MESSAGE ); + int plyrIndex = cursor.getColumnIndex( DBHelper.SENDER ); + for ( int ii = 0; cursor.moveToNext(); ++ii ) { + String msg = cursor.getString( msgIndex ); + int plyr = cursor.getInt( plyrIndex ); + HistoryPair pair = new HistoryPair(msg, plyr ); + result[ii] = pair; } - cursor.close(); - db.close(); } + cursor.close(); + db.close(); + } - if ( null == result ) { - result = convertChatString( context, rowid, playersLocal ); - } + if ( null == result ) { + result = convertChatString( context, rowid, playersLocal ); } return result; } @@ -1792,24 +1790,22 @@ public class DBUtils { private static String getChatHistoryStr( Context context, long rowid ) { String result = null; - if ( BuildConstants.CHAT_SUPPORTED ) { - String[] columns = { DBHelper.CHAT_HISTORY }; - String selection = String.format( ROW_ID_FMT, rowid ); - initDB( context ); - synchronized( s_dbHelper ) { - SQLiteDatabase db = s_dbHelper.getReadableDatabase(); + String[] columns = { DBHelper.CHAT_HISTORY }; + String selection = String.format( ROW_ID_FMT, rowid ); + initDB( context ); + synchronized( s_dbHelper ) { + SQLiteDatabase db = s_dbHelper.getReadableDatabase(); - 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 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(); } return result; } diff --git a/xwords4/android/scripts/common_targets.xml b/xwords4/android/scripts/common_targets.xml index 0b98fcbca..e06f2367d 100644 --- a/xwords4/android/scripts/common_targets.xml +++ b/xwords4/android/scripts/common_targets.xml @@ -27,12 +27,10 @@ - - @@ -59,14 +57,12 @@ - - - diff --git a/xwords4/android/scripts/genvers.sh b/xwords4/android/scripts/genvers.sh index f11663fa6..1950e0461 100755 --- a/xwords4/android/scripts/genvers.sh +++ b/xwords4/android/scripts/genvers.sh @@ -6,13 +6,11 @@ STRINGS_HASH="" OUT_PATH="" VARIANT="" CLIENT_VERS_RELAY="" -CHAT_SUPPORTED="" GCM_SENDER_ID=${GCM_SENDER_ID:-""} CRITTERCISM_APP_ID=${CRITTERCISM_APP_ID:-""} usage() { echo "usage: $0 --variant --client-vers \\" - echo " --chat-enabled \\" echo " [--vers-outfile path/to/versout.txt]" exit 1 } @@ -28,10 +26,6 @@ while [ $# -gt 0 ]; do CLIENT_VERS_RELAY=$2 shift ;; - --chat-enabled) - CHAT_SUPPORTED=$2 - shift - ;; --vers-outfile) OUT_PATH=$2 shift @@ -43,7 +37,7 @@ while [ $# -gt 0 ]; do shift done -[ -n "$VARIANT" -a -n "$CLIENT_VERS_RELAY" -a -n "$CHAT_SUPPORTED" ] || usage +[ -n "$VARIANT" -a -n "$CLIENT_VERS_RELAY" ] || usage BUILD_DIR=$(basename $(pwd)) cd $(dirname $0) @@ -114,7 +108,6 @@ public class BuildConstants { public static final String GIT_REV = "$SHORTVERS"; public static final String STRINGS_HASH = "$STRINGS_HASH"; public static final short CLIENT_VERS_RELAY = $CLIENT_VERS_RELAY; - public static final boolean CHAT_SUPPORTED = $CHAT_SUPPORTED; public static final long BUILD_STAMP = $(date +'%s'); public static final String DBG_TAG = "$DBG_TAG"; public static final String VARIANT = "$VARIANT";