1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-19 15:17: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() {
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;

View File

@ -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;
}

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_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_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>

View File

@ -204,28 +204,50 @@
<PreferenceCategory
android:title="@string/pref_header_navigation"
app:iconSpaceReserved="false">
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="navigation_forward"
android:layout="@layout/preference_checkbox"
android:summary="@string/pref_summary_navigation_forward"
android:title="@string/pref_title_navigation_forward"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:dependency="navigation_forward"
android:key="nagivation_screen_on"
android:layout="@layout/preference_checkbox"
android:title="@string/pref_title_whenscreenon"
app:iconSpaceReserved="false" />
<ListPreference
android:defaultValue="autodetect"
android:entries="@array/osmand_package_names"
android:entryValues="@array/osmand_package_names_values"
android:key="pref_key_osmand_packagename"
android:summary="@string/pref_summary_osmand_packagename"
android:title="@string/pref_title_osmand_packagename"
app:iconSpaceReserved="false" />
<PreferenceScreen
android:key="navigation_settings"
android:title="@string/pref_title_navigation_prefs"
app:iconSpaceReserved="false">
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="navigation_forward"
android:layout="@layout/preference_checkbox"
android:summary="@string/pref_summary_navigation_forward"
android:title="@string/pref_title_navigation_forward"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:dependency="navigation_forward"
android:key="nagivation_screen_on"
android:layout="@layout/preference_checkbox"
android:title="@string/pref_title_whenscreenon"
app:iconSpaceReserved="false" />
<ListPreference
android:defaultValue="autodetect"
android:entries="@array/osmand_package_names"
android:entryValues="@array/osmand_package_names_values"
android:key="pref_key_osmand_packagename"
android:summary="@string/pref_summary_osmand_packagename"
android:title="@string/pref_title_osmand_packagename"
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
android:title="@string/preferences_category_device_specific_settings"