diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index e4eb7b5be..9e6da5d40 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -64,6 +64,8 @@
Save
Discard
Retry
+ Text
+ Html
Name:
@@ -558,13 +560,19 @@
that many people.)
Let\'s play Crosswords
- \u003ca href=\"%1$s\"\u003ETap here to
+ \u003ca href=\"%1$s\"\u003ETap here to
accept\u003c/a\u003E my invitation and join this
game.\u003cbr\u003E \u003ca
href=\"http://eehouse.org/market.php\"\u003E
Tap here to install Crosswords\u003c/a\u003E if you haven\'t
already.
+ Accept my invitation and join this
+ game: %1$s . (But install Crosswords first:
+ http://eehouse.org/market.php ).
+ Send invitation using plain text or
+ html? Text links are harder to open but can be sent via SMS.
+ Most devices let you send html only via email.
Send invitation via
Unable to download. Do you have
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
index cbfa5a838..f2941a345 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
@@ -39,6 +39,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 DIALOG_LAST = CONFIRM_THEN;
private int m_msgID;
@@ -49,6 +50,11 @@ public class DlgDelegate {
private String m_dictName = null;
DialogInterface.OnClickListener m_then;
+ public interface TextOrHtmlClicked {
+ public void clicked( boolean choseText );
+ };
+ private TextOrHtmlClicked m_txt_or_html;
+
public DlgDelegate( Activity activity ) {
m_activity = activity;
}
@@ -69,6 +75,9 @@ public class DlgDelegate {
case CONFIRM_THEN:
dialog = createConfirmThenDialog();
break;
+ case TEXT_OR_HTML_THEN:
+ dialog = createHtmlThenDialog();
+ break;
}
return dialog;
}
@@ -87,6 +96,8 @@ public class DlgDelegate {
public void onPrepareDialog( int id, Dialog dialog )
{
AlertDialog ad = (AlertDialog)dialog;
+ DialogInterface.OnClickListener lstnr;
+
switch( id ) {
case DIALOG_ABOUT:
break;
@@ -105,6 +116,22 @@ public class DlgDelegate {
ad.setButton( AlertDialog.BUTTON_POSITIVE,
m_activity.getString( R.string.button_ok ), m_then );
break;
+ case TEXT_OR_HTML_THEN:
+ lstnr = new DialogInterface.OnClickListener() {
+ public void onClick( DialogInterface dlg, int button ) {
+ if ( null != m_txt_or_html ) {
+ m_txt_or_html.
+ clicked( button == AlertDialog.BUTTON_POSITIVE );
+ }
+ }
+ };
+ ad.setButton( AlertDialog.BUTTON_POSITIVE,
+ m_activity.getString( R.string.button_text ),
+ lstnr );
+ ad.setButton( AlertDialog.BUTTON_NEGATIVE,
+ m_activity.getString( R.string.button_html ),
+ lstnr );
+ break;
}
}
@@ -142,6 +169,12 @@ public class DlgDelegate {
m_activity.showDialog( CONFIRM_THEN );
}
+ public void showTextOrHtmlThen( TextOrHtmlClicked txtOrHtml )
+ {
+ m_txt_or_html = txtOrHtml;
+ m_activity.showDialog( TEXT_OR_HTML_THEN );
+ }
+
public void doSyncMenuitem()
{
if ( null == DBUtils.getRelayIDs( m_activity, false ) ) {
@@ -239,4 +272,15 @@ public class DlgDelegate {
.create();
return dialog;
}
+
+ private Dialog createHtmlThenDialog()
+ {
+ return new AlertDialog.Builder( m_activity )
+ .setTitle( R.string.query_title )
+ .setMessage( R.string.text_or_html )
+ .setPositiveButton( R.string.button_text, null ) // will change
+ .setNegativeButton( R.string.button_html, null )
+ .create();
+ }
+
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
index 119558949..c2529927b 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
@@ -404,7 +404,9 @@ public class GameUtils {
info.nPlayers );
}
- public static void launchInviteActivity( Context context, String room,
+ public static void launchInviteActivity( Context context,
+ boolean choseText,
+ String room,
int lang, int nPlayers )
{
Random random = new Random();
@@ -413,19 +415,36 @@ public class GameUtils {
if ( null != gameUri ) {
Intent intent = new Intent( Intent.ACTION_SEND );
- intent.setType("text/html");
+ intent.setType( choseText? "text/plain" : "text/html");
intent.putExtra( Intent.EXTRA_SUBJECT,
context.getString( R.string.invite_subject ) );
- String format = context.getString( R.string.invite_bodyf );
+ int fmtId = choseText? R.string.invite_txtf : R.string.invite_htmf;
+ String format = context.getString( fmtId );
String message = String.format( format, gameUri.toString() );
- intent.putExtra( Intent.EXTRA_TEXT, Html.fromHtml(message) );
+ intent.putExtra( Intent.EXTRA_TEXT,
+ choseText ? message : Html.fromHtml(message) );
String chooserMsg = context.getString( R.string.invite_chooser );
context.startActivity( Intent.createChooser( intent, chooserMsg ) );
}
}
+ public static void launchInviteActivity( final XWActivity activity,
+ final String room,
+ final int lang,
+ final int nPlayers )
+ {
+ DlgDelegate.TextOrHtmlClicked cb =
+ new DlgDelegate.TextOrHtmlClicked() {
+ public void clicked( boolean choseText ) {
+ launchInviteActivity( activity, choseText, room,
+ lang, nPlayers );
+ }
+ };
+ activity.showTextOrHtmlThen( cb );
+ }
+
public static boolean gameDictsHere( Context context, long rowid )
{
return gameDictsHere( context, rowid, null, null );
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java
index 72b254b97..57feb8188 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java
@@ -88,6 +88,7 @@ public class NewGameActivity extends XWActivity {
private void makeNewGame( boolean networked, boolean launch )
{
+ boolean finished = true;
String room = null;
long rowid;
int[] lang = {0};
@@ -102,15 +103,32 @@ public class NewGameActivity extends XWActivity {
}
if ( launch ) {
- GameUtils.launchGame( this, rowid, networked );
if ( networked ) {
- GameUtils.launchInviteActivity( this, room, lang[0], nPlayers );
+ finished = false;
+ final String froom = room;
+ final long frowid = rowid;
+ final int flang = lang[0];
+ showTextOrHtmlThen( new DlgDelegate.TextOrHtmlClicked() {
+ public void clicked( boolean choseText ) {
+ GameUtils.launchGame( NewGameActivity.this,
+ frowid, true );
+ GameUtils.
+ launchInviteActivity( NewGameActivity.this,
+ choseText, froom, flang,
+ nPlayers );
+ finish();
+ }
+ } );
+ } else {
+ GameUtils.launchGame( this, rowid, false );
}
} else {
GameUtils.doConfig( this, rowid, GameConfig.class );
}
- finish();
+ if ( finished ) {
+ finish();
+ }
}
}
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java
index d093924b6..7bb01a339 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java
@@ -127,6 +127,11 @@ public class XWActivity extends Activity {
m_delegate.showConfirmThen( getString(msgID), action );
}
+ public void showTextOrHtmlThen( DlgDelegate.TextOrHtmlClicked txtOrHtml )
+ {
+ m_delegate.showTextOrHtmlThen( txtOrHtml );
+ }
+
protected void doSyncMenuitem()
{
m_delegate.doSyncMenuitem();