projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altosdroid: Lots of bluetooth connection changes
[fw/altos]
/
altosdroid
/
src
/
org
/
altusmetrum
/
AltosDroid
/
DeviceListActivity.java
diff --git
a/altosdroid/src/org/altusmetrum/AltosDroid/DeviceListActivity.java
b/altosdroid/src/org/altusmetrum/AltosDroid/DeviceListActivity.java
index 7b9cbde74a84f0f4721231b37252e7846d1ee872..fd6abe0fbd7057c66a261987fa01efc04654fc81 100644
(file)
--- a/
altosdroid/src/org/altusmetrum/AltosDroid/DeviceListActivity.java
+++ b/
altosdroid/src/org/altusmetrum/AltosDroid/DeviceListActivity.java
@@
-50,7
+50,8
@@
public class DeviceListActivity extends Activity {
private static final boolean D = true;
// Return Intent extra
private static final boolean D = true;
// Return Intent extra
- public static String EXTRA_DEVICE_ADDRESS = "device_address";
+ public static final String EXTRA_DEVICE_ADDRESS = "device_address";
+ public static final String EXTRA_DEVICE_NAME = "device_name";
// Member fields
private BluetoothAdapter mBtAdapter;
// Member fields
private BluetoothAdapter mBtAdapter;
@@
-109,9
+110,10
@@
public class DeviceListActivity extends Activity {
// If there are paired devices, add each one to the ArrayAdapter
if (pairedDevices.size() > 0) {
findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE);
// If there are paired devices, add each one to the ArrayAdapter
if (pairedDevices.size() > 0) {
findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE);
- for (BluetoothDevice device : pairedDevices) {
- mPairedDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
- }
+ for (BluetoothDevice device : pairedDevices)
+ if (device.getName().startsWith("TeleBT"))
+ mPairedDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
+
} else {
String noDevices = getResources().getText(R.string.none_paired).toString();
mPairedDevicesArrayAdapter.add(noDevices);
} else {
String noDevices = getResources().getText(R.string.none_paired).toString();
mPairedDevicesArrayAdapter.add(noDevices);
@@
-163,9
+165,20
@@
public class DeviceListActivity extends Activity {
String info = ((TextView) v).getText().toString();
String address = info.substring(info.length() - 17);
String info = ((TextView) v).getText().toString();
String address = info.substring(info.length() - 17);
+ int newline = info.indexOf('\n');
+
+ String name = null;
+ if (newline > 0)
+ name = info.substring(0, newline);
+ else
+ name = info;
+
+ if (D) Log.d(TAG, String.format("******* selected item '%s'", info));
+
// Create the result Intent and include the MAC address
Intent intent = new Intent();
intent.putExtra(EXTRA_DEVICE_ADDRESS, address);
// Create the result Intent and include the MAC address
Intent intent = new Intent();
intent.putExtra(EXTRA_DEVICE_ADDRESS, address);
+ intent.putExtra(EXTRA_DEVICE_NAME, name);
// Set result and finish this Activity
setResult(Activity.RESULT_OK, intent);
// Set result and finish this Activity
setResult(Activity.RESULT_OK, intent);
@@
-185,7
+198,8
@@
public class DeviceListActivity extends Activity {
// Get the BluetoothDevice object from the Intent
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
// If it's already paired, skip it, because it's been listed already
// Get the BluetoothDevice object from the Intent
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
// If it's already paired, skip it, because it's been listed already
- if (device.getBondState() != BluetoothDevice.BOND_BONDED) {
+ if ( device.getBondState() != BluetoothDevice.BOND_BONDED
+ && device.getName().startsWith("TeleBT") ) {
mNewDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
}
// When discovery is finished, change the Activity title
mNewDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
}
// When discovery is finished, change the Activity title