// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: braces fieldsfirst space lnc package com.oliodevices.assist.app; import android.app.Activity; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ListView; import android.widget.TextView; import com.google.android.gms.analytics.Tracker; import com.olio.util.ALog; import com.oliodevices.assist.app.core.OlioApplication; import java.util.Iterator; import java.util.Set; public class DeviceListActivity extends Activity { private static final boolean D = true; public static String EXTRA_DEVICE_ADDRESS = "device_address"; private static final String TAG = "DeviceListActivity"; private BluetoothAdapter mBtAdapter; private android.widget.AdapterView.OnItemClickListener mDeviceClickListener; private ArrayAdapter mNewDevicesArrayAdapter; private ArrayAdapter mPairedDevicesArrayAdapter; private final BroadcastReceiver mReceiver = new BroadcastReceiver() { final DeviceListActivity this$0; public void onReceive(Context context, Intent intent) { context = intent.getAction(); if ("android.bluetooth.device.action.FOUND".equals(context)) { context = (BluetoothDevice)intent.getParcelableExtra("android.bluetooth.device.extra.DEVICE"); if (context.getBondState() != 12) { mNewDevicesArrayAdapter.add((new StringBuilder()).append(context.getName()).append("\n").append(context.getAddress()).toString()); } } else if ("android.bluetooth.adapter.action.DISCOVERY_FINISHED".equals(context)) { setProgressBarIndeterminateVisibility(false); setTitle("Select a device to connect"); if (mNewDevicesArrayAdapter.getCount() == 0) { mNewDevicesArrayAdapter.add("No devices found"); return; } } } { this$0 = DeviceListActivity.this; super(); } }; private Tracker mTracker; public DeviceListActivity() { mTracker = null; mDeviceClickListener = new android.widget.AdapterView.OnItemClickListener() { final DeviceListActivity this$0; public void onItemClick(AdapterView adapterview, View view, int i, long l) { mBtAdapter.cancelDiscovery(); adapterview = ((TextView)view).getText().toString(); adapterview = adapterview.substring(adapterview.length() - 17); view = new Intent(); view.putExtra(DeviceListActivity.EXTRA_DEVICE_ADDRESS, adapterview); setResult(-1, view); finish(); } { this$0 = DeviceListActivity.this; super(); } }; } private void doDiscovery() { ALog.d("doDiscovery()", new Object[0]); setProgressBarIndeterminateVisibility(true); setTitle("Scanning for devices\u2026"); findViewById(0x7f0d00b8).setVisibility(0); if (mBtAdapter.isDiscovering()) { mBtAdapter.cancelDiscovery(); } mBtAdapter.startDiscovery(); } protected void onCreate(Bundle bundle) { super.onCreate(bundle); mTracker = ((OlioApplication)getApplication()).getDefaultTracker(); requestWindowFeature(5); setContentView(0x7f030022); setResult(0); ((Button)findViewById(0x7f0d00ba)).setOnClickListener(new android.view.View.OnClickListener() { final DeviceListActivity this$0; public void onClick(View view) { doDiscovery(); view.setVisibility(8); } { this$0 = DeviceListActivity.this; super(); } }); mPairedDevicesArrayAdapter = new ArrayAdapter(this, 0x7f030024); mNewDevicesArrayAdapter = new ArrayAdapter(this, 0x7f030024); bundle = (ListView)findViewById(0x7f0d00b7); bundle.setAdapter(mPairedDevicesArrayAdapter); bundle.setOnItemClickListener(mDeviceClickListener); bundle = (ListView)findViewById(0x7f0d00b9); bundle.setAdapter(mNewDevicesArrayAdapter); bundle.setOnItemClickListener(mDeviceClickListener); bundle = new IntentFilter("android.bluetooth.device.action.FOUND"); registerReceiver(mReceiver, bundle); bundle = new IntentFilter("android.bluetooth.adapter.action.DISCOVERY_FINISHED"); registerReceiver(mReceiver, bundle); mBtAdapter = BluetoothAdapter.getDefaultAdapter(); bundle = mBtAdapter.getBondedDevices(); if (bundle.size() > 0) { findViewById(0x7f0d00b6).setVisibility(0); BluetoothDevice bluetoothdevice; for (bundle = bundle.iterator(); bundle.hasNext(); mPairedDevicesArrayAdapter.add((new StringBuilder()).append(bluetoothdevice.getName()).append("\n").append(bluetoothdevice.getAddress()).toString())) { bluetoothdevice = (BluetoothDevice)bundle.next(); } } else { mPairedDevicesArrayAdapter.add("No devices have been paired"); } } protected void onDestroy() { super.onDestroy(); if (mBtAdapter != null) { mBtAdapter.cancelDiscovery(); } unregisterReceiver(mReceiver); } protected void onResume() { super.onResume(); if (mTracker != null) { mTracker.setScreenName("DeviceListActivity"); mTracker.send((new com.google.android.gms.analytics.HitBuilders.ScreenViewBuilder()).build()); } } }