Skip to content

Commit

Permalink
Merge branch 'osmandapp:master' into hardy_Afa
Browse files Browse the repository at this point in the history
  • Loading branch information
sonora authored Sep 2, 2024
2 parents 864e01b + 5f6335a commit b207069
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 26 deletions.
8 changes: 4 additions & 4 deletions OsmAnd/res/values-uk/phrases.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4734,7 +4734,7 @@
<string name="poi_reservation">Резервування</string>
<string name="poi_us_maps_recreation_area_facility">Облаштування зони відпочинку</string>
<string name="poi_photo_booth">Фотокабінка</string>
<string name="poi_us_maps_recreation_area_activity_backpacking">Рюкзак для подорожей</string>
<string name="poi_us_maps_recreation_area_activity_backpacking">Туристичний похід</string>
<string name="poi_padus_area">Зона PAD-US</string>
<string name="poi_padus_category_proclamation">Категорія: проголошення</string>
<string name="poi_padus_category_fee">Категорія: плата</string>
Expand All @@ -4751,12 +4751,12 @@
<string name="poi_padus_public_access_unknown">Доступ: невідомо</string>
<string name="poi_padus_public_access_closed">Доступ: закрито</string>
<string name="poi_us_maps_recreation_area_activity_beachcombing">Прочісування пляжу</string>
<string name="poi_us_maps_recreation_area_activity_bicycling">Велосипедна прогулянка</string>
<string name="poi_us_maps_recreation_area_activity_bicycling">Велопрогулянка</string>
<string name="poi_us_maps_recreation_area_activity_big_game_hunting">Полювання на велику дичину</string>
<string name="poi_us_maps_recreation_area_activity_boating_motorized">Моторне катання на човнах</string>
<string name="poi_us_maps_recreation_area_activity_boating_motorized">Катання на моторизованих човнах</string>
<string name="poi_us_maps_recreation_area_facility_cabin_rentals">Оренда кабіни</string>
<string name="poi_live_music_yes">Так</string>
<string name="poi_us_maps_recreation_area_activity_boating_non_motorized">Безмоторне катання на човнах</string>
<string name="poi_us_maps_recreation_area_activity_boating_non_motorized">Катання на немоторизованих човнах</string>
<string name="poi_us_maps_recreation_area_activity_campground_camping">Кемпінг в наметовому містечку</string>
<string name="poi_via">Через</string>
<string name="poi_us_maps_recreation_area_activity_interpretive_areas">Зони інтерпретації</string>
Expand Down
4 changes: 3 additions & 1 deletion OsmAnd/src/net/osmand/plus/NavigationService.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import net.osmand.plus.auto.NavigationSession;
import net.osmand.plus.helpers.LocationCallback;
import net.osmand.plus.helpers.LocationServiceHelper;
import net.osmand.plus.notifications.OsmandNotification.NotificationType;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.settings.enums.LocationSource;
Expand Down Expand Up @@ -137,7 +138,8 @@ public int onStartCommand(Intent intent, int flags, int startId) {
locationServiceHelper = app.createLocationServiceHelper();
app.setNavigationService(this);

Notification notification = app.getNotificationHelper().buildTopNotification(this);
Notification notification = app.getNotificationHelper().buildTopNotification(this,
isUsedBy(USED_BY_NAVIGATION) ? NotificationType.NAVIGATION : NotificationType.GPX);
boolean hasNotification = notification != null;
if (hasNotification) {
try {
Expand Down
61 changes: 40 additions & 21 deletions OsmAnd/src/net/osmand/plus/notifications/NotificationHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,36 @@ private void init() {
}

@Nullable
public Notification buildTopNotification(@NonNull Service service) {
OsmandNotification notification = acquireTopNotification(service);
if (notification != null) {
removeNotification(notification.getType());
setTopNotification(notification);
Builder notificationBuilder = notification.buildNotification(service, false);
if (notificationBuilder != null) {
return notificationBuilder.build();
} else {
return null;
public Notification buildTopNotification(@NonNull Service service, @NonNull NotificationType type) {
List<OsmandNotification> notifications = acquireTopNotifications(service);
for (OsmandNotification notification : notifications) {
if (notification.getType() == type) {
Notification topNotification = buildTopNotification(service, notification);
if (topNotification != null) {
return topNotification;
}
}
} else {
return null;
}
for (OsmandNotification notification : notifications) {
if (notification.getType() != type) {
Notification topNotification = buildTopNotification(service, notification);
if (topNotification != null) {
return topNotification;
}
}
}
return null;
}

@Nullable
private Notification buildTopNotification(@NonNull Service service, @NonNull OsmandNotification notification) {
removeNotification(notification.getType());
setTopNotification(notification);
Builder notificationBuilder = notification.buildNotification(service, false);
if (notificationBuilder != null) {
return notificationBuilder.build();
}
return null;
}

@NonNull
Expand All @@ -78,15 +94,16 @@ public Notification buildCarAppNotification() {
return carAppNotification.buildNotification(null, false).build();
}

@Nullable
private OsmandNotification acquireTopNotification(@Nullable Service service) {
@NonNull
private List<OsmandNotification> acquireTopNotifications(@Nullable Service service) {
List<OsmandNotification> res = new ArrayList<>();
if (navigationNotification.isEnabled(service)) {
return navigationNotification;
} else if (gpxNotification.isEnabled(service)) {
return gpxNotification;
} else {
return null;
res.add(navigationNotification);
}
if (gpxNotification.isEnabled(service)) {
res.add(gpxNotification);
}
return res;
}

public void resetTopNotification() {
Expand All @@ -96,8 +113,10 @@ public void resetTopNotification() {
}

public void updateTopNotification() {
OsmandNotification notification = acquireTopNotification(null);
setTopNotification(notification);
List<OsmandNotification> notifications = acquireTopNotifications(null);
if (!notifications.isEmpty()) {
setTopNotification(notifications.get(0));
}
}

private void setTopNotification(OsmandNotification notification) {
Expand Down

0 comments on commit b207069

Please sign in to comment.