mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-03 15:32:54 +01:00
Moyoung: Modernize classes and methods and fix compiler errors
This commit is contained in:
parent
918fa8bedc
commit
c5102bdf70
@ -1041,14 +1041,14 @@ public class GBDaoGenerator {
|
|||||||
Entity activitySample = addEntity(schema, "MoyoungActivitySample");
|
Entity activitySample = addEntity(schema, "MoyoungActivitySample");
|
||||||
activitySample.implementsSerializable();
|
activitySample.implementsSerializable();
|
||||||
addCommonActivitySampleProperties("AbstractActivitySample", activitySample, user, device);
|
addCommonActivitySampleProperties("AbstractActivitySample", activitySample, user, device);
|
||||||
activitySample.addIntProperty(SAMPLE_STEPS).notNull().codeBeforeGetterAndSetter(OVERRIDE).codeBeforeGetter("@Override\n public int getRawIntensity() {\n return getSteps();\n }\n\n");
|
activitySample.addIntProperty(SAMPLE_STEPS).notNull().codeBeforeGetterAndSetter(OVERRIDE);
|
||||||
activitySample.addIntProperty(SAMPLE_RAW_KIND).notNull().codeBeforeGetterAndSetter(OVERRIDE);
|
activitySample.addIntProperty(SAMPLE_RAW_KIND).notNull().codeBeforeGetterAndSetter(OVERRIDE);
|
||||||
activitySample.addIntProperty("dataSource").notNull();
|
activitySample.addIntProperty("dataSource").notNull();
|
||||||
activitySample.addIntProperty("caloriesBurnt").notNull();
|
activitySample.addIntProperty("caloriesBurnt").notNull();
|
||||||
activitySample.addIntProperty("distanceMeters").notNull();
|
activitySample.addIntProperty("distanceMeters").notNull();
|
||||||
addHeartRateProperties(activitySample);
|
// addHeartRateProperties(activitySample);
|
||||||
addBloodPressureProperies(activitySample);
|
// addBloodPressureProperies(activitySample);
|
||||||
addBloodOxidationProperies(activitySample);
|
// addBloodOxidationProperies(activitySample);
|
||||||
activitySample.addIntProperty("batteryLevel").notNull();
|
activitySample.addIntProperty("batteryLevel").notNull();
|
||||||
return activitySample;
|
return activitySample;
|
||||||
}
|
}
|
||||||
|
@ -17,15 +17,11 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung;
|
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.Activity;
|
|
||||||
import android.bluetooth.le.ScanFilter;
|
import android.bluetooth.le.ScanFilter;
|
||||||
import android.content.Context;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.ParcelUuid;
|
import android.os.ParcelUuid;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -33,7 +29,6 @@ import java.util.Collections;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractDeviceCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractDeviceCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungEnumDeviceVersion;
|
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungEnumDeviceVersion;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungEnumMetricSystem;
|
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungEnumMetricSystem;
|
||||||
@ -50,21 +45,11 @@ import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSett
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
|
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.moyoung.MoyoungDeviceSupport;
|
||||||
|
|
||||||
public class MoyoungDeviceCoordinator extends AbstractDeviceCoordinator {
|
public abstract class AbstractMoyoungDeviceCoordinator extends AbstractDeviceCoordinator {
|
||||||
|
|
||||||
@Override
|
|
||||||
public DeviceType getDeviceType() {
|
|
||||||
return DeviceType.DAFIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getManufacturer() {
|
|
||||||
return "Media-Tech";
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
@ -77,12 +62,8 @@ public class MoyoungDeviceCoordinator extends AbstractDeviceCoordinator {
|
|||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
|
public Class<? extends DeviceSupport> getDeviceSupportClass() {
|
||||||
// TODO: It would be nice to also filter on "manufacturer" (which is used as a protocol version) being MOYOUNG-V2 or MOYOUNG but I have no idea if it's possible to do that at this point
|
return MoyoungDeviceSupport.class;
|
||||||
if (candidate.supportsService(MoyoungConstants.UUID_SERVICE_MOYOUNG)) {
|
|
||||||
return DeviceType.DAFIT;
|
|
||||||
}
|
|
||||||
return DeviceType.UNKNOWN;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -90,15 +71,9 @@ public class MoyoungDeviceCoordinator extends AbstractDeviceCoordinator {
|
|||||||
return BONDING_STYLE_NONE;
|
return BONDING_STYLE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Class<? extends Activity> getPairingActivity() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void deleteDevice(@NonNull GBDevice gbDevice, @NonNull Device device, @NonNull DaoSession session) throws GBException {
|
protected void deleteDevice(@NonNull GBDevice gbDevice, @NonNull Device device, @NonNull DaoSession session) throws GBException {
|
||||||
|
// TODO: remove device specific data
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -117,43 +92,18 @@ public class MoyoungDeviceCoordinator extends AbstractDeviceCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InstallHandler findInstallHandler(Uri uri, Context context) {
|
public int getAlarmSlotCount(GBDevice device) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean supportsScreenshots() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAlarmSlotCount() {
|
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean supportsSmartWakeup(GBDevice device) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsHeartRateMeasurement(GBDevice device) {
|
public boolean supportsHeartRateMeasurement(GBDevice device) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean supportsAppsManagement() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<? extends Activity> getAppsManagementActivity() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsCalendarEvents() {
|
public boolean supportsCalendarEvents() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -178,28 +128,9 @@ public class MoyoungDeviceCoordinator extends AbstractDeviceCoordinator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsMusicInfo() {
|
public boolean supportsMusicInfo() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean supportsLedColor() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean supportsRgbLedColor() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public int[] getColorPresets() {
|
|
||||||
return new int[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean supportsUnicodeEmojis() { return false; }
|
|
||||||
|
|
||||||
private static final MoyoungSetting[] MOYOUNG_SETTINGS = new MoyoungSetting[] {
|
private static final MoyoungSetting[] MOYOUNG_SETTINGS = new MoyoungSetting[] {
|
||||||
new MoyoungSettingUserInfo("USER_INFO", MoyoungConstants.CMD_SET_USER_INFO),
|
new MoyoungSettingUserInfo("USER_INFO", MoyoungConstants.CMD_SET_USER_INFO),
|
||||||
new MoyoungSettingByte("STEP_LENGTH", (byte)-1, MoyoungConstants.CMD_SET_STEP_LENGTH),
|
new MoyoungSettingByte("STEP_LENGTH", (byte)-1, MoyoungConstants.CMD_SET_STEP_LENGTH),
|
@ -0,0 +1,43 @@
|
|||||||
|
/* Copyright (C) 2024 Arjan Schrijver
|
||||||
|
|
||||||
|
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 <https://www.gnu.org/licenses/>. */
|
||||||
|
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
|
|
||||||
|
public class ColmiI28UltraCoordinator extends AbstractMoyoungDeviceCoordinator {
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(ColmiI28UltraCoordinator.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Pattern getSupportedDeviceName() {
|
||||||
|
return Pattern.compile("i28 Ultra");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDeviceNameResource() {
|
||||||
|
return R.string.devicetype_colmi_i28_ultra;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getManufacturer() {
|
||||||
|
return "Colmi";
|
||||||
|
}
|
||||||
|
}
|
@ -98,41 +98,41 @@ public class MoyoungSampleProvider extends AbstractSampleProvider<MoyoungActivit
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int normalizeType(int rawType) {
|
public ActivityKind normalizeType(int rawType) {
|
||||||
if (rawType == ACTIVITY_NOT_MEASURED)
|
if (rawType == ACTIVITY_NOT_MEASURED)
|
||||||
return ActivityKind.TYPE_NOT_MEASURED;
|
return ActivityKind.NOT_MEASURED;
|
||||||
else if (rawType == ACTIVITY_SLEEP_LIGHT)
|
else if (rawType == ACTIVITY_SLEEP_LIGHT)
|
||||||
return ActivityKind.TYPE_LIGHT_SLEEP;
|
return ActivityKind.LIGHT_SLEEP;
|
||||||
else if (rawType == ACTIVITY_SLEEP_RESTFUL)
|
else if (rawType == ACTIVITY_SLEEP_RESTFUL)
|
||||||
return ActivityKind.TYPE_DEEP_SLEEP;
|
return ActivityKind.DEEP_SLEEP;
|
||||||
else if (rawType == ACTIVITY_SLEEP_START || rawType == ACTIVITY_SLEEP_END)
|
else if (rawType == ACTIVITY_SLEEP_START || rawType == ACTIVITY_SLEEP_END)
|
||||||
return ActivityKind.TYPE_NOT_MEASURED;
|
return ActivityKind.NOT_MEASURED;
|
||||||
else if (rawType == ACTIVITY_TRAINING_WALK)
|
else if (rawType == ACTIVITY_TRAINING_WALK)
|
||||||
return ActivityKind.TYPE_WALKING;
|
return ActivityKind.WALKING;
|
||||||
else if (rawType == ACTIVITY_TRAINING_RUN)
|
else if (rawType == ACTIVITY_TRAINING_RUN)
|
||||||
return ActivityKind.TYPE_RUNNING;
|
return ActivityKind.RUNNING;
|
||||||
else if (rawType == ACTIVITY_TRAINING_BIKING)
|
else if (rawType == ACTIVITY_TRAINING_BIKING)
|
||||||
return ActivityKind.TYPE_CYCLING;
|
return ActivityKind.CYCLING;
|
||||||
else if (rawType == ACTIVITY_TRAINING_SWIM)
|
else if (rawType == ACTIVITY_TRAINING_SWIM)
|
||||||
return ActivityKind.TYPE_SWIMMING;
|
return ActivityKind.SWIMMING;
|
||||||
else if (rawType == ACTIVITY_TRAINING_ROPE || rawType == ACTIVITY_TRAINING_BADMINTON ||
|
else if (rawType == ACTIVITY_TRAINING_ROPE || rawType == ACTIVITY_TRAINING_BADMINTON ||
|
||||||
rawType == ACTIVITY_TRAINING_BASKETBALL || rawType == ACTIVITY_TRAINING_FOOTBALL ||
|
rawType == ACTIVITY_TRAINING_BASKETBALL || rawType == ACTIVITY_TRAINING_FOOTBALL ||
|
||||||
rawType == ACTIVITY_TRAINING_MOUNTAINEERING || rawType == ACTIVITY_TRAINING_TENNIS ||
|
rawType == ACTIVITY_TRAINING_MOUNTAINEERING || rawType == ACTIVITY_TRAINING_TENNIS ||
|
||||||
rawType == ACTIVITY_TRAINING_RUGBY || rawType == ACTIVITY_TRAINING_GOLF)
|
rawType == ACTIVITY_TRAINING_RUGBY || rawType == ACTIVITY_TRAINING_GOLF)
|
||||||
return ActivityKind.TYPE_EXERCISE;
|
return ActivityKind.EXERCISE;
|
||||||
else
|
else
|
||||||
return ActivityKind.TYPE_ACTIVITY;
|
return ActivityKind.ACTIVITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int toRawActivityKind(int activityKind) {
|
public int toRawActivityKind(ActivityKind activityKind) {
|
||||||
if (activityKind == ActivityKind.TYPE_NOT_MEASURED)
|
if (activityKind == ActivityKind.NOT_MEASURED)
|
||||||
return ACTIVITY_NOT_MEASURED;
|
return ACTIVITY_NOT_MEASURED;
|
||||||
else if (activityKind == ActivityKind.TYPE_LIGHT_SLEEP)
|
else if (activityKind == ActivityKind.LIGHT_SLEEP)
|
||||||
return ACTIVITY_SLEEP_LIGHT;
|
return ACTIVITY_SLEEP_LIGHT;
|
||||||
else if (activityKind == ActivityKind.TYPE_DEEP_SLEEP)
|
else if (activityKind == ActivityKind.DEEP_SLEEP)
|
||||||
return ACTIVITY_SLEEP_RESTFUL;
|
return ACTIVITY_SLEEP_RESTFUL;
|
||||||
else if (activityKind == ActivityKind.TYPE_ACTIVITY)
|
else if (activityKind == ActivityKind.ACTIVITY)
|
||||||
return ACTIVITY_NOT_MEASURED; // TODO: ?
|
return ACTIVITY_NOT_MEASURED; // TODO: ?
|
||||||
else
|
else
|
||||||
throw new IllegalArgumentException("Invalid Gadgetbridge activity kind: " + activityKind);
|
throw new IllegalArgumentException("Invalid Gadgetbridge activity kind: " + activityKind);
|
||||||
|
@ -29,7 +29,7 @@ public class MoyoungWeatherForecast {
|
|||||||
this.maxTemp = maxTemp;
|
this.maxTemp = maxTemp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MoyoungWeatherForecast(WeatherSpec.Forecast forecast)
|
public MoyoungWeatherForecast(WeatherSpec.Daily forecast)
|
||||||
{
|
{
|
||||||
conditionId = MoyoungConstants.openWeatherConditionToMoyoungConditionId(forecast.conditionCode);
|
conditionId = MoyoungConstants.openWeatherConditionToMoyoungConditionId(forecast.conditionCode);
|
||||||
minTemp = (byte)(forecast.minTemp - 273); // Kelvin -> Celcius
|
minTemp = (byte)(forecast.minTemp - 273); // Kelvin -> Celcius
|
||||||
|
@ -221,6 +221,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.mijia_lywsd.MijiaMhoC303Coor
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.devices.miscale.MiSmartScaleCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.miscale.MiSmartScaleCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.miscale.MiCompositionScaleCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.miscale.MiCompositionScaleCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.moondrop.MoondropSpaceTravelCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.moondrop.MoondropSpaceTravelCoordinator;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.ColmiI28UltraCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.no1f1.No1F1Coordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.no1f1.No1F1Coordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.nothing.CmfBudsPro2Coordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.nothing.CmfBudsPro2Coordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.nothing.Ear1Coordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.nothing.Ear1Coordinator;
|
||||||
@ -558,6 +559,7 @@ public enum DeviceType {
|
|||||||
COLMI_R03(ColmiR03Coordinator.class),
|
COLMI_R03(ColmiR03Coordinator.class),
|
||||||
COLMI_R06(ColmiR06Coordinator.class),
|
COLMI_R06(ColmiR06Coordinator.class),
|
||||||
COLMI_R10(ColmiR10Coordinator.class),
|
COLMI_R10(ColmiR10Coordinator.class),
|
||||||
|
COLMI_I28_ULTRA(ColmiI28UltraCoordinator.class),
|
||||||
B_AND_W_P_SERIES(BandWPSeriesDeviceCoordinator.class),
|
B_AND_W_P_SERIES(BandWPSeriesDeviceCoordinator.class),
|
||||||
SCANNABLE(ScannableDeviceCoordinator.class),
|
SCANNABLE(ScannableDeviceCoordinator.class),
|
||||||
CYCLING_SENSOR(CyclingSensorCoordinator.class),
|
CYCLING_SENSOR(CyclingSensorCoordinator.class),
|
||||||
|
@ -205,7 +205,7 @@ public class FetchDataOperation extends AbstractBTLEOperation<MoyoungDeviceSuppo
|
|||||||
operationStatus = OperationStatus.FINISHED;
|
operationStatus = OperationStatus.FINISHED;
|
||||||
if (getDevice() != null && getDevice().isConnected()) {
|
if (getDevice() != null && getDevice().isConnected()) {
|
||||||
unsetBusy();
|
unsetBusy();
|
||||||
GB.signalActivityDataFinish();
|
GB.signalActivityDataFinish(getDevice());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ import android.bluetooth.BluetoothGatt;
|
|||||||
import android.bluetooth.BluetoothGattCharacteristic;
|
import android.bluetooth.BluetoothGattCharacteristic;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -42,7 +41,6 @@ import java.util.Calendar;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -57,25 +55,20 @@ import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventConfigurationRead;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.AbstractMoyoungDeviceCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungConstants;
|
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungConstants;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungSampleProvider;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungWeatherForecast;
|
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungWeatherForecast;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungWeatherToday;
|
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungWeatherToday;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungDeviceCoordinator;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungSampleProvider;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungEnumDeviceVersion;
|
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungEnumDeviceVersion;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungEnumLanguage;
|
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungEnumLanguage;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungEnumMetricSystem;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungEnumTimeSystem;
|
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungEnumTimeSystem;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSetting;
|
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSetting;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingEnum;
|
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingEnum;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingLanguage;
|
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingLanguage;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingRemindersToMove;
|
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingRemindersToMove;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingTimeRange;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.entities.BaseActivitySummary;
|
import nodomain.freeyourgadget.gadgetbridge.entities.BaseActivitySummary;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.entities.BaseActivitySummaryDao;
|
import nodomain.freeyourgadget.gadgetbridge.entities.BaseActivitySummaryDao;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
|
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
|
||||||
@ -86,12 +79,8 @@ import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
|
import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceService;
|
import nodomain.freeyourgadget.gadgetbridge.model.DeviceService;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.RecordedDataTypes;
|
import nodomain.freeyourgadget.gadgetbridge.model.RecordedDataTypes;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
|
||||||
@ -107,7 +96,6 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.deviceinfo.Dev
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.heartrate.HeartRateProfile;
|
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.heartrate.HeartRateProfile;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.AlarmUtils;
|
import nodomain.freeyourgadget.gadgetbridge.util.AlarmUtils;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.ArrayUtils;
|
import nodomain.freeyourgadget.gadgetbridge.util.ArrayUtils;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.NotificationUtils;
|
import nodomain.freeyourgadget.gadgetbridge.util.NotificationUtils;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||||
@ -174,8 +162,8 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
sendSetting(builder, getSetting("USER_INFO"), new ActivityUser()); // these settings are write-only, so write them just in case because there is no way to know if they desynced somehow
|
sendSetting(builder, getSetting("USER_INFO"), new ActivityUser()); // these settings are write-only, so write them just in case because there is no way to know if they desynced somehow
|
||||||
sendSetting(builder, getSetting("GOAL_STEP"), new ActivityUser().getStepsGoal());
|
sendSetting(builder, getSetting("GOAL_STEP"), new ActivityUser().getStepsGoal());
|
||||||
batteryInfoProfile.requestBatteryInfo(builder);
|
batteryInfoProfile.requestBatteryInfo(builder);
|
||||||
batteryInfoProfile.enableNotify(builder);
|
batteryInfoProfile.enableNotify(builder, true);
|
||||||
heartRateProfile.enableNotify(builder);
|
heartRateProfile.enableNotify(builder, true);
|
||||||
builder.notify(getCharacteristic(MoyoungConstants.UUID_CHARACTERISTIC_STEPS), true);
|
builder.notify(getCharacteristic(MoyoungConstants.UUID_CHARACTERISTIC_STEPS), true);
|
||||||
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZED, getContext()));
|
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZED, getContext()));
|
||||||
|
|
||||||
@ -261,9 +249,9 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
sample.setCaloriesBurnt(ActivitySample.NOT_MEASURED);
|
sample.setCaloriesBurnt(ActivitySample.NOT_MEASURED);
|
||||||
|
|
||||||
sample.setHeartRate(heartRate);
|
sample.setHeartRate(heartRate);
|
||||||
sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
// sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||||
sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
// sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||||
sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
// sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||||
|
|
||||||
addGBActivitySample(sample);
|
addGBActivitySample(sample);
|
||||||
broadcastSample(sample);
|
broadcastSample(sample);
|
||||||
@ -290,9 +278,9 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
sample.setCaloriesBurnt(ActivitySample.NOT_MEASURED);
|
sample.setCaloriesBurnt(ActivitySample.NOT_MEASURED);
|
||||||
|
|
||||||
sample.setHeartRate(ActivitySample.NOT_MEASURED);
|
sample.setHeartRate(ActivitySample.NOT_MEASURED);
|
||||||
sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
// sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||||
sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
// sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||||
sample.setBloodOxidation(percent);
|
// sample.setBloodOxidation(percent);
|
||||||
|
|
||||||
addGBActivitySample(sample);
|
addGBActivitySample(sample);
|
||||||
broadcastSample(sample);
|
broadcastSample(sample);
|
||||||
@ -319,9 +307,9 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
sample.setCaloriesBurnt(ActivitySample.NOT_MEASURED);
|
sample.setCaloriesBurnt(ActivitySample.NOT_MEASURED);
|
||||||
|
|
||||||
sample.setHeartRate(ActivitySample.NOT_MEASURED);
|
sample.setHeartRate(ActivitySample.NOT_MEASURED);
|
||||||
sample.setBloodPressureSystolic(data1);
|
// sample.setBloodPressureSystolic(data1);
|
||||||
sample.setBloodPressureDiastolic(data2);
|
// sample.setBloodPressureDiastolic(data2);
|
||||||
sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
// sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||||
|
|
||||||
addGBActivitySample(sample);
|
addGBActivitySample(sample);
|
||||||
broadcastSample(sample);
|
broadcastSample(sample);
|
||||||
@ -462,9 +450,9 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
sample.setCaloriesBurnt(ActivitySample.NOT_MEASURED);
|
sample.setCaloriesBurnt(ActivitySample.NOT_MEASURED);
|
||||||
|
|
||||||
sample.setHeartRate(ActivitySample.NOT_MEASURED);
|
sample.setHeartRate(ActivitySample.NOT_MEASURED);
|
||||||
sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
// sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||||
sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
// sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||||
sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
// sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||||
|
|
||||||
addGBActivitySample(sample);
|
addGBActivitySample(sample);
|
||||||
broadcastSample(sample);
|
broadcastSample(sample);
|
||||||
@ -504,11 +492,6 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
sendNotification(MoyoungConstants.notificationType(notificationSpec.type), sender + ":" + text);
|
sendNotification(MoyoungConstants.notificationType(notificationSpec.type), sender + ":" + text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDeleteNotification(int id) {
|
|
||||||
// not supported :(
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSetCallState(CallSpec callSpec) {
|
public void onSetCallState(CallSpec callSpec) {
|
||||||
if (callSpec.command == CallSpec.CALL_INCOMING)
|
if (callSpec.command == CallSpec.CALL_INCOMING)
|
||||||
@ -517,11 +500,6 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
sendNotification(MoyoungConstants.NOTIFICATION_TYPE_CALL_OFF_HOOK, "");
|
sendNotification(MoyoungConstants.NOTIFICATION_TYPE_CALL_OFF_HOOK, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSetCannedMessages(CannedMessagesSpec cannedMessagesSpec) {
|
|
||||||
// not supported :(
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setTime(TransactionBuilder builder) {
|
private void setTime(TransactionBuilder builder) {
|
||||||
ByteBuffer buffer = ByteBuffer.allocate(5);
|
ByteBuffer buffer = ByteBuffer.allocate(5);
|
||||||
buffer.putInt(MoyoungConstants.LocalTimeToWatchTime(new Date())); // The watch is hardcoded to GMT+8 internally...
|
buffer.putInt(MoyoungConstants.LocalTimeToWatchTime(new Date())); // The watch is hardcoded to GMT+8 internally...
|
||||||
@ -631,46 +609,6 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSetMusicState(MusicStateSpec stateSpec) {
|
|
||||||
// not supported :(
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSetMusicInfo(MusicSpec musicSpec) {
|
|
||||||
// not supported :(
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInstallApp(Uri uri) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAppInfoReq() {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAppStart(UUID uuid, boolean start) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAppDelete(UUID uuid) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAppConfiguration(UUID appUuid, String config, Integer id) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAppReorder(UUID[] uuids) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFetchRecordedData(int dataTypes) {
|
public void onFetchRecordedData(int dataTypes) {
|
||||||
if ((dataTypes & RecordedDataTypes.TYPE_ACTIVITY) != 0)
|
if ((dataTypes & RecordedDataTypes.TYPE_ACTIVITY) != 0)
|
||||||
@ -734,9 +672,9 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
sample.setCaloriesBurnt(0);
|
sample.setCaloriesBurnt(0);
|
||||||
|
|
||||||
sample.setHeartRate(ActivitySample.NOT_MEASURED);
|
sample.setHeartRate(ActivitySample.NOT_MEASURED);
|
||||||
sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
// sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||||
sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
// sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||||
sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
// sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||||
|
|
||||||
provider.addGBActivitySample(sample);
|
provider.addGBActivitySample(sample);
|
||||||
broadcastSample(sample);
|
broadcastSample(sample);
|
||||||
@ -831,9 +769,9 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
sample.setCaloriesBurnt(newCalories);
|
sample.setCaloriesBurnt(newCalories);
|
||||||
|
|
||||||
sample.setHeartRate(ActivitySample.NOT_MEASURED);
|
sample.setHeartRate(ActivitySample.NOT_MEASURED);
|
||||||
sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
// sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||||
sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
// sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||||
sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
// sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||||
|
|
||||||
provider.addGBActivitySample(sample);
|
provider.addGBActivitySample(sample);
|
||||||
if (isRealtime)
|
if (isRealtime)
|
||||||
@ -936,9 +874,9 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
prevSegmentSample.setCaloriesBurnt(ActivitySample.NOT_MEASURED);
|
prevSegmentSample.setCaloriesBurnt(ActivitySample.NOT_MEASURED);
|
||||||
|
|
||||||
prevSegmentSample.setHeartRate(ActivitySample.NOT_MEASURED);
|
prevSegmentSample.setHeartRate(ActivitySample.NOT_MEASURED);
|
||||||
prevSegmentSample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
// prevSegmentSample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||||
prevSegmentSample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
// prevSegmentSample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||||
prevSegmentSample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
// prevSegmentSample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||||
|
|
||||||
addGBActivitySampleIfNotExists(provider, prevSegmentSample);
|
addGBActivitySampleIfNotExists(provider, prevSegmentSample);
|
||||||
|
|
||||||
@ -958,9 +896,9 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
nextSegmentSample.setCaloriesBurnt(ActivitySample.NOT_MEASURED);
|
nextSegmentSample.setCaloriesBurnt(ActivitySample.NOT_MEASURED);
|
||||||
|
|
||||||
nextSegmentSample.setHeartRate(ActivitySample.NOT_MEASURED);
|
nextSegmentSample.setHeartRate(ActivitySample.NOT_MEASURED);
|
||||||
nextSegmentSample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
// nextSegmentSample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||||
nextSegmentSample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
// nextSegmentSample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||||
nextSegmentSample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
// nextSegmentSample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||||
|
|
||||||
addGBActivitySampleIfNotExists(provider, nextSegmentSample);
|
addGBActivitySampleIfNotExists(provider, nextSegmentSample);
|
||||||
|
|
||||||
@ -1031,7 +969,7 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
summary.setDevice(device);
|
summary.setDevice(device);
|
||||||
summary.setUser(user);
|
summary.setUser(user);
|
||||||
|
|
||||||
int gbType = provider.normalizeType(type);
|
ActivityKind gbType = provider.normalizeType(type);
|
||||||
String name;
|
String name;
|
||||||
if (type == MoyoungSampleProvider.ACTIVITY_TRAINING_ROPE)
|
if (type == MoyoungSampleProvider.ACTIVITY_TRAINING_ROPE)
|
||||||
name = "Rope";
|
name = "Rope";
|
||||||
@ -1050,9 +988,9 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
else if (type == MoyoungSampleProvider.ACTIVITY_TRAINING_GOLF)
|
else if (type == MoyoungSampleProvider.ACTIVITY_TRAINING_GOLF)
|
||||||
name = "Golf";
|
name = "Golf";
|
||||||
else
|
else
|
||||||
name = ActivityKind.asString(gbType, getContext());
|
name = gbType.name();
|
||||||
summary.setName(name);
|
summary.setName(name);
|
||||||
summary.setActivityKind(gbType);
|
summary.setActivityKind(gbType.getCode());
|
||||||
|
|
||||||
summary.setStartTime(startTime);
|
summary.setStartTime(startTime);
|
||||||
summary.setEndTime(endTime);
|
summary.setEndTime(endTime);
|
||||||
@ -1138,16 +1076,6 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
onAbortHeartRateTest();
|
onAbortHeartRateTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSetHeartRateMeasurementInterval(int seconds) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnableHeartRateSleepSupport(boolean enable) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFindDevice(boolean start) {
|
public void onFindDevice(boolean start) {
|
||||||
if (start)
|
if (start)
|
||||||
@ -1157,7 +1085,7 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_FIND_MY_WATCH, new byte[0]));
|
sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_FIND_MY_WATCH, new byte[0]));
|
||||||
builder.queue(getQueue());
|
builder.queue(getQueue());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
LOG.error("Error while finding device: ", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1166,29 +1094,9 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSetConstantVibration(int integer) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onScreenshotReq() {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAddCalendarEvent(CalendarEventSpec calendarEventSpec) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDeleteCalendarEvent(byte type, long id) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private <T extends MoyoungSetting> T getSetting(String id) {
|
private <T extends MoyoungSetting> T getSetting(String id) {
|
||||||
MoyoungDeviceCoordinator coordinator = (MoyoungDeviceCoordinator) DeviceHelper.getInstance().getCoordinator(getDevice());
|
AbstractMoyoungDeviceCoordinator coordinator = (AbstractMoyoungDeviceCoordinator) getDevice().getDeviceCoordinator();
|
||||||
for(MoyoungSetting setting : coordinator.getSupportedSettings())
|
for(MoyoungSetting setting : coordinator.getSupportedSettings())
|
||||||
{
|
{
|
||||||
if (setting.name.equals(id))
|
if (setting.name.equals(id))
|
||||||
@ -1274,19 +1182,19 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
sendSetting(getSetting("TIME_SYSTEM"), timeSystem);
|
sendSetting(getSetting("TIME_SYSTEM"), timeSystem);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM:
|
// case DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM:
|
||||||
String metricSystemPref = prefs.getString(DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM, getContext().getString(R.string.p_unit_metric));
|
// String metricSystemPref = prefs.getString(DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM, getContext().getString(R.string.p_unit_metric));
|
||||||
|
//
|
||||||
MoyoungEnumMetricSystem metricSystem;
|
// MoyoungEnumMetricSystem metricSystem;
|
||||||
if (metricSystemPref.equals(getContext().getString(R.string.p_unit_metric)))
|
// if (metricSystemPref.equals(getContext().getString(R.string.p_unit_metric)))
|
||||||
metricSystem = MoyoungEnumMetricSystem.METRIC_SYSTEM;
|
// metricSystem = MoyoungEnumMetricSystem.METRIC_SYSTEM;
|
||||||
else if (metricSystemPref.equals(getContext().getString(R.string.p_unit_imperial)))
|
// else if (metricSystemPref.equals(getContext().getString(R.string.p_unit_imperial)))
|
||||||
metricSystem = MoyoungEnumMetricSystem.IMPERIAL_SYSTEM;
|
// metricSystem = MoyoungEnumMetricSystem.IMPERIAL_SYSTEM;
|
||||||
else
|
// else
|
||||||
throw new IllegalArgumentException();
|
// throw new IllegalArgumentException();
|
||||||
|
//
|
||||||
sendSetting(getSetting("METRIC_SYSTEM"), metricSystem);
|
// sendSetting(getSetting("METRIC_SYSTEM"), metricSystem);
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case MoyoungConstants.PREF_WATCH_FACE:
|
case MoyoungConstants.PREF_WATCH_FACE:
|
||||||
String watchFacePref = prefs.getString(MoyoungConstants.PREF_WATCH_FACE, String.valueOf(1));
|
String watchFacePref = prefs.getString(MoyoungConstants.PREF_WATCH_FACE, String.valueOf(1));
|
||||||
@ -1310,47 +1218,47 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
sendSetting(versionSetting, versionSetting.findByValue(versionNum));
|
sendSetting(versionSetting, versionSetting.findByValue(versionNum));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MiBandConst.PREF_DO_NOT_DISTURB:
|
// case MiBandConst.PREF_DO_NOT_DISTURB:
|
||||||
case MiBandConst.PREF_DO_NOT_DISTURB_START:
|
// case MiBandConst.PREF_DO_NOT_DISTURB_START:
|
||||||
case MiBandConst.PREF_DO_NOT_DISTURB_END:
|
// case MiBandConst.PREF_DO_NOT_DISTURB_END:
|
||||||
String doNotDisturbPref = prefs.getString(MiBandConst.PREF_DO_NOT_DISTURB, MiBandConst.PREF_DO_NOT_DISTURB_OFF);
|
// String doNotDisturbPref = prefs.getString(MiBandConst.PREF_DO_NOT_DISTURB, MiBandConst.PREF_DO_NOT_DISTURB_OFF);
|
||||||
boolean doNotDisturbEnabled = !MiBandConst.PREF_DO_NOT_DISTURB_OFF.equals(doNotDisturbPref);
|
// boolean doNotDisturbEnabled = !MiBandConst.PREF_DO_NOT_DISTURB_OFF.equals(doNotDisturbPref);
|
||||||
|
//
|
||||||
|
// Calendar doNotDisturbStart = getTimePref(prefs, MiBandConst.PREF_DO_NOT_DISTURB_START, "01:00");
|
||||||
|
// Calendar doNotDisturbEnd = getTimePref(prefs, MiBandConst.PREF_DO_NOT_DISTURB_END, "06:00");
|
||||||
|
//
|
||||||
|
// MoyoungSettingTimeRange.TimeRange doNotDisturb;
|
||||||
|
// if (doNotDisturbEnabled)
|
||||||
|
// doNotDisturb = new MoyoungSettingTimeRange.TimeRange(
|
||||||
|
// (byte) doNotDisturbStart.get(Calendar.HOUR_OF_DAY), (byte) doNotDisturbStart.get(Calendar.MINUTE),
|
||||||
|
// (byte) doNotDisturbEnd.get(Calendar.HOUR_OF_DAY), (byte) doNotDisturbEnd.get(Calendar.MINUTE));
|
||||||
|
// else
|
||||||
|
// doNotDisturb = new MoyoungSettingTimeRange.TimeRange((byte)0, (byte)0, (byte)0, (byte)0);
|
||||||
|
//
|
||||||
|
// sendSetting(getSetting("DO_NOT_DISTURB_TIME"), doNotDisturb);
|
||||||
|
// break;
|
||||||
|
|
||||||
Calendar doNotDisturbStart = getTimePref(prefs, MiBandConst.PREF_DO_NOT_DISTURB_START, "01:00");
|
// case HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT:
|
||||||
Calendar doNotDisturbEnd = getTimePref(prefs, MiBandConst.PREF_DO_NOT_DISTURB_END, "06:00");
|
// case HuamiConst.PREF_DISPLAY_ON_LIFT_START:
|
||||||
|
// case HuamiConst.PREF_DISPLAY_ON_LIFT_END:
|
||||||
MoyoungSettingTimeRange.TimeRange doNotDisturb;
|
// String quickViewPref = prefs.getString(HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT, MiBandConst.PREF_DO_NOT_DISTURB_OFF);
|
||||||
if (doNotDisturbEnabled)
|
// boolean quickViewEnabled = !quickViewPref.equals(getContext().getString(R.string.p_off));
|
||||||
doNotDisturb = new MoyoungSettingTimeRange.TimeRange(
|
// boolean quickViewScheduled = quickViewPref.equals(getContext().getString(R.string.p_scheduled));
|
||||||
(byte) doNotDisturbStart.get(Calendar.HOUR_OF_DAY), (byte) doNotDisturbStart.get(Calendar.MINUTE),
|
//
|
||||||
(byte) doNotDisturbEnd.get(Calendar.HOUR_OF_DAY), (byte) doNotDisturbEnd.get(Calendar.MINUTE));
|
// Calendar quickViewStart = getTimePref(prefs, HuamiConst.PREF_DISPLAY_ON_LIFT_START, "00:00");
|
||||||
else
|
// Calendar quickViewEnd = getTimePref(prefs, HuamiConst.PREF_DISPLAY_ON_LIFT_END, "00:00");
|
||||||
doNotDisturb = new MoyoungSettingTimeRange.TimeRange((byte)0, (byte)0, (byte)0, (byte)0);
|
//
|
||||||
|
// MoyoungSettingTimeRange.TimeRange quickViewTime;
|
||||||
sendSetting(getSetting("DO_NOT_DISTURB_TIME"), doNotDisturb);
|
// if (quickViewEnabled && quickViewScheduled)
|
||||||
break;
|
// quickViewTime = new MoyoungSettingTimeRange.TimeRange(
|
||||||
|
// (byte) quickViewStart.get(Calendar.HOUR_OF_DAY), (byte) quickViewStart.get(Calendar.MINUTE),
|
||||||
case HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT:
|
// (byte) quickViewEnd.get(Calendar.HOUR_OF_DAY), (byte) quickViewEnd.get(Calendar.MINUTE));
|
||||||
case HuamiConst.PREF_DISPLAY_ON_LIFT_START:
|
// else
|
||||||
case HuamiConst.PREF_DISPLAY_ON_LIFT_END:
|
// quickViewTime = new MoyoungSettingTimeRange.TimeRange((byte)0, (byte)0, (byte)0, (byte)0);
|
||||||
String quickViewPref = prefs.getString(HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT, MiBandConst.PREF_DO_NOT_DISTURB_OFF);
|
//
|
||||||
boolean quickViewEnabled = !quickViewPref.equals(getContext().getString(R.string.p_off));
|
// sendSetting(getSetting("QUICK_VIEW"), quickViewEnabled);
|
||||||
boolean quickViewScheduled = quickViewPref.equals(getContext().getString(R.string.p_scheduled));
|
// sendSetting(getSetting("QUICK_VIEW_TIME"), quickViewTime);
|
||||||
|
// break;
|
||||||
Calendar quickViewStart = getTimePref(prefs, HuamiConst.PREF_DISPLAY_ON_LIFT_START, "00:00");
|
|
||||||
Calendar quickViewEnd = getTimePref(prefs, HuamiConst.PREF_DISPLAY_ON_LIFT_END, "00:00");
|
|
||||||
|
|
||||||
MoyoungSettingTimeRange.TimeRange quickViewTime;
|
|
||||||
if (quickViewEnabled && quickViewScheduled)
|
|
||||||
quickViewTime = new MoyoungSettingTimeRange.TimeRange(
|
|
||||||
(byte) quickViewStart.get(Calendar.HOUR_OF_DAY), (byte) quickViewStart.get(Calendar.MINUTE),
|
|
||||||
(byte) quickViewEnd.get(Calendar.HOUR_OF_DAY), (byte) quickViewEnd.get(Calendar.MINUTE));
|
|
||||||
else
|
|
||||||
quickViewTime = new MoyoungSettingTimeRange.TimeRange((byte)0, (byte)0, (byte)0, (byte)0);
|
|
||||||
|
|
||||||
sendSetting(getSetting("QUICK_VIEW"), quickViewEnabled);
|
|
||||||
sendSetting(getSetting("QUICK_VIEW_TIME"), quickViewTime);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MoyoungConstants.PREF_SEDENTARY_REMINDER:
|
case MoyoungConstants.PREF_SEDENTARY_REMINDER:
|
||||||
String sedentaryReminderPref = prefs.getString(MoyoungConstants.PREF_SEDENTARY_REMINDER, "off");
|
String sedentaryReminderPref = prefs.getString(MoyoungConstants.PREF_SEDENTARY_REMINDER, "off");
|
||||||
@ -1397,9 +1305,9 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
querySetting(getSetting("TIME_SYSTEM"));
|
querySetting(getSetting("TIME_SYSTEM"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM:
|
// case DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM:
|
||||||
querySetting(getSetting("METRIC_SYSTEM"));
|
// querySetting(getSetting("METRIC_SYSTEM"));
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case MoyoungConstants.PREF_WATCH_FACE:
|
case MoyoungConstants.PREF_WATCH_FACE:
|
||||||
querySetting(getSetting("DISPLAY_WATCH_FACE"));
|
querySetting(getSetting("DISPLAY_WATCH_FACE"));
|
||||||
@ -1413,18 +1321,18 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
querySetting(getSetting("DEVICE_VERSION"));
|
querySetting(getSetting("DEVICE_VERSION"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MiBandConst.PREF_DO_NOT_DISTURB:
|
// case MiBandConst.PREF_DO_NOT_DISTURB:
|
||||||
case MiBandConst.PREF_DO_NOT_DISTURB_START:
|
// case MiBandConst.PREF_DO_NOT_DISTURB_START:
|
||||||
case MiBandConst.PREF_DO_NOT_DISTURB_END:
|
// case MiBandConst.PREF_DO_NOT_DISTURB_END:
|
||||||
querySetting(getSetting("DO_NOT_DISTURB_TIME"));
|
// querySetting(getSetting("DO_NOT_DISTURB_TIME"));
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT:
|
// case HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT:
|
||||||
case HuamiConst.PREF_DISPLAY_ON_LIFT_START:
|
// case HuamiConst.PREF_DISPLAY_ON_LIFT_START:
|
||||||
case HuamiConst.PREF_DISPLAY_ON_LIFT_END:
|
// case HuamiConst.PREF_DISPLAY_ON_LIFT_END:
|
||||||
querySetting(getSetting("QUICK_VIEW"));
|
// querySetting(getSetting("QUICK_VIEW"));
|
||||||
querySetting(getSetting("QUICK_VIEW_TIME"));
|
// querySetting(getSetting("QUICK_VIEW_TIME"));
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case MoyoungConstants.PREF_SEDENTARY_REMINDER:
|
case MoyoungConstants.PREF_SEDENTARY_REMINDER:
|
||||||
querySetting(getSetting("SEDENTARY_REMINDER"));
|
querySetting(getSetting("SEDENTARY_REMINDER"));
|
||||||
@ -1440,10 +1348,10 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GBDeviceEventConfigurationRead configReadEvent = new GBDeviceEventConfigurationRead();
|
// GBDeviceEventConfigurationRead configReadEvent = new GBDeviceEventConfigurationRead();
|
||||||
configReadEvent.config = config;
|
// configReadEvent.config = config;
|
||||||
configReadEvent.event = GBDeviceEventConfigurationRead.Event.IN_PROGRESS;
|
// configReadEvent.event = GBDeviceEventConfigurationRead.Event.IN_PROGRESS;
|
||||||
evaluateGBDeviceEvent(configReadEvent);
|
// evaluateGBDeviceEvent(configReadEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onReadConfigurationDone(MoyoungSetting setting, Object value, byte[] data)
|
public void onReadConfigurationDone(MoyoungSetting setting, Object value, byte[] data)
|
||||||
@ -1463,15 +1371,15 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
throw new IllegalArgumentException("Invalid value");
|
throw new IllegalArgumentException("Invalid value");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "METRIC_SYSTEM":
|
// case "METRIC_SYSTEM":
|
||||||
MoyoungEnumMetricSystem metricSystem = (MoyoungEnumMetricSystem) value;
|
// MoyoungEnumMetricSystem metricSystem = (MoyoungEnumMetricSystem) value;
|
||||||
if (metricSystem == MoyoungEnumMetricSystem.METRIC_SYSTEM)
|
// if (metricSystem == MoyoungEnumMetricSystem.METRIC_SYSTEM)
|
||||||
changedProperties.put(DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM, getContext().getString(R.string.p_unit_metric));
|
// changedProperties.put(DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM, getContext().getString(R.string.p_unit_metric));
|
||||||
else if (metricSystem == MoyoungEnumMetricSystem.IMPERIAL_SYSTEM)
|
// else if (metricSystem == MoyoungEnumMetricSystem.IMPERIAL_SYSTEM)
|
||||||
changedProperties.put(DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM, getContext().getString(R.string.p_unit_imperial));
|
// changedProperties.put(DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM, getContext().getString(R.string.p_unit_imperial));
|
||||||
else
|
// else
|
||||||
throw new IllegalArgumentException("Invalid value");
|
// throw new IllegalArgumentException("Invalid value");
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case "DISPLAY_WATCH_FACE":
|
case "DISPLAY_WATCH_FACE":
|
||||||
byte watchFace = (Byte) value;
|
byte watchFace = (Byte) value;
|
||||||
@ -1493,37 +1401,37 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
changedProperties.put(MoyoungConstants.PREF_DEVICE_VERSION, String.valueOf(deviceVersion.value()));
|
changedProperties.put(MoyoungConstants.PREF_DEVICE_VERSION, String.valueOf(deviceVersion.value()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "DO_NOT_DISTURB_TIME":
|
// case "DO_NOT_DISTURB_TIME":
|
||||||
MoyoungSettingTimeRange.TimeRange doNotDisturb = (MoyoungSettingTimeRange.TimeRange) value;
|
// MoyoungSettingTimeRange.TimeRange doNotDisturb = (MoyoungSettingTimeRange.TimeRange) value;
|
||||||
if (doNotDisturb.start_h == 0 && doNotDisturb.start_m == 0 &&
|
// if (doNotDisturb.start_h == 0 && doNotDisturb.start_m == 0 &&
|
||||||
doNotDisturb.end_h == 0 && doNotDisturb.end_m == 0)
|
// doNotDisturb.end_h == 0 && doNotDisturb.end_m == 0)
|
||||||
changedProperties.put(MiBandConst.PREF_DO_NOT_DISTURB, MiBandConst.PREF_DO_NOT_DISTURB_OFF);
|
// changedProperties.put(MiBandConst.PREF_DO_NOT_DISTURB, MiBandConst.PREF_DO_NOT_DISTURB_OFF);
|
||||||
else
|
// else
|
||||||
changedProperties.put(MiBandConst.PREF_DO_NOT_DISTURB, MiBandConst.PREF_DO_NOT_DISTURB_SCHEDULED);
|
// changedProperties.put(MiBandConst.PREF_DO_NOT_DISTURB, MiBandConst.PREF_DO_NOT_DISTURB_SCHEDULED);
|
||||||
changedProperties.put(MiBandConst.PREF_DO_NOT_DISTURB_START, String.format(Locale.ROOT, "%02d:%02d", doNotDisturb.start_h, doNotDisturb.start_m));
|
// changedProperties.put(MiBandConst.PREF_DO_NOT_DISTURB_START, String.format(Locale.ROOT, "%02d:%02d", doNotDisturb.start_h, doNotDisturb.start_m));
|
||||||
changedProperties.put(MiBandConst.PREF_DO_NOT_DISTURB_END, String.format(Locale.ROOT, "%02d:%02d", doNotDisturb.end_h, doNotDisturb.end_m));
|
// changedProperties.put(MiBandConst.PREF_DO_NOT_DISTURB_END, String.format(Locale.ROOT, "%02d:%02d", doNotDisturb.end_h, doNotDisturb.end_m));
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case "QUICK_VIEW":
|
// case "QUICK_VIEW":
|
||||||
boolean quickViewEnabled = (Boolean) value;
|
// boolean quickViewEnabled = (Boolean) value;
|
||||||
boolean quickViewScheduled = prefs.getString(HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT, getContext().getString(R.string.p_off)).equals(getContext().getString(R.string.p_scheduled));
|
// boolean quickViewScheduled = prefs.getString(HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT, getContext().getString(R.string.p_off)).equals(getContext().getString(R.string.p_scheduled));
|
||||||
changedProperties.put(HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT, quickViewEnabled ? (quickViewScheduled ? getContext().getString(R.string.p_scheduled) : getContext().getString(R.string.p_on)) : getContext().getString(R.string.p_off));
|
// changedProperties.put(HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT, quickViewEnabled ? (quickViewScheduled ? getContext().getString(R.string.p_scheduled) : getContext().getString(R.string.p_on)) : getContext().getString(R.string.p_off));
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case "QUICK_VIEW_TIME":
|
// case "QUICK_VIEW_TIME":
|
||||||
boolean quickViewEnabled2 = !prefs.getString(HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT, getContext().getString(R.string.p_off)).equals(getContext().getString(R.string.p_off));
|
// boolean quickViewEnabled2 = !prefs.getString(HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT, getContext().getString(R.string.p_off)).equals(getContext().getString(R.string.p_off));
|
||||||
MoyoungSettingTimeRange.TimeRange quickViewTime = (MoyoungSettingTimeRange.TimeRange) value;
|
// MoyoungSettingTimeRange.TimeRange quickViewTime = (MoyoungSettingTimeRange.TimeRange) value;
|
||||||
if (quickViewEnabled2)
|
// if (quickViewEnabled2)
|
||||||
{
|
// {
|
||||||
if (quickViewTime.start_h == 0 && quickViewTime.start_m == 0 &&
|
// if (quickViewTime.start_h == 0 && quickViewTime.start_m == 0 &&
|
||||||
quickViewTime.end_h == 0 && quickViewTime.end_m == 0)
|
// quickViewTime.end_h == 0 && quickViewTime.end_m == 0)
|
||||||
changedProperties.put(HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT, getContext().getString(R.string.p_on));
|
// changedProperties.put(HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT, getContext().getString(R.string.p_on));
|
||||||
else
|
// else
|
||||||
changedProperties.put(HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT, getContext().getString(R.string.p_scheduled));
|
// changedProperties.put(HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT, getContext().getString(R.string.p_scheduled));
|
||||||
}
|
// }
|
||||||
changedProperties.put(HuamiConst.PREF_DISPLAY_ON_LIFT_START, String.format(Locale.ROOT, "%02d:%02d", quickViewTime.start_h, quickViewTime.start_m));
|
// changedProperties.put(HuamiConst.PREF_DISPLAY_ON_LIFT_START, String.format(Locale.ROOT, "%02d:%02d", quickViewTime.start_h, quickViewTime.start_m));
|
||||||
changedProperties.put(HuamiConst.PREF_DISPLAY_ON_LIFT_END, String.format(Locale.ROOT, "%02d:%02d", quickViewTime.end_h, quickViewTime.end_m));
|
// changedProperties.put(HuamiConst.PREF_DISPLAY_ON_LIFT_END, String.format(Locale.ROOT, "%02d:%02d", quickViewTime.end_h, quickViewTime.end_m));
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case "SEDENTARY_REMINDER":
|
case "SEDENTARY_REMINDER":
|
||||||
boolean sedentaryReminderEnabled = (Boolean) value;
|
boolean sedentaryReminderEnabled = (Boolean) value;
|
||||||
@ -1541,13 +1449,13 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
for (Map.Entry<String, String> property : changedProperties.entrySet())
|
for (Map.Entry<String, String> property : changedProperties.entrySet())
|
||||||
prefsEditor.putString(property.getKey(), property.getValue());
|
prefsEditor.putString(property.getKey(), property.getValue());
|
||||||
prefsEditor.apply();
|
prefsEditor.apply();
|
||||||
for (Map.Entry<String, String> property : changedProperties.entrySet())
|
// for (Map.Entry<String, String> property : changedProperties.entrySet())
|
||||||
{
|
// {
|
||||||
GBDeviceEventConfigurationRead configReadEvent = new GBDeviceEventConfigurationRead();
|
// GBDeviceEventConfigurationRead configReadEvent = new GBDeviceEventConfigurationRead();
|
||||||
configReadEvent.config = property.getKey();
|
// configReadEvent.config = property.getKey();
|
||||||
configReadEvent.event = GBDeviceEventConfigurationRead.Event.SUCCESS;
|
// configReadEvent.event = GBDeviceEventConfigurationRead.Event.SUCCESS;
|
||||||
evaluateGBDeviceEvent(configReadEvent);
|
// evaluateGBDeviceEvent(configReadEvent);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1555,13 +1463,14 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
try {
|
try {
|
||||||
new QuerySettingsOperation(this).perform();
|
new QuerySettingsOperation(this).perform();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
LOG.debug("Error while testing new function: ", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSendWeather(WeatherSpec weatherSpec) {
|
public void onSendWeather(ArrayList<WeatherSpec> weatherSpecs) {
|
||||||
try {
|
try {
|
||||||
|
WeatherSpec weatherSpec = weatherSpecs.get(0);
|
||||||
TransactionBuilder builder = performInitialized("onSendWeather");
|
TransactionBuilder builder = performInitialized("onSendWeather");
|
||||||
|
|
||||||
MoyoungWeatherToday weatherToday = new MoyoungWeatherToday(weatherSpec);
|
MoyoungWeatherToday weatherToday = new MoyoungWeatherToday(weatherSpec);
|
||||||
@ -1594,14 +1503,4 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSetFmFrequency(float frequency) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSetLedColor(int color) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -27,13 +27,12 @@ import org.slf4j.LoggerFactory;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.AbstractMoyoungDeviceCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungConstants;
|
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungConstants;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungDeviceCoordinator;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSetting;
|
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSetting;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEOperation;
|
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEOperation;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.operations.OperationStatus;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.operations.OperationStatus;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
|
||||||
|
|
||||||
public class QuerySettingsOperation extends AbstractBTLEOperation<MoyoungDeviceSupport> {
|
public class QuerySettingsOperation extends AbstractBTLEOperation<MoyoungDeviceSupport> {
|
||||||
|
|
||||||
@ -51,7 +50,7 @@ public class QuerySettingsOperation extends AbstractBTLEOperation<MoyoungDeviceS
|
|||||||
|
|
||||||
public QuerySettingsOperation(MoyoungDeviceSupport support) {
|
public QuerySettingsOperation(MoyoungDeviceSupport support) {
|
||||||
super(support);
|
super(support);
|
||||||
MoyoungDeviceCoordinator coordinator = (MoyoungDeviceCoordinator) DeviceHelper.getInstance().getCoordinator(getDevice());
|
AbstractMoyoungDeviceCoordinator coordinator = (AbstractMoyoungDeviceCoordinator) getDevice().getDeviceCoordinator();
|
||||||
this.settingsToQuery = coordinator.getSupportedSettings();
|
this.settingsToQuery = coordinator.getSupportedSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,9 +189,9 @@ public class TrainingFinishedDataOperation extends AbstractBTLEOperation<Moyoung
|
|||||||
sample.setCaloriesBurnt(ActivitySample.NOT_MEASURED);
|
sample.setCaloriesBurnt(ActivitySample.NOT_MEASURED);
|
||||||
|
|
||||||
sample.setHeartRate(measurement != 0 ? measurement : ActivitySample.NOT_MEASURED);
|
sample.setHeartRate(measurement != 0 ? measurement : ActivitySample.NOT_MEASURED);
|
||||||
sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
// sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||||
sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
// sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||||
sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
// sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||||
|
|
||||||
provider.addGBActivitySample(sample);
|
provider.addGBActivitySample(sample);
|
||||||
LOG.info("Adding a training sample: " + sample.toString());
|
LOG.info("Adding a training sample: " + sample.toString());
|
||||||
@ -229,7 +229,7 @@ public class TrainingFinishedDataOperation extends AbstractBTLEOperation<Moyoung
|
|||||||
operationStatus = OperationStatus.FINISHED;
|
operationStatus = OperationStatus.FINISHED;
|
||||||
if (getDevice() != null && getDevice().isConnected()) {
|
if (getDevice() != null && getDevice().isConnected()) {
|
||||||
unsetBusy();
|
unsetBusy();
|
||||||
GB.signalActivityDataFinish();
|
GB.signalActivityDataFinish(getDevice());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,6 +119,8 @@ public class ArrayUtils {
|
|||||||
if (array[i] == value) return i;
|
if (array[i] == value) return i;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a byte array contains all zeros
|
* Check if a byte array contains all zeros
|
||||||
* @param array The array to check
|
* @param array The array to check
|
||||||
|
@ -1896,6 +1896,7 @@
|
|||||||
<string name="devicetype_colmi_r03">Colmi R03</string>
|
<string name="devicetype_colmi_r03">Colmi R03</string>
|
||||||
<string name="devicetype_colmi_r06">Colmi R06</string>
|
<string name="devicetype_colmi_r06">Colmi R06</string>
|
||||||
<string name="devicetype_colmi_r10">Colmi R10</string>
|
<string name="devicetype_colmi_r10">Colmi R10</string>
|
||||||
|
<string name="devicetype_colmi_i28_ultra">Colmi i28 Ultra</string>
|
||||||
<string name="devicetype_bandw_pseries">Bowers and Wilkins P series</string>
|
<string name="devicetype_bandw_pseries">Bowers and Wilkins P series</string>
|
||||||
<string name="choose_auto_export_location">Choose export location</string>
|
<string name="choose_auto_export_location">Choose export location</string>
|
||||||
<string name="notification_channel_name">General</string>
|
<string name="notification_channel_name">General</string>
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
android:entryValues="@array/do_not_disturb_no_auto_values"
|
android:entryValues="@array/do_not_disturb_no_auto_values"
|
||||||
android:key="do_not_disturb"
|
android:key="do_not_disturb"
|
||||||
android:summary="%s"
|
android:summary="%s"
|
||||||
app:dependentValue="@string/p_scheduled"
|
|
||||||
android:title="@string/mi2_prefs_do_not_disturb" />
|
android:title="@string/mi2_prefs_do_not_disturb" />
|
||||||
|
|
||||||
<nodomain.freeyourgadget.gadgetbridge.util.XTimePreference
|
<nodomain.freeyourgadget.gadgetbridge.util.XTimePreference
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
android:entryValues="@array/sedentary_reminder_values"
|
android:entryValues="@array/sedentary_reminder_values"
|
||||||
android:key="sedentary_reminder"
|
android:key="sedentary_reminder"
|
||||||
android:summary="%s"
|
android:summary="%s"
|
||||||
app:dependentValue="@string/p_on"
|
|
||||||
android:title="@string/pref_sedentary_reminder" />
|
android:title="@string/pref_sedentary_reminder" />
|
||||||
|
|
||||||
<androidx.preference.EditTextPreference
|
<androidx.preference.EditTextPreference
|
||||||
|
Loading…
Reference in New Issue
Block a user