diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil/FossilWatchAdapter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil/FossilWatchAdapter.java
index 43f9707f3e..961d68871e 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil/FossilWatchAdapter.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil/FossilWatchAdapter.java
@@ -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();
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/buttonconfig/ConfigPayload.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/buttonconfig/ConfigPayload.java
index b1d936be12..4205b0a06f 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/buttonconfig/ConfigPayload.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/buttonconfig/ConfigPayload.java
@@ -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;
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index d77245d6d8..dea29387e2 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -5449,6 +5449,7 @@
- @string/qhybrid_button_function_volume_down
- @string/qhybrid_button_function_step_goal
- @string/qhybrid_button_function_control_music
+ - @string/qhybrid_button_function_ring_phone
@@ -5463,6 +5464,6 @@
- VOLUME_DOWN
- STEP_GOAL_COMPLETION
- MUSIC_CONTROL
+ - RING_PHONE
-
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index cb6384a728..5a142adaee 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -4724,4 +4724,5 @@
Volume down
Step goal progress
Control music player
+ Ring phone