mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-27 20:36:51 +01:00
Try to refresh device list if BluetoothDevice.ACTION_BOND_STATE_CHANGED is received.
On my Android 4.4 device, this does not work however (no Intents arrive)
This commit is contained in:
parent
f101926186
commit
0d77a5ac05
@ -45,11 +45,15 @@ public class ControlCenter extends Activity {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (action.equals(ACTION_QUIT)) {
|
||||
switch (action) {
|
||||
case ACTION_QUIT:
|
||||
finish();
|
||||
} else if (action.equals(ACTION_REFRESH_DEVICELIST)) {
|
||||
break;
|
||||
case ACTION_REFRESH_DEVICELIST:
|
||||
case BluetoothDevice.ACTION_BOND_STATE_CHANGED:
|
||||
refreshPairedDevices();
|
||||
} else if (action.equals(GBDevice.ACTION_DEVICE_CHANGED)) {
|
||||
break;
|
||||
case GBDevice.ACTION_DEVICE_CHANGED:
|
||||
GBDevice dev = intent.getParcelableExtra("device");
|
||||
if (dev.getAddress() != null) {
|
||||
int index = deviceList.indexOf(dev); // search by address
|
||||
@ -64,6 +68,7 @@ public class ControlCenter extends Activity {
|
||||
if (dev.isConnected() && dev.getFirmwareVersion() == null) {
|
||||
requestDeviceInfo();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -95,6 +100,7 @@ public class ControlCenter extends Activity {
|
||||
filter.addAction(ACTION_QUIT);
|
||||
filter.addAction(ACTION_REFRESH_DEVICELIST);
|
||||
filter.addAction(GBDevice.ACTION_DEVICE_CHANGED);
|
||||
filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
|
||||
LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filter);
|
||||
|
||||
refreshPairedDevices();
|
||||
@ -103,7 +109,7 @@ public class ControlCenter extends Activity {
|
||||
*/
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
if (sharedPrefs.getBoolean("firstrun", true)) {
|
||||
sharedPrefs.edit().putBoolean("firstrun", false).commit();
|
||||
sharedPrefs.edit().putBoolean("firstrun", false).apply();
|
||||
Intent enableIntent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
|
||||
startActivity(enableIntent);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user