mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-10 12:09:27 +01:00
Mi/Amazfit Band 5: Add support for setting/sorting shortcuts
This commit is contained in:
parent
c4eb1c0879
commit
5b55898059
@ -2409,11 +2409,18 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
LOG.info("enabled items" + enabledList);
|
||||
|
||||
byte[] command = new byte[keyIdMap.size() * 4 + 1];
|
||||
byte[] command = new byte[(keyIdMap.size() + 1) * 4 + 1];
|
||||
command[0] = 0x1e;
|
||||
// it seem that we first have to put all ENABLED items into the array, oder does matter
|
||||
|
||||
int pos = 1;
|
||||
int index = 0;
|
||||
|
||||
command[pos++] = (byte) index++;
|
||||
command[pos++] = 0x00;
|
||||
command[pos++] = menuType;
|
||||
command[pos++] = 0x12;
|
||||
|
||||
for (String key : enabledList) {
|
||||
Integer id = keyIdMap.get(key);
|
||||
if (id != null) {
|
||||
|
@ -49,12 +49,40 @@ public class AmazfitBand5Support extends MiBand5Support {
|
||||
keyIdMap.put("workout", 0x03);
|
||||
keyIdMap.put("more", 0x07);
|
||||
keyIdMap.put("stress", 0x1c);
|
||||
keyIdMap.put("cycles", 0x1d);
|
||||
keyIdMap.put("period", 0x1d);
|
||||
|
||||
setDisplayItemsNew(builder, false, R.array.pref_amazfitband5_display_items_default, keyIdMap);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AmazfitBand5Support setShortcuts(TransactionBuilder builder) {
|
||||
Map<String, Integer> keyIdMap = new LinkedHashMap<>();
|
||||
keyIdMap.put("notifications", 0x06);
|
||||
keyIdMap.put("weather", 0x04);
|
||||
keyIdMap.put("music", 0x0b);
|
||||
keyIdMap.put("timer", 0x0d);
|
||||
keyIdMap.put("alarm", 0x09);
|
||||
keyIdMap.put("findphone", 0x0e);
|
||||
keyIdMap.put("worldclock", 0x1a);
|
||||
keyIdMap.put("status", 0x01);
|
||||
keyIdMap.put("pai", 0x19);
|
||||
keyIdMap.put("hr", 0x02);
|
||||
keyIdMap.put("spo2", 0x24);
|
||||
keyIdMap.put("stress", 0x1c);
|
||||
keyIdMap.put("eventreminder", 0x15);
|
||||
keyIdMap.put("dnd", 0x08);
|
||||
keyIdMap.put("stopwatch", 0x0c);
|
||||
keyIdMap.put("workout", 0x03);
|
||||
keyIdMap.put("mutephone", 0x0f);
|
||||
keyIdMap.put("period", 0x1d);
|
||||
keyIdMap.put("takephoto", 0x0a);
|
||||
keyIdMap.put("alexa", 0x39);
|
||||
setDisplayItemsNew(builder, true, R.array.pref_amazfitband5_shortcuts_default, keyIdMap);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HuamiFWHelper createFWHelper(Uri uri, Context context) throws IOException {
|
||||
return new AmazfitBand5FWHelper(uri, context);
|
||||
|
@ -48,12 +48,38 @@ public class MiBand5Support extends MiBand4Support {
|
||||
keyIdMap.put("workout", 0x03);
|
||||
keyIdMap.put("more", 0x07);
|
||||
keyIdMap.put("stress", 0x1c);
|
||||
keyIdMap.put("cycles", 0x1d);
|
||||
keyIdMap.put("period", 0x1d);
|
||||
|
||||
setDisplayItemsNew(builder, false, R.array.pref_miband5_display_items_default, keyIdMap);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MiBand5Support setShortcuts(TransactionBuilder builder) {
|
||||
Map<String, Integer> keyIdMap = new LinkedHashMap<>();
|
||||
keyIdMap.put("notifications", 0x06);
|
||||
keyIdMap.put("weather", 0x04);
|
||||
keyIdMap.put("music", 0x0b);
|
||||
keyIdMap.put("timer", 0x0d);
|
||||
keyIdMap.put("alarm", 0x09);
|
||||
keyIdMap.put("findphone", 0x0e);
|
||||
keyIdMap.put("worldclock", 0x1a);
|
||||
keyIdMap.put("status", 0x01);
|
||||
keyIdMap.put("pai", 0x19);
|
||||
keyIdMap.put("hr", 0x02);
|
||||
keyIdMap.put("stress", 0x1c);
|
||||
keyIdMap.put("eventreminder", 0x15);
|
||||
keyIdMap.put("dnd", 0x08);
|
||||
keyIdMap.put("stopwatch", 0x0c);
|
||||
keyIdMap.put("workout", 0x03);
|
||||
keyIdMap.put("mutephone", 0x0f);
|
||||
keyIdMap.put("period", 0x1d);
|
||||
keyIdMap.put("takephoto", 0x0a);
|
||||
setDisplayItemsNew(builder, true, R.array.pref_miband5_shortcuts_default, keyIdMap);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HuamiFWHelper createFWHelper(Uri uri, Context context) throws IOException {
|
||||
return new MiBand5FWHelper(uri, context);
|
||||
|
@ -355,6 +355,54 @@
|
||||
<item>@string/p_menuitem_cycles</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_miband5_shortcuts">
|
||||
<item>@string/menuitem_weather</item>
|
||||
<item>@string/menuitem_notifications</item>
|
||||
<item>@string/menuitem_music</item>
|
||||
<item>@string/menuitem_timer</item>
|
||||
<item>@string/menuitem_alarm</item>
|
||||
<item>@string/menuitem_findphone</item>
|
||||
<item>@string/menuitem_worldclock</item>
|
||||
<item>@string/menuitem_status</item>
|
||||
<item>@string/menuitem_pai</item>
|
||||
<item>@string/menuitem_hr</item>
|
||||
<item>@string/menuitem_stress</item>
|
||||
<item>@string/menuitem_eventreminder</item>
|
||||
<item>@string/menuitem_dnd</item>
|
||||
<item>@string/menuitem_stopwatch</item>
|
||||
<item>@string/menuitem_workout</item>
|
||||
<item>@string/menuitem_mutephone</item>
|
||||
<item>@string/menuitem_cycles</item>
|
||||
<item>@string/menuitem_takephoto</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_miband5_shortcuts_values">
|
||||
<item>@string/p_menuitem_notifications</item>
|
||||
<item>@string/p_menuitem_weather</item>
|
||||
<item>@string/p_menuitem_music</item>
|
||||
<item>@string/p_menuitem_timer</item>
|
||||
<item>@string/p_menuitem_alarm</item>
|
||||
<item>@string/p_menuitem_findphone</item>
|
||||
<item>@string/p_menuitem_worldclock</item>
|
||||
<item>@string/p_menuitem_status</item>
|
||||
<item>@string/p_menuitem_pai</item>
|
||||
<item>@string/p_menuitem_hr</item>
|
||||
<item>@string/p_menuitem_stress</item>
|
||||
<item>@string/p_menuitem_eventreminder</item>
|
||||
<item>@string/p_menuitem_dnd</item>
|
||||
<item>@string/p_menuitem_stopwatch</item>
|
||||
<item>@string/p_menuitem_workout</item>
|
||||
<item>@string/p_menuitem_mutephone</item>
|
||||
<item>@string/p_menuitem_cycles</item>
|
||||
<item>@string/p_menuitem_takephoto</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_miband5_shortcuts_default">
|
||||
<item>@string/p_menuitem_notifications</item>
|
||||
<item>@string/p_menuitem_weather</item>
|
||||
<item>@string/p_menuitem_music</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_amazfitband5_display_items">
|
||||
<item>@string/menuitem_status</item>
|
||||
<item>@string/menuitem_pai</item>
|
||||
@ -400,6 +448,58 @@
|
||||
<item>@string/p_menuitem_cycles</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_amazfitband5_shortcuts">
|
||||
<item>@string/menuitem_weather</item>
|
||||
<item>@string/menuitem_notifications</item>
|
||||
<item>@string/menuitem_music</item>
|
||||
<item>@string/menuitem_timer</item>
|
||||
<item>@string/menuitem_alarm</item>
|
||||
<item>@string/menuitem_findphone</item>
|
||||
<item>@string/menuitem_worldclock</item>
|
||||
<item>@string/menuitem_status</item>
|
||||
<item>@string/menuitem_pai</item>
|
||||
<item>@string/menuitem_hr</item>
|
||||
<item>@string/menuitem_spo2</item>
|
||||
<item>@string/menuitem_stress</item>
|
||||
<item>@string/menuitem_eventreminder</item>
|
||||
<item>@string/menuitem_dnd</item>
|
||||
<item>@string/menuitem_stopwatch</item>
|
||||
<item>@string/menuitem_workout</item>
|
||||
<item>@string/menuitem_mutephone</item>
|
||||
<item>@string/menuitem_cycles</item>
|
||||
<item>@string/menuitem_takephoto</item>
|
||||
<item>@string/menuitem_alexa</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_amazfitband5_shortcuts_values">
|
||||
<item>@string/p_menuitem_notifications</item>
|
||||
<item>@string/p_menuitem_weather</item>
|
||||
<item>@string/p_menuitem_music</item>
|
||||
<item>@string/p_menuitem_timer</item>
|
||||
<item>@string/p_menuitem_alarm</item>
|
||||
<item>@string/p_menuitem_findphone</item>
|
||||
<item>@string/p_menuitem_worldclock</item>
|
||||
<item>@string/p_menuitem_status</item>
|
||||
<item>@string/p_menuitem_pai</item>
|
||||
<item>@string/p_menuitem_hr</item>
|
||||
<item>@string/p_menuitem_spo2</item>
|
||||
<item>@string/p_menuitem_stress</item>
|
||||
<item>@string/p_menuitem_eventreminder</item>
|
||||
<item>@string/p_menuitem_dnd</item>
|
||||
<item>@string/p_menuitem_stopwatch</item>
|
||||
<item>@string/p_menuitem_workout</item>
|
||||
<item>@string/p_menuitem_mutephone</item>
|
||||
<item>@string/p_menuitem_cycles</item>
|
||||
<item>@string/p_menuitem_takephoto</item>
|
||||
<item>@string/p_menuitem_alexa</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_amazfitband5_shortcuts_default">
|
||||
<item>@string/p_menuitem_notifications</item>
|
||||
<item>@string/p_menuitem_weather</item>
|
||||
<item>@string/p_menuitem_music</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_bip_display_items">
|
||||
<item>@string/menuitem_status</item>
|
||||
<item>@string/menuitem_activity</item>
|
||||
@ -592,11 +692,6 @@
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_bips_shortcuts_default">
|
||||
<item>@string/p_menuitem_status</item>
|
||||
<item>@string/p_menuitem_alipay</item>
|
||||
<item>@string/p_menuitem_nfc</item>
|
||||
<item>@string/p_menuitem_pai</item>
|
||||
<item>@string/p_menuitem_hr</item>
|
||||
<item>@string/p_menuitem_music</item>
|
||||
<item>@string/p_menuitem_weather</item>
|
||||
</string-array>
|
||||
|
@ -818,7 +818,7 @@
|
||||
<string name="menuitem_activity">Activity</string>
|
||||
<string name="menuitem_weather">Weather</string>
|
||||
<string name="menuitem_breathing">Breathing</string>
|
||||
<string name="menuitem_cycles">Cycles</string>
|
||||
<string name="menuitem_cycles">Period</string>
|
||||
<string name="menuitem_alarm">Alarm</string>
|
||||
<string name="menuitem_timer">Timer</string>
|
||||
<string name="menuitem_compass">Compass</string>
|
||||
@ -836,6 +836,12 @@
|
||||
<string name="menuitem_workout">Workout</string>
|
||||
<string name="menuitem_unknown">Unknown</string>
|
||||
<string name="menuitem_worldclock">World Clock</string>
|
||||
<string name="menuitem_findphone">Find Phone</string>
|
||||
<string name="menuitem_mutephone">Mute Phone</string>
|
||||
<string name="menuitem_takephoto">Take a photo</string>
|
||||
<string name="menuitem_alexa">Alexa</string>
|
||||
<string name="menuitem_dnd">DND</string>
|
||||
<string name="menuitem_stopwatch">Stopwatch</string>
|
||||
<string name="watch9_time_minutes">Minutes:</string>
|
||||
<string name="watch9_time_hours">Hours:</string>
|
||||
<string name="watch9_time_seconds">Seconds:</string>
|
||||
|
@ -36,10 +36,16 @@
|
||||
<item name="p_menuitem_spo2" type="string">spo2</item>
|
||||
<item name="p_menuitem_pai" type="string">pai</item>
|
||||
<item name="p_menuitem_stress" type="string">stress</item>
|
||||
<item name="p_menuitem_cycles" type="string">cycles</item>
|
||||
<item name="p_menuitem_cycles" type="string">period</item>
|
||||
<item name="p_menuitem_eventreminder" type="string">eventreminder</item>
|
||||
<item name="p_menuitem_workout" type="string">workout</item>
|
||||
<item name="p_menuitem_worldclock" type="string">worldclock</item>
|
||||
<item name="p_menuitem_findphone" type="string">findphone</item>
|
||||
<item name="p_menuitem_dnd" type="string">dnd</item>
|
||||
<item name="p_menuitem_stopwatch" type="string">stopwatch</item>
|
||||
<item name="p_menuitem_mutephone" type="string">mutephone</item>
|
||||
<item name="p_menuitem_takephoto" type="string">takephoto</item>
|
||||
<item name="p_menuitem_alexa" type="string">alexa</item>
|
||||
|
||||
<item name="p_off" type="string">off</item>
|
||||
<item name="p_on" type="string">on</item>
|
||||
|
@ -9,6 +9,15 @@
|
||||
android:key="display_items"
|
||||
android:summary="@string/mi2_prefs_display_items_summary"
|
||||
android:title="@string/mi2_prefs_display_items" />
|
||||
<com.mobeta.android.dslv.DragSortListPreference
|
||||
android:defaultValue="@array/pref_amazfitband5_shortcuts_default"
|
||||
android:dialogTitle="@string/bip_prefs_shortcuts"
|
||||
android:entries="@array/pref_amazfitband5_shortcuts"
|
||||
android:entryValues="@array/pref_amazfitband5_shortcuts_values"
|
||||
android:key="shortcuts_sortable"
|
||||
android:persistent="true"
|
||||
android:summary="@string/bip_prefs_shotcuts_summary"
|
||||
android:title="@string/bip_prefs_shortcuts" />
|
||||
<ListPreference
|
||||
android:icon="@drawable/ic_language"
|
||||
android:defaultValue="auto"
|
||||
|
@ -10,6 +10,15 @@
|
||||
android:persistent="true"
|
||||
android:summary="@string/mi2_prefs_display_items_summary"
|
||||
android:title="@string/mi2_prefs_display_items" />
|
||||
<com.mobeta.android.dslv.DragSortListPreference
|
||||
android:defaultValue="@array/pref_miband5_shortcuts_default"
|
||||
android:dialogTitle="@string/bip_prefs_shortcuts"
|
||||
android:entries="@array/pref_miband5_shortcuts"
|
||||
android:entryValues="@array/pref_miband5_shortcuts_values"
|
||||
android:key="shortcuts_sortable"
|
||||
android:persistent="true"
|
||||
android:summary="@string/bip_prefs_shotcuts_summary"
|
||||
android:title="@string/bip_prefs_shortcuts" />
|
||||
<ListPreference
|
||||
android:icon="@drawable/ic_language"
|
||||
android:defaultValue="auto"
|
||||
|
Loading…
Reference in New Issue
Block a user