mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-02 15:02:56 +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");
|
||||
activitySample.implementsSerializable();
|
||||
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("dataSource").notNull();
|
||||
activitySample.addIntProperty("caloriesBurnt").notNull();
|
||||
activitySample.addIntProperty("distanceMeters").notNull();
|
||||
addHeartRateProperties(activitySample);
|
||||
addBloodPressureProperies(activitySample);
|
||||
addBloodOxidationProperies(activitySample);
|
||||
// addHeartRateProperties(activitySample);
|
||||
// addBloodPressureProperies(activitySample);
|
||||
// addBloodOxidationProperies(activitySample);
|
||||
activitySample.addIntProperty("batteryLevel").notNull();
|
||||
return activitySample;
|
||||
}
|
||||
|
@ -17,15 +17,11 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.moyoung;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.bluetooth.le.ScanFilter;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.ParcelUuid;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@ -33,7 +29,6 @@ import java.util.Collections;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractDeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungEnumDeviceVersion;
|
||||
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.Device;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
||||
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 {
|
||||
|
||||
@Override
|
||||
public DeviceType getDeviceType() {
|
||||
return DeviceType.DAFIT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getManufacturer() {
|
||||
return "Media-Tech";
|
||||
}
|
||||
public abstract class AbstractMoyoungDeviceCoordinator extends AbstractDeviceCoordinator {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
@ -77,12 +62,8 @@ public class MoyoungDeviceCoordinator extends AbstractDeviceCoordinator {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
|
||||
// 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
|
||||
if (candidate.supportsService(MoyoungConstants.UUID_SERVICE_MOYOUNG)) {
|
||||
return DeviceType.DAFIT;
|
||||
}
|
||||
return DeviceType.UNKNOWN;
|
||||
public Class<? extends DeviceSupport> getDeviceSupportClass() {
|
||||
return MoyoungDeviceSupport.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -90,15 +71,9 @@ public class MoyoungDeviceCoordinator extends AbstractDeviceCoordinator {
|
||||
return BONDING_STYLE_NONE;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Class<? extends Activity> getPairingActivity() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deleteDevice(@NonNull GBDevice gbDevice, @NonNull Device device, @NonNull DaoSession session) throws GBException {
|
||||
|
||||
// TODO: remove device specific data
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -117,43 +92,18 @@ public class MoyoungDeviceCoordinator extends AbstractDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstallHandler findInstallHandler(Uri uri, Context context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsScreenshots() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
public int getAlarmSlotCount(GBDevice device) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsSmartWakeup(GBDevice device) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsHeartRateMeasurement(GBDevice device) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsAppsManagement() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Activity> getAppsManagementActivity() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsCalendarEvents() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -178,28 +128,9 @@ public class MoyoungDeviceCoordinator extends AbstractDeviceCoordinator {
|
||||
|
||||
@Override
|
||||
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[] {
|
||||
new MoyoungSettingUserInfo("USER_INFO", MoyoungConstants.CMD_SET_USER_INFO),
|
||||
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
|
||||
public int normalizeType(int rawType) {
|
||||
public ActivityKind normalizeType(int rawType) {
|
||||
if (rawType == ACTIVITY_NOT_MEASURED)
|
||||
return ActivityKind.TYPE_NOT_MEASURED;
|
||||
return ActivityKind.NOT_MEASURED;
|
||||
else if (rawType == ACTIVITY_SLEEP_LIGHT)
|
||||
return ActivityKind.TYPE_LIGHT_SLEEP;
|
||||
return ActivityKind.LIGHT_SLEEP;
|
||||
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)
|
||||
return ActivityKind.TYPE_NOT_MEASURED;
|
||||
return ActivityKind.NOT_MEASURED;
|
||||
else if (rawType == ACTIVITY_TRAINING_WALK)
|
||||
return ActivityKind.TYPE_WALKING;
|
||||
return ActivityKind.WALKING;
|
||||
else if (rawType == ACTIVITY_TRAINING_RUN)
|
||||
return ActivityKind.TYPE_RUNNING;
|
||||
return ActivityKind.RUNNING;
|
||||
else if (rawType == ACTIVITY_TRAINING_BIKING)
|
||||
return ActivityKind.TYPE_CYCLING;
|
||||
return ActivityKind.CYCLING;
|
||||
else if (rawType == ACTIVITY_TRAINING_SWIM)
|
||||
return ActivityKind.TYPE_SWIMMING;
|
||||
return ActivityKind.SWIMMING;
|
||||
else if (rawType == ACTIVITY_TRAINING_ROPE || rawType == ACTIVITY_TRAINING_BADMINTON ||
|
||||
rawType == ACTIVITY_TRAINING_BASKETBALL || rawType == ACTIVITY_TRAINING_FOOTBALL ||
|
||||
rawType == ACTIVITY_TRAINING_MOUNTAINEERING || rawType == ACTIVITY_TRAINING_TENNIS ||
|
||||
rawType == ACTIVITY_TRAINING_RUGBY || rawType == ACTIVITY_TRAINING_GOLF)
|
||||
return ActivityKind.TYPE_EXERCISE;
|
||||
return ActivityKind.EXERCISE;
|
||||
else
|
||||
return ActivityKind.TYPE_ACTIVITY;
|
||||
return ActivityKind.ACTIVITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int toRawActivityKind(int activityKind) {
|
||||
if (activityKind == ActivityKind.TYPE_NOT_MEASURED)
|
||||
public int toRawActivityKind(ActivityKind activityKind) {
|
||||
if (activityKind == ActivityKind.NOT_MEASURED)
|
||||
return ACTIVITY_NOT_MEASURED;
|
||||
else if (activityKind == ActivityKind.TYPE_LIGHT_SLEEP)
|
||||
else if (activityKind == ActivityKind.LIGHT_SLEEP)
|
||||
return ACTIVITY_SLEEP_LIGHT;
|
||||
else if (activityKind == ActivityKind.TYPE_DEEP_SLEEP)
|
||||
else if (activityKind == ActivityKind.DEEP_SLEEP)
|
||||
return ACTIVITY_SLEEP_RESTFUL;
|
||||
else if (activityKind == ActivityKind.TYPE_ACTIVITY)
|
||||
else if (activityKind == ActivityKind.ACTIVITY)
|
||||
return ACTIVITY_NOT_MEASURED; // TODO: ?
|
||||
else
|
||||
throw new IllegalArgumentException("Invalid Gadgetbridge activity kind: " + activityKind);
|
||||
|
@ -29,7 +29,7 @@ public class MoyoungWeatherForecast {
|
||||
this.maxTemp = maxTemp;
|
||||
}
|
||||
|
||||
public MoyoungWeatherForecast(WeatherSpec.Forecast forecast)
|
||||
public MoyoungWeatherForecast(WeatherSpec.Daily forecast)
|
||||
{
|
||||
conditionId = MoyoungConstants.openWeatherConditionToMoyoungConditionId(forecast.conditionCode);
|
||||
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.MiCompositionScaleCoordinator;
|
||||
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.nothing.CmfBudsPro2Coordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.nothing.Ear1Coordinator;
|
||||
@ -558,6 +559,7 @@ public enum DeviceType {
|
||||
COLMI_R03(ColmiR03Coordinator.class),
|
||||
COLMI_R06(ColmiR06Coordinator.class),
|
||||
COLMI_R10(ColmiR10Coordinator.class),
|
||||
COLMI_I28_ULTRA(ColmiI28UltraCoordinator.class),
|
||||
B_AND_W_P_SERIES(BandWPSeriesDeviceCoordinator.class),
|
||||
SCANNABLE(ScannableDeviceCoordinator.class),
|
||||
CYCLING_SENSOR(CyclingSensorCoordinator.class),
|
||||
|
@ -205,7 +205,7 @@ public class FetchDataOperation extends AbstractBTLEOperation<MoyoungDeviceSuppo
|
||||
operationStatus = OperationStatus.FINISHED;
|
||||
if (getDevice() != null && getDevice().isConnected()) {
|
||||
unsetBusy();
|
||||
GB.signalActivityDataFinish();
|
||||
GB.signalActivityDataFinish(getDevice());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ import android.bluetooth.BluetoothGatt;
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
@ -42,7 +41,6 @@ import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
@ -57,25 +55,20 @@ import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventConfigurationRead;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
|
||||
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.MoyoungSampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungWeatherForecast;
|
||||
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.MoyoungEnumLanguage;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungEnumMetricSystem;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungEnumTimeSystem;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSetting;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingEnum;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingLanguage;
|
||||
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.BaseActivitySummaryDao;
|
||||
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.ActivityUser;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
|
||||
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.RecordedDataTypes;
|
||||
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.util.AlarmUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.ArrayUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.NotificationUtils;
|
||||
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("GOAL_STEP"), new ActivityUser().getStepsGoal());
|
||||
batteryInfoProfile.requestBatteryInfo(builder);
|
||||
batteryInfoProfile.enableNotify(builder);
|
||||
heartRateProfile.enableNotify(builder);
|
||||
batteryInfoProfile.enableNotify(builder, true);
|
||||
heartRateProfile.enableNotify(builder, true);
|
||||
builder.notify(getCharacteristic(MoyoungConstants.UUID_CHARACTERISTIC_STEPS), true);
|
||||
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZED, getContext()));
|
||||
|
||||
@ -261,9 +249,9 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
sample.setCaloriesBurnt(ActivitySample.NOT_MEASURED);
|
||||
|
||||
sample.setHeartRate(heartRate);
|
||||
sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||
sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||
sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||
// sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||
// sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||
// sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||
|
||||
addGBActivitySample(sample);
|
||||
broadcastSample(sample);
|
||||
@ -290,9 +278,9 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
sample.setCaloriesBurnt(ActivitySample.NOT_MEASURED);
|
||||
|
||||
sample.setHeartRate(ActivitySample.NOT_MEASURED);
|
||||
sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||
sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||
sample.setBloodOxidation(percent);
|
||||
// sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||
// sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||
// sample.setBloodOxidation(percent);
|
||||
|
||||
addGBActivitySample(sample);
|
||||
broadcastSample(sample);
|
||||
@ -319,9 +307,9 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
sample.setCaloriesBurnt(ActivitySample.NOT_MEASURED);
|
||||
|
||||
sample.setHeartRate(ActivitySample.NOT_MEASURED);
|
||||
sample.setBloodPressureSystolic(data1);
|
||||
sample.setBloodPressureDiastolic(data2);
|
||||
sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||
// sample.setBloodPressureSystolic(data1);
|
||||
// sample.setBloodPressureDiastolic(data2);
|
||||
// sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||
|
||||
addGBActivitySample(sample);
|
||||
broadcastSample(sample);
|
||||
@ -462,9 +450,9 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
sample.setCaloriesBurnt(ActivitySample.NOT_MEASURED);
|
||||
|
||||
sample.setHeartRate(ActivitySample.NOT_MEASURED);
|
||||
sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||
sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||
sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||
// sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||
// sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||
// sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||
|
||||
addGBActivitySample(sample);
|
||||
broadcastSample(sample);
|
||||
@ -504,11 +492,6 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
sendNotification(MoyoungConstants.notificationType(notificationSpec.type), sender + ":" + text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteNotification(int id) {
|
||||
// not supported :(
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetCallState(CallSpec callSpec) {
|
||||
if (callSpec.command == CallSpec.CALL_INCOMING)
|
||||
@ -517,11 +500,6 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
sendNotification(MoyoungConstants.NOTIFICATION_TYPE_CALL_OFF_HOOK, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetCannedMessages(CannedMessagesSpec cannedMessagesSpec) {
|
||||
// not supported :(
|
||||
}
|
||||
|
||||
private void setTime(TransactionBuilder builder) {
|
||||
ByteBuffer buffer = ByteBuffer.allocate(5);
|
||||
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
|
||||
public void onFetchRecordedData(int dataTypes) {
|
||||
if ((dataTypes & RecordedDataTypes.TYPE_ACTIVITY) != 0)
|
||||
@ -734,9 +672,9 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
sample.setCaloriesBurnt(0);
|
||||
|
||||
sample.setHeartRate(ActivitySample.NOT_MEASURED);
|
||||
sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||
sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||
sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||
// sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||
// sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||
// sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||
|
||||
provider.addGBActivitySample(sample);
|
||||
broadcastSample(sample);
|
||||
@ -831,9 +769,9 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
sample.setCaloriesBurnt(newCalories);
|
||||
|
||||
sample.setHeartRate(ActivitySample.NOT_MEASURED);
|
||||
sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||
sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||
sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||
// sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||
// sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||
// sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||
|
||||
provider.addGBActivitySample(sample);
|
||||
if (isRealtime)
|
||||
@ -936,9 +874,9 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
prevSegmentSample.setCaloriesBurnt(ActivitySample.NOT_MEASURED);
|
||||
|
||||
prevSegmentSample.setHeartRate(ActivitySample.NOT_MEASURED);
|
||||
prevSegmentSample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||
prevSegmentSample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||
prevSegmentSample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||
// prevSegmentSample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||
// prevSegmentSample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||
// prevSegmentSample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||
|
||||
addGBActivitySampleIfNotExists(provider, prevSegmentSample);
|
||||
|
||||
@ -958,9 +896,9 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
nextSegmentSample.setCaloriesBurnt(ActivitySample.NOT_MEASURED);
|
||||
|
||||
nextSegmentSample.setHeartRate(ActivitySample.NOT_MEASURED);
|
||||
nextSegmentSample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||
nextSegmentSample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||
nextSegmentSample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||
// nextSegmentSample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||
// nextSegmentSample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||
// nextSegmentSample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||
|
||||
addGBActivitySampleIfNotExists(provider, nextSegmentSample);
|
||||
|
||||
@ -1031,7 +969,7 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
summary.setDevice(device);
|
||||
summary.setUser(user);
|
||||
|
||||
int gbType = provider.normalizeType(type);
|
||||
ActivityKind gbType = provider.normalizeType(type);
|
||||
String name;
|
||||
if (type == MoyoungSampleProvider.ACTIVITY_TRAINING_ROPE)
|
||||
name = "Rope";
|
||||
@ -1050,9 +988,9 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
else if (type == MoyoungSampleProvider.ACTIVITY_TRAINING_GOLF)
|
||||
name = "Golf";
|
||||
else
|
||||
name = ActivityKind.asString(gbType, getContext());
|
||||
name = gbType.name();
|
||||
summary.setName(name);
|
||||
summary.setActivityKind(gbType);
|
||||
summary.setActivityKind(gbType.getCode());
|
||||
|
||||
summary.setStartTime(startTime);
|
||||
summary.setEndTime(endTime);
|
||||
@ -1138,16 +1076,6 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
onAbortHeartRateTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetHeartRateMeasurementInterval(int seconds) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnableHeartRateSleepSupport(boolean enable) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFindDevice(boolean start) {
|
||||
if (start)
|
||||
@ -1157,7 +1085,7 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_FIND_MY_WATCH, new byte[0]));
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
LOG.error("Error while finding device: ", e);
|
||||
}
|
||||
}
|
||||
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")
|
||||
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())
|
||||
{
|
||||
if (setting.name.equals(id))
|
||||
@ -1274,19 +1182,19 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
sendSetting(getSetting("TIME_SYSTEM"), timeSystem);
|
||||
break;
|
||||
|
||||
case DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM:
|
||||
String metricSystemPref = prefs.getString(DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM, getContext().getString(R.string.p_unit_metric));
|
||||
|
||||
MoyoungEnumMetricSystem metricSystem;
|
||||
if (metricSystemPref.equals(getContext().getString(R.string.p_unit_metric)))
|
||||
metricSystem = MoyoungEnumMetricSystem.METRIC_SYSTEM;
|
||||
else if (metricSystemPref.equals(getContext().getString(R.string.p_unit_imperial)))
|
||||
metricSystem = MoyoungEnumMetricSystem.IMPERIAL_SYSTEM;
|
||||
else
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
sendSetting(getSetting("METRIC_SYSTEM"), metricSystem);
|
||||
break;
|
||||
// case DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM:
|
||||
// String metricSystemPref = prefs.getString(DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM, getContext().getString(R.string.p_unit_metric));
|
||||
//
|
||||
// MoyoungEnumMetricSystem metricSystem;
|
||||
// if (metricSystemPref.equals(getContext().getString(R.string.p_unit_metric)))
|
||||
// metricSystem = MoyoungEnumMetricSystem.METRIC_SYSTEM;
|
||||
// else if (metricSystemPref.equals(getContext().getString(R.string.p_unit_imperial)))
|
||||
// metricSystem = MoyoungEnumMetricSystem.IMPERIAL_SYSTEM;
|
||||
// else
|
||||
// throw new IllegalArgumentException();
|
||||
//
|
||||
// sendSetting(getSetting("METRIC_SYSTEM"), metricSystem);
|
||||
// break;
|
||||
|
||||
case MoyoungConstants.PREF_WATCH_FACE:
|
||||
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));
|
||||
break;
|
||||
|
||||
case MiBandConst.PREF_DO_NOT_DISTURB:
|
||||
case MiBandConst.PREF_DO_NOT_DISTURB_START:
|
||||
case MiBandConst.PREF_DO_NOT_DISTURB_END:
|
||||
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);
|
||||
// case MiBandConst.PREF_DO_NOT_DISTURB:
|
||||
// case MiBandConst.PREF_DO_NOT_DISTURB_START:
|
||||
// case MiBandConst.PREF_DO_NOT_DISTURB_END:
|
||||
// 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);
|
||||
//
|
||||
// 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");
|
||||
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;
|
||||
|
||||
case HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT:
|
||||
case HuamiConst.PREF_DISPLAY_ON_LIFT_START:
|
||||
case HuamiConst.PREF_DISPLAY_ON_LIFT_END:
|
||||
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));
|
||||
boolean quickViewScheduled = quickViewPref.equals(getContext().getString(R.string.p_scheduled));
|
||||
|
||||
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 HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT:
|
||||
// case HuamiConst.PREF_DISPLAY_ON_LIFT_START:
|
||||
// case HuamiConst.PREF_DISPLAY_ON_LIFT_END:
|
||||
// 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));
|
||||
// boolean quickViewScheduled = quickViewPref.equals(getContext().getString(R.string.p_scheduled));
|
||||
//
|
||||
// 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:
|
||||
String sedentaryReminderPref = prefs.getString(MoyoungConstants.PREF_SEDENTARY_REMINDER, "off");
|
||||
@ -1397,9 +1305,9 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
querySetting(getSetting("TIME_SYSTEM"));
|
||||
break;
|
||||
|
||||
case DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM:
|
||||
querySetting(getSetting("METRIC_SYSTEM"));
|
||||
break;
|
||||
// case DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM:
|
||||
// querySetting(getSetting("METRIC_SYSTEM"));
|
||||
// break;
|
||||
|
||||
case MoyoungConstants.PREF_WATCH_FACE:
|
||||
querySetting(getSetting("DISPLAY_WATCH_FACE"));
|
||||
@ -1413,18 +1321,18 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
querySetting(getSetting("DEVICE_VERSION"));
|
||||
break;
|
||||
|
||||
case MiBandConst.PREF_DO_NOT_DISTURB:
|
||||
case MiBandConst.PREF_DO_NOT_DISTURB_START:
|
||||
case MiBandConst.PREF_DO_NOT_DISTURB_END:
|
||||
querySetting(getSetting("DO_NOT_DISTURB_TIME"));
|
||||
break;
|
||||
// case MiBandConst.PREF_DO_NOT_DISTURB:
|
||||
// case MiBandConst.PREF_DO_NOT_DISTURB_START:
|
||||
// case MiBandConst.PREF_DO_NOT_DISTURB_END:
|
||||
// querySetting(getSetting("DO_NOT_DISTURB_TIME"));
|
||||
// break;
|
||||
|
||||
case HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT:
|
||||
case HuamiConst.PREF_DISPLAY_ON_LIFT_START:
|
||||
case HuamiConst.PREF_DISPLAY_ON_LIFT_END:
|
||||
querySetting(getSetting("QUICK_VIEW"));
|
||||
querySetting(getSetting("QUICK_VIEW_TIME"));
|
||||
break;
|
||||
// case HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT:
|
||||
// case HuamiConst.PREF_DISPLAY_ON_LIFT_START:
|
||||
// case HuamiConst.PREF_DISPLAY_ON_LIFT_END:
|
||||
// querySetting(getSetting("QUICK_VIEW"));
|
||||
// querySetting(getSetting("QUICK_VIEW_TIME"));
|
||||
// break;
|
||||
|
||||
case MoyoungConstants.PREF_SEDENTARY_REMINDER:
|
||||
querySetting(getSetting("SEDENTARY_REMINDER"));
|
||||
@ -1440,10 +1348,10 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
return;
|
||||
}
|
||||
|
||||
GBDeviceEventConfigurationRead configReadEvent = new GBDeviceEventConfigurationRead();
|
||||
configReadEvent.config = config;
|
||||
configReadEvent.event = GBDeviceEventConfigurationRead.Event.IN_PROGRESS;
|
||||
evaluateGBDeviceEvent(configReadEvent);
|
||||
// GBDeviceEventConfigurationRead configReadEvent = new GBDeviceEventConfigurationRead();
|
||||
// configReadEvent.config = config;
|
||||
// configReadEvent.event = GBDeviceEventConfigurationRead.Event.IN_PROGRESS;
|
||||
// evaluateGBDeviceEvent(configReadEvent);
|
||||
}
|
||||
|
||||
public void onReadConfigurationDone(MoyoungSetting setting, Object value, byte[] data)
|
||||
@ -1463,15 +1371,15 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
throw new IllegalArgumentException("Invalid value");
|
||||
break;
|
||||
|
||||
case "METRIC_SYSTEM":
|
||||
MoyoungEnumMetricSystem metricSystem = (MoyoungEnumMetricSystem) value;
|
||||
if (metricSystem == MoyoungEnumMetricSystem.METRIC_SYSTEM)
|
||||
changedProperties.put(DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM, getContext().getString(R.string.p_unit_metric));
|
||||
else if (metricSystem == MoyoungEnumMetricSystem.IMPERIAL_SYSTEM)
|
||||
changedProperties.put(DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM, getContext().getString(R.string.p_unit_imperial));
|
||||
else
|
||||
throw new IllegalArgumentException("Invalid value");
|
||||
break;
|
||||
// case "METRIC_SYSTEM":
|
||||
// MoyoungEnumMetricSystem metricSystem = (MoyoungEnumMetricSystem) value;
|
||||
// if (metricSystem == MoyoungEnumMetricSystem.METRIC_SYSTEM)
|
||||
// changedProperties.put(DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM, getContext().getString(R.string.p_unit_metric));
|
||||
// else if (metricSystem == MoyoungEnumMetricSystem.IMPERIAL_SYSTEM)
|
||||
// changedProperties.put(DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM, getContext().getString(R.string.p_unit_imperial));
|
||||
// else
|
||||
// throw new IllegalArgumentException("Invalid value");
|
||||
// break;
|
||||
|
||||
case "DISPLAY_WATCH_FACE":
|
||||
byte watchFace = (Byte) value;
|
||||
@ -1493,37 +1401,37 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
changedProperties.put(MoyoungConstants.PREF_DEVICE_VERSION, String.valueOf(deviceVersion.value()));
|
||||
break;
|
||||
|
||||
case "DO_NOT_DISTURB_TIME":
|
||||
MoyoungSettingTimeRange.TimeRange doNotDisturb = (MoyoungSettingTimeRange.TimeRange) value;
|
||||
if (doNotDisturb.start_h == 0 && doNotDisturb.start_m == 0 &&
|
||||
doNotDisturb.end_h == 0 && doNotDisturb.end_m == 0)
|
||||
changedProperties.put(MiBandConst.PREF_DO_NOT_DISTURB, MiBandConst.PREF_DO_NOT_DISTURB_OFF);
|
||||
else
|
||||
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_END, String.format(Locale.ROOT, "%02d:%02d", doNotDisturb.end_h, doNotDisturb.end_m));
|
||||
break;
|
||||
// case "DO_NOT_DISTURB_TIME":
|
||||
// MoyoungSettingTimeRange.TimeRange doNotDisturb = (MoyoungSettingTimeRange.TimeRange) value;
|
||||
// if (doNotDisturb.start_h == 0 && doNotDisturb.start_m == 0 &&
|
||||
// doNotDisturb.end_h == 0 && doNotDisturb.end_m == 0)
|
||||
// changedProperties.put(MiBandConst.PREF_DO_NOT_DISTURB, MiBandConst.PREF_DO_NOT_DISTURB_OFF);
|
||||
// else
|
||||
// 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_END, String.format(Locale.ROOT, "%02d:%02d", doNotDisturb.end_h, doNotDisturb.end_m));
|
||||
// break;
|
||||
|
||||
case "QUICK_VIEW":
|
||||
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));
|
||||
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;
|
||||
// case "QUICK_VIEW":
|
||||
// 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));
|
||||
// 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;
|
||||
|
||||
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));
|
||||
MoyoungSettingTimeRange.TimeRange quickViewTime = (MoyoungSettingTimeRange.TimeRange) value;
|
||||
if (quickViewEnabled2)
|
||||
{
|
||||
if (quickViewTime.start_h == 0 && quickViewTime.start_m == 0 &&
|
||||
quickViewTime.end_h == 0 && quickViewTime.end_m == 0)
|
||||
changedProperties.put(HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT, getContext().getString(R.string.p_on));
|
||||
else
|
||||
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_END, String.format(Locale.ROOT, "%02d:%02d", quickViewTime.end_h, quickViewTime.end_m));
|
||||
break;
|
||||
// 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));
|
||||
// MoyoungSettingTimeRange.TimeRange quickViewTime = (MoyoungSettingTimeRange.TimeRange) value;
|
||||
// if (quickViewEnabled2)
|
||||
// {
|
||||
// if (quickViewTime.start_h == 0 && quickViewTime.start_m == 0 &&
|
||||
// quickViewTime.end_h == 0 && quickViewTime.end_m == 0)
|
||||
// changedProperties.put(HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT, getContext().getString(R.string.p_on));
|
||||
// else
|
||||
// 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_END, String.format(Locale.ROOT, "%02d:%02d", quickViewTime.end_h, quickViewTime.end_m));
|
||||
// break;
|
||||
|
||||
case "SEDENTARY_REMINDER":
|
||||
boolean sedentaryReminderEnabled = (Boolean) value;
|
||||
@ -1541,13 +1449,13 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
for (Map.Entry<String, String> property : changedProperties.entrySet())
|
||||
prefsEditor.putString(property.getKey(), property.getValue());
|
||||
prefsEditor.apply();
|
||||
for (Map.Entry<String, String> property : changedProperties.entrySet())
|
||||
{
|
||||
GBDeviceEventConfigurationRead configReadEvent = new GBDeviceEventConfigurationRead();
|
||||
configReadEvent.config = property.getKey();
|
||||
configReadEvent.event = GBDeviceEventConfigurationRead.Event.SUCCESS;
|
||||
evaluateGBDeviceEvent(configReadEvent);
|
||||
}
|
||||
// for (Map.Entry<String, String> property : changedProperties.entrySet())
|
||||
// {
|
||||
// GBDeviceEventConfigurationRead configReadEvent = new GBDeviceEventConfigurationRead();
|
||||
// configReadEvent.config = property.getKey();
|
||||
// configReadEvent.event = GBDeviceEventConfigurationRead.Event.SUCCESS;
|
||||
// evaluateGBDeviceEvent(configReadEvent);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1555,13 +1463,14 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
try {
|
||||
new QuerySettingsOperation(this).perform();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
LOG.debug("Error while testing new function: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSendWeather(WeatherSpec weatherSpec) {
|
||||
public void onSendWeather(ArrayList<WeatherSpec> weatherSpecs) {
|
||||
try {
|
||||
WeatherSpec weatherSpec = weatherSpecs.get(0);
|
||||
TransactionBuilder builder = performInitialized("onSendWeather");
|
||||
|
||||
MoyoungWeatherToday weatherToday = new MoyoungWeatherToday(weatherSpec);
|
||||
@ -1594,14 +1503,4 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
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.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.AbstractMoyoungDeviceCoordinator;
|
||||
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.service.btle.AbstractBTLEOperation;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.operations.OperationStatus;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
||||
|
||||
public class QuerySettingsOperation extends AbstractBTLEOperation<MoyoungDeviceSupport> {
|
||||
|
||||
@ -51,7 +50,7 @@ public class QuerySettingsOperation extends AbstractBTLEOperation<MoyoungDeviceS
|
||||
|
||||
public QuerySettingsOperation(MoyoungDeviceSupport support) {
|
||||
super(support);
|
||||
MoyoungDeviceCoordinator coordinator = (MoyoungDeviceCoordinator) DeviceHelper.getInstance().getCoordinator(getDevice());
|
||||
AbstractMoyoungDeviceCoordinator coordinator = (AbstractMoyoungDeviceCoordinator) getDevice().getDeviceCoordinator();
|
||||
this.settingsToQuery = coordinator.getSupportedSettings();
|
||||
}
|
||||
|
||||
|
@ -189,9 +189,9 @@ public class TrainingFinishedDataOperation extends AbstractBTLEOperation<Moyoung
|
||||
sample.setCaloriesBurnt(ActivitySample.NOT_MEASURED);
|
||||
|
||||
sample.setHeartRate(measurement != 0 ? measurement : ActivitySample.NOT_MEASURED);
|
||||
sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||
sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||
sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||
// sample.setBloodPressureSystolic(ActivitySample.NOT_MEASURED);
|
||||
// sample.setBloodPressureDiastolic(ActivitySample.NOT_MEASURED);
|
||||
// sample.setBloodOxidation(ActivitySample.NOT_MEASURED);
|
||||
|
||||
provider.addGBActivitySample(sample);
|
||||
LOG.info("Adding a training sample: " + sample.toString());
|
||||
@ -229,7 +229,7 @@ public class TrainingFinishedDataOperation extends AbstractBTLEOperation<Moyoung
|
||||
operationStatus = OperationStatus.FINISHED;
|
||||
if (getDevice() != null && getDevice().isConnected()) {
|
||||
unsetBusy();
|
||||
GB.signalActivityDataFinish();
|
||||
GB.signalActivityDataFinish(getDevice());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -119,6 +119,8 @@ public class ArrayUtils {
|
||||
if (array[i] == value) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a byte array contains all zeros
|
||||
* @param array The array to check
|
||||
|
@ -1896,6 +1896,7 @@
|
||||
<string name="devicetype_colmi_r03">Colmi R03</string>
|
||||
<string name="devicetype_colmi_r06">Colmi R06</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="choose_auto_export_location">Choose export location</string>
|
||||
<string name="notification_channel_name">General</string>
|
||||
|
@ -18,7 +18,6 @@
|
||||
android:entryValues="@array/do_not_disturb_no_auto_values"
|
||||
android:key="do_not_disturb"
|
||||
android:summary="%s"
|
||||
app:dependentValue="@string/p_scheduled"
|
||||
android:title="@string/mi2_prefs_do_not_disturb" />
|
||||
|
||||
<nodomain.freeyourgadget.gadgetbridge.util.XTimePreference
|
||||
|
@ -16,7 +16,6 @@
|
||||
android:entryValues="@array/sedentary_reminder_values"
|
||||
android:key="sedentary_reminder"
|
||||
android:summary="%s"
|
||||
app:dependentValue="@string/p_on"
|
||||
android:title="@string/pref_sedentary_reminder" />
|
||||
|
||||
<androidx.preference.EditTextPreference
|
||||
|
Loading…
Reference in New Issue
Block a user