mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-22 07:28:16 +01:00
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:
parent
22711e75a5
commit
c78a3afb36
22 changed files with 160 additions and 113 deletions
|
@ -656,8 +656,11 @@ public class BoardDelegate extends DelegateBase
|
|||
case BT_INVITE_RESULT:
|
||||
missingMeans = InviteMeans.BLUETOOTH;
|
||||
break;
|
||||
case SMS_INVITE_RESULT:
|
||||
missingMeans = InviteMeans.SMS;
|
||||
case SMS_DATA_INVITE_RESULT:
|
||||
missingMeans = InviteMeans.SMS_DATA;
|
||||
break;
|
||||
case SMS_USER_INVITE_RESULT:
|
||||
missingMeans = InviteMeans.SMS_USER;
|
||||
break;
|
||||
case RELAY_INVITE_RESULT:
|
||||
missingMeans = InviteMeans.RELAY;
|
||||
|
@ -1062,11 +1065,10 @@ public class BoardDelegate extends DelegateBase
|
|||
case DROP_SMS_ACTION: // do nothing; work done in onNegButton case
|
||||
break;
|
||||
|
||||
case INVITE_SMS:
|
||||
case INVITE_SMS_DATA:
|
||||
int nMissing = (Integer)params[0];
|
||||
SentInvitesInfo info = (SentInvitesInfo)params[1];
|
||||
SMSInviteDelegate.launchForResult( m_activity, nMissing, info,
|
||||
RequestCode.SMS_INVITE_RESULT );
|
||||
launchPhoneNumberInvite( nMissing, info, RequestCode.SMS_DATA_INVITE_RESULT );
|
||||
break;
|
||||
|
||||
case ASKED_PHONE_STATE:
|
||||
|
@ -1118,11 +1120,11 @@ public class BoardDelegate extends DelegateBase
|
|||
showArchiveNA( false );
|
||||
break;
|
||||
|
||||
case ENABLE_SMS_DO:
|
||||
case ENABLE_NBS_DO:
|
||||
post( new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
retrySMSInvites( params );
|
||||
retryNBSInvites( params );
|
||||
}
|
||||
} );
|
||||
// FALLTHRU: so super gets called, before
|
||||
|
@ -1218,11 +1220,15 @@ public class BoardDelegate extends DelegateBase
|
|||
BTInviteDelegate.launchForResult( m_activity, m_mySIS.nMissing, info,
|
||||
RequestCode.BT_INVITE_RESULT );
|
||||
break;
|
||||
case SMS:
|
||||
case SMS_DATA:
|
||||
Perms23.tryGetPerms( this, new Perm[] { Perm.SEND_SMS,
|
||||
Perm.RECEIVE_SMS },
|
||||
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;
|
||||
case RELAY:
|
||||
RelayInviteDelegate.launchForResult( m_activity, m_mySIS.nMissing, info,
|
||||
|
@ -1498,6 +1504,12 @@ public class BoardDelegate extends DelegateBase
|
|||
return m_handler;
|
||||
}
|
||||
|
||||
private void launchPhoneNumberInvite( int nMissing, SentInvitesInfo info,
|
||||
RequestCode code )
|
||||
{
|
||||
SMSInviteDelegate.launchForResult( m_activity, nMissing, info, code );
|
||||
}
|
||||
|
||||
private void deleteAndClose()
|
||||
{
|
||||
GameUtils.deleteGame( m_activity, m_jniThread.getLock(), false );
|
||||
|
@ -2442,9 +2454,9 @@ public class BoardDelegate extends DelegateBase
|
|||
private void warnIfNoTransport()
|
||||
{
|
||||
if ( m_connTypes.contains( CommsConnType.COMMS_CONN_SMS ) ) {
|
||||
if ( !XWPrefs.getSMSEnabled( m_activity ) ) {
|
||||
if ( !XWPrefs.getNBSEnabled( m_activity ) ) {
|
||||
makeConfirmThenBuilder( R.string.warn_sms_disabled,
|
||||
Action.ENABLE_SMS_ASK )
|
||||
Action.ENABLE_NBS_ASK )
|
||||
.setPosButton( R.string.button_enable_sms )
|
||||
.setNegButton( R.string.button_later )
|
||||
.show();
|
||||
|
@ -2499,8 +2511,11 @@ public class BoardDelegate extends DelegateBase
|
|||
}
|
||||
BTService.inviteRemote( m_activity, dev, nli );
|
||||
break;
|
||||
case SMS:
|
||||
sendSMSInviteIf( dev, nli, true );
|
||||
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
|
||||
break;
|
||||
case RELAY:
|
||||
|
@ -2838,7 +2853,7 @@ public class BoardDelegate extends DelegateBase
|
|||
String value;
|
||||
value = m_summary.getStringExtra( GameSummary.EXTRA_REMATCH_PHONE );
|
||||
if ( null != value ) {
|
||||
sendSMSInviteIf( value, nli, true );
|
||||
sendNBSInviteIf( value, nli, true );
|
||||
}
|
||||
value = m_summary.getStringExtra( GameSummary.EXTRA_REMATCH_BTADDR );
|
||||
if ( null != value ) {
|
||||
|
@ -2861,15 +2876,15 @@ public class BoardDelegate extends DelegateBase
|
|||
return force;
|
||||
}
|
||||
|
||||
private void sendSMSInviteIf( String phone, NetLaunchInfo nli,
|
||||
private void sendNBSInviteIf( String phone, NetLaunchInfo nli,
|
||||
boolean askOk )
|
||||
{
|
||||
if ( XWPrefs.getSMSEnabled( m_activity ) ) {
|
||||
if ( XWPrefs.getNBSEnabled( m_activity ) ) {
|
||||
SMSService.inviteRemote( m_activity, phone, nli );
|
||||
recordInviteSent( InviteMeans.SMS, phone );
|
||||
recordInviteSent( InviteMeans.SMS_DATA, phone );
|
||||
} else if ( askOk ) {
|
||||
makeConfirmThenBuilder( R.string.warn_sms_disabled,
|
||||
Action.ENABLE_SMS_ASK )
|
||||
Action.ENABLE_NBS_ASK )
|
||||
.setPosButton( R.string.button_enable_sms )
|
||||
.setNegButton( R.string.button_later )
|
||||
.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
|
||||
&& params[0] instanceof NetLaunchInfo
|
||||
&& params[1] instanceof String ) {
|
||||
sendSMSInviteIf( (String)params[1], (NetLaunchInfo)params[0],
|
||||
sendNBSInviteIf( (String)params[1], (NetLaunchInfo)params[0],
|
||||
false );
|
||||
} else {
|
||||
Log.w( TAG, "retrySMSInvites: tests failed" );
|
||||
Log.w( TAG, "retryNBSInvites: tests failed" );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -495,7 +495,7 @@ public class ConnStatusHandler {
|
|||
boolean result = true;
|
||||
switch( connType ) {
|
||||
case COMMS_CONN_SMS:
|
||||
result = XWPrefs.getSMSEnabled( context )
|
||||
result = XWPrefs.getNBSEnabled( context )
|
||||
&& !getAirplaneModeOn( context );
|
||||
break;
|
||||
case COMMS_CONN_BT:
|
||||
|
|
|
@ -114,7 +114,7 @@ public class ConnViaViewLayout extends LinearLayout {
|
|||
Context context = getContext();
|
||||
switch( typ ) {
|
||||
case COMMS_CONN_SMS:
|
||||
enabled = XWPrefs.getSMSEnabled( context );
|
||||
enabled = XWPrefs.getNBSEnabled( context );
|
||||
break;
|
||||
case COMMS_CONN_BT:
|
||||
enabled = BTService.BTEnabled();
|
||||
|
|
|
@ -566,9 +566,11 @@ public class DBUtils {
|
|||
String msg;
|
||||
|
||||
switch ( means ) {
|
||||
case SMS:
|
||||
msg = LocUtils.getString( context, R.string.invit_expl_sms_fmt,
|
||||
target, timestamp );
|
||||
case SMS_DATA:
|
||||
case SMS_USER:
|
||||
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;
|
||||
case BLUETOOTH:
|
||||
String devName = BTService.nameForAddr( target );
|
||||
|
|
|
@ -740,11 +740,11 @@ public class DelegateBase implements DlgClickNotify,
|
|||
boolean handled = true;
|
||||
Log.d( TAG, "%s.onPosButton(%s)", getClass().getSimpleName(), action );
|
||||
switch( action ) {
|
||||
case ENABLE_SMS_ASK:
|
||||
showSMSEnableDialog( Action.ENABLE_SMS_DO );
|
||||
case ENABLE_NBS_ASK:
|
||||
showSMSEnableDialog( Action.ENABLE_NBS_DO );
|
||||
break;
|
||||
case ENABLE_SMS_DO:
|
||||
XWPrefs.setSMSEnabled( m_activity, true );
|
||||
case ENABLE_NBS_DO:
|
||||
XWPrefs.setNBSEnabled( m_activity, true );
|
||||
break;
|
||||
case ENABLE_BT_DO:
|
||||
BTService.enable();
|
||||
|
|
|
@ -78,7 +78,7 @@ public class DlgDelegate {
|
|||
NFC_TO_SELF,
|
||||
DROP_RELAY_ACTION,
|
||||
DROP_SMS_ACTION,
|
||||
INVITE_SMS,
|
||||
INVITE_SMS_DATA,
|
||||
BLANK_PICKED,
|
||||
TRAY_PICKED,
|
||||
INVITE_INFO,
|
||||
|
@ -115,9 +115,9 @@ public class DlgDelegate {
|
|||
// DwnldDelegate && GamesListDelegate
|
||||
STORAGE_CONFIRMED,
|
||||
|
||||
// clasify me
|
||||
ENABLE_SMS_ASK,
|
||||
ENABLE_SMS_DO,
|
||||
// classify me
|
||||
ENABLE_NBS_ASK,
|
||||
ENABLE_NBS_DO,
|
||||
ENABLE_BT_DO,
|
||||
ENABLE_RELAY_DO,
|
||||
ENABLE_RELAY_DO_OR,
|
||||
|
@ -296,7 +296,9 @@ public class DlgDelegate {
|
|||
// These are stored in the INVITES table. Don't change order
|
||||
// gratuitously
|
||||
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 onNegButton( Action action, Object... params );
|
||||
|
@ -401,7 +403,7 @@ public class DlgDelegate {
|
|||
public void showInviteChoicesThen( final Action action,
|
||||
SentInvitesInfo info )
|
||||
{
|
||||
if ( (XWApp.SMS_INVITE_ENABLED && Utils.deviceSupportsSMS( m_activity ))
|
||||
if ( (Utils.deviceSupportsNBS( m_activity ))
|
||||
|| XWPrefs.getNFCToSelfEnabled( m_activity )
|
||||
|| NFCUtils.nfcAvail( m_activity )[0]
|
||||
|| WiDirWrapper.enabled()
|
||||
|
|
|
@ -284,7 +284,7 @@ public class GameConfigDelegate extends DelegateBase
|
|||
switch( typ ) {
|
||||
case COMMS_CONN_SMS:
|
||||
makeConfirmThenBuilder( R.string.warn_sms_disabled,
|
||||
Action.ENABLE_SMS_ASK )
|
||||
Action.ENABLE_NBS_ASK )
|
||||
.setPosButton( R.string.button_enable_sms )
|
||||
.setNegButton( R.string.button_later )
|
||||
.show();
|
||||
|
|
|
@ -695,15 +695,8 @@ public class GameUtils {
|
|||
|
||||
public static void launchEmailInviteActivity( Activity activity, NetLaunchInfo nli )
|
||||
{
|
||||
// DbgUtils.logf( "launchEmailInviteActivity: nli=%s", nli.makeLaunchJSON() );
|
||||
Uri gameUri = nli.makeLaunchUri( activity );
|
||||
// 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 );
|
||||
|
||||
String message = makeInviteMessage( activity, nli, R.string.invite_htm_fmt );
|
||||
if ( null != message ) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction( Intent.ACTION_SEND );
|
||||
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 )
|
||||
{
|
||||
byte[] stream = savedGame( context, lock );
|
||||
|
|
|
@ -30,7 +30,7 @@ import android.support.v4.app.DialogFragment;
|
|||
import android.widget.Button;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eehouse.android.xw4.DlgDelegate.Action;
|
||||
import org.eehouse.android.xw4.DlgDelegate.ActionPair;
|
||||
|
@ -67,31 +67,25 @@ public class InviteChoicesAlert extends DlgDelegateAlert {
|
|||
lastMeans = ((SentInvitesInfo)state.m_params[0]).getLastMeans();
|
||||
}
|
||||
|
||||
if ( XWApp.SMS_INVITE_ENABLED && Utils.deviceSupportsSMS(context) ) {
|
||||
items.add( getString( R.string.invite_choice_sms ) );
|
||||
means.add( InviteMeans.SMS );
|
||||
}
|
||||
items.add( getString( R.string.invite_choice_email ) );
|
||||
means.add( InviteMeans.EMAIL );
|
||||
add( items, means, R.string.invite_choice_user_sms, InviteMeans.SMS_USER );
|
||||
add( items, means, R.string.invite_choice_email, InviteMeans.EMAIL );
|
||||
|
||||
if ( BTService.BTAvailable() ) {
|
||||
items.add( getString( R.string.invite_choice_bt ) );
|
||||
means.add( InviteMeans.BLUETOOTH );
|
||||
add( items, means, R.string.invite_choice_bt, InviteMeans.BLUETOOTH );
|
||||
}
|
||||
if ( Utils.deviceSupportsNBS(context) ) {
|
||||
add( items, means, R.string.invite_choice_data_sms, InviteMeans.SMS_DATA );
|
||||
}
|
||||
if ( BuildConfig.RELAYINVITE_SUPPORTED ) {
|
||||
items.add( getString( R.string.invite_choice_relay ) );
|
||||
means.add( InviteMeans.RELAY );
|
||||
add( items, means, R.string.invite_choice_relay, InviteMeans.RELAY );
|
||||
}
|
||||
if ( WiDirWrapper.enabled() ) {
|
||||
items.add( getString( R.string.invite_choice_p2p ) );
|
||||
means.add( InviteMeans.WIFIDIRECT );
|
||||
add( items, means, R.string.invite_choice_p2p, InviteMeans.WIFIDIRECT );
|
||||
}
|
||||
if ( XWPrefs.getNFCToSelfEnabled( context )
|
||||
|| NFCUtils.nfcAvail( context )[0] ) {
|
||||
items.add( getString( R.string.invite_choice_nfc ) );
|
||||
means.add( InviteMeans.NFC );
|
||||
if ( XWPrefs.getNFCToSelfEnabled( context ) || NFCUtils.nfcAvail( context )[0] ) {
|
||||
add( items, means, R.string.invite_choice_nfc, InviteMeans.NFC );
|
||||
}
|
||||
items.add( getString( R.string.slmenu_copy_sel ) );
|
||||
means.add( InviteMeans.CLIPBOARD );
|
||||
add( items, means, R.string.slmenu_copy_sel, InviteMeans.CLIPBOARD );
|
||||
|
||||
final int[] sel = { -1 };
|
||||
if ( null != lastMeans ) {
|
||||
|
@ -104,10 +98,10 @@ public class InviteChoicesAlert extends DlgDelegateAlert {
|
|||
}
|
||||
|
||||
OnClickListener selChanged = new OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int view ) {
|
||||
public void onClick( DialogInterface dlg, int pos ) {
|
||||
XWActivity activity = (XWActivity)getActivity();
|
||||
sel[0] = view;
|
||||
switch ( means.get(view) ) {
|
||||
sel[0] = pos;
|
||||
switch ( means.get(pos) ) {
|
||||
case CLIPBOARD:
|
||||
String msg =
|
||||
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)
|
||||
.show();
|
||||
break;
|
||||
case SMS:
|
||||
if ( ! XWPrefs.getSMSEnabled( context ) ) {
|
||||
case SMS_DATA:
|
||||
if ( ! XWPrefs.getNBSEnabled( context ) ) {
|
||||
activity
|
||||
.makeConfirmThenBuilder( R.string.warn_sms_disabled,
|
||||
Action.ENABLE_SMS_ASK )
|
||||
Action.ENABLE_NBS_ASK )
|
||||
.setPosButton( R.string.button_enable_sms )
|
||||
.setNegButton( R.string.button_later )
|
||||
.show();
|
||||
|
@ -135,7 +129,7 @@ public class InviteChoicesAlert extends DlgDelegateAlert {
|
|||
|
||||
final OnClickListener okClicked = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick( DialogInterface dlg, int view ) {
|
||||
public void onClick( DialogInterface dlg, int pos ) {
|
||||
Assert.assertTrue( Action.SKIP_CALLBACK != state.m_action );
|
||||
int indx = sel[0];
|
||||
if ( 0 <= indx ) {
|
||||
|
@ -154,21 +148,27 @@ public class InviteChoicesAlert extends DlgDelegateAlert {
|
|||
.setPositiveButton( android.R.string.ok, okClicked )
|
||||
.setNegativeButton( android.R.string.cancel, null );
|
||||
if ( BuildConfig.DEBUG ) {
|
||||
builder.setNeutralButton( R.string.ok_with_robots,
|
||||
new OnClickListener() {
|
||||
@Override
|
||||
public void onClick( DialogInterface dlg,
|
||||
int view ) {
|
||||
|
||||
if ( state.m_params[0] instanceof SentInvitesInfo ) {
|
||||
SentInvitesInfo sii = (SentInvitesInfo)state.m_params[0];
|
||||
sii.setRemotesRobots();
|
||||
}
|
||||
okClicked.onClick( dlg, view );
|
||||
}
|
||||
} );
|
||||
OnClickListener ocl = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick( DialogInterface dlg, int pos ) {
|
||||
if ( state.m_params[0] instanceof SentInvitesInfo ) {
|
||||
SentInvitesInfo sii = (SentInvitesInfo)
|
||||
state.m_params[0];
|
||||
sii.setRemotesRobots();
|
||||
}
|
||||
okClicked.onClick( dlg, pos );
|
||||
}
|
||||
};
|
||||
builder.setNeutralButton( R.string.ok_with_robots, ocl );
|
||||
}
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
private void add( List<String> items, List<InviteMeans> means,
|
||||
int resID, InviteMeans oneMeans )
|
||||
{
|
||||
items.add( getString( resID ) );
|
||||
means.add( oneMeans );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public class PrefsDelegate extends DelegateBase
|
|||
private static int[] s_keys = {
|
||||
R.string.key_logging_on,
|
||||
R.string.key_show_sms,
|
||||
R.string.key_enable_sms,
|
||||
R.string.key_enable_nbs,
|
||||
R.string.key_download_path,
|
||||
R.string.key_thumbsize,
|
||||
R.string.key_xlations_locale,
|
||||
|
@ -190,7 +190,7 @@ public class PrefsDelegate extends DelegateBase
|
|||
case R.string.key_show_sms:
|
||||
SMSService.smsToastEnable( sp.getBoolean( key, false ) );
|
||||
break;
|
||||
case R.string.key_enable_sms:
|
||||
case R.string.key_enable_nbs:
|
||||
if ( ! sp.getBoolean( key, true ) ) {
|
||||
SMSService.stopService( m_activity );
|
||||
}
|
||||
|
@ -247,8 +247,8 @@ public class PrefsDelegate extends DelegateBase
|
|||
{
|
||||
boolean handled = true;
|
||||
switch ( action ) {
|
||||
case ENABLE_SMS_DO:
|
||||
XWPrefs.setSMSEnabled( m_activity, true );
|
||||
case ENABLE_NBS_DO:
|
||||
XWPrefs.setNBSEnabled( m_activity, true );
|
||||
SMSCheckBoxPreference.setChecked();
|
||||
break;
|
||||
case DISABLE_RELAY_DO:
|
||||
|
@ -372,7 +372,7 @@ public class PrefsDelegate extends DelegateBase
|
|||
private void hideStuff()
|
||||
{
|
||||
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() ) {
|
||||
|
|
|
@ -26,7 +26,8 @@ public enum RequestCode {
|
|||
|
||||
// BoardDelegate
|
||||
BT_INVITE_RESULT,
|
||||
SMS_INVITE_RESULT,
|
||||
SMS_USER_INVITE_RESULT,
|
||||
SMS_DATA_INVITE_RESULT,
|
||||
RELAY_INVITE_RESULT,
|
||||
P2P_INVITE_RESULT,
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public class SMSCheckBoxPreference extends ConfirmingCheckBoxPreference {
|
|||
protected void onAttachedToActivity()
|
||||
{
|
||||
super.onAttachedToActivity();
|
||||
if ( !Utils.deviceSupportsSMS( getContext() ) ) {
|
||||
if ( !Utils.deviceSupportsNBS( getContext() ) ) {
|
||||
setEnabled( false );
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class SMSCheckBoxPreference extends ConfirmingCheckBoxPreference {
|
|||
@Override
|
||||
protected void checkIfConfirmed() {
|
||||
PrefsActivity activity = (PrefsActivity)getContext();
|
||||
activity.showSMSEnableDialog( Action.ENABLE_SMS_DO );
|
||||
activity.showSMSEnableDialog( Action.ENABLE_NBS_DO );
|
||||
}
|
||||
|
||||
protected static void setChecked()
|
||||
|
|
|
@ -71,7 +71,7 @@ public class SMSInviteDelegate extends InviteDelegate {
|
|||
.makeIntent( activity, SMSInviteActivity.class,
|
||||
nMissing, info );
|
||||
if ( null != info ) {
|
||||
String lastDev = info.getLastDev( InviteMeans.SMS );
|
||||
String lastDev = info.getLastDev( InviteMeans.SMS_DATA );
|
||||
intent.putExtra( INTENT_KEY_LASTDEV, lastDev );
|
||||
}
|
||||
activity.startActivityForResult( intent, requestCode.ordinal() );
|
||||
|
|
|
@ -203,7 +203,7 @@ public class SMSService extends XWService {
|
|||
int gameID, byte[] binmsg )
|
||||
{
|
||||
int nSent = -1;
|
||||
if ( XWPrefs.getSMSEnabled( context ) ) {
|
||||
if ( XWPrefs.getNBSEnabled( context ) ) {
|
||||
Intent intent = getIntentTo( context, SMSAction.SEND )
|
||||
.putExtra( PHONE, phone )
|
||||
.putExtra( MultiService.GAMEID, gameID )
|
||||
|
@ -282,7 +282,7 @@ public class SMSService extends XWService {
|
|||
public void onCreate()
|
||||
{
|
||||
mHelper = new SMSServiceHelper( this );
|
||||
if ( Utils.deviceSupportsSMS( this ) ) {
|
||||
if ( Utils.deviceSupportsNBS( this ) ) {
|
||||
registerReceivers();
|
||||
} else {
|
||||
stopSelf();
|
||||
|
@ -369,7 +369,7 @@ public class SMSService extends XWService {
|
|||
}
|
||||
|
||||
if ( Service.START_NOT_STICKY == result
|
||||
|| !XWPrefs.getSMSEnabled( this ) ) {
|
||||
|| !XWPrefs.getNBSEnabled( this ) ) {
|
||||
stopSelf( startId );
|
||||
}
|
||||
|
||||
|
@ -509,7 +509,7 @@ public class SMSService extends XWService {
|
|||
private boolean sendBuffers( byte[][] fragments, String phone )
|
||||
{
|
||||
boolean success = false;
|
||||
if ( XWPrefs.getSMSEnabled( this ) ) {
|
||||
if ( XWPrefs.getNBSEnabled( this ) ) {
|
||||
|
||||
// Try send-to-self
|
||||
if ( XWPrefs.getSMSToSelfEnabled( this ) ) {
|
||||
|
|
|
@ -138,7 +138,7 @@ public class Utils {
|
|||
// 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
|
||||
// that's not allowed except on GSM phones.)
|
||||
public static boolean deviceSupportsSMS( Context context )
|
||||
public static boolean deviceSupportsNBS( Context context )
|
||||
{
|
||||
boolean result = false;
|
||||
if ( Perms23.havePermission( Perm.READ_PHONE_STATE ) ) {
|
||||
|
@ -149,7 +149,7 @@ public class Utils {
|
|||
result = TelephonyManager.PHONE_TYPE_GSM == type;
|
||||
}
|
||||
}
|
||||
Log.d( TAG, "deviceSupportsSMS() => %b", result );
|
||||
Log.d( TAG, "deviceSupportsNBS() => %b", result );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,6 @@ public class XWApp extends Application implements LifecycleObserver {
|
|||
public static final boolean ATTACH_SUPPORTED = false;
|
||||
public static final boolean LOG_LIFECYLE = 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 CONTEXT_MENUS_ENABLED = true;
|
||||
public static final boolean OFFER_DUALPANE = false;
|
||||
|
|
|
@ -64,7 +64,7 @@ public class XWConnAddrPreference extends DialogPreference {
|
|||
case COMMS_CONN_SMS:
|
||||
activity
|
||||
.makeConfirmThenBuilder( R.string.warn_sms_disabled,
|
||||
Action.ENABLE_SMS_ASK )
|
||||
Action.ENABLE_NBS_ASK )
|
||||
.setPosButton( R.string.button_enable_sms )
|
||||
.setNegButton( R.string.button_later )
|
||||
.show();
|
||||
|
|
|
@ -39,16 +39,16 @@ public class XWPrefs {
|
|||
// No reason to put this in xml if they're private to this file!
|
||||
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();
|
||||
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 );
|
||||
setPrefsBoolean( context, R.string.key_enable_sms, enabled );
|
||||
setPrefsBoolean( context, R.string.key_enable_nbs, enabled );
|
||||
}
|
||||
|
||||
public static boolean getDebugEnabled( Context context )
|
||||
|
|
|
@ -60,7 +60,7 @@ public class CommsAddrRec {
|
|||
case COMMS_CONN_BT:
|
||||
id = R.string.invite_choice_bt; break;
|
||||
case COMMS_CONN_SMS:
|
||||
id = R.string.connstat_sms; break;
|
||||
id = R.string.invite_choice_data_sms; break;
|
||||
case COMMS_CONN_P2P:
|
||||
id = R.string.invite_choice_p2p; break;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
<string name="key_notify_sound">key_notify_sound</string>
|
||||
<string name="key_disable_relay">key_disable_relay</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_network_behavior">key_network_behavior</string>
|
||||
<string name="key_keep_screenon">key_keep_screenon</string>
|
||||
|
|
|
@ -575,8 +575,10 @@
|
|||
this alert will not be dismissed until everybody has been invited
|
||||
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>
|
||||
<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
|
||||
paired device \"%1$s\" on %2$s</string>
|
||||
<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
|
||||
between html and plaintext formatting but I also provide some
|
||||
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_bt">Bluetooth</string>
|
||||
<string name="invite_choice_nfc">NFC (\"Android beaming\")</string>
|
||||
|
@ -1205,6 +1208,10 @@
|
|||
(full link: %1$s )
|
||||
</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
|
||||
Android to launch an app that can send it, typically an email
|
||||
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_sms">SMS/texting</string>
|
||||
<!-- -->
|
||||
<string name="enable_sms">Allow games via SMS</string>
|
||||
<!-- -->
|
||||
<string name="enable_sms_summary">Only if you have unlimited texting!</string>
|
||||
|
|
|
@ -300,7 +300,7 @@
|
|||
android:key="@string/key_network_behavior"
|
||||
>
|
||||
<org.eehouse.android.xw4.SMSCheckBoxPreference
|
||||
android:key="@string/key_enable_sms"
|
||||
android:key="@string/key_enable_nbs"
|
||||
android:title="@string/enable_sms"
|
||||
android:summary="@string/enable_sms_summary"
|
||||
android:defaultValue="false"
|
||||
|
|
Loading…
Reference in a new issue