mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Garmin: remove the legacy vivomovehr package
Migrate the GarminCapability class to main garmin package. Delete the VivomoveHrSampleProvider class which was unused.
This commit is contained in:
+1
-2
@@ -14,7 +14,7 @@
|
||||
|
||||
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.vivomovehr;
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.garmin;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@@ -25,7 +25,6 @@ import java.util.Set;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.GarminPreferences;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.deviceevents.CapabilitiesDeviceEvent;
|
||||
|
||||
public enum GarminCapability {
|
||||
-1
@@ -30,7 +30,6 @@ import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.TimeSampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.Vo2MaxSampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.vivomovehr.GarminCapability;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.BaseActivitySummaryDao;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.GarminActivitySampleDao;
|
||||
|
||||
-1
@@ -35,7 +35,6 @@ import nodomain.freeyourgadget.gadgetbridge.activities.install.FwAppInstallerAct
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.install.InstallActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.vivomovehr.GarminCapability;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.GenericItem;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions;
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.garmin;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.vivomovehr.GarminCapability.COURSE_DOWNLOAD;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.garmin.GarminCapability.COURSE_DOWNLOAD;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
-1
@@ -31,7 +31,6 @@ import nodomain.freeyourgadget.gadgetbridge.activities.install.FwAppInstallerAct
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.install.InstallActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.vivomovehr.GarminCapability;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.GenericItem;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.GarminPrgFile;
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.GarminCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.vivomovehr.GarminCapability;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.GarminCapability;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
||||
|
||||
|
||||
-235
@@ -1,235 +0,0 @@
|
||||
/* Copyright (C) 2023-2024 Petr Kadlec
|
||||
|
||||
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.vivomovehr;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import de.greenrobot.dao.AbstractDao;
|
||||
import de.greenrobot.dao.Property;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractSampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.VivomoveHrActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.VivomoveHrActivitySampleDao;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
|
||||
|
||||
public class VivomoveHrSampleProvider extends AbstractSampleProvider<VivomoveHrActivitySample> {
|
||||
public static final int RAW_TYPE_KIND_MASK = 0x0F000000;
|
||||
public static final int RAW_TYPE_KIND_ACTIVITY = 0x00000000;
|
||||
public static final int RAW_TYPE_KIND_SLEEP = 0x01000000;
|
||||
// public static final int RAW_TYPE_KIND_NOT_WORN = 0x0F000000;
|
||||
public static final int RAW_NOT_WORN = 0x0F000000;
|
||||
|
||||
public VivomoveHrSampleProvider(GBDevice device, DaoSession session) {
|
||||
super(device, session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityKind normalizeType(int rawType) {
|
||||
if (rawType == RAW_NOT_WORN) {
|
||||
return ActivityKind.NOT_WORN;
|
||||
}
|
||||
|
||||
switch (rawType & RAW_TYPE_KIND_MASK) {
|
||||
case RAW_TYPE_KIND_ACTIVITY:
|
||||
return normalizeActivityType(rawType & ~RAW_TYPE_KIND_MASK);
|
||||
case RAW_TYPE_KIND_SLEEP:
|
||||
return normalizeSleepType(rawType & ~RAW_TYPE_KIND_MASK);
|
||||
default:
|
||||
// ???
|
||||
return ActivityKind.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
private static ActivityKind normalizeActivityType(int rawType) {
|
||||
switch (rawType) {
|
||||
case 0:
|
||||
// generic
|
||||
return ActivityKind.ACTIVITY;
|
||||
case 1:
|
||||
// running
|
||||
return ActivityKind.RUNNING;
|
||||
case 2:
|
||||
// cycling
|
||||
return ActivityKind.CYCLING;
|
||||
case 3:
|
||||
// transition
|
||||
return ActivityKind.VIVOMOVE_HR_TRANSITION;
|
||||
case 4:
|
||||
// fitness_equipment
|
||||
return ActivityKind.EXERCISE;
|
||||
case 5:
|
||||
// swimming
|
||||
return ActivityKind.SWIMMING;
|
||||
case 6:
|
||||
// walking
|
||||
return ActivityKind.WALKING;
|
||||
case 8:
|
||||
// sedentary
|
||||
// TODO?
|
||||
return ActivityKind.ACTIVITY;
|
||||
|
||||
default:
|
||||
return ActivityKind.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
private static ActivityKind normalizeSleepType(int rawType) {
|
||||
switch (rawType) {
|
||||
case 0:
|
||||
// deep_sleep
|
||||
return ActivityKind.DEEP_SLEEP;
|
||||
case 1:
|
||||
// light_sleep
|
||||
return ActivityKind.LIGHT_SLEEP;
|
||||
case 2:
|
||||
// awake
|
||||
case 3:
|
||||
// more_awake
|
||||
return ActivityKind.ACTIVITY;
|
||||
default:
|
||||
// ?
|
||||
return ActivityKind.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int toRawActivityKind(ActivityKind activityKind) {
|
||||
switch (activityKind) {
|
||||
case NOT_WORN:
|
||||
return RAW_NOT_WORN;
|
||||
|
||||
case ACTIVITY:
|
||||
// generic
|
||||
//noinspection PointlessBitwiseExpression
|
||||
return RAW_TYPE_KIND_ACTIVITY | 0;
|
||||
case RUNNING:
|
||||
// running
|
||||
return RAW_TYPE_KIND_ACTIVITY | 1;
|
||||
case CYCLING:
|
||||
// cycling
|
||||
return RAW_TYPE_KIND_ACTIVITY | 2;
|
||||
case VIVOMOVE_HR_TRANSITION:
|
||||
return RAW_TYPE_KIND_ACTIVITY | 3;
|
||||
case EXERCISE:
|
||||
// fitness_equipment
|
||||
return RAW_TYPE_KIND_ACTIVITY | 4;
|
||||
case SWIMMING:
|
||||
// swimming
|
||||
return RAW_TYPE_KIND_ACTIVITY | 5;
|
||||
case WALKING:
|
||||
// walking
|
||||
return RAW_TYPE_KIND_ACTIVITY | 6;
|
||||
case LIGHT_SLEEP:
|
||||
return RAW_TYPE_KIND_SLEEP | 1;
|
||||
case DEEP_SLEEP:
|
||||
//noinspection PointlessBitwiseExpression
|
||||
return RAW_TYPE_KIND_SLEEP | 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float normalizeIntensity(int rawIntensity) {
|
||||
return rawIntensity / 255.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VivomoveHrActivitySample createActivitySample() {
|
||||
return new VivomoveHrActivitySample();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractDao<VivomoveHrActivitySample, ?> getSampleDao() {
|
||||
return getSession().getVivomoveHrActivitySampleDao();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected Property getRawKindSampleProperty() {
|
||||
return VivomoveHrActivitySampleDao.Properties.RawKind;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Property getTimestampSampleProperty() {
|
||||
return VivomoveHrActivitySampleDao.Properties.Timestamp;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Property getDeviceIdentifierSampleProperty() {
|
||||
return VivomoveHrActivitySampleDao.Properties.DeviceId;
|
||||
}
|
||||
|
||||
public static String rawKindToString(int rawType) {
|
||||
if (rawType == RAW_NOT_WORN) {
|
||||
return "not worn";
|
||||
}
|
||||
|
||||
switch (rawType & RAW_TYPE_KIND_MASK) {
|
||||
case RAW_TYPE_KIND_ACTIVITY:
|
||||
return activityTypeToString(rawType & ~RAW_TYPE_KIND_MASK);
|
||||
case RAW_TYPE_KIND_SLEEP:
|
||||
return sleepTypeToString(rawType & ~RAW_TYPE_KIND_MASK);
|
||||
default:
|
||||
// ???
|
||||
return "unknown " + rawType;
|
||||
}
|
||||
}
|
||||
|
||||
private static String activityTypeToString(int rawType) {
|
||||
switch (rawType) {
|
||||
case 0:
|
||||
return "generic";
|
||||
case 1:
|
||||
return "running";
|
||||
case 2:
|
||||
return "cycling";
|
||||
case 3:
|
||||
return "transition";
|
||||
case 4:
|
||||
return "fitness equipment";
|
||||
case 5:
|
||||
return "swimming";
|
||||
case 6:
|
||||
return "walking";
|
||||
case 8:
|
||||
return "sedentary";
|
||||
default:
|
||||
return "unknown activity " + rawType;
|
||||
}
|
||||
}
|
||||
|
||||
private static String sleepTypeToString(int rawType) {
|
||||
switch (rawType) {
|
||||
case 0:
|
||||
return "deep sleep";
|
||||
case 1:
|
||||
return "light sleep";
|
||||
case 2:
|
||||
// awake
|
||||
return "awake";
|
||||
case 3:
|
||||
// more_awake
|
||||
return "more awake";
|
||||
default:
|
||||
return "unknown sleep " + rawType;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.vivomovehr.GarminCapability;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.GarminCapability;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.FitLocalMessageBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.GlobalFITMessage;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.fit.RecordData;
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.garmin.GarminFitFileInstallH
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.GarminGpxRouteInstallHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.GarminPreferences;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.GarminPrgFileInstallHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.vivomovehr.GarminCapability;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.GarminCapability;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
||||
import nodomain.freeyourgadget.gadgetbridge.externalevents.gps.GBLocationService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import android.content.Context;
|
||||
import java.util.Set;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.vivomovehr.GarminCapability;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.GarminCapability;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
|
||||
public class CapabilitiesDeviceEvent extends GBDeviceEvent {
|
||||
|
||||
+1
-6
@@ -1,15 +1,10 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.messages;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.GarminPreferences;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.vivomovehr.GarminCapability;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.deviceevents.CapabilitiesDeviceEvent;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.garmin.GarminCapability;
|
||||
|
||||
|
||||
public class ConfigurationMessage extends GFDIMessage {
|
||||
|
||||
Reference in New Issue
Block a user