mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-09 22:00:39 +01:00
Offer to delete finished games
This commit is contained in:
parent
9804594237
commit
c22526b1f7
8 changed files with 73 additions and 42 deletions
|
@ -1107,6 +1107,17 @@ public class BoardDelegate extends DelegateBase
|
|||
showArchiveNA( false );
|
||||
break;
|
||||
|
||||
case DELETE_ACTION:
|
||||
if ( 0 < params.length && (Boolean)params[0] ) {
|
||||
deleteAndClose();
|
||||
} else {
|
||||
makeConfirmThenBuilder( R.string.confirm_delete,
|
||||
Action.DELETE_ACTION )
|
||||
.setParams(true)
|
||||
.show();
|
||||
}
|
||||
break;
|
||||
|
||||
case LAUNCH_INVITE_ACTION:
|
||||
for ( Object obj : params ) {
|
||||
if ( obj instanceof CommsAddrRec ) {
|
||||
|
|
|
@ -83,6 +83,7 @@ public class DlgDelegate {
|
|||
ARCHIVE_SEL_ACTION, // archive was clicked
|
||||
ARCHIVE_ACTION,
|
||||
REMATCH_ACTION,
|
||||
DELETE_ACTION,
|
||||
|
||||
// Dict Browser
|
||||
FINISH_ACTION,
|
||||
|
|
|
@ -95,8 +95,6 @@ public class EnableSMSAlert extends DlgDelegateAlert {
|
|||
private void checkEnableButton( AlertDialog dialog )
|
||||
{
|
||||
boolean enabled = 0 < mSpinner.getSelectedItemPosition();
|
||||
((AlertDialog)dialog)
|
||||
.getButton( AlertDialog.BUTTON_POSITIVE )
|
||||
.setEnabled( enabled );
|
||||
Utils.enableAlertButton( dialog, AlertDialog.BUTTON_POSITIVE, enabled );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.eehouse.android.xw4.jni.GameSummary;
|
|||
import org.eehouse.android.xw4.loc.LocUtils;
|
||||
|
||||
public class GameOverAlert extends XWDialogFragment
|
||||
implements DialogInterface.OnClickListener
|
||||
implements DialogInterface.OnClickListener, CompoundButton.OnCheckedChangeListener
|
||||
{
|
||||
private static final String TAG = GameOverAlert.class.getSimpleName();
|
||||
private static final String SUMMARY = "SUMMARY";
|
||||
|
@ -45,14 +45,13 @@ public class GameOverAlert extends XWDialogFragment
|
|||
private static final String MSG = "MSG";
|
||||
private static final String IN_ARCH = "IN_ARCH";
|
||||
|
||||
private AlertDialog m_dialog;
|
||||
private AlertDialog mDialog;
|
||||
private GameSummary mSummary;
|
||||
private int mTitleID;
|
||||
private String mMsg;
|
||||
private ViewGroup m_view;
|
||||
private ViewGroup mView;
|
||||
private boolean mInArchive;
|
||||
private CheckBox mArchiveBox;
|
||||
// private boolean mArchiveChecked;
|
||||
|
||||
public static GameOverAlert newInstance( GameSummary summary,
|
||||
int titleID, String msg,
|
||||
|
@ -95,42 +94,52 @@ public class GameOverAlert extends XWDialogFragment
|
|||
mInArchive = sis.getBoolean( IN_ARCH );
|
||||
|
||||
Activity activity = getActivity();
|
||||
m_view = (ViewGroup)LocUtils.inflate( activity, R.layout.game_over );
|
||||
mView = (ViewGroup)LocUtils.inflate( activity, R.layout.game_over );
|
||||
initView();
|
||||
|
||||
AlertDialog.Builder ab = LocUtils.makeAlertBuilder( activity )
|
||||
.setTitle( mTitleID )
|
||||
.setView( m_view )
|
||||
.setView( mView )
|
||||
.setPositiveButton( android.R.string.ok, this )
|
||||
.setNeutralButton( R.string.button_rematch, this )
|
||||
.setNegativeButton( R.string.button_delete, this )
|
||||
;
|
||||
|
||||
m_dialog = ab.create();
|
||||
Log.d( TAG, "onCreateDialog() => %s", m_dialog );
|
||||
return m_dialog;
|
||||
mDialog = ab.create();
|
||||
mDialog.setOnShowListener( new DialogInterface.OnShowListener() {
|
||||
@Override
|
||||
public void onShow( DialogInterface dialog ) {
|
||||
boolean nowChecked = mArchiveBox.isChecked();
|
||||
onCheckedChanged( null, nowChecked );
|
||||
}
|
||||
});
|
||||
|
||||
Log.d( TAG, "onCreateDialog() => %s", mDialog );
|
||||
return mDialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getFragTag() { return TAG; }
|
||||
|
||||
// @Override
|
||||
// public void onCheckedChanged( CompoundButton buttonView, boolean isChecked )
|
||||
// {
|
||||
// Log.d( TAG, "onCheckedChanged(%b)", isChecked );
|
||||
// mArchiveChecked = isChecked;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void onClick( DialogInterface dialog, int which )
|
||||
{
|
||||
Action action = null;
|
||||
boolean archiveAfter =
|
||||
((CheckBox)m_view.findViewById(R.id.archive_check))
|
||||
((CheckBox)mView.findViewById(R.id.archive_check))
|
||||
.isChecked();
|
||||
if ( which == AlertDialog.BUTTON_NEUTRAL ) {
|
||||
switch ( which ) {
|
||||
case AlertDialog.BUTTON_NEUTRAL:
|
||||
action = Action.REMATCH_ACTION;
|
||||
} else if ( which == AlertDialog.BUTTON_POSITIVE && archiveAfter ) {
|
||||
action = Action.ARCHIVE_SEL_ACTION;
|
||||
break;
|
||||
case AlertDialog.BUTTON_POSITIVE:
|
||||
if ( archiveAfter ) {
|
||||
action = Action.ARCHIVE_SEL_ACTION;
|
||||
}
|
||||
break;
|
||||
case AlertDialog.BUTTON_NEGATIVE:
|
||||
action = Action.DELETE_ACTION;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( null != action ) {
|
||||
|
@ -143,16 +152,18 @@ public class GameOverAlert extends XWDialogFragment
|
|||
}
|
||||
}
|
||||
|
||||
// private void trySend( Action action, boolean bool )
|
||||
// {
|
||||
// Log.d( TAG, "trySend(%s)", action );
|
||||
// }
|
||||
@Override
|
||||
public void onCheckedChanged( CompoundButton bv, boolean isChecked )
|
||||
{
|
||||
Utils.enableAlertButton( mDialog, AlertDialog.BUTTON_NEGATIVE, !isChecked );
|
||||
}
|
||||
|
||||
private void initView()
|
||||
{
|
||||
((TextView)m_view.findViewById( R.id.msg )).setText( mMsg );
|
||||
((TextView)mView.findViewById( R.id.msg )).setText( mMsg );
|
||||
|
||||
mArchiveBox = (CheckBox)m_view.findViewById( R.id.archive_check );
|
||||
mArchiveBox = (CheckBox)mView.findViewById( R.id.archive_check );
|
||||
mArchiveBox.setOnCheckedChangeListener( this );
|
||||
if ( mInArchive ) {
|
||||
mArchiveBox.setVisibility( View.GONE );
|
||||
}
|
||||
|
|
|
@ -987,9 +987,8 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
|
||||
private void enableMoveGroupButton( DialogInterface dlgi )
|
||||
{
|
||||
((AlertDialog)dlgi)
|
||||
.getButton( AlertDialog.BUTTON_POSITIVE )
|
||||
.setEnabled( 0 <= m_mySIS.groupSelItem );
|
||||
Utils.enableAlertButton( (AlertDialog)dlgi, AlertDialog.BUTTON_POSITIVE,
|
||||
0 <= m_mySIS.groupSelItem );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,7 +23,6 @@ import android.app.AlertDialog;
|
|||
import android.content.Context;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.DialogInterface;
|
||||
import android.widget.Button;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
@ -44,8 +43,8 @@ public class InviteChoicesAlert extends DlgDelegateAlert
|
|||
|
||||
private static WeakReference<InviteChoicesAlert> sSelf;
|
||||
|
||||
private Button mPosButton;
|
||||
private InviteView mInviteView;
|
||||
private AlertDialog mDialog;
|
||||
|
||||
public static InviteChoicesAlert newInstance( DlgState state )
|
||||
{
|
||||
|
@ -182,17 +181,15 @@ public class InviteChoicesAlert extends DlgDelegateAlert
|
|||
@Override
|
||||
AlertDialog create( AlertDialog.Builder builder )
|
||||
{
|
||||
AlertDialog dialog = super.create( builder );
|
||||
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||
mDialog = super.create( builder );
|
||||
mDialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||
@Override
|
||||
public void onShow( DialogInterface diface ) {
|
||||
mPosButton = ((AlertDialog)diface)
|
||||
.getButton( AlertDialog.BUTTON_POSITIVE );
|
||||
enableOkButton();
|
||||
}
|
||||
});
|
||||
|
||||
return dialog;
|
||||
return mDialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -251,8 +248,7 @@ public class InviteChoicesAlert extends DlgDelegateAlert
|
|||
|
||||
private void enableOkButton()
|
||||
{
|
||||
if ( null != mPosButton ) {
|
||||
mPosButton.setEnabled( null != mInviteView.getChoice() );
|
||||
}
|
||||
boolean enable = null != mInviteView.getChoice();
|
||||
Utils.enableAlertButton( mDialog, AlertDialog.BUTTON_POSITIVE, enable );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
package org.eehouse.android.xw4;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
|
@ -48,6 +49,7 @@ import android.view.Menu;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
@ -684,6 +686,15 @@ public class Utils {
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
static void enableAlertButton( AlertDialog dlg, int which, boolean enable )
|
||||
{
|
||||
Button button = dlg.getButton(which);
|
||||
if ( null != button ) {
|
||||
button.setEnabled( enable );
|
||||
}
|
||||
}
|
||||
|
||||
// But see hexArray above
|
||||
private static final String HEX_CHARS = "0123456789ABCDEF";
|
||||
private static char[] HEX_CHARS_ARRAY = HEX_CHARS.toCharArray();
|
||||
|
|
|
@ -1997,6 +1997,10 @@
|
|||
<string name="button_archive">Archive\u200C</string>
|
||||
<string name="checkbox_archive">Move to Archive</string>
|
||||
<string name="group_name_archive">Archive</string>
|
||||
<!-- When you choose "delete" from the game-over dialog, you see
|
||||
this string in a comfirmation dialog -->
|
||||
<string name="confirm_delete">Are you sure you want to delete the
|
||||
current game? \n\n(This action cannot be undone.)</string>
|
||||
<string name="duplicate_group_name_fmt">The group “%1$s” already exists.</string>
|
||||
<string name="button_reconnect">Reconnect</string>
|
||||
<string name="square_tiles">Square rack tiles</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue