mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-28 07:58:08 +01:00
change "nbs" to "sms" everywhere. No other code change.
This commit is contained in:
parent
7b9e835722
commit
3b10f1593c
24 changed files with 151 additions and 214 deletions
|
@ -66,7 +66,7 @@
|
|||
<activity android:name="BTInviteActivity"
|
||||
android:theme="@android:style/Theme.Dialog"
|
||||
/>
|
||||
<activity android:name="NBSInviteActivity"
|
||||
<activity android:name="SMSInviteActivity"
|
||||
android:theme="@android:style/Theme.Dialog"
|
||||
/>
|
||||
|
||||
|
@ -163,14 +163,13 @@
|
|||
|
||||
<service android:name="BTService"/>
|
||||
|
||||
<receiver android:name="NBSReceiver" >
|
||||
<receiver android:name="SMSReceiver" >
|
||||
<intent-filter android:priority="999" >
|
||||
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
|
||||
<service android:name="NBSService"/>
|
||||
<service android:name="SMSService"/>
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
|
@ -10,7 +10,7 @@ local_C_INCLUDES+= \
|
|||
|
||||
local_LDLIBS += -llog
|
||||
|
||||
# local_DEBUG = -DMEM_DEBUG -DDEBUG -DENABLE_LOGGING
|
||||
local_DEBUG = -DMEM_DEBUG -DDEBUG -DENABLE_LOGGING
|
||||
local_DEFINES += \
|
||||
$(local_DEBUG) \
|
||||
-DXWFEATURE_RELAY \
|
||||
|
|
|
@ -27,5 +27,5 @@ prefs_w_buttons.xml
|
|||
relay_game_config.xml
|
||||
rename_game.xml
|
||||
select_dialog_item.xml
|
||||
nbsinviter.xml
|
||||
nbsinviter_item.xml
|
||||
smsinviter_item.xml
|
||||
smsinviter.xml
|
||||
|
|
|
@ -26,14 +26,12 @@ GameUtils.java
|
|||
GitVersion.java
|
||||
MountEventReceiver.java
|
||||
MultiMsgSink.java
|
||||
NBSReceiver.java
|
||||
NetLaunchInfo.java
|
||||
NetStateCache.java
|
||||
NetUtils.java
|
||||
NewGameActivity.java
|
||||
PollListPreference.java
|
||||
PrefsActivity.java
|
||||
ReceiveNBS.java
|
||||
RefreshNamesTask.java
|
||||
RelayGameActivity.java
|
||||
RelayMsgSink.java
|
||||
|
@ -51,7 +49,8 @@ XWListItem.java
|
|||
XWListPreference.java
|
||||
GameNamer.java
|
||||
LookupActivity.java
|
||||
NBSInviteActivity.java
|
||||
NBSService.java
|
||||
InviteActivity.java
|
||||
NBSListItem.java
|
||||
SMSInviteActivity.java
|
||||
SMSListItem.java
|
||||
SMSReceiver.java
|
||||
SMSService.java
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.eehouse.android.xw4bt.jni.XwJNI;
|
|||
public class XWApp extends Application {
|
||||
|
||||
public static final boolean BTSUPPORTED = true;
|
||||
public static final boolean NBSSUPPORTED = true;
|
||||
public static final boolean SMSSUPPORTED = true;
|
||||
|
||||
private static UUID s_UUID = null;
|
||||
private static Boolean s_onEmulator = null;
|
||||
|
@ -59,8 +59,6 @@ public class XWApp extends Application {
|
|||
return s_UUID;
|
||||
}
|
||||
|
||||
public static short getNBSPort() { return (short)50009; }
|
||||
|
||||
public static String getAppName( Context context )
|
||||
{
|
||||
return context.getString( R.string.app_name );
|
||||
|
|
|
@ -144,13 +144,5 @@
|
|||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<!-- <receiver android:name="NBSReceiver"> -->
|
||||
<!-- <intent-filter android:priority="10"> -->
|
||||
<!-- <action android:name="android.intent.action.DATA_SMS_RECEIVED" /> -->
|
||||
<!-- <data android:scheme="sms" /> -->
|
||||
<!-- <data android:port="50009" /> -->
|
||||
<!-- </intent-filter> -->
|
||||
<!-- </receiver> -->
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
|
@ -105,32 +105,32 @@
|
|||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<!-- NBS -->
|
||||
<TextView android:id="@+id/nbs_separator"
|
||||
<!-- SMS -->
|
||||
<TextView android:id="@+id/sms_separator"
|
||||
style="@style/config_separator"
|
||||
android:layout_marginTop="10dip"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="@string/newgame_nbs_header"
|
||||
android:text="@string/newgame_sms_header"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<LinearLayout android:id="@+id/nbs_disabled"
|
||||
<LinearLayout android:id="@+id/sms_disabled"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
>
|
||||
<TextView android:text="@string/nbs_disabled"
|
||||
<TextView android:text="@string/sms_disabled"
|
||||
style="@style/relay_explain"
|
||||
/>
|
||||
<Button android:id="@+id/newgame_enable_nbs"
|
||||
<Button android:id="@+id/newgame_enable_sms"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/newgame_enable_nbs"
|
||||
android:text="@string/newgame_enable_sms"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout android:id="@+id/nbs_stuff"
|
||||
<LinearLayout android:id="@+id/sms_stuff"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -148,7 +148,7 @@
|
|||
android:layout_weight="0"
|
||||
android:layout_gravity="center_vertical|center_horizontal"
|
||||
/>
|
||||
<TextView android:text="@string/nbs_networked_desc"
|
||||
<TextView android:text="@string/sms_networked_desc"
|
||||
style="@style/relay_explain"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
@ -157,14 +157,14 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
<Button android:id="@+id/newgame_invite_nbs"
|
||||
<Button android:id="@+id/newgame_invite_sms"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/newgame_invite"
|
||||
/>
|
||||
|
||||
<Button android:id="@+id/newgame_nbs_config"
|
||||
<Button android:id="@+id/newgame_sms_config"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
>
|
||||
<Button android:id="@+id/button_add"
|
||||
android:text="@string/button_nbs_add"
|
||||
android:text="@string/button_sms_add"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<org.eehouse.android.xw4.NBSListItem
|
||||
<org.eehouse.android.xw4.SMSListItem
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
|
@ -28,4 +28,4 @@
|
|||
android:layout_width="wrap_content"
|
||||
/>
|
||||
</LinearLayout>
|
||||
</org.eehouse.android.xw4.NBSListItem>
|
||||
</org.eehouse.android.xw4.SMSListItem>
|
|
@ -61,8 +61,8 @@
|
|||
<string name="key_closed_langs">key_closed_langs</string>
|
||||
<string name="key_bt_names">key_bt_names</string>
|
||||
<string name="key_bt_addrs">key_bt_addrs</string>
|
||||
<string name="key_nbs_names">key_nbs_names</string>
|
||||
<string name="key_nbs_phones">key_nbs_phones</string>
|
||||
<string name="key_sms_names">key_sms_names</string>
|
||||
<string name="key_sms_phones">key_sms_phones</string>
|
||||
|
||||
<string name="key_notagain_sync">key_notagain_sync</string>
|
||||
<string name="key_notagain_chat">key_notagain_chat</string>
|
||||
|
|
|
@ -1875,28 +1875,28 @@
|
|||
<string name="game_btname_title">Bluetooth game name</string>
|
||||
<string name="dft_bt_namef">Game %X</string>
|
||||
|
||||
<string name="newgame_nbs_header">New SMS Game</string>
|
||||
<string name="nbs_networked_desc">Create a game that will be
|
||||
<string name="newgame_sms_header">New SMS Game</string>
|
||||
<string name="sms_networked_desc">Create a game that will be
|
||||
played via invisible text messages. !!!DO NOT DO THIS UNLESS YOU HAVE
|
||||
AN UNLIMITED TEXT MESSAGING PLAN!!!</string>
|
||||
<string name="nbs_disabled">nbs_disabled</string>
|
||||
<string name="newgame_enable_nbs">newgame_enable_nbs</string>
|
||||
<string name="sms_disabled">sms_disabled</string>
|
||||
<string name="newgame_enable_sms">newgame_enable_sms</string>
|
||||
<string name="err_no_phone">Phone number required</string>
|
||||
<string name="dft_nbs_namef">SMS Game %X</string>
|
||||
<string name="nbs_devs_missing">Missing connections? Invite SMS
|
||||
<string name="dft_sms_namef">SMS Game %X</string>
|
||||
<string name="sms_devs_missing">Missing connections? Invite SMS
|
||||
devs? (I won\'t ask again until you reopen this game.)</string>
|
||||
|
||||
<string name="new_nbs_title">New game via SMS</string>
|
||||
<string name="new_nbs_bodyf">Phone with number %s has invited you to
|
||||
<string name="new_sms_title">New game via SMS</string>
|
||||
<string name="new_sms_bodyf">Phone with number %s has invited you to
|
||||
play</string>
|
||||
<string name="new_nbsmove_title">New move via SMS</string>
|
||||
<string name="new_smsmove_title">New move via SMS</string>
|
||||
|
||||
<string name="button_nbs_add">Add contact</string>
|
||||
<string name="invite_nbs_descf">Please select the %d phone numbers you
|
||||
<string name="button_sms_add">Add contact</string>
|
||||
<string name="invite_sms_descf">Please select the %d phone numbers you
|
||||
want to invite to this game. Use the Add contact button if you
|
||||
don\'t see a number you want.</string>
|
||||
<string name="manual_number_hint">Other number</string>
|
||||
<string name="manual_owner_name">(Entered manually)</string>
|
||||
<string name="nbs_nomobile">Contact has no mobile number.</string>
|
||||
<string name="nbs_nomobilef">Contact for %s has no mobile number.</string>
|
||||
<string name="sms_nomobile">Contact has no mobile number.</string>
|
||||
<string name="sms_nomobilef">Contact for %s has no mobile number.</string>
|
||||
</resources>
|
||||
|
|
|
@ -76,7 +76,7 @@ public class BoardActivity extends XWActivity
|
|||
|
||||
private static final int CHAT_REQUEST = 1;
|
||||
private static final int BT_INVITE_RESULT = 2;
|
||||
private static final int NBS_INVITE_RESULT = 3;
|
||||
private static final int SMS_INVITE_RESULT = 3;
|
||||
|
||||
private static final int SCREEN_ON_TIME = 10 * 60 * 1000; // 10 mins
|
||||
|
||||
|
@ -97,7 +97,7 @@ public class BoardActivity extends XWActivity
|
|||
private static final int BUTTON_BROWSE_ACTION = 15;
|
||||
private static final int VALUES_ACTION = 16;
|
||||
private static final int BT_PICK_ACTION = 17;
|
||||
private static final int NBS_PICK_ACTION = 18;
|
||||
private static final int SMS_PICK_ACTION = 18;
|
||||
|
||||
private static final String DLG_TITLE = "DLG_TITLE";
|
||||
private static final String DLG_TITLESTR = "DLG_TITLESTR";
|
||||
|
@ -532,10 +532,10 @@ public class BoardActivity extends XWActivity
|
|||
// onResume -- meaning m_gi etc are still null.
|
||||
m_missingDevs = data.getStringArrayExtra( BTInviteActivity.DEVS );
|
||||
break;
|
||||
case NBS_INVITE_RESULT:
|
||||
case SMS_INVITE_RESULT:
|
||||
// onActivityResult is called immediately *before*
|
||||
// onResume -- meaning m_gi etc are still null.
|
||||
m_missingDevs = data.getStringArrayExtra( NBSInviteActivity.DEVS );
|
||||
m_missingDevs = data.getStringArrayExtra( SMSInviteActivity.DEVS );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -745,9 +745,9 @@ public class BoardActivity extends XWActivity
|
|||
GameUtils.launchBTInviter( this, m_nMissingPlayers,
|
||||
BT_INVITE_RESULT );
|
||||
break;
|
||||
case NBS_PICK_ACTION:
|
||||
GameUtils.launchNBSInviter( this, m_nMissingPlayers,
|
||||
NBS_INVITE_RESULT );
|
||||
case SMS_PICK_ACTION:
|
||||
GameUtils.launchSMSInviter( this, m_nMissingPlayers,
|
||||
SMS_INVITE_RESULT );
|
||||
break;
|
||||
case COMMIT_ACTION:
|
||||
cmd = JNIThread.JNICmd.CMD_COMMIT;
|
||||
|
@ -1353,8 +1353,8 @@ public class BoardActivity extends XWActivity
|
|||
action = BT_PICK_ACTION;
|
||||
break;
|
||||
case COMMS_CONN_SMS:
|
||||
msgID = R.string.nbs_devs_missing;
|
||||
action = NBS_PICK_ACTION;
|
||||
msgID = R.string.sms_devs_missing;
|
||||
action = SMS_PICK_ACTION;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1723,7 +1723,7 @@ public class BoardActivity extends XWActivity
|
|||
|
||||
private void tryInvites()
|
||||
{
|
||||
if ( XWApp.BTSUPPORTED || XWApp.NBSSUPPORTED ) {
|
||||
if ( XWApp.BTSUPPORTED || XWApp.SMSSUPPORTED ) {
|
||||
if ( null != m_missingDevs ) {
|
||||
String gameName = GameUtils.getName( this, m_rowid );
|
||||
boolean doProgress = false;
|
||||
|
@ -1736,7 +1736,7 @@ public class BoardActivity extends XWActivity
|
|||
m_gi.nPlayers, 1 );
|
||||
break;
|
||||
case COMMS_CONN_SMS:
|
||||
NBSService.inviteRemote( this, dev, m_gi.gameID,
|
||||
SMSService.inviteRemote( this, dev, m_gi.gameID,
|
||||
gameName, m_gi.dictLang,
|
||||
m_gi.nPlayers, 1 );
|
||||
break;
|
||||
|
|
|
@ -380,7 +380,7 @@ public class CommsTransport implements TransportProcs,
|
|||
}
|
||||
break;
|
||||
case COMMS_CONN_SMS:
|
||||
nSent = NBSService.sendPacket( m_context, addr.sms_phone,
|
||||
nSent = SMSService.sendPacket( m_context, addr.sms_phone,
|
||||
gameID, buf );
|
||||
break;
|
||||
case COMMS_CONN_BT:
|
||||
|
|
|
@ -454,7 +454,7 @@ public class GameUtils {
|
|||
null, gameID, isHost );
|
||||
}
|
||||
|
||||
public static long makeNewNBSGame( Context context, int gameID,
|
||||
public static long makeNewSMSGame( Context context, int gameID,
|
||||
CommsAddrRec addr, int lang,
|
||||
int nPlayersT, int nPlayersH )
|
||||
{
|
||||
|
@ -476,11 +476,11 @@ public class GameUtils {
|
|||
activity.startActivityForResult( intent, requestCode );
|
||||
}
|
||||
|
||||
public static void launchNBSInviter( Activity activity, int nMissing,
|
||||
public static void launchSMSInviter( Activity activity, int nMissing,
|
||||
int requestCode )
|
||||
{
|
||||
Intent intent = new Intent( activity, NBSInviteActivity.class );
|
||||
intent.putExtra( NBSInviteActivity.INTENT_KEY_NMISSING, nMissing );
|
||||
Intent intent = new Intent( activity, SMSInviteActivity.class );
|
||||
intent.putExtra( SMSInviteActivity.INTENT_KEY_NMISSING, nMissing );
|
||||
activity.startActivityForResult( intent, requestCode );
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ public class GamesList extends XWListActivity
|
|||
private long m_rowid;
|
||||
private String m_nameField;
|
||||
private NetLaunchInfo m_netLaunchInfo;
|
||||
private String m_nbsPhone;
|
||||
// private String m_smsPhone;
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog( int id )
|
||||
|
|
|
@ -51,9 +51,9 @@ public class NewGameActivity extends XWActivity {
|
|||
private static final String SAVE_REMOTEGAME = "REMOTEGAME";
|
||||
private static final String SAVE_GAMEID = "GAMEID";
|
||||
private static final int CONFIG_FOR_BT = 1;
|
||||
private static final int CONFIG_FOR_NBS = 2;
|
||||
private static final int CONFIG_FOR_SMS = 2;
|
||||
private static final int INVITE_FOR_BT = 3;
|
||||
private static final int INVITE_FOR_NBS = 4;
|
||||
private static final int INVITE_FOR_SMS = 4;
|
||||
|
||||
// Dialogs
|
||||
private static final int NAME_GAME = DlgDelegate.DIALOG_LAST + 1;
|
||||
|
@ -113,7 +113,7 @@ public class NewGameActivity extends XWActivity {
|
|||
} );
|
||||
|
||||
checkEnableBT( true );
|
||||
checkEnableNBS();
|
||||
checkEnableSMS();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -160,7 +160,7 @@ public class NewGameActivity extends XWActivity {
|
|||
if ( Activity.RESULT_CANCELED != resultCode ) {
|
||||
switch ( requestCode ) {
|
||||
case CONFIG_FOR_BT:
|
||||
case CONFIG_FOR_NBS:
|
||||
case CONFIG_FOR_SMS:
|
||||
if ( Activity.RESULT_CANCELED == resultCode ) {
|
||||
DBUtils.deleteGame( this, m_newRowID );
|
||||
} else {
|
||||
|
@ -184,20 +184,20 @@ public class NewGameActivity extends XWActivity {
|
|||
}
|
||||
break;
|
||||
|
||||
case INVITE_FOR_NBS:
|
||||
case INVITE_FOR_SMS:
|
||||
if ( Activity.RESULT_CANCELED != resultCode ) {
|
||||
String[] phones =
|
||||
data.getStringArrayExtra( NBSInviteActivity.DEVS );
|
||||
data.getStringArrayExtra( SMSInviteActivity.DEVS );
|
||||
Assert.assertTrue( 1 == phones.length );
|
||||
|
||||
m_gameID = GameUtils.newGameID();
|
||||
m_gameName = Utils.format( this, R.string.dft_nbs_namef,
|
||||
m_gameName = Utils.format( this, R.string.dft_sms_namef,
|
||||
m_gameID & 0xFFFF );
|
||||
NBSService.inviteRemote( NewGameActivity.this, phones[0],
|
||||
SMSService.inviteRemote( NewGameActivity.this, phones[0],
|
||||
m_gameID, m_gameName,
|
||||
m_lang, 2, 1 );
|
||||
long rowid =
|
||||
GameUtils.makeNewNBSGame( NewGameActivity.this,
|
||||
GameUtils.makeNewSMSGame( NewGameActivity.this,
|
||||
m_gameID, null, m_lang,
|
||||
2, 1 );
|
||||
GameUtils.launchGame( NewGameActivity.this, rowid, true );
|
||||
|
@ -348,14 +348,14 @@ public class NewGameActivity extends XWActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private void makeNewNBSGame( boolean useDefaults )
|
||||
private void makeNewSMSGame( boolean useDefaults )
|
||||
{
|
||||
int gameID = GameUtils.newGameID();
|
||||
if ( !useDefaults ) {
|
||||
m_newRowID = GameUtils.makeNewNBSGame( NewGameActivity.this,
|
||||
m_newRowID = GameUtils.makeNewSMSGame( NewGameActivity.this,
|
||||
gameID, null, m_lang,
|
||||
2, 1 ); // initial defaults
|
||||
String name = Utils.format( this, R.string.dft_nbs_namef,
|
||||
String name = Utils.format( this, R.string.dft_sms_namef,
|
||||
gameID & 0xFFFF );
|
||||
DBUtils.setName( this, m_newRowID, name );
|
||||
|
||||
|
@ -363,9 +363,9 @@ public class NewGameActivity extends XWActivity {
|
|||
intent.setAction( Intent.ACTION_EDIT );
|
||||
intent.putExtra( GameUtils.INTENT_KEY_ROWID, m_newRowID );
|
||||
intent.putExtra( GameUtils.INTENT_FORRESULT_ROWID, true );
|
||||
startActivityForResult( intent, CONFIG_FOR_NBS );
|
||||
startActivityForResult( intent, CONFIG_FOR_SMS );
|
||||
} else {
|
||||
GameUtils.launchNBSInviter( this, 1, INVITE_FOR_NBS );
|
||||
GameUtils.launchSMSInviter( this, 1, INVITE_FOR_SMS );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -416,35 +416,35 @@ public class NewGameActivity extends XWActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private void checkEnableNBS()
|
||||
private void checkEnableSMS()
|
||||
{
|
||||
if ( XWApp.NBSSUPPORTED ) {
|
||||
if ( XWApp.SMSSUPPORTED ) {
|
||||
boolean enabled = true; // is the phone on
|
||||
findViewById( R.id.nbs_separator ).setVisibility( View.VISIBLE );
|
||||
findViewById( R.id.sms_separator ).setVisibility( View.VISIBLE );
|
||||
|
||||
findViewById( R.id.nbs_disabled ).
|
||||
findViewById( R.id.sms_disabled ).
|
||||
setVisibility( enabled ? View.GONE : View.VISIBLE );
|
||||
findViewById( R.id.nbs_stuff ).
|
||||
findViewById( R.id.sms_stuff ).
|
||||
setVisibility( enabled ? View.VISIBLE : View.GONE );
|
||||
|
||||
Button button;
|
||||
if ( enabled ) {
|
||||
button = (Button)findViewById( R.id.newgame_invite_nbs );
|
||||
button = (Button)findViewById( R.id.newgame_invite_sms );
|
||||
button.setOnClickListener( new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick( View v ) {
|
||||
makeNewNBSGame( true );
|
||||
makeNewSMSGame( true );
|
||||
}
|
||||
} );
|
||||
button = (Button)findViewById( R.id.newgame_nbs_config );
|
||||
button = (Button)findViewById( R.id.newgame_sms_config );
|
||||
button.setOnClickListener( new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick( View v ) {
|
||||
makeNewNBSGame( false );
|
||||
makeNewSMSGame( false );
|
||||
}
|
||||
} );
|
||||
} else {
|
||||
button = (Button)findViewById( R.id.newgame_enable_nbs );
|
||||
button = (Button)findViewById( R.id.newgame_enable_sms );
|
||||
button.setOnClickListener( new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick( View v ) {
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant reinstall"; -*- */
|
||||
/*
|
||||
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
|
||||
* rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
// package org.eehouse.android.xw4;
|
||||
|
||||
// import android.content.BroadcastReceiver;
|
||||
// import android.content.Context;
|
||||
// import android.content.Intent;
|
||||
// import android.os.Bundle;
|
||||
// import android.telephony.SmsMessage;
|
||||
|
||||
// public class ReceiveNBS extends BroadcastReceiver {
|
||||
|
||||
// @Override
|
||||
// public void onReceive( Context context, Intent intent )
|
||||
// {
|
||||
// DbgUtils.logf( "onReceive called: %s", intent.toString() );
|
||||
|
||||
// Bundle bundle = intent.getExtras();
|
||||
// SmsMessage[] smsarr = null;
|
||||
// if (bundle != null) {
|
||||
// Object[] pdus = (Object[]) bundle.get("pdus");
|
||||
// smsarr = new SmsMessage[pdus.length];
|
||||
// for ( int ii = 0; ii < pdus.length; ii++){
|
||||
// smsarr[ii] = SmsMessage.createFromPdu((byte[])pdus[ii]);
|
||||
// DbgUtils.logf( "from %s", smsarr[ii].getOriginatingAddress() );
|
||||
// // buf.append( smsarr[ii].getMessageBody() );
|
||||
// // XwJni.handle( XwJni.JNICmd.CMD_RECEIVE,
|
||||
// // smsarr[ii].getMessageBody() );
|
||||
// }
|
||||
// }
|
||||
// } // onReceive
|
||||
|
||||
// }
|
|
@ -39,22 +39,22 @@ import junit.framework.Assert;
|
|||
|
||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
||||
|
||||
public class NBSInviteActivity extends InviteActivity {
|
||||
public class SMSInviteActivity extends InviteActivity {
|
||||
|
||||
private static final int GET_CONTACT = 1;
|
||||
|
||||
private ArrayList<String> m_names;
|
||||
private ArrayList<String> m_phones;
|
||||
private NBSPhonesAdapter m_adapter;
|
||||
private SMSPhonesAdapter m_adapter;
|
||||
private EditText m_manualField;
|
||||
|
||||
@Override
|
||||
protected void onCreate( Bundle savedInstanceState )
|
||||
{
|
||||
super.onCreate( savedInstanceState, R.layout.nbsinviter,
|
||||
super.onCreate( savedInstanceState, R.layout.smsinviter,
|
||||
R.id.button_invite, R.id.button_add,
|
||||
R.id.button_clear, R.id.invite_desc,
|
||||
R.string.invite_nbs_descf );
|
||||
R.string.invite_sms_descf );
|
||||
|
||||
m_manualField = (EditText)findViewById( R.id.phone_edit );
|
||||
ImageButton button = (ImageButton)findViewById( R.id.manual_add_button );
|
||||
|
@ -101,7 +101,7 @@ public class NBSInviteActivity extends InviteActivity {
|
|||
ListView list = (ListView)findViewById( android.R.id.list );
|
||||
int count = list.getChildCount();
|
||||
for ( int ii = count - 1; ii >= 0; --ii ) {
|
||||
NBSListItem item = (NBSListItem)list.getChildAt( ii );
|
||||
SMSListItem item = (SMSListItem)list.getChildAt( ii );
|
||||
if ( item.isChecked() ) {
|
||||
m_phones.remove( ii );
|
||||
m_names.remove( ii );
|
||||
|
@ -117,7 +117,7 @@ public class NBSInviteActivity extends InviteActivity {
|
|||
int count = list.getChildCount();
|
||||
int index = 0;
|
||||
for ( int ii = 0; ii < count; ++ii ) {
|
||||
NBSListItem item = (NBSListItem)list.getChildAt( ii );
|
||||
SMSListItem item = (SMSListItem)list.getChildAt( ii );
|
||||
if ( item.isChecked() ) {
|
||||
result[index++] = item.getNumber();
|
||||
}
|
||||
|
@ -162,8 +162,8 @@ public class NBSInviteActivity extends InviteActivity {
|
|||
rebuildList();
|
||||
} else {
|
||||
int resid = null != name && 0 < name.length()
|
||||
? R.string.nbs_nomobilef
|
||||
: R.string.nbs_nomobile;
|
||||
? R.string.sms_nomobilef
|
||||
: R.string.sms_nomobile;
|
||||
String msg = Utils.format( this, resid, name );
|
||||
showOKOnlyDialog( msg );
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ public class NBSInviteActivity extends InviteActivity {
|
|||
|
||||
private void rebuildList()
|
||||
{
|
||||
m_adapter = new NBSPhonesAdapter();
|
||||
m_adapter = new SMSPhonesAdapter();
|
||||
setListAdapter( m_adapter );
|
||||
m_checkCount = 0;
|
||||
tryEnable();
|
||||
|
@ -181,31 +181,31 @@ public class NBSInviteActivity extends InviteActivity {
|
|||
|
||||
private void getSavedState()
|
||||
{
|
||||
m_names = CommonPrefs.getNBSNames( this );
|
||||
m_phones = CommonPrefs.getNBSPhones( this );
|
||||
m_names = CommonPrefs.getSMSNames( this );
|
||||
m_phones = CommonPrefs.getSMSPhones( this );
|
||||
}
|
||||
|
||||
private void saveState()
|
||||
{
|
||||
CommonPrefs.setNBSNames( this, m_names );
|
||||
CommonPrefs.setNBSPhones( this, m_phones );
|
||||
CommonPrefs.setSMSNames( this, m_names );
|
||||
CommonPrefs.setSMSPhones( this, m_phones );
|
||||
}
|
||||
|
||||
private class NBSPhonesAdapter extends XWListAdapter {
|
||||
private NBSListItem[] m_items;
|
||||
private class SMSPhonesAdapter extends XWListAdapter {
|
||||
private SMSListItem[] m_items;
|
||||
|
||||
public NBSPhonesAdapter()
|
||||
public SMSPhonesAdapter()
|
||||
{
|
||||
super( m_phones.size() );
|
||||
m_items = new NBSListItem[m_phones.size()];
|
||||
m_items = new SMSListItem[m_phones.size()];
|
||||
}
|
||||
|
||||
public Object getItem( int position )
|
||||
{
|
||||
NBSListItem item =
|
||||
(NBSListItem)Utils.inflate( NBSInviteActivity.this,
|
||||
R.layout.nbsinviter_item );
|
||||
item.setOnCheckedChangeListener( NBSInviteActivity.this );
|
||||
SMSListItem item =
|
||||
(SMSListItem)Utils.inflate( SMSInviteActivity.this,
|
||||
R.layout.smsinviter_item );
|
||||
item.setOnCheckedChangeListener( SMSInviteActivity.this );
|
||||
item.setContents( m_names.get(position), m_phones.get(position) );
|
||||
m_items[position] = item;
|
||||
return item;
|
|
@ -27,9 +27,9 @@ import android.content.Context;
|
|||
import android.util.AttributeSet;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
|
||||
public class NBSListItem extends LinearLayout {
|
||||
public class SMSListItem extends LinearLayout {
|
||||
|
||||
public NBSListItem( Context cx, AttributeSet as )
|
||||
public SMSListItem( Context cx, AttributeSet as )
|
||||
{
|
||||
super( cx, as );
|
||||
}
|
|
@ -28,7 +28,7 @@ import android.telephony.SmsMessage;
|
|||
|
||||
import junit.framework.Assert;
|
||||
|
||||
public class NBSReceiver extends BroadcastReceiver {
|
||||
public class SMSReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive( Context context, Intent intent )
|
||||
|
@ -37,23 +37,23 @@ public class NBSReceiver extends BroadcastReceiver {
|
|||
if ( null != bundle ) {
|
||||
boolean isMine = false;
|
||||
Object[] pdus = (Object[])bundle.get( "pdus" );
|
||||
SmsMessage[] nbses = new SmsMessage[pdus.length];
|
||||
SmsMessage[] smses = new SmsMessage[pdus.length];
|
||||
|
||||
for ( int ii = 0; ii < pdus.length; ++ii ) {
|
||||
SmsMessage nbs = SmsMessage.createFromPdu((byte[])pdus[ii]);
|
||||
String body = nbs.getMessageBody();
|
||||
String postDetectable = NBSService.fromPublicFmt( body );
|
||||
SmsMessage sms = SmsMessage.createFromPdu((byte[])pdus[ii]);
|
||||
String body = sms.getMessageBody();
|
||||
String postDetectable = SMSService.fromPublicFmt( body );
|
||||
isMine = null != postDetectable;
|
||||
if ( isMine ) {
|
||||
String phone = nbs.getOriginatingAddress();
|
||||
DbgUtils.logf( "NBSReceiver: \"%s\" from %s",
|
||||
String phone = sms.getOriginatingAddress();
|
||||
DbgUtils.logf( "SMSReceiver: \"%s\" from %s",
|
||||
body, phone );
|
||||
NBSService.handleFrom( context, postDetectable, phone );
|
||||
SMSService.handleFrom( context, postDetectable, phone );
|
||||
}
|
||||
}
|
||||
|
||||
if ( isMine ) {
|
||||
DbgUtils.logf( "NBSReceiver: ABORTING message" );
|
||||
DbgUtils.logf( "SMSReceiver: ABORTING message" );
|
||||
abortBroadcast();
|
||||
}
|
||||
}
|
|
@ -41,7 +41,7 @@ import junit.framework.Assert;
|
|||
|
||||
import org.eehouse.android.xw4.jni.CommsAddrRec;
|
||||
|
||||
public class NBSService extends Service {
|
||||
public class SMSService extends Service {
|
||||
|
||||
private static final String PUBLIC_HEADER = "_XW4";
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class NBSService extends Service {
|
|||
|
||||
// All messages are base64-encoded byte arrays. The first byte is
|
||||
// always one of these. What follows depends.
|
||||
private enum NBS_CMD { NONE, INVITE, DATA, };
|
||||
private enum SMS_CMD { NONE, INVITE, DATA, };
|
||||
|
||||
private int m_nReceived = 0;
|
||||
private static int s_nSent = 0;
|
||||
|
@ -96,7 +96,7 @@ public class NBSService extends Service {
|
|||
public static int sendPacket( Context context, String phone,
|
||||
int gameID, byte[] binmsg )
|
||||
{
|
||||
DbgUtils.logf( "NBSService.sendPacket()" );
|
||||
DbgUtils.logf( "SMSService.sendPacket()" );
|
||||
Intent intent = getIntentTo( context, SEND );
|
||||
intent.putExtra( PHONE, phone );
|
||||
intent.putExtra( GAMEID, gameID );
|
||||
|
@ -121,7 +121,7 @@ public class NBSService extends Service {
|
|||
|
||||
private static Intent getIntentTo( Context context, int cmd )
|
||||
{
|
||||
Intent intent = new Intent( context, NBSService.class );
|
||||
Intent intent = new Intent( context, SMSService.class );
|
||||
intent.putExtra( CMD_STR, cmd );
|
||||
return intent;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ public class NBSService extends Service {
|
|||
@Override
|
||||
public void onCreate()
|
||||
{
|
||||
if ( XWApp.NBSSUPPORTED ) {
|
||||
if ( XWApp.SMSSUPPORTED ) {
|
||||
} else {
|
||||
stopSelf();
|
||||
}
|
||||
|
@ -139,11 +139,11 @@ public class NBSService extends Service {
|
|||
public int onStartCommand( Intent intent, int flags, int startId )
|
||||
{
|
||||
int result;
|
||||
if ( XWApp.NBSSUPPORTED && null != intent ) {
|
||||
if ( XWApp.SMSSUPPORTED && null != intent ) {
|
||||
int cmd = intent.getIntExtra( CMD_STR, -1 );
|
||||
switch( cmd ) {
|
||||
case HANDLE:
|
||||
DbgUtils.showf( this, "got %dth nbs", ++m_nReceived );
|
||||
DbgUtils.showf( this, "got %dth sms", ++m_nReceived );
|
||||
String buffer = intent.getStringExtra( BUFFER );
|
||||
String phone = intent.getStringExtra( PHONE );
|
||||
receiveBuffer( buffer, phone );
|
||||
|
@ -193,7 +193,7 @@ public class NBSService extends Service {
|
|||
das.writeByte( nPlayersH );
|
||||
das.flush();
|
||||
|
||||
send( NBS_CMD.INVITE, bas.toByteArray(), phone );
|
||||
send( SMS_CMD.INVITE, bas.toByteArray(), phone );
|
||||
} catch ( java.io.IOException ioe ) {
|
||||
DbgUtils.logf( "ioe: %s", ioe.toString() );
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ public class NBSService extends Service {
|
|||
|
||||
public int sendPacket( String phone, int gameID, byte[] bytes )
|
||||
{
|
||||
DbgUtils.logf( "non-static NBSService.sendPacket()" );
|
||||
DbgUtils.logf( "non-static SMSService.sendPacket()" );
|
||||
int nSent = -1;
|
||||
ByteArrayOutputStream bas = new ByteArrayOutputStream( 128 );
|
||||
DataOutputStream das = new DataOutputStream( bas );
|
||||
|
@ -209,7 +209,7 @@ public class NBSService extends Service {
|
|||
das.writeInt( gameID );
|
||||
das.write( bytes, 0, bytes.length );
|
||||
das.flush();
|
||||
if ( send( NBS_CMD.DATA, bas.toByteArray(), phone ) ) {
|
||||
if ( send( SMS_CMD.DATA, bas.toByteArray(), phone ) ) {
|
||||
nSent = bytes.length;
|
||||
}
|
||||
} catch ( java.io.IOException ioe ) {
|
||||
|
@ -218,12 +218,12 @@ public class NBSService extends Service {
|
|||
return nSent;
|
||||
}
|
||||
|
||||
private boolean send( NBS_CMD cmd, byte[] bytes, String phone )
|
||||
private boolean send( SMS_CMD cmd, byte[] bytes, String phone )
|
||||
throws java.io.IOException
|
||||
{
|
||||
DbgUtils.logf( "non-static NBSService.sendPacket()" );
|
||||
DbgUtils.logf( "non-static SMSService.sendPacket()" );
|
||||
int hash = Arrays.hashCode( bytes );
|
||||
DbgUtils.logf( "NBSService: outgoing hash on %d bytes: %X",
|
||||
DbgUtils.logf( "SMSService: outgoing hash on %d bytes: %X",
|
||||
bytes.length, hash );
|
||||
ByteArrayOutputStream bas = new ByteArrayOutputStream( 128 );
|
||||
DataOutputStream das = new DataOutputStream( bas );
|
||||
|
@ -265,7 +265,7 @@ public class NBSService extends Service {
|
|||
return result;
|
||||
}
|
||||
|
||||
private void receive( NBS_CMD cmd, byte[] data, String phone )
|
||||
private void receive( SMS_CMD cmd, byte[] data, String phone )
|
||||
{
|
||||
CommsAddrRec addr = new CommsAddrRec( phone );
|
||||
DataInputStream dis =
|
||||
|
@ -279,14 +279,14 @@ public class NBSService extends Service {
|
|||
int nPlayersT = dis.readByte();
|
||||
int nPlayersH = dis.readByte();
|
||||
|
||||
long rowid = GameUtils.makeNewNBSGame( this, gameID, addr,
|
||||
long rowid = GameUtils.makeNewSMSGame( this, gameID, addr,
|
||||
lang, nPlayersT, nPlayersH );
|
||||
|
||||
if ( null != gameName && 0 < gameName.length() ) {
|
||||
DBUtils.setName( this, rowid, gameName );
|
||||
}
|
||||
String body = Utils.format( this, R.string.new_nbs_bodyf, phone );
|
||||
postNotification( gameID, R.string.new_nbs_title, body );
|
||||
String body = Utils.format( this, R.string.new_sms_bodyf, phone );
|
||||
postNotification( gameID, R.string.new_sms_title, body );
|
||||
break;
|
||||
case DATA:
|
||||
gameID = dis.readInt();
|
||||
|
@ -360,21 +360,21 @@ public class NBSService extends Service {
|
|||
try {
|
||||
byte proto = dis.readByte();
|
||||
if ( 0 != proto ) {
|
||||
DbgUtils.logf( "NBSService.disAssemble: bad proto %d; dropping",
|
||||
DbgUtils.logf( "SMSService.disAssemble: bad proto %d; dropping",
|
||||
proto );
|
||||
} else {
|
||||
NBS_CMD cmd = NBS_CMD.values()[dis.readByte()];
|
||||
SMS_CMD cmd = SMS_CMD.values()[dis.readByte()];
|
||||
int hashRead = dis.readInt();
|
||||
DbgUtils.logf( "NBSService: incoming hash: %X", hashRead );
|
||||
DbgUtils.logf( "SMSService: incoming hash: %X", hashRead );
|
||||
byte[] rest = new byte[dis.available()];
|
||||
dis.read( rest );
|
||||
int hashComputed = Arrays.hashCode( rest );
|
||||
if ( hashComputed == hashRead ) {
|
||||
DbgUtils.logf( "NBSService: incoming hashes on %d " +
|
||||
DbgUtils.logf( "SMSService: incoming hashes on %d " +
|
||||
"bytes match: %X", rest.length, hashRead );
|
||||
receive( cmd, rest, senderPhone );
|
||||
} else {
|
||||
DbgUtils.logf( "NBSService: incoming hashes on %d bytes "
|
||||
DbgUtils.logf( "SMSService: incoming hashes on %d bytes "
|
||||
+ "DON'T match: read: %X; figured: %X",
|
||||
rest.length, hashRead, hashComputed );
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ public class NBSService extends Service {
|
|||
|
||||
private boolean sendBuffers( String[] fragments, String phone )
|
||||
{
|
||||
DbgUtils.logf( "NBSService.sendBuffers()" );
|
||||
DbgUtils.logf( "SMSService.sendBuffers()" );
|
||||
boolean success = false;
|
||||
if ( XWApp.onEmulator() ) {
|
||||
DbgUtils.logf( "sendBuffer(phone=%s): FAKING IT", phone );
|
||||
|
@ -420,9 +420,9 @@ public class NBSService extends Service {
|
|||
} else {
|
||||
long rowid = DBUtils.getRowIDFor( this, gameID );
|
||||
if ( DBUtils.ROWID_NOTFOUND != rowid ) {
|
||||
NBSMsgSink sink = new NBSMsgSink( this );
|
||||
SMSMsgSink sink = new SMSMsgSink( this );
|
||||
if ( GameUtils.feedMessage( this, rowid, msg, addr, sink ) ) {
|
||||
postNotification( gameID, R.string.new_nbsmove_title,
|
||||
postNotification( gameID, R.string.new_smsmove_title,
|
||||
getString(R.string.new_move_body)
|
||||
);
|
||||
}
|
||||
|
@ -437,9 +437,9 @@ public class NBSService extends Service {
|
|||
Utils.postNotification( this, intent, title, body );
|
||||
}
|
||||
|
||||
private class NBSMsgSink extends MultiMsgSink {
|
||||
private class SMSMsgSink extends MultiMsgSink {
|
||||
private Context m_context;
|
||||
public NBSMsgSink( Context context ) {
|
||||
public SMSMsgSink( Context context ) {
|
||||
super();
|
||||
m_context = context;
|
||||
}
|
||||
|
@ -447,7 +447,7 @@ public class NBSService extends Service {
|
|||
/***** TransportProcs interface *****/
|
||||
public int transportSend( byte[] buf, final CommsAddrRec addr, int gameID )
|
||||
{
|
||||
DbgUtils.logf( "NBSMsgSink.transportSend()" );
|
||||
DbgUtils.logf( "SMSMsgSink.transportSend()" );
|
||||
return sendPacket( addr.sms_phone, gameID, buf );
|
||||
}
|
||||
|
|
@ -30,7 +30,7 @@ import org.eehouse.android.xw4.jni.XwJNI;
|
|||
public class XWApp extends Application {
|
||||
|
||||
public static final boolean BTSUPPORTED = false;
|
||||
public static final boolean NBSSUPPORTED = false;
|
||||
public static final boolean SMSSUPPORTED = false;
|
||||
|
||||
private static UUID s_UUID = null;
|
||||
private static Boolean s_onEmulator = null;
|
||||
|
|
|
@ -349,16 +349,16 @@ public class CommonPrefs {
|
|||
setPrefsStringArray( context, R.string.key_bt_names, names );
|
||||
}
|
||||
|
||||
public static void setNBSNames( Context context, ArrayList<String> names )
|
||||
public static void setSMSNames( Context context, ArrayList<String> names )
|
||||
{
|
||||
String[] array = names.toArray( new String[names.size()] );
|
||||
setPrefsStringArray( context, R.string.key_nbs_names, array );
|
||||
setPrefsStringArray( context, R.string.key_sms_names, array );
|
||||
}
|
||||
|
||||
public static void setNBSPhones( Context context, ArrayList<String> names )
|
||||
public static void setSMSPhones( Context context, ArrayList<String> names )
|
||||
{
|
||||
String[] array = names.toArray( new String[names.size()] );
|
||||
setPrefsStringArray( context, R.string.key_nbs_phones, array );
|
||||
setPrefsStringArray( context, R.string.key_sms_phones, array );
|
||||
}
|
||||
|
||||
public static String[] getBTNames( Context context )
|
||||
|
@ -366,14 +366,14 @@ public class CommonPrefs {
|
|||
return getPrefsStringArray( context, R.string.key_bt_names );
|
||||
}
|
||||
|
||||
public static ArrayList<String> getNBSNames( Context context )
|
||||
public static ArrayList<String> getSMSNames( Context context )
|
||||
{
|
||||
return getPrefsStringArrayList( context, R.string.key_nbs_names );
|
||||
return getPrefsStringArrayList( context, R.string.key_sms_names );
|
||||
}
|
||||
|
||||
public static ArrayList<String> getNBSPhones( Context context )
|
||||
public static ArrayList<String> getSMSPhones( Context context )
|
||||
{
|
||||
return getPrefsStringArrayList( context, R.string.key_nbs_phones );
|
||||
return getPrefsStringArrayList( context, R.string.key_sms_phones );
|
||||
}
|
||||
|
||||
public static void setBTAddresses( Context context, String[] addrs )
|
||||
|
|
|
@ -54,7 +54,7 @@ public class CommsAddrRec {
|
|||
|
||||
// sms case
|
||||
public String sms_phone;
|
||||
public int sms_port; // NBS port, if they still use those
|
||||
public int sms_port; // SMS port, if they still use those
|
||||
|
||||
public CommsAddrRec( CommsConnType cTyp )
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue