mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Fossil Q: Add button function to ring phone
This commit is contained in:
committed by
Arjan Schrijver
parent
a03bfee348
commit
7735b2d795
+20
-8
@@ -55,6 +55,7 @@ import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.HybridHRActivitySampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.NotificationConfiguration;
|
||||
@@ -117,6 +118,7 @@ public class FossilWatchAdapter extends WatchAdapter {
|
||||
|
||||
private int lastButtonIndex = -1;
|
||||
protected boolean saveRawActivityFiles = false;
|
||||
private boolean findPhoneActive = false;
|
||||
|
||||
protected final Logger LOG = LoggerFactory.getLogger(getClass().getSimpleName());
|
||||
|
||||
@@ -805,13 +807,17 @@ public class FossilWatchAdapter extends WatchAdapter {
|
||||
protected void handleBackgroundCharacteristic(BluetoothGattCharacteristic characteristic, byte[] value) {
|
||||
byte requestType = value[1];
|
||||
|
||||
String upperButtonFunction = getDeviceSpecificPreferences().getString("top_button_function", "");
|
||||
String middleButtonFunction = getDeviceSpecificPreferences().getString("middle_button_function", "");
|
||||
String bottomButtonFunction = getDeviceSpecificPreferences().getString("bottom_button_function", "");
|
||||
|
||||
switch (requestType) {
|
||||
case 0x02: {
|
||||
byte syncId = value[2];
|
||||
getDeviceSupport().getDevice().addDeviceInfo(new GenericItem(QHybridSupport.ITEM_LAST_HEARTBEAT, DateFormat.getTimeInstance().format(new Date())));
|
||||
break;
|
||||
}
|
||||
case 0x08: { // FORWARD_TO_PHONE
|
||||
case 0x08: { // FORWARD_TO_PHONE / RING_PHONE
|
||||
if (value.length != 12) {
|
||||
throw new RuntimeException("wrong button message");
|
||||
}
|
||||
@@ -822,11 +828,20 @@ public class FossilWatchAdapter extends WatchAdapter {
|
||||
lastButtonIndex = index;
|
||||
log("Button press on button " + button);
|
||||
|
||||
Intent i = new Intent(QHYBRID_EVENT_BUTTON_PRESS);
|
||||
i.putExtra("BUTTON", button);
|
||||
getContext().sendBroadcast(i);
|
||||
if ((button == 1 && upperButtonFunction.equals("RING_PHONE"))
|
||||
|| (button == 2 && middleButtonFunction.equals("RING_PHONE"))
|
||||
|| (button == 3 && bottomButtonFunction.equals("RING_PHONE"))) {
|
||||
GBDeviceEventFindPhone findPhoneEvent = new GBDeviceEventFindPhone();
|
||||
findPhoneEvent.event = findPhoneActive ? GBDeviceEventFindPhone.Event.STOP : GBDeviceEventFindPhone.Event.START;
|
||||
getDeviceSupport().evaluateGBDeviceEvent(findPhoneEvent);
|
||||
findPhoneActive = !findPhoneActive;
|
||||
} else {
|
||||
Intent i = new Intent(QHYBRID_EVENT_BUTTON_PRESS);
|
||||
i.putExtra("BUTTON", button);
|
||||
getContext().sendBroadcast(i);
|
||||
|
||||
LOG.debug("Sent broadcast intent: ACTION={} EXTRA=BUTTON={}", QHYBRID_EVENT_BUTTON_PRESS, button);
|
||||
LOG.debug("Sent broadcast intent: ACTION={} EXTRA=BUTTON={}", QHYBRID_EVENT_BUTTON_PRESS, button);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -837,9 +852,6 @@ public class FossilWatchAdapter extends WatchAdapter {
|
||||
}
|
||||
int action = value[3];
|
||||
|
||||
String upperButtonFunction = getDeviceSpecificPreferences().getString("top_button_function", "");
|
||||
String middleButtonFunction = getDeviceSpecificPreferences().getString("middle_button_function", "");
|
||||
String bottomButtonFunction = getDeviceSpecificPreferences().getString("bottom_button_function", "");
|
||||
boolean musicControlEnabled = upperButtonFunction.equals("MUSIC_CONTROL") || middleButtonFunction.equals("MUSIC_CONTROL") || bottomButtonFunction.equals("MUSIC_CONTROL");
|
||||
MusicControlRequest.MUSIC_WATCH_REQUEST request = MusicControlRequest.MUSIC_WATCH_REQUEST.fromCommandByte((byte)action);
|
||||
GBDevice currentDevice = getDeviceSupport().getDevice();
|
||||
|
||||
+7
-2
@@ -22,7 +22,7 @@ import java.util.Arrays;
|
||||
|
||||
public enum ConfigPayload {
|
||||
FORWARD_TO_PHONE(
|
||||
"forward to phone",
|
||||
"forward to phone", // Identical to RING_PHONE, but handled differently in FossilWatchAdapter
|
||||
new byte[]{(byte) 0x01, (byte) 0x01, (byte) 0x0C, (byte) 0x00},
|
||||
new byte[]{(byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x0C, (byte) 0x2E, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x00, (byte) 0x02, (byte) 0x01, (byte) 0x0F, (byte) 0x00, (byte) 0x8B, (byte) 0x00, (byte) 0x00, (byte) 0x93, (byte) 0x00, (byte) 0x01, (byte) 0x08, (byte) 0x01, (byte) 0x14, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0xFE, (byte) 0x08, (byte) 0x00, (byte) 0x93, (byte) 0x00, (byte) 0x02, (byte) 0x01, (byte) 0x00, (byte) 0xBF, (byte) 0xD5, (byte) 0x54, (byte) 0xD1}
|
||||
),
|
||||
@@ -70,6 +70,11 @@ public enum ConfigPayload {
|
||||
"show step goal completion",
|
||||
new byte[]{(byte) 0x01, (byte) 0x02, (byte) 0x1C, (byte) 0x00},
|
||||
new byte[]{(byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x1C, (byte) 0x3E, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x07, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x27, (byte) 0x00, (byte) 0x89, (byte) 0x05, (byte) 0x01, (byte) 0x07, (byte) 0xB0, (byte) 0x08, (byte) 0x00, (byte) 0xB0, (byte) 0x08, (byte) 0x00, (byte) 0xB0, (byte) 0x08, (byte) 0x00, (byte) 0x08, (byte) 0x01, (byte) 0x05, (byte) 0x00, (byte) 0x89, (byte) 0x05, (byte) 0x01, (byte) 0x07, (byte) 0xF1, (byte) 0x04, (byte) 0x00, (byte) 0xF1, (byte) 0x04, (byte) 0x00, (byte) 0xF1, (byte) 0x04, (byte) 0x00, (byte) 0x08, (byte) 0x01, (byte) 0x50, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x0B, (byte) 0xD9, (byte) 0xCF, (byte) 0xDA}
|
||||
),
|
||||
RING_PHONE(
|
||||
"ring phone", // Identical to FORWARD_TO_PHONE, but handled differently in FossilWatchAdapter
|
||||
new byte[]{(byte) 0x01, (byte) 0x01, (byte) 0x0C, (byte) 0x00},
|
||||
new byte[]{(byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x0C, (byte) 0x2E, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x00, (byte) 0x02, (byte) 0x01, (byte) 0x0F, (byte) 0x00, (byte) 0x8B, (byte) 0x00, (byte) 0x00, (byte) 0x93, (byte) 0x00, (byte) 0x01, (byte) 0x08, (byte) 0x01, (byte) 0x14, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0xFE, (byte) 0x08, (byte) 0x00, (byte) 0x93, (byte) 0x00, (byte) 0x02, (byte) 0x01, (byte) 0x00, (byte) 0xBF, (byte) 0xD5, (byte) 0x54, (byte) 0xD1}
|
||||
)
|
||||
;
|
||||
private byte[] header, data;
|
||||
@@ -107,4 +112,4 @@ public enum ConfigPayload {
|
||||
this.header = header;
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5449,6 +5449,7 @@
|
||||
<item>@string/qhybrid_button_function_volume_down</item>
|
||||
<item>@string/qhybrid_button_function_step_goal</item>
|
||||
<item>@string/qhybrid_button_function_control_music</item>
|
||||
<item>@string/qhybrid_button_function_ring_phone</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="qhybrid_button_functions_values">
|
||||
@@ -5463,6 +5464,6 @@
|
||||
<item>VOLUME_DOWN</item>
|
||||
<item>STEP_GOAL_COMPLETION</item>
|
||||
<item>MUSIC_CONTROL</item>
|
||||
<item>RING_PHONE</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
@@ -4724,4 +4724,5 @@
|
||||
<string name="qhybrid_button_function_volume_down">Volume down</string>
|
||||
<string name="qhybrid_button_function_step_goal">Step goal progress</string>
|
||||
<string name="qhybrid_button_function_control_music">Control music player</string>
|
||||
<string name="qhybrid_button_function_ring_phone">Ring phone</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user