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

Enable Fitness App Tracking Stop in Huami actions. Add Toggle function to the Tracking

This commit is contained in:
vanous 2022-05-09 17:18:06 +02:00
parent 2aecb85015
commit 873ac85001
6 changed files with 23 additions and 16 deletions

View File

@ -74,6 +74,7 @@ public class HuamiConst {
public static final String PREF_BUTTON_ACTION_SELECTION_BROADCAST = "BROADCAST";
public static final String PREF_BUTTON_ACTION_SELECTION_FITNESS_APP_START = "FITNESS_CONTROL_START";
public static final String PREF_BUTTON_ACTION_SELECTION_FITNESS_APP_STOP = "FITNESS_CONTROL_STOP";
public static final String PREF_BUTTON_ACTION_SELECTION_FITNESS_APP_TOGGLE = "FITNESS_CONTROL_TOGGLE";
public static final String PREF_DEVICE_ACTION_SELECTION_OFF = "UNKNOWN";
public static final String PREF_DEVICE_ACTION_SELECTION_BROADCAST = "BROADCAST";

View File

@ -113,4 +113,13 @@ public class OpenTracksController extends Activity {
}
GBApplication.app().setOpenTracksObserver(null);
}
public static void toggleRecording(Context context) {
OpenTracksContentObserver openTracksObserver = GBApplication.app().getOpenTracksObserver();
if (openTracksObserver == null) {
startRecording(context);
} else {
stopRecording(context);
}
}
}

View File

@ -177,6 +177,7 @@ import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.Dev
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_BUTTON_ACTION_SELECTION_BROADCAST;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_BUTTON_ACTION_SELECTION_FITNESS_APP_START;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_BUTTON_ACTION_SELECTION_FITNESS_APP_STOP;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_BUTTON_ACTION_SELECTION_FITNESS_APP_TOGGLE;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_BUTTON_ACTION_SELECTION_OFF;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DEVICE_ACTION_FELL_SLEEP_BROADCAST;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DEVICE_ACTION_FELL_SLEEP_SELECTION;
@ -1438,6 +1439,9 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
case PREF_BUTTON_ACTION_SELECTION_FITNESS_APP_STOP:
OpenTracksController.stopRecording(this.getContext());
break;
case PREF_BUTTON_ACTION_SELECTION_FITNESS_APP_TOGGLE:
OpenTracksController.toggleRecording(this.getContext());
break;
default:
handleMediaButton(buttonPreference);
}
@ -1457,6 +1461,9 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
case PREF_BUTTON_ACTION_SELECTION_FITNESS_APP_STOP:
OpenTracksController.stopRecording(this.getContext());
break;
case PREF_BUTTON_ACTION_SELECTION_FITNESS_APP_TOGGLE:
OpenTracksController.toggleRecording(this.getContext());
break;
default:
handleMediaButton(deviceAction);
}

View File

@ -1655,11 +1655,8 @@
<item>@string/pref_media_rewind</item>
<item>@string/pref_device_action_broadcast</item>
<item>@string/pref_device_action_fitness_app_control_start</item>
<!--
Enable when OpenTracks allows to be stopped via intent
https://github.com/OpenTracksApp/OpenTracks/issues/1103
<item>@string/pref_device_action_fitness_app_control_stop</item>
-->
<item>@string/pref_device_action_fitness_app_control_toggle</item>
</string-array>
<string-array name="button_action_values">
@ -1675,11 +1672,8 @@
<item>@string/pref_media_rewind_value</item>
<item>@string/pref_device_action_broadcast_value</item>
<item>@string/pref_device_action_fitness_app_control_start_value</item>
<!--
Enable when OpenTracks allows to be stopped via intent
https://github.com/OpenTracksApp/OpenTracks/issues/1103
<item>@string/pref_device_action_fitness_app_control_stop_value</item>
-->
<item>@string/pref_device_action_fitness_app_control_toggle_value</item>
</string-array>
<string-array name="device_action_options">
@ -1689,11 +1683,8 @@
<item>@string/pref_media_playpause</item>
<item>@string/pref_device_action_broadcast</item>
<item>@string/pref_device_action_fitness_app_control_start</item>
<!--
Enable when OpenTracks allows to be stopped via intent
https://github.com/OpenTracksApp/OpenTracks/issues/1103
<item>@string/pref_device_action_fitness_app_control_stop</item>
-->
<item>@string/pref_device_action_fitness_app_control_toggle</item>
</string-array>
<string-array name="device_action_values">
@ -1703,11 +1694,8 @@
<item>@string/pref_media_playpause_value</item>
<item>@string/pref_device_action_broadcast_value</item>
<item>@string/pref_device_action_fitness_app_control_start_value</item>
<!--
Enable when OpenTracks allows to be stopped via intent
https://github.com/OpenTracksApp/OpenTracks/issues/1103
<item>@string/pref_device_action_fitness_app_control_stop_value</item>
-->
<item>@string/pref_device_action_fitness_app_control_toggle_value</item>
</string-array>
<string-array name="pref_hybridhr_buttonfunctions">

View File

@ -1530,6 +1530,7 @@
<string name="pref_device_action_broadcast">Send Broadcast</string>
<string name="pref_device_action_fitness_app_control_start">Fitness App Tracking Start</string>
<string name="pref_device_action_fitness_app_control_stop">Fitness App Tracking Stop</string>
<string name="pref_device_action_fitness_app_control_toggle">Toggle Fitness App Tracking</string>
<!-- Translators: the ### indicate number of digits, keep intact -->
<string name="distance_format_meters">###m</string>
<!-- Translators: the ### indicate number of digits, keep intact -->

View File

@ -109,6 +109,7 @@
<item name="pref_device_action_broadcast_value" translatable="false" type="string">BROADCAST</item>
<item name="pref_device_action_fitness_app_control_start_value" translatable="false" type="string">FITNESS_CONTROL_START</item>
<item name="pref_device_action_fitness_app_control_stop_value" translatable="false" type="string">FITNESS_CONTROL_STOP</item>
<item name="pref_device_action_fitness_app_control_toggle_value" translatable="false" type="string">FITNESS_CONTROL_TOGGLE</item>
<item name="pref_title_touch_voice_assistant" type="string">Voice Assistant</item>
<item name="pref_title_touch_anc" type="string">Active Noise Cancelling</item>
<item name="pref_title_touch_quick_ambient" type="string">Quick Ambient Sound</item>