Add ability to disable notifications update
This commit is contained in:
parent
00237eabda
commit
80906be53b
3 changed files with 17 additions and 3 deletions
|
@ -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);
|
||||||
|
@ -121,7 +126,7 @@ public class NavigationNotification extends OsmandNotification {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Builder buildNotification(boolean wearable) {
|
public Builder buildNotification(boolean wearable) {
|
||||||
if (!isEnabled() || !app.getSettings().SHOW_NAVIGATION_NOTIFICATION.get()) {
|
if (!isEnabled()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
NavigationService service = app.getNavigationService();
|
NavigationService service = app.getNavigationService();
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in a new issue