2019-12-06 22:49:44 +01:00
|
|
|
/* Copyright (C) 2019 Daniel Dakhno
|
|
|
|
|
|
|
|
This file is part of Gadgetbridge.
|
|
|
|
|
|
|
|
Gadgetbridge is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published
|
|
|
|
by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Gadgetbridge is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2019-10-24 19:44:35 +02:00
|
|
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter;
|
|
|
|
|
|
|
|
import android.bluetooth.BluetoothGatt;
|
|
|
|
import android.bluetooth.BluetoothGattCharacteristic;
|
|
|
|
import android.content.Context;
|
|
|
|
|
2019-11-20 00:56:09 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2019-10-28 12:35:22 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.NotificationConfiguration;
|
2019-11-20 00:56:09 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
2019-10-24 19:44:35 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybridSupport;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.misfit.PlayNotificationRequest;
|
|
|
|
|
|
|
|
public abstract class WatchAdapter {
|
|
|
|
private QHybridSupport deviceSupport;
|
|
|
|
|
|
|
|
public WatchAdapter(QHybridSupport deviceSupport){
|
|
|
|
this.deviceSupport = deviceSupport;
|
|
|
|
}
|
|
|
|
|
2019-10-27 23:24:02 +01:00
|
|
|
public QHybridSupport getDeviceSupport(){
|
2019-10-24 19:44:35 +02:00
|
|
|
return this.deviceSupport;
|
|
|
|
}
|
|
|
|
|
2019-10-30 02:50:00 +01:00
|
|
|
public Context getContext(){
|
2019-10-24 19:44:35 +02:00
|
|
|
return getDeviceSupport().getContext();
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract void initialize();
|
|
|
|
|
|
|
|
public abstract void playPairingAnimation();
|
2019-10-28 12:35:22 +01:00
|
|
|
public abstract void playNotification(NotificationConfiguration config);
|
2019-10-24 19:44:35 +02:00
|
|
|
public abstract void setTime();
|
2019-11-24 00:44:14 +01:00
|
|
|
public abstract void overwriteButtons(String buttonConfigJson);
|
2019-10-24 19:44:35 +02:00
|
|
|
public abstract void setActivityHand(double progress);
|
|
|
|
public abstract void setHands(short hour, short minute);
|
|
|
|
public abstract void vibrate(PlayNotificationRequest.VibrationType vibration);
|
2019-10-25 19:13:55 +02:00
|
|
|
public abstract void vibrateFindMyDevicePattern();
|
2019-10-24 19:44:35 +02:00
|
|
|
public abstract void requestHandsControl();
|
|
|
|
public abstract void releaseHandsControl();
|
|
|
|
public abstract void setStepGoal(int stepGoal);
|
|
|
|
public abstract void setVibrationStrength(short strength);
|
2019-10-30 02:50:00 +01:00
|
|
|
public abstract void syncNotificationSettings();
|
2019-10-27 23:24:02 +01:00
|
|
|
public abstract void onTestNewFunction();
|
2019-11-20 18:59:13 +01:00
|
|
|
public abstract void setTimezoneOffsetMinutes(short offset);
|
2019-10-24 19:44:35 +02:00
|
|
|
|
2019-11-04 02:47:38 +01:00
|
|
|
public abstract boolean supportsFindDevice();
|
2019-10-25 19:13:55 +02:00
|
|
|
public abstract boolean supportsExtendedVibration();
|
|
|
|
public abstract boolean supportsActivityHand();
|
2019-11-21 22:17:42 +01:00
|
|
|
|
|
|
|
public String getModelName() {
|
|
|
|
String modelNumber = getDeviceSupport().getDevice().getModel();
|
|
|
|
switch (modelNumber) {
|
|
|
|
case "HW.0.0":
|
|
|
|
return "Q Commuter";
|
|
|
|
case "HL.0.0":
|
|
|
|
return "Q Activist";
|
|
|
|
case "DN.1.0":
|
|
|
|
return "Hybrid HR Collider";
|
|
|
|
}
|
|
|
|
return "unknwon Q";
|
|
|
|
}
|
2019-10-25 19:13:55 +02:00
|
|
|
|
|
|
|
public abstract void onFetchActivityData();
|
|
|
|
|
2019-11-20 00:56:09 +01:00
|
|
|
public abstract void onSetAlarms(ArrayList<? extends Alarm> alarms);
|
|
|
|
|
2019-10-24 19:44:35 +02:00
|
|
|
public abstract boolean onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic);
|
2019-11-14 04:56:34 +01:00
|
|
|
public void onMtuChanged(BluetoothGatt gatt, int mtu, int status){};
|
2019-10-27 23:24:02 +01:00
|
|
|
|
|
|
|
|
|
|
|
public String arrayToString(byte[] bytes) {
|
|
|
|
if (bytes.length == 0) return "";
|
|
|
|
StringBuilder s = new StringBuilder();
|
|
|
|
final String chars = "0123456789ABCDEF";
|
|
|
|
for (byte b : bytes) {
|
|
|
|
s.append(chars.charAt((b >> 4) & 0xF)).append(chars.charAt(b & 0xF)).append(" ");
|
|
|
|
}
|
|
|
|
return s.substring(0, s.length() - 1) + "\n";
|
|
|
|
}
|
2019-10-24 19:44:35 +02:00
|
|
|
}
|