mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-03 17:02:13 +01:00
No functional changes, only run "Reformat code"
This commit is contained in:
parent
7f24ba8ffb
commit
5d6109a4fb
@ -100,6 +100,8 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
|
||||
private static final long SCAN_DURATION = 30000; // 30s
|
||||
private final Handler handler = new Handler();
|
||||
private final ArrayList<GBDeviceCandidate> deviceCandidates = new ArrayList<>();
|
||||
int CallbackType = android.bluetooth.le.ScanSettings.CALLBACK_TYPE_ALL_MATCHES;
|
||||
int MatchMode = android.bluetooth.le.ScanSettings.MATCH_MODE_STICKY;
|
||||
private ScanCallback newBLEScanCallback = null;
|
||||
/**
|
||||
* If already bonded devices are to be ignored when scanning
|
||||
@ -115,8 +117,6 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
|
||||
private Button startButton;
|
||||
private boolean scanning;
|
||||
private long selectedUnsupportedDeviceKey = DebugActivity.SELECT_DEVICE;
|
||||
private Set<BTUUIDPair> foundCandidates = new HashSet<>();
|
||||
|
||||
private final Runnable stopRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -124,6 +124,7 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
|
||||
LOG.info("Discovery stopped by thread timeout.");
|
||||
}
|
||||
};
|
||||
private Set<BTUUIDPair> foundCandidates = new HashSet<>();
|
||||
private final BroadcastReceiver bluetoothReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
@ -168,8 +169,6 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
|
||||
}
|
||||
}
|
||||
};
|
||||
int CallbackType = android.bluetooth.le.ScanSettings.CALLBACK_TYPE_ALL_MATCHES;
|
||||
int MatchMode = android.bluetooth.le.ScanSettings.MATCH_MODE_STICKY;
|
||||
|
||||
public void logMessageContent(byte[] value) {
|
||||
if (value != null) {
|
||||
@ -184,7 +183,6 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
|
||||
BondingUtil.handleActivityResult(this, requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
|
||||
private GBDeviceCandidate getCandidateFromMAC(BluetoothDevice device) {
|
||||
for (GBDeviceCandidate candidate : deviceCandidates) {
|
||||
if (candidate.getMacAddress().equals(device.getAddress())) {
|
||||
@ -424,6 +422,17 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
|
||||
return scanning;
|
||||
}
|
||||
|
||||
public void setScanning(boolean scanning) {
|
||||
this.scanning = scanning;
|
||||
if (scanning) {
|
||||
startButton.setText(getString(R.string.discovery_stop_scanning));
|
||||
} else {
|
||||
startButton.setText(getString(R.string.discovery_start_scanning));
|
||||
bluetoothProgress.setVisibility(View.GONE);
|
||||
bluetoothLEProgress.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void startBTLEDiscovery() {
|
||||
LOG.info("Starting BLE discovery");
|
||||
|
||||
@ -465,7 +474,6 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
|
||||
|
||||
/**
|
||||
* Starts a regular Bluetooth scan
|
||||
*
|
||||
*/
|
||||
private void startBTDiscovery() {
|
||||
LOG.info("Starting BT discovery");
|
||||
@ -492,17 +500,6 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
|
||||
}
|
||||
}
|
||||
|
||||
public void setScanning(boolean scanning) {
|
||||
this.scanning = scanning;
|
||||
if (scanning) {
|
||||
startButton.setText(getString(R.string.discovery_stop_scanning));
|
||||
} else {
|
||||
startButton.setText(getString(R.string.discovery_start_scanning));
|
||||
bluetoothProgress.setVisibility(View.GONE);
|
||||
bluetoothLEProgress.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void bluetoothStateChanged(int newState) {
|
||||
if (newState == BluetoothAdapter.STATE_ON) {
|
||||
this.adapter = BluetoothAdapter.getDefaultAdapter();
|
||||
@ -771,20 +768,6 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
|
||||
spinner.setOnItemSelectedListener(new CustomOnDeviceSelectedListener());
|
||||
}
|
||||
|
||||
public class CustomOnDeviceSelectedListener implements AdapterView.OnItemSelectedListener {
|
||||
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
|
||||
SpinnerWithIconItem selectedItem = (SpinnerWithIconItem) parent.getItemAtPosition(pos);
|
||||
selectedUnsupportedDeviceKey = selectedItem.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void onBondingComplete(boolean success) {
|
||||
finish();
|
||||
}
|
||||
@ -839,6 +822,20 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
|
||||
return this;
|
||||
}
|
||||
|
||||
public class CustomOnDeviceSelectedListener implements AdapterView.OnItemSelectedListener {
|
||||
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
|
||||
SpinnerWithIconItem selectedItem = (SpinnerWithIconItem) parent.getItemAtPosition(pos);
|
||||
selectedUnsupportedDeviceKey = selectedItem.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class BTUUIDPair {
|
||||
private final BluetoothDevice bluetoothDevice;
|
||||
private final ParcelUuid[] parcelUuid;
|
||||
@ -863,4 +860,6 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user