1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-29 03:55:49 +01:00

Casio GB-5600B/GB-6900B: Add configurable disconnect notification

This commit is contained in:
Andreas Böhler 2020-11-23 22:52:30 +01:00
parent 99d1a0f0b9
commit b0a0a29bcb
2 changed files with 22 additions and 3 deletions

View File

@ -47,7 +47,7 @@ public class CasioGB6900DeviceCoordinator extends AbstractDeviceCoordinator {
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getDevice().getName();
if (name != null) {
if (name.startsWith("CASIO") && (name.endsWith("6900B") || name.endsWith("5600B"))) {
if (name.startsWith("CASIO") && (name.contains("6900B") || name.contains("5600B"))) {
return DeviceType.CASIOGB6900;
}
}
@ -149,4 +149,11 @@ public class CasioGB6900DeviceCoordinator extends AbstractDeviceCoordinator {
protected void deleteDevice(@NonNull GBDevice gbDevice, @NonNull Device device, @NonNull DaoSession session) throws GBException {
}
@Override
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
return new int[] {
R.xml.devicesettings_disconnectnotification_noshed
};
}
}

View File

@ -22,6 +22,7 @@ import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattDescriptor;
import android.bluetooth.BluetoothGattService;
import android.content.SharedPreferences;
import android.net.Uri;
import android.widget.Toast;
@ -35,6 +36,7 @@ import java.util.Calendar;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
@ -57,6 +59,8 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.operations.Ini
import nodomain.freeyourgadget.gadgetbridge.util.GB;
import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_DISCONNECTNOTIF_NOSHED;
public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
private static final Logger LOG = LoggerFactory.getLogger(CasioGB6900DeviceSupport.class);
@ -184,13 +188,21 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
return mModel;
}
// FIXME: Replace hardcoded values by configuration
private void configureWatch(TransactionBuilder builder) {
if (mBtGatt == null) {
return;
}
byte[] value = new byte[]{GattCharacteristic.MILD_ALERT};
SharedPreferences sharedPreferences = GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress());
boolean enable = sharedPreferences.getBoolean(PREF_DISCONNECTNOTIF_NOSHED, false);
byte[] value = new byte[1];
if(enable)
value[0] = GattCharacteristic.MILD_ALERT;
else
value[0] = GattCharacteristic.NO_ALERT;
BluetoothGattService llService = mBtGatt.getService(CasioConstants.LINK_LOSS_SERVICE);
BluetoothGattCharacteristic charact = llService.getCharacteristic(CasioConstants.ALERT_LEVEL_CHARACTERISTIC_UUID);