add archive menuitem

As with Rematch, you should have the option once you've dismissed the
special alert that comes up when finished games are opened.
This commit is contained in:
Eric House 2017-12-16 08:06:20 -08:00
parent da1c3f992a
commit 39dbe67929
2 changed files with 40 additions and 17 deletions

View file

@ -206,23 +206,16 @@ public class BoardDelegate extends DelegateBase
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 ) {
if ( !inArchiveGroup() ) {
lstnr = new OnClickListener() {
public void onClick( DialogInterface dlg,
int whichButton ) {
makeNotAgainBuilder( R.string.not_again_archive,
R.string.key_na_archive,
Action.ARCHIVE_ACTION )
.setParams( archiveName, archiveGroup )
.show();
showArchiveNA();
}
};
ab.setNeutralButton( R.string.button_archive, lstnr );
}
} else if ( DlgID.DLG_CONNSTAT == dlgID
&& BuildConfig.DEBUG && null != m_connTypes
&& (m_connTypes.contains( CommsConnType.COMMS_CONN_RELAY )
@ -847,6 +840,9 @@ public class BoardDelegate extends DelegateBase
enable = m_gameOver && rematchSupported( false );
Utils.setItemVisible( menu, R.id.board_menu_rematch, enable );
enable = m_gameOver && !inArchiveGroup();
Utils.setItemVisible( menu, R.id.board_menu_archive, enable );
boolean netGame = null != m_gi
&& DeviceRole.SERVER_STANDALONE != m_gi.serverRole;
Utils.setItemVisible( menu, R.id.gamel_menu_checkmoves, netGame );
@ -890,6 +886,10 @@ public class BoardDelegate extends DelegateBase
doRematchIf();
break;
case R.id.board_menu_archive:
showArchiveNA();
break;
case R.id.board_menu_trade_commit:
cmd = JNICmd.CMD_COMMIT;
break;
@ -1112,9 +1112,7 @@ public class BoardDelegate extends DelegateBase
break;
case ARCHIVE_ACTION:
String archiveName = (String)params[0];
long archiveGroup = (Long)params[1];
archiveAndClose( archiveName, archiveGroup );
archiveAndClose();
break;
case ENABLE_SMS_DO:
@ -2600,12 +2598,33 @@ public class BoardDelegate extends DelegateBase
return wordsArray;
}
private void archiveAndClose( String archiveName, long groupID )
private boolean inArchiveGroup()
{
if ( DBUtils.GROUPID_UNSPEC == groupID ) {
groupID = DBUtils.addGroup( m_activity, archiveName );
String archiveName = LocUtils
.getString( m_activity, R.string.group_name_archive );
long archiveGroup = DBUtils.getGroup( m_activity, archiveName );
long curGroup = DBUtils.getGroupForGame( m_activity, m_rowid );
return curGroup == archiveGroup;
}
private void showArchiveNA()
{
makeNotAgainBuilder( R.string.not_again_archive,
R.string.key_na_archive,
Action.ARCHIVE_ACTION )
.show();
}
private void archiveAndClose()
{
String archiveName = LocUtils
.getString( m_activity, R.string.group_name_archive );
long archiveGroupID = DBUtils.getGroup( m_activity, archiveName );
if ( DBUtils.GROUPID_UNSPEC == archiveGroupID ) {
archiveGroupID = DBUtils.addGroup( m_activity, archiveName );
}
DBUtils.moveGame( m_activity, m_rowid, groupID );
DBUtils.moveGame( m_activity, m_rowid, archiveGroupID );
waitCloseGame( false );
finish();
}

View file

@ -5,6 +5,10 @@
<group android:id="@+id/group_done">
<!-- title set in BoardActivity -->
<item android:id="@+id/board_menu_archive"
android:title="@string/button_archive"
android:showAsAction="ifRoom"
/>
<item android:id="@+id/board_menu_rematch"
android:title="@string/button_rematch"
android:showAsAction="ifRoom"