commit
d4897db5cd
10 changed files with 47 additions and 4 deletions
|
@ -11,6 +11,8 @@
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
<string name="navigation_notification_desc">Show system notification while navigation with navigation instructions.</string>
|
||||||
|
<string name="navigation_notification">Navigation notification</string>
|
||||||
<string name="please_provide_profile_name_message">Please provide a name for the profile</string>
|
<string name="please_provide_profile_name_message">Please provide a name for the profile</string>
|
||||||
<string name="open_settings">Open settings</string>
|
<string name="open_settings">Open settings</string>
|
||||||
<string name="plugin_disabled">Plugin disabled</string>
|
<string name="plugin_disabled">Plugin disabled</string>
|
||||||
|
|
|
@ -72,4 +72,12 @@
|
||||||
android:summaryOn="@string/shared_string_on"
|
android:summaryOn="@string/shared_string_on"
|
||||||
android:title="@string/animate_my_location" />
|
android:title="@string/animate_my_location" />
|
||||||
|
|
||||||
|
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
|
||||||
|
android:key="show_navigation_notification"
|
||||||
|
android:layout="@layout/preference_with_descr_dialog_and_switch"
|
||||||
|
android:summaryOff="@string/shared_string_disabled"
|
||||||
|
android:summaryOn="@string/shared_string_enabled"
|
||||||
|
android:title="@string/navigation_notification"
|
||||||
|
tools:icon="@drawable/ic_action_notification" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
|
@ -1973,6 +1973,8 @@ public class OsmandSettings {
|
||||||
SHOW_ZOOM_BUTTONS_NAVIGATION.setModeDefaultValue(ApplicationMode.PEDESTRIAN, true);
|
SHOW_ZOOM_BUTTONS_NAVIGATION.setModeDefaultValue(ApplicationMode.PEDESTRIAN, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final CommonPreference<Boolean> SHOW_NAVIGATION_NOTIFICATION = new BooleanPreference("show_navigation_notification", true).makeProfile();
|
||||||
|
|
||||||
// Json
|
// Json
|
||||||
public final OsmandPreference<String> SELECTED_GPX = new StringPreference("selected_gpx", "").makeGlobal();
|
public final OsmandPreference<String> SELECTED_GPX = new StringPreference("selected_gpx", "").makeGlobal();
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,7 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment
|
||||||
|
|
||||||
private void setupShowTripRecNotificationPref() {
|
private void setupShowTripRecNotificationPref() {
|
||||||
SwitchPreferenceEx showTripRecNotification = (SwitchPreferenceEx) findPreference(settings.SHOW_TRIP_REC_NOTIFICATION.getId());
|
SwitchPreferenceEx showTripRecNotification = (SwitchPreferenceEx) findPreference(settings.SHOW_TRIP_REC_NOTIFICATION.getId());
|
||||||
showTripRecNotification.setDescription(getString(R.string.trip_rec_notification_settings));
|
showTripRecNotification.setDescription(getString(R.string.trip_rec_notification_settings_desc));
|
||||||
showTripRecNotification.setIcon(getPersistentPrefIcon(R.drawable.ic_action_notification));
|
showTripRecNotification.setIcon(getPersistentPrefIcon(R.drawable.ic_action_notification));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,11 @@ public class DownloadNotification extends OsmandNotification {
|
||||||
return new Intent(app, DownloadActivity.class);
|
return new Intent(app, DownloadActivity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isUpdateDisabled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NotificationCompat.Builder buildNotification(boolean wearable) {
|
public NotificationCompat.Builder buildNotification(boolean wearable) {
|
||||||
icon = android.R.drawable.stat_sys_download;
|
icon = android.R.drawable.stat_sys_download;
|
||||||
|
|
|
@ -48,6 +48,11 @@ public class ErrorNotification extends OsmandNotification {
|
||||||
return new Intent(app, MapActivity.class);
|
return new Intent(app, MapActivity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isUpdateDisabled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NotificationCompat.Builder buildNotification(boolean wearable) {
|
public NotificationCompat.Builder buildNotification(boolean wearable) {
|
||||||
String notificationTitle;
|
String notificationTitle;
|
||||||
|
|
|
@ -103,6 +103,11 @@ public class GpxNotification extends OsmandNotification {
|
||||||
return new Intent(app, MapActivity.class);
|
return new Intent(app, MapActivity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isUpdateDisabled() {
|
||||||
|
return app.getSettings().MAP_ACTIVITY_ENABLED.get() && !app.getSettings().SHOW_TRIP_REC_NOTIFICATION.get();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNotificationDismissed() {
|
public void onNotificationDismissed() {
|
||||||
if (!wasNoDataDismissed) {
|
if (!wasNoDataDismissed) {
|
||||||
|
|
|
@ -114,6 +114,11 @@ public class NavigationNotification extends OsmandNotification {
|
||||||
|| (routingHelper.isRoutePlanningMode() && routingHelper.isPauseNavigation());
|
|| (routingHelper.isRoutePlanningMode() && routingHelper.isPauseNavigation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isUpdateDisabled() {
|
||||||
|
return app.getSettings().MAP_ACTIVITY_ENABLED.get() && !app.getSettings().SHOW_NAVIGATION_NOTIFICATION.get();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Intent getContentIntent() {
|
public Intent getContentIntent() {
|
||||||
return new Intent(app, MapActivity.class);
|
return new Intent(app, MapActivity.class);
|
||||||
|
|
|
@ -11,7 +11,6 @@ import android.support.v4.app.NotificationManagerCompat;
|
||||||
|
|
||||||
import net.osmand.plus.NotificationHelper;
|
import net.osmand.plus.NotificationHelper;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
|
||||||
|
|
||||||
public abstract class OsmandNotification {
|
public abstract class OsmandNotification {
|
||||||
|
|
||||||
|
@ -105,6 +104,8 @@ public abstract class OsmandNotification {
|
||||||
|
|
||||||
public abstract boolean isEnabled();
|
public abstract boolean isEnabled();
|
||||||
|
|
||||||
|
public abstract boolean isUpdateDisabled();
|
||||||
|
|
||||||
public abstract Intent getContentIntent();
|
public abstract Intent getContentIntent();
|
||||||
|
|
||||||
public void setupNotification(Notification notification) {
|
public void setupNotification(Notification notification) {
|
||||||
|
@ -125,7 +126,7 @@ public abstract class OsmandNotification {
|
||||||
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(app);
|
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(app);
|
||||||
if (isEnabled()) {
|
if (isEnabled()) {
|
||||||
Builder notificationBuilder = buildNotification(false);
|
Builder notificationBuilder = buildNotification(false);
|
||||||
if (notificationBuilder != null) {
|
if (notificationBuilder != null && !isUpdateDisabled()) {
|
||||||
Notification notification = getNotification(notificationBuilder, false);
|
Notification notification = getNotification(notificationBuilder, false);
|
||||||
setupNotification(notification);
|
setupNotification(notification);
|
||||||
notificationManager.notify(top ? TOP_NOTIFICATION_SERVICE_ID : getOsmandNotificationId(), notification);
|
notificationManager.notify(top ? TOP_NOTIFICATION_SERVICE_ID : getOsmandNotificationId(), notification);
|
||||||
|
@ -141,6 +142,9 @@ public abstract class OsmandNotification {
|
||||||
if (isEnabled()) {
|
if (isEnabled()) {
|
||||||
Builder notificationBuilder = buildNotification(false);
|
Builder notificationBuilder = buildNotification(false);
|
||||||
if (notificationBuilder != null) {
|
if (notificationBuilder != null) {
|
||||||
|
if (isUpdateDisabled()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Notification notification = getNotification(notificationBuilder, true);
|
Notification notification = getNotification(notificationBuilder, true);
|
||||||
setupNotification(notification);
|
setupNotification(notification);
|
||||||
if (top) {
|
if (top) {
|
||||||
|
|
|
@ -63,6 +63,7 @@ public class NavigationFragment extends BaseSettingsFragment {
|
||||||
|
|
||||||
setupSpeakRoutingAlarmsPref();
|
setupSpeakRoutingAlarmsPref();
|
||||||
setupVehicleParametersPref();
|
setupVehicleParametersPref();
|
||||||
|
setupNavigationNotificationPref();
|
||||||
|
|
||||||
animateMyLocation.setDescription(getString(R.string.animate_my_location_desc));
|
animateMyLocation.setDescription(getString(R.string.animate_my_location_desc));
|
||||||
}
|
}
|
||||||
|
@ -260,6 +261,12 @@ public class NavigationFragment extends BaseSettingsFragment {
|
||||||
vehicleParameters.setIcon(getContentIcon(iconRes));
|
vehicleParameters.setIcon(getContentIcon(iconRes));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupNavigationNotificationPref() {
|
||||||
|
SwitchPreferenceEx navigationNotification = (SwitchPreferenceEx) findPreference(settings.SHOW_NAVIGATION_NOTIFICATION.getId());
|
||||||
|
navigationNotification.setDescription(getString(R.string.navigation_notification_desc));
|
||||||
|
navigationNotification.setIcon(getPersistentPrefIcon(R.drawable.ic_action_notification));
|
||||||
|
}
|
||||||
|
|
||||||
private void updateMenu() {
|
private void updateMenu() {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
|
|
Loading…
Reference in a new issue