experimental option that puts invite url text into clipboard so user

can invite using app of her choice.

Conflicts:
	xwords4/android/XWords4/res/values/strings.xml
	xwords4/android/XWords4/res_src/values-ba_CK/strings.xml
	xwords4/android/XWords4/res_src/values-ca_PS/strings.xml
	xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
This commit is contained in:
Eric House 2015-08-23 21:44:45 -07:00
parent ec3af948e3
commit 98bd41bc14
8 changed files with 790 additions and 684 deletions

File diff suppressed because it is too large Load diff

View file

@ -113,6 +113,7 @@
<string name="key_na_values">key_na_values</string>
<string name="key_na_studycopy">key_na_studycopy</string>
<string name="key_na_fmt_expl">key_na_fmt_expl</string>
<string name="key_na_clip_expl">key_na_clip_expl</string>
<string name="key_na_dicts">key_na_dicts</string>
<string name="key_enable_debug">key_enable_debug</string>
<string name="key_enable_dup_invite">key_enable_dup_invite</string>

View file

@ -2541,4 +2541,18 @@
<string name="confirm_clear_chat">Are you sure you want to delete
all chat history for this game?\n\n(This action cannot be
undone.)</string>
<!-- EXPERIMENTAL: A choice of how to invite, along with SMS,
Bluetooth, email etc -->
<string name="invite_choice_clip">I\'ll choose</string>
<!-- EXPERIMENTAL: Shown as toast when user chooses "My choice" for
invitation -->
<string name="invite_copied">Invitation ready to paste</string>
<!-- EXPERIMENTAL: "label" for invite on clipboard. If it's shown
it's by some Android utility -->
<string name="clip_label">Invitation URL</string>
<!-- EXPERIMENTAL: Newbie hint next when invite_choice_clip shown
when chosen -->
<string name="not_again_clip_expl_fmt">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.</string>
</resources>

View file

@ -2189,4 +2189,18 @@
<string name="confirm_clear_chat">Era uoy erus uoy tnaw ot eteled
lla tahc yrotsih rof siht ?emag\n\nsIht( noitca tonnac eb
enodnu.)</string>
<!-- EXPERIMENTAL: A choice of how to invite, along with SMS,
Bluetooth, email etc -->
<string name="invite_choice_clip">I\'ll esoohc</string>
<!-- EXPERIMENTAL: Shown as toast when user chooses "My choice" for
invitation -->
<string name="invite_copied">Noitativni ydaer ot etsap</string>
<!-- EXPERIMENTAL: "label" for invite on clipboard. If it's shown
it's by some Android utility -->
<string name="clip_label">Noitativni LRU</string>
<!-- EXPERIMENTAL: Newbie hint next when invite_choice_clip shown
when chosen -->
<string name="not_again_clip_expl_fmt">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.</string>
</resources>

View file

@ -2189,4 +2189,18 @@
<string name="confirm_clear_chat">ARE YOU SURE YOU WANT TO DELETE
ALL CHAT HISTORY FOR THIS GAME?\n\n(THIS ACTION CANNOT BE
UNDONE.)</string>
<!-- EXPERIMENTAL: A choice of how to invite, along with SMS,
Bluetooth, email etc -->
<string name="invite_choice_clip">I\'LL CHOOSE</string>
<!-- EXPERIMENTAL: Shown as toast when user chooses "My choice" for
invitation -->
<string name="invite_copied">INVITATION READY TO PASTE</string>
<!-- EXPERIMENTAL: "label" for invite on clipboard. If it's shown
it's by some Android utility -->
<string name="clip_label">INVITATION URL</string>
<!-- EXPERIMENTAL: Newbie hint next when invite_choice_clip shown
when chosen -->
<string name="not_again_clip_expl_fmt">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.</string>
</resources>

View file

@ -1046,12 +1046,17 @@ public class BoardDelegate extends DelegateBase
SMS_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();

View file

@ -138,7 +138,7 @@ public class DlgDelegate {
public interface DlgClickNotify {
public static enum InviteMeans {
SMS, EMAIL, NFC, BLUETOOTH,
SMS, EMAIL, NFC, BLUETOOTH, 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 );
@ -626,6 +631,9 @@ public class DlgDelegate {
items.add( getString( R.string.invite_choice_nfc ) );
means.add( DlgClickNotify.InviteMeans.NFC );
}
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() {
@ -637,6 +645,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() {

View file

@ -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 {
@ -605,6 +604,33 @@ public class GameUtils {
inviteID, gameID, gameName, 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() );