From 1d5249f13916512cd0ef7ce03813a2cdd4ac939b Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 22 Jul 2015 07:32:36 -0700 Subject: [PATCH] respect game dict and language in rematch! NOTE: this doesn't handle the case where players have different dicts. --- .../eehouse/android/xw4/BoardDelegate.java | 3 ++- .../org/eehouse/android/xw4/GameUtils.java | 20 +++++++++++-------- .../android/xw4/GamesListDelegate.java | 9 +++++++++ 3 files changed, 23 insertions(+), 9 deletions(-) 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 22009a4f2..7cc5cdfae 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java @@ -2564,7 +2564,8 @@ public class BoardDelegate extends DelegateBase if ( doIt ) { Intent intent = GamesListDelegate - .makeRematchIntent( m_activity, m_rowid, m_connTypes, btAddr, + .makeRematchIntent( m_activity, m_rowid, m_gi.dictName, + m_gi.dictLang, m_connTypes, btAddr, phone, relayID ); if ( null != intent ) { startActivity( intent ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java index cf596651d..046859adf 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java @@ -483,23 +483,27 @@ public class GameUtils { public static long makeNewMultiGame( Context context, long groupID, String gameName ) { - return makeNewMultiGame( context, groupID, (CommsConnTypeSet)null, - gameName ); + return makeNewMultiGame( context, groupID, null, 0, + (CommsConnTypeSet)null, gameName ); } public static long makeNewMultiGame( Context context, long groupID, - CommsConnTypeSet addrSet, String gameName ) + String dict, int lang, + CommsConnTypeSet addrSet, + String gameName ) { String inviteID = makeRandomID(); - return makeNewMultiGame( context, groupID, inviteID, addrSet, gameName ); + return makeNewMultiGame( context, groupID, inviteID, dict, lang, + addrSet, gameName ); } private static long makeNewMultiGame( Context context, long groupID, - String inviteID, CommsConnTypeSet addrSet, + String inviteID, String dict, + int lang, CommsConnTypeSet addrSet, String gameName ) { - int[] lang = {0}; - String[] dict = {null}; + int[] langArray = {lang}; + String[] dictArray = {dict}; if ( null == addrSet ) { addrSet = XWPrefs.getAddrTypes( context ); } @@ -507,7 +511,7 @@ public class GameUtils { addr.populate( context ); int forceChannel = 0; return makeNewMultiGame( context, (MultiMsgSink)null, (UtilCtxt)null, - groupID, addr, lang, dict, 2, 1, + groupID, addr, langArray, dictArray, 2, 1, forceChannel, inviteID, 0, gameName, true ); } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java index 2049ffbb0..85730b368 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java @@ -87,11 +87,14 @@ public class GamesListDelegate extends ListDelegateBase private static final String ROWID_EXTRA = "rowid"; private static final String GAMEID_EXTRA = "gameid"; private static final String REMATCH_ROWID_EXTRA = "rm_rowid"; + private static final String REMATCH_DICT_EXTRA = "rm_dict"; + private static final String REMATCH_LANG_EXTRA = "rm_lang"; private static final String REMATCH_ADDRS_EXTRA = "rm_addrs"; private static final String REMATCH_BTADDR_EXTRA = "rm_btaddr"; private static final String REMATCH_PHONE_EXTRA = "rm_phone"; private static final String REMATCH_RELAYID_EXTRA = "rm_relayid"; + private static final String ALERT_MSG = "alert_msg"; private class GameListAdapter extends XWExpListAdapter { @@ -1858,12 +1861,15 @@ public class GamesListDelegate extends ListDelegateBase // this will juggle if the preference is set newid = GameUtils.dupeGame( m_activity, rowid ); } else { + String dict = intent.getStringExtra( REMATCH_DICT_EXTRA ); + int lang = intent.getIntExtra( REMATCH_LANG_EXTRA, -1 ); int bits = intent.getIntExtra( REMATCH_ADDRS_EXTRA, -1 ); CommsConnTypeSet addrs = new CommsConnTypeSet( bits ); long groupID = DBUtils.getGroupForGame( m_activity, rowid ); String gameName = "rematch"; // FIX ME :-) newid = GameUtils.makeNewMultiGame( m_activity, groupID, + dict, lang, addrs, gameName ); DBUtils.addRematchInfo( m_activity, newid, btAddr, phone, @@ -2254,6 +2260,7 @@ public class GamesListDelegate extends ListDelegateBase } public static Intent makeRematchIntent( Context context, long rowid, + String dict, int lang, CommsConnTypeSet addrTypes, String btAddr, String phone, String relayID ) @@ -2262,6 +2269,8 @@ public class GamesListDelegate extends ListDelegateBase if ( XWApp.REMATCH_SUPPORTED ) { intent = makeSelfIntent( context ); intent.putExtra( REMATCH_ROWID_EXTRA, rowid ); + intent.putExtra( REMATCH_DICT_EXTRA, dict ); + intent.putExtra( REMATCH_LANG_EXTRA, lang ); if ( null != addrTypes ) { intent.putExtra( REMATCH_ADDRS_EXTRA, addrTypes.toInt() ); // here if ( null != btAddr ) {