mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-01 06:19:57 +01:00
warn about duplicate games not just when there's exactly one, and
include the most recent create time in the warning.
This commit is contained in:
parent
95062fb967
commit
32d7daf2b5
3 changed files with 30 additions and 22 deletions
|
@ -1552,8 +1552,8 @@
|
|||
the same room name over and over so they'll get this warning
|
||||
and it's harmless to ignore it. -->
|
||||
<string name="dup_game_queryf">You already have a game that seems
|
||||
to have been created from the same invitation. Are you sure you
|
||||
want to open another?</string>
|
||||
to have been created (on %1$s) from the same invitation. Are you
|
||||
sure you want to create another?</string>
|
||||
|
||||
<!-- Title of generic dialog used to display information -->
|
||||
<string name="info_title">FYI...</string>
|
||||
|
|
|
@ -535,13 +535,16 @@ public class DBUtils {
|
|||
}
|
||||
}
|
||||
|
||||
public static long getRowIDForOpen( Context context, NetLaunchInfo nli )
|
||||
// Return creation time of newest game matching this nli, or null
|
||||
// if none found.
|
||||
public static Date getMostRecentCreate( Context context,
|
||||
NetLaunchInfo nli )
|
||||
{
|
||||
long result = ROWID_NOTFOUND;
|
||||
Date result = null;
|
||||
initDB( context );
|
||||
synchronized( s_dbHelper ) {
|
||||
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
|
||||
String[] columns = { ROW_ID };
|
||||
String[] columns = { DBHelper.CREATE_TIME };
|
||||
String selection =
|
||||
String.format( "%s='%s' AND %s='%s' AND %s=%d AND %s=%d",
|
||||
DBHelper.ROOMNAME, nli.room,
|
||||
|
@ -549,9 +552,12 @@ public class DBUtils {
|
|||
DBHelper.DICTLANG, nli.lang,
|
||||
DBHelper.NUM_PLAYERS, nli.nPlayersT );
|
||||
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
|
||||
selection, null, null, null, null );
|
||||
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
|
||||
result = cursor.getLong( cursor.getColumnIndex(ROW_ID) );
|
||||
selection, null, null, null,
|
||||
DBHelper.CREATE_TIME + " DESC" ); // order by
|
||||
while ( cursor.moveToNext() ) {
|
||||
int indx = cursor.getColumnIndex( DBHelper.CREATE_TIME );
|
||||
result = new Date( cursor.getLong( indx ) );
|
||||
break;
|
||||
}
|
||||
cursor.close();
|
||||
db.close();
|
||||
|
@ -559,14 +565,14 @@ public class DBUtils {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static long getRowIDForOpen( Context context, Uri data )
|
||||
public static Date getMostRecentCreate( Context context, Uri data )
|
||||
{
|
||||
long rowid = ROWID_NOTFOUND;
|
||||
Date result = null;
|
||||
NetLaunchInfo nli = new NetLaunchInfo( context, data );
|
||||
if ( null != nli && nli.isValid() ) {
|
||||
rowid = getRowIDForOpen( context, nli );
|
||||
result = getMostRecentCreate( context, nli );
|
||||
}
|
||||
return rowid;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String[] getRelayIDs( Context context, boolean noMsgs )
|
||||
|
|
|
@ -20,30 +20,31 @@
|
|||
|
||||
package org.eehouse.android.xw4;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.app.Dialog;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.ListActivity;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Button;
|
||||
import android.view.MenuInflater;
|
||||
import java.io.File;
|
||||
import android.preference.PreferenceManager;
|
||||
import java.util.Date;
|
||||
// import android.telephony.PhoneStateListener;
|
||||
// import android.telephony.TelephonyManager;
|
||||
import junit.framework.Assert;
|
||||
|
@ -779,14 +780,15 @@ public class GamesList extends XWListActivity
|
|||
|
||||
private void startNewNetGame( NetLaunchInfo nli )
|
||||
{
|
||||
long rowid = DBUtils.getRowIDForOpen( this, nli );
|
||||
Date create = DBUtils.getMostRecentCreate( this, nli );
|
||||
|
||||
if ( DBUtils.ROWID_NOTFOUND == rowid ) {
|
||||
if ( null == create ) {
|
||||
if ( checkWarnNoDict( nli ) ) {
|
||||
makeNewNetGame( nli );
|
||||
}
|
||||
} else {
|
||||
String msg = getString( R.string.dup_game_queryf, nli.room );
|
||||
String msg = getString( R.string.dup_game_queryf,
|
||||
create.toString() );
|
||||
m_netLaunchInfo = nli;
|
||||
showConfirmThen( msg, NEW_NET_GAME_ACTION );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue