altosdroid: Switch from custom title to standard Holo theme
[fw/altos] / altosdroid / src / org / altusmetrum / AltosDroid / DeviceListActivity.java
index 71692122b8def9d96839a9f70414d0f74ecf20e3..4af117a29bbde343c91a0a0b8c6416aa0836280d 100644 (file)
@@ -27,7 +27,6 @@ import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.os.Bundle;
-import android.util.Log;
 import android.view.View;
 import android.view.Window;
 import android.view.View.OnClickListener;
@@ -45,12 +44,10 @@ import android.widget.AdapterView.OnItemClickListener;
  * Activity in the result Intent.
  */
 public class DeviceListActivity extends Activity {
-       // Debugging
-       private static final String TAG = "DeviceListActivity";
-       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;
@@ -136,7 +133,7 @@ public class DeviceListActivity extends Activity {
        * Start device discover with the BluetoothAdapter
        */
        private void doDiscovery() {
-               if (D) Log.d(TAG, "doDiscovery()");
+               AltosDebug.debug("doDiscovery()");
 
                // Indicate scanning in the title
                setProgressBarIndeterminateVisibility(true);
@@ -164,9 +161,20 @@ public class DeviceListActivity extends Activity {
                        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;
+
+                       AltosDebug.debug("******* selected item '%s'", info);
+
                        // 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);