mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +01:00
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.
This commit is contained in:
parent
014cafe67e
commit
4e21e40de5
2 changed files with 90 additions and 81 deletions
|
@ -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() {
|
||||
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,
|
||||
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 );
|
||||
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 );
|
||||
}
|
||||
inviteButtonTxt = R.string.newgame_reinvite;
|
||||
}
|
||||
ab.setMessage( message );
|
||||
|
||||
ab.setTitle( title )
|
||||
.setMessage( message );
|
||||
|
||||
alert.setNoDismissListenerPos( ab, R.string.newgame_invite,
|
||||
new OnClickListener() {
|
||||
// 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 ( 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();
|
||||
}
|
||||
} );
|
||||
}
|
||||
if ( invitesNeeded ) {
|
||||
alert.setNoDismissListenerPos( ab, inviteButtonTxt, onInvite );
|
||||
} else {
|
||||
alert.setNoDismissListenerNeg( ab, inviteButtonTxt, onInvite );
|
||||
closeLoc[0] = DialogInterface.BUTTON_POSITIVE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -453,51 +453,48 @@
|
|||
<string name="no_moves_made">(No moves yet)</string>
|
||||
<!-- If a networked game is opened and is not complete, i.e. if it
|
||||
is listed as expecting remote players who have not yet shown
|
||||
up, then the most likely explanation is that none has been
|
||||
invited. (It's also possible that an invitation has been
|
||||
sent, but I have no way of knowing that.) So every time I
|
||||
open such a game I give the user a chance to issue an
|
||||
invititation while trying to warn him not to send duplicates.
|
||||
The number of players missing is substituted for "%1$d". -->
|
||||
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-->
|
||||
<string name="invites_unsent">This game is configured to expect a
|
||||
remote player.
|
||||
\n\nWould you like to invite someone?</string>
|
||||
|
||||
<!-- This is the second: invitations have been sent but players
|
||||
are still missing. -->
|
||||
<plurals name="invite_msg_fmt">
|
||||
<item quantity="one">This game is waiting for one remote
|
||||
player to respond to an invitation.</item>
|
||||
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.</item>
|
||||
|
||||
<item quantity="other">This game is waiting for %1$d remote
|
||||
players to repond to invitations.</item>
|
||||
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.</item>
|
||||
</plurals>
|
||||
<string name="invite_msg_extra">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.</string>
|
||||
|
||||
<string name="invite_msg_extra_rematch">With rematches, all
|
||||
necessary invitations will have been sent automatically. But you
|
||||
can always send new ones if an invitee is not responding.</string>
|
||||
<!-- <plurals name="invite_sent_fmt"> -->
|
||||
<!-- <item quantity="one">You have already invited a remote player to -->
|
||||
<!-- this game. We are waiting for him/her to respond. Please -->
|
||||
<!-- use the re-invite button if you think the invitation did not go -->
|
||||
<!-- out.</item> -->
|
||||
<!-- <item quantity="other">You have already sent %1$d unique -->
|
||||
<!-- invitations for this game. We are waiting for %2$d of the -->
|
||||
<!-- recipients to respond. Please use the re-invite button if you -->
|
||||
<!-- think the invitations did not go out.</item> -->
|
||||
<!-- </plurals> -->
|
||||
<!-- <string name="invited_msg">This game was created from an -->
|
||||
<!-- invitation you received. As soon as it is able to connect to the -->
|
||||
<!-- sender and any other invitees have arrived play will -->
|
||||
<!-- begin.</string> -->
|
||||
<!-- Appended to message above if local device has NFC available -->
|
||||
<string name="invite_if_nfc">Or just Tap to Invite -- if the other
|
||||
device also has Android Beaming and is nearby.</string>
|
||||
<!-- Appended to message above if local device has NFC
|
||||
available. But not used right now -->
|
||||
<!--string name="invite_if_nfc">Or just Tap to Invite - if the other
|
||||
device also has Android Beaming and is nearby.</string-->
|
||||
<!-- Most users create games with only two players, which is the
|
||||
default, but CrossWords supports up to four. When I'm using
|
||||
the above string to encourage the opener of a game missing
|
||||
players to invite, IF the number of missing players is
|
||||
greater than one this text is appended to the above. -->
|
||||
<string name="invite_multiple">\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.)</string>
|
||||
<!-- <string name="invite_multiple">\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.)</string> -->
|
||||
<string name="invit_expl_sms_fmt">Invite sent via Data SMS to phone
|
||||
number %1$s on %2$s</string>
|
||||
<string name="invit_expl_usrsms_fmt">Invite sent via SMS on %1$s</string>
|
||||
|
@ -1008,6 +1005,7 @@
|
|||
it immediately because an email or messaging app will be
|
||||
launched to send your invitation. -->
|
||||
<string name="newgame_invite">Invite now</string>
|
||||
<string name="newgame_reinvite">Invite again</string>
|
||||
<!-- Button offering to invite Known Player to a new game -->
|
||||
<string name="invite_player_fmt">Invite %1$s</string>
|
||||
<string name="newgame_invite_more">History</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue