Add ability to disable notifications update

This commit is contained in:
Vitaliy 2020-02-17 14:20:19 +02:00
parent 00237eabda
commit 80906be53b
3 changed files with 17 additions and 3 deletions

View file

@ -103,6 +103,11 @@ public class GpxNotification extends OsmandNotification {
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
public void onNotificationDismissed() {
if (!wasNoDataDismissed) {

View file

@ -114,6 +114,11 @@ public class NavigationNotification extends OsmandNotification {
|| (routingHelper.isRoutePlanningMode() && routingHelper.isPauseNavigation());
}
@Override
public boolean isUpdateDisabled() {
return app.getSettings().MAP_ACTIVITY_ENABLED.get() && !app.getSettings().SHOW_NAVIGATION_NOTIFICATION.get();
}
@Override
public Intent getContentIntent() {
return new Intent(app, MapActivity.class);
@ -121,7 +126,7 @@ public class NavigationNotification extends OsmandNotification {
@Override
public Builder buildNotification(boolean wearable) {
if (!isEnabled() || !app.getSettings().SHOW_NAVIGATION_NOTIFICATION.get()) {
if (!isEnabled()) {
return null;
}
NavigationService service = app.getNavigationService();

View file

@ -11,7 +11,6 @@ import android.support.v4.app.NotificationManagerCompat;
import net.osmand.plus.NotificationHelper;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.activities.MapActivity;
public abstract class OsmandNotification {
@ -105,6 +104,8 @@ public abstract class OsmandNotification {
public abstract boolean isEnabled();
public abstract boolean isUpdateDisabled();
public abstract Intent getContentIntent();
public void setupNotification(Notification notification) {
@ -125,7 +126,7 @@ public abstract class OsmandNotification {
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(app);
if (isEnabled()) {
Builder notificationBuilder = buildNotification(false);
if (notificationBuilder != null) {
if (notificationBuilder != null && !isUpdateDisabled()) {
Notification notification = getNotification(notificationBuilder, false);
setupNotification(notification);
notificationManager.notify(top ? TOP_NOTIFICATION_SERVICE_ID : getOsmandNotificationId(), notification);
@ -141,6 +142,9 @@ public abstract class OsmandNotification {
if (isEnabled()) {
Builder notificationBuilder = buildNotification(false);
if (notificationBuilder != null) {
if (isUpdateDisabled()) {
return false;
}
Notification notification = getNotification(notificationBuilder, true);
setupNotification(notification);
if (top) {