From adf71c85a5ad52a030dc045c42f135b0594ef409 Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 31 Aug 2016 19:37:56 -0700 Subject: [PATCH] add turnIsLocal to android db So we can filter on it determining the display order of games in games list. --- xwords4/android/XWords4/jni/xwjni.c | 2 +- .../XWords4/src/org/eehouse/android/xw4/DBHelper.java | 8 +++++++- .../XWords4/src/org/eehouse/android/xw4/DBUtils.java | 5 ++++- .../src/org/eehouse/android/xw4/jni/GameSummary.java | 3 ++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c index 4b513255a..2b42937fd 100644 --- a/xwords4/android/XWords4/jni/xwjni.c +++ b/xwords4/android/XWords4/jni/xwjni.c @@ -1664,7 +1664,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1summarize XP_Bool isLocal; setInt( env, jsummary, "turn", server_getCurrentTurn( state->game.server, &isLocal ) ); - // setBool( env, jsummary, "turnIsLocal", isLocal ); + setBool( env, jsummary, "turnIsLocal", isLocal ); setInt( env, jsummary, "lastMoveTime", server_getLastMoveTime(state->game.server) ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBHelper.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBHelper.java index 55e6648eb..f50634cb1 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBHelper.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBHelper.java @@ -46,12 +46,13 @@ public class DBHelper extends SQLiteOpenHelper { public static final String TABLE_NAME_CHAT = "chat"; public static final String TABLE_NAME_LOGS = "logs"; private static final String DB_NAME = "xwdb"; - private static final int DB_VERSION = 27; + private static final int DB_VERSION = 28; public static final String GAME_NAME = "GAME_NAME"; public static final String VISID = "VISID"; public static final String NUM_MOVES = "NUM_MOVES"; public static final String TURN = "TURN"; + public static final String TURN_LOCAL = "TURN_LOCAL"; public static final String GIFLAGS = "GIFLAGS"; public static final String PLAYERS = "PLAYERS"; @@ -126,6 +127,7 @@ public class DBHelper extends SQLiteOpenHelper { ,{ GAME_NAME, "TEXT" } ,{ NUM_MOVES, "INTEGER" } ,{ TURN, "INTEGER" } + ,{ TURN_LOCAL, "INTEGER" } ,{ GIFLAGS, "INTEGER" } ,{ NUM_PLAYERS, "INTEGER" } ,{ MISSINGPLYRS,"INTEGER" } @@ -322,6 +324,10 @@ public class DBHelper extends SQLiteOpenHelper { createChatsTable( db ); case 26: createLogsTable( db ); + case 27: + if ( !madeSumTable ) { + addSumColumn( db, TURN_LOCAL ); + } break; default: 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 9e1949f2a..ce8b80e57 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java @@ -125,7 +125,7 @@ public class DBUtils { DBHelper.NUM_MOVES, DBHelper.NUM_PLAYERS, DBHelper.MISSINGPLYRS, DBHelper.GAME_OVER, DBHelper.PLAYERS, - DBHelper.TURN, DBHelper.GIFLAGS, + DBHelper.TURN, DBHelper.TURN_LOCAL, DBHelper.GIFLAGS, DBHelper.CONTYPE, DBHelper.SERVERROLE, DBHelper.ROOMNAME, DBHelper.RELAYID, /*DBHelper.SMSPHONE,*/ DBHelper.SEED, @@ -159,6 +159,8 @@ public class DBUtils { summary.turn = cursor.getInt(cursor. getColumnIndex(DBHelper.TURN)); + summary.turnIsLocal = 0 != cursor.getInt(cursor. + getColumnIndex(DBHelper.TURN_LOCAL)); summary. setGiFlags( cursor.getInt(cursor. getColumnIndex(DBHelper.GIFLAGS)) @@ -269,6 +271,7 @@ public class DBUtils { values.put( DBHelper.NUM_PLAYERS, summary.nPlayers ); values.put( DBHelper.MISSINGPLYRS, summary.missingPlayers ); values.put( DBHelper.TURN, summary.turn ); + values.put( DBHelper.TURN_LOCAL, summary.turnIsLocal? 1 : 0 ); values.put( DBHelper.GIFLAGS, summary.giflags() ); values.put( DBHelper.PLAYERS, summary.summarizePlayers() ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/GameSummary.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/GameSummary.java index 6eff0fac0..d15b845e6 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/GameSummary.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/GameSummary.java @@ -50,9 +50,10 @@ public class GameSummary { public static final int MSG_FLAGS_GAMEOVER = 4; public static final int MSG_FLAGS_ALL = 7; - public int lastMoveTime; + public int lastMoveTime; // set by jni's server.c on move receipt public int nMoves; public int turn; + public boolean turnIsLocal; public int nPlayers; public int missingPlayers; public int[] scores;