mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-19 23:27:48 +01:00
Support selecting enabled navigation apps
This commit is contained in:
parent
70acf47a2e
commit
fac566c7da
@ -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;
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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>
|
||||||
|
@ -204,28 +204,50 @@
|
|||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="@string/pref_header_navigation"
|
android:title="@string/pref_header_navigation"
|
||||||
app:iconSpaceReserved="false">
|
app:iconSpaceReserved="false">
|
||||||
<SwitchPreferenceCompat
|
<PreferenceScreen
|
||||||
android:defaultValue="true"
|
android:key="navigation_settings"
|
||||||
android:key="navigation_forward"
|
android:title="@string/pref_title_navigation_prefs"
|
||||||
android:layout="@layout/preference_checkbox"
|
app:iconSpaceReserved="false">
|
||||||
android:summary="@string/pref_summary_navigation_forward"
|
<SwitchPreferenceCompat
|
||||||
android:title="@string/pref_title_navigation_forward"
|
android:defaultValue="true"
|
||||||
app:iconSpaceReserved="false" />
|
android:key="navigation_forward"
|
||||||
<SwitchPreferenceCompat
|
android:layout="@layout/preference_checkbox"
|
||||||
android:defaultValue="true"
|
android:summary="@string/pref_summary_navigation_forward"
|
||||||
android:dependency="navigation_forward"
|
android:title="@string/pref_title_navigation_forward"
|
||||||
android:key="nagivation_screen_on"
|
app:iconSpaceReserved="false" />
|
||||||
android:layout="@layout/preference_checkbox"
|
<SwitchPreferenceCompat
|
||||||
android:title="@string/pref_title_whenscreenon"
|
android:defaultValue="true"
|
||||||
app:iconSpaceReserved="false" />
|
android:dependency="navigation_forward"
|
||||||
<ListPreference
|
android:key="nagivation_screen_on"
|
||||||
android:defaultValue="autodetect"
|
android:layout="@layout/preference_checkbox"
|
||||||
android:entries="@array/osmand_package_names"
|
android:title="@string/pref_title_whenscreenon"
|
||||||
android:entryValues="@array/osmand_package_names_values"
|
app:iconSpaceReserved="false" />
|
||||||
android:key="pref_key_osmand_packagename"
|
<ListPreference
|
||||||
android:summary="@string/pref_summary_osmand_packagename"
|
android:defaultValue="autodetect"
|
||||||
android:title="@string/pref_title_osmand_packagename"
|
android:entries="@array/osmand_package_names"
|
||||||
app:iconSpaceReserved="false" />
|
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>
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="@string/preferences_category_device_specific_settings"
|
android:title="@string/preferences_category_device_specific_settings"
|
||||||
|
Loading…
Reference in New Issue
Block a user