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