From a58048e9ebadb8aecb5c2366a7b4d36921269fca Mon Sep 17 00:00:00 2001 From: Eric House Date: Sun, 15 Nov 2020 14:17:00 -0800 Subject: [PATCH] get rid of boolean meant to prevent duplicate invite alerts It was preventing even one and seems no longer to be necessary. --- .../eehouse/android/xw4/BoardDelegate.java | 41 ++++++++++++------- .../org/eehouse/android/xw4/GameUtils.java | 20 +++------ .../android/xw4/GamesListDelegate.java | 13 ++---- .../org/eehouse/android/xw4/Quarantine.java | 2 + .../app/src/main/res/values/strings.xml | 3 ++ 5 files changed, 40 insertions(+), 39 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java index 7b1c968b7..4c02e9b40 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java @@ -125,7 +125,6 @@ public class BoardDelegate extends DelegateBase private JNIThread.GameStateInfo m_gsi; private int m_nGuestDevs = -1; - private boolean m_haveInvited = false; private boolean m_showedReInvite; private boolean m_overNotShown; private boolean m_dropRelayOnDismiss; @@ -637,7 +636,6 @@ public class BoardDelegate extends DelegateBase Bundle args = getArguments(); m_rowid = args.getLong( GameUtils.INTENT_KEY_ROWID, -1 ); Log.i( TAG, "opening rowid %d", m_rowid ); - m_haveInvited = args.getBoolean( GameUtils.INVITED, false ); m_overNotShown = true; } // init @@ -849,11 +847,20 @@ public class BoardDelegate extends DelegateBase @Override protected void setTitle() { - String title = GameUtils.getName( m_activity, m_rowid ); - if ( null != m_gi && m_gi.inDuplicateMode ) { - title = LocUtils.getString( m_activity, R.string.dupe_title_fmt, title ); - } - setTitle( title ); + runOnUiThread( new Runnable() { + @Override + public void run() { + String title = GameUtils.getName( m_activity, m_rowid ); + if ( 0 < m_mySIS.nMissing ) { + title = LocUtils.getString( m_activity, R.string.title_missing_fmt, + title, m_mySIS.nMissing ); + } + if ( null != m_gi && m_gi.inDuplicateMode ) { + title = LocUtils.getString( m_activity, R.string.dupe_title_fmt, title ); + } + setTitle( title ); + } + } ); } private void initToolbar() @@ -1727,7 +1734,7 @@ public class BoardDelegate extends DelegateBase finish(); - GameUtils.launchGame( getDelegator(), m_rowid, m_haveInvited ); + GameUtils.launchGame( getDelegator(), m_rowid ); } private void setGotGameDict( String getDict ) @@ -1737,7 +1744,7 @@ public class BoardDelegate extends DelegateBase String msg = getString( R.string.reload_new_dict_fmt, getDict ); showToast( msg ); finish(); - GameUtils.launchGame( getDelegator(), m_rowid, false ); + GameUtils.launchGame( getDelegator(), m_rowid ); } private XwJNI.XP_Key keyCodeToXPKey( int keyCode ) @@ -1794,11 +1801,9 @@ public class BoardDelegate extends DelegateBase skipDismiss = !tryRematchInvites( false ); } else if ( m_summary.hasInviteInfo() ) { skipDismiss = !tryOtherInvites(); - } else if ( !m_haveInvited ) { - m_haveInvited = true; - showInviteAlertIf(); - invalidateOptionsMenuIf(); + } else if ( showInviteAlertIf() ) { skipDismiss = true; + invalidateOptionsMenuIf(); } else { toastStr = getQuantityString( R.plurals.msg_relay_waiting_fmt, nMissing, devOrder, room, nMissing ); @@ -1828,6 +1833,7 @@ public class BoardDelegate extends DelegateBase } invalidateOptionsMenuIf(); + setTitle(); } // handleConndMessage private class BoardUtilCtxt extends UtilCtxtImpl { @@ -2023,6 +2029,7 @@ public class BoardDelegate extends DelegateBase post( new Runnable() { @Override public void run() { + setTitle(); makeNotAgainBuilder( R.string.not_again_turnchanged, R.string.key_notagain_turnchanged ) .show(); @@ -2165,10 +2172,11 @@ public class BoardDelegate extends DelegateBase m_nGuestDevs = nDevs; m_mySIS.nMissing = nMissing; // will be 0 unless isServer is true + setTitle(); if ( null != connTypes && 0 == connTypes.size() ) { askNoAddrsDelete(); - } else if ( 0 < nMissing && isServer && !m_haveInvited ) { + } else if ( 0 < nMissing && isServer ) { doDismiss = false; post( new Runnable() { @Override @@ -2679,8 +2687,9 @@ public class BoardDelegate extends DelegateBase // This is failing sometimes, and so the null == m_inviteAlert test means // we never post it. BUT on a lot of devices without the test we wind up // trying over and over to put the thing up. - private void showInviteAlertIf() + private boolean showInviteAlertIf() { + boolean success = false; DbgUtils.assertOnUIThread(); if ( alertOrderAt( StartAlertOrder.INVITE ) ) { if ( ! m_haveStartedShowing && null == m_inviteAlert @@ -2694,10 +2703,12 @@ public class BoardDelegate extends DelegateBase ias.nMissing = m_mySIS.nMissing; showDialogFragment( DlgID.DLG_INVITE, ias ); m_haveStartedShowing = true; + success = true; } else { alertOrderIncrIfAt( StartAlertOrder.INVITE ); } } + return success; } private boolean doZoom( int zoomBy ) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameUtils.java index eeb547b27..725bd2f51 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameUtils.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameUtils.java @@ -63,7 +63,6 @@ import java.util.Map; public class GameUtils { private static final String TAG = GameUtils.class.getSimpleName(); - public static final String INVITED = "invited"; public static final String INTENT_KEY_ROWID = "rowid"; interface ResendDoneProc { @@ -943,26 +942,22 @@ public class GameUtils { return file.endsWith( XWConstants.GAME_EXTN ); } - private static Bundle makeLaunchExtras( long rowid, boolean invited ) + private static Bundle makeLaunchExtras( long rowid ) { Bundle bundle = new Bundle(); bundle.putLong( INTENT_KEY_ROWID, rowid ); - if ( invited ) { - bundle.putBoolean( INVITED, true ); - } return bundle; } - public static void launchGame( Delegator delegator, long rowid, - boolean invited ) + public static void launchGame( Delegator delegator, long rowid ) { - launchGame( delegator, rowid, invited, null ); + launchGame( delegator, rowid, null ); } public static void launchGame( Delegator delegator, long rowid, - boolean invited, Bundle moreExtras ) + Bundle moreExtras ) { - Bundle extras = makeLaunchExtras( rowid, invited ); + Bundle extras = makeLaunchExtras( rowid ); if ( null != moreExtras ) { extras.putAll( moreExtras ); } @@ -977,11 +972,6 @@ public class GameUtils { } } - public static void launchGame( Delegator delegator, long rowid ) - { - launchGame( delegator, rowid, false ); - } - private static class FeedUtilsImpl extends UtilCtxtImpl { private Context m_context; private long m_rowid; diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java index 08698bf37..68c39999c 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java @@ -2797,7 +2797,7 @@ public class GamesListDelegate extends ListDelegateBase return madeGame; } - private void launchGame( long rowid, boolean invited, Bundle extras ) + private void launchGame( long rowid, Bundle extras ) { if ( DBUtils.ROWID_NOTFOUND == rowid ) { Log.d( TAG, "launchGame(): dropping bad rowid" ); @@ -2806,25 +2806,20 @@ public class GamesListDelegate extends ListDelegateBase if ( m_adapter.inExpandedGroup( rowid ) ) { setSelGame( rowid ); } - GameUtils.launchGame( getDelegator(), rowid, invited, extras ); + GameUtils.launchGame( getDelegator(), rowid, extras ); } } private void launchGame( long rowid ) { - launchGame( rowid, false, null ); - } - - private void launchGame( long rowid, Bundle extras ) - { - launchGame( rowid, false, extras ); + launchGame( rowid, null ); } private void makeNewNetGame( NetLaunchInfo nli ) { long rowid = DBUtils.ROWID_NOTFOUND; rowid = GameUtils.makeNewMultiGame( m_activity, nli ); - launchGame( rowid, true, null ); + launchGame( rowid, null ); } private void tryStartsFromIntent( Intent intent ) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Quarantine.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Quarantine.java index e4ca51ba0..d47571b20 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Quarantine.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Quarantine.java @@ -51,6 +51,8 @@ public class Quarantine { if ( !result ) { Log.d( TAG, "safeToOpen(%d) => %b (count=%d)", rowid, result, count ); if ( BuildConfig.NON_RELEASE ) { + Log.d( TAG, "printing calling stack:" ); + DbgUtils.printStack( TAG ); List list = get().listFor( rowid ); for ( int ii = 0; ii < list.size(); ++ii ) { StackTraceElement[] trace = list.get( ii ); diff --git a/xwords4/android/app/src/main/res/values/strings.xml b/xwords4/android/app/src/main/res/values/strings.xml index a5c96dace..42f7a7b73 100644 --- a/xwords4/android/app/src/main/res/values/strings.xml +++ b/xwords4/android/app/src/main/res/values/strings.xml @@ -2674,4 +2674,7 @@ Choose your opponent + + %1$s (missing %2$d)