From 5e26ec37d9bb677d7e55d007a33f3ea4bf3f6217 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Fri, 25 May 2018 17:43:35 +0300 Subject: [PATCH 01/19] Fix small issues with new progress bar --- OsmAnd/src/net/osmand/plus/activities/MapActivity.java | 4 ++++ .../osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 57303e6765..55dc81013b 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -440,6 +440,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven if (pbExtView.getVisibility() == View.VISIBLE) { pbExtView.setVisibility(View.GONE); } + if (MapRouteInfoMenu.isVisible()) { + pb.setVisibility(View.GONE); + return; + } if (pb.getVisibility() == View.GONE) { pb.setVisibility(View.VISIBLE); } diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java index e17c31b794..0edd5072d6 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java @@ -764,7 +764,6 @@ public class RouteInfoWidgetsFactory { private int dist; private LanesDrawable lanesDrawable; private View centerInfo; - private View progress; private int shadowRadius; public LanesControl(final MapActivity map, final OsmandMapTileView view) { @@ -772,7 +771,6 @@ public class RouteInfoWidgetsFactory { lanesText = (TextView) map.findViewById(R.id.map_lanes_dist_text); lanesShadowText = (TextView) map.findViewById(R.id.map_lanes_dist_text_shadow); centerInfo = (View) map.findViewById(R.id.map_center_info); - progress = (View) map.findViewById(R.id.map_horizontal_progress); lanesDrawable = new LanesDrawable(map, map.getMapView().getScaleCoefficient()); lanesView.setImageDrawable(lanesDrawable); trackingUtilities = map.getMapViewTrackingUtilities(); @@ -859,7 +857,7 @@ public class RouteInfoWidgetsFactory { updateVisibility(lanesShadowText, visible && shadowRadius > 0); updateVisibility(lanesText, visible); updateVisibility(lanesView, visible); - updateVisibility(centerInfo, visible || progress.getVisibility() == View.VISIBLE); + updateVisibility(centerInfo, visible); return true; } } From 0d1c54f534a3821f1d29205e612f4498ba910e77 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Fri, 25 May 2018 15:38:50 +0300 Subject: [PATCH 02/19] Fix methods for receiving location --- .../osmand/plus/OsmAndLocationProvider.java | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java index 5b2611e2c2..16f2538a1f 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java @@ -5,6 +5,7 @@ import java.util.Arrays; import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; import net.osmand.GeoidAltitudeCorrection; import net.osmand.PlatformUtil; @@ -70,12 +71,12 @@ public class OsmAndLocationProvider implements SensorEventListener { private static final int GPS_DIST_REQUEST = 0; private static final int NOT_SWITCH_TO_NETWORK_WHEN_GPS_LOST_MS = 12000; - private static final long STALE_LOCATION_TIMEOUT = 1000 * 60 * 5; // 5 minutes - private static final long STALE_LOCATION_TIMEOUT_FOR_UI = 1000 * 60 * 15; // 15 minutes + private static final long LOCATION_TIMEOUT_TO_BE_STALE = 1000 * 60 * 2; // 2 minutes + private static final long STALE_LOCATION_TIMEOUT_TO_BE_GONE = 1000 * 60 * 20; // 20 minutes private static final int REQUESTS_BEFORE_CHECK_LOCATION = 100; - private int locationRequestsCounter; - private int staleLocationRequestsCounter; + private AtomicInteger locationRequestsCounter = new AtomicInteger(); + private AtomicInteger staleLocationRequestsCounter = new AtomicInteger(); private net.osmand.Location cachedLocation; @@ -869,15 +870,15 @@ public class OsmAndLocationProvider implements SensorEventListener { } public net.osmand.Location getLastKnownLocation() { - net.osmand.Location location = this.location; - if (location != null && locationRequestsCounter == 0 - && System.currentTimeMillis() - location.getTime() > STALE_LOCATION_TIMEOUT) { - location = null; - } - if (locationRequestsCounter == REQUESTS_BEFORE_CHECK_LOCATION) { - locationRequestsCounter = 0; - } else { - locationRequestsCounter++; + net.osmand.Location loc = this.location; + if (loc != null) { + int counter = locationRequestsCounter.incrementAndGet(); + if (counter >= REQUESTS_BEFORE_CHECK_LOCATION && locationRequestsCounter.compareAndSet(counter, 0)) { + net.osmand.Location cached = cachedLocation; + if (cached != null && System.currentTimeMillis() - cached.getTime() > LOCATION_TIMEOUT_TO_BE_STALE) { + location = null; + } + } } return location; } @@ -885,19 +886,17 @@ public class OsmAndLocationProvider implements SensorEventListener { @Nullable public net.osmand.Location getLastStaleKnownLocation() { net.osmand.Location newLoc = getLastKnownLocation(); - if (newLoc == null) { - if (staleLocationRequestsCounter == 0 && cachedLocation != null - && System.currentTimeMillis() - cachedLocation.getTime() > STALE_LOCATION_TIMEOUT_FOR_UI) { - cachedLocation = null; + if (newLoc == null && cachedLocation != null) { + int counter = staleLocationRequestsCounter.incrementAndGet(); + if (counter >= REQUESTS_BEFORE_CHECK_LOCATION && staleLocationRequestsCounter.compareAndSet(counter, 0)) { + net.osmand.Location cached = cachedLocation; + if (cached != null && System.currentTimeMillis() - cached.getTime() > STALE_LOCATION_TIMEOUT_TO_BE_GONE) { + cachedLocation = null; + } } } else { cachedLocation = newLoc; } - if (staleLocationRequestsCounter == REQUESTS_BEFORE_CHECK_LOCATION) { - staleLocationRequestsCounter = 0; - } else { - staleLocationRequestsCounter++; - } return cachedLocation; } From 285d3c1a6c60f8b274008e66a53823ed16413cdb Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Fri, 25 May 2018 15:43:36 +0300 Subject: [PATCH 03/19] Replace cached location with current --- OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java index 16f2538a1f..69394cb8fe 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java @@ -874,8 +874,7 @@ public class OsmAndLocationProvider implements SensorEventListener { if (loc != null) { int counter = locationRequestsCounter.incrementAndGet(); if (counter >= REQUESTS_BEFORE_CHECK_LOCATION && locationRequestsCounter.compareAndSet(counter, 0)) { - net.osmand.Location cached = cachedLocation; - if (cached != null && System.currentTimeMillis() - cached.getTime() > LOCATION_TIMEOUT_TO_BE_STALE) { + if (System.currentTimeMillis() - loc.getTime() > LOCATION_TIMEOUT_TO_BE_STALE) { location = null; } } From 1385b5e267e6d27ead3dea3bb16de14433208f42 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Fri, 25 May 2018 18:08:31 +0300 Subject: [PATCH 04/19] Merge --- .../activities/OsmandActionBarActivity.java | 3 +- .../plus/mapcontextmenu/MenuBuilder.java | 6 +- .../builders/AmenityMenuBuilder.java | 59 +++++++++++++------ .../quickaction/QuickActionListFragment.java | 3 +- 4 files changed, 49 insertions(+), 22 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/OsmandActionBarActivity.java b/OsmAnd/src/net/osmand/plus/activities/OsmandActionBarActivity.java index 5162339969..91af8c103b 100644 --- a/OsmAnd/src/net/osmand/plus/activities/OsmandActionBarActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/OsmandActionBarActivity.java @@ -19,8 +19,7 @@ public class OsmandActionBarActivity extends OsmandInAppPurchaseActivity { //should be called after set content view protected void setupHomeButton(){ - Drawable back = ((OsmandApplication)getApplication()).getIconsCache().getIcon(R.drawable.ic_arrow_back); - back.setColorFilter(ContextCompat.getColor(this, R.color.color_white), PorterDuff.Mode.MULTIPLY); + Drawable back = ((OsmandApplication)getApplication()).getIconsCache().getIcon(R.drawable.ic_arrow_back, R.color.color_white); final ActionBar supportActionBar = getSupportActionBar(); if (supportActionBar != null) { supportActionBar.setHomeButtonEnabled(true); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 6bd5beaf65..3605b06f02 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -13,6 +13,7 @@ import android.net.Uri; import android.os.AsyncTask; import android.support.annotation.NonNull; import android.support.v4.content.ContextCompat; +import android.support.v4.graphics.drawable.DrawableCompat; import android.support.v7.view.ContextThemeWrapper; import android.text.ClipboardManager; import android.text.TextUtils; @@ -752,7 +753,10 @@ public class MenuBuilder { public Drawable getRowIcon(Context ctx, String fileName) { Drawable d = RenderingIcons.getBigIcon(ctx, fileName); if (d != null) { - d.setColorFilter(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_icon_light : R.color.ctx_menu_bottom_view_icon_dark), PorterDuff.Mode.SRC_IN); + d = DrawableCompat.wrap(d); + d.mutate(); + d.setColorFilter(app.getResources().getColor(light + ? R.color.ctx_menu_bottom_view_icon_light : R.color.ctx_menu_bottom_view_icon_dark), PorterDuff.Mode.SRC_IN); return d; } else { return null; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index 5edc09f0fa..6479301de4 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -25,6 +25,7 @@ import net.osmand.data.Amenity; import net.osmand.data.PointDescription; import net.osmand.osm.AbstractPoiType; import net.osmand.osm.MapPoiTypes; +import net.osmand.osm.PoiCategory; import net.osmand.osm.PoiType; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; @@ -49,6 +50,7 @@ import java.util.Calendar; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; +import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -344,6 +346,7 @@ public class AmenityMenuBuilder extends MenuBuilder { Map> poiAdditionalCategories = new HashMap<>(); AmenityInfoRow cuisineRow = null; + List collectedPoiTypes = new ArrayList<>(); for (Map.Entry e : amenity.getAdditionalInfo().entrySet()) { int iconId = 0; @@ -362,14 +365,15 @@ public class AmenityMenuBuilder extends MenuBuilder { boolean isWiki = false; boolean isText = false; boolean isDescription = false; - boolean needLinks = !("population".equals(key) - || "height".equals(key)); + boolean needLinks = !("population".equals(key) || "height".equals(key)); boolean isPhoneNumber = false; boolean isUrl = false; boolean isCuisine = false; int poiTypeOrder = 0; String poiTypeKeyName = ""; + PoiType poiType = amenity.getType().getPoiTypeByKeyName(key); + AbstractPoiType pt = poiTypes.getAnyPoiAdditionalTypeByKey(key); if (pt == null && !Algorithms.isEmpty(vl) && vl.length() < 50) { pt = poiTypes.getAnyPoiAdditionalTypeByKey(key + "_" + vl); @@ -501,6 +505,8 @@ public class AmenityMenuBuilder extends MenuBuilder { if (icon == null && isText && iconId == 0) { iconId = R.drawable.ic_action_note_dark; } + } else if (poiType != null) { + collectedPoiTypes.add(poiType); } else { textPrefix = Algorithms.capitalizeFirstLetterAndLowercase(e.getKey()); vl = amenity.unzipContent(e.getValue()); @@ -524,12 +530,10 @@ public class AmenityMenuBuilder extends MenuBuilder { } if (isDescription) { descriptions.add(row); - } else { - if (!isCuisine) { - infoRows.add(row); - } else { - cuisineRow = row; - } + } else if (isCuisine) { + cuisineRow = row; + } else if (poiType == null) { + infoRows.add(row); } } @@ -568,12 +572,27 @@ public class AmenityMenuBuilder extends MenuBuilder { sb.append(pt.getTranslation()); } boolean cuisineOrDish = categoryName.equals(Amenity.CUISINE) || categoryName.equals(Amenity.DISH); - CollapsableView collapsableView = getPoiAdditionalCollapsableView(view.getContext(), true, categoryTypes, cuisineOrDish ? cuisineRow : null); + CollapsableView collapsableView = getPoiTypeCollapsableView(view.getContext(), true, categoryTypes, true, cuisineOrDish ? cuisineRow : null); infoRows.add(new AmenityInfoRow(poiAdditionalCategoryName, icon, pType.getPoiAdditionalCategoryTranslation(), sb.toString(), true, collapsableView, 0, false, false, false, pType.getOrder(), pType.getKeyName(), false, false, false, 1)); } } + if (collectedPoiTypes.size() > 0) { + CollapsableView collapsableView = getPoiTypeCollapsableView(view.getContext(), true, collectedPoiTypes, false, null); + PoiCategory poiCategory = amenity.getType(); + Drawable icon = getRowIcon(view.getContext(), poiCategory.getIconKeyName()); + StringBuilder sb = new StringBuilder(); + for (PoiType pt : collectedPoiTypes) { + if (sb.length() > 0) { + sb.append(" • "); + } + sb.append(pt.getTranslation()); + } + infoRows.add(new AmenityInfoRow(poiCategory.getKeyName(), icon, poiCategory.getTranslation(), sb.toString(), true, collapsableView, + 0, false, false, false, 40, poiCategory.getKeyName(), false, false, false, 1)); + } + Collections.sort(infoRows, new Comparator() { @Override public int compare(AmenityInfoRow row1, AmenityInfoRow row2) { @@ -664,9 +683,9 @@ public class AmenityMenuBuilder extends MenuBuilder { return params; } - private CollapsableView getPoiAdditionalCollapsableView( - final Context context, boolean collapsed, - @NonNull final List categoryTypes, AmenityInfoRow textCuisineRow) { + private CollapsableView getPoiTypeCollapsableView(final Context context, boolean collapsed, + @NonNull final List categoryTypes, + final boolean poiAdditional, AmenityInfoRow textRow) { final List buttons = new ArrayList<>(); @@ -684,9 +703,15 @@ public class AmenityMenuBuilder extends MenuBuilder { PoiUIFilter filter = app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + amenity.getType().getKeyName()); if (filter != null) { filter.clearFilter(); - filter.setTypeToAccept(amenity.getType(), true); - filter.updateTypesToAccept(pt); - filter.setFilterByName(pt.getKeyName().replace('_', ':').toLowerCase()); + if (poiAdditional) { + filter.setTypeToAccept(amenity.getType(), true); + filter.updateTypesToAccept(pt); + filter.setFilterByName(pt.getKeyName().replace('_', ':').toLowerCase()); + } else { + LinkedHashSet accept = new LinkedHashSet<>(); + accept.add(pt.getKeyName()); + filter.selectSubTypesToAccept(amenity.getType(), accept); + } getMapActivity().showQuickSearch(filter); } } @@ -699,9 +724,9 @@ public class AmenityMenuBuilder extends MenuBuilder { view.addView(button); } - if (textCuisineRow != null) { + if (textRow != null) { TextViewEx button = buildButtonInCollapsableView(context, true, false, false); - String name = textCuisineRow.textPrefix + ": " + textCuisineRow.text.toLowerCase(); + String name = textRow.textPrefix + ": " + textRow.text.toLowerCase(); button.setText(name); view.addView(button); } diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java index a0adce7a5c..913903d041 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java @@ -109,8 +109,7 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick private void setUpToolbar(View view) { Toolbar toolbar = (Toolbar) view.findViewById(R.id.custom_toolbar); - Drawable back = getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back); - back.setColorFilter(ContextCompat.getColor(getContext(), R.color.color_white), PorterDuff.Mode.MULTIPLY); + Drawable back = getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back, R.color.color_white); toolbar.setNavigationIcon(back); toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up); toolbar.setNavigationOnClickListener(new View.OnClickListener() { From 17f4dfb7c4a2b4606b7b8dac70fbac738af505f2 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Fri, 25 May 2018 18:25:44 +0300 Subject: [PATCH 05/19] Fix OsmAndLocationProvider#scheduleCheckIfGpsLost --- .../osmand/plus/OsmAndLocationProvider.java | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java index 69394cb8fe..52da10c065 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java @@ -691,7 +691,8 @@ public class OsmAndLocationProvider implements SensorEventListener { private void scheduleCheckIfGpsLost(final net.osmand.Location location) { final RoutingHelper routingHelper = app.getRoutingHelper(); - if (location != null) { + if (location != null && routingHelper.isFollowingMode() && routingHelper.getLeftDistance() > 0 + && simulatePosition == null) { final long fixTime = location.getTime(); app.runMessageInUIThreadAndCancelPrevious(LOST_LOCATION_MSG_ID, new Runnable() { @@ -709,25 +710,23 @@ public class OsmAndLocationProvider implements SensorEventListener { setLocation(null); } }, LOST_LOCATION_CHECK_DELAY); - if (routingHelper.isFollowingMode() && routingHelper.getLeftDistance() > 0 && simulatePosition == null) { - app.runMessageInUIThreadAndCancelPrevious(START_SIMULATE_LOCATION_MSG_ID, new Runnable() { + app.runMessageInUIThreadAndCancelPrevious(START_SIMULATE_LOCATION_MSG_ID, new Runnable() { - @Override - public void run() { - net.osmand.Location lastKnown = getLastKnownLocation(); - if (lastKnown != null && lastKnown.getTime() > fixTime) { - // false positive case, still strange how we got here with removeMessages - return; - } - List tunnel = routingHelper.getUpcomingTunnel(1000); - if(tunnel != null) { - simulatePosition = new SimulationProvider(); - simulatePosition.startSimulation(tunnel, location); - simulatePositionImpl(); - } + @Override + public void run() { + net.osmand.Location lastKnown = getLastKnownLocation(); + if (lastKnown != null && lastKnown.getTime() > fixTime) { + // false positive case, still strange how we got here with removeMessages + return; } - }, START_LOCATION_SIMULATION_DELAY); - } + List tunnel = routingHelper.getUpcomingTunnel(1000); + if(tunnel != null) { + simulatePosition = new SimulationProvider(); + simulatePosition.startSimulation(tunnel, location); + simulatePositionImpl(); + } + } + }, START_LOCATION_SIMULATION_DELAY); } } From ae2df017ef08bbc0d2a363ce7d4c5a983798868e Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Fri, 25 May 2018 18:32:46 +0300 Subject: [PATCH 06/19] Add check for "setLocation(null)" --- OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java index 52da10c065..81ddb09e66 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java @@ -706,8 +706,10 @@ public class OsmAndLocationProvider implements SensorEventListener { gpsSignalLost = true; if (routingHelper.isFollowingMode() && routingHelper.getLeftDistance() > 0) { routingHelper.getVoiceRouter().gpsLocationLost(); + if (simulatePosition == null) { + setLocation(null); + } } - setLocation(null); } }, LOST_LOCATION_CHECK_DELAY); app.runMessageInUIThreadAndCancelPrevious(START_SIMULATE_LOCATION_MSG_ID, new Runnable() { From 27b88ea389eb58b98a48b6f7d7ddabb993e0bc8d Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Fri, 25 May 2018 18:40:28 +0300 Subject: [PATCH 07/19] Fix check for "setLocation(null)" --- OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java index 81ddb09e66..c98be15d2e 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java @@ -704,11 +704,10 @@ public class OsmAndLocationProvider implements SensorEventListener { return; } gpsSignalLost = true; - if (routingHelper.isFollowingMode() && routingHelper.getLeftDistance() > 0) { + if (routingHelper.isFollowingMode() && routingHelper.getLeftDistance() > 0 + && simulatePosition == null) { routingHelper.getVoiceRouter().gpsLocationLost(); - if (simulatePosition == null) { - setLocation(null); - } + setLocation(null); } } }, LOST_LOCATION_CHECK_DELAY); From 85e2e19801fb1909b7541459d0b7322c5be58e14 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Fri, 25 May 2018 18:52:18 +0300 Subject: [PATCH 08/19] Fix #5309 --- .../net/osmand/plus/views/OsmandMapTileView.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java index 58fb851fd5..7b0c5479fa 100644 --- a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java +++ b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java @@ -373,7 +373,10 @@ public class OsmandMapTileView implements IMapDownloaderCallback { if (mainLayer != null) { animatedDraggingThread.stopAnimating(); currentViewport.setZoomAndAnimation(zoom, 0, 0); - currentViewport.setRotate(zoom > LOWEST_ZOOM_TO_ROTATE ? rotate : 0); + if (zoom <= LOWEST_ZOOM_TO_ROTATE) { + rotate = 0; + } + currentViewport.setRotate(rotate); refreshMap(); } } @@ -383,7 +386,10 @@ public class OsmandMapTileView implements IMapDownloaderCallback { animatedDraggingThread.stopAnimating(); currentViewport.setZoomAndAnimation(zoom, 0); currentViewport.setMapDensity(mapDensity); - currentViewport.setRotate(zoom > LOWEST_ZOOM_TO_ROTATE ? rotate : 0); + if (zoom <= LOWEST_ZOOM_TO_ROTATE) { + rotate = 0; + } + currentViewport.setRotate(rotate); refreshMap(); } } @@ -899,7 +905,10 @@ public class OsmandMapTileView implements IMapDownloaderCallback { protected void zoomToAnimate(int zoom, double zoomToAnimate, boolean notify) { if (mainLayer != null && getMaxZoom() >= zoom && getMinZoom() <= zoom) { currentViewport.setZoomAndAnimation(zoom, zoomToAnimate); - currentViewport.setRotate(zoom > LOWEST_ZOOM_TO_ROTATE ? rotate : 0); + if (zoom <= LOWEST_ZOOM_TO_ROTATE) { + rotate = 0; + } + currentViewport.setRotate(rotate); refreshMap(); if (notify && locationListener != null) { locationListener.locationChanged(getLatitude(), getLongitude(), this); From f8246c5cf476fbe85335281325046c6ace751175 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Fri, 25 May 2018 23:12:50 +0200 Subject: [PATCH 09/19] Fix #5003 --- .../src/net/osmand/binary/RouteDataObject.java | 13 +++++++++++++ .../src/net/osmand/router/RouteSegmentResult.java | 3 +++ 2 files changed, 16 insertions(+) diff --git a/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java b/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java index 6bf172ad4a..c599e471fe 100644 --- a/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java +++ b/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java @@ -236,6 +236,7 @@ public class RouteDataObject { } return null; } + public String getName(String lang){ return getName(lang, false); @@ -684,6 +685,18 @@ public class RouteDataObject { } return direction; } + + public boolean isRoadDeleted() { + int[] pt = getTypes(); + int sz = pt.length; + for (int i = 0; i < sz; i++) { + RouteTypeRule r = region.quickGetEncodingRule(pt[i]); + if ("osmand_change".equals(r.getTag()) && "delete".equals(r.getValue())) { + return true; + } + } + return false; + } public boolean isStopApplicable(boolean direction, int intId, int startPointInd, int endPointInd) { int[] pt = getPointTypes(intId); diff --git a/OsmAnd-java/src/net/osmand/router/RouteSegmentResult.java b/OsmAnd-java/src/net/osmand/router/RouteSegmentResult.java index 77db8130f2..6ee9fbbb52 100644 --- a/OsmAnd-java/src/net/osmand/router/RouteSegmentResult.java +++ b/OsmAnd-java/src/net/osmand/router/RouteSegmentResult.java @@ -71,6 +71,9 @@ public class RouteSegmentResult { } public void attachRoute(int roadIndex, RouteSegmentResult r){ + if(r.getObject().isRoadDeleted()) { + return; + } int st = Math.abs(roadIndex - startPointIndex); if(attachedRoutes[st] == null) { attachedRoutes[st] = new ArrayList(); From df88bf74bec86e56384a36d9e735bb9a451e1be0 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sat, 26 May 2018 00:02:57 +0200 Subject: [PATCH 10/19] Fix turn lanes bug (a test fix) --- .../src/net/osmand/router/RouteResultPreparation.java | 4 ++-- OsmAnd-java/src/net/osmand/router/TurnType.java | 10 ++++++---- OsmAnd-java/test/resources/test_turn_lanes.json | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java b/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java index e4a1d69649..a066d14946 100644 --- a/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java +++ b/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java @@ -743,9 +743,9 @@ public class RouteResultPreparation { } } } - if(straightActiveLen == target.activeLen) { + if(straightActiveBegin != -1 && straightActiveLen <= target.activeLen) { active.activeStartIndex = straightActiveBegin; - active.activeEndIndex = straightActiveBegin + target.activeLen - 1; + active.activeEndIndex = straightActiveBegin + straightActiveLen - 1; changed = true; } else { // cause the next-turn goes forward exclude left most and right most lane diff --git a/OsmAnd-java/src/net/osmand/router/TurnType.java b/OsmAnd-java/src/net/osmand/router/TurnType.java index 873825c0ea..c1f4e4bd88 100644 --- a/OsmAnd-java/src/net/osmand/router/TurnType.java +++ b/OsmAnd-java/src/net/osmand/router/TurnType.java @@ -416,11 +416,13 @@ public class TurnType { public static int convertType(String lane) { int turn; // merge should be recognized as continue route (but it could displayed differently) - if (lane.equals("none") || lane.equals("through") - || lane.equals("merge_to_left") - || lane.equals("merge_to_right")) { + if(lane.equals("merge_to_left")) { turn = TurnType.C; - } else if (lane.equals("slight_right") ) { + } else if(lane.equals("merge_to_right")) { + turn = TurnType.C; + } else if (lane.equals("none") || lane.equals("through")) { + turn = TurnType.C; + } else if (lane.equals("slight_right")) { turn = TurnType.TSLR; } else if (lane.equals("slight_left") ) { turn = TurnType.TSLL; diff --git a/OsmAnd-java/test/resources/test_turn_lanes.json b/OsmAnd-java/test/resources/test_turn_lanes.json index 8598eee117..b743a2e731 100644 --- a/OsmAnd-java/test/resources/test_turn_lanes.json +++ b/OsmAnd-java/test/resources/test_turn_lanes.json @@ -595,8 +595,8 @@ }, "expectedResults": { "222244": "TL|TL|+C,TR", - "222243": "TL|TL|+C|C|TSLR", - "222164": "TL|TL|+C|C" + "222243": "TL|TL|+C|+C|TSLR", + "222164": "TL|TL|+C|+C" } }, { From be1bb0e2575f262e20dcd1fc805cb22365f2c1dd Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sat, 26 May 2018 11:25:57 +0200 Subject: [PATCH 11/19] Avoid potential crash --- .../osmand/plus/resources/IncrementalChangesManager.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/resources/IncrementalChangesManager.java b/OsmAnd/src/net/osmand/plus/resources/IncrementalChangesManager.java index bfa84f2fdf..9c965ab78b 100644 --- a/OsmAnd/src/net/osmand/plus/resources/IncrementalChangesManager.java +++ b/OsmAnd/src/net/osmand/plus/resources/IncrementalChangesManager.java @@ -161,10 +161,12 @@ public class IncrementalChangesManager { if(date.endsWith("00")) { monthUpdates.put(monthYear, ru); } else { - if (!dayUpdates.containsKey(monthYear)) { - dayUpdates.put(monthYear, new ArrayList()); + List list = dayUpdates.get(monthYear); + if (list == null) { + list = new ArrayList(); } - dayUpdates.get(monthYear).add(ru); + list.add(ru); + dayUpdates.put(monthYear, list); } return true; } From c503c78c707e2f1136450c71f4c365f6d946b179 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sat, 26 May 2018 11:30:14 +0200 Subject: [PATCH 12/19] Fix NPE --- .../net/osmand/plus/resources/IncrementalChangesManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/resources/IncrementalChangesManager.java b/OsmAnd/src/net/osmand/plus/resources/IncrementalChangesManager.java index 9c965ab78b..fba620ff0b 100644 --- a/OsmAnd/src/net/osmand/plus/resources/IncrementalChangesManager.java +++ b/OsmAnd/src/net/osmand/plus/resources/IncrementalChangesManager.java @@ -94,6 +94,9 @@ public class IncrementalChangesManager { RegionUpdate monthRu = regionUpdateFiles.monthUpdates.get(month); while (it.hasNext()) { RegionUpdate ru = it.next(); + if(ru == null) { + continue; + } if (ru.obfCreated < dateCreated || (monthRu != null && ru.obfCreated < monthRu.obfCreated)) { log.info("Delete overlapping day update " + ru.file.getName()); From 86376c9ed89cdbfa6bf6e2ce24c07c9114d9a699 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sat, 26 May 2018 11:36:33 +0200 Subject: [PATCH 13/19] Try to avoid npe #5496 --- .../mapcontextmenu/editors/FavoritePointEditorFragment.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java index 436ccc3a6d..ea1cdc9fb2 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/FavoritePointEditorFragment.java @@ -183,6 +183,9 @@ public class FavoritePointEditorFragment extends PointEditorFragment { } else { helper.editFavouriteName(favorite, name, category, description); } + if(getMapActivity() == null) { + return; + } getMapActivity().refreshMap(); if (needDismiss) { dismiss(false); From 4fc3b20e5d5458943bab5f4124d37f5aade0650b Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 28 May 2018 22:12:20 +0200 Subject: [PATCH 14/19] Fix crashes --- OsmAnd/src/net/osmand/plus/AppInitializer.java | 4 ++-- OsmAnd/src/net/osmand/plus/GPXUtilities.java | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 9fb04f29ba..99232cface 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -13,7 +13,7 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.os.Build; import android.support.v7.app.AlertDialog; - +import android.util.Log; import net.osmand.IProgress; import net.osmand.IndexConstants; import net.osmand.PlatformUtil; @@ -67,7 +67,6 @@ import java.util.Locale; import java.util.Random; import btools.routingapp.BRouterServiceConnection; - import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getPendingIntent; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLastCheck; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLiveUpdatesOn; @@ -353,6 +352,7 @@ public class AppInitializer implements IProgress { return app.getString(in); } } catch (Exception e) { + LOG.info("No translation: " + keyName); } return null; } diff --git a/OsmAnd/src/net/osmand/plus/GPXUtilities.java b/OsmAnd/src/net/osmand/plus/GPXUtilities.java index b7a2168538..0edaec5933 100644 --- a/OsmAnd/src/net/osmand/plus/GPXUtilities.java +++ b/OsmAnd/src/net/osmand/plus/GPXUtilities.java @@ -1231,7 +1231,9 @@ public class GPXUtilities { public static String writeGpxFile(File fout, GPXFile file, OsmandApplication ctx) { Writer output = null; try { - fout.getParentFile().mkdirs(); + if(fout.getParentFile() != null) { + fout.getParentFile().mkdirs(); + } output = new OutputStreamWriter(new FileOutputStream(fout), "UTF-8"); //$NON-NLS-1$ String msg = writeGpx(output, file, ctx); if(Algorithms.isEmpty(file.path)) { From ada8c2a998844bcc88549c7f983351ae56522130 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 28 May 2018 22:12:41 +0200 Subject: [PATCH 15/19] Fix crashes --- OsmAnd/src/net/osmand/plus/AppInitializer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 99232cface..7ab054d9cd 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -351,7 +351,7 @@ public class AppInitializer implements IProgress { Integer in = (Integer) f.get(null); return app.getString(in); } - } catch (Exception e) { + } catch (Throwable e) { LOG.info("No translation: " + keyName); } return null; From 846bd3fcfa16462da03e36e29592c4a95cbc345b Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 29 May 2018 10:25:35 +0200 Subject: [PATCH 16/19] try to wrap db --- .../src/net/osmand/plus/api/SQLiteAPIImpl.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/api/SQLiteAPIImpl.java b/OsmAnd/src/net/osmand/plus/api/SQLiteAPIImpl.java index 8ed2827e6b..7199388596 100644 --- a/OsmAnd/src/net/osmand/plus/api/SQLiteAPIImpl.java +++ b/OsmAnd/src/net/osmand/plus/api/SQLiteAPIImpl.java @@ -1,15 +1,19 @@ package net.osmand.plus.api; +import net.osmand.PlatformUtil; +import net.osmand.plus.OsmandApplication; + +import org.apache.commons.logging.Log; + import android.annotation.SuppressLint; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; -import net.osmand.plus.OsmandApplication; - public class SQLiteAPIImpl implements SQLiteAPI { private OsmandApplication app; + private static final Log LOG = PlatformUtil.getLog(SQLiteAPIImpl.class); public SQLiteAPIImpl(OsmandApplication app) { this.app = app; @@ -18,9 +22,13 @@ public class SQLiteAPIImpl implements SQLiteAPI { @SuppressLint("InlinedApi") @Override public SQLiteConnection getOrCreateDatabase(String name, boolean readOnly) { - android.database.sqlite.SQLiteDatabase db = app.openOrCreateDatabase(name, - Context.MODE_PRIVATE | - (readOnly ? 0 : Context.MODE_ENABLE_WRITE_AHEAD_LOGGING), null); + android.database.sqlite.SQLiteDatabase db = null; + try { + db = app.openOrCreateDatabase(name, Context.MODE_PRIVATE + | (readOnly ? 0 : Context.MODE_ENABLE_WRITE_AHEAD_LOGGING), null); + } catch (RuntimeException e) { + LOG.error(e.getMessage(), e); + } if(db == null) { return null; } From 5c7b4cf719aa3f48916250f3ae904238df04f071 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Tue, 29 May 2018 12:46:07 +0300 Subject: [PATCH 17/19] The "later" button on travel cards hides the card until the application is restarted --- .../src/net/osmand/plus/AppInitializer.java | 2 ++ .../src/net/osmand/plus/OsmandSettings.java | 3 ++ .../explore/ExploreTabFragment.java | 29 +++++++++++++++++-- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 7ab054d9cd..aacab9a87a 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -177,6 +177,8 @@ public class AppInitializer implements IProgress { startPrefs.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit(); appVersionChanged = true; } + app.getSettings().SHOW_TRAVEL_UPDATE_CARD.set(true); + app.getSettings().SHOW_TRAVEL_NEEDED_MAPS_CARD.set(true); initSettings = true; } diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 33c424033a..242d543373 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -3006,6 +3006,9 @@ public class OsmandSettings { public final OsmandPreference SELECTED_TRAVEL_BOOK = new StringPreference("selected_travel_book", "").makeGlobal(); + public final OsmandPreference SHOW_TRAVEL_UPDATE_CARD = new BooleanPreference("show_travel_update_card", true).makeGlobal(); + public final OsmandPreference SHOW_TRAVEL_NEEDED_MAPS_CARD = new BooleanPreference("show_travel_needed_maps_card", true).makeGlobal(); + public final ListStringPreference TRANSPORT_DEFAULT_SETTINGS = (ListStringPreference) new ListStringPreference("transport_default_settings", "transportStops", ",").makeProfile(); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java index 047a66fd16..2f05c8c578 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java @@ -16,6 +16,7 @@ import android.view.ViewGroup; import net.osmand.data.LatLon; import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.Version; import net.osmand.plus.base.BaseOsmAndFragment; @@ -206,6 +207,22 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv addNeededMapsCard(); } + private boolean showUpdateCard() { + OsmandSettings settings = getSettings(); + if (settings != null) { + return settings.SHOW_TRAVEL_UPDATE_CARD.get(); + } + return false; + } + + private boolean showNeededMapsCard() { + OsmandSettings settings = getSettings(); + if (settings != null) { + return settings.SHOW_TRAVEL_NEEDED_MAPS_CARD.get(); + } + return false; + } + private void addDownloadUpdateCard() { final OsmandApplication app = getMyApplication(); if (app != null && adapter != null) { @@ -214,7 +231,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv boolean outdated = mainIndexItem != null && mainIndexItem.isOutdated(); File selectedTravelBook = app.getTravelDbHelper().getSelectedTravelBook(); - if (selectedTravelBook == null || outdated) { + if (selectedTravelBook == null || (outdated && showUpdateCard())) { boolean showOtherMaps = false; if (selectedTravelBook == null) { List items = downloadThread.getIndexes().getWikivoyageItems(); @@ -238,6 +255,10 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv downloadThread.cancelDownload(mainIndexItem); adapter.updateDownloadUpdateCard(false); } else if (!downloadUpdateCard.isDownload()) { + OsmandSettings settings = getSettings(); + if (settings != null) { + settings.SHOW_TRAVEL_UPDATE_CARD.set(false); + } removeDownloadUpdateCard(); } else if (downloadUpdateCard.isShowOtherMapsBtn()) { Activity activity = getActivity(); @@ -258,7 +279,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv private void addNeededMapsCard() { final OsmandApplication app = getMyApplication(); - if (app != null && !neededIndexItems.isEmpty() && adapter != null) { + if (app != null && !neededIndexItems.isEmpty() && adapter != null && showNeededMapsCard()) { neededMapsCard = new TravelNeededMapsCard(app, nightMode, neededIndexItems); neededMapsCard.setListener(new TravelNeededMapsCard.CardListener() { @Override @@ -277,6 +298,10 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv adapter.updateNeededMapsCard(false); } } else { + OsmandSettings settings = getSettings(); + if (settings != null) { + settings.SHOW_TRAVEL_NEEDED_MAPS_CARD.set(false); + } removeNeededMapsCard(); } } From c9f8057b136afe5b990130baff7110f730a06789 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Tue, 29 May 2018 12:59:21 +0300 Subject: [PATCH 18/19] Remove redundant code --- .../explore/ExploreTabFragment.java | 31 +++---------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java index 2f05c8c578..7f4ac20953 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java @@ -16,7 +16,6 @@ import android.view.ViewGroup; import net.osmand.data.LatLon; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.Version; import net.osmand.plus.base.BaseOsmAndFragment; @@ -207,22 +206,6 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv addNeededMapsCard(); } - private boolean showUpdateCard() { - OsmandSettings settings = getSettings(); - if (settings != null) { - return settings.SHOW_TRAVEL_UPDATE_CARD.get(); - } - return false; - } - - private boolean showNeededMapsCard() { - OsmandSettings settings = getSettings(); - if (settings != null) { - return settings.SHOW_TRAVEL_NEEDED_MAPS_CARD.get(); - } - return false; - } - private void addDownloadUpdateCard() { final OsmandApplication app = getMyApplication(); if (app != null && adapter != null) { @@ -231,7 +214,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv boolean outdated = mainIndexItem != null && mainIndexItem.isOutdated(); File selectedTravelBook = app.getTravelDbHelper().getSelectedTravelBook(); - if (selectedTravelBook == null || (outdated && showUpdateCard())) { + if (selectedTravelBook == null || (outdated && app.getSettings().SHOW_TRAVEL_UPDATE_CARD.get())) { boolean showOtherMaps = false; if (selectedTravelBook == null) { List items = downloadThread.getIndexes().getWikivoyageItems(); @@ -255,10 +238,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv downloadThread.cancelDownload(mainIndexItem); adapter.updateDownloadUpdateCard(false); } else if (!downloadUpdateCard.isDownload()) { - OsmandSettings settings = getSettings(); - if (settings != null) { - settings.SHOW_TRAVEL_UPDATE_CARD.set(false); - } + app.getSettings().SHOW_TRAVEL_UPDATE_CARD.set(false); removeDownloadUpdateCard(); } else if (downloadUpdateCard.isShowOtherMapsBtn()) { Activity activity = getActivity(); @@ -279,7 +259,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv private void addNeededMapsCard() { final OsmandApplication app = getMyApplication(); - if (app != null && !neededIndexItems.isEmpty() && adapter != null && showNeededMapsCard()) { + if (app != null && !neededIndexItems.isEmpty() && adapter != null && app.getSettings().SHOW_TRAVEL_NEEDED_MAPS_CARD.get()) { neededMapsCard = new TravelNeededMapsCard(app, nightMode, neededIndexItems); neededMapsCard.setListener(new TravelNeededMapsCard.CardListener() { @Override @@ -298,10 +278,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv adapter.updateNeededMapsCard(false); } } else { - OsmandSettings settings = getSettings(); - if (settings != null) { - settings.SHOW_TRAVEL_NEEDED_MAPS_CARD.set(false); - } + app.getSettings().SHOW_TRAVEL_NEEDED_MAPS_CARD.set(false); removeNeededMapsCard(); } } From fd16da1f8163a58ca08071158e6d3dda8f94f24a Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Tue, 29 May 2018 14:15:45 +0300 Subject: [PATCH 19/19] Fix #5502 --- OsmAnd/src/net/osmand/plus/views/OsmandMapLayer.java | 4 ++++ OsmAnd/src/net/osmand/plus/views/POIMapLayer.java | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/OsmandMapLayer.java b/OsmAnd/src/net/osmand/plus/views/OsmandMapLayer.java index 5969853e95..767e0cd10e 100644 --- a/OsmAnd/src/net/osmand/plus/views/OsmandMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/OsmandMapLayer.java @@ -313,6 +313,9 @@ public abstract class OsmandMapLayer { } } + public void layerOnPreExecute() { + } + public void layerOnPostExecute() { } @@ -350,6 +353,7 @@ public abstract class OsmandMapLayer { @Override protected void onPreExecute() { currentTask = this; + layerOnPreExecute(); } @Override diff --git a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java index 731534a28b..311e452981 100644 --- a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java @@ -94,16 +94,20 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon return super.isInterrupted(); } + + @Override + public void layerOnPreExecute() { + calculatedFilters = new TreeSet<>(filters); + } + @Override public void layerOnPostExecute() { - filters = calculatedFilters; activity.getMapView().refreshMap(); } @Override protected List calculateResult(RotatedTileBox tileBox) { QuadRect latLonBounds = tileBox.getLatLonBounds(); - calculatedFilters = filters; if (calculatedFilters.isEmpty() || latLonBounds == null) { return new ArrayList<>(); }