mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-30 14:02:56 +01:00
Amazfit GTS: support setting menu items
This commit is contained in:
parent
34bb6deef9
commit
a851bb5cf1
@ -88,7 +88,7 @@ public class AmazfitGTSCoordinator extends HuamiCoordinator {
|
||||
|
||||
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
|
||||
return new int[]{
|
||||
R.xml.devicesettings_amazfitgtr,
|
||||
R.xml.devicesettings_amazfitgts,
|
||||
R.xml.devicesettings_wearlocation,
|
||||
R.xml.devicesettings_timeformat,
|
||||
R.xml.devicesettings_liftwrist_display,
|
||||
|
@ -19,9 +19,15 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts.AmazfitGTSFWHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
@ -29,6 +35,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip.Ama
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperationNew;
|
||||
|
||||
public class AmazfitGTSSupport extends AmazfitBipSupport {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTSSupport.class);
|
||||
|
||||
@Override
|
||||
public byte getCryptFlags() {
|
||||
@ -58,8 +65,58 @@ public class AmazfitGTSSupport extends AmazfitBipSupport {
|
||||
|
||||
@Override
|
||||
protected AmazfitGTSSupport setDisplayItems(TransactionBuilder builder) {
|
||||
// not supported yet
|
||||
if (gbDevice.getFirmwareVersion() == null) {
|
||||
LOG.warn("Device not initialized yet, won't set menu items");
|
||||
return this;
|
||||
}
|
||||
|
||||
Set<String> pages = HuamiCoordinator.getDisplayItems(gbDevice.getAddress());
|
||||
LOG.info("Setting display items to " + (pages == null ? "none" : pages));
|
||||
byte[] command = new byte[]{
|
||||
0x00, (byte) 0xC2, 0x00, 0x1E, // looks like chunked, but 0x00 :O
|
||||
0x00, 0x00, (byte) 0xFF, 0x01, // Status
|
||||
0x01, 0x00, (byte) 0xFF, 0x19, // PAI
|
||||
0x02, 0x00, (byte) 0xFF, 0x02, // HR
|
||||
0x03, 0x00, (byte) 0xFF, 0x03, // Workout
|
||||
0x04, 0x00, (byte) 0xFF, 0x14, // Activities
|
||||
0x05, 0x00, (byte) 0xFF, 0x04, // Weather
|
||||
0x06, 0x00, (byte) 0xFF, 0x0B, // Music
|
||||
0x07, 0x00, (byte) 0xFF, 0x06, // Notifications
|
||||
0x08, 0x00, (byte) 0xFF, 0x09, // Alarm
|
||||
0x09, 0x00, (byte) 0xFF, 0x15, // Event reminder
|
||||
0x0A, 0x00, (byte) 0xFF, 0x07, // More
|
||||
0x0B, 0x00, (byte) 0xFF, 0x13 // Settings
|
||||
};
|
||||
|
||||
String[] keys = {"status", "pai", "hr", "workout", "activity", "weather", "music", "notifications", "alarm", "eventreminder", "more", "settings"};
|
||||
byte[] ids = {1, 25, 2, 3, 20, 4, 11, 6, 9, 21, 7, 19};
|
||||
|
||||
if (pages != null) {
|
||||
pages.add("settings");
|
||||
// it seem that we first have to put all ENABLED items into the array
|
||||
int pos = 4;
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
String key = keys[i];
|
||||
byte id = ids[i];
|
||||
if (pages.contains(key)) {
|
||||
command[pos + 1] = 0x00;
|
||||
command[pos + 3] = id;
|
||||
pos += 4;
|
||||
}
|
||||
}
|
||||
// And then all DISABLED ones
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
String key = keys[i];
|
||||
byte id = ids[i];
|
||||
if (!pages.contains(key)) {
|
||||
command[pos + 1] = 0x01;
|
||||
command[pos + 3] = id;
|
||||
pos += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
builder.write(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_CHUNKEDTRANSFER), command);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -353,6 +353,47 @@
|
||||
<item>@string/p_menuitem_music</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_gts_display_items">
|
||||
<item>@string/menuitem_status</item>
|
||||
<item>@string/menuitem_pai</item>
|
||||
<item>@string/menuitem_hr</item>
|
||||
<item>@string/menuitem_workout</item>
|
||||
<item>@string/menuitem_activity</item>
|
||||
<item>@string/menuitem_weather</item>
|
||||
<item>@string/menuitem_music</item>
|
||||
<item>@string/menuitem_notifications</item>
|
||||
<item>@string/menuitem_alarm</item>
|
||||
<item>@string/menuitem_eventreminder</item>
|
||||
<item>@string/menuitem_more</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_gts_display_items_values">
|
||||
<item>@string/p_menuitem_status</item>
|
||||
<item>@string/p_menuitem_pai</item>
|
||||
<item>@string/p_menuitem_hr</item>
|
||||
<item>@string/p_menuitem_workout</item>
|
||||
<item>@string/p_menuitem_activity</item>
|
||||
<item>@string/p_menuitem_weather</item>
|
||||
<item>@string/p_menuitem_music</item>
|
||||
<item>@string/p_menuitem_notifications</item>
|
||||
<item>@string/p_menuitem_alarm</item>
|
||||
<item>@string/p_menuitem_eventreminder</item>
|
||||
<item>@string/p_menuitem_more</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_gts_display_items_default">
|
||||
<item>@string/p_menuitem_status</item>
|
||||
<item>@string/p_menuitem_pai</item>
|
||||
<item>@string/p_menuitem_hr</item>
|
||||
<item>@string/p_menuitem_workout</item>
|
||||
<item>@string/p_menuitem_activity</item>
|
||||
<item>@string/p_menuitem_weather</item>
|
||||
<item>@string/p_menuitem_music</item>
|
||||
<item>@string/p_menuitem_notifications</item>
|
||||
<item>@string/p_menuitem_alarm</item>
|
||||
<item>@string/p_menuitem_eventreminder</item>
|
||||
<item>@string/p_menuitem_more</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_entries_unit_system">
|
||||
<item>@string/unit_metric</item>
|
||||
|
@ -726,6 +726,10 @@
|
||||
<string name="menuitem_music">Music</string>
|
||||
<string name="menuitem_more">More</string>
|
||||
<string name="menuitem_nfc">NFC</string>
|
||||
<string name="menuitem_pai">PAI</string>
|
||||
<string name="menuitem_hr">Heart Rate</string>
|
||||
<string name="menuitem_eventreminder">Event Reminder</string>
|
||||
<string name="menuitem_workout">Workout</string>
|
||||
<string name="watch9_time_minutes">Minutes:</string>
|
||||
<string name="watch9_time_hours">Hours:</string>
|
||||
<string name="watch9_time_seconds">Seconds:</string>
|
||||
|
@ -33,6 +33,10 @@
|
||||
<item name="p_menuitem_music" type="string">music</item>
|
||||
<item name="p_menuitem_more" type="string">more</item>
|
||||
<item name="p_menuitem_nfc" type="string">nfc</item>
|
||||
<item name="p_menuitem_hr" type="string">hr</item>
|
||||
<item name="p_menuitem_pai" type="string">pai</item>
|
||||
<item name="p_menuitem_eventreminder" type="string">eventreminder</item>
|
||||
<item name="p_menuitem_workout" type="string">workout</item>
|
||||
|
||||
<item name="p_off" type="string">off</item>
|
||||
<item name="p_on" type="string">on</item>
|
||||
|
20
app/src/main/res/xml/devicesettings_amazfitgts.xml
Normal file
20
app/src/main/res/xml/devicesettings_amazfitgts.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<MultiSelectListPreference
|
||||
android:icon="@drawable/ic_widgets"
|
||||
android:defaultValue="@array/pref_gts_display_items_default"
|
||||
android:dialogTitle="@string/mi2_prefs_display_items"
|
||||
android:entries="@array/pref_gts_display_items"
|
||||
android:entryValues="@array/pref_gts_display_items_values"
|
||||
android:key="display_items"
|
||||
android:summary="@string/mi2_prefs_display_items_summary"
|
||||
android:title="@string/mi2_prefs_display_items" />
|
||||
<ListPreference
|
||||
android:icon="@drawable/ic_language"
|
||||
android:defaultValue="auto"
|
||||
android:entries="@array/pref_amazfitbip_language"
|
||||
android:entryValues="@array/pref_amazfitbip_language_values"
|
||||
android:key="language"
|
||||
android:summary="%s"
|
||||
android:title="@string/pref_title_language" />
|
||||
</androidx.preference.PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user