mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-11 08:48:06 +01:00
put invite/wait alert on back stack
Add to DldID the ability to specify whether dialog fragments bearing that id go on the back stack. Set INVITE alerts (only) to use that mechanism. Having them on the back stack seems to be required by their buttons being hacked to not dismiss them, which in turn is required because I want them to stick around underneath other alerts their buttons launch.
This commit is contained in:
parent
e12c303f0c
commit
52ea395ad6
6 changed files with 34 additions and 16 deletions
|
@ -2804,8 +2804,10 @@ public class BoardDelegate extends DelegateBase
|
|||
DBUtils.recordInviteSent( m_activity, m_rowid, means, dev );
|
||||
|
||||
if ( !invitesSent ) {
|
||||
m_inviteAlert.dismiss();
|
||||
m_inviteAlert = null;
|
||||
if ( null != m_inviteAlert ) {
|
||||
m_inviteAlert.dismiss();
|
||||
m_inviteAlert = null;
|
||||
}
|
||||
Log.d( TAG, "recordInviteSent(): redoing invite alert" );
|
||||
showInviteAlertIf();
|
||||
}
|
||||
|
|
|
@ -72,6 +72,13 @@ public class DBAlert extends XWDialogFragment {
|
|||
return mDlgID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean belongsOnBackStack()
|
||||
{
|
||||
boolean result = getDlgID().belongsOnBackStack();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragTag()
|
||||
{
|
||||
|
|
|
@ -88,6 +88,13 @@ abstract class DlgDelegateAlert extends XWDialogFragment {
|
|||
return getState(null).m_id.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean belongsOnBackStack()
|
||||
{
|
||||
boolean result = getState(null).m_id.belongsOnBackStack();
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void checkNotAgainCheck( DlgState state, NotAgainView naView )
|
||||
{
|
||||
if ( null != naView && naView.getChecked() ) {
|
||||
|
|
|
@ -32,7 +32,7 @@ public enum DlgID {
|
|||
, DICT_OR_DECLINE
|
||||
, DLG_CONNSTAT
|
||||
, DLG_DELETED
|
||||
, DLG_INVITE
|
||||
, DLG_INVITE(true)
|
||||
, DLG_OKONLY
|
||||
, ENABLE_NFC
|
||||
, FORCE_REMOTE
|
||||
|
@ -68,4 +68,10 @@ public enum DlgID {
|
|||
, GAMES_LIST_NEWGAME
|
||||
, CHANGE_CONN
|
||||
, GAMES_LIST_NAME_REMATCH
|
||||
;
|
||||
|
||||
private boolean m_addToStack;
|
||||
private DlgID(boolean addToStack) { m_addToStack = addToStack; }
|
||||
private DlgID() { m_addToStack = false; }
|
||||
boolean belongsOnBackStack() { return m_addToStack; }
|
||||
}
|
||||
|
|
|
@ -51,7 +51,8 @@ public class XWActivity extends FragmentActivity
|
|||
protected void onCreate( Bundle savedInstanceState, DelegateBase dlgt )
|
||||
{
|
||||
if ( XWApp.LOG_LIFECYLE ) {
|
||||
Log.i( TAG, "onCreate(this=%H)", this );
|
||||
Log.i( TAG, "%s.onCreate(this=%H,sis=%s)", getClass().getSimpleName(),
|
||||
this, savedInstanceState );
|
||||
}
|
||||
super.onCreate( savedInstanceState );
|
||||
m_dlgt = dlgt;
|
||||
|
@ -285,25 +286,18 @@ public class XWActivity extends FragmentActivity
|
|||
{
|
||||
FragmentManager fm = getSupportFragmentManager();
|
||||
String tag = df.getFragTag();
|
||||
if ( true ) {
|
||||
df.show( fm, tag );
|
||||
} else {
|
||||
Log.d( TAG, "%s.show(%s) called; tag: %s", getClass().getSimpleName(),
|
||||
df.getClass().getSimpleName(), tag );
|
||||
// Log.d( TAG, "show(%s); tag: %s", df.getClass().getSimpleName(), tag );
|
||||
if ( df.belongsOnBackStack() ) {
|
||||
FragmentTransaction trans = fm.beginTransaction();
|
||||
|
||||
Fragment prev = fm.findFragmentByTag( tag );
|
||||
if ( null != prev && prev instanceof DialogFragment ) {
|
||||
Log.d( TAG, "show(): removing %s (tag %s)",
|
||||
prev.getClass().getSimpleName(), tag );
|
||||
((DialogFragment)prev).dismiss();
|
||||
} else {
|
||||
Log.d( TAG, "show(): NOT removing or didn't find for tag %s)", tag );
|
||||
}
|
||||
trans.addToBackStack( tag );
|
||||
|
||||
// Create and show the dialog. show() commits the transaction
|
||||
df.show( trans, tag );
|
||||
} else {
|
||||
df.show( fm, tag );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,8 @@ abstract class XWDialogFragment extends DialogFragment {
|
|||
void onCancelled( XWDialogFragment frag );
|
||||
}
|
||||
|
||||
abstract String getFragTag();
|
||||
|
||||
@Override
|
||||
public void onResume()
|
||||
{
|
||||
|
@ -90,7 +92,7 @@ abstract class XWDialogFragment extends DialogFragment {
|
|||
}
|
||||
}
|
||||
|
||||
abstract String getFragTag();
|
||||
public boolean belongsOnBackStack() { return false; }
|
||||
|
||||
protected void setOnDismissListener( OnDismissListener lstnr )
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue