mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-13 20:48:02 +01:00
add "archive" option to dialog on opening done game
Create the group if needed. Name's not user-editable at this point. Should be a preference, and that preference should be changed if user renames it.
This commit is contained in:
parent
b77ea0aaad
commit
c2eff7d3f2
4 changed files with 59 additions and 5 deletions
|
@ -204,6 +204,21 @@ public class BoardDelegate extends DelegateBase
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ab.setNegativeButton( R.string.button_rematch, lstnr );
|
ab.setNegativeButton( R.string.button_rematch, lstnr );
|
||||||
|
|
||||||
|
// If we're not already in the "archive" group, offer to move
|
||||||
|
final String archiveName = LocUtils
|
||||||
|
.getString( m_activity, R.string.group_name_archive );
|
||||||
|
final long archiveGroup = DBUtils.getGroup( m_activity, archiveName );
|
||||||
|
long curGroup = DBUtils.getGroupForGame( m_activity, m_rowid );
|
||||||
|
if ( curGroup != archiveGroup ) {
|
||||||
|
lstnr = new OnClickListener() {
|
||||||
|
public void onClick( DialogInterface dlg,
|
||||||
|
int whichButton ) {
|
||||||
|
archiveAndClose( archiveName, archiveGroup );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ab.setNeutralButton( R.string.button_archive, lstnr );
|
||||||
|
}
|
||||||
} else if ( DlgID.DLG_CONNSTAT == dlgID
|
} else if ( DlgID.DLG_CONNSTAT == dlgID
|
||||||
&& BuildConfig.DEBUG && null != m_connTypes
|
&& BuildConfig.DEBUG && null != m_connTypes
|
||||||
&& (m_connTypes.contains( CommsConnType.COMMS_CONN_RELAY )
|
&& (m_connTypes.contains( CommsConnType.COMMS_CONN_RELAY )
|
||||||
|
@ -2575,6 +2590,16 @@ public class BoardDelegate extends DelegateBase
|
||||||
return wordsArray;
|
return wordsArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void archiveAndClose( String archiveName, long groupID )
|
||||||
|
{
|
||||||
|
if ( DBUtils.GROUPID_UNSPEC == groupID ) {
|
||||||
|
groupID = DBUtils.addGroup( m_activity, archiveName );
|
||||||
|
}
|
||||||
|
DBUtils.moveGame( m_activity, m_rowid, groupID );
|
||||||
|
waitCloseGame( false );
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
// For now, supported if standalone or either BT or SMS used for transport
|
// For now, supported if standalone or either BT or SMS used for transport
|
||||||
private boolean rematchSupported( boolean showMulti )
|
private boolean rematchSupported( boolean showMulti )
|
||||||
{
|
{
|
||||||
|
|
|
@ -81,7 +81,9 @@ public class DBUtils {
|
||||||
private static long s_cachedRowID = ROWID_NOTFOUND;
|
private static long s_cachedRowID = ROWID_NOTFOUND;
|
||||||
private static byte[] s_cachedBytes = null;
|
private static byte[] s_cachedBytes = null;
|
||||||
|
|
||||||
public static enum GameChangeType { GAME_CHANGED, GAME_CREATED, GAME_DELETED };
|
public static enum GameChangeType { GAME_CHANGED, GAME_CREATED,
|
||||||
|
GAME_DELETED, GAME_MOVED,
|
||||||
|
};
|
||||||
|
|
||||||
public static interface DBChangeListener {
|
public static interface DBChangeListener {
|
||||||
public void gameSaved( long rowid, GameChangeType change );
|
public void gameSaved( long rowid, GameChangeType change );
|
||||||
|
@ -1701,6 +1703,29 @@ public class DBUtils {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static long getGroup( Context context, String name )
|
||||||
|
{
|
||||||
|
long result = GROUPID_UNSPEC;
|
||||||
|
String[] columns = { ROW_ID };
|
||||||
|
String selection = DBHelper.GROUPNAME + " = ?";
|
||||||
|
String[] selArgs = { name };
|
||||||
|
|
||||||
|
initDB( context );
|
||||||
|
synchronized( s_dbHelper ) {
|
||||||
|
Cursor cursor = s_db.query( DBHelper.TABLE_NAME_GROUPS, columns,
|
||||||
|
selection, selArgs,
|
||||||
|
null, // groupBy
|
||||||
|
null, // having
|
||||||
|
null // orderby
|
||||||
|
);
|
||||||
|
if ( cursor.moveToNext() ) {
|
||||||
|
result = cursor.getLong( cursor.getColumnIndex( ROW_ID ) );
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public static long addGroup( Context context, String name )
|
public static long addGroup( Context context, String name )
|
||||||
{
|
{
|
||||||
long rowid = GROUPID_UNSPEC;
|
long rowid = GROUPID_UNSPEC;
|
||||||
|
@ -1759,13 +1784,14 @@ public class DBUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change group id of a game
|
// Change group id of a game
|
||||||
public static void moveGame( Context context, long gameid, long groupID )
|
public static void moveGame( Context context, long rowid, long groupID )
|
||||||
{
|
{
|
||||||
Assert.assertTrue( GROUPID_UNSPEC != groupID );
|
Assert.assertTrue( GROUPID_UNSPEC != groupID );
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put( DBHelper.GROUPID, groupID );
|
values.put( DBHelper.GROUPID, groupID );
|
||||||
updateRow( context, DBHelper.TABLE_NAME_SUM, gameid, values );
|
updateRow( context, DBHelper.TABLE_NAME_SUM, rowid, values );
|
||||||
invalGroupsCache();
|
invalGroupsCache();
|
||||||
|
notifyListeners( rowid, GameChangeType.GAME_MOVED );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getChatHistoryStr( Context context, long rowid )
|
private static String getChatHistoryStr( Context context, long rowid )
|
||||||
|
|
|
@ -1060,8 +1060,6 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
invalidateOptionsMenuIf();
|
invalidateOptionsMenuIf();
|
||||||
setTitle();
|
setTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
mkListAdapter();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void invalidateOptionsMenuIf()
|
public void invalidateOptionsMenuIf()
|
||||||
|
@ -1133,6 +1131,9 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
mkListAdapter();
|
mkListAdapter();
|
||||||
setSelGame( rowid );
|
setSelGame( rowid );
|
||||||
break;
|
break;
|
||||||
|
case GAME_MOVED:
|
||||||
|
mkListAdapter();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -2158,6 +2158,8 @@
|
||||||
game with the same players and parameters as the one that
|
game with the same players and parameters as the one that
|
||||||
just ended. -->
|
just ended. -->
|
||||||
<string name="button_rematch">Rematch</string>
|
<string name="button_rematch">Rematch</string>
|
||||||
|
<string name="button_archive">Archive\u200C</string>
|
||||||
|
<string name="group_name_archive">Archive</string>
|
||||||
|
|
||||||
<string name="button_reconnect">Reconnect</string>
|
<string name="button_reconnect">Reconnect</string>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue