From fac566c7da73d1ff923e7edaad6690e8324e6471 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Sun, 19 Nov 2023 21:08:22 +0100 Subject: [PATCH] Support selecting enabled navigation apps --- .../externalevents/OsmandEventReceiver.java | 11 ++-- .../GoogleMapsNotificationHandler.java | 3 +- app/src/main/res/values/strings.xml | 4 ++ app/src/main/res/xml/preferences.xml | 66 ++++++++++++------- 4 files changed, 56 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/OsmandEventReceiver.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/OsmandEventReceiver.java index 5dbb2c8d4..87db2ddc2 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/OsmandEventReceiver.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/OsmandEventReceiver.java @@ -160,16 +160,17 @@ public class OsmandEventReceiver { } private boolean shouldSendNavigation() { - final Prefs prefs = GBApplication.getPrefs(); + Prefs prefs = GBApplication.getPrefs(); - final boolean navigationForward = prefs.getBoolean("navigation_forward", true); - if (!navigationForward) { + boolean navigationForward = prefs.getBoolean("navigation_forward", true); + boolean navigationOsmAnd = prefs.getBoolean("navigation_app_osmand", true); + if (!navigationForward || !navigationOsmAnd) { return false; } - final boolean navigationScreenOn = prefs.getBoolean("nagivation_screen_on", true); + boolean navigationScreenOn = prefs.getBoolean("nagivation_screen_on", true); if (!navigationScreenOn) { - final PowerManager powermanager = (PowerManager) app.getSystemService(Context.POWER_SERVICE); + PowerManager powermanager = (PowerManager) app.getSystemService(Context.POWER_SERVICE); if (powermanager != null && powermanager.isScreenOn()) { LOG.info("Not forwarding navigation instructions, screen seems to be on and settings do not allow this"); return false; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/notifications/GoogleMapsNotificationHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/notifications/GoogleMapsNotificationHandler.java index 0417c53cb..74d68d36d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/notifications/GoogleMapsNotificationHandler.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/notifications/GoogleMapsNotificationHandler.java @@ -992,7 +992,8 @@ public class GoogleMapsNotificationHandler { Prefs prefs = GBApplication.getPrefs(); boolean navigationForward = prefs.getBoolean("navigation_forward", true); - if (!navigationForward) { + boolean navigationGMaps = prefs.getBoolean("navigation_app_gmaps", true); + if (!navigationForward || !navigationGMaps) { shouldSendNavigation = false; return; } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ac6b5a32e..dbc2399cd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2400,4 +2400,8 @@ Prefix notification title with name of source application OsmAnd package name Used for selecting the version of OsmAnd to connect to + Navigation preferences + Navigation apps + OsmAnd(+) + Google Maps diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 4d9be5373..f7525a9d3 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -204,28 +204,50 @@ - - - + + + + + + + + +