From 918fa8bedc959a4dfaf7b243bc0faac0c50b4d68 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Mon, 19 Aug 2024 22:12:53 +0200 Subject: [PATCH] Rename DaFit references to Moyoung to reflect the protocol used --- .../gadgetbridge/daogen/GBDaoGenerator.java | 5 +- .../MoyoungConstants.java} | 32 +- .../MoyoungDeviceCoordinator.java} | 92 ++--- .../MoyoungSampleProvider.java} | 54 +-- .../MoyoungWeatherForecast.java} | 10 +- .../MoyoungWeatherToday.java} | 10 +- .../settings/MoyoungEnum.java} | 4 +- .../settings/MoyoungEnumDeviceVersion.java} | 6 +- .../settings/MoyoungEnumDominantHand.java} | 6 +- .../settings/MoyoungEnumLanguage.java} | 6 +- .../settings/MoyoungEnumMetricSystem.java} | 6 +- .../settings/MoyoungEnumTimeSystem.java} | 6 +- .../settings/MoyoungSetting.java} | 6 +- .../settings/MoyoungSettingBool.java} | 6 +- .../settings/MoyoungSettingByte.java} | 6 +- .../settings/MoyoungSettingEnum.java} | 6 +- .../settings/MoyoungSettingInt.java} | 6 +- .../settings/MoyoungSettingLanguage.java} | 22 +- .../MoyoungSettingRemindersToMove.java} | 6 +- .../settings/MoyoungSettingTimeRange.java} | 6 +- .../settings/MoyoungSettingUserInfo.java} | 6 +- .../FetchDataOperation.java | 46 +-- .../MoyoungDeviceSupport.java} | 384 +++++++++--------- .../MoyoungPacket.java} | 4 +- .../MoyoungPacketIn.java} | 13 +- .../MoyoungPacketOut.java} | 10 +- .../QuerySettingsOperation.java | 32 +- .../TrainingFinishedDataOperation.java | 44 +- app/src/main/res/values/arrays.xml | 8 +- app/src/main/res/values/strings.xml | 1 - ...devicesettings_moyoung_device_version.xml} | 6 +- ...ml => devicesettings_moyoung_language.xml} | 2 +- ...cesettings_moyoung_sedentary_reminder.xml} | 0 ...l => devicesettings_moyoung_watchface.xml} | 6 +- 34 files changed, 431 insertions(+), 432 deletions(-) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/{dafit/DaFitConstants.java => moyoung/MoyoungConstants.java} (95%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/{dafit/DaFitDeviceCoordinator.java => moyoung/MoyoungDeviceCoordinator.java} (51%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/{dafit/DaFitSampleProvider.java => moyoung/MoyoungSampleProvider.java} (77%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/{dafit/DaFitWeatherForecast.java => moyoung/MoyoungWeatherForecast.java} (76%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/{dafit/DaFitWeatherToday.java => moyoung/MoyoungWeatherToday.java} (81%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/{dafit/settings/DaFitEnum.java => moyoung/settings/MoyoungEnum.java} (88%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/{dafit/settings/DaFitEnumDeviceVersion.java => moyoung/settings/MoyoungEnumDeviceVersion.java} (84%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/{dafit/settings/DaFitEnumDominantHand.java => moyoung/settings/MoyoungEnumDominantHand.java} (84%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/{dafit/settings/DaFitEnumLanguage.java => moyoung/settings/MoyoungEnumLanguage.java} (91%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/{dafit/settings/DaFitEnumMetricSystem.java => moyoung/settings/MoyoungEnumMetricSystem.java} (84%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/{dafit/settings/DaFitEnumTimeSystem.java => moyoung/settings/MoyoungEnumTimeSystem.java} (84%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/{dafit/settings/DaFitSetting.java => moyoung/settings/MoyoungSetting.java} (84%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/{dafit/settings/DaFitSettingBool.java => moyoung/settings/MoyoungSettingBool.java} (85%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/{dafit/settings/DaFitSettingByte.java => moyoung/settings/MoyoungSettingByte.java} (84%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/{dafit/settings/DaFitSettingEnum.java => moyoung/settings/MoyoungSettingEnum.java} (85%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/{dafit/settings/DaFitSettingInt.java => moyoung/settings/MoyoungSettingInt.java} (87%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/{dafit/settings/DaFitSettingLanguage.java => moyoung/settings/MoyoungSettingLanguage.java} (68%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/{dafit/settings/DaFitSettingRemindersToMove.java => moyoung/settings/MoyoungSettingRemindersToMove.java} (89%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/{dafit/settings/DaFitSettingTimeRange.java => moyoung/settings/MoyoungSettingTimeRange.java} (90%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/{dafit/settings/DaFitSettingUserInfo.java => moyoung/settings/MoyoungSettingUserInfo.java} (87%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/{dafit => moyoung}/FetchDataOperation.java (74%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/{dafit/DaFitDeviceSupport.java => moyoung/MoyoungDeviceSupport.java} (78%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/{dafit/DaFitPacket.java => moyoung/MoyoungPacket.java} (89%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/{dafit/DaFitPacketIn.java => moyoung/MoyoungPacketIn.java} (91%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/{dafit/DaFitPacketOut.java => moyoung/MoyoungPacketOut.java} (88%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/{dafit => moyoung}/QuerySettingsOperation.java (76%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/{dafit => moyoung}/TrainingFinishedDataOperation.java (81%) rename app/src/main/res/xml/{devicesettings_dafit_device_version.xml => devicesettings_moyoung_device_version.xml} (63%) rename app/src/main/res/xml/{devicesettings_dafit_language.xml => devicesettings_moyoung_language.xml} (90%) rename app/src/main/res/xml/{devicesettings_dafit_sedentary_reminder.xml => devicesettings_moyoung_sedentary_reminder.xml} (100%) rename app/src/main/res/xml/{devicesettings_dafit_watchface.xml => devicesettings_moyoung_watchface.xml} (68%) diff --git a/GBDaoGenerator/src/nodomain/freeyourgadget/gadgetbridge/daogen/GBDaoGenerator.java b/GBDaoGenerator/src/nodomain/freeyourgadget/gadgetbridge/daogen/GBDaoGenerator.java index 39afa4176..733192d08 100644 --- a/GBDaoGenerator/src/nodomain/freeyourgadget/gadgetbridge/daogen/GBDaoGenerator.java +++ b/GBDaoGenerator/src/nodomain/freeyourgadget/gadgetbridge/daogen/GBDaoGenerator.java @@ -150,6 +150,7 @@ public class GBDaoGenerator { addColmiSleepStageSample(schema, user, device); addColmiHrvValueSample(schema, user, device); addColmiHrvSummarySample(schema, user, device); + addMoyoungActivitySample(schema, user, device); addHuaweiActivitySample(schema, user, device); @@ -1036,8 +1037,8 @@ public class GBDaoGenerator { return activitySample; } - private static Entity addDaFitActivitySample(Schema schema, Entity user, Entity device) { - Entity activitySample = addEntity(schema, "DaFitActivitySample"); + private static Entity addMoyoungActivitySample(Schema schema, Entity user, Entity device) { + 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"); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/DaFitConstants.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/MoyoungConstants.java similarity index 95% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/DaFitConstants.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/MoyoungConstants.java index 392dd3fa9..bf5ce5891 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/DaFitConstants.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/MoyoungConstants.java @@ -14,7 +14,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.dafit; +package nodomain.freeyourgadget.gadgetbridge.devices.moyoung; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -25,7 +25,7 @@ import java.util.UUID; import nodomain.freeyourgadget.gadgetbridge.model.NotificationType; import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSupport; -public class DaFitConstants { +public class MoyoungConstants { // (*) - based only on static reverse engineering of the original app code, // not supported by my watch so not implemented // (or at least I didn't manage to get any response out of it) @@ -97,7 +97,7 @@ public class DaFitConstants { // * 20 - protocol version (queries manufacturer name, see description above) - public static final UUID UUID_SERVICE_DAFIT = UUID.fromString(String.format(AbstractBTLEDeviceSupport.BASE_UUID, "feea")); + public static final UUID UUID_SERVICE_MOYOUNG = UUID.fromString(String.format(AbstractBTLEDeviceSupport.BASE_UUID, "feea")); public static final UUID UUID_CHARACTERISTIC_STEPS = UUID.fromString(String.format(AbstractBTLEDeviceSupport.BASE_UUID, "fee1")); public static final UUID UUID_CHARACTERISTIC_DATA_OUT = UUID.fromString(String.format(AbstractBTLEDeviceSupport.BASE_UUID, "fee2")); public static final UUID UUID_CHARACTERISTIC_DATA_IN = UUID.fromString(String.format(AbstractBTLEDeviceSupport.BASE_UUID, "fee3")); @@ -365,36 +365,36 @@ public class DaFitConstants { public static final byte WEATHER_HAZE = 7; // it's basically very big fog :P // NOTE: values > 7 give random glitchy crap as images :D - public static byte openWeatherConditionToDaFitConditionId(int openWeatherMapCondition) { + public static byte openWeatherConditionToMoyoungConditionId(int openWeatherMapCondition) { int openWeatherMapGroup = openWeatherMapCondition / 100; switch (openWeatherMapGroup) { case 2: // thunderstorm case 3: // drizzle case 5: // rain - return DaFitConstants.WEATHER_RAINY; + return MoyoungConstants.WEATHER_RAINY; case 6: // snow - return DaFitConstants.WEATHER_SNOWY; + return MoyoungConstants.WEATHER_SNOWY; case 7: // fog - return DaFitConstants.WEATHER_FOGGY; + return MoyoungConstants.WEATHER_FOGGY; case 8: // clear / clouds if (openWeatherMapCondition <= 801) // few clouds - return DaFitConstants.WEATHER_SUNNY; + return MoyoungConstants.WEATHER_SUNNY; if (openWeatherMapCondition >= 804) // overcast clouds - return DaFitConstants.WEATHER_CLOUDY; - return DaFitConstants.WEATHER_OVERCAST; + return MoyoungConstants.WEATHER_CLOUDY; + return MoyoungConstants.WEATHER_OVERCAST; case 9: // extreme default: if (openWeatherMapCondition == 905) // windy - return DaFitConstants.WEATHER_SANDSTORM; - return DaFitConstants.WEATHER_HAZE; + return MoyoungConstants.WEATHER_SANDSTORM; + return MoyoungConstants.WEATHER_HAZE; } } - public static final String PREF_WATCH_FACE = "dafit_watch_face"; - public static final String PREF_LANGUAGE = "dafit_language"; - public static final String PREF_LANGUAGE_SUPPORT = "dafit_language_supported"; - public static final String PREF_DEVICE_VERSION = "dafit_device_version"; + public static final String PREF_WATCH_FACE = "moyoung_watch_face"; + public static final String PREF_LANGUAGE = "moyoung_language"; + public static final String PREF_LANGUAGE_SUPPORT = "moyoung_language_supported"; + public static final String PREF_DEVICE_VERSION = "moyoung_device_version"; public static final String PREF_SEDENTARY_REMINDER = "sedentary_reminder"; public static final String PREF_SEDENTARY_REMINDER_PERIOD = "sedentary_reminder_period"; public static final String PREF_SEDENTARY_REMINDER_STEPS = "sedentary_reminder_steps"; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/DaFitDeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/MoyoungDeviceCoordinator.java similarity index 51% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/DaFitDeviceCoordinator.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/MoyoungDeviceCoordinator.java index 9aca13545..9c0a2ad40 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/DaFitDeviceCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/MoyoungDeviceCoordinator.java @@ -14,7 +14,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.dafit; +package nodomain.freeyourgadget.gadgetbridge.devices.moyoung; import android.annotation.TargetApi; import android.app.Activity; @@ -35,18 +35,18 @@ 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.dafit.settings.DaFitEnumDeviceVersion; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitEnumMetricSystem; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitEnumTimeSystem; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSetting; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingBool; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingByte; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingEnum; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingInt; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingLanguage; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingRemindersToMove; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingTimeRange; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingUserInfo; +import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungEnumDeviceVersion; +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.MoyoungSettingBool; +import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingByte; +import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingEnum; +import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings.MoyoungSettingInt; +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.moyoung.settings.MoyoungSettingUserInfo; import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession; import nodomain.freeyourgadget.gadgetbridge.entities.Device; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; @@ -54,7 +54,7 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -public class DaFitDeviceCoordinator extends AbstractDeviceCoordinator { +public class MoyoungDeviceCoordinator extends AbstractDeviceCoordinator { @Override public DeviceType getDeviceType() { @@ -70,7 +70,7 @@ public class DaFitDeviceCoordinator extends AbstractDeviceCoordinator { @Override @TargetApi(Build.VERSION_CODES.LOLLIPOP) public Collection createBLEScanFilters() { - ParcelUuid service = new ParcelUuid(DaFitConstants.UUID_SERVICE_DAFIT); + ParcelUuid service = new ParcelUuid(MoyoungConstants.UUID_SERVICE_MOYOUNG); ScanFilter filter = new ScanFilter.Builder().setServiceUuid(service).build(); return Collections.singletonList(filter); } @@ -79,7 +79,7 @@ public class DaFitDeviceCoordinator extends AbstractDeviceCoordinator { @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(DaFitConstants.UUID_SERVICE_DAFIT)) { + if (candidate.supportsService(MoyoungConstants.UUID_SERVICE_MOYOUNG)) { return DeviceType.DAFIT; } return DeviceType.UNKNOWN; @@ -113,7 +113,7 @@ public class DaFitDeviceCoordinator extends AbstractDeviceCoordinator { @Override public SampleProvider getSampleProvider(GBDevice device, DaoSession session) { - return new DaFitSampleProvider(device, session); + return new MoyoungSampleProvider(device, session); } @Override @@ -200,31 +200,31 @@ public class DaFitDeviceCoordinator extends AbstractDeviceCoordinator { @Override public boolean supportsUnicodeEmojis() { return false; } - private static final DaFitSetting[] DAFIT_SETTINGS = new DaFitSetting[] { - new DaFitSettingUserInfo("USER_INFO", DaFitConstants.CMD_SET_USER_INFO), - new DaFitSettingByte("STEP_LENGTH", (byte)-1, DaFitConstants.CMD_SET_STEP_LENGTH), - // (*) new DaFitSettingEnum<>("DOMINANT_HAND", DaFitConstants.CMD_QUERY_DOMINANT_HAND, DaFitConstants.CMD_SET_DOMINANT_HAND, DaFitEnumDominantHand.class), - new DaFitSettingInt("GOAL_STEP", DaFitConstants.CMD_QUERY_GOAL_STEP, DaFitConstants.CMD_SET_GOAL_STEP), + 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), + // (*) new MoyoungSettingEnum<>("DOMINANT_HAND", MoyoungConstants.CMD_QUERY_DOMINANT_HAND, MoyoungConstants.CMD_SET_DOMINANT_HAND, MoyoungEnumDominantHand.class), + new MoyoungSettingInt("GOAL_STEP", MoyoungConstants.CMD_QUERY_GOAL_STEP, MoyoungConstants.CMD_SET_GOAL_STEP), - new DaFitSettingEnum<>("DEVICE_VERSION", DaFitConstants.CMD_QUERY_DEVICE_VERSION, DaFitConstants.CMD_SET_DEVICE_VERSION, DaFitEnumDeviceVersion.class), - new DaFitSettingLanguage("DEVICE_LANGUAGE", DaFitConstants.CMD_QUERY_DEVICE_LANGUAGE, DaFitConstants.CMD_SET_DEVICE_LANGUAGE), - new DaFitSettingEnum<>("TIME_SYSTEM", DaFitConstants.CMD_QUERY_TIME_SYSTEM, DaFitConstants.CMD_SET_TIME_SYSTEM, DaFitEnumTimeSystem.class), - new DaFitSettingEnum<>("METRIC_SYSTEM", DaFitConstants.CMD_QUERY_METRIC_SYSTEM, DaFitConstants.CMD_SET_METRIC_SYSTEM, DaFitEnumMetricSystem.class), + new MoyoungSettingEnum<>("DEVICE_VERSION", MoyoungConstants.CMD_QUERY_DEVICE_VERSION, MoyoungConstants.CMD_SET_DEVICE_VERSION, MoyoungEnumDeviceVersion.class), + new MoyoungSettingLanguage("DEVICE_LANGUAGE", MoyoungConstants.CMD_QUERY_DEVICE_LANGUAGE, MoyoungConstants.CMD_SET_DEVICE_LANGUAGE), + new MoyoungSettingEnum<>("TIME_SYSTEM", MoyoungConstants.CMD_QUERY_TIME_SYSTEM, MoyoungConstants.CMD_SET_TIME_SYSTEM, MoyoungEnumTimeSystem.class), + new MoyoungSettingEnum<>("METRIC_SYSTEM", MoyoungConstants.CMD_QUERY_METRIC_SYSTEM, MoyoungConstants.CMD_SET_METRIC_SYSTEM, MoyoungEnumMetricSystem.class), - // (*) new DaFitSetting("DISPLAY_DEVICE_FUNCTION", DaFitConstants.CMD_QUERY_DISPLAY_DEVICE_FUNCTION, DaFitConstants.CMD_SET_DISPLAY_DEVICE_FUNCTION), - // (*) new DaFitSetting("SUPPORT_WATCH_FACE", DaFitConstants.CMD_QUERY_SUPPORT_WATCH_FACE, (byte)-1), - // (*) new DaFitSetting("WATCH_FACE_LAYOUT", DaFitConstants.CMD_QUERY_WATCH_FACE_LAYOUT, DaFitConstants.CMD_SET_WATCH_FACE_LAYOUT), - new DaFitSettingByte("DISPLAY_WATCH_FACE", DaFitConstants.CMD_QUERY_DISPLAY_WATCH_FACE, DaFitConstants.CMD_SET_DISPLAY_WATCH_FACE), - new DaFitSettingBool("OTHER_MESSAGE_STATE", DaFitConstants.CMD_QUERY_OTHER_MESSAGE_STATE, DaFitConstants.CMD_SET_OTHER_MESSAGE_STATE), + // (*) new MoyoungSetting("DISPLAY_DEVICE_FUNCTION", MoyoungConstants.CMD_QUERY_DISPLAY_DEVICE_FUNCTION, MoyoungConstants.CMD_SET_DISPLAY_DEVICE_FUNCTION), + // (*) new MoyoungSetting("SUPPORT_WATCH_FACE", MoyoungConstants.CMD_QUERY_SUPPORT_WATCH_FACE, (byte)-1), + // (*) new MoyoungSetting("WATCH_FACE_LAYOUT", MoyoungConstants.CMD_QUERY_WATCH_FACE_LAYOUT, MoyoungConstants.CMD_SET_WATCH_FACE_LAYOUT), + new MoyoungSettingByte("DISPLAY_WATCH_FACE", MoyoungConstants.CMD_QUERY_DISPLAY_WATCH_FACE, MoyoungConstants.CMD_SET_DISPLAY_WATCH_FACE), + new MoyoungSettingBool("OTHER_MESSAGE_STATE", MoyoungConstants.CMD_QUERY_OTHER_MESSAGE_STATE, MoyoungConstants.CMD_SET_OTHER_MESSAGE_STATE), - new DaFitSettingBool("QUICK_VIEW", DaFitConstants.CMD_QUERY_QUICK_VIEW, DaFitConstants.CMD_SET_QUICK_VIEW), - new DaFitSettingTimeRange("QUICK_VIEW_TIME", DaFitConstants.CMD_QUERY_QUICK_VIEW_TIME, DaFitConstants.CMD_SET_QUICK_VIEW_TIME), - new DaFitSettingBool("SEDENTARY_REMINDER", DaFitConstants.CMD_QUERY_SEDENTARY_REMINDER, DaFitConstants.CMD_SET_SEDENTARY_REMINDER), - new DaFitSettingRemindersToMove("REMINDERS_TO_MOVE_PERIOD", DaFitConstants.CMD_QUERY_REMINDERS_TO_MOVE_PERIOD, DaFitConstants.CMD_SET_REMINDERS_TO_MOVE_PERIOD), - new DaFitSettingTimeRange("DO_NOT_DISTURB_TIME", DaFitConstants.CMD_QUERY_DO_NOT_DISTURB_TIME, DaFitConstants.CMD_SET_DO_NOT_DISTURB_TIME), - // (*) new DaFitSetting("PSYCHOLOGICAL_PERIOD", DaFitConstants.CMD_QUERY_PSYCHOLOGICAL_PERIOD, DaFitConstants.CMD_SET_PSYCHOLOGICAL_PERIOD), + new MoyoungSettingBool("QUICK_VIEW", MoyoungConstants.CMD_QUERY_QUICK_VIEW, MoyoungConstants.CMD_SET_QUICK_VIEW), + new MoyoungSettingTimeRange("QUICK_VIEW_TIME", MoyoungConstants.CMD_QUERY_QUICK_VIEW_TIME, MoyoungConstants.CMD_SET_QUICK_VIEW_TIME), + new MoyoungSettingBool("SEDENTARY_REMINDER", MoyoungConstants.CMD_QUERY_SEDENTARY_REMINDER, MoyoungConstants.CMD_SET_SEDENTARY_REMINDER), + new MoyoungSettingRemindersToMove("REMINDERS_TO_MOVE_PERIOD", MoyoungConstants.CMD_QUERY_REMINDERS_TO_MOVE_PERIOD, MoyoungConstants.CMD_SET_REMINDERS_TO_MOVE_PERIOD), + new MoyoungSettingTimeRange("DO_NOT_DISTURB_TIME", MoyoungConstants.CMD_QUERY_DO_NOT_DISTURB_TIME, MoyoungConstants.CMD_SET_DO_NOT_DISTURB_TIME), + // (*) new MoyoungSetting("PSYCHOLOGICAL_PERIOD", MoyoungConstants.CMD_QUERY_PSYCHOLOGICAL_PERIOD, MoyoungConstants.CMD_SET_PSYCHOLOGICAL_PERIOD), - new DaFitSettingBool("BREATHING_LIGHT", DaFitConstants.CMD_QUERY_BREATHING_LIGHT, DaFitConstants.CMD_SET_BREATHING_LIGHT) + new MoyoungSettingBool("BREATHING_LIGHT", MoyoungConstants.CMD_QUERY_BREATHING_LIGHT, MoyoungConstants.CMD_SET_BREATHING_LIGHT) }; @Override @@ -232,20 +232,20 @@ public class DaFitDeviceCoordinator extends AbstractDeviceCoordinator { return new int[]{ R.xml.devicesettings_personalinfo, //R.xml.devicesettings_steplength, // TODO is this needed? does it work? write-only so hard to tell - R.xml.devicesettings_dafit_device_version, - R.xml.devicesettings_dafit_language, + R.xml.devicesettings_moyoung_device_version, + R.xml.devicesettings_moyoung_language, R.xml.devicesettings_timeformat, R.xml.devicesettings_measurementsystem, - R.xml.devicesettings_dafit_watchface, - //R.xml.devicesettings_dafit_othermessage, // not implemented because this doesn't really do anything on the watch side, only enables/disables sending of "other" notifications in the app (no idea why they store the setting on the watch) + R.xml.devicesettings_moyoung_watchface, + //R.xml.devicesettings_moyoung_othermessage, // not implemented because this doesn't really do anything on the watch side, only enables/disables sending of "other" notifications in the app (no idea why they store the setting on the watch) R.xml.devicesettings_liftwrist_display, - R.xml.devicesettings_dafit_sedentary_reminder, + R.xml.devicesettings_moyoung_sedentary_reminder, R.xml.devicesettings_donotdisturb_no_auto_v2, - //R.xml.devicesettings_dafit_breathinglight, // No idea what this does but it doesn't seem to change anything + //R.xml.devicesettings_moyoung_breathinglight, // No idea what this does but it doesn't seem to change anything }; } - public DaFitSetting[] getSupportedSettings() { - return DAFIT_SETTINGS; + public MoyoungSetting[] getSupportedSettings() { + return MOYOUNG_SETTINGS; } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/DaFitSampleProvider.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/MoyoungSampleProvider.java similarity index 77% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/DaFitSampleProvider.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/MoyoungSampleProvider.java index 58ff5bb6f..29f96d4d4 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/DaFitSampleProvider.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/MoyoungSampleProvider.java @@ -14,7 +14,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.dafit; +package nodomain.freeyourgadget.gadgetbridge.devices.moyoung; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -31,13 +31,13 @@ import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; import nodomain.freeyourgadget.gadgetbridge.devices.AbstractSampleProvider; import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession; import nodomain.freeyourgadget.gadgetbridge.entities.Device; -import nodomain.freeyourgadget.gadgetbridge.entities.DaFitActivitySample; -import nodomain.freeyourgadget.gadgetbridge.entities.DaFitActivitySampleDao; +import nodomain.freeyourgadget.gadgetbridge.entities.MoyoungActivitySample; +import nodomain.freeyourgadget.gadgetbridge.entities.MoyoungActivitySampleDao; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind; import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample; -public class DaFitSampleProvider extends AbstractSampleProvider { +public class MoyoungSampleProvider extends AbstractSampleProvider { public static final int SOURCE_NOT_MEASURED = -1; public static final int SOURCE_STEPS_REALTIME = 1; // steps gathered at realtime from the steps characteristic public static final int SOURCE_STEPS_SUMMARY = 2; // steps gathered from the daily summary @@ -48,53 +48,53 @@ public class DaFitSampleProvider extends AbstractSampleProvider getSampleDao() { - return getSession().getDaFitActivitySampleDao(); + public AbstractDao getSampleDao() { + return getSession().getMoyoungActivitySampleDao(); } @NonNull @Override protected Property getTimestampSampleProperty() { - return DaFitActivitySampleDao.Properties.Timestamp; + return MoyoungActivitySampleDao.Properties.Timestamp; } @Nullable @Override protected Property getRawKindSampleProperty() { - return DaFitActivitySampleDao.Properties.RawKind; + return MoyoungActivitySampleDao.Properties.RawKind; } @NonNull @Override protected Property getDeviceIdentifierSampleProperty() { - return DaFitActivitySampleDao.Properties.DeviceId; + return MoyoungActivitySampleDao.Properties.DeviceId; } @Override - public DaFitActivitySample createActivitySample() { - return new DaFitActivitySample(); + public MoyoungActivitySample createActivitySample() { + return new MoyoungActivitySample(); } @Override @@ -163,12 +163,12 @@ public class DaFitSampleProvider extends AbstractSampleProvider qb = getSampleDao().queryBuilder(); + /*QueryBuilder qb = getSampleDao().queryBuilder(); qb.where(deviceProperty.eq(dbDevice.getId())) .where(timestampProperty.ge(timestamp_from), timestampProperty.le(timestamp_to)) .where(getRawKindSampleProperty().eq(ACTIVITY_NOT_MEASURED)); - List samples = qb.build().list(); - for (DaFitActivitySample sample : samples) { + List samples = qb.build().list(); + for (MoyoungActivitySample sample : samples) { sample.setProvider(this); sample.setRawKind(new_raw_activity_kind); sample.update(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/DaFitWeatherForecast.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/MoyoungWeatherForecast.java similarity index 76% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/DaFitWeatherForecast.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/MoyoungWeatherForecast.java index e33964014..30eda6acf 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/DaFitWeatherForecast.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/MoyoungWeatherForecast.java @@ -14,24 +14,24 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.dafit; +package nodomain.freeyourgadget.gadgetbridge.devices.moyoung; import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec; -public class DaFitWeatherForecast { +public class MoyoungWeatherForecast { public final byte conditionId; public final byte minTemp; public final byte maxTemp; - public DaFitWeatherForecast(byte conditionId, byte minTemp, byte maxTemp) { + public MoyoungWeatherForecast(byte conditionId, byte minTemp, byte maxTemp) { this.conditionId = conditionId; this.minTemp = minTemp; this.maxTemp = maxTemp; } - public DaFitWeatherForecast(WeatherSpec.Forecast forecast) + public MoyoungWeatherForecast(WeatherSpec.Forecast forecast) { - conditionId = DaFitConstants.openWeatherConditionToDaFitConditionId(forecast.conditionCode); + conditionId = MoyoungConstants.openWeatherConditionToMoyoungConditionId(forecast.conditionCode); minTemp = (byte)(forecast.minTemp - 273); // Kelvin -> Celcius maxTemp = (byte)(forecast.maxTemp - 273); // Kelvin -> Celcius } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/DaFitWeatherToday.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/MoyoungWeatherToday.java similarity index 81% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/DaFitWeatherToday.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/MoyoungWeatherToday.java index fe4e78144..8de62d017 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/DaFitWeatherToday.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/MoyoungWeatherToday.java @@ -14,7 +14,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.dafit; +package nodomain.freeyourgadget.gadgetbridge.devices.moyoung; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -22,14 +22,14 @@ import androidx.annotation.Nullable; import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec; import nodomain.freeyourgadget.gadgetbridge.util.StringUtils; -public class DaFitWeatherToday { +public class MoyoungWeatherToday { public final byte conditionId; public final byte currentTemp; public final Short pm25; // (*) public final String lunar_or_festival; // (*) public final String city; // (*) - public DaFitWeatherToday(byte conditionId, byte currentTemp, @Nullable Short pm25, @NonNull String lunar_or_festival, @NonNull String city) { + public MoyoungWeatherToday(byte conditionId, byte currentTemp, @Nullable Short pm25, @NonNull String lunar_or_festival, @NonNull String city) { if (lunar_or_festival.length() != 4) throw new IllegalArgumentException("lunar_or_festival"); if (city.length() != 4) @@ -41,9 +41,9 @@ public class DaFitWeatherToday { this.city = city; } - public DaFitWeatherToday(WeatherSpec weatherSpec) + public MoyoungWeatherToday(WeatherSpec weatherSpec) { - conditionId = DaFitConstants.openWeatherConditionToDaFitConditionId(weatherSpec.currentConditionCode); + conditionId = MoyoungConstants.openWeatherConditionToMoyoungConditionId(weatherSpec.currentConditionCode); currentTemp = (byte)(weatherSpec.currentTemp - 273); // Kelvin -> Celcius pm25 = null; lunar_or_festival = StringUtils.pad("", 4); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitEnum.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungEnum.java similarity index 88% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitEnum.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungEnum.java index 33f3bdc3e..3d7e6611e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitEnum.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungEnum.java @@ -14,8 +14,8 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings; +package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings; -public interface DaFitEnum { +public interface MoyoungEnum { byte value(); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitEnumDeviceVersion.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungEnumDeviceVersion.java similarity index 84% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitEnumDeviceVersion.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungEnumDeviceVersion.java index b33ca49ae..c142c7e7a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitEnumDeviceVersion.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungEnumDeviceVersion.java @@ -14,15 +14,15 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings; +package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings; -public enum DaFitEnumDeviceVersion implements DaFitEnum { +public enum MoyoungEnumDeviceVersion implements MoyoungEnum { CHINESE_EDITION((byte)0), INTERNATIONAL_EDITION((byte)1); public final byte value; - DaFitEnumDeviceVersion(byte value) { + MoyoungEnumDeviceVersion(byte value) { this.value = value; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitEnumDominantHand.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungEnumDominantHand.java similarity index 84% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitEnumDominantHand.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungEnumDominantHand.java index c05ceabc1..442a57128 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitEnumDominantHand.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungEnumDominantHand.java @@ -14,15 +14,15 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings; +package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings; -public enum DaFitEnumDominantHand implements DaFitEnum { +public enum MoyoungEnumDominantHand implements MoyoungEnum { LEFT_HAND((byte)0), RIGHT_HAND((byte)1); public final byte value; - DaFitEnumDominantHand(byte value) { + MoyoungEnumDominantHand(byte value) { this.value = value; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitEnumLanguage.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungEnumLanguage.java similarity index 91% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitEnumLanguage.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungEnumLanguage.java index 5b94f1736..ee27a654a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitEnumLanguage.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungEnumLanguage.java @@ -14,9 +14,9 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings; +package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings; -public enum DaFitEnumLanguage implements DaFitEnum { +public enum MoyoungEnumLanguage implements MoyoungEnum { LANGUAGE_ENGLISH((byte)0), LANGUAGE_CHINESE((byte)1), LANGUAGE_JAPANESE((byte)2), @@ -45,7 +45,7 @@ public enum DaFitEnumLanguage implements DaFitEnum { public final byte value; - DaFitEnumLanguage(byte value) { + MoyoungEnumLanguage(byte value) { this.value = value; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitEnumMetricSystem.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungEnumMetricSystem.java similarity index 84% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitEnumMetricSystem.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungEnumMetricSystem.java index 570343968..032e6907d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitEnumMetricSystem.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungEnumMetricSystem.java @@ -14,15 +14,15 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings; +package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings; -public enum DaFitEnumMetricSystem implements DaFitEnum { +public enum MoyoungEnumMetricSystem implements MoyoungEnum { METRIC_SYSTEM((byte)0), IMPERIAL_SYSTEM((byte)1); public final byte value; - DaFitEnumMetricSystem(byte value) { + MoyoungEnumMetricSystem(byte value) { this.value = value; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitEnumTimeSystem.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungEnumTimeSystem.java similarity index 84% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitEnumTimeSystem.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungEnumTimeSystem.java index 68e5a26dd..e80eb81e8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitEnumTimeSystem.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungEnumTimeSystem.java @@ -14,15 +14,15 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings; +package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings; -public enum DaFitEnumTimeSystem implements DaFitEnum { +public enum MoyoungEnumTimeSystem implements MoyoungEnum { TIME_SYSTEM_12((byte)0), TIME_SYSTEM_24((byte)1); public final byte value; - DaFitEnumTimeSystem(byte value) { + MoyoungEnumTimeSystem(byte value) { this.value = value; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitSetting.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungSetting.java similarity index 84% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitSetting.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungSetting.java index 5638a5ab2..a5be46e9a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitSetting.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungSetting.java @@ -14,14 +14,14 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings; +package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings; -public abstract class DaFitSetting { +public abstract class MoyoungSetting { public final String name; public final byte cmdQuery; public final byte cmdSet; - public DaFitSetting(String name, byte cmdQuery, byte cmdSet) { + public MoyoungSetting(String name, byte cmdQuery, byte cmdSet) { this.name = name; this.cmdQuery = cmdQuery; this.cmdSet = cmdSet; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitSettingBool.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungSettingBool.java similarity index 85% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitSettingBool.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungSettingBool.java index 515aa6b67..dba651669 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitSettingBool.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungSettingBool.java @@ -14,10 +14,10 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings; +package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings; -public class DaFitSettingBool extends DaFitSetting { - public DaFitSettingBool(String name, byte cmdQuery, byte cmdSet) { +public class MoyoungSettingBool extends MoyoungSetting { + public MoyoungSettingBool(String name, byte cmdQuery, byte cmdSet) { super(name, cmdQuery, cmdSet); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitSettingByte.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungSettingByte.java similarity index 84% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitSettingByte.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungSettingByte.java index fb5fd6849..c5dd92bfc 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitSettingByte.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungSettingByte.java @@ -14,10 +14,10 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings; +package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings; -public class DaFitSettingByte extends DaFitSetting { - public DaFitSettingByte(String name, byte cmdQuery, byte cmdSet) { +public class MoyoungSettingByte extends MoyoungSetting { + public MoyoungSettingByte(String name, byte cmdQuery, byte cmdSet) { super(name, cmdQuery, cmdSet); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitSettingEnum.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungSettingEnum.java similarity index 85% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitSettingEnum.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungSettingEnum.java index 50791f735..60e8d5dbf 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitSettingEnum.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungSettingEnum.java @@ -14,12 +14,12 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings; +package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings; -public class DaFitSettingEnum & DaFitEnum> extends DaFitSetting { +public class MoyoungSettingEnum & MoyoungEnum> extends MoyoungSetting { protected final Class clazz; - public DaFitSettingEnum(String name, byte cmdQuery, byte cmdSet, Class clazz) { + public MoyoungSettingEnum(String name, byte cmdQuery, byte cmdSet, Class clazz) { super(name, cmdQuery, cmdSet); this.clazz = clazz; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitSettingInt.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungSettingInt.java similarity index 87% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitSettingInt.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungSettingInt.java index 1ba6b0aed..be9bcc28f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitSettingInt.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungSettingInt.java @@ -14,13 +14,13 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings; +package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings; import java.nio.ByteBuffer; import java.nio.ByteOrder; -public class DaFitSettingInt extends DaFitSetting { - public DaFitSettingInt(String name, byte cmdQuery, byte cmdSet) { +public class MoyoungSettingInt extends MoyoungSetting { + public MoyoungSettingInt(String name, byte cmdQuery, byte cmdSet) { super(name, cmdQuery, cmdSet); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitSettingLanguage.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungSettingLanguage.java similarity index 68% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitSettingLanguage.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungSettingLanguage.java index b3158133e..99bbee686 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitSettingLanguage.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungSettingLanguage.java @@ -14,7 +14,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings; +package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings; import android.util.Pair; @@ -22,12 +22,12 @@ import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; -public class DaFitSettingLanguage extends DaFitSettingEnum { - public DaFitSettingLanguage(String name, byte cmdQuery, byte cmdSet) { - super(name, cmdQuery, cmdSet, DaFitEnumLanguage.class); +public class MoyoungSettingLanguage extends MoyoungSettingEnum { + public MoyoungSettingLanguage(String name, byte cmdQuery, byte cmdSet) { + super(name, cmdQuery, cmdSet, MoyoungEnumLanguage.class); } - private Pair decodeData(byte[] data) { + private Pair decodeData(byte[] data) { if (data.length != 5) throw new IllegalArgumentException("Wrong data length, should be 5, was " + data.length); @@ -38,26 +38,26 @@ public class DaFitSettingLanguage extends DaFitSettingEnum { int supportedNum = buffer.getInt(); String supportedStr = new StringBuffer(Integer.toBinaryString(supportedNum)).reverse().toString(); - DaFitEnumLanguage currentLanguage = super.decode(current); - List supportedLanguages = new ArrayList<>(); - for (DaFitEnumLanguage e : clazz.getEnumConstants()) { + MoyoungEnumLanguage currentLanguage = super.decode(current); + List supportedLanguages = new ArrayList<>(); + for (MoyoungEnumLanguage e : clazz.getEnumConstants()) { if (e.value() >= supportedStr.length()) continue; if (Integer.parseInt(supportedStr.substring(e.value(), e.value() + 1)) != 0) supportedLanguages.add(e); } - DaFitEnumLanguage[] supportedLanguagesArr = new DaFitEnumLanguage[supportedLanguages.size()]; + MoyoungEnumLanguage[] supportedLanguagesArr = new MoyoungEnumLanguage[supportedLanguages.size()]; return Pair.create(currentLanguage, supportedLanguages.toArray(supportedLanguagesArr)); } @Override - public DaFitEnumLanguage decode(byte[] data) { + public MoyoungEnumLanguage decode(byte[] data) { return decodeData(data).first; } @Override - public DaFitEnumLanguage[] decodeSupportedValues(byte[] data) { + public MoyoungEnumLanguage[] decodeSupportedValues(byte[] data) { return decodeData(data).second; } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitSettingRemindersToMove.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungSettingRemindersToMove.java similarity index 89% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitSettingRemindersToMove.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungSettingRemindersToMove.java index 765ad24d6..0e2c59ad0 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/dafit/settings/DaFitSettingRemindersToMove.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/settings/MoyoungSettingRemindersToMove.java @@ -14,11 +14,11 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings; +package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings; import java.nio.ByteBuffer; -public class DaFitSettingRemindersToMove extends DaFitSetting { +public class MoyoungSettingRemindersToMove extends MoyoungSetting { public static class RemindersToMove { public byte period; public byte steps; @@ -46,7 +46,7 @@ public class DaFitSettingRemindersToMove extends DaFitSetting. */ -package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings; +package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings; import java.nio.ByteBuffer; import java.nio.ByteOrder; -public class DaFitSettingTimeRange extends DaFitSetting { +public class MoyoungSettingTimeRange extends MoyoungSetting { public static class TimeRange { public byte start_h; public byte start_m; @@ -47,7 +47,7 @@ public class DaFitSettingTimeRange extends DaFitSetting. */ -package nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings; +package nodomain.freeyourgadget.gadgetbridge.devices.moyoung.settings; import org.apache.commons.lang3.NotImplementedException; @@ -22,8 +22,8 @@ import java.nio.ByteBuffer; import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser; -public class DaFitSettingUserInfo extends DaFitSetting { - public DaFitSettingUserInfo(String name, byte cmdSet) { +public class MoyoungSettingUserInfo extends MoyoungSetting { + public MoyoungSettingUserInfo(String name, byte cmdSet) { super(name, (byte)-1, cmdSet); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/dafit/FetchDataOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/moyoung/FetchDataOperation.java similarity index 74% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/dafit/FetchDataOperation.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/moyoung/FetchDataOperation.java index 09d1803db..8eb18e990 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/dafit/FetchDataOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/moyoung/FetchDataOperation.java @@ -14,7 +14,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.dafit; +package nodomain.freeyourgadget.gadgetbridge.service.devices.moyoung; import android.bluetooth.BluetoothGatt; import android.bluetooth.BluetoothGattCharacteristic; @@ -29,13 +29,13 @@ import java.util.UUID; import nodomain.freeyourgadget.gadgetbridge.Logging; import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.DaFitConstants; +import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungConstants; 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.GB; -public class FetchDataOperation extends AbstractBTLEOperation { +public class FetchDataOperation extends AbstractBTLEOperation { private static final Logger LOG = LoggerFactory.getLogger(FetchDataOperation.class); @@ -43,9 +43,9 @@ public class FetchDataOperation extends AbstractBTLEOperation packet = DaFitPacketIn.parsePacket(packetIn.getPacket()); - packetIn = new DaFitPacketIn(); + Pair packet = MoyoungPacketIn.parsePacket(packetIn.getPacket()); + packetIn = new MoyoungPacketIn(); if (packet != null) { byte packetType = packet.first; byte[] payload = packet.second; @@ -119,12 +119,12 @@ public class FetchDataOperation extends AbstractBTLEOperation. */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.dafit; +package nodomain.freeyourgadget.gadgetbridge.service.devices.moyoung; import android.bluetooth.BluetoothGatt; import android.bluetooth.BluetoothGattCharacteristic; @@ -60,26 +60,26 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallContro import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventConfigurationRead; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.DaFitConstants; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.DaFitWeatherForecast; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.DaFitWeatherToday; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.DaFitDeviceCoordinator; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.DaFitSampleProvider; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitEnumDeviceVersion; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitEnumLanguage; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitEnumMetricSystem; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitEnumTimeSystem; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSetting; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingEnum; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingLanguage; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingRemindersToMove; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSettingTimeRange; +import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungConstants; +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; -import nodomain.freeyourgadget.gadgetbridge.entities.DaFitActivitySample; +import nodomain.freeyourgadget.gadgetbridge.entities.MoyoungActivitySample; import nodomain.freeyourgadget.gadgetbridge.entities.User; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind; @@ -113,14 +113,14 @@ import nodomain.freeyourgadget.gadgetbridge.util.NotificationUtils; import nodomain.freeyourgadget.gadgetbridge.util.Prefs; import nodomain.freeyourgadget.gadgetbridge.util.StringUtils; -public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { +public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport { - private static final Logger LOG = LoggerFactory.getLogger(DaFitDeviceSupport.class); + private static final Logger LOG = LoggerFactory.getLogger(MoyoungDeviceSupport.class); private static final long IDLE_STEPS_INTERVAL = 5 * 60 * 1000; - private final DeviceInfoProfile deviceInfoProfile; - private final BatteryInfoProfile batteryInfoProfile; - private final HeartRateProfile heartRateProfile; + private final DeviceInfoProfile deviceInfoProfile; + private final BatteryInfoProfile batteryInfoProfile; + private final HeartRateProfile heartRateProfile; private final GBDeviceEventVersionInfo versionCmd = new GBDeviceEventVersionInfo(); private final GBDeviceEventBatteryInfo batteryCmd = new GBDeviceEventBatteryInfo(); private final IntentListener mListener = new IntentListener() { @@ -139,11 +139,11 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { private Handler idleUpdateHandler = new Handler(); public static final int MTU = 20; // TODO: there seems to be some way to change this value...? - private DaFitPacketIn packetIn = new DaFitPacketIn(); + private MoyoungPacketIn packetIn = new MoyoungPacketIn(); private boolean realTimeHeartRate; - public DaFitDeviceSupport() { + public MoyoungDeviceSupport() { super(LOG); batteryCmd.level = ActivitySample.NOT_MEASURED; @@ -152,7 +152,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { addSupportedService(GattService.UUID_SERVICE_DEVICE_INFORMATION); addSupportedService(GattService.UUID_SERVICE_BATTERY_SERVICE); addSupportedService(GattService.UUID_SERVICE_HEART_RATE); - addSupportedService(DaFitConstants.UUID_SERVICE_DAFIT); + addSupportedService(MoyoungConstants.UUID_SERVICE_MOYOUNG); deviceInfoProfile = new DeviceInfoProfile<>(this); deviceInfoProfile.addListener(mListener); @@ -168,7 +168,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { @Override protected TransactionBuilder initializeDevice(TransactionBuilder builder) { builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZING, getContext())); - builder.notify(getCharacteristic(DaFitConstants.UUID_CHARACTERISTIC_DATA_IN), true); + builder.notify(getCharacteristic(MoyoungConstants.UUID_CHARACTERISTIC_DATA_IN), true); deviceInfoProfile.requestDeviceInfo(builder); setTime(builder); 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 @@ -176,11 +176,11 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { batteryInfoProfile.requestBatteryInfo(builder); batteryInfoProfile.enableNotify(builder); heartRateProfile.enableNotify(builder); - builder.notify(getCharacteristic(DaFitConstants.UUID_CHARACTERISTIC_STEPS), true); + builder.notify(getCharacteristic(MoyoungConstants.UUID_CHARACTERISTIC_STEPS), true); builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZED, getContext())); // TODO: I would prefer this to be done when the alarms screen is open, not on initialization... - sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_QUERY_ALARM_CLOCK, new byte[0])); + sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_QUERY_ALARM_CLOCK, new byte[0])); return builder; } @@ -194,16 +194,16 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { private BluetoothGattCharacteristic getTargetCharacteristicForPacketType(byte packetType) { if (packetType == 1) - return getCharacteristic(DaFitConstants.UUID_CHARACTERISTIC_DATA_SPECIAL_1); + return getCharacteristic(MoyoungConstants.UUID_CHARACTERISTIC_DATA_SPECIAL_1); else if (packetType == 2) - return getCharacteristic(DaFitConstants.UUID_CHARACTERISTIC_DATA_SPECIAL_2); + return getCharacteristic(MoyoungConstants.UUID_CHARACTERISTIC_DATA_SPECIAL_2); else - return getCharacteristic(DaFitConstants.UUID_CHARACTERISTIC_DATA_OUT); + return getCharacteristic(MoyoungConstants.UUID_CHARACTERISTIC_DATA_OUT); } public void sendPacket(TransactionBuilder builder, byte[] packet) { - DaFitPacketOut packetOut = new DaFitPacketOut(packet); + MoyoungPacketOut packetOut = new MoyoungPacketOut(packet); byte[] fragment = new byte[MTU]; while(packetOut.getFragment(fragment)) @@ -215,18 +215,18 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { @Override public boolean onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) { UUID charUuid = characteristic.getUuid(); - if (charUuid.equals(DaFitConstants.UUID_CHARACTERISTIC_STEPS)) + if (charUuid.equals(MoyoungConstants.UUID_CHARACTERISTIC_STEPS)) { byte[] payload = characteristic.getValue(); Log.i("AAAAAAAAAAAAAAAA", "Update step count: " + Logging.formatBytes(characteristic.getValue())); handleStepsHistory(0, payload, true); return true; } - if (charUuid.equals(DaFitConstants.UUID_CHARACTERISTIC_DATA_IN)) + if (charUuid.equals(MoyoungConstants.UUID_CHARACTERISTIC_DATA_IN)) { if (packetIn.putFragment(characteristic.getValue())) { - Pair packet = DaFitPacketIn.parsePacket(packetIn.getPacket()); - packetIn = new DaFitPacketIn(); + Pair packet = MoyoungPacketIn.parsePacket(packetIn.getPacket()); + packetIn = new MoyoungPacketIn(); if (packet != null) { byte packetType = packet.first; byte[] payload = packet.second; @@ -244,16 +244,16 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { private boolean handlePacket(byte packetType, byte[] payload) { - if (packetType == DaFitConstants.CMD_TRIGGER_MEASURE_HEARTRATE) + if (packetType == MoyoungConstants.CMD_TRIGGER_MEASURE_HEARTRATE) { int heartRate = payload[0]; Log.i("XXXXXXXX", "Measure heart rate finished: " + heartRate + " BPM"); - DaFitActivitySample sample = new DaFitActivitySample(); + MoyoungActivitySample sample = new MoyoungActivitySample(); sample.setTimestamp((int) (System.currentTimeMillis() / 1000)); - sample.setRawKind(DaFitSampleProvider.ACTIVITY_NOT_MEASURED); - sample.setDataSource(DaFitSampleProvider.SOURCE_SINGLE_MEASURE); + sample.setRawKind(MoyoungSampleProvider.ACTIVITY_NOT_MEASURED); + sample.setDataSource(MoyoungSampleProvider.SOURCE_SINGLE_MEASURE); sample.setBatteryLevel(ActivitySample.NOT_MEASURED); sample.setSteps(ActivitySample.NOT_MEASURED); @@ -273,16 +273,16 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { return true; } - if (packetType == DaFitConstants.CMD_TRIGGER_MEASURE_BLOOD_OXYGEN) + if (packetType == MoyoungConstants.CMD_TRIGGER_MEASURE_BLOOD_OXYGEN) { int percent = payload[0]; Log.i("XXXXXXXX", "Measure blood oxygen finished: " + percent + "%"); - DaFitActivitySample sample = new DaFitActivitySample(); + MoyoungActivitySample sample = new MoyoungActivitySample(); sample.setTimestamp((int) (System.currentTimeMillis() / 1000)); - sample.setRawKind(DaFitSampleProvider.ACTIVITY_NOT_MEASURED); - sample.setDataSource(DaFitSampleProvider.SOURCE_SINGLE_MEASURE); + sample.setRawKind(MoyoungSampleProvider.ACTIVITY_NOT_MEASURED); + sample.setDataSource(MoyoungSampleProvider.SOURCE_SINGLE_MEASURE); sample.setBatteryLevel(ActivitySample.NOT_MEASURED); sample.setSteps(ActivitySample.NOT_MEASURED); @@ -299,7 +299,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { return true; } - if (packetType == DaFitConstants.CMD_TRIGGER_MEASURE_BLOOD_PRESSURE) + if (packetType == MoyoungConstants.CMD_TRIGGER_MEASURE_BLOOD_PRESSURE) { int dataUnknown = payload[0]; int data1 = payload[1]; @@ -307,11 +307,11 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { Log.i("XXXXXXXX", "Measure blood pressure finished: " + data1 + "/" + data2 + " (" + dataUnknown + ")"); - DaFitActivitySample sample = new DaFitActivitySample(); + MoyoungActivitySample sample = new MoyoungActivitySample(); sample.setTimestamp((int) (System.currentTimeMillis() / 1000)); - sample.setRawKind(DaFitSampleProvider.ACTIVITY_NOT_MEASURED); - sample.setDataSource(DaFitSampleProvider.SOURCE_SINGLE_MEASURE); + sample.setRawKind(MoyoungSampleProvider.ACTIVITY_NOT_MEASURED); + sample.setDataSource(MoyoungSampleProvider.SOURCE_SINGLE_MEASURE); sample.setBatteryLevel(ActivitySample.NOT_MEASURED); sample.setSteps(ActivitySample.NOT_MEASURED); @@ -329,7 +329,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { return true; } - if (packetType == DaFitConstants.CMD_QUERY_LAST_DYNAMIC_RATE) + if (packetType == MoyoungConstants.CMD_QUERY_LAST_DYNAMIC_RATE) { // Training on the watch just finished and it wants us to fetch the details LOG.info("Starting training fetch"); @@ -340,31 +340,31 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { } } - if (packetType == DaFitConstants.CMD_NOTIFY_PHONE_OPERATION) + if (packetType == MoyoungConstants.CMD_NOTIFY_PHONE_OPERATION) { byte operation = payload[0]; - if (operation == DaFitConstants.ARG_OPERATION_PLAY_PAUSE) + if (operation == MoyoungConstants.ARG_OPERATION_PLAY_PAUSE) { GBDeviceEventMusicControl musicCmd = new GBDeviceEventMusicControl(); musicCmd.event = GBDeviceEventMusicControl.Event.PLAYPAUSE; evaluateGBDeviceEvent(musicCmd); return true; } - if (operation == DaFitConstants.ARG_OPERATION_PREV_SONG) + if (operation == MoyoungConstants.ARG_OPERATION_PREV_SONG) { GBDeviceEventMusicControl musicCmd = new GBDeviceEventMusicControl(); musicCmd.event = GBDeviceEventMusicControl.Event.PREVIOUS; evaluateGBDeviceEvent(musicCmd); return true; } - if (operation == DaFitConstants.ARG_OPERATION_NEXT_SONG) + if (operation == MoyoungConstants.ARG_OPERATION_NEXT_SONG) { GBDeviceEventMusicControl musicCmd = new GBDeviceEventMusicControl(); musicCmd.event = GBDeviceEventMusicControl.Event.NEXT; evaluateGBDeviceEvent(musicCmd); return true; } - if (operation == DaFitConstants.ARG_OPERATION_DROP_INCOMING_CALL) + if (operation == MoyoungConstants.ARG_OPERATION_DROP_INCOMING_CALL) { GBDeviceEventCallControl callCmd = new GBDeviceEventCallControl(); callCmd.event = GBDeviceEventCallControl.Event.REJECT; @@ -373,20 +373,20 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { } } - if (packetType == DaFitConstants.CMD_SWITCH_CAMERA_VIEW) + if (packetType == MoyoungConstants.CMD_SWITCH_CAMERA_VIEW) { // TODO: trigger camera photo return true; } - if (packetType == DaFitConstants.CMD_NOTIFY_WEATHER_CHANGE) + if (packetType == MoyoungConstants.CMD_NOTIFY_WEATHER_CHANGE) { LOG.info("The watch really wants us to transmit the weather data for some reason..."); // TODO: transmit weather return true; } - for (DaFitSetting setting : queriedSettings) + for (MoyoungSetting setting : queriedSettings) { if (setting.cmdQuery == packetType) { @@ -397,7 +397,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { } } - if (packetType == DaFitConstants.CMD_QUERY_ALARM_CLOCK) + if (packetType == MoyoungConstants.CMD_QUERY_ALARM_CLOCK) { handleGetAlarmsResponse(payload); return true; @@ -407,18 +407,18 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { return false; } - private void addGBActivitySample(DaFitActivitySample sample) { - addGBActivitySamples(new DaFitActivitySample[] { sample }); + private void addGBActivitySample(MoyoungActivitySample sample) { + addGBActivitySamples(new MoyoungActivitySample[] { sample }); } - private void addGBActivitySamples(DaFitActivitySample[] samples) { + private void addGBActivitySamples(MoyoungActivitySample[] samples) { try (DBHandler dbHandler = GBApplication.acquireDB()) { User user = DBHelper.getUser(dbHandler.getDaoSession()); Device device = DBHelper.getDevice(getDevice(), dbHandler.getDaoSession()); - DaFitSampleProvider provider = new DaFitSampleProvider(getDevice(), dbHandler.getDaoSession()); + MoyoungSampleProvider provider = new MoyoungSampleProvider(getDevice(), dbHandler.getDaoSession()); - for (DaFitActivitySample sample : samples) { + for (MoyoungActivitySample sample : samples) { sample.setDevice(device); sample.setUser(user); sample.setProvider(provider); @@ -431,7 +431,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { } } - private void broadcastSample(DaFitActivitySample sample) { + private void broadcastSample(MoyoungActivitySample sample) { Intent intent = new Intent(DeviceService.ACTION_REALTIME_SAMPLES) .putExtra(DeviceService.EXTRA_REALTIME_SAMPLE, sample) .putExtra(DeviceService.EXTRA_TIMESTAMP, sample.getTimestamp()); @@ -450,11 +450,11 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { batteryCmd.level = (short) info.getPercentCharged(); handleGBDeviceEvent(batteryCmd); - DaFitActivitySample sample = new DaFitActivitySample(); + MoyoungActivitySample sample = new MoyoungActivitySample(); sample.setTimestamp((int) (System.currentTimeMillis() / 1000)); - sample.setRawKind(DaFitSampleProvider.ACTIVITY_NOT_MEASURED); - sample.setDataSource(DaFitSampleProvider.SOURCE_BATTERY); + sample.setRawKind(MoyoungSampleProvider.ACTIVITY_NOT_MEASURED); + sample.setDataSource(MoyoungSampleProvider.SOURCE_BATTERY); sample.setBatteryLevel(batteryCmd.level); sample.setSteps(ActivitySample.NOT_MEASURED); @@ -483,7 +483,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { byte[] payload = new byte[str.length + 1]; payload[0] = type; System.arraycopy(str, 0, payload, 1, str.length); - sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_SEND_MESSAGE, payload)); + sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_SEND_MESSAGE, payload)); builder.queue(getQueue()); } catch (IOException e) { e.printStackTrace(); @@ -501,7 +501,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { text = StringUtils.getFirstOf(StringUtils.getFirstOf(notificationSpec.title, notificationSpec.subject), notificationSpec.body); // The notification is split at first : into sender and text - sendNotification(DaFitConstants.notificationType(notificationSpec.type), sender + ":" + text); + sendNotification(MoyoungConstants.notificationType(notificationSpec.type), sender + ":" + text); } @Override @@ -512,9 +512,9 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { @Override public void onSetCallState(CallSpec callSpec) { if (callSpec.command == CallSpec.CALL_INCOMING) - sendNotification(DaFitConstants.NOTIFICATION_TYPE_CALL, NotificationUtils.getPreferredTextFor(callSpec)); + sendNotification(MoyoungConstants.NOTIFICATION_TYPE_CALL, NotificationUtils.getPreferredTextFor(callSpec)); else - sendNotification(DaFitConstants.NOTIFICATION_TYPE_CALL_OFF_HOOK, ""); + sendNotification(MoyoungConstants.NOTIFICATION_TYPE_CALL_OFF_HOOK, ""); } @Override @@ -524,9 +524,9 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { private void setTime(TransactionBuilder builder) { ByteBuffer buffer = ByteBuffer.allocate(5); - buffer.putInt(DaFitConstants.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... buffer.put((byte)8); // I guess this means GMT+8 but changing it has no effect at all (it was hardcoded in the original app too) - sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_SYNC_TIME, buffer.array())); + sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_SYNC_TIME, buffer.array())); } @Override @@ -623,7 +623,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { else repeat = 2; buffer.put(repeat); - sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_SET_ALARM_CLOCK, buffer.array())); + sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_SET_ALARM_CLOCK, buffer.array())); } builder.queue(getQueue()); } catch (IOException e) { @@ -715,18 +715,18 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { User user = DBHelper.getUser(dbHandler.getDaoSession()); Device device = DBHelper.getDevice(getDevice(), dbHandler.getDaoSession()); - DaFitSampleProvider provider = new DaFitSampleProvider(getDevice(), dbHandler.getDaoSession()); + MoyoungSampleProvider provider = new MoyoungSampleProvider(getDevice(), dbHandler.getDaoSession()); int currentSampleTimestamp = (int)(Calendar.getInstance().getTimeInMillis() / 1000); - DaFitActivitySample sample = new DaFitActivitySample(); + MoyoungActivitySample sample = new MoyoungActivitySample(); sample.setDevice(device); sample.setUser(user); sample.setProvider(provider); sample.setTimestamp(currentSampleTimestamp); - sample.setRawKind(DaFitSampleProvider.ACTIVITY_NOT_MEASURED); - sample.setDataSource(DaFitSampleProvider.SOURCE_STEPS_IDLE); + sample.setRawKind(MoyoungSampleProvider.ACTIVITY_NOT_MEASURED); + sample.setDataSource(MoyoungSampleProvider.SOURCE_STEPS_IDLE); sample.setBatteryLevel(batteryCmd.level); sample.setSteps(0); @@ -768,7 +768,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { User user = DBHelper.getUser(dbHandler.getDaoSession()); Device device = DBHelper.getDevice(getDevice(), dbHandler.getDaoSession()); - DaFitSampleProvider provider = new DaFitSampleProvider(getDevice(), dbHandler.getDaoSession()); + MoyoungSampleProvider provider = new MoyoungSampleProvider(getDevice(), dbHandler.getDaoSession()); Calendar thisSample = Calendar.getInstance(); if (daysAgo != 0) @@ -796,7 +796,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { int previousSteps = 0; int previousDistance = 0; int previousCalories = 0; - for (DaFitActivitySample sample : provider.getAllActivitySamples(startOfDayTimestamp, thisSampleTimestamp)) + for (MoyoungActivitySample sample : provider.getAllActivitySamples(startOfDayTimestamp, thisSampleTimestamp)) { if (sample.getSteps() != ActivitySample.NOT_MEASURED) previousSteps += sample.getSteps(); @@ -816,14 +816,14 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { } else if (newSteps != 0 || newDistance != 0 || newCalories != 0 || daysAgo == 0) { - DaFitActivitySample sample = new DaFitActivitySample(); + MoyoungActivitySample sample = new MoyoungActivitySample(); sample.setDevice(device); sample.setUser(user); sample.setProvider(provider); sample.setTimestamp(thisSampleTimestamp); - sample.setRawKind(DaFitSampleProvider.ACTIVITY_NOT_MEASURED); - sample.setDataSource(daysAgo == 0 ? DaFitSampleProvider.SOURCE_STEPS_REALTIME : DaFitSampleProvider.SOURCE_STEPS_SUMMARY); + sample.setRawKind(MoyoungSampleProvider.ACTIVITY_NOT_MEASURED); + sample.setDataSource(daysAgo == 0 ? MoyoungSampleProvider.SOURCE_STEPS_REALTIME : MoyoungSampleProvider.SOURCE_STEPS_SUMMARY); sample.setBatteryLevel(ActivitySample.NOT_MEASURED); sample.setSteps(newSteps); @@ -857,7 +857,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { if (data.length % 3 != 0) throw new IllegalArgumentException(); - int prevActivityType = DaFitSampleProvider.ACTIVITY_SLEEP_START; + int prevActivityType = MoyoungSampleProvider.ACTIVITY_SLEEP_START; int prevSampleTimestamp = -1; for(int i = 0; i < data.length / 3; i++) @@ -897,7 +897,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { User user = DBHelper.getUser(dbHandler.getDaoSession()); Device device = DBHelper.getDevice(getDevice(), dbHandler.getDaoSession()); - DaFitSampleProvider provider = new DaFitSampleProvider(getDevice(), dbHandler.getDaoSession()); + MoyoungSampleProvider provider = new MoyoungSampleProvider(getDevice(), dbHandler.getDaoSession()); Calendar thisSample = Calendar.getInstance(); thisSample.add(Calendar.HOUR_OF_DAY, 4); // the clock assumes the sleep day changes at 20:00, so move the time forward to make the day correct @@ -911,24 +911,24 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { int thisSampleTimestamp = (int) (thisSample.getTimeInMillis() / 1000); int activityType; - if (type == DaFitConstants.SLEEP_SOBER) - activityType = DaFitSampleProvider.ACTIVITY_SLEEP_END; - else if (type == DaFitConstants.SLEEP_LIGHT) - activityType = DaFitSampleProvider.ACTIVITY_SLEEP_LIGHT; - else if (type == DaFitConstants.SLEEP_RESTFUL) - activityType = DaFitSampleProvider.ACTIVITY_SLEEP_RESTFUL; + if (type == MoyoungConstants.SLEEP_SOBER) + activityType = MoyoungSampleProvider.ACTIVITY_SLEEP_END; + else if (type == MoyoungConstants.SLEEP_LIGHT) + activityType = MoyoungSampleProvider.ACTIVITY_SLEEP_LIGHT; + else if (type == MoyoungConstants.SLEEP_RESTFUL) + activityType = MoyoungSampleProvider.ACTIVITY_SLEEP_RESTFUL; else throw new IllegalArgumentException("Invalid sleep type"); // Insert the end of previous segment sample - DaFitActivitySample prevSegmentSample = new DaFitActivitySample(); + MoyoungActivitySample prevSegmentSample = new MoyoungActivitySample(); prevSegmentSample.setDevice(device); prevSegmentSample.setUser(user); prevSegmentSample.setProvider(provider); prevSegmentSample.setTimestamp(thisSampleTimestamp - 1); prevSegmentSample.setRawKind(prevActivityType); - prevSegmentSample.setDataSource(DaFitSampleProvider.SOURCE_SLEEP_SUMMARY); + prevSegmentSample.setDataSource(MoyoungSampleProvider.SOURCE_SLEEP_SUMMARY); prevSegmentSample.setBatteryLevel(ActivitySample.NOT_MEASURED); prevSegmentSample.setSteps(ActivitySample.NOT_MEASURED); @@ -943,14 +943,14 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { addGBActivitySampleIfNotExists(provider, prevSegmentSample); // Insert the start of new segment sample - DaFitActivitySample nextSegmentSample = new DaFitActivitySample(); + MoyoungActivitySample nextSegmentSample = new MoyoungActivitySample(); nextSegmentSample.setDevice(device); nextSegmentSample.setUser(user); nextSegmentSample.setProvider(provider); nextSegmentSample.setTimestamp(thisSampleTimestamp); nextSegmentSample.setRawKind(activityType); - nextSegmentSample.setDataSource(DaFitSampleProvider.SOURCE_SLEEP_SUMMARY); + nextSegmentSample.setDataSource(MoyoungSampleProvider.SOURCE_SLEEP_SUMMARY); nextSegmentSample.setBatteryLevel(ActivitySample.NOT_MEASURED); nextSegmentSample.setSteps(ActivitySample.NOT_MEASURED); @@ -965,12 +965,12 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { addGBActivitySampleIfNotExists(provider, nextSegmentSample); // Set the activity type on all samples in this time period - if (prevActivityType != DaFitSampleProvider.ACTIVITY_SLEEP_START) + if (prevActivityType != MoyoungSampleProvider.ACTIVITY_SLEEP_START) provider.updateActivityInRange(prevSampleTimestamp, thisSampleTimestamp, prevActivityType); prevActivityType = activityType; - if (prevActivityType == DaFitSampleProvider.ACTIVITY_SLEEP_END) - prevActivityType = DaFitSampleProvider.ACTIVITY_SLEEP_START; + if (prevActivityType == MoyoungSampleProvider.ACTIVITY_SLEEP_END) + prevActivityType = MoyoungSampleProvider.ACTIVITY_SLEEP_START; prevSampleTimestamp = thisSampleTimestamp; } catch (Exception ex) { ex.printStackTrace(); @@ -992,8 +992,8 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { ByteBuffer buffer = ByteBuffer.wrap(data, 24 * i, 24); buffer.order(ByteOrder.LITTLE_ENDIAN); - Date startTime = DaFitConstants.WatchTimeToLocalTime(buffer.getInt()); - Date endTime = DaFitConstants.WatchTimeToLocalTime(buffer.getInt()); + Date startTime = MoyoungConstants.WatchTimeToLocalTime(buffer.getInt()); + Date endTime = MoyoungConstants.WatchTimeToLocalTime(buffer.getInt()); int validTime = buffer.getShort(); byte num = buffer.get(); // == i byte type = buffer.get(); @@ -1011,7 +1011,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { User user = DBHelper.getUser(dbHandler.getDaoSession()); Device device = DBHelper.getDevice(getDevice(), dbHandler.getDaoSession()); - DaFitSampleProvider provider = new DaFitSampleProvider(getDevice(), dbHandler.getDaoSession()); + MoyoungSampleProvider provider = new MoyoungSampleProvider(getDevice(), dbHandler.getDaoSession()); BaseActivitySummaryDao summaryDao = provider.getSession().getBaseActivitySummaryDao(); QueryBuilder qb = summaryDao.queryBuilder(); @@ -1033,21 +1033,21 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { int gbType = provider.normalizeType(type); String name; - if (type == DaFitSampleProvider.ACTIVITY_TRAINING_ROPE) + if (type == MoyoungSampleProvider.ACTIVITY_TRAINING_ROPE) name = "Rope"; - else if (type == DaFitSampleProvider.ACTIVITY_TRAINING_BADMINTON) + else if (type == MoyoungSampleProvider.ACTIVITY_TRAINING_BADMINTON) name = "Badminton"; - else if (type == DaFitSampleProvider.ACTIVITY_TRAINING_BASKETBALL) + else if (type == MoyoungSampleProvider.ACTIVITY_TRAINING_BASKETBALL) name = "Basketball"; - else if (type == DaFitSampleProvider.ACTIVITY_TRAINING_FOOTBALL) + else if (type == MoyoungSampleProvider.ACTIVITY_TRAINING_FOOTBALL) name = "Football"; - else if (type == DaFitSampleProvider.ACTIVITY_TRAINING_MOUNTAINEERING) + else if (type == MoyoungSampleProvider.ACTIVITY_TRAINING_MOUNTAINEERING) name = "Mountaineering"; - else if (type == DaFitSampleProvider.ACTIVITY_TRAINING_TENNIS) + else if (type == MoyoungSampleProvider.ACTIVITY_TRAINING_TENNIS) name = "Tennis"; - else if (type == DaFitSampleProvider.ACTIVITY_TRAINING_RUGBY) + else if (type == MoyoungSampleProvider.ACTIVITY_TRAINING_RUGBY) name = "Rugby"; - else if (type == DaFitSampleProvider.ACTIVITY_TRAINING_GOLF) + else if (type == MoyoungSampleProvider.ACTIVITY_TRAINING_GOLF) name = "Golf"; else name = ActivityKind.asString(gbType, getContext()); @@ -1070,10 +1070,10 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { } } - private void addGBActivitySampleIfNotExists(DaFitSampleProvider provider, DaFitActivitySample sample) + private void addGBActivitySampleIfNotExists(MoyoungSampleProvider provider, MoyoungActivitySample sample) { boolean alreadyHaveThisSample = false; - for (DaFitActivitySample sample2 : provider.getAllActivitySamples(sample.getTimestamp() - 1, sample.getTimestamp() + 1)) + for (MoyoungActivitySample sample2 : provider.getAllActivitySamples(sample.getTimestamp() - 1, sample.getTimestamp() + 1)) { if (sample2.getTimestamp() == sample2.getTimestamp() && sample2.getRawKind() == sample.getRawKind()) alreadyHaveThisSample = true; @@ -1093,7 +1093,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { try { TransactionBuilder builder = performInitialized("shutdown"); - sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_SHUTDOWN, new byte[] { -1 })); + sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_SHUTDOWN, new byte[] { -1 })); builder.queue(getQueue()); } catch (IOException e) { e.printStackTrace(); @@ -1104,7 +1104,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { { try { TransactionBuilder builder = performInitialized("onHeartRateTest"); - sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_TRIGGER_MEASURE_HEARTRATE, new byte[] { start ? (byte)0 : (byte)-1 })); + sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_TRIGGER_MEASURE_HEARTRATE, new byte[] { start ? (byte)0 : (byte)-1 })); builder.queue(getQueue()); } catch (IOException e) { e.printStackTrace(); @@ -1154,7 +1154,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { { try { TransactionBuilder builder = performInitialized("onFindDevice"); - sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_FIND_MY_WATCH, new byte[0])); + sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_FIND_MY_WATCH, new byte[0])); builder.queue(getQueue()); } catch (IOException e) { e.printStackTrace(); @@ -1187,9 +1187,9 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { } @SuppressWarnings("unchecked") - private T getSetting(String id) { - DaFitDeviceCoordinator coordinator = (DaFitDeviceCoordinator) DeviceHelper.getInstance().getCoordinator(getDevice()); - for(DaFitSetting setting : coordinator.getSupportedSettings()) + private T getSetting(String id) { + MoyoungDeviceCoordinator coordinator = (MoyoungDeviceCoordinator) DeviceHelper.getInstance().getCoordinator(getDevice()); + for(MoyoungSetting setting : coordinator.getSupportedSettings()) { if (setting.name.equals(id)) return (T) setting; @@ -1210,12 +1210,12 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { return cal; } - private void sendSetting(TransactionBuilder builder, DaFitSetting setting, T newValue) + private void sendSetting(TransactionBuilder builder, MoyoungSetting setting, T newValue) { - sendPacket(builder, DaFitPacketOut.buildPacket(setting.cmdSet, setting.encode(newValue))); + sendPacket(builder, MoyoungPacketOut.buildPacket(setting.cmdSet, setting.encode(newValue))); } - private void sendSetting(DaFitSetting setting, T newValue) + private void sendSetting(MoyoungSetting setting, T newValue) { try { TransactionBuilder builder = performInitialized("sendSetting"); @@ -1226,16 +1226,16 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { } } - private Set queriedSettings = new HashSet<>(); + private Set queriedSettings = new HashSet<>(); - private void querySetting(DaFitSetting setting) + private void querySetting(MoyoungSetting setting) { if (queriedSettings.contains(setting)) return; try { TransactionBuilder builder = performInitialized("querySetting"); - sendPacket(builder, DaFitPacketOut.buildPacket(setting.cmdQuery, new byte[0])); + sendPacket(builder, MoyoungPacketOut.buildPacket(setting.cmdQuery, new byte[0])); builder.queue(getQueue()); queriedSettings.add(setting); } catch (IOException e) { @@ -1263,11 +1263,11 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { case DeviceSettingsPreferenceConst.PREF_TIMEFORMAT: String timeSystemPref = prefs.getString(DeviceSettingsPreferenceConst.PREF_TIMEFORMAT, getContext().getString(R.string.p_timeformat_24h)); - DaFitEnumTimeSystem timeSystem; + MoyoungEnumTimeSystem timeSystem; if (timeSystemPref.equals(getContext().getString(R.string.p_timeformat_24h))) - timeSystem = DaFitEnumTimeSystem.TIME_SYSTEM_24; + timeSystem = MoyoungEnumTimeSystem.TIME_SYSTEM_24; else if (timeSystemPref.equals(getContext().getString(R.string.p_timeformat_am_pm))) - timeSystem = DaFitEnumTimeSystem.TIME_SYSTEM_12; + timeSystem = MoyoungEnumTimeSystem.TIME_SYSTEM_12; else throw new IllegalArgumentException(); @@ -1277,36 +1277,36 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { case DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM: String metricSystemPref = prefs.getString(DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM, getContext().getString(R.string.p_unit_metric)); - DaFitEnumMetricSystem metricSystem; + MoyoungEnumMetricSystem metricSystem; if (metricSystemPref.equals(getContext().getString(R.string.p_unit_metric))) - metricSystem = DaFitEnumMetricSystem.METRIC_SYSTEM; + metricSystem = MoyoungEnumMetricSystem.METRIC_SYSTEM; else if (metricSystemPref.equals(getContext().getString(R.string.p_unit_imperial))) - metricSystem = DaFitEnumMetricSystem.IMPERIAL_SYSTEM; + metricSystem = MoyoungEnumMetricSystem.IMPERIAL_SYSTEM; else throw new IllegalArgumentException(); sendSetting(getSetting("METRIC_SYSTEM"), metricSystem); break; - case DaFitConstants.PREF_WATCH_FACE: - String watchFacePref = prefs.getString(DaFitConstants.PREF_WATCH_FACE, String.valueOf(1)); + case MoyoungConstants.PREF_WATCH_FACE: + String watchFacePref = prefs.getString(MoyoungConstants.PREF_WATCH_FACE, String.valueOf(1)); byte watchFace = Byte.valueOf(watchFacePref); sendSetting(getSetting("DISPLAY_WATCH_FACE"), watchFace); break; - case DaFitConstants.PREF_LANGUAGE: - String languagePref = prefs.getString(DaFitConstants.PREF_LANGUAGE, - String.valueOf(DaFitEnumLanguage.LANGUAGE_ENGLISH.value())); + case MoyoungConstants.PREF_LANGUAGE: + String languagePref = prefs.getString(MoyoungConstants.PREF_LANGUAGE, + String.valueOf(MoyoungEnumLanguage.LANGUAGE_ENGLISH.value())); byte languageNum = Byte.valueOf(languagePref); - DaFitSettingEnum languageSetting = getSetting("DEVICE_LANGUAGE"); + MoyoungSettingEnum languageSetting = getSetting("DEVICE_LANGUAGE"); sendSetting(languageSetting, languageSetting.findByValue(languageNum)); break; - case DaFitConstants.PREF_DEVICE_VERSION: - String versionPref = prefs.getString(DaFitConstants.PREF_DEVICE_VERSION, - String.valueOf(DaFitEnumDeviceVersion.INTERNATIONAL_EDITION.value())); + case MoyoungConstants.PREF_DEVICE_VERSION: + String versionPref = prefs.getString(MoyoungConstants.PREF_DEVICE_VERSION, + String.valueOf(MoyoungEnumDeviceVersion.INTERNATIONAL_EDITION.value())); byte versionNum = Byte.valueOf(versionPref); - DaFitSettingEnum versionSetting = getSetting("DEVICE_VERSION"); + MoyoungSettingEnum versionSetting = getSetting("DEVICE_VERSION"); sendSetting(versionSetting, versionSetting.findByValue(versionNum)); break; @@ -1319,13 +1319,13 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { Calendar doNotDisturbStart = getTimePref(prefs, MiBandConst.PREF_DO_NOT_DISTURB_START, "01:00"); Calendar doNotDisturbEnd = getTimePref(prefs, MiBandConst.PREF_DO_NOT_DISTURB_END, "06:00"); - DaFitSettingTimeRange.TimeRange doNotDisturb; + MoyoungSettingTimeRange.TimeRange doNotDisturb; if (doNotDisturbEnabled) - doNotDisturb = new DaFitSettingTimeRange.TimeRange( + 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 DaFitSettingTimeRange.TimeRange((byte)0, (byte)0, (byte)0, (byte)0); + doNotDisturb = new MoyoungSettingTimeRange.TimeRange((byte)0, (byte)0, (byte)0, (byte)0); sendSetting(getSetting("DO_NOT_DISTURB_TIME"), doNotDisturb); break; @@ -1340,34 +1340,34 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { Calendar quickViewStart = getTimePref(prefs, HuamiConst.PREF_DISPLAY_ON_LIFT_START, "00:00"); Calendar quickViewEnd = getTimePref(prefs, HuamiConst.PREF_DISPLAY_ON_LIFT_END, "00:00"); - DaFitSettingTimeRange.TimeRange quickViewTime; + MoyoungSettingTimeRange.TimeRange quickViewTime; if (quickViewEnabled && quickViewScheduled) - quickViewTime = new DaFitSettingTimeRange.TimeRange( + 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 DaFitSettingTimeRange.TimeRange((byte)0, (byte)0, (byte)0, (byte)0); + 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 DaFitConstants.PREF_SEDENTARY_REMINDER: - String sedentaryReminderPref = prefs.getString(DaFitConstants.PREF_SEDENTARY_REMINDER, "off"); + case MoyoungConstants.PREF_SEDENTARY_REMINDER: + String sedentaryReminderPref = prefs.getString(MoyoungConstants.PREF_SEDENTARY_REMINDER, "off"); boolean sedentaryReminderEnabled = !sedentaryReminderPref.equals("off"); sendSetting(getSetting("SEDENTARY_REMINDER"), sedentaryReminderEnabled); break; - case DaFitConstants.PREF_SEDENTARY_REMINDER_PERIOD: - case DaFitConstants.PREF_SEDENTARY_REMINDER_STEPS: - case DaFitConstants.PREF_SEDENTARY_REMINDER_START: - case DaFitConstants.PREF_SEDENTARY_REMINDER_END: - byte sedentaryPeriod = (byte) prefs.getInt(DaFitConstants.PREF_SEDENTARY_REMINDER_PERIOD, 30); - byte sedentarySteps = (byte) prefs.getInt(DaFitConstants.PREF_SEDENTARY_REMINDER_STEPS, 100); - byte sedentaryStart = (byte) prefs.getInt(DaFitConstants.PREF_SEDENTARY_REMINDER_START, 10); - byte sedentaryEnd = (byte) prefs.getInt(DaFitConstants.PREF_SEDENTARY_REMINDER_END, 22); + case MoyoungConstants.PREF_SEDENTARY_REMINDER_PERIOD: + case MoyoungConstants.PREF_SEDENTARY_REMINDER_STEPS: + case MoyoungConstants.PREF_SEDENTARY_REMINDER_START: + case MoyoungConstants.PREF_SEDENTARY_REMINDER_END: + byte sedentaryPeriod = (byte) prefs.getInt(MoyoungConstants.PREF_SEDENTARY_REMINDER_PERIOD, 30); + byte sedentarySteps = (byte) prefs.getInt(MoyoungConstants.PREF_SEDENTARY_REMINDER_STEPS, 100); + byte sedentaryStart = (byte) prefs.getInt(MoyoungConstants.PREF_SEDENTARY_REMINDER_START, 10); + byte sedentaryEnd = (byte) prefs.getInt(MoyoungConstants.PREF_SEDENTARY_REMINDER_END, 22); sendSetting(getSetting("REMINDERS_TO_MOVE_PERIOD"), - new DaFitSettingRemindersToMove.RemindersToMove(sedentaryPeriod, sedentarySteps, sedentaryStart, sedentaryEnd)); + new MoyoungSettingRemindersToMove.RemindersToMove(sedentaryPeriod, sedentarySteps, sedentaryStart, sedentaryEnd)); break; } @@ -1401,15 +1401,15 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { querySetting(getSetting("METRIC_SYSTEM")); break; - case DaFitConstants.PREF_WATCH_FACE: + case MoyoungConstants.PREF_WATCH_FACE: querySetting(getSetting("DISPLAY_WATCH_FACE")); break; - case DaFitConstants.PREF_LANGUAGE: + case MoyoungConstants.PREF_LANGUAGE: querySetting(getSetting("DEVICE_LANGUAGE")); break; - case DaFitConstants.PREF_DEVICE_VERSION: + case MoyoungConstants.PREF_DEVICE_VERSION: querySetting(getSetting("DEVICE_VERSION")); break; @@ -1426,14 +1426,14 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { querySetting(getSetting("QUICK_VIEW_TIME")); break; - case DaFitConstants.PREF_SEDENTARY_REMINDER: + case MoyoungConstants.PREF_SEDENTARY_REMINDER: querySetting(getSetting("SEDENTARY_REMINDER")); break; - case DaFitConstants.PREF_SEDENTARY_REMINDER_PERIOD: - case DaFitConstants.PREF_SEDENTARY_REMINDER_STEPS: - case DaFitConstants.PREF_SEDENTARY_REMINDER_START: - case DaFitConstants.PREF_SEDENTARY_REMINDER_END: + case MoyoungConstants.PREF_SEDENTARY_REMINDER_PERIOD: + case MoyoungConstants.PREF_SEDENTARY_REMINDER_STEPS: + case MoyoungConstants.PREF_SEDENTARY_REMINDER_START: + case MoyoungConstants.PREF_SEDENTARY_REMINDER_END: querySetting(getSetting("REMINDERS_TO_MOVE_PERIOD")); break; default: @@ -1446,7 +1446,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { evaluateGBDeviceEvent(configReadEvent); } - public void onReadConfigurationDone(DaFitSetting setting, Object value, byte[] data) + public void onReadConfigurationDone(MoyoungSetting setting, Object value, byte[] data) { Log.i("CONFIG", setting.name + " = " + value); Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress())); @@ -1454,20 +1454,20 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { SharedPreferences.Editor prefsEditor = prefs.getPreferences().edit(); switch (setting.name) { case "TIME_SYSTEM": - DaFitEnumTimeSystem timeSystem = (DaFitEnumTimeSystem) value; - if (timeSystem == DaFitEnumTimeSystem.TIME_SYSTEM_24) + MoyoungEnumTimeSystem timeSystem = (MoyoungEnumTimeSystem) value; + if (timeSystem == MoyoungEnumTimeSystem.TIME_SYSTEM_24) changedProperties.put(DeviceSettingsPreferenceConst.PREF_TIMEFORMAT, getContext().getString(R.string.p_timeformat_24h)); - else if (timeSystem == DaFitEnumTimeSystem.TIME_SYSTEM_12) + else if (timeSystem == MoyoungEnumTimeSystem.TIME_SYSTEM_12) changedProperties.put(DeviceSettingsPreferenceConst.PREF_TIMEFORMAT, getContext().getString(R.string.p_timeformat_am_pm)); else throw new IllegalArgumentException("Invalid value"); break; case "METRIC_SYSTEM": - DaFitEnumMetricSystem metricSystem = (DaFitEnumMetricSystem) value; - if (metricSystem == DaFitEnumMetricSystem.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 == DaFitEnumMetricSystem.IMPERIAL_SYSTEM) + else if (metricSystem == MoyoungEnumMetricSystem.IMPERIAL_SYSTEM) changedProperties.put(DeviceSettingsPreferenceConst.PREF_MEASUREMENTSYSTEM, getContext().getString(R.string.p_unit_imperial)); else throw new IllegalArgumentException("Invalid value"); @@ -1475,26 +1475,26 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { case "DISPLAY_WATCH_FACE": byte watchFace = (Byte) value; - changedProperties.put(DaFitConstants.PREF_WATCH_FACE, String.valueOf(watchFace)); + changedProperties.put(MoyoungConstants.PREF_WATCH_FACE, String.valueOf(watchFace)); break; case "DEVICE_LANGUAGE": - DaFitEnumLanguage language = (DaFitEnumLanguage) value; - changedProperties.put(DaFitConstants.PREF_LANGUAGE, String.valueOf(language.value())); - DaFitEnumLanguage[] supportedLanguages = ((DaFitSettingLanguage) setting).decodeSupportedValues(data); + MoyoungEnumLanguage language = (MoyoungEnumLanguage) value; + changedProperties.put(MoyoungConstants.PREF_LANGUAGE, String.valueOf(language.value())); + MoyoungEnumLanguage[] supportedLanguages = ((MoyoungSettingLanguage) setting).decodeSupportedValues(data); Set supportedLanguagesList = new HashSet<>(); - for(DaFitEnumLanguage supportedLanguage : supportedLanguages) + for(MoyoungEnumLanguage supportedLanguage : supportedLanguages) supportedLanguagesList.add(String.valueOf(supportedLanguage.value())); - prefsEditor.putStringSet(DaFitConstants.PREF_LANGUAGE_SUPPORT, supportedLanguagesList); + prefsEditor.putStringSet(MoyoungConstants.PREF_LANGUAGE_SUPPORT, supportedLanguagesList); break; case "DEVICE_VERSION": - DaFitEnumDeviceVersion deviceVersion = (DaFitEnumDeviceVersion) value; - changedProperties.put(DaFitConstants.PREF_DEVICE_VERSION, String.valueOf(deviceVersion.value())); + MoyoungEnumDeviceVersion deviceVersion = (MoyoungEnumDeviceVersion) value; + changedProperties.put(MoyoungConstants.PREF_DEVICE_VERSION, String.valueOf(deviceVersion.value())); break; case "DO_NOT_DISTURB_TIME": - DaFitSettingTimeRange.TimeRange doNotDisturb = (DaFitSettingTimeRange.TimeRange) value; + 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); @@ -1512,7 +1512,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { 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)); - DaFitSettingTimeRange.TimeRange quickViewTime = (DaFitSettingTimeRange.TimeRange) value; + MoyoungSettingTimeRange.TimeRange quickViewTime = (MoyoungSettingTimeRange.TimeRange) value; if (quickViewEnabled2) { if (quickViewTime.start_h == 0 && quickViewTime.start_m == 0 && @@ -1527,15 +1527,15 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { case "SEDENTARY_REMINDER": boolean sedentaryReminderEnabled = (Boolean) value; - changedProperties.put(DaFitConstants.PREF_SEDENTARY_REMINDER, sedentaryReminderEnabled ? "on": "off"); + changedProperties.put(MoyoungConstants.PREF_SEDENTARY_REMINDER, sedentaryReminderEnabled ? "on": "off"); break; case "REMINDERS_TO_MOVE_PERIOD": - DaFitSettingRemindersToMove.RemindersToMove remindersToMove = (DaFitSettingRemindersToMove.RemindersToMove) value; - changedProperties.put(DaFitConstants.PREF_SEDENTARY_REMINDER_PERIOD, String.valueOf(remindersToMove.period)); - changedProperties.put(DaFitConstants.PREF_SEDENTARY_REMINDER_STEPS, String.valueOf(remindersToMove.steps)); - changedProperties.put(DaFitConstants.PREF_SEDENTARY_REMINDER_START, String.valueOf(remindersToMove.start_h)); - changedProperties.put(DaFitConstants.PREF_SEDENTARY_REMINDER_END, String.valueOf(remindersToMove.end_h)); + MoyoungSettingRemindersToMove.RemindersToMove remindersToMove = (MoyoungSettingRemindersToMove.RemindersToMove) value; + changedProperties.put(MoyoungConstants.PREF_SEDENTARY_REMINDER_PERIOD, String.valueOf(remindersToMove.period)); + changedProperties.put(MoyoungConstants.PREF_SEDENTARY_REMINDER_STEPS, String.valueOf(remindersToMove.steps)); + changedProperties.put(MoyoungConstants.PREF_SEDENTARY_REMINDER_START, String.valueOf(remindersToMove.start_h)); + changedProperties.put(MoyoungConstants.PREF_SEDENTARY_REMINDER_END, String.valueOf(remindersToMove.end_h)); break; } for (Map.Entry property : changedProperties.entrySet()) @@ -1564,7 +1564,7 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { try { TransactionBuilder builder = performInitialized("onSendWeather"); - DaFitWeatherToday weatherToday = new DaFitWeatherToday(weatherSpec); + MoyoungWeatherToday weatherToday = new MoyoungWeatherToday(weatherSpec); ByteBuffer packetWeatherToday = ByteBuffer.allocate(weatherToday.pm25 != null ? 21 : 19); packetWeatherToday.put(weatherToday.pm25 != null ? (byte)1 : (byte)0); packetWeatherToday.put(weatherToday.conditionId); @@ -1573,21 +1573,21 @@ public class DaFitDeviceSupport extends AbstractBTLEDeviceSupport { packetWeatherToday.putShort(weatherToday.pm25); packetWeatherToday.put(weatherToday.lunar_or_festival.getBytes("unicodebigunmarked")); packetWeatherToday.put(weatherToday.city.getBytes("unicodebigunmarked")); - sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_SET_WEATHER_TODAY, packetWeatherToday.array())); + sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_SET_WEATHER_TODAY, packetWeatherToday.array())); ByteBuffer packetWeatherForecast = ByteBuffer.allocate(7 * 3); for(int i = 0; i < 7; i++) { - DaFitWeatherForecast forecast; + MoyoungWeatherForecast forecast; if (weatherSpec.forecasts.size() > i) - forecast = new DaFitWeatherForecast(weatherSpec.forecasts.get(i)); + forecast = new MoyoungWeatherForecast(weatherSpec.forecasts.get(i)); else - forecast = new DaFitWeatherForecast(DaFitConstants.WEATHER_HAZE, (byte)-100, (byte)-100); // I don't think there is a way to send less (my watch shows only tomorrow anyway...) + forecast = new MoyoungWeatherForecast(MoyoungConstants.WEATHER_HAZE, (byte)-100, (byte)-100); // I don't think there is a way to send less (my watch shows only tomorrow anyway...) packetWeatherForecast.put(forecast.conditionId); packetWeatherForecast.put(forecast.minTemp); packetWeatherForecast.put(forecast.maxTemp); } - sendPacket(builder, DaFitPacketOut.buildPacket(DaFitConstants.CMD_SET_WEATHER_FUTURE, packetWeatherForecast.array())); + sendPacket(builder, MoyoungPacketOut.buildPacket(MoyoungConstants.CMD_SET_WEATHER_FUTURE, packetWeatherForecast.array())); builder.queue(getQueue()); } catch (IOException e) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/dafit/DaFitPacket.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/moyoung/MoyoungPacket.java similarity index 89% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/dafit/DaFitPacket.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/moyoung/MoyoungPacket.java index 3550968b2..dda8ae912 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/dafit/DaFitPacket.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/moyoung/MoyoungPacket.java @@ -14,9 +14,9 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.dafit; +package nodomain.freeyourgadget.gadgetbridge.service.devices.moyoung; -public class DaFitPacket { +public class MoyoungPacket { protected byte[] packet; protected int position = 0; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/dafit/DaFitPacketIn.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/moyoung/MoyoungPacketIn.java similarity index 91% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/dafit/DaFitPacketIn.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/moyoung/MoyoungPacketIn.java index 9c60e6d1e..e3e93f900 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/dafit/DaFitPacketIn.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/moyoung/MoyoungPacketIn.java @@ -14,9 +14,8 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.dafit; +package nodomain.freeyourgadget.gadgetbridge.service.devices.moyoung; -import android.util.Log; import android.util.Pair; import androidx.annotation.NonNull; @@ -33,8 +32,8 @@ import nodomain.freeyourgadget.gadgetbridge.Logging; *
  * {@code
  * if(packetIn.putFragment(fragment)) {
- *     Pair packet = DaFitPacketIn.parsePacket(packetIn.getPacket());
- *     packetIn = new DaFitPacketIn();
+ *     Pair packet = MoyoungPacketIn.parsePacket(packetIn.getPacket());
+ *     packetIn = new MoyoungPacketIn();
  *     if (packet != null) {
  *         byte packetType = packet.first;
  *         byte[] payload = packet.second;
@@ -43,10 +42,10 @@ import nodomain.freeyourgadget.gadgetbridge.Logging;
  * }
  * 
*/ -public class DaFitPacketIn extends DaFitPacket { - private static final Logger LOG = LoggerFactory.getLogger(DaFitPacketIn.class); +public class MoyoungPacketIn extends MoyoungPacket { + private static final Logger LOG = LoggerFactory.getLogger(MoyoungPacketIn.class); - public DaFitPacketIn() + public MoyoungPacketIn() { } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/dafit/DaFitPacketOut.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/moyoung/MoyoungPacketOut.java similarity index 88% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/dafit/DaFitPacketOut.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/moyoung/MoyoungPacketOut.java index a1c9b8bb2..18efef729 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/dafit/DaFitPacketOut.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/moyoung/MoyoungPacketOut.java @@ -14,7 +14,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.dafit; +package nodomain.freeyourgadget.gadgetbridge.service.devices.moyoung; import androidx.annotation.NonNull; @@ -24,15 +24,15 @@ import androidx.annotation.NonNull; * Usage: *
  * {@code
- * DaFitPacketOut packetOut = new DaFitPacketOut(DaFitPacketOut.buildPacket(type, payload));
+ * MoyoungPacketOut packetOut = new MoyoungPacketOut(MoyoungPacketOut.buildPacket(type, payload));
  * byte[] fragment = new byte[MTU];
  * while(packetOut.getFragment(fragment))
  *     send(fragment);
  * }
  * 
*/ -public class DaFitPacketOut extends DaFitPacket { - public DaFitPacketOut(byte[] packet) +public class MoyoungPacketOut extends MoyoungPacket { + public MoyoungPacketOut(byte[] packet) { this.packet = packet; } @@ -64,7 +64,7 @@ public class DaFitPacketOut extends DaFitPacket { byte[] packet = new byte[payload.length + 5]; packet[0] = (byte)0xFE; packet[1] = (byte)0xEA; - if (DaFitDeviceSupport.MTU == 20) + if (MoyoungDeviceSupport.MTU == 20) { packet[2] = 16; packet[3] = (byte)(packet.length & 0xFF); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/dafit/QuerySettingsOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/moyoung/QuerySettingsOperation.java similarity index 76% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/dafit/QuerySettingsOperation.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/moyoung/QuerySettingsOperation.java index 35ecec657..5ac5e87c1 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/dafit/QuerySettingsOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/moyoung/QuerySettingsOperation.java @@ -14,7 +14,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.dafit; +package nodomain.freeyourgadget.gadgetbridge.service.devices.moyoung; import android.bluetooth.BluetoothGatt; import android.bluetooth.BluetoothGattCharacteristic; @@ -27,31 +27,31 @@ import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.UUID; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.DaFitConstants; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.DaFitDeviceCoordinator; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.settings.DaFitSetting; +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 { +public class QuerySettingsOperation extends AbstractBTLEOperation { private static final Logger LOG = LoggerFactory.getLogger(QuerySettingsOperation.class); - private final DaFitSetting[] settingsToQuery; + private final MoyoungSetting[] settingsToQuery; private boolean[] received; - private DaFitPacketIn packetIn = new DaFitPacketIn(); + private MoyoungPacketIn packetIn = new MoyoungPacketIn(); - public QuerySettingsOperation(DaFitDeviceSupport support, DaFitSetting[] settingsToQuery) { + public QuerySettingsOperation(MoyoungDeviceSupport support, MoyoungSetting[] settingsToQuery) { super(support); this.settingsToQuery = settingsToQuery; } - public QuerySettingsOperation(DaFitDeviceSupport support) { + public QuerySettingsOperation(MoyoungDeviceSupport support) { super(support); - DaFitDeviceCoordinator coordinator = (DaFitDeviceCoordinator) DeviceHelper.getInstance().getCoordinator(getDevice()); + MoyoungDeviceCoordinator coordinator = (MoyoungDeviceCoordinator) DeviceHelper.getInstance().getCoordinator(getDevice()); this.settingsToQuery = coordinator.getSupportedSettings(); } @@ -65,12 +65,12 @@ public class QuerySettingsOperation extends AbstractBTLEOperation packet = DaFitPacketIn.parsePacket(packetIn.getPacket()); - packetIn = new DaFitPacketIn(); + Pair packet = MoyoungPacketIn.parsePacket(packetIn.getPacket()); + packetIn = new MoyoungPacketIn(); if (packet != null) { byte packetType = packet.first; byte[] payload = packet.second; @@ -108,7 +108,7 @@ public class QuerySettingsOperation extends AbstractBTLEOperation. */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.dafit; +package nodomain.freeyourgadget.gadgetbridge.service.devices.moyoung; import android.bluetooth.BluetoothGatt; import android.bluetooth.BluetoothGattCharacteristic; @@ -37,10 +37,10 @@ import nodomain.freeyourgadget.gadgetbridge.Logging; import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.DaFitConstants; -import nodomain.freeyourgadget.gadgetbridge.devices.dafit.DaFitSampleProvider; +import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungConstants; +import nodomain.freeyourgadget.gadgetbridge.devices.moyoung.MoyoungSampleProvider; import nodomain.freeyourgadget.gadgetbridge.entities.Device; -import nodomain.freeyourgadget.gadgetbridge.entities.DaFitActivitySample; +import nodomain.freeyourgadget.gadgetbridge.entities.MoyoungActivitySample; import nodomain.freeyourgadget.gadgetbridge.entities.User; import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample; import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEOperation; @@ -48,7 +48,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.operations.OperationStatus; import nodomain.freeyourgadget.gadgetbridge.util.GB; -public class TrainingFinishedDataOperation extends AbstractBTLEOperation { +public class TrainingFinishedDataOperation extends AbstractBTLEOperation { private static final Logger LOG = LoggerFactory.getLogger(FetchDataOperation.class); @@ -56,9 +56,9 @@ public class TrainingFinishedDataOperation extends AbstractBTLEOperation packet = DaFitPacketIn.parsePacket(packetIn.getPacket()); - packetIn = new DaFitPacketIn(); + Pair packet = MoyoungPacketIn.parsePacket(packetIn.getPacket()); + packetIn = new MoyoungPacketIn(); if (packet != null) { byte packetType = packet.first; byte[] payload = packet.second; @@ -106,11 +106,11 @@ public class TrainingFinishedDataOperation extends AbstractBTLEOperation 1) + if (sequenceType == MoyoungConstants.ARG_TRANSMISSION_LAST && payload.length > 1) throw new IllegalArgumentException("Last packet shouldn't have any data"); data.write(payload, 1, payload.length - 1); - if (sequenceType != DaFitConstants.ARG_TRANSMISSION_LAST) + if (sequenceType != MoyoungConstants.ARG_TRANSMISSION_LAST) queryMoreData(); else processAllData(); @@ -137,7 +137,7 @@ public class TrainingFinishedDataOperation extends AbstractBTLEOperationru_RU - + Watch face 1 Watch face 2 Watch face 3 - + 1 2 3 - + Chinese edition International edition - + 0 1 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 494d79fca..964f57fd1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1821,7 +1821,6 @@ Mijia Temperature and Humidity Sensor 2 Mijia Temperature and Humidity Sensor 2 (E-ink) Mijia MHO-C303 - Da Fit Makibes HR3 Bangle.js TLW64 diff --git a/app/src/main/res/xml/devicesettings_dafit_device_version.xml b/app/src/main/res/xml/devicesettings_moyoung_device_version.xml similarity index 63% rename from app/src/main/res/xml/devicesettings_dafit_device_version.xml rename to app/src/main/res/xml/devicesettings_moyoung_device_version.xml index b50f003ad..96db58259 100644 --- a/app/src/main/res/xml/devicesettings_dafit_device_version.xml +++ b/app/src/main/res/xml/devicesettings_moyoung_device_version.xml @@ -2,9 +2,9 @@ diff --git a/app/src/main/res/xml/devicesettings_dafit_language.xml b/app/src/main/res/xml/devicesettings_moyoung_language.xml similarity index 90% rename from app/src/main/res/xml/devicesettings_dafit_language.xml rename to app/src/main/res/xml/devicesettings_moyoung_language.xml index 6eda64262..e4c18b756 100644 --- a/app/src/main/res/xml/devicesettings_dafit_language.xml +++ b/app/src/main/res/xml/devicesettings_moyoung_language.xml @@ -3,7 +3,7 @@ \ No newline at end of file diff --git a/app/src/main/res/xml/devicesettings_dafit_sedentary_reminder.xml b/app/src/main/res/xml/devicesettings_moyoung_sedentary_reminder.xml similarity index 100% rename from app/src/main/res/xml/devicesettings_dafit_sedentary_reminder.xml rename to app/src/main/res/xml/devicesettings_moyoung_sedentary_reminder.xml diff --git a/app/src/main/res/xml/devicesettings_dafit_watchface.xml b/app/src/main/res/xml/devicesettings_moyoung_watchface.xml similarity index 68% rename from app/src/main/res/xml/devicesettings_dafit_watchface.xml rename to app/src/main/res/xml/devicesettings_moyoung_watchface.xml index 731e0d49e..6b8879080 100644 --- a/app/src/main/res/xml/devicesettings_dafit_watchface.xml +++ b/app/src/main/res/xml/devicesettings_moyoung_watchface.xml @@ -3,9 +3,9 @@