2015-01-07 14:00:18 +01:00
|
|
|
package nodomain.freeyourgadget.gadgetbridge;
|
|
|
|
|
2015-03-07 15:32:34 +01:00
|
|
|
import android.app.Activity;
|
2015-06-21 00:34:05 +02:00
|
|
|
import android.app.ProgressDialog;
|
2015-03-21 18:18:07 +01:00
|
|
|
import android.bluetooth.BluetoothAdapter;
|
|
|
|
import android.bluetooth.BluetoothDevice;
|
2015-02-06 13:55:44 +01:00
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
import android.content.Context;
|
2015-06-21 00:34:05 +02:00
|
|
|
import android.content.DialogInterface;
|
2015-01-07 14:00:18 +01:00
|
|
|
import android.content.Intent;
|
2015-02-06 13:55:44 +01:00
|
|
|
import android.content.IntentFilter;
|
2015-01-18 22:44:38 +01:00
|
|
|
import android.content.SharedPreferences;
|
2015-01-07 14:00:18 +01:00
|
|
|
import android.os.Bundle;
|
2015-01-18 22:44:38 +01:00
|
|
|
import android.preference.PreferenceManager;
|
2015-03-27 10:56:08 +01:00
|
|
|
import android.support.v4.content.LocalBroadcastManager;
|
2015-06-01 16:57:45 +02:00
|
|
|
import android.view.ContextMenu;
|
2015-01-07 14:00:18 +01:00
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuItem;
|
|
|
|
import android.view.View;
|
2015-03-21 18:18:07 +01:00
|
|
|
import android.widget.AdapterView;
|
|
|
|
import android.widget.ListView;
|
2015-03-27 12:33:51 +01:00
|
|
|
import android.widget.TextView;
|
2015-03-21 18:18:07 +01:00
|
|
|
import android.widget.Toast;
|
2015-05-01 01:49:43 +02:00
|
|
|
|
2015-05-28 00:26:41 +02:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
2015-04-26 00:53:48 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Set;
|
2015-05-01 01:49:43 +02:00
|
|
|
|
2015-06-24 20:14:08 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.activities.ConfigureAlarms;
|
2015-06-11 23:34:16 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.activities.SleepChartActivity;
|
2015-04-26 00:53:48 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.adapter.GBDeviceAdapter;
|
2015-05-05 00:48:02 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.discovery.DiscoveryActivity;
|
2015-05-10 13:08:28 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.miband.MiBandConst;
|
2015-04-26 00:53:48 +02:00
|
|
|
|
2015-03-07 15:32:34 +01:00
|
|
|
public class ControlCenter extends Activity {
|
2015-02-06 13:55:44 +01:00
|
|
|
|
2015-05-28 00:26:41 +02:00
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(ControlCenter.class);
|
2015-03-21 18:18:07 +01:00
|
|
|
|
2015-02-06 13:55:44 +01:00
|
|
|
public static final String ACTION_QUIT
|
|
|
|
= "nodomain.freeyourgadget.gadgetbride.controlcenter.action.quit";
|
2015-01-07 14:00:18 +01:00
|
|
|
|
2015-03-22 12:46:28 +01:00
|
|
|
public static final String ACTION_REFRESH_DEVICELIST
|
2015-03-22 00:34:54 +01:00
|
|
|
= "nodomain.freeyourgadget.gadgetbride.controlcenter.action.set_version";
|
|
|
|
|
2015-03-27 12:33:51 +01:00
|
|
|
TextView hintTextView;
|
2015-03-21 18:18:07 +01:00
|
|
|
ListView deviceListView;
|
|
|
|
GBDeviceAdapter mGBDeviceAdapter;
|
2015-06-01 16:57:45 +02:00
|
|
|
private GBDevice selectedDevice = null;
|
|
|
|
|
2015-03-21 18:18:07 +01:00
|
|
|
final List<GBDevice> deviceList = new ArrayList<>();
|
2015-01-07 14:00:18 +01:00
|
|
|
|
2015-02-06 13:55:44 +01:00
|
|
|
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
|
|
|
@Override
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
2015-03-22 00:34:54 +01:00
|
|
|
String action = intent.getAction();
|
2015-05-10 16:56:09 +02:00
|
|
|
switch (action) {
|
|
|
|
case ACTION_QUIT:
|
|
|
|
finish();
|
|
|
|
break;
|
|
|
|
case ACTION_REFRESH_DEVICELIST:
|
|
|
|
case BluetoothDevice.ACTION_BOND_STATE_CHANGED:
|
|
|
|
refreshPairedDevices();
|
|
|
|
break;
|
|
|
|
case GBDevice.ACTION_DEVICE_CHANGED:
|
2015-05-28 00:26:41 +02:00
|
|
|
GBDevice dev = intent.getParcelableExtra(GBDevice.EXTRA_DEVICE);
|
2015-05-10 16:56:09 +02:00
|
|
|
if (dev.getAddress() != null) {
|
|
|
|
int index = deviceList.indexOf(dev); // search by address
|
|
|
|
if (index >= 0) {
|
|
|
|
deviceList.set(index, dev);
|
|
|
|
} else {
|
|
|
|
deviceList.add(dev);
|
|
|
|
}
|
2015-03-22 00:34:54 +01:00
|
|
|
}
|
2015-05-10 16:56:09 +02:00
|
|
|
refreshPairedDevices();
|
2015-04-24 23:08:47 +02:00
|
|
|
|
2015-06-06 19:39:04 +02:00
|
|
|
refreshBusyState(dev);
|
|
|
|
|
2015-05-28 00:26:41 +02:00
|
|
|
if (dev.isConnected() && dev.getFirmwareVersion() == null && !dev.isInitializing()) {
|
|
|
|
LOG.info("device connected, requesting more info");
|
2015-05-10 16:56:09 +02:00
|
|
|
requestDeviceInfo();
|
|
|
|
}
|
|
|
|
break;
|
2015-02-06 13:55:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-06-06 19:39:04 +02:00
|
|
|
private void refreshBusyState(GBDevice dev) {
|
|
|
|
mGBDeviceAdapter.notifyDataSetChanged();
|
|
|
|
}
|
|
|
|
|
2015-01-07 14:00:18 +01:00
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.activity_controlcenter);
|
2015-03-28 23:23:10 +01:00
|
|
|
hintTextView = (TextView) findViewById(R.id.hintTextView);
|
2015-03-21 18:18:07 +01:00
|
|
|
deviceListView = (ListView) findViewById(R.id.deviceListView);
|
|
|
|
mGBDeviceAdapter = new GBDeviceAdapter(this, deviceList);
|
|
|
|
deviceListView.setAdapter(this.mGBDeviceAdapter);
|
|
|
|
deviceListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
2015-01-12 00:35:15 +01:00
|
|
|
@Override
|
2015-03-21 18:18:07 +01:00
|
|
|
public void onItemClick(AdapterView parent, View v, int position, long id) {
|
2015-04-19 15:53:43 +02:00
|
|
|
if (deviceList.get(position).isConnected()) {
|
2015-03-25 22:23:45 +01:00
|
|
|
Intent startIntent = new Intent(ControlCenter.this, AppManagerActivity.class);
|
|
|
|
startActivity(startIntent);
|
|
|
|
} else {
|
|
|
|
Intent startIntent = new Intent(ControlCenter.this, BluetoothCommunicationService.class);
|
|
|
|
startIntent.setAction(BluetoothCommunicationService.ACTION_CONNECT);
|
2015-05-05 00:48:02 +02:00
|
|
|
startIntent.putExtra(BluetoothCommunicationService.EXTRA_DEVICE_ADDRESS, deviceList.get(position).getAddress());
|
2015-03-25 22:23:45 +01:00
|
|
|
startService(startIntent);
|
|
|
|
}
|
2015-01-12 00:35:15 +01:00
|
|
|
}
|
|
|
|
});
|
2015-03-21 18:18:07 +01:00
|
|
|
|
2015-06-01 16:57:45 +02:00
|
|
|
registerForContextMenu(deviceListView);
|
|
|
|
|
2015-05-10 17:05:24 +02:00
|
|
|
IntentFilter filterLocal = new IntentFilter();
|
|
|
|
filterLocal.addAction(ACTION_QUIT);
|
|
|
|
filterLocal.addAction(ACTION_REFRESH_DEVICELIST);
|
|
|
|
filterLocal.addAction(GBDevice.ACTION_DEVICE_CHANGED);
|
|
|
|
filterLocal.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
|
|
|
|
LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filterLocal);
|
|
|
|
|
|
|
|
registerReceiver(mReceiver, new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED));
|
2015-03-21 18:18:07 +01:00
|
|
|
|
2015-03-22 12:46:28 +01:00
|
|
|
refreshPairedDevices();
|
2015-01-18 22:44:38 +01:00
|
|
|
/*
|
|
|
|
* Ask for permission to intercept notifications on first run.
|
|
|
|
*/
|
|
|
|
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
|
|
|
if (sharedPrefs.getBoolean("firstrun", true)) {
|
2015-05-10 16:56:09 +02:00
|
|
|
sharedPrefs.edit().putBoolean("firstrun", false).apply();
|
2015-01-18 22:44:38 +01:00
|
|
|
Intent enableIntent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
|
|
|
|
startActivity(enableIntent);
|
|
|
|
}
|
2015-03-22 00:34:54 +01:00
|
|
|
Intent startIntent = new Intent(this, BluetoothCommunicationService.class);
|
2015-02-06 13:55:44 +01:00
|
|
|
startIntent.setAction(BluetoothCommunicationService.ACTION_START);
|
|
|
|
startService(startIntent);
|
|
|
|
|
2015-05-06 22:59:31 +02:00
|
|
|
|
2015-05-07 22:15:53 +02:00
|
|
|
if (GB.isBluetoothEnabled() && deviceList.isEmpty()) {
|
2015-05-06 22:59:31 +02:00
|
|
|
// start discovery when no devices are present
|
|
|
|
startActivity(new Intent(this, DiscoveryActivity.class));
|
|
|
|
} else {
|
|
|
|
requestDeviceInfo();
|
|
|
|
}
|
2015-04-24 23:08:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Requests information from the {@link BluetoothCommunicationService} about the connection state,
|
|
|
|
* firmware info, etc.
|
2015-04-26 00:53:48 +02:00
|
|
|
* <p/>
|
2015-04-24 23:08:47 +02:00
|
|
|
* Note that this method may cause an implicit device connection (for auto-connectable devices).
|
|
|
|
*/
|
|
|
|
private void requestDeviceInfo() {
|
|
|
|
Intent versionInfoIntent = new Intent(ControlCenter.this, BluetoothCommunicationService.class);
|
2015-03-22 00:34:54 +01:00
|
|
|
versionInfoIntent.setAction(BluetoothCommunicationService.ACTION_REQUEST_VERSIONINFO);
|
|
|
|
startService(versionInfoIntent);
|
2015-01-07 14:00:18 +01:00
|
|
|
}
|
|
|
|
|
2015-06-01 16:57:45 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
|
|
|
|
super.onCreateContextMenu(menu, v, menuInfo);
|
|
|
|
AdapterView.AdapterContextMenuInfo acmi = (AdapterView.AdapterContextMenuInfo) menuInfo;
|
|
|
|
selectedDevice = deviceList.get(acmi.position);
|
2015-06-07 15:31:42 +02:00
|
|
|
if (selectedDevice != null && selectedDevice.isBusy()) {
|
|
|
|
// no context menu when device is busy
|
|
|
|
return;
|
|
|
|
}
|
2015-06-22 22:16:19 +02:00
|
|
|
getMenuInflater().inflate(R.menu.controlcenter_context, menu);
|
|
|
|
|
|
|
|
if (!selectedDevice.isConnected() || selectedDevice.getType() == DeviceType.PEBBLE) {
|
|
|
|
menu.removeItem(R.id.controlcenter_fetch_activity_data);
|
2015-07-05 00:41:06 +02:00
|
|
|
menu.removeItem(R.id.controlcenter_configure_alarms);
|
2015-06-22 22:16:19 +02:00
|
|
|
}
|
|
|
|
|
2015-06-24 00:23:38 +02:00
|
|
|
if (!selectedDevice.isConnected() || selectedDevice.getType() == DeviceType.MIBAND) {
|
|
|
|
menu.removeItem(R.id.controlcenter_take_screenshot);
|
|
|
|
}
|
|
|
|
|
2015-06-22 22:16:19 +02:00
|
|
|
if (!selectedDevice.isConnected()) {
|
|
|
|
menu.removeItem(R.id.controlcenter_disconnect);
|
|
|
|
menu.removeItem(R.id.controlcenter_find_device);
|
|
|
|
}
|
|
|
|
|
2015-06-01 16:57:45 +02:00
|
|
|
menu.setHeaderTitle(selectedDevice.getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onContextItemSelected(MenuItem item) {
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
case R.id.controlcenter_start_sleepmonitor:
|
|
|
|
if (selectedDevice != null) {
|
2015-06-13 20:37:53 +02:00
|
|
|
Intent startIntent;
|
2015-06-17 08:18:24 +02:00
|
|
|
startIntent = new Intent(ControlCenter.this, SleepChartActivity.class);
|
2015-06-23 23:03:05 +02:00
|
|
|
// startIntent = new Intent(ControlCenter.this, ChartsActivity.class);
|
2015-06-01 16:57:45 +02:00
|
|
|
startIntent.putExtra("device", selectedDevice);
|
|
|
|
startActivity(startIntent);
|
|
|
|
}
|
|
|
|
return true;
|
2015-06-06 19:39:04 +02:00
|
|
|
case R.id.controlcenter_fetch_activity_data:
|
|
|
|
if (selectedDevice != null) {
|
|
|
|
Intent startIntent = new Intent(this, BluetoothCommunicationService.class);
|
|
|
|
startIntent.setAction(BluetoothCommunicationService.ACTION_FETCH_ACTIVITY_DATA);
|
|
|
|
startService(startIntent);
|
|
|
|
}
|
2015-06-08 23:30:51 +02:00
|
|
|
return true;
|
2015-06-07 15:31:42 +02:00
|
|
|
case R.id.controlcenter_disconnect:
|
|
|
|
if (selectedDevice != null) {
|
|
|
|
selectedDevice = null;
|
|
|
|
Intent startIntent = new Intent(this, BluetoothCommunicationService.class);
|
|
|
|
startIntent.setAction(BluetoothCommunicationService.ACTION_DISCONNECT);
|
|
|
|
startService(startIntent);
|
|
|
|
}
|
2015-06-08 23:30:51 +02:00
|
|
|
return true;
|
2015-06-21 00:34:05 +02:00
|
|
|
case R.id.controlcenter_find_device:
|
|
|
|
if (selectedDevice != null) {
|
|
|
|
findDevice(true);
|
2015-06-24 00:23:38 +02:00
|
|
|
ProgressDialog.show(
|
2015-06-21 00:34:05 +02:00
|
|
|
this,
|
|
|
|
getString(R.string.control_center_find_lost_device),
|
|
|
|
getString(R.string.control_center_cancel_to_stop_vibration),
|
|
|
|
true, true,
|
|
|
|
new DialogInterface.OnCancelListener() {
|
|
|
|
@Override
|
|
|
|
public void onCancel(DialogInterface dialog) {
|
2015-06-22 22:16:19 +02:00
|
|
|
findDevice(false);
|
2015-06-21 00:34:05 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2015-06-30 21:18:27 +02:00
|
|
|
return true;
|
2015-06-24 20:14:08 +02:00
|
|
|
case R.id.controlcenter_configure_alarms:
|
|
|
|
if (selectedDevice != null) {
|
|
|
|
Intent startIntent;
|
|
|
|
startIntent = new Intent(ControlCenter.this, ConfigureAlarms.class);
|
|
|
|
startActivity(startIntent);
|
|
|
|
}
|
2015-06-24 00:23:38 +02:00
|
|
|
return true;
|
|
|
|
case R.id.controlcenter_take_screenshot:
|
|
|
|
if (selectedDevice != null) {
|
|
|
|
Intent startIntent = new Intent(this, BluetoothCommunicationService.class);
|
|
|
|
startIntent.setAction(BluetoothCommunicationService.ACTION_REQUEST_SCREENSHOT);
|
|
|
|
startService(startIntent);
|
|
|
|
}
|
|
|
|
return true;
|
2015-06-01 16:57:45 +02:00
|
|
|
default:
|
|
|
|
return super.onContextItemSelected(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-21 00:34:05 +02:00
|
|
|
private void findDevice(boolean start) {
|
|
|
|
Intent startIntent = new Intent(this, BluetoothCommunicationService.class);
|
|
|
|
startIntent.putExtra("find_start", start);
|
|
|
|
startIntent.setAction(BluetoothCommunicationService.ACTION_FIND_DEVICE);
|
|
|
|
startService(startIntent);
|
|
|
|
}
|
2015-06-01 16:57:45 +02:00
|
|
|
|
2015-01-07 14:00:18 +01:00
|
|
|
@Override
|
|
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
|
// Inflate the menu; this adds items to the action bar if it is present.
|
|
|
|
getMenuInflater().inflate(R.menu.menu_main, menu);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
2015-03-27 11:23:30 +01:00
|
|
|
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
case R.id.action_settings:
|
|
|
|
Intent settingsIntent = new Intent(this, SettingsActivity.class);
|
|
|
|
startActivity(settingsIntent);
|
|
|
|
return true;
|
|
|
|
case R.id.action_debug:
|
|
|
|
Intent debugIntent = new Intent(this, DebugActivity.class);
|
|
|
|
startActivity(debugIntent);
|
|
|
|
return true;
|
|
|
|
case R.id.action_quit:
|
|
|
|
Intent stopIntent = new Intent(this, BluetoothCommunicationService.class);
|
|
|
|
stopService(stopIntent);
|
|
|
|
|
|
|
|
Intent quitIntent = new Intent(ControlCenter.ACTION_QUIT);
|
|
|
|
LocalBroadcastManager.getInstance(this).sendBroadcast(quitIntent);
|
|
|
|
return true;
|
2015-05-05 00:48:02 +02:00
|
|
|
case R.id.action_discover:
|
|
|
|
Intent discoverIntent = new Intent(this, DiscoveryActivity.class);
|
|
|
|
startActivity(discoverIntent);
|
|
|
|
return true;
|
2015-03-22 13:10:45 +01:00
|
|
|
}
|
2015-01-07 14:00:18 +01:00
|
|
|
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
|
}
|
2015-02-07 12:58:18 +01:00
|
|
|
|
2015-02-06 13:55:44 +01:00
|
|
|
@Override
|
|
|
|
protected void onDestroy() {
|
2015-03-27 10:56:08 +01:00
|
|
|
LocalBroadcastManager.getInstance(this).unregisterReceiver(mReceiver);
|
2015-05-10 17:05:24 +02:00
|
|
|
unregisterReceiver(mReceiver);
|
2015-02-06 13:55:44 +01:00
|
|
|
super.onDestroy();
|
|
|
|
}
|
|
|
|
|
2015-03-22 12:46:28 +01:00
|
|
|
private void refreshPairedDevices() {
|
2015-04-20 23:25:46 +02:00
|
|
|
boolean connected = false;
|
|
|
|
List<GBDevice> availableDevices = new ArrayList<>();
|
2015-04-19 12:35:23 +02:00
|
|
|
for (GBDevice device : deviceList) {
|
2015-04-20 10:50:30 +02:00
|
|
|
if (device.isConnected() || device.isConnecting()) {
|
2015-04-20 23:25:46 +02:00
|
|
|
connected = true;
|
|
|
|
availableDevices.add(device);
|
2015-04-19 12:35:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-22 12:46:28 +01:00
|
|
|
BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();
|
2015-04-19 12:35:23 +02:00
|
|
|
|
2015-03-22 12:46:28 +01:00
|
|
|
if (btAdapter == null) {
|
2015-05-01 01:26:12 +02:00
|
|
|
Toast.makeText(this, R.string.bluetooth_is_not_supported_, Toast.LENGTH_SHORT).show();
|
2015-03-22 12:46:28 +01:00
|
|
|
} else if (!btAdapter.isEnabled()) {
|
2015-05-01 01:26:12 +02:00
|
|
|
Toast.makeText(this, R.string.bluetooth_is_disabled_, Toast.LENGTH_SHORT).show();
|
2015-03-22 12:46:28 +01:00
|
|
|
} else {
|
|
|
|
Set<BluetoothDevice> pairedDevices = btAdapter.getBondedDevices();
|
2015-04-20 23:25:46 +02:00
|
|
|
for (BluetoothDevice pairedDevice : pairedDevices) {
|
2015-05-05 00:48:02 +02:00
|
|
|
DeviceType deviceDeviceType;
|
2015-04-20 23:25:46 +02:00
|
|
|
if (pairedDevice.getName().indexOf("Pebble") == 0) {
|
2015-05-05 00:48:02 +02:00
|
|
|
deviceDeviceType = DeviceType.PEBBLE;
|
2015-04-20 23:25:46 +02:00
|
|
|
} else if (pairedDevice.getName().equals("MI")) {
|
2015-05-05 00:48:02 +02:00
|
|
|
deviceDeviceType = DeviceType.MIBAND;
|
2015-04-01 18:34:52 +02:00
|
|
|
} else {
|
2015-03-31 23:34:19 +02:00
|
|
|
continue;
|
|
|
|
}
|
2015-05-05 00:48:02 +02:00
|
|
|
GBDevice device = new GBDevice(pairedDevice.getAddress(), pairedDevice.getName(), deviceDeviceType);
|
2015-04-20 23:25:46 +02:00
|
|
|
if (!availableDevices.contains(device)) {
|
|
|
|
availableDevices.add(device);
|
2015-04-19 12:35:23 +02:00
|
|
|
}
|
2015-03-22 12:46:28 +01:00
|
|
|
}
|
2015-04-01 23:00:05 +02:00
|
|
|
|
|
|
|
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
2015-05-10 13:08:28 +02:00
|
|
|
String miAddr = sharedPrefs.getString(MiBandConst.PREF_MIBAND_ADDRESS, null);
|
2015-04-20 23:25:46 +02:00
|
|
|
if (miAddr != null && miAddr.length() > 0) {
|
2015-05-05 00:48:02 +02:00
|
|
|
GBDevice miDevice = new GBDevice(miAddr, "MI", DeviceType.MIBAND);
|
2015-04-20 23:25:46 +02:00
|
|
|
if (!availableDevices.contains(miDevice)) {
|
|
|
|
availableDevices.add(miDevice);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
deviceList.retainAll(availableDevices);
|
|
|
|
for (GBDevice dev : availableDevices) {
|
|
|
|
if (!deviceList.contains(dev)) {
|
|
|
|
deviceList.add(dev);
|
|
|
|
}
|
2015-04-01 23:00:05 +02:00
|
|
|
}
|
|
|
|
|
2015-04-20 23:25:46 +02:00
|
|
|
if (connected) {
|
2015-05-01 01:26:12 +02:00
|
|
|
hintTextView.setText(R.string.tap_connected_device_for_app_mananger);
|
2015-04-19 12:35:23 +02:00
|
|
|
} else if (!deviceList.isEmpty()) {
|
2015-05-01 01:26:12 +02:00
|
|
|
hintTextView.setText(R.string.tap_a_device_to_connect);
|
2015-03-27 12:33:51 +01:00
|
|
|
}
|
2015-03-22 12:46:28 +01:00
|
|
|
}
|
2015-04-20 11:58:59 +02:00
|
|
|
mGBDeviceAdapter.notifyDataSetChanged();
|
2015-03-22 12:46:28 +01:00
|
|
|
}
|
2015-02-06 13:55:44 +01:00
|
|
|
}
|