From d8af8bede0fc9868aa0f079c132ad614d187e1c1 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Mon, 2 Jan 2023 15:15:48 +0100 Subject: [PATCH] Fossil/Skagen Hybrids: Allow launching watch apps from app manager --- .../assets/fossil_hr/openSourceWatchface.bin | Bin 8690 -> 8734 bytes .../AbstractAppManagerFragment.java | 6 +++ .../AppManagerFragmentInstalledApps.java | 41 ++++++++++-------- .../devices/qhybrid/QHybridConstants.java | 2 +- .../devices/qhybrid/QHybridSupport.java | 4 +- .../fossil_hr/FossilHRWatchAdapter.java | 17 ++++++++ external/fossil-hr-watchface | 2 +- 7 files changed, 50 insertions(+), 22 deletions(-) diff --git a/app/src/main/assets/fossil_hr/openSourceWatchface.bin b/app/src/main/assets/fossil_hr/openSourceWatchface.bin index e8980fe3b8497513493b1bea4d8879eea261bcea..17987ff4ff46569cf79d4fb3dc61a8947ad1bc31 100644 GIT binary patch delta 629 zcmYk2OKTHh6o#LfrkOO8OTSE}O^dzgW~Q4&gmk18H&F-N2*rgJtb`&1x+&U%C@Q!~ zKoDUzu3FIA&%13Wjcq7R?Pk_Oq$}6i`wL{6g`UlOIGp!#&Y#NarOeg2x%mRUN(^mf zE-E9h(ooOA`y8A%pl-lf6J7^*l!~63MBy|sr7u1@>Nir?pLO4Ww+v3atd$nUY=q^+ zv0^J?Y?gsNCn?NgCu#RNx}7?*V~#$RN^ka^tYteHCtmugT^O`!JMpq8EsAo49TCli zBRV;|-!b-`{EXSEriAX~XNK(Iwh}dFt2!(y>WN9bTqrFHBf?`f;udBZvDNk!$e$!u zRaH$0c>}C|sMSEe1#2DTy8kh~DztYHUIS|b!iUiH=QH<&E5Ta>?FqQIAoPD_)|Aj+ z$xe)0pTK$v-e-^ktSPA71^ETsul{!S>E-YPcrPH5i6pddJsB?sZV{|aaPv^x`kx9~ z9Xt~>1Hxcs&{2ovHiVDC)uHCRb}h z_#L{tAosv)`5Q*@T-X9{AHpg zFJadWoErSUnHIY`?eJj0n^N%N$xA#7-X)#L-sSt{@!t3QeQ)F3@7estxw)$q4(gY& zlRqOJxs`*(BCHjmqQjyNssYR44QW=%jv{f4lq9D|M*L>>@;y6UAFM5CGYQtkcgd2p zu^EPT?P1NR_J%Fl&REJPYrxJ-DcS9T{#d@3v(vS&gQp7?T{~S@YYSRE!JeA*Ra@<8 zR?05!*?ObYnO8K$)*FUZ?n((Mb>_>OoOoP-6O{UiWLcJnwBQPuY4ALVAA!3C@s|H3 zx1l+YA-V+a6Nr|<^l#^HYTi?DH$mJ5=NbtAPkvJp{(50z++<8cU16TBvf7I@cT5^xgU@>ldmF=~N$2WA`MHUzu=XT5q#bRc*SQ4Y*K zhzj5y1@8lxqY#XN`4NH&I1}J?!;__H>3Cu;_QBmxLVz><@2>wZ30IAFCOkX&L;4Fk CFNrDu diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/appmanager/AbstractAppManagerFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/appmanager/AbstractAppManagerFragment.java index 60d9fc3e5..41e8eec8e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/appmanager/AbstractAppManagerFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/appmanager/AbstractAppManagerFragment.java @@ -148,6 +148,12 @@ public abstract class AbstractAppManagerFragment extends Fragment { appList.add(app); } } + if (mGBDevice.getType() == DeviceType.FOSSILQHYBRID) { + List systemApps = getSystemAppsInCategory(); + for (GBDeviceApp systemApp : systemApps) { + appList.add(systemApp); + } + } } private Bitmap getAppPreviewImage(String name) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/appmanager/AppManagerFragmentInstalledApps.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/appmanager/AppManagerFragmentInstalledApps.java index 7a4dceaf8..69eb1e65c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/appmanager/AppManagerFragmentInstalledApps.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/appmanager/AppManagerFragmentInstalledApps.java @@ -16,6 +16,7 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.activities.appmanager; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -30,27 +31,29 @@ public class AppManagerFragmentInstalledApps extends AbstractAppManagerFragment @Override protected List getSystemAppsInCategory() { List systemApps = new ArrayList<>(); - if (mGBDevice.getType() != DeviceType.PEBBLE) { - return systemApps; - } - //systemApps.add(new GBDeviceApp(UUID.fromString("4dab81a6-d2fc-458a-992c-7a1f3b96a970"), "Sports (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM)); - //systemApps.add(new GBDeviceApp(UUID.fromString("cf1e816a-9db0-4511-bbb8-f60c48ca8fac"), "Golf (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM)); - systemApps.add(new GBDeviceApp(UUID.fromString("1f03293d-47af-4f28-b960-f2b02a6dd757"), "Music (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM)); - systemApps.add(new GBDeviceApp(PebbleProtocol.UUID_NOTIFICATIONS, "Notifications (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM)); - systemApps.add(new GBDeviceApp(UUID.fromString("67a32d95-ef69-46d4-a0b9-854cc62f97f9"), "Alarms (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM)); - systemApps.add(new GBDeviceApp(UUID.fromString("18e443ce-38fd-47c8-84d5-6d0c775fbe55"), "Watchfaces (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM)); - if (mGBDevice != null) { - if (PebbleUtils.hasHealth(mGBDevice.getModel())) { - systemApps.add(new GBDeviceApp(UUID.fromString("0863fc6a-66c5-4f62-ab8a-82ed00a98b5d"), "Send Text (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM)); - systemApps.add(new GBDeviceApp(PebbleProtocol.UUID_PEBBLE_HEALTH, "Health (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM)); - } - if (PebbleUtils.hasHRM(mGBDevice.getModel())) { - systemApps.add(new GBDeviceApp(PebbleProtocol.UUID_WORKOUT, "Workout (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM)); - } - if (PebbleUtils.getFwMajor(mGBDevice.getFirmwareVersion()) >= 4) { - systemApps.add(new GBDeviceApp(PebbleProtocol.UUID_WEATHER, "Weather (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM)); + if (mGBDevice.getType() == DeviceType.PEBBLE) { + //systemApps.add(new GBDeviceApp(UUID.fromString("4dab81a6-d2fc-458a-992c-7a1f3b96a970"), "Sports (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM)); + //systemApps.add(new GBDeviceApp(UUID.fromString("cf1e816a-9db0-4511-bbb8-f60c48ca8fac"), "Golf (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM)); + systemApps.add(new GBDeviceApp(UUID.fromString("1f03293d-47af-4f28-b960-f2b02a6dd757"), "Music (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM)); + systemApps.add(new GBDeviceApp(PebbleProtocol.UUID_NOTIFICATIONS, "Notifications (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM)); + systemApps.add(new GBDeviceApp(UUID.fromString("67a32d95-ef69-46d4-a0b9-854cc62f97f9"), "Alarms (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM)); + systemApps.add(new GBDeviceApp(UUID.fromString("18e443ce-38fd-47c8-84d5-6d0c775fbe55"), "Watchfaces (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM)); + + if (mGBDevice != null) { + if (PebbleUtils.hasHealth(mGBDevice.getModel())) { + systemApps.add(new GBDeviceApp(UUID.fromString("0863fc6a-66c5-4f62-ab8a-82ed00a98b5d"), "Send Text (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM)); + systemApps.add(new GBDeviceApp(PebbleProtocol.UUID_PEBBLE_HEALTH, "Health (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM)); + } + if (PebbleUtils.hasHRM(mGBDevice.getModel())) { + systemApps.add(new GBDeviceApp(PebbleProtocol.UUID_WORKOUT, "Workout (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM)); + } + if (PebbleUtils.getFwMajor(mGBDevice.getFirmwareVersion()) >= 4) { + systemApps.add(new GBDeviceApp(PebbleProtocol.UUID_WEATHER, "Weather (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM)); + } } + } else if (mGBDevice.getType() == DeviceType.FOSSILQHYBRID) { + systemApps.add(new GBDeviceApp(UUID.nameUUIDFromBytes("workoutApp".getBytes(StandardCharsets.UTF_8)), "workoutApp", "", "", GBDeviceApp.Type.APP_ACTIVITYTRACKER)); } return systemApps; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/QHybridConstants.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/QHybridConstants.java index c18ae482f..097d95087 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/QHybridConstants.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/QHybridConstants.java @@ -22,7 +22,7 @@ import java.util.Map; import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind; public final class QHybridConstants { - public static final String HYBRIDHR_WATCHFACE_VERSION = "1.8"; + public static final String HYBRIDHR_WATCHFACE_VERSION = "1.9"; public static final int HYBRID_HR_WATCHFACE_WIDGET_SIZE = 76; public static Map KNOWN_WAPP_VERSIONS = new HashMap() { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/QHybridSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/QHybridSupport.java index 09b7a5a8f..3a8611d81 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/QHybridSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/QHybridSupport.java @@ -825,7 +825,9 @@ public class QHybridSupport extends QHybridBaseSupport { public void onAppStart(UUID uuid, boolean start) { if(this.watchAdapter instanceof FossilHRWatchAdapter) { String appName = ((FossilHRWatchAdapter) watchAdapter).getInstalledAppNameFromUUID(uuid); - if (appName != null) { + if ((appName != null) && (appName.endsWith("App"))) { + ((FossilHRWatchAdapter) watchAdapter).startAppOnWatch(appName); + } else { ((FossilHRWatchAdapter) watchAdapter).activateWatchface(appName); } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java index 806dca8f2..aa08eeb9f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java @@ -472,6 +472,20 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter { queueWrite(new SelectedThemePutRequest(this, appName)); } + public void startAppOnWatch(String appName) { + try { + JSONObject jsonObject = new JSONObject() + .put("push", new JSONObject() + .put("set", new JSONObject() + .put("customWatchFace._.config.start_app", appName) + ) + ); + queueWrite(new JsonPutRequest(jsonObject, this)); + } catch (JSONException e) { + LOG.warn("Couldn't start app on watch: " + e.getMessage()); + } + } + private void setVibrationStrengthFromConfig() { Prefs prefs = new Prefs(getDeviceSpecificPreferences()); int vibrationStrengh = prefs.getInt(DeviceSettingsPreferenceConst.PREF_VIBRATION_STRENGH_PERCENTAGE, 2); @@ -1859,6 +1873,9 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter { return appInfo.getAppName(); } } + if (uuid.equals(UUID.nameUUIDFromBytes("workoutApp".getBytes(StandardCharsets.UTF_8)))) { + return "workoutApp"; + } return null; } } diff --git a/external/fossil-hr-watchface b/external/fossil-hr-watchface index 1f7c07473..1a58411e8 160000 --- a/external/fossil-hr-watchface +++ b/external/fossil-hr-watchface @@ -1 +1 @@ -Subproject commit 1f7c07473b9232b59c51c4d9daaa29aab815db45 +Subproject commit 1a58411e8fe32d1a1a80982fdc5775b4529cf8d1