1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-26 02:25:50 +01:00

Mi Band 6: Add support for workout activity types

This commit is contained in:
José Rebelo 2022-09-25 11:10:38 +02:00
parent 11716c906b
commit aac1e656b1
5 changed files with 148 additions and 13 deletions

View File

@ -3479,8 +3479,7 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
protected HuamiSupport setWorkoutActivityTypes(final TransactionBuilder builder) {
final SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress());
final List<String> allActivityTypes = Arrays.asList(getContext().getResources().getStringArray(R.array.pref_miband5_workout_activity_types_values));
final List<String> defaultActivityTypes = Arrays.asList(getContext().getResources().getStringArray(R.array.pref_miband5_workout_activity_types_default));
final List<String> defaultActivityTypes = Arrays.asList(HuamiWorkoutActivityType.Freestyle.name().toLowerCase(Locale.ROOT));
final String activityTypesPref = prefs.getString(HuamiConst.PREF_WORKOUT_ACTIVITY_TYPES_SORTABLE, null);
final List<String> enabledActivityTypes;
@ -3492,7 +3491,7 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
LOG.info("Setting workout types to {}", enabledActivityTypes);
final byte[] command = new byte[allActivityTypes.size() * 3 + 2];
final byte[] command = new byte[enabledActivityTypes.size() * 3 + 2];
command[0] = 0x0b;
command[1] = 0x00;
@ -3504,15 +3503,6 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
command[pos++] = 0x01;
}
// Send all the remaining disabled workout types
for (final String workoutType : allActivityTypes) {
if (!enabledActivityTypes.contains(workoutType)) {
command[pos++] = HuamiWorkoutScreenActivityType.fromPrefValue(workoutType).getCode();
command[pos++] = 0x00;
command[pos++] = 0x00;
}
}
writeToChunked(builder, 9, command);
return this;

View File

@ -32,7 +32,27 @@ public enum HuamiWorkoutScreenActivityType {
Freestyle(0x10),
JumpRope(0x15),
RowingMachine(0x17),
Yoga(0x3c);
Yoga(0x3c),
Dance(0x4c),
IndoorFitness(0x18),
Gymnastics(0x3b),
HIIT(0x31),
CoreTraining(0x32),
Stretching(0x35),
Stepper(0x3a),
Pilates(0x3d),
Basketball(0x55),
Volleyball(0x58),
TableTennis(0x59),
Badminton(0x5c),
Cricket(0x4e),
Bowling(0x50),
Boxing(0x61),
// TODO: Not working Kickboxing(0x72),
StreetDance(0x4a),
Zumba(0x4d),
IndoorIceSkating(0x2d),
;
private final byte code;

View File

@ -674,6 +674,105 @@
<item>yoga</item>
</string-array>
<string-array name="pref_miband6_workout_activity_types_values">
<item>outdoor_running</item>
<item>walking</item>
<item>treadmill</item>
<item>outdoor_cycling</item>
<item>indoor_cycling</item>
<item>elliptical</item>
<item>pool_swimming</item>
<item>freestyle</item>
<item>jump_rope</item>
<item>rowing_machine</item>
<item>yoga</item>
<item>dance</item>
<item>indoor_fitness</item>
<item>gymnastics</item>
<item>hiit</item>
<item>core_training</item>
<item>stretching</item>
<item>stepper</item>
<item>pilates</item>
<item>basketball</item>
<item>volleyball</item>
<item>table_tennis</item>
<item>badminton</item>
<item>cricket</item>
<item>bowling</item>
<item>boxing</item>
<!-- TODO: Not working <item>kickboxing</item> -->
<item>street_dance</item>
<item>zumba</item>
<item>indoor_ice_skating</item>
</string-array>
<string-array name="pref_miband6_workout_activity_types">
<item>@string/activity_type_outdoor_running</item>
<item>@string/activity_type_walking</item>
<item>@string/activity_type_treadmill</item>
<item>@string/activity_type_outdoor_cycling</item>
<item>@string/activity_type_indoor_cycling</item>
<item>@string/activity_type_elliptical</item>
<item>@string/activity_type_swimming</item>
<item>@string/activity_type_freestyle</item>
<item>@string/activity_type_jump_roping</item>
<item>@string/activity_type_rowing_machine</item>
<item>@string/activity_type_yoga</item>
<item>@string/activity_type_dance</item>
<item>@string/activity_type_indoor_fitness</item>
<item>@string/activity_type_gymnastics</item>
<item>@string/activity_type_hiit</item>
<item>@string/activity_type_core_training</item>
<item>@string/activity_type_stretching</item>
<item>@string/activity_type_stepper</item>
<item>@string/activity_type_pilates</item>
<item>@string/activity_type_basketball</item>
<item>@string/activity_type_volleyball</item>
<item>@string/activity_type_table_tennis</item>
<item>@string/activity_type_badminton</item>
<item>@string/activity_type_cricket</item>
<item>@string/activity_type_bowling</item>
<item>@string/activity_type_boxing</item>
<!-- TODO: Not working <item>@string/activity_type_kickboxing</item> -->
<item>@string/activity_type_street_dance</item>
<item>@string/activity_type_zumba</item>
<item>@string/activity_type_indoor_ice_skating</item>
</string-array>
<string-array name="pref_miband6_workout_activity_types_default">
<item>outdoor_running</item>
<item>walking</item>
<item>treadmill</item>
<item>outdoor_cycling</item>
<item>indoor_cycling</item>
<item>elliptical</item>
<item>pool_swimming</item>
<item>freestyle</item>
<item>jump_rope</item>
<item>rowing_machine</item>
<item>yoga</item>
<item>dance</item>
<item>indoor_fitness</item>
<item>gymnastics</item>
<item>hiit</item>
<item>core_training</item>
<item>stretching</item>
<item>stepper</item>
<item>pilates</item>
<item>basketball</item>
<item>volleyball</item>
<item>table_tennis</item>
<item>badminton</item>
<item>cricket</item>
<item>bowling</item>
<item>boxing</item>
<!-- TODO: Not working <item>kickboxing</item> -->
<item>street_dance</item>
<item>zumba</item>
<item>indoor_ice_skating</item>
</string-array>
<string-array name="pref_neo_display_items">
<item>@string/menuitem_pai</item>
<item>@string/menuitem_dnd</item>

View File

@ -1029,6 +1029,22 @@
<string name="activity_type_pingpong">Ping Pong</string>
<string name="activity_type_badminton">Badminton</string>
<string name="activity_type_strength_training">Strength Training</string>
<string name="activity_type_dance">Dance</string>
<string name="activity_type_indoor_fitness">Indoor Fitness</string>
<string name="activity_type_gymnastics">Gymnastics</string>
<string name="activity_type_hiit">High-intensity Interval Training</string>
<string name="activity_type_core_training">Core Training</string>
<string name="activity_type_stretching">Stretching</string>
<string name="activity_type_stepper">Stepper</string>
<string name="activity_type_pilates">Pilates</string>
<string name="activity_type_volleyball">Volleyball</string>
<string name="activity_type_table_tennis">Table Tennis</string>
<string name="activity_type_bowling">Bowling</string>
<string name="activity_type_boxing">Boxing</string>
<string name="activity_type_kickboxing">Kickboxing</string>
<string name="activity_type_street_dance">Street Dance</string>
<string name="activity_type_zumba">Zumba</string>
<string name="activity_type_indoor_ice_skating">Indoor Ice Skating</string>
<string name="activity_type_unknown">Unknown activity</string>
<string name="activity_summaries">Sport Activities</string>
<string name="activity_summary_detail">Sport Activity Detail</string>

View File

@ -20,4 +20,14 @@
android:persistent="true"
android:summary="@string/bip_prefs_shotcuts_summary"
android:title="@string/bip_prefs_shortcuts" />
<com.mobeta.android.dslv.DragSortListPreference
android:icon="@drawable/ic_activity_unknown_small"
android:defaultValue="@array/pref_miband6_workout_activity_types_default"
android:dialogTitle="@string/mi5_prefs_workout_activity_types"
android:entries="@array/pref_miband6_workout_activity_types"
android:entryValues="@array/pref_miband6_workout_activity_types_values"
android:key="workout_activity_types_sortable"
android:persistent="true"
android:summary="@string/mi5_prefs_workout_activity_types_summary"
android:title="@string/mi5_prefs_workout_activity_types" />
</androidx.preference.PreferenceScreen>