1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-26 11:56:48 +01:00

Huami: Add "Strength Training" activity type

Used on at least the Amazfit Bip U
This commit is contained in:
Andreas Shimokawa 2021-01-22 22:14:11 +01:00
parent 0fd2de2bd3
commit fb2c9158e4
3 changed files with 31 additions and 2 deletions

View File

@ -50,8 +50,9 @@ public class ActivityKind {
public static final int TYPE_BASKETBALL = 0x00040000; public static final int TYPE_BASKETBALL = 0x00040000;
public static final int TYPE_PINGPONG = 0x00080000; public static final int TYPE_PINGPONG = 0x00080000;
public static final int TYPE_BADMINTON = 0x00100000; public static final int TYPE_BADMINTON = 0x00100000;
public static final int TYPE_STRENGTH_TRAINING = 0x00200000;
private static final int TYPES_COUNT = 23; private static final int TYPES_COUNT = 24;
public static final int TYPE_SLEEP = TYPE_LIGHT_SLEEP | TYPE_DEEP_SLEEP; public static final int TYPE_SLEEP = TYPE_LIGHT_SLEEP | TYPE_DEEP_SLEEP;
public static final int TYPE_ALL = TYPE_ACTIVITY | TYPE_SLEEP | TYPE_NOT_WORN; public static final int TYPE_ALL = TYPE_ACTIVITY | TYPE_SLEEP | TYPE_NOT_WORN;
@ -104,6 +105,25 @@ public class ActivityKind {
if ((types & ActivityKind.TYPE_YOGA) != 0) { if ((types & ActivityKind.TYPE_YOGA) != 0) {
result[i++] = provider.toRawActivityKind(TYPE_YOGA); result[i++] = provider.toRawActivityKind(TYPE_YOGA);
} }
if ((types & ActivityKind.TYPE_ROWING_MACHINE) != 0) {
result[i++] = provider.toRawActivityKind(TYPE_ROWING_MACHINE);
}
if ((types & ActivityKind.TYPE_CRICKET) != 0) {
result[i++] = provider.toRawActivityKind(TYPE_CRICKET);
}
if ((types & ActivityKind.TYPE_BASKETBALL) != 0) {
result[i++] = provider.toRawActivityKind(TYPE_BASKETBALL);
}
if ((types & ActivityKind.TYPE_PINGPONG) != 0) {
result[i++] = provider.toRawActivityKind(TYPE_PINGPONG);
}
if ((types & ActivityKind.TYPE_BADMINTON) != 0) {
result[i++] = provider.toRawActivityKind(TYPE_BADMINTON);
}
if ((types & ActivityKind.TYPE_STRENGTH_TRAINING) != 0) {
result[i++] = provider.toRawActivityKind(TYPE_STRENGTH_TRAINING);
}
return Arrays.copyOf(result, i); return Arrays.copyOf(result, i);
} }
@ -153,6 +173,8 @@ public class ActivityKind {
return context.getString(R.string.activity_type_pingpong); return context.getString(R.string.activity_type_pingpong);
case TYPE_BADMINTON: case TYPE_BADMINTON:
return context.getString(R.string.activity_type_badminton); return context.getString(R.string.activity_type_badminton);
case TYPE_STRENGTH_TRAINING:
return context.getString(R.string.activity_type_strength_training);
case TYPE_UNKNOWN: case TYPE_UNKNOWN:
default: default:
return context.getString(R.string.activity_type_unknown); return context.getString(R.string.activity_type_unknown);
@ -189,7 +211,6 @@ public class ActivityKind {
return R.drawable.ic_activity_rope_jump; return R.drawable.ic_activity_rope_jump;
case TYPE_YOGA: case TYPE_YOGA:
return R.drawable.ic_activity_yoga; return R.drawable.ic_activity_yoga;
case TYPE_SOCCER: case TYPE_SOCCER:
return R.drawable.ic_activity_soccer; return R.drawable.ic_activity_soccer;
case TYPE_ROWING_MACHINE: case TYPE_ROWING_MACHINE:
@ -202,6 +223,8 @@ public class ActivityKind {
return R.drawable.ic_activity_pingpong; return R.drawable.ic_activity_pingpong;
case TYPE_BADMINTON: case TYPE_BADMINTON:
return R.drawable.ic_activity_badmington; return R.drawable.ic_activity_badmington;
case TYPE_STRENGTH_TRAINING:
return R.drawable.ic_activity_unknown_small; //FIXME: find icon
case TYPE_NOT_WORN: // fall through case TYPE_NOT_WORN: // fall through
case TYPE_ACTIVITY: // fall through case TYPE_ACTIVITY: // fall through

View File

@ -31,6 +31,7 @@ public enum HuamiSportsActivityType {
Soccer(0x12), Soccer(0x12),
JumpRope(0x15), JumpRope(0x15),
RowingMachine(0x17), RowingMachine(0x17),
StrengthTraining(0x34),
Yoga(0x3c), Yoga(0x3c),
Cricket(0x4e), Cricket(0x4e),
Basketball(0x55), Basketball(0x55),
@ -80,6 +81,8 @@ public enum HuamiSportsActivityType {
return ActivityKind.TYPE_PINGPONG; return ActivityKind.TYPE_PINGPONG;
case Badminton: case Badminton:
return ActivityKind.TYPE_BADMINTON; return ActivityKind.TYPE_BADMINTON;
case StrengthTraining:
return ActivityKind.TYPE_STRENGTH_TRAINING;
} }
throw new RuntimeException("Not mapped activity kind for: " + this); throw new RuntimeException("Not mapped activity kind for: " + this);
} }
@ -129,6 +132,8 @@ public enum HuamiSportsActivityType {
return PingPong; return PingPong;
case ActivityKind.TYPE_BADMINTON: case ActivityKind.TYPE_BADMINTON:
return Badminton; return Badminton;
case ActivityKind.TYPE_STRENGTH_TRAINING:
return StrengthTraining;
} }
throw new RuntimeException("No matching activity activityKind: " + activityKind); throw new RuntimeException("No matching activity activityKind: " + activityKind);

View File

@ -760,6 +760,7 @@
<string name="activity_type_basketball">Basketball</string> <string name="activity_type_basketball">Basketball</string>
<string name="activity_type_pingpong">Ping Pong</string> <string name="activity_type_pingpong">Ping Pong</string>
<string name="activity_type_badminton">Badminton</string> <string name="activity_type_badminton">Badminton</string>
<string name="activity_type_strength_training">Strength Training</string>
<string name="activity_type_unknown">Unknown activity</string> <string name="activity_type_unknown">Unknown activity</string>
<string name="activity_summaries">Sport Activities</string> <string name="activity_summaries">Sport Activities</string>
<string name="activity_summary_detail">Sport Activity Detail</string> <string name="activity_summary_detail">Sport Activity Detail</string>