From 4e21e40de5f37486a5d9cc6e6c8d06cf574d9912 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 20 Feb 2021 20:31:53 -0800 Subject: [PATCH] tweak buttons and text of invite dialog I want to encourage people not to think there's action to be taken between when they invite and an invitee responds, e.g. to email. So make the "Close Game" button the "positive" one that case. --- .../android/xw4/InvitesNeededAlert.java | 107 ++++++++++-------- .../app/src/main/res/values/strings.xml | 64 +++++------ 2 files changed, 90 insertions(+), 81 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/InvitesNeededAlert.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/InvitesNeededAlert.java index 57c19da6f..efbe3d0e1 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/InvitesNeededAlert.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/InvitesNeededAlert.java @@ -140,9 +140,10 @@ class InvitesNeededAlert { State state = (State)params[0]; AlertDialog.Builder ab = mDelegate.makeAlertBuilder(); mAlert = alert; + int[] closeLoc = { AlertDialog.BUTTON_NEGATIVE }; if ( state.mIsServer ) { - makeImplHost( ab, callbacks, alert, state ); + makeImplHost( ab, callbacks, alert, state, closeLoc ); } else { makeImplGuest( ab, state ); } @@ -156,14 +157,22 @@ class InvitesNeededAlert { } } ); - - alert.setNoDismissListenerNeg( ab, R.string.button_close_game, - new OnClickListener() { - @Override - public void onClick( DialogInterface dlg, int item ) { - callbacks.onCloseClicked(); - } - } ); + OnClickListener onClose = new OnClickListener() { + @Override + public void onClick( DialogInterface dlg, int item ) { + callbacks.onCloseClicked(); + } + }; + switch ( closeLoc[0] ) { + case AlertDialog.BUTTON_NEGATIVE: + alert.setNoDismissListenerNeg( ab, R.string.button_close_game, onClose ); + break; + case AlertDialog.BUTTON_POSITIVE: + alert.setNoDismissListenerPos( ab, R.string.button_close_game, onClose ); + break; + default: + Assert.failDbg(); + } Dialog result = ab.create(); result.setCanceledOnTouchOutside( false ); @@ -186,13 +195,18 @@ class InvitesNeededAlert { } private void makeImplHost( AlertDialog.Builder ab, final Callbacks callbacks, - DBAlert alert, State state ) + DBAlert alert, State state, int[] closeLoc ) { Context context = mDelegate.getActivity(); - String title; - - boolean isRematch = state.mIsRematch; final int nPlayersMissing = state.mNPlayersMissing; + + long rowid = callbacks.getRowID(); + SentInvitesInfo sentInfo = DBUtils.getInvitesFor( context, rowid ); + int nSent = sentInfo.getMinPlayerCount(); + boolean invitesNeeded = nPlayersMissing > nSent; + + String title; + boolean isRematch = state.mIsRematch; if ( isRematch ) { title = LocUtils.getString( context, R.string.waiting_rematch_title ); } else { @@ -200,43 +214,40 @@ class InvitesNeededAlert { .getQuantityString( context, R.plurals.waiting_title_fmt, nPlayersMissing, nPlayersMissing ); } + ab.setTitle( title ); - String message = LocUtils - .getQuantityString( context, R.plurals.invite_msg_fmt, - nPlayersMissing, nPlayersMissing ); - message += "\n\n" - + LocUtils.getString( context, R.string.invite_msg_extra ); - - if ( isRematch ) { - message += "\n\n" - + LocUtils.getString( context, R.string.invite_msg_extra_rematch ); - } - - ab.setTitle( title ) - .setMessage( message ); - - alert.setNoDismissListenerPos( ab, R.string.newgame_invite, - new OnClickListener() { - @Override - public void onClick( DialogInterface dlg, int item ) { - callbacks.onInviteClicked(); - } - } ); - - if ( BuildConfig.NON_RELEASE ) { - long rowid = callbacks.getRowID(); - SentInvitesInfo sentInfo = DBUtils.getInvitesFor( context, rowid ); - int nSent = sentInfo.getMinPlayerCount(); - boolean invitesSent = nSent >= nPlayersMissing; - if ( invitesSent ) { - alert.setNoDismissListenerNeut( ab, R.string.newgame_invite_more, - new OnClickListener() { - @Override - public void onClick( DialogInterface dlg, int item ) { - callbacks.onInfoClicked(); - } - } ); + String message; + int inviteButtonTxt; + if ( invitesNeeded ) { + Assert.assertTrueNR( !isRematch ); + message = LocUtils.getString( context, R.string.invites_unsent ); + inviteButtonTxt = R.string.newgame_invite; + } else { + message = LocUtils + .getQuantityString( context, R.plurals.invite_msg_fmt, // here + nPlayersMissing, nPlayersMissing ); + if ( isRematch ) { + message += "\n\n" + + LocUtils.getString( context, R.string.invite_msg_extra_rematch ); } + inviteButtonTxt = R.string.newgame_reinvite; + } + ab.setMessage( message ); + + // If user needs to act, emphasize that by having the positive button + // be Invite. If not, have the positive button be Close + OnClickListener onInvite = new OnClickListener() { + @Override + public void onClick( DialogInterface dlg, int item ) { + callbacks.onInviteClicked(); + } + }; + + if ( invitesNeeded ) { + alert.setNoDismissListenerPos( ab, inviteButtonTxt, onInvite ); + } else { + alert.setNoDismissListenerNeg( ab, inviteButtonTxt, onInvite ); + closeLoc[0] = DialogInterface.BUTTON_POSITIVE; } } } diff --git a/xwords4/android/app/src/main/res/values/strings.xml b/xwords4/android/app/src/main/res/values/strings.xml index 9ab643a75..660a33dd0 100644 --- a/xwords4/android/app/src/main/res/values/strings.xml +++ b/xwords4/android/app/src/main/res/values/strings.xml @@ -453,51 +453,48 @@ (No moves yet) + up, then IF nobody's been invited (the initial case) the user + needs to invite. But once that's done, there's nothing to do + until recipients respond. So there are two messages for the + two cases. This is the first--> + This game is configured to expect a + remote player. + \n\nWould you like to invite someone? + + This game is waiting for one remote - player to respond to an invitation. + player to receive and respond to an invitation. + + \n\nYou will see this message until the invited player has + responded. If you suspect the invitation you sent was lost, + there’s no harm in sending another. + This game is waiting for %1$d remote - players to repond to invitations. + players to repond to invitations. + + \n\nYou will see this message until all expected players have + responded. If you suspect any invitations you sent were lost, + there’s no harm in sending more. - You will see this message until - all expected players have connected. If you’ve already sent an - invitation and suspect it was lost, there’s no harm in sending - another. + With rematches, all necessary invitations will have been sent automatically. But you can always send new ones if an invitee is not responding. - - - - - - - - - - - - - - - - Or just Tap to Invite -- if the other - device also has Android Beaming and is nearby. + + - \u0020(You are expecting multiple - remote players. You don’t have to invite them all at once, but - this alert will not be dismissed until everybody has been invited - and all invitations have been accepted.) + + + + Invite sent via Data SMS to phone number %1$s on %2$s Invite sent via SMS on %1$s @@ -1008,6 +1005,7 @@ it immediately because an email or messaging app will be launched to send your invitation. --> Invite now + Invite again Invite %1$s History