fix invites dialog to show the right buttons for all cases.

This commit is contained in:
Eric House 2013-11-13 06:52:45 -08:00
parent d119033333
commit 3b3746d2e5
5 changed files with 35 additions and 17 deletions

View file

@ -1181,6 +1181,10 @@
explanation/guidance. -->
<string name="sms_or_email">Send invitation using SMS (texting) or
via email?</string>
<string name="nfc_or_email">Send invitation using NFC (Android
beaming NEW) or via email?</string>
<string name="nfc_or_sms_or_email">Send invitation using SMS
(texting) or NFC (Android beaming NEW) or via email?</string>
<!-- When an invitation is sent, the user gets to choose between
plaintext and html formatting. These two strings are shown in the

View file

@ -499,7 +499,7 @@ public class BoardActivity extends XWActivity
lstnr = new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dialog,
int item ) {
showEmailOrSMSThen( LAUNCH_INVITE_ACTION );
showInviteChoicesThen( LAUNCH_INVITE_ACTION );
}
};
dialog = new AlertDialog.Builder( this )

View file

@ -43,7 +43,7 @@ public class DlgDelegate {
public static final int DIALOG_OKONLY = 2;
public static final int DIALOG_NOTAGAIN = 3;
public static final int CONFIRM_THEN = 4;
public static final int TEXT_OR_HTML_THEN = 5;
public static final int INVITE_CHOICES_THEN = 5;
public static final int DLG_DICTGONE = 6;
public static final int DIALOG_LAST = DLG_DICTGONE;
@ -119,8 +119,8 @@ public class DlgDelegate {
case CONFIRM_THEN:
dialog = createConfirmThenDialog( state, id );
break;
case TEXT_OR_HTML_THEN:
dialog = createHtmlThenDialog( state, id );
case INVITE_CHOICES_THEN:
dialog = createInviteChoicesDialog( state, id );
break;
case DLG_DICTGONE:
dialog = createDictGoneDialog();
@ -219,12 +219,13 @@ public class DlgDelegate {
m_activity.showDialog( CONFIRM_THEN );
}
public void showEmailOrSMSThen( final int callbackID )
public void showInviteChoicesThen( final int callbackID )
{
if ( Utils.deviceSupportsSMS( m_activity ) ) {
DlgState state = new DlgState( TEXT_OR_HTML_THEN, callbackID );
if ( Utils.deviceSupportsSMS( m_activity )
|| NFCUtils.nfcAvail( m_activity ) ) {
DlgState state = new DlgState( INVITE_CHOICES_THEN, callbackID );
addState( state );
m_activity.showDialog( TEXT_OR_HTML_THEN );
m_activity.showDialog( INVITE_CHOICES_THEN );
} else {
post( new Runnable() {
public void run() {
@ -402,21 +403,34 @@ public class DlgDelegate {
return setCallbackDismissListener( dialog, state, id );
}
private Dialog createHtmlThenDialog( DlgState state, int id )
private Dialog createInviteChoicesDialog( DlgState state, int id )
{
OnClickListener lstnr = mkCallbackClickListener( state );
boolean haveSMS = Utils.deviceSupportsSMS( m_activity );
boolean haveNFC = NFCUtils.nfcAvail( m_activity );
int msgID;
if ( haveSMS && haveNFC ) {
msgID = R.string.nfc_or_sms_or_email;
} else if ( haveSMS ) {
msgID = R.string.sms_or_email;
} else {
msgID = R.string.nfc_or_email;
}
AlertDialog.Builder builder = new AlertDialog.Builder( m_activity )
.setTitle( R.string.query_title )
.setMessage( R.string.sms_or_email )
.setPositiveButton( R.string.button_text, lstnr )
.setMessage( msgID )
.setNegativeButton( R.string.button_html, lstnr );
if ( NFCUtils.nfcAvail( m_activity ) ) {
if ( haveSMS ) {
builder.setPositiveButton( R.string.button_text, lstnr );
}
if ( haveNFC ) {
builder.setNeutralButton( R.string.button_nfc, lstnr );
}
Dialog dialog = builder.create();
return setCallbackDismissListener( dialog, state, id );
return setCallbackDismissListener( builder.create(), state, id );
}
private Dialog createDictGoneDialog()

View file

@ -309,7 +309,7 @@ public class NewGameActivity extends XWActivity {
{
if ( launch && networked ) {
// Let 'em cancel before we make the game
showEmailOrSMSThen( NEW_GAME_ACTION );
showInviteChoicesThen( NEW_GAME_ACTION );
} else {
makeNewGame( networked, launch, DlgDelegate.SMS_BTN );
}

View file

@ -147,9 +147,9 @@ public class XWActivity extends Activity
m_delegate.showConfirmThen( getString(msg), posButton, action );
}
public void showEmailOrSMSThen( int action )
public void showInviteChoicesThen( int action )
{
m_delegate.showEmailOrSMSThen( action );
m_delegate.showInviteChoicesThen( action );
}
protected void doSyncMenuitem()