remove compile-time enabling of chat: it's not coming out

This commit is contained in:
Eric House 2016-07-29 07:32:50 -07:00
parent 36f127fb18
commit ec96a00b46
7 changed files with 66 additions and 98 deletions

View file

@ -134,7 +134,7 @@ dependencies {
task genVers(type: Exec) { task genVers(type: Exec) {
workingDir '../' workingDir '../'
commandLine '../scripts/genvers.sh', '--variant', VARIANT_NAME, 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, '--thumbnail-enabled', THUMBNAIL_ENABLED,
'--vers-outfile', "assets/gitvers.txt" '--vers-outfile', "assets/gitvers.txt"
} }

View file

@ -38,6 +38,7 @@ LOCAL_DEFINES += \
-DHASH_STREAM \ -DHASH_STREAM \
-DXWFEATURE_BASE64 \ -DXWFEATURE_BASE64 \
-DXWFEATURE_DEVID \ -DXWFEATURE_DEVID \
-DXWFEATURE_CHAT \
-DCOMMON_LAYOUT \ -DCOMMON_LAYOUT \
-DNATIVE_NLI \ -DNATIVE_NLI \
-DCOMMS_VERSION=1 \ -DCOMMS_VERSION=1 \
@ -46,10 +47,6 @@ LOCAL_DEFINES += \
-DRELAY_ROOM_DEFAULT=\"\" \ -DRELAY_ROOM_DEFAULT=\"\" \
-D__LITTLE_ENDIAN \ -D__LITTLE_ENDIAN \
ifeq ($(CHAT_ENABLED),true)
LOCAL_DEFINES += -DXWFEATURE_CHAT
endif
# -DXWFEATURE_SCOREONEPASS \ # -DXWFEATURE_SCOREONEPASS \
LOCAL_SRC_FILES += \ LOCAL_SRC_FILES += \

View file

@ -540,9 +540,7 @@ public class BoardDelegate extends DelegateBase
{ {
getBundledData( savedInstanceState ); getBundledData( savedInstanceState );
if ( BuildConstants.CHAT_SUPPORTED ) { m_pendingChats = new ArrayList<String>();
m_pendingChats = new ArrayList<String>();
}
m_utils = new BoardUtilCtxt(); m_utils = new BoardUtilCtxt();
m_jniu = JNIUtilsImpl.get( m_activity ); m_jniu = JNIUtilsImpl.get( m_activity );
@ -788,8 +786,7 @@ public class BoardDelegate extends DelegateBase
Utils.setItemVisible( menu, R.id.board_menu_hint_next, Utils.setItemVisible( menu, R.id.board_menu_hint_next,
m_gsi.canHint ); m_gsi.canHint );
Utils.setItemVisible( menu, R.id.board_menu_chat, 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, Utils.setItemVisible( menu, R.id.board_menu_tray,
!inTrade && m_gsi.canHideRack ); !inTrade && m_gsi.canHideRack );
Utils.setItemVisible( menu, R.id.board_menu_trade, 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, public void showChat( final String msg, final int fromIndx,
String fromPlayer ) String fromPlayer )
{ {
if ( BuildConstants.CHAT_SUPPORTED ) { runOnUiThread( new Runnable() {
runOnUiThread( new Runnable() { public void run() {
public void run() { DBUtils.appendChatHistory( m_activity, m_rowid, msg,
DBUtils.appendChatHistory( m_activity, m_rowid, msg, fromIndx );
fromIndx ); if ( ! ChatDelegate.append( m_rowid, msg,
if ( ! ChatDelegate.append( m_rowid, msg, fromIndx ) ) {
fromIndx ) ) { startChatActivity();
startChatActivity();
}
} }
} ); }
} } );
} }
} // class BoardUtilCtxt } // class BoardUtilCtxt
@ -2247,12 +2242,10 @@ public class BoardDelegate extends DelegateBase
R.string.not_again_undo, R.string.not_again_undo,
R.string.key_notagain_undo, R.string.key_notagain_undo,
Action.UNDO_ACTION ); Action.UNDO_ACTION );
if ( BuildConstants.CHAT_SUPPORTED ) { m_toolbar.setListener( Toolbar.BUTTON_CHAT,
m_toolbar.setListener( Toolbar.BUTTON_CHAT, R.string.not_again_chat,
R.string.not_again_chat, R.string.key_notagain_chat,
R.string.key_notagain_chat, Action.CHAT_ACTION );
Action.CHAT_ACTION );
}
} }
} // populateToolbar } // populateToolbar
@ -2340,13 +2333,11 @@ public class BoardDelegate extends DelegateBase
private void startChatActivity() private void startChatActivity()
{ {
if ( BuildConstants.CHAT_SUPPORTED ) { int curPlayer = XwJNI.board_getSelPlayer( m_jniGamePtr );
int curPlayer = XwJNI.board_getSelPlayer( m_jniGamePtr ); String[] names = m_gi.playerNames();
String[] names = m_gi.playerNames(); boolean[] locs = m_gi.playersLocal(); // to convert old histories
boolean[] locs = m_gi.playersLocal(); // to convert old histories ChatDelegate.start( getDelegator(), m_rowid, curPlayer,
ChatDelegate.start( getDelegator(), m_rowid, curPlayer, names, locs );
names, locs );
}
} }
private void closeIfFinishing( boolean force ) private void closeIfFinishing( boolean force )
@ -2414,13 +2405,11 @@ public class BoardDelegate extends DelegateBase
private void trySendChats() private void trySendChats()
{ {
if ( BuildConstants.CHAT_SUPPORTED && null != m_jniThread ) { Iterator<String> iter = m_pendingChats.iterator();
Iterator<String> iter = m_pendingChats.iterator(); while ( iter.hasNext() ) {
while ( iter.hasNext() ) { handleViaThread( JNICmd.CMD_SENDCHAT, iter.next() );
handleViaThread( JNICmd.CMD_SENDCHAT, iter.next() );
}
m_pendingChats.clear();
} }
m_pendingChats.clear();
} }
private void tryInvites() 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_UNDO, m_gsi.canRedo );
m_toolbar.update( Toolbar.BUTTON_HINT_PREV, m_gsi.canHint ); 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_HINT_NEXT, m_gsi.canHint );
m_toolbar.update( Toolbar.BUTTON_CHAT, m_toolbar.update( Toolbar.BUTTON_CHAT, m_gsi.canChat );
BuildConstants.CHAT_SUPPORTED && m_gsi.canChat );
m_toolbar.update( Toolbar.BUTTON_BROWSE_DICT, m_toolbar.update( Toolbar.BUTTON_BROWSE_DICT,
null != m_gi.dictName( m_view.getCurPlayer() ) ); null != m_gi.dictName( m_view.getCurPlayer() ) );
} }

View file

@ -27,9 +27,7 @@ public class ChatActivity extends XWActivity {
@Override @Override
public void onCreate( Bundle savedInstanceState ) public void onCreate( Bundle savedInstanceState )
{ {
if ( BuildConstants.CHAT_SUPPORTED ) { ChatDelegate dlgt = new ChatDelegate( this, savedInstanceState );
ChatDelegate dlgt = new ChatDelegate( this, savedInstanceState ); super.onCreate( savedInstanceState, dlgt );
super.onCreate( savedInstanceState, dlgt );
}
} }
} }

View file

@ -1268,32 +1268,30 @@ public class DBUtils {
boolean[] playersLocal ) boolean[] playersLocal )
{ {
HistoryPair[] result = null; HistoryPair[] result = null;
if ( BuildConstants.CHAT_SUPPORTED ) { String[] columns = { DBHelper.SENDER, DBHelper.MESSAGE };
String[] columns = { DBHelper.SENDER, DBHelper.MESSAGE }; String selection = String.format( "%s=%d", DBHelper.ROW, rowid );
String selection = String.format( "%s=%d", DBHelper.ROW, rowid ); initDB( context );
initDB( context ); synchronized( s_dbHelper ) {
synchronized( s_dbHelper ) { SQLiteDatabase db = s_dbHelper.getReadableDatabase();
SQLiteDatabase db = s_dbHelper.getReadableDatabase(); Cursor cursor = db.query( DBHelper.TABLE_NAME_CHAT, columns,
Cursor cursor = db.query( DBHelper.TABLE_NAME_CHAT, columns, selection, null, null, null, null );
selection, null, null, null, null ); if ( 0 < cursor.getCount() ) {
if ( 0 < cursor.getCount() ) { result = new HistoryPair[cursor.getCount()];
result = new HistoryPair[cursor.getCount()]; int msgIndex = cursor.getColumnIndex( DBHelper.MESSAGE );
int msgIndex = cursor.getColumnIndex( DBHelper.MESSAGE ); int plyrIndex = cursor.getColumnIndex( DBHelper.SENDER );
int plyrIndex = cursor.getColumnIndex( DBHelper.SENDER ); for ( int ii = 0; cursor.moveToNext(); ++ii ) {
for ( int ii = 0; cursor.moveToNext(); ++ii ) { String msg = cursor.getString( msgIndex );
String msg = cursor.getString( msgIndex ); int plyr = cursor.getInt( plyrIndex );
int plyr = cursor.getInt( plyrIndex ); HistoryPair pair = new HistoryPair(msg, plyr );
HistoryPair pair = new HistoryPair(msg, plyr ); result[ii] = pair;
result[ii] = pair;
}
} }
cursor.close();
db.close();
} }
cursor.close();
db.close();
}
if ( null == result ) { if ( null == result ) {
result = convertChatString( context, rowid, playersLocal ); result = convertChatString( context, rowid, playersLocal );
}
} }
return result; return result;
} }
@ -1792,24 +1790,22 @@ public class DBUtils {
private static String getChatHistoryStr( Context context, long rowid ) private static String getChatHistoryStr( Context context, long rowid )
{ {
String result = null; String result = null;
if ( BuildConstants.CHAT_SUPPORTED ) { String[] columns = { DBHelper.CHAT_HISTORY };
String[] columns = { DBHelper.CHAT_HISTORY }; String selection = String.format( ROW_ID_FMT, rowid );
String selection = String.format( ROW_ID_FMT, rowid ); initDB( context );
initDB( context ); synchronized( s_dbHelper ) {
synchronized( s_dbHelper ) { SQLiteDatabase db = s_dbHelper.getReadableDatabase();
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns, Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
selection, null, null, null, null ); selection, null, null, null, null );
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) { if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
result = result =
cursor.getString( cursor cursor.getString( cursor
.getColumnIndex(DBHelper .getColumnIndex(DBHelper
.CHAT_HISTORY)); .CHAT_HISTORY));
}
cursor.close();
db.close();
} }
cursor.close();
db.close();
} }
return result; return result;
} }

View file

@ -27,12 +27,10 @@
<arg value="${build.target}"/> <arg value="${build.target}"/>
</exec> </exec>
<property name="CHAT_ENABLED" value="true" />
<exec dir="." executable="../scripts/ndkbuild.sh" failonerror="true"> <exec dir="." executable="../scripts/ndkbuild.sh" failonerror="true">
<arg value="BUILD_TARGET=${build.target}" /> <arg value="BUILD_TARGET=${build.target}" />
<arg value="-j3"/> <arg value="-j3"/>
<arg value="INITIAL_CLIENT_VERS=${INITIAL_CLIENT_VERS}" /> <arg value="INITIAL_CLIENT_VERS=${INITIAL_CLIENT_VERS}" />
<arg value="CHAT_ENABLED=${CHAT_ENABLED}" />
<arg value="VARIANT=${VARIANT_NAME}" /> <arg value="VARIANT=${VARIANT_NAME}" />
<arg value="V=1" /> <arg value="V=1" />
</exec> </exec>
@ -59,14 +57,12 @@
<arg value="${VARIANT_NAME}"/> <arg value="${VARIANT_NAME}"/>
</exec> </exec>
<exec dir="." executable="../scripts/genvers.sh" output="/dev/null" <exec dir="." executable="../scripts/genvers.sh" output="/dev/null"
failonerror="true"> failonerror="true">
<arg value="--variant" /> <arg value="--variant" />
<arg value="${VARIANT_NAME}" /> <arg value="${VARIANT_NAME}" />
<arg value="--client-vers" /> <arg value="--client-vers" />
<arg value="${INITIAL_CLIENT_VERS}" /> <arg value="${INITIAL_CLIENT_VERS}" />
<arg value="--chat-enabled"/>
<arg value="${CHAT_ENABLED}" />
<arg value="--vers-outfile" /> <arg value="--vers-outfile" />
<arg value="./assets/gitvers.txt" /> <arg value="./assets/gitvers.txt" />
</exec> </exec>

View file

@ -6,13 +6,11 @@ STRINGS_HASH=""
OUT_PATH="" OUT_PATH=""
VARIANT="" VARIANT=""
CLIENT_VERS_RELAY="" CLIENT_VERS_RELAY=""
CHAT_SUPPORTED=""
GCM_SENDER_ID=${GCM_SENDER_ID:-""} GCM_SENDER_ID=${GCM_SENDER_ID:-""}
CRITTERCISM_APP_ID=${CRITTERCISM_APP_ID:-""} CRITTERCISM_APP_ID=${CRITTERCISM_APP_ID:-""}
usage() { usage() {
echo "usage: $0 --variant <variant> --client-vers <relay_vers> \\" echo "usage: $0 --variant <variant> --client-vers <relay_vers> \\"
echo " --chat-enabled <trueOrFalse> <trueOrFalse> \\"
echo " [--vers-outfile path/to/versout.txt]" echo " [--vers-outfile path/to/versout.txt]"
exit 1 exit 1
} }
@ -28,10 +26,6 @@ while [ $# -gt 0 ]; do
CLIENT_VERS_RELAY=$2 CLIENT_VERS_RELAY=$2
shift shift
;; ;;
--chat-enabled)
CHAT_SUPPORTED=$2
shift
;;
--vers-outfile) --vers-outfile)
OUT_PATH=$2 OUT_PATH=$2
shift shift
@ -43,7 +37,7 @@ while [ $# -gt 0 ]; do
shift shift
done 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)) BUILD_DIR=$(basename $(pwd))
cd $(dirname $0) cd $(dirname $0)
@ -114,7 +108,6 @@ public class BuildConstants {
public static final String GIT_REV = "$SHORTVERS"; public static final String GIT_REV = "$SHORTVERS";
public static final String STRINGS_HASH = "$STRINGS_HASH"; public static final String STRINGS_HASH = "$STRINGS_HASH";
public static final short CLIENT_VERS_RELAY = $CLIENT_VERS_RELAY; 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 long BUILD_STAMP = $(date +'%s');
public static final String DBG_TAG = "$DBG_TAG"; public static final String DBG_TAG = "$DBG_TAG";
public static final String VARIANT = "$VARIANT"; public static final String VARIANT = "$VARIANT";