distinguish between NBS and SMS

What I've been calling SMS is now "data sms" (or "nbs", in
code). There's a new way of inviting, called "User Sms" or somesuch,
that launches the user's SMS app with a URL and phone number, much like
email (save that no addressing is required by the inviter.) This new way
won't be involved in the ban on SMS permissions. (But play by NBS is
still awesome and will stay where it can.)
This commit is contained in:
Eric House 2019-02-26 11:28:37 -08:00
parent 22711e75a5
commit c78a3afb36
22 changed files with 160 additions and 113 deletions

View file

@ -656,8 +656,11 @@ public class BoardDelegate extends DelegateBase
case BT_INVITE_RESULT: case BT_INVITE_RESULT:
missingMeans = InviteMeans.BLUETOOTH; missingMeans = InviteMeans.BLUETOOTH;
break; break;
case SMS_INVITE_RESULT: case SMS_DATA_INVITE_RESULT:
missingMeans = InviteMeans.SMS; missingMeans = InviteMeans.SMS_DATA;
break;
case SMS_USER_INVITE_RESULT:
missingMeans = InviteMeans.SMS_USER;
break; break;
case RELAY_INVITE_RESULT: case RELAY_INVITE_RESULT:
missingMeans = InviteMeans.RELAY; missingMeans = InviteMeans.RELAY;
@ -1062,11 +1065,10 @@ public class BoardDelegate extends DelegateBase
case DROP_SMS_ACTION: // do nothing; work done in onNegButton case case DROP_SMS_ACTION: // do nothing; work done in onNegButton case
break; break;
case INVITE_SMS: case INVITE_SMS_DATA:
int nMissing = (Integer)params[0]; int nMissing = (Integer)params[0];
SentInvitesInfo info = (SentInvitesInfo)params[1]; SentInvitesInfo info = (SentInvitesInfo)params[1];
SMSInviteDelegate.launchForResult( m_activity, nMissing, info, launchPhoneNumberInvite( nMissing, info, RequestCode.SMS_DATA_INVITE_RESULT );
RequestCode.SMS_INVITE_RESULT );
break; break;
case ASKED_PHONE_STATE: case ASKED_PHONE_STATE:
@ -1118,11 +1120,11 @@ public class BoardDelegate extends DelegateBase
showArchiveNA( false ); showArchiveNA( false );
break; break;
case ENABLE_SMS_DO: case ENABLE_NBS_DO:
post( new Runnable() { post( new Runnable() {
@Override @Override
public void run() { public void run() {
retrySMSInvites( params ); retryNBSInvites( params );
} }
} ); } );
// FALLTHRU: so super gets called, before // FALLTHRU: so super gets called, before
@ -1218,11 +1220,15 @@ public class BoardDelegate extends DelegateBase
BTInviteDelegate.launchForResult( m_activity, m_mySIS.nMissing, info, BTInviteDelegate.launchForResult( m_activity, m_mySIS.nMissing, info,
RequestCode.BT_INVITE_RESULT ); RequestCode.BT_INVITE_RESULT );
break; break;
case SMS: case SMS_DATA:
Perms23.tryGetPerms( this, new Perm[] { Perm.SEND_SMS, Perms23.tryGetPerms( this, new Perm[] { Perm.SEND_SMS,
Perm.RECEIVE_SMS }, Perm.RECEIVE_SMS },
R.string.sms_invite_rationale, R.string.sms_invite_rationale,
Action.INVITE_SMS, m_mySIS.nMissing, info ); Action.INVITE_SMS_DATA, m_mySIS.nMissing, info );
break;
case SMS_USER: // like an email invite, but we want the phone #
launchPhoneNumberInvite( m_mySIS.nMissing, info,
RequestCode.SMS_USER_INVITE_RESULT );
break; break;
case RELAY: case RELAY:
RelayInviteDelegate.launchForResult( m_activity, m_mySIS.nMissing, info, RelayInviteDelegate.launchForResult( m_activity, m_mySIS.nMissing, info,
@ -1498,6 +1504,12 @@ public class BoardDelegate extends DelegateBase
return m_handler; return m_handler;
} }
private void launchPhoneNumberInvite( int nMissing, SentInvitesInfo info,
RequestCode code )
{
SMSInviteDelegate.launchForResult( m_activity, nMissing, info, code );
}
private void deleteAndClose() private void deleteAndClose()
{ {
GameUtils.deleteGame( m_activity, m_jniThread.getLock(), false ); GameUtils.deleteGame( m_activity, m_jniThread.getLock(), false );
@ -2442,9 +2454,9 @@ public class BoardDelegate extends DelegateBase
private void warnIfNoTransport() private void warnIfNoTransport()
{ {
if ( m_connTypes.contains( CommsConnType.COMMS_CONN_SMS ) ) { if ( m_connTypes.contains( CommsConnType.COMMS_CONN_SMS ) ) {
if ( !XWPrefs.getSMSEnabled( m_activity ) ) { if ( !XWPrefs.getNBSEnabled( m_activity ) ) {
makeConfirmThenBuilder( R.string.warn_sms_disabled, makeConfirmThenBuilder( R.string.warn_sms_disabled,
Action.ENABLE_SMS_ASK ) Action.ENABLE_NBS_ASK )
.setPosButton( R.string.button_enable_sms ) .setPosButton( R.string.button_enable_sms )
.setNegButton( R.string.button_later ) .setNegButton( R.string.button_later )
.show(); .show();
@ -2499,8 +2511,11 @@ public class BoardDelegate extends DelegateBase
} }
BTService.inviteRemote( m_activity, dev, nli ); BTService.inviteRemote( m_activity, dev, nli );
break; break;
case SMS: case SMS_USER:
sendSMSInviteIf( dev, nli, true ); GameUtils.launchSMSInviteActivity( m_activity, dev, nli );
break;
case SMS_DATA:
sendNBSInviteIf( dev, nli, true );
dev = null; // don't record send a second time dev = null; // don't record send a second time
break; break;
case RELAY: case RELAY:
@ -2838,7 +2853,7 @@ public class BoardDelegate extends DelegateBase
String value; String value;
value = m_summary.getStringExtra( GameSummary.EXTRA_REMATCH_PHONE ); value = m_summary.getStringExtra( GameSummary.EXTRA_REMATCH_PHONE );
if ( null != value ) { if ( null != value ) {
sendSMSInviteIf( value, nli, true ); sendNBSInviteIf( value, nli, true );
} }
value = m_summary.getStringExtra( GameSummary.EXTRA_REMATCH_BTADDR ); value = m_summary.getStringExtra( GameSummary.EXTRA_REMATCH_BTADDR );
if ( null != value ) { if ( null != value ) {
@ -2861,15 +2876,15 @@ public class BoardDelegate extends DelegateBase
return force; return force;
} }
private void sendSMSInviteIf( String phone, NetLaunchInfo nli, private void sendNBSInviteIf( String phone, NetLaunchInfo nli,
boolean askOk ) boolean askOk )
{ {
if ( XWPrefs.getSMSEnabled( m_activity ) ) { if ( XWPrefs.getNBSEnabled( m_activity ) ) {
SMSService.inviteRemote( m_activity, phone, nli ); SMSService.inviteRemote( m_activity, phone, nli );
recordInviteSent( InviteMeans.SMS, phone ); recordInviteSent( InviteMeans.SMS_DATA, phone );
} else if ( askOk ) { } else if ( askOk ) {
makeConfirmThenBuilder( R.string.warn_sms_disabled, makeConfirmThenBuilder( R.string.warn_sms_disabled,
Action.ENABLE_SMS_ASK ) Action.ENABLE_NBS_ASK )
.setPosButton( R.string.button_enable_sms ) .setPosButton( R.string.button_enable_sms )
.setNegButton( R.string.button_later ) .setNegButton( R.string.button_later )
.setParams( nli, phone ) .setParams( nli, phone )
@ -2877,15 +2892,15 @@ public class BoardDelegate extends DelegateBase
} }
} }
private void retrySMSInvites( Object[] params ) private void retryNBSInvites( Object[] params )
{ {
if ( null != params && 2 == params.length if ( null != params && 2 == params.length
&& params[0] instanceof NetLaunchInfo && params[0] instanceof NetLaunchInfo
&& params[1] instanceof String ) { && params[1] instanceof String ) {
sendSMSInviteIf( (String)params[1], (NetLaunchInfo)params[0], sendNBSInviteIf( (String)params[1], (NetLaunchInfo)params[0],
false ); false );
} else { } else {
Log.w( TAG, "retrySMSInvites: tests failed" ); Log.w( TAG, "retryNBSInvites: tests failed" );
} }
} }

View file

@ -495,7 +495,7 @@ public class ConnStatusHandler {
boolean result = true; boolean result = true;
switch( connType ) { switch( connType ) {
case COMMS_CONN_SMS: case COMMS_CONN_SMS:
result = XWPrefs.getSMSEnabled( context ) result = XWPrefs.getNBSEnabled( context )
&& !getAirplaneModeOn( context ); && !getAirplaneModeOn( context );
break; break;
case COMMS_CONN_BT: case COMMS_CONN_BT:

View file

@ -114,7 +114,7 @@ public class ConnViaViewLayout extends LinearLayout {
Context context = getContext(); Context context = getContext();
switch( typ ) { switch( typ ) {
case COMMS_CONN_SMS: case COMMS_CONN_SMS:
enabled = XWPrefs.getSMSEnabled( context ); enabled = XWPrefs.getNBSEnabled( context );
break; break;
case COMMS_CONN_BT: case COMMS_CONN_BT:
enabled = BTService.BTEnabled(); enabled = BTService.BTEnabled();

View file

@ -566,9 +566,11 @@ public class DBUtils {
String msg; String msg;
switch ( means ) { switch ( means ) {
case SMS: case SMS_DATA:
msg = LocUtils.getString( context, R.string.invit_expl_sms_fmt, case SMS_USER:
target, timestamp ); int fmt = means == InviteMeans.SMS_DATA
? R.string.invit_expl_sms_fmt : R.string.invit_expl_usrsms_fmt;
msg = LocUtils.getString( context, fmt, target, timestamp );
break; break;
case BLUETOOTH: case BLUETOOTH:
String devName = BTService.nameForAddr( target ); String devName = BTService.nameForAddr( target );

View file

@ -740,11 +740,11 @@ public class DelegateBase implements DlgClickNotify,
boolean handled = true; boolean handled = true;
Log.d( TAG, "%s.onPosButton(%s)", getClass().getSimpleName(), action ); Log.d( TAG, "%s.onPosButton(%s)", getClass().getSimpleName(), action );
switch( action ) { switch( action ) {
case ENABLE_SMS_ASK: case ENABLE_NBS_ASK:
showSMSEnableDialog( Action.ENABLE_SMS_DO ); showSMSEnableDialog( Action.ENABLE_NBS_DO );
break; break;
case ENABLE_SMS_DO: case ENABLE_NBS_DO:
XWPrefs.setSMSEnabled( m_activity, true ); XWPrefs.setNBSEnabled( m_activity, true );
break; break;
case ENABLE_BT_DO: case ENABLE_BT_DO:
BTService.enable(); BTService.enable();

View file

@ -78,7 +78,7 @@ public class DlgDelegate {
NFC_TO_SELF, NFC_TO_SELF,
DROP_RELAY_ACTION, DROP_RELAY_ACTION,
DROP_SMS_ACTION, DROP_SMS_ACTION,
INVITE_SMS, INVITE_SMS_DATA,
BLANK_PICKED, BLANK_PICKED,
TRAY_PICKED, TRAY_PICKED,
INVITE_INFO, INVITE_INFO,
@ -115,9 +115,9 @@ public class DlgDelegate {
// DwnldDelegate && GamesListDelegate // DwnldDelegate && GamesListDelegate
STORAGE_CONFIRMED, STORAGE_CONFIRMED,
// clasify me // classify me
ENABLE_SMS_ASK, ENABLE_NBS_ASK,
ENABLE_SMS_DO, ENABLE_NBS_DO,
ENABLE_BT_DO, ENABLE_BT_DO,
ENABLE_RELAY_DO, ENABLE_RELAY_DO,
ENABLE_RELAY_DO_OR, ENABLE_RELAY_DO_OR,
@ -296,7 +296,9 @@ public class DlgDelegate {
// These are stored in the INVITES table. Don't change order // These are stored in the INVITES table. Don't change order
// gratuitously // gratuitously
public static enum InviteMeans { public static enum InviteMeans {
SMS, EMAIL, NFC, BLUETOOTH, CLIPBOARD, RELAY, WIFIDIRECT, SMS_DATA, // classic NBS-based data sms
EMAIL, NFC, BLUETOOTH, CLIPBOARD, RELAY, WIFIDIRECT,
SMS_USER, // just launch the SMS app, as with email
}; };
boolean onPosButton( Action action, Object... params ); boolean onPosButton( Action action, Object... params );
boolean onNegButton( Action action, Object... params ); boolean onNegButton( Action action, Object... params );
@ -401,7 +403,7 @@ public class DlgDelegate {
public void showInviteChoicesThen( final Action action, public void showInviteChoicesThen( final Action action,
SentInvitesInfo info ) SentInvitesInfo info )
{ {
if ( (XWApp.SMS_INVITE_ENABLED && Utils.deviceSupportsSMS( m_activity )) if ( (Utils.deviceSupportsNBS( m_activity ))
|| XWPrefs.getNFCToSelfEnabled( m_activity ) || XWPrefs.getNFCToSelfEnabled( m_activity )
|| NFCUtils.nfcAvail( m_activity )[0] || NFCUtils.nfcAvail( m_activity )[0]
|| WiDirWrapper.enabled() || WiDirWrapper.enabled()

View file

@ -284,7 +284,7 @@ public class GameConfigDelegate extends DelegateBase
switch( typ ) { switch( typ ) {
case COMMS_CONN_SMS: case COMMS_CONN_SMS:
makeConfirmThenBuilder( R.string.warn_sms_disabled, makeConfirmThenBuilder( R.string.warn_sms_disabled,
Action.ENABLE_SMS_ASK ) Action.ENABLE_NBS_ASK )
.setPosButton( R.string.button_enable_sms ) .setPosButton( R.string.button_enable_sms )
.setNegButton( R.string.button_later ) .setNegButton( R.string.button_later )
.show(); .show();

View file

@ -695,15 +695,8 @@ public class GameUtils {
public static void launchEmailInviteActivity( Activity activity, NetLaunchInfo nli ) public static void launchEmailInviteActivity( Activity activity, NetLaunchInfo nli )
{ {
// DbgUtils.logf( "launchEmailInviteActivity: nli=%s", nli.makeLaunchJSON() ); String message = makeInviteMessage( activity, nli, R.string.invite_htm_fmt );
Uri gameUri = nli.makeLaunchUri( activity ); if ( null != message ) {
// DbgUtils.logf( "launchEmailInviteActivity: uri=%s", gameUri );
String msgString = null == gameUri ? null : gameUri.toString();
if ( null != msgString ) {
int choiceID;
String message = LocUtils.getString( activity, R.string.invite_htm_fmt, msgString );
Intent intent = new Intent(); Intent intent = new Intent();
intent.setAction( Intent.ACTION_SEND ); intent.setAction( Intent.ACTION_SEND );
String subject = String subject =
@ -736,6 +729,36 @@ public class GameUtils {
} }
} }
public static void launchSMSInviteActivity( Activity activity, String phone,
NetLaunchInfo nli )
{
String message = makeInviteMessage( activity, nli,
R.string.invite_sms_fmt );
if ( null != message ) {
Intent intent = new Intent( Intent.ACTION_VIEW )
.setData( Uri.parse("sms:" + phone) )
.putExtra( "sms_body", message )
;
if ( intent.resolveActivity(activity.getPackageManager()) != null) {
activity.startActivity( intent );
} else {
DbgUtils.showf( "Unable to launch SMS app" );
}
}
}
private static String makeInviteMessage( Activity activity, NetLaunchInfo nli,
int fmtID )
{
String result = null;
Uri gameUri = nli.makeLaunchUri( activity );
String msgString = null == gameUri ? null : gameUri.toString();
if ( null != msgString ) {
result = LocUtils.getString( activity, fmtID, msgString );
}
return result;
}
public static String[] dictNames( Context context, GameLock lock ) public static String[] dictNames( Context context, GameLock lock )
{ {
byte[] stream = savedGame( context, lock ); byte[] stream = savedGame( context, lock );

View file

@ -30,7 +30,7 @@ import android.support.v4.app.DialogFragment;
import android.widget.Button; import android.widget.Button;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import org.eehouse.android.xw4.DlgDelegate.Action; import org.eehouse.android.xw4.DlgDelegate.Action;
import org.eehouse.android.xw4.DlgDelegate.ActionPair; import org.eehouse.android.xw4.DlgDelegate.ActionPair;
@ -67,31 +67,25 @@ public class InviteChoicesAlert extends DlgDelegateAlert {
lastMeans = ((SentInvitesInfo)state.m_params[0]).getLastMeans(); lastMeans = ((SentInvitesInfo)state.m_params[0]).getLastMeans();
} }
if ( XWApp.SMS_INVITE_ENABLED && Utils.deviceSupportsSMS(context) ) { add( items, means, R.string.invite_choice_user_sms, InviteMeans.SMS_USER );
items.add( getString( R.string.invite_choice_sms ) ); add( items, means, R.string.invite_choice_email, InviteMeans.EMAIL );
means.add( InviteMeans.SMS );
}
items.add( getString( R.string.invite_choice_email ) );
means.add( InviteMeans.EMAIL );
if ( BTService.BTAvailable() ) { if ( BTService.BTAvailable() ) {
items.add( getString( R.string.invite_choice_bt ) ); add( items, means, R.string.invite_choice_bt, InviteMeans.BLUETOOTH );
means.add( InviteMeans.BLUETOOTH ); }
if ( Utils.deviceSupportsNBS(context) ) {
add( items, means, R.string.invite_choice_data_sms, InviteMeans.SMS_DATA );
} }
if ( BuildConfig.RELAYINVITE_SUPPORTED ) { if ( BuildConfig.RELAYINVITE_SUPPORTED ) {
items.add( getString( R.string.invite_choice_relay ) ); add( items, means, R.string.invite_choice_relay, InviteMeans.RELAY );
means.add( InviteMeans.RELAY );
} }
if ( WiDirWrapper.enabled() ) { if ( WiDirWrapper.enabled() ) {
items.add( getString( R.string.invite_choice_p2p ) ); add( items, means, R.string.invite_choice_p2p, InviteMeans.WIFIDIRECT );
means.add( InviteMeans.WIFIDIRECT );
} }
if ( XWPrefs.getNFCToSelfEnabled( context ) if ( XWPrefs.getNFCToSelfEnabled( context ) || NFCUtils.nfcAvail( context )[0] ) {
|| NFCUtils.nfcAvail( context )[0] ) { add( items, means, R.string.invite_choice_nfc, InviteMeans.NFC );
items.add( getString( R.string.invite_choice_nfc ) );
means.add( InviteMeans.NFC );
} }
items.add( getString( R.string.slmenu_copy_sel ) ); add( items, means, R.string.slmenu_copy_sel, InviteMeans.CLIPBOARD );
means.add( InviteMeans.CLIPBOARD );
final int[] sel = { -1 }; final int[] sel = { -1 };
if ( null != lastMeans ) { if ( null != lastMeans ) {
@ -104,10 +98,10 @@ public class InviteChoicesAlert extends DlgDelegateAlert {
} }
OnClickListener selChanged = new OnClickListener() { OnClickListener selChanged = new OnClickListener() {
public void onClick( DialogInterface dlg, int view ) { public void onClick( DialogInterface dlg, int pos ) {
XWActivity activity = (XWActivity)getActivity(); XWActivity activity = (XWActivity)getActivity();
sel[0] = view; sel[0] = pos;
switch ( means.get(view) ) { switch ( means.get(pos) ) {
case CLIPBOARD: case CLIPBOARD:
String msg = String msg =
getString( R.string.not_again_clip_expl_fmt, getString( R.string.not_again_clip_expl_fmt,
@ -116,11 +110,11 @@ public class InviteChoicesAlert extends DlgDelegateAlert {
.makeNotAgainBuilder(msg, R.string.key_na_clip_expl) .makeNotAgainBuilder(msg, R.string.key_na_clip_expl)
.show(); .show();
break; break;
case SMS: case SMS_DATA:
if ( ! XWPrefs.getSMSEnabled( context ) ) { if ( ! XWPrefs.getNBSEnabled( context ) ) {
activity activity
.makeConfirmThenBuilder( R.string.warn_sms_disabled, .makeConfirmThenBuilder( R.string.warn_sms_disabled,
Action.ENABLE_SMS_ASK ) Action.ENABLE_NBS_ASK )
.setPosButton( R.string.button_enable_sms ) .setPosButton( R.string.button_enable_sms )
.setNegButton( R.string.button_later ) .setNegButton( R.string.button_later )
.show(); .show();
@ -135,7 +129,7 @@ public class InviteChoicesAlert extends DlgDelegateAlert {
final OnClickListener okClicked = new OnClickListener() { final OnClickListener okClicked = new OnClickListener() {
@Override @Override
public void onClick( DialogInterface dlg, int view ) { public void onClick( DialogInterface dlg, int pos ) {
Assert.assertTrue( Action.SKIP_CALLBACK != state.m_action ); Assert.assertTrue( Action.SKIP_CALLBACK != state.m_action );
int indx = sel[0]; int indx = sel[0];
if ( 0 <= indx ) { if ( 0 <= indx ) {
@ -154,21 +148,27 @@ public class InviteChoicesAlert extends DlgDelegateAlert {
.setPositiveButton( android.R.string.ok, okClicked ) .setPositiveButton( android.R.string.ok, okClicked )
.setNegativeButton( android.R.string.cancel, null ); .setNegativeButton( android.R.string.cancel, null );
if ( BuildConfig.DEBUG ) { if ( BuildConfig.DEBUG ) {
builder.setNeutralButton( R.string.ok_with_robots, OnClickListener ocl = new OnClickListener() {
new OnClickListener() {
@Override @Override
public void onClick( DialogInterface dlg, public void onClick( DialogInterface dlg, int pos ) {
int view ) {
if ( state.m_params[0] instanceof SentInvitesInfo ) { if ( state.m_params[0] instanceof SentInvitesInfo ) {
SentInvitesInfo sii = (SentInvitesInfo)state.m_params[0]; SentInvitesInfo sii = (SentInvitesInfo)
state.m_params[0];
sii.setRemotesRobots(); sii.setRemotesRobots();
} }
okClicked.onClick( dlg, view ); okClicked.onClick( dlg, pos );
} }
} ); };
builder.setNeutralButton( R.string.ok_with_robots, ocl );
} }
return builder.create(); return builder.create();
} }
private void add( List<String> items, List<InviteMeans> means,
int resID, InviteMeans oneMeans )
{
items.add( getString( resID ) );
means.add( oneMeans );
}
} }

View file

@ -52,7 +52,7 @@ public class PrefsDelegate extends DelegateBase
private static int[] s_keys = { private static int[] s_keys = {
R.string.key_logging_on, R.string.key_logging_on,
R.string.key_show_sms, R.string.key_show_sms,
R.string.key_enable_sms, R.string.key_enable_nbs,
R.string.key_download_path, R.string.key_download_path,
R.string.key_thumbsize, R.string.key_thumbsize,
R.string.key_xlations_locale, R.string.key_xlations_locale,
@ -190,7 +190,7 @@ public class PrefsDelegate extends DelegateBase
case R.string.key_show_sms: case R.string.key_show_sms:
SMSService.smsToastEnable( sp.getBoolean( key, false ) ); SMSService.smsToastEnable( sp.getBoolean( key, false ) );
break; break;
case R.string.key_enable_sms: case R.string.key_enable_nbs:
if ( ! sp.getBoolean( key, true ) ) { if ( ! sp.getBoolean( key, true ) ) {
SMSService.stopService( m_activity ); SMSService.stopService( m_activity );
} }
@ -247,8 +247,8 @@ public class PrefsDelegate extends DelegateBase
{ {
boolean handled = true; boolean handled = true;
switch ( action ) { switch ( action ) {
case ENABLE_SMS_DO: case ENABLE_NBS_DO:
XWPrefs.setSMSEnabled( m_activity, true ); XWPrefs.setNBSEnabled( m_activity, true );
SMSCheckBoxPreference.setChecked(); SMSCheckBoxPreference.setChecked();
break; break;
case DISABLE_RELAY_DO: case DISABLE_RELAY_DO:
@ -372,7 +372,7 @@ public class PrefsDelegate extends DelegateBase
private void hideStuff() private void hideStuff()
{ {
if ( !Utils.isGSMPhone( m_activity ) || Perms23.haveNativePerms() ) { if ( !Utils.isGSMPhone( m_activity ) || Perms23.haveNativePerms() ) {
hideOne( R.string.key_enable_sms, R.string.key_network_behavior ); hideOne( R.string.key_enable_nbs, R.string.key_network_behavior );
} }
if ( ABUtils.haveActionBar() ) { if ( ABUtils.haveActionBar() ) {

View file

@ -26,7 +26,8 @@ public enum RequestCode {
// BoardDelegate // BoardDelegate
BT_INVITE_RESULT, BT_INVITE_RESULT,
SMS_INVITE_RESULT, SMS_USER_INVITE_RESULT,
SMS_DATA_INVITE_RESULT,
RELAY_INVITE_RESULT, RELAY_INVITE_RESULT,
P2P_INVITE_RESULT, P2P_INVITE_RESULT,

View file

@ -39,7 +39,7 @@ public class SMSCheckBoxPreference extends ConfirmingCheckBoxPreference {
protected void onAttachedToActivity() protected void onAttachedToActivity()
{ {
super.onAttachedToActivity(); super.onAttachedToActivity();
if ( !Utils.deviceSupportsSMS( getContext() ) ) { if ( !Utils.deviceSupportsNBS( getContext() ) ) {
setEnabled( false ); setEnabled( false );
} }
} }
@ -47,7 +47,7 @@ public class SMSCheckBoxPreference extends ConfirmingCheckBoxPreference {
@Override @Override
protected void checkIfConfirmed() { protected void checkIfConfirmed() {
PrefsActivity activity = (PrefsActivity)getContext(); PrefsActivity activity = (PrefsActivity)getContext();
activity.showSMSEnableDialog( Action.ENABLE_SMS_DO ); activity.showSMSEnableDialog( Action.ENABLE_NBS_DO );
} }
protected static void setChecked() protected static void setChecked()

View file

@ -71,7 +71,7 @@ public class SMSInviteDelegate extends InviteDelegate {
.makeIntent( activity, SMSInviteActivity.class, .makeIntent( activity, SMSInviteActivity.class,
nMissing, info ); nMissing, info );
if ( null != info ) { if ( null != info ) {
String lastDev = info.getLastDev( InviteMeans.SMS ); 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() );

View file

@ -203,7 +203,7 @@ public class SMSService extends XWService {
int gameID, byte[] binmsg ) int gameID, byte[] binmsg )
{ {
int nSent = -1; int nSent = -1;
if ( XWPrefs.getSMSEnabled( context ) ) { if ( XWPrefs.getNBSEnabled( context ) ) {
Intent intent = getIntentTo( context, SMSAction.SEND ) Intent intent = getIntentTo( context, SMSAction.SEND )
.putExtra( PHONE, phone ) .putExtra( PHONE, phone )
.putExtra( MultiService.GAMEID, gameID ) .putExtra( MultiService.GAMEID, gameID )
@ -282,7 +282,7 @@ public class SMSService extends XWService {
public void onCreate() public void onCreate()
{ {
mHelper = new SMSServiceHelper( this ); mHelper = new SMSServiceHelper( this );
if ( Utils.deviceSupportsSMS( this ) ) { if ( Utils.deviceSupportsNBS( this ) ) {
registerReceivers(); registerReceivers();
} else { } else {
stopSelf(); stopSelf();
@ -369,7 +369,7 @@ public class SMSService extends XWService {
} }
if ( Service.START_NOT_STICKY == result if ( Service.START_NOT_STICKY == result
|| !XWPrefs.getSMSEnabled( this ) ) { || !XWPrefs.getNBSEnabled( this ) ) {
stopSelf( startId ); stopSelf( startId );
} }
@ -509,7 +509,7 @@ public class SMSService extends XWService {
private boolean sendBuffers( byte[][] fragments, String phone ) private boolean sendBuffers( byte[][] fragments, String phone )
{ {
boolean success = false; boolean success = false;
if ( XWPrefs.getSMSEnabled( this ) ) { if ( XWPrefs.getNBSEnabled( this ) ) {
// Try send-to-self // Try send-to-self
if ( XWPrefs.getSMSToSelfEnabled( this ) ) { if ( XWPrefs.getSMSToSelfEnabled( this ) ) {

View file

@ -138,7 +138,7 @@ public class Utils {
// temporary workaround for KitKat having broken use of non-data messages, // temporary workaround for KitKat having broken use of non-data messages,
// we only support SMS on kitkat if data messages have been turned on (and // we only support SMS on kitkat if data messages have been turned on (and
// that's not allowed except on GSM phones.) // that's not allowed except on GSM phones.)
public static boolean deviceSupportsSMS( Context context ) public static boolean deviceSupportsNBS( Context context )
{ {
boolean result = false; boolean result = false;
if ( Perms23.havePermission( Perm.READ_PHONE_STATE ) ) { if ( Perms23.havePermission( Perm.READ_PHONE_STATE ) ) {
@ -149,7 +149,7 @@ public class Utils {
result = TelephonyManager.PHONE_TYPE_GSM == type; result = TelephonyManager.PHONE_TYPE_GSM == type;
} }
} }
Log.d( TAG, "deviceSupportsSMS() => %b", result ); Log.d( TAG, "deviceSupportsNBS() => %b", result );
return result; return result;
} }

View file

@ -45,7 +45,6 @@ public class XWApp extends Application implements LifecycleObserver {
public static final boolean ATTACH_SUPPORTED = false; public static final boolean ATTACH_SUPPORTED = false;
public static final boolean LOG_LIFECYLE = false; public static final boolean LOG_LIFECYLE = false;
public static final boolean DEBUG_EXP_TIMERS = false; public static final boolean DEBUG_EXP_TIMERS = false;
public static final boolean SMS_INVITE_ENABLED = true;
public static final boolean LOCUTILS_ENABLED = false; public static final boolean LOCUTILS_ENABLED = false;
public static final boolean CONTEXT_MENUS_ENABLED = true; public static final boolean CONTEXT_MENUS_ENABLED = true;
public static final boolean OFFER_DUALPANE = false; public static final boolean OFFER_DUALPANE = false;

View file

@ -64,7 +64,7 @@ public class XWConnAddrPreference extends DialogPreference {
case COMMS_CONN_SMS: case COMMS_CONN_SMS:
activity activity
.makeConfirmThenBuilder( R.string.warn_sms_disabled, .makeConfirmThenBuilder( R.string.warn_sms_disabled,
Action.ENABLE_SMS_ASK ) Action.ENABLE_NBS_ASK )
.setPosButton( R.string.button_enable_sms ) .setPosButton( R.string.button_enable_sms )
.setNegButton( R.string.button_later ) .setNegButton( R.string.button_later )
.show(); .show();

View file

@ -39,16 +39,16 @@ public class XWPrefs {
// No reason to put this in xml if they're private to this file! // No reason to put this in xml if they're private to this file!
private static final String key_checked_upgrades = "key_checked_upgrades"; private static final String key_checked_upgrades = "key_checked_upgrades";
public static boolean getSMSEnabled( Context context ) public static boolean getNBSEnabled( Context context )
{ {
boolean haveNative = Perms23.haveNativePerms(); boolean haveNative = Perms23.haveNativePerms();
return haveNative || getPrefsBoolean( context, R.string.key_enable_sms, false ); return haveNative || getPrefsBoolean( context, R.string.key_enable_nbs, false );
} }
public static void setSMSEnabled( Context context, boolean enabled ) public static void setNBSEnabled( Context context, boolean enabled )
{ {
Assert.assertTrue( !Perms23.haveNativePerms() || !BuildConfig.DEBUG ); Assert.assertTrue( !Perms23.haveNativePerms() || !BuildConfig.DEBUG );
setPrefsBoolean( context, R.string.key_enable_sms, enabled ); setPrefsBoolean( context, R.string.key_enable_nbs, enabled );
} }
public static boolean getDebugEnabled( Context context ) public static boolean getDebugEnabled( Context context )

View file

@ -60,7 +60,7 @@ public class CommsAddrRec {
case COMMS_CONN_BT: case COMMS_CONN_BT:
id = R.string.invite_choice_bt; break; id = R.string.invite_choice_bt; break;
case COMMS_CONN_SMS: case COMMS_CONN_SMS:
id = R.string.connstat_sms; break; id = R.string.invite_choice_data_sms; break;
case COMMS_CONN_P2P: case COMMS_CONN_P2P:
id = R.string.invite_choice_p2p; break; id = R.string.invite_choice_p2p; break;
} }

View file

@ -61,7 +61,7 @@
<string name="key_notify_sound">key_notify_sound</string> <string name="key_notify_sound">key_notify_sound</string>
<string name="key_disable_relay">key_disable_relay</string> <string name="key_disable_relay">key_disable_relay</string>
<string name="key_notify_vibrate">key_notify_vibrate</string> <string name="key_notify_vibrate">key_notify_vibrate</string>
<string name="key_enable_sms">key_enable_sms</string> <string name="key_enable_nbs">key_enable_nbs</string>
<string name="key_enable_p2p">key_enable_p2p</string> <string name="key_enable_p2p">key_enable_p2p</string>
<string name="key_network_behavior">key_network_behavior</string> <string name="key_network_behavior">key_network_behavior</string>
<string name="key_keep_screenon">key_keep_screenon</string> <string name="key_keep_screenon">key_keep_screenon</string>

View file

@ -575,8 +575,10 @@
this alert will not be dismissed until everybody has been invited this alert will not be dismissed until everybody has been invited
and all invitations have been accepted.)</string> and all invitations have been accepted.)</string>
<string name="invit_expl_sms_fmt">Invite sent via SMS to phone <string name="invit_expl_sms_fmt">Invite sent via Data SMS to phone
number %1$s on %2$s</string> number %1$s on %2$s</string>
<string name="invit_expl_usrsms_fmt">Invite sent via SMS messaging
to phone number %1$s on %2$s</string>
<string name="invit_expl_bt_fmt">Invite sent via Bluetooth to <string name="invit_expl_bt_fmt">Invite sent via Bluetooth to
paired device \"%1$s\" on %2$s</string> paired device \"%1$s\" on %2$s</string>
<string name="invit_expl_relay_fmt">Invite forwarded by the relay <string name="invit_expl_relay_fmt">Invite forwarded by the relay
@ -1162,7 +1164,8 @@
<!-- The invitation process begins with this query. The choice is <!-- The invitation process begins with this query. The choice is
between html and plaintext formatting but I also provide some between html and plaintext formatting but I also provide some
explanation/guidance. --> explanation/guidance. -->
<string name="invite_choice_sms">SMS (texting)</string> <string name="invite_choice_user_sms">SMS (texting)</string>
<string name="invite_choice_data_sms">Data SMS</string>
<string name="invite_choice_email">Email</string> <string name="invite_choice_email">Email</string>
<string name="invite_choice_bt">Bluetooth</string> <string name="invite_choice_bt">Bluetooth</string>
<string name="invite_choice_nfc">NFC (\"Android beaming\")</string> <string name="invite_choice_nfc">NFC (\"Android beaming\")</string>
@ -1205,6 +1208,10 @@
(full link: %1$s ) (full link: %1$s )
</string> </string>
<string name="invite_sms_fmt">Tap the link to accept my
invitation and join a CrossWords game: %1$s
</string>
<!-- When I've created the invitation, in text or html, I ask <!-- When I've created the invitation, in text or html, I ask
Android to launch an app that can send it, typically an email Android to launch an app that can send it, typically an email
or messaging app. Android then asks the user to choose which or messaging app. Android then asks the user to choose which
@ -2047,8 +2054,6 @@
<!-- --> <!-- -->
<string name="connstat_relay">Internet/relay</string> <string name="connstat_relay">Internet/relay</string>
<!-- --> <!-- -->
<string name="connstat_sms">SMS/texting</string>
<!-- -->
<string name="enable_sms">Allow games via SMS</string> <string name="enable_sms">Allow games via SMS</string>
<!-- --> <!-- -->
<string name="enable_sms_summary">Only if you have unlimited texting!</string> <string name="enable_sms_summary">Only if you have unlimited texting!</string>

View file

@ -300,7 +300,7 @@
android:key="@string/key_network_behavior" android:key="@string/key_network_behavior"
> >
<org.eehouse.android.xw4.SMSCheckBoxPreference <org.eehouse.android.xw4.SMSCheckBoxPreference
android:key="@string/key_enable_sms" android:key="@string/key_enable_nbs"
android:title="@string/enable_sms" android:title="@string/enable_sms"
android:summary="@string/enable_sms_summary" android:summary="@string/enable_sms_summary"
android:defaultValue="false" android:defaultValue="false"