From f5bc9ca43443706662bfeea91563ad5e15c23f24 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 5 Mar 2016 21:30:21 -0800 Subject: [PATCH] toward using chat senders' names in history: add chats table so we can keep track of sender as a separate column rather than a prepended string. I'm committing this separately for easier debugging of the code that uses it and that converts from the old format. --- .../src/org/eehouse/android/xw4/DBHelper.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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 55545207d..49b907a4b 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBHelper.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBHelper.java @@ -1,6 +1,6 @@ /* -*- compile-command: "find-and-ant.sh debug install"; -*- */ /* - * Copyright 2009-2010 by Eric House (xwords@eehouse.org). All + * Copyright 2009-2016 by Eric House (xwords@eehouse.org). All * rights reserved. * * This program is free software; you can redistribute it and/or @@ -42,8 +42,9 @@ public class DBHelper extends SQLiteOpenHelper { public static final String TABLE_NAME_LOC = "loc"; public static final String TABLE_NAME_PAIRS = "pairs"; public static final String TABLE_NAME_INVITES = "invites"; + public static final String TABLE_NAME_CHAT = "chat"; private static final String DB_NAME = "xwdb"; - private static final int DB_VERSION = 25; + private static final int DB_VERSION = 26; public static final String GAME_NAME = "GAME_NAME"; public static final String VISID = "VISID"; @@ -111,6 +112,9 @@ public class DBHelper extends SQLiteOpenHelper { public static final String TARGET = "TARGET"; public static final String TIMESTAMP = "TIMESTAMP"; + public static final String SENDER = "SENDER"; + public static final String MESSAGE = "MESSAGE"; + private Context m_context; private static final String[][] s_summaryColsAndTypes = { @@ -206,6 +210,12 @@ public class DBHelper extends SQLiteOpenHelper { ,{ TIMESTAMP, "DATETIME DEFAULT CURRENT_TIMESTAMP" } }; + private static final String[][] s_chatsSchema = { + { ROW, "INTEGER" } + ,{ SENDER, "INTEGER" } + ,{ MESSAGE, "TEXT" } + }; + public DBHelper( Context context ) { super( context, DB_NAME, null, DB_VERSION ); @@ -230,6 +240,7 @@ public class DBHelper extends SQLiteOpenHelper { createLocTable( db ); createPairsTable( db ); createInvitesTable( db ); + createChatsTable( db ); } @Override @@ -297,6 +308,8 @@ public class DBHelper extends SQLiteOpenHelper { } case 24: createInvitesTable( db ); + case 25: + createChatsTable( db ); break; default: @@ -401,6 +414,11 @@ public class DBHelper extends SQLiteOpenHelper { createTable( db, TABLE_NAME_INVITES, s_invitesSchema ); } + private void createChatsTable( SQLiteDatabase db ) + { + createTable( db, TABLE_NAME_CHAT, s_chatsSchema ); + } + // Move all existing games to the row previously named "cur games' private void moveToCurGames( SQLiteDatabase db ) {