diff --git a/xwords4/android/XWords4/res/values/common_rsrc.xml b/xwords4/android/XWords4/res/values/common_rsrc.xml
index c1911fbeb..1c3b7dba8 100644
--- a/xwords4/android/XWords4/res/values/common_rsrc.xml
+++ b/xwords4/android/XWords4/res/values/common_rsrc.xml
@@ -113,6 +113,7 @@
key_na_values
key_na_studycopy
key_na_fmt_expl
+ key_na_clip_expl
key_na_dicts
key_enable_debug
key_enable_dup_invite
diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml
index 58410b976..81b275ec7 100644
--- a/xwords4/android/XWords4/res/values/strings.xml
+++ b/xwords4/android/XWords4/res/values/strings.xml
@@ -2558,4 +2558,18 @@
Enable relay invites to self
(To aid testing and debugging)
+
+ I\'ll choose
+
+ Invitation ready to paste
+
+ Invitation URL
+
+ The \"%1$s\" option copies an
+ invitation URL to the clipboard. Paste it into the app of your
+ choice and send it to your friend.
diff --git a/xwords4/android/XWords4/res_src/values-ba_CK/strings.xml b/xwords4/android/XWords4/res_src/values-ba_CK/strings.xml
index a1eeb37c5..5c558b7ab 100644
--- a/xwords4/android/XWords4/res_src/values-ba_CK/strings.xml
+++ b/xwords4/android/XWords4/res_src/values-ba_CK/strings.xml
@@ -2203,4 +2203,18 @@
em wonk fi I\'m gnorw dna I\'ll yrt redrah ot ekam ti krow.
Elbane yaler setivni ot fles
oT( dia gnitset dna )gniggubed
+
+ I\'ll esoohc
+
+ Noitativni ydaer ot etsap
+
+ Noitativni LRU
+
+ Eht \"%1$s\" noitpo seipoc na
+ noitativni LRU ot eht draobpilc. Etsap ti otni eht ppa fo ruoy
+ eciohc dna dnes ti ot ruoy dneirf.
diff --git a/xwords4/android/XWords4/res_src/values-ca_PS/strings.xml b/xwords4/android/XWords4/res_src/values-ca_PS/strings.xml
index 6a1f6a1f8..9a9e5cd96 100644
--- a/xwords4/android/XWords4/res_src/values-ca_PS/strings.xml
+++ b/xwords4/android/XWords4/res_src/values-ca_PS/strings.xml
@@ -2203,4 +2203,18 @@
ME KNOW IF I\'M WRONG AND I\'LL TRY HARDER TO MAKE IT WORK.
ENABLE RELAY INVITES TO SELF
(TO AID TESTING AND DEBUGGING)
+
+ I\'LL CHOOSE
+
+ INVITATION READY TO PASTE
+
+ INVITATION URL
+
+ THE \"%1$s\" OPTION COPIES AN
+ INVITATION URL TO THE CLIPBOARD. PASTE IT INTO THE APP OF YOUR
+ CHOICE AND SEND IT TO YOUR FRIEND.
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java
index 67f2a9416..f67d1e5ec 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java
@@ -1069,12 +1069,17 @@ public class BoardDelegate extends DelegateBase
RELAY_INVITE_RESULT );
break;
case EMAIL:
+ case CLIPBOARD:
NetLaunchInfo nli = new NetLaunchInfo( m_summary, m_gi, 1,
1 + m_nGuestDevs );
if ( !m_relayConnected ) {
nli.removeAddress( CommsConnType.COMMS_CONN_RELAY );
}
- GameUtils.launchEmailInviteActivity( m_activity, nli );
+ if ( InviteMeans.EMAIL == means ) {
+ GameUtils.launchEmailInviteActivity( m_activity, nli );
+ } else if ( InviteMeans.CLIPBOARD == means ) {
+ GameUtils.inviteURLToClip( m_activity, nli );
+ }
break;
default:
Assert.fail();
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 8b80f4bc0..e444fe34d 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
@@ -138,7 +138,7 @@ public class DlgDelegate {
public interface DlgClickNotify {
public static enum InviteMeans {
- SMS, EMAIL, NFC, BLUETOOTH, RELAY,
+ SMS, EMAIL, NFC, BLUETOOTH, RELAY, CLIPBOARD,
};
void dlgButtonClicked( Action action, int button, Object[] params );
void inviteChoiceMade( Action action, InviteMeans means, Object[] params );
@@ -335,6 +335,11 @@ public class DlgDelegate {
showNotAgainDlgThen( msgID, prefsKey, Action.SKIP_CALLBACK );
}
+ private void showNotAgainDlgThen( String msg, int prefsKey )
+ {
+ showNotAgainDlgThen( msg, prefsKey, Action.SKIP_CALLBACK, null, null );
+ }
+
public void showConfirmThen( String msg, Action action )
{
showConfirmThen( null, msg, android.R.string.ok, action, null );
@@ -630,6 +635,9 @@ public class DlgDelegate {
items.add( getString( R.string.invite_choice_relay ) );
means.add( DlgClickNotify.InviteMeans.RELAY );
}
+ final int clipPos = means.size();
+ items.add( getString( R.string.invite_choice_clip ) );
+ means.add( DlgClickNotify.InviteMeans.CLIPBOARD );
final int[] sel = { -1 };
OnClickListener selChanged = new OnClickListener() {
@@ -641,6 +649,13 @@ public class DlgDelegate {
.setEnabled( true );
}
sel[0] = view;
+
+ if ( view == clipPos ) {
+ String msg =
+ getString( R.string.not_again_clip_expl_fmt,
+ getString(R.string.invite_choice_clip) );
+ showNotAgainDlgThen( msg, R.string.key_na_clip_expl );
+ }
}
};
OnClickListener okClicked = new OnClickListener() {
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 046859adf..67c59ac74 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java
@@ -49,7 +49,6 @@ import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnTypeSet;
import org.eehouse.android.xw4.jni.CurGameInfo.DeviceRole;
import org.eehouse.android.xw4.jni.LastMoveInfo;
-import org.eehouse.android.xw4.DlgDelegate.DlgClickNotify.InviteMeans;
public class GameUtils {
@@ -608,6 +607,33 @@ public class GameUtils {
isHost );
}
+ // @SuppressLint({ "NewApi", "NewApi", "NewApi", "NewApi" })
+ // @SuppressWarnings("deprecation")
+ // @TargetApi(11)
+ public static void inviteURLToClip( Context context, NetLaunchInfo nli )
+ {
+ Uri gameUri = nli.makeLaunchUri( context );
+ String asStr = gameUri.toString();
+
+ int sdk = android.os.Build.VERSION.SDK_INT;
+ if ( sdk < android.os.Build.VERSION_CODES.HONEYCOMB ) {
+ android.text.ClipboardManager clipboard =
+ (android.text.ClipboardManager)
+ context.getSystemService(Context.CLIPBOARD_SERVICE);
+ clipboard.setText( asStr );
+ } else {
+ android.content.ClipboardManager clipboard =
+ (android.content.ClipboardManager)
+ context.getSystemService(Context.CLIPBOARD_SERVICE);
+ String label = LocUtils.getString( context, R.string.clip_label );
+ android.content.ClipData clip = android.content.ClipData
+ .newPlainText( label, asStr );
+ clipboard.setPrimaryClip( clip );
+ }
+
+ Utils.showToast( context, R.string.invite_copied );
+ }
+
public static void launchEmailInviteActivity( Activity activity, NetLaunchInfo nli )
{
// DbgUtils.logf( "launchEmailInviteActivity: nli=%s", nli.makeLaunchJSON() );