mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-22 07:28:16 +01:00
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:
parent
da1c3f992a
commit
39dbe67929
2 changed files with 40 additions and 17 deletions
|
@ -206,23 +206,16 @@ 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
|
// If we're not already in the "archive" group, offer to move
|
||||||
final String archiveName = LocUtils
|
if ( !inArchiveGroup() ) {
|
||||||
.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() {
|
lstnr = new OnClickListener() {
|
||||||
public void onClick( DialogInterface dlg,
|
public void onClick( DialogInterface dlg,
|
||||||
int whichButton ) {
|
int whichButton ) {
|
||||||
makeNotAgainBuilder( R.string.not_again_archive,
|
showArchiveNA();
|
||||||
R.string.key_na_archive,
|
|
||||||
Action.ARCHIVE_ACTION )
|
|
||||||
.setParams( archiveName, archiveGroup )
|
|
||||||
.show();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ab.setNeutralButton( R.string.button_archive, lstnr );
|
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 )
|
||||||
|
@ -847,6 +840,9 @@ public class BoardDelegate extends DelegateBase
|
||||||
enable = m_gameOver && rematchSupported( false );
|
enable = m_gameOver && rematchSupported( false );
|
||||||
Utils.setItemVisible( menu, R.id.board_menu_rematch, enable );
|
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
|
boolean netGame = null != m_gi
|
||||||
&& DeviceRole.SERVER_STANDALONE != m_gi.serverRole;
|
&& DeviceRole.SERVER_STANDALONE != m_gi.serverRole;
|
||||||
Utils.setItemVisible( menu, R.id.gamel_menu_checkmoves, netGame );
|
Utils.setItemVisible( menu, R.id.gamel_menu_checkmoves, netGame );
|
||||||
|
@ -890,6 +886,10 @@ public class BoardDelegate extends DelegateBase
|
||||||
doRematchIf();
|
doRematchIf();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case R.id.board_menu_archive:
|
||||||
|
showArchiveNA();
|
||||||
|
break;
|
||||||
|
|
||||||
case R.id.board_menu_trade_commit:
|
case R.id.board_menu_trade_commit:
|
||||||
cmd = JNICmd.CMD_COMMIT;
|
cmd = JNICmd.CMD_COMMIT;
|
||||||
break;
|
break;
|
||||||
|
@ -1112,9 +1112,7 @@ public class BoardDelegate extends DelegateBase
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ARCHIVE_ACTION:
|
case ARCHIVE_ACTION:
|
||||||
String archiveName = (String)params[0];
|
archiveAndClose();
|
||||||
long archiveGroup = (Long)params[1];
|
|
||||||
archiveAndClose( archiveName, archiveGroup );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ENABLE_SMS_DO:
|
case ENABLE_SMS_DO:
|
||||||
|
@ -2600,12 +2598,33 @@ public class BoardDelegate extends DelegateBase
|
||||||
return wordsArray;
|
return wordsArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void archiveAndClose( String archiveName, long groupID )
|
private boolean inArchiveGroup()
|
||||||
{
|
{
|
||||||
if ( DBUtils.GROUPID_UNSPEC == groupID ) {
|
String archiveName = LocUtils
|
||||||
groupID = DBUtils.addGroup( m_activity, archiveName );
|
.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 );
|
waitCloseGame( false );
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
<group android:id="@+id/group_done">
|
<group android:id="@+id/group_done">
|
||||||
<!-- title set in BoardActivity -->
|
<!-- 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"
|
<item android:id="@+id/board_menu_rematch"
|
||||||
android:title="@string/button_rematch"
|
android:title="@string/button_rematch"
|
||||||
android:showAsAction="ifRoom"
|
android:showAsAction="ifRoom"
|
||||||
|
|
Loading…
Reference in a new issue