1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-03 00:43:02 +01:00

Mi Band 5: Start fitness tracking on phone when workout starts on band

This commit is contained in:
José Rebelo 2022-06-04 21:22:04 +01:00 committed by vanous
parent b07cd54468
commit 2101b5840a
6 changed files with 33 additions and 0 deletions

View File

@ -116,6 +116,7 @@ public class DeviceSettingsPreferenceConst {
public static final String PREF_DO_NOT_DISTURB_AUTOMATIC = "automatic";
public static final String PREF_DO_NOT_DISTURB_SCHEDULED = "scheduled";
public static final String PREF_WORKOUT_START_ON_PHONE = "workout_start_on_phone";
public static final String PREF_WORKOUT_SEND_GPS_TO_BAND = "workout_send_gps_to_band";
public static final String PREF_FIND_PHONE = "prefs_find_phone";

View File

@ -363,6 +363,12 @@ public abstract class HuamiCoordinator extends AbstractDeviceCoordinator {
return prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB_LIFT_WRIST, false);
}
public static boolean getWorkoutStartOnPhone(String deviceAddress) {
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(deviceAddress);
return prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_WORKOUT_START_ON_PHONE, false);
}
public static boolean getWorkoutSendGpsToBand(String deviceAddress) {
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(deviceAddress);

View File

@ -115,6 +115,7 @@ public class MiBand5Coordinator extends HuamiCoordinator {
R.xml.devicesettings_nightmode,
R.xml.devicesettings_liftwrist_display_sensitivity,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_workout_start_on_phone,
R.xml.devicesettings_workout_send_gps_to_band,
R.xml.devicesettings_swipeunlock,
R.xml.devicesettings_sync_calendar,

View File

@ -1907,13 +1907,27 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
LOG.info("Got workout status {}", status);
final boolean sendGpsToBand = HuamiCoordinator.getWorkoutSendGpsToBand(getDevice().getAddress());
final boolean startOnPhone = HuamiCoordinator.getWorkoutStartOnPhone(getDevice().getAddress());
switch (status) {
case Start:
if (workoutNeedsGps && startOnPhone) {
LOG.info("Starting OpenTracks recording");
OpenTracksController.startRecording(getContext());
}
break;
case End:
GBLocationManager.stop(getContext(), this);
if (startOnPhone) {
if (GBApplication.app().getOpenTracksObserver() != null) {
LOG.info("Stopping OpenTracks recording");
OpenTracksController.stopRecording(getContext());
}
}
break;
}

View File

@ -370,6 +370,8 @@
<string name="prefs_hr_alarm_activity">Heart rate alarm during sports activity</string>
<string name="prefs_hr_alarm_low">Low limit</string>
<string name="prefs_hr_alarm_high">High limit</string>
<string name="pref_workout_start_on_phone_title">Fitness app tracking</string>
<string name="pref_workout_start_on_phone_summary">Start/stop fitness app tracking on phone when a GPS workout is started on the band</string>
<string name="pref_workout_send_gps_title">Send GPS during workout</string>
<string name="pref_workout_send_gps_summary">Send the current GPS location to the band during a workout</string>
<!-- Auto export preferences -->

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<SwitchPreference
android:defaultValue="false"
android:icon="@drawable/ic_activity_unknown_small"
android:key="workout_start_on_phone"
android:summary="@string/pref_workout_start_on_phone_summary"
android:title="@string/pref_workout_start_on_phone_title" />
</androidx.preference.PreferenceScreen>