mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-12 08:47:50 +01:00
Pass message to SMS app same as to email
Doing away with letting user build a local phone list (left over from the NBS case where it made sense.) Just launch the default SMS app with the message and let 'em choose a recipient. Hard to test, but works on two of two phones so far.
This commit is contained in:
parent
9be9caae54
commit
38ae14296c
3 changed files with 24 additions and 44 deletions
|
@ -1185,7 +1185,7 @@ public class BoardDelegate extends DelegateBase
|
|||
case INVITE_SMS_DATA:
|
||||
int nMissing = (Integer)params[0];
|
||||
SentInvitesInfo info = (SentInvitesInfo)params[1];
|
||||
launchPhoneNumberInvite( nMissing, info, InviteMeans.SMS_DATA,
|
||||
launchPhoneNumberInvite( nMissing, info,
|
||||
RequestCode.SMS_DATA_INVITE_RESULT );
|
||||
break;
|
||||
|
||||
|
@ -1280,7 +1280,7 @@ public class BoardDelegate extends DelegateBase
|
|||
if ( Perms23.bannedWithWorkaround( m_activity, perms ) ) {
|
||||
int nMissing = (Integer)params[0];
|
||||
SentInvitesInfo info = (SentInvitesInfo)params[1];
|
||||
launchPhoneNumberInvite( nMissing, info, InviteMeans.SMS_DATA,
|
||||
launchPhoneNumberInvite( nMissing, info,
|
||||
RequestCode.SMS_DATA_INVITE_RESULT );
|
||||
} else if ( Perms23.anyBanned( m_activity, perms ) ) {
|
||||
makeOkOnlyBuilder( R.string.sms_banned_ok_only )
|
||||
|
@ -1362,10 +1362,6 @@ public class BoardDelegate extends DelegateBase
|
|||
Action.INVITE_SMS_DATA, m_mySIS.nMissing,
|
||||
info, perms );
|
||||
break;
|
||||
case SMS_USER: // like an email invite, but we want the phone #
|
||||
launchPhoneNumberInvite( m_mySIS.nMissing, info, means,
|
||||
RequestCode.SMS_USER_INVITE_RESULT );
|
||||
break;
|
||||
case RELAY:
|
||||
RelayInviteDelegate.launchForResult( m_activity, m_mySIS.nMissing, info,
|
||||
RequestCode.RELAY_INVITE_RESULT );
|
||||
|
@ -1379,6 +1375,7 @@ public class BoardDelegate extends DelegateBase
|
|||
m_mySIS.nMissing, info,
|
||||
RequestCode.P2P_INVITE_RESULT );
|
||||
break;
|
||||
case SMS_USER:
|
||||
case EMAIL:
|
||||
case CLIPBOARD:
|
||||
NetLaunchInfo nli = new NetLaunchInfo( m_activity, m_summary, m_gi, 1,
|
||||
|
@ -1386,10 +1383,16 @@ public class BoardDelegate extends DelegateBase
|
|||
if ( m_relayMissing ) {
|
||||
nli.removeAddress( CommsConnType.COMMS_CONN_RELAY );
|
||||
}
|
||||
if ( InviteMeans.EMAIL == means ) {
|
||||
switch ( means ) {
|
||||
case EMAIL:
|
||||
GameUtils.launchEmailInviteActivity( m_activity, nli );
|
||||
} else if ( InviteMeans.CLIPBOARD == means ) {
|
||||
break;
|
||||
case SMS_USER:
|
||||
GameUtils.launchSMSInviteActivity( m_activity, nli );
|
||||
break;
|
||||
case CLIPBOARD:
|
||||
GameUtils.inviteURLToClip( m_activity, nli );
|
||||
break;
|
||||
}
|
||||
recordInviteSent( means, null );
|
||||
|
||||
|
@ -1668,10 +1671,9 @@ public class BoardDelegate extends DelegateBase
|
|||
}
|
||||
|
||||
private void launchPhoneNumberInvite( int nMissing, SentInvitesInfo info,
|
||||
InviteMeans means, RequestCode code )
|
||||
RequestCode code )
|
||||
{
|
||||
SMSInviteDelegate.launchForResult( m_activity, nMissing, info,
|
||||
means, code );
|
||||
SMSInviteDelegate.launchForResult( m_activity, nMissing, info, code );
|
||||
}
|
||||
|
||||
private void deleteAndClose( int gameID )
|
||||
|
@ -2800,9 +2802,6 @@ public class BoardDelegate extends DelegateBase
|
|||
}
|
||||
BTService.inviteRemote( m_activity, dev, nli );
|
||||
break;
|
||||
case SMS_USER:
|
||||
GameUtils.launchSMSInviteActivity( m_activity, dev, nli );
|
||||
break;
|
||||
case SMS_DATA:
|
||||
sendNBSInviteIf( dev, nli, true );
|
||||
dev = null; // don't record send a second time
|
||||
|
@ -2822,6 +2821,9 @@ public class BoardDelegate extends DelegateBase
|
|||
case MQTT:
|
||||
MQTTUtils.inviteRemote( m_activity, dev, nli );
|
||||
break;
|
||||
default:
|
||||
Assert.failDbg();
|
||||
break;
|
||||
}
|
||||
|
||||
if ( null != dev ) {
|
||||
|
|
|
@ -768,7 +768,10 @@ public class GameUtils {
|
|||
// There seems to be no standard on how to launch an SMS app to send a
|
||||
// message. So let's gather here the stuff that works, and try in order
|
||||
// until something succeeds.
|
||||
public static void launchSMSInviteActivity( Activity activity, String phone,
|
||||
//
|
||||
// And, added later and without the ability to test all of these, let's
|
||||
// not include a phone number.
|
||||
public static void launchSMSInviteActivity( Activity activity,
|
||||
NetLaunchInfo nli )
|
||||
{
|
||||
String message = makeInviteMessage( activity, nli,
|
||||
|
@ -790,22 +793,17 @@ public class GameUtils {
|
|||
.setPackage( defaultSmsPkg )
|
||||
.setType( "text/plain" )
|
||||
.putExtra( Intent.EXTRA_TEXT, message )
|
||||
.setData( Uri.parse("sms:" + phone) )
|
||||
.putExtra( "sms_body", message )
|
||||
.putExtra( "address", phone)
|
||||
.setData(Uri.parse("smsto:" + phone))
|
||||
;
|
||||
break;
|
||||
case 1: // test case: Signal
|
||||
intent = new Intent( Intent.ACTION_SENDTO,
|
||||
Uri.parse("smsto:" + phone) )
|
||||
intent = new Intent( Intent.ACTION_SENDTO )
|
||||
.putExtra("sms_body", message)
|
||||
.setPackage( defaultSmsPkg )
|
||||
;
|
||||
break;
|
||||
case 2:
|
||||
intent = new Intent( Intent.ACTION_VIEW )
|
||||
.setData( Uri.parse("sms:" + phone) )
|
||||
.putExtra( "sms_body", message )
|
||||
;
|
||||
break;
|
||||
|
|
|
@ -57,24 +57,20 @@ public class SMSInviteDelegate extends InviteDelegate {
|
|||
R.id.manual_add_button,
|
||||
R.id.button_clear,
|
||||
};
|
||||
private static final String INTENT_KEY_MEANS = "means";
|
||||
|
||||
private ArrayList<PhoneRec> m_phoneRecs;
|
||||
private Activity m_activity;
|
||||
private InviteMeans mMeans;
|
||||
|
||||
public static void launchForResult( Activity activity, int nMissing,
|
||||
SentInvitesInfo info,
|
||||
InviteMeans means,
|
||||
RequestCode requestCode )
|
||||
{
|
||||
|
||||
Intent intent = InviteDelegate
|
||||
.makeIntent( activity, SMSInviteActivity.class,
|
||||
nMissing, info )
|
||||
.putExtra( INTENT_KEY_MEANS, means.ordinal() );
|
||||
nMissing, info );
|
||||
if ( null != info ) {
|
||||
String lastDev = info.getLastDev( means );
|
||||
String lastDev = info.getLastDev( InviteMeans.SMS_DATA );
|
||||
intent.putExtra( INTENT_KEY_LASTDEV, lastDev );
|
||||
}
|
||||
activity.startActivityForResult( intent, requestCode.ordinal() );
|
||||
|
@ -91,7 +87,6 @@ public class SMSInviteDelegate extends InviteDelegate {
|
|||
{
|
||||
super.init( savedInstanceState );
|
||||
|
||||
mMeans = InviteMeans.values()[getIntent().getIntExtra(INTENT_KEY_MEANS, -1)];
|
||||
String msg = getString( R.string.button_invite );
|
||||
msg = getQuantityString( R.plurals.invite_sms_desc_fmt, m_nMissing,
|
||||
m_nMissing, msg );
|
||||
|
@ -105,22 +100,7 @@ public class SMSInviteDelegate extends InviteDelegate {
|
|||
}
|
||||
|
||||
@Override
|
||||
int getExtra()
|
||||
{
|
||||
int result = 0;
|
||||
switch( mMeans ) {
|
||||
case SMS_DATA:
|
||||
result = R.string.invite_nbs_desc;
|
||||
break;
|
||||
case SMS_USER:
|
||||
result = R.string.invite_sms_desc;
|
||||
break;
|
||||
default:
|
||||
Assert.failDbg();
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
int getExtra() { return R.string.invite_nbs_desc; }
|
||||
|
||||
@Override
|
||||
protected void onBarButtonClicked( int id )
|
||||
|
|
Loading…
Add table
Reference in a new issue