1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-24 01:25:50 +01:00

Support selecting enabled navigation apps

This commit is contained in:
Arjan Schrijver 2023-11-19 21:08:22 +01:00
parent 70acf47a2e
commit fac566c7da
4 changed files with 56 additions and 28 deletions

View File

@ -160,16 +160,17 @@ public class OsmandEventReceiver {
} }
private boolean shouldSendNavigation() { private boolean shouldSendNavigation() {
final Prefs prefs = GBApplication.getPrefs(); Prefs prefs = GBApplication.getPrefs();
final boolean navigationForward = prefs.getBoolean("navigation_forward", true); boolean navigationForward = prefs.getBoolean("navigation_forward", true);
if (!navigationForward) { boolean navigationOsmAnd = prefs.getBoolean("navigation_app_osmand", true);
if (!navigationForward || !navigationOsmAnd) {
return false; return false;
} }
final boolean navigationScreenOn = prefs.getBoolean("nagivation_screen_on", true); boolean navigationScreenOn = prefs.getBoolean("nagivation_screen_on", true);
if (!navigationScreenOn) { if (!navigationScreenOn) {
final PowerManager powermanager = (PowerManager) app.getSystemService(Context.POWER_SERVICE); PowerManager powermanager = (PowerManager) app.getSystemService(Context.POWER_SERVICE);
if (powermanager != null && powermanager.isScreenOn()) { if (powermanager != null && powermanager.isScreenOn()) {
LOG.info("Not forwarding navigation instructions, screen seems to be on and settings do not allow this"); LOG.info("Not forwarding navigation instructions, screen seems to be on and settings do not allow this");
return false; return false;

View File

@ -992,7 +992,8 @@ public class GoogleMapsNotificationHandler {
Prefs prefs = GBApplication.getPrefs(); Prefs prefs = GBApplication.getPrefs();
boolean navigationForward = prefs.getBoolean("navigation_forward", true); boolean navigationForward = prefs.getBoolean("navigation_forward", true);
if (!navigationForward) { boolean navigationGMaps = prefs.getBoolean("navigation_app_gmaps", true);
if (!navigationForward || !navigationGMaps) {
shouldSendNavigation = false; shouldSendNavigation = false;
return; return;
} }

View File

@ -2400,4 +2400,8 @@
<string name="pref_summary_prefix_notification_with_app">Prefix notification title with name of source application</string> <string name="pref_summary_prefix_notification_with_app">Prefix notification title with name of source application</string>
<string name="pref_title_osmand_packagename">OsmAnd package name</string> <string name="pref_title_osmand_packagename">OsmAnd package name</string>
<string name="pref_summary_osmand_packagename">Used for selecting the version of OsmAnd to connect to</string> <string name="pref_summary_osmand_packagename">Used for selecting the version of OsmAnd to connect to</string>
<string name="pref_title_navigation_prefs">Navigation preferences</string>
<string name="pref_title_navigation_apps">Navigation apps</string>
<string name="pref_navigation_app_osmand">OsmAnd(+)</string>
<string name="pref_navigation_app_gmaps">Google Maps</string>
</resources> </resources>

View File

@ -204,6 +204,10 @@
<PreferenceCategory <PreferenceCategory
android:title="@string/pref_header_navigation" android:title="@string/pref_header_navigation"
app:iconSpaceReserved="false"> app:iconSpaceReserved="false">
<PreferenceScreen
android:key="navigation_settings"
android:title="@string/pref_title_navigation_prefs"
app:iconSpaceReserved="false">
<SwitchPreferenceCompat <SwitchPreferenceCompat
android:defaultValue="true" android:defaultValue="true"
android:key="navigation_forward" android:key="navigation_forward"
@ -226,6 +230,24 @@
android:summary="@string/pref_summary_osmand_packagename" android:summary="@string/pref_summary_osmand_packagename"
android:title="@string/pref_title_osmand_packagename" android:title="@string/pref_title_osmand_packagename"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<PreferenceCategory
android:key="navigation_apps_selection"
android:title="@string/pref_title_navigation_apps"
app:iconSpaceReserved="false">
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="navigation_app_osmand"
android:layout="@layout/preference_checkbox"
android:title="@string/pref_navigation_app_osmand"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="navigation_app_gmaps"
android:layout="@layout/preference_checkbox"
android:title="@string/pref_navigation_app_gmaps"
app:iconSpaceReserved="false" />
</PreferenceCategory>
</PreferenceScreen>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory <PreferenceCategory
android:title="@string/preferences_category_device_specific_settings" android:title="@string/preferences_category_device_specific_settings"