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:
Eric House 2020-09-14 21:21:17 -07:00
parent 9be9caae54
commit 38ae14296c
3 changed files with 24 additions and 44 deletions

View file

@ -1185,7 +1185,7 @@ public class BoardDelegate extends DelegateBase
case INVITE_SMS_DATA: case INVITE_SMS_DATA:
int nMissing = (Integer)params[0]; int nMissing = (Integer)params[0];
SentInvitesInfo info = (SentInvitesInfo)params[1]; SentInvitesInfo info = (SentInvitesInfo)params[1];
launchPhoneNumberInvite( nMissing, info, InviteMeans.SMS_DATA, launchPhoneNumberInvite( nMissing, info,
RequestCode.SMS_DATA_INVITE_RESULT ); RequestCode.SMS_DATA_INVITE_RESULT );
break; break;
@ -1280,7 +1280,7 @@ public class BoardDelegate extends DelegateBase
if ( Perms23.bannedWithWorkaround( m_activity, perms ) ) { if ( Perms23.bannedWithWorkaround( m_activity, perms ) ) {
int nMissing = (Integer)params[0]; int nMissing = (Integer)params[0];
SentInvitesInfo info = (SentInvitesInfo)params[1]; SentInvitesInfo info = (SentInvitesInfo)params[1];
launchPhoneNumberInvite( nMissing, info, InviteMeans.SMS_DATA, launchPhoneNumberInvite( nMissing, info,
RequestCode.SMS_DATA_INVITE_RESULT ); RequestCode.SMS_DATA_INVITE_RESULT );
} else if ( Perms23.anyBanned( m_activity, perms ) ) { } else if ( Perms23.anyBanned( m_activity, perms ) ) {
makeOkOnlyBuilder( R.string.sms_banned_ok_only ) makeOkOnlyBuilder( R.string.sms_banned_ok_only )
@ -1362,10 +1362,6 @@ public class BoardDelegate extends DelegateBase
Action.INVITE_SMS_DATA, m_mySIS.nMissing, Action.INVITE_SMS_DATA, m_mySIS.nMissing,
info, perms ); info, perms );
break; 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: case RELAY:
RelayInviteDelegate.launchForResult( m_activity, m_mySIS.nMissing, info, RelayInviteDelegate.launchForResult( m_activity, m_mySIS.nMissing, info,
RequestCode.RELAY_INVITE_RESULT ); RequestCode.RELAY_INVITE_RESULT );
@ -1379,6 +1375,7 @@ public class BoardDelegate extends DelegateBase
m_mySIS.nMissing, info, m_mySIS.nMissing, info,
RequestCode.P2P_INVITE_RESULT ); RequestCode.P2P_INVITE_RESULT );
break; break;
case SMS_USER:
case EMAIL: case EMAIL:
case CLIPBOARD: case CLIPBOARD:
NetLaunchInfo nli = new NetLaunchInfo( m_activity, m_summary, m_gi, 1, NetLaunchInfo nli = new NetLaunchInfo( m_activity, m_summary, m_gi, 1,
@ -1386,10 +1383,16 @@ public class BoardDelegate extends DelegateBase
if ( m_relayMissing ) { if ( m_relayMissing ) {
nli.removeAddress( CommsConnType.COMMS_CONN_RELAY ); nli.removeAddress( CommsConnType.COMMS_CONN_RELAY );
} }
if ( InviteMeans.EMAIL == means ) { switch ( means ) {
case EMAIL:
GameUtils.launchEmailInviteActivity( m_activity, nli ); 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 ); GameUtils.inviteURLToClip( m_activity, nli );
break;
} }
recordInviteSent( means, null ); recordInviteSent( means, null );
@ -1668,10 +1671,9 @@ public class BoardDelegate extends DelegateBase
} }
private void launchPhoneNumberInvite( int nMissing, SentInvitesInfo info, private void launchPhoneNumberInvite( int nMissing, SentInvitesInfo info,
InviteMeans means, RequestCode code ) RequestCode code )
{ {
SMSInviteDelegate.launchForResult( m_activity, nMissing, info, SMSInviteDelegate.launchForResult( m_activity, nMissing, info, code );
means, code );
} }
private void deleteAndClose( int gameID ) private void deleteAndClose( int gameID )
@ -2800,9 +2802,6 @@ public class BoardDelegate extends DelegateBase
} }
BTService.inviteRemote( m_activity, dev, nli ); BTService.inviteRemote( m_activity, dev, nli );
break; break;
case SMS_USER:
GameUtils.launchSMSInviteActivity( m_activity, dev, nli );
break;
case SMS_DATA: case SMS_DATA:
sendNBSInviteIf( dev, nli, true ); sendNBSInviteIf( dev, nli, true );
dev = null; // don't record send a second time dev = null; // don't record send a second time
@ -2822,6 +2821,9 @@ public class BoardDelegate extends DelegateBase
case MQTT: case MQTT:
MQTTUtils.inviteRemote( m_activity, dev, nli ); MQTTUtils.inviteRemote( m_activity, dev, nli );
break; break;
default:
Assert.failDbg();
break;
} }
if ( null != dev ) { if ( null != dev ) {

View file

@ -768,7 +768,10 @@ public class GameUtils {
// There seems to be no standard on how to launch an SMS app to send a // 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 // message. So let's gather here the stuff that works, and try in order
// until something succeeds. // 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 ) NetLaunchInfo nli )
{ {
String message = makeInviteMessage( activity, nli, String message = makeInviteMessage( activity, nli,
@ -790,22 +793,17 @@ public class GameUtils {
.setPackage( defaultSmsPkg ) .setPackage( defaultSmsPkg )
.setType( "text/plain" ) .setType( "text/plain" )
.putExtra( Intent.EXTRA_TEXT, message ) .putExtra( Intent.EXTRA_TEXT, message )
.setData( Uri.parse("sms:" + phone) )
.putExtra( "sms_body", message ) .putExtra( "sms_body", message )
.putExtra( "address", phone)
.setData(Uri.parse("smsto:" + phone))
; ;
break; break;
case 1: // test case: Signal case 1: // test case: Signal
intent = new Intent( Intent.ACTION_SENDTO, intent = new Intent( Intent.ACTION_SENDTO )
Uri.parse("smsto:" + phone) )
.putExtra("sms_body", message) .putExtra("sms_body", message)
.setPackage( defaultSmsPkg ) .setPackage( defaultSmsPkg )
; ;
break; break;
case 2: case 2:
intent = new Intent( Intent.ACTION_VIEW ) intent = new Intent( Intent.ACTION_VIEW )
.setData( Uri.parse("sms:" + phone) )
.putExtra( "sms_body", message ) .putExtra( "sms_body", message )
; ;
break; break;

View file

@ -57,24 +57,20 @@ public class SMSInviteDelegate extends InviteDelegate {
R.id.manual_add_button, R.id.manual_add_button,
R.id.button_clear, R.id.button_clear,
}; };
private static final String INTENT_KEY_MEANS = "means";
private ArrayList<PhoneRec> m_phoneRecs; private ArrayList<PhoneRec> m_phoneRecs;
private Activity m_activity; private Activity m_activity;
private InviteMeans mMeans;
public static void launchForResult( Activity activity, int nMissing, public static void launchForResult( Activity activity, int nMissing,
SentInvitesInfo info, SentInvitesInfo info,
InviteMeans means,
RequestCode requestCode ) RequestCode requestCode )
{ {
Intent intent = InviteDelegate Intent intent = InviteDelegate
.makeIntent( activity, SMSInviteActivity.class, .makeIntent( activity, SMSInviteActivity.class,
nMissing, info ) nMissing, info );
.putExtra( INTENT_KEY_MEANS, means.ordinal() );
if ( null != info ) { if ( null != info ) {
String lastDev = info.getLastDev( means ); String lastDev = info.getLastDev( InviteMeans.SMS_DATA );
intent.putExtra( INTENT_KEY_LASTDEV, lastDev ); intent.putExtra( INTENT_KEY_LASTDEV, lastDev );
} }
activity.startActivityForResult( intent, requestCode.ordinal() ); activity.startActivityForResult( intent, requestCode.ordinal() );
@ -91,7 +87,6 @@ public class SMSInviteDelegate extends InviteDelegate {
{ {
super.init( savedInstanceState ); super.init( savedInstanceState );
mMeans = InviteMeans.values()[getIntent().getIntExtra(INTENT_KEY_MEANS, -1)];
String msg = getString( R.string.button_invite ); String msg = getString( R.string.button_invite );
msg = getQuantityString( R.plurals.invite_sms_desc_fmt, m_nMissing, msg = getQuantityString( R.plurals.invite_sms_desc_fmt, m_nMissing,
m_nMissing, msg ); m_nMissing, msg );
@ -105,22 +100,7 @@ public class SMSInviteDelegate extends InviteDelegate {
} }
@Override @Override
int getExtra() int getExtra() { return R.string.invite_nbs_desc; }
{
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;
}
@Override @Override
protected void onBarButtonClicked( int id ) protected void onBarButtonClicked( int id )