From 9653acecc173fd8c02bd4c4fc2ae8317f52df00a Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 9 Feb 2021 03:41:27 +0200 Subject: [PATCH 1/2] Fix #10775 --- .../osmand/plus/dashboard/DashboardOnMap.java | 4 +- .../osmand/plus/dialogs/RasterMapMenu.java | 8 +-- .../plus/rastermaps/MapUnderlayAction.java | 12 ++-- .../rastermaps/OsmandRasterMapsPlugin.java | 29 ++++++-- .../plus/render/MapRenderRepositories.java | 72 +++++++++---------- .../plus/srtmplugin/ContourLinesAction.java | 4 +- .../plus/srtmplugin/ContourLinesMenu.java | 11 +-- .../osmand/plus/srtmplugin/SRTMPlugin.java | 7 +- .../osmand/plus/srtmplugin/TerrainAction.java | 4 +- 9 files changed, 79 insertions(+), 72 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index bb2143c7eb..f1685b87c9 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -96,6 +96,8 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import static net.osmand.plus.dialogs.ConfigureMapMenu.refreshMapComplete; + public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInformationListener { private static final org.apache.commons.logging.Log LOG = PlatformUtil.getLog(DashboardOnMap.class); @@ -777,7 +779,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInfo plugin.registerLayers(mapActivity); } } - SRTMPlugin.refreshMapComplete(mapActivity); + refreshMapComplete(mapActivity); } else if (visibleType == DashboardType.WIKIPEDIA) { refreshContent(true); } diff --git a/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java index 54cb7ba447..1cbdc27a8e 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java @@ -20,6 +20,8 @@ import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin; import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin.OnMapSelectedCallback; import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin.RasterMapType; +import static net.osmand.plus.dialogs.ConfigureMapMenu.refreshMapComplete; + public class RasterMapMenu { private static final String TAG = "RasterMapMenu"; public static ContextMenuAdapter createListAdapter(final MapActivity mapActivity, @@ -180,10 +182,4 @@ public class RasterMapMenu { LayerTransparencySeekbarMode seekbarMode = app.getSettings().LAYER_TRANSPARENCY_SEEKBAR_MODE.get(); return seekbarMode == LayerTransparencySeekbarMode.UNDEFINED || seekbarMode == currentMapTypeSeekbarMode; } - - public static void refreshMapComplete(final MapActivity activity) { - activity.getMyApplication().getResourceManager().getRenderer().clearCache(); - activity.updateMapSettings(); - activity.getMapView().refreshMap(true); - } } diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java index ca79cb4895..b313009f4c 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java @@ -15,20 +15,21 @@ import com.google.gson.reflect.TypeToken; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; -import net.osmand.plus.settings.backend.CommonPreference; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.quickaction.QuickAction; import net.osmand.plus.quickaction.QuickActionType; import net.osmand.plus.quickaction.SwitchableAction; +import net.osmand.plus.settings.backend.OsmandSettings; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; import java.util.Map; +import static net.osmand.plus.dialogs.ConfigureMapMenu.refreshMapComplete; + public class MapUnderlayAction extends SwitchableAction> { private final static String KEY_UNDERLAYS = "underlays"; @@ -141,14 +142,9 @@ public class MapUnderlayAction extends SwitchableAction> { settings.MAP_UNDERLAY.set(null); activity.getMapLayers().getMapControlsLayer().hideTransparencyBar(); settings.MAP_UNDERLAY_PREVIOUS.set(null); - - } - final CommonPreference hidePolygonsPref = - activity.getMyApplication().getSettings().getCustomRenderBooleanProperty("noPolygons"); - hidePolygonsPref.set(hasUnderlay); - plugin.updateMapLayers(activity.getMapView(), settings.MAP_UNDERLAY, activity.getMapLayers()); + refreshMapComplete(activity); Toast.makeText(activity, activity.getString(R.string.quick_action_map_underlay_switch, getTranslatedItemName(activity, params)), Toast.LENGTH_SHORT).show(); } diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java index d1696c82a1..bbb32923b9 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java @@ -29,17 +29,16 @@ import net.osmand.plus.ContextMenuItem; import net.osmand.plus.DialogListItemAdapter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.R; import net.osmand.plus.Version; import net.osmand.plus.activities.DownloadTilesDialog; -import net.osmand.plus.mapsource.EditMapSourceDialogFragment; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivityLayers; import net.osmand.plus.dashboard.DashboardOnMap.DashboardType; -import net.osmand.plus.dialogs.RasterMapMenu; +import net.osmand.plus.mapsource.EditMapSourceDialogFragment; import net.osmand.plus.quickaction.QuickActionType; +import net.osmand.plus.settings.backend.CommonPreference; +import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.views.MapTileLayer; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.util.Algorithms; @@ -54,6 +53,7 @@ import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_U import static net.osmand.aidlapi.OsmAndCustomizationConstants.OVERLAY_MAP; import static net.osmand.aidlapi.OsmAndCustomizationConstants.UNDERLAY_MAP; import static net.osmand.plus.ContextMenuAdapter.makeDeleteAction; +import static net.osmand.plus.dialogs.ConfigureMapMenu.refreshMapComplete; public class OsmandRasterMapsPlugin extends OsmandPlugin { @@ -66,6 +66,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { private MapTileLayer overlayLayer; private MapTileLayer underlayLayer; + private StateChangedListener underlayListener; private StateChangedListener overlayLayerListener; public OsmandRasterMapsPlugin(OsmandApplication app) { @@ -103,6 +104,20 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { return "feature_articles/online-maps-plugin.html"; } + @Override + public boolean init(@NonNull final OsmandApplication app, Activity activity) { + final CommonPreference hidePolygonsPref = settings.getCustomRenderBooleanProperty("noPolygons"); + underlayListener = new StateChangedListener() { + @Override + public void stateChanged(String change) { + hidePolygonsPref.set(settings.MAP_UNDERLAY.get() != null); + } + }; + // mapView.addLayer(overlayLayer, 0.7f); + settings.MAP_UNDERLAY.addListener(underlayListener); + return true; + } + @Override public void registerLayers(MapActivity activity) { createLayers(); @@ -147,10 +162,10 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { mapView.removeLayer(underlayLayer); underlayLayer.setMap(null); } - if(settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.get() == LayerTransparencySeekbarMode.UNDERLAY && + if (settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.get() == LayerTransparencySeekbarMode.UNDERLAY && underlayLayer.getMap() != null || underlayLayer.getMapTileAdapter() != null) { layers.getMapControlsLayer().showTransparencyBar(settings.MAP_TRANSPARENCY, true); - } else if(settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.get() == LayerTransparencySeekbarMode.OVERLAY && + } else if (settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.get() == LayerTransparencySeekbarMode.OVERLAY && overlayLayer.getMap() != null || overlayLayer.getMapTileAdapter() != null) { layers.getMapControlsLayer().showTransparencyBar(settings.MAP_OVERLAY_TRANSPARENCY, true); } else { @@ -339,7 +354,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { adapter.notifyDataSetChanged(); - RasterMapMenu.refreshMapComplete(mapActivity); + refreshMapComplete(mapActivity); } } } diff --git a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java index 0b07a41c4f..bc2fc2ee45 100644 --- a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java +++ b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java @@ -1,26 +1,11 @@ package net.osmand.plus.render; -import gnu.trove.iterator.TIntObjectIterator; -import gnu.trove.list.TLongList; -import gnu.trove.list.array.TIntArrayList; -import gnu.trove.list.array.TLongArrayList; -import gnu.trove.map.hash.TIntObjectHashMap; -import gnu.trove.set.TLongSet; -import gnu.trove.set.hash.TLongHashSet; - -import java.io.File; -import java.io.IOException; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.TreeSet; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.Bitmap.Config; +import android.os.Handler; +import android.os.Looper; +import android.widget.Toast; import net.osmand.IProgress; import net.osmand.NativeLibrary.NativeSearchResult; @@ -39,14 +24,14 @@ import net.osmand.data.QuadPointDouble; import net.osmand.data.QuadRect; import net.osmand.data.RotatedTileBox; import net.osmand.map.MapTileDownloader; -import net.osmand.plus.settings.backend.OsmAndAppCustomization.OsmAndAppCustomizationListener; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.R; import net.osmand.plus.development.OsmandDevelopmentPlugin; import net.osmand.plus.render.OsmandRenderer.RenderingContext; +import net.osmand.plus.settings.backend.CommonPreference; +import net.osmand.plus.settings.backend.OsmAndAppCustomization.OsmAndAppCustomizationListener; +import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.views.OsmandMapLayer.DrawSettings; import net.osmand.render.RenderingRuleProperty; import net.osmand.render.RenderingRuleSearchRequest; @@ -55,16 +40,31 @@ import net.osmand.render.RenderingRulesStorage; import net.osmand.util.Algorithms; import net.osmand.util.MapAlgorithms; import net.osmand.util.MapUtils; - import net.osmand.util.TransliterationHelper; + import org.apache.commons.logging.Log; -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Bitmap.Config; -import android.os.Handler; -import android.os.Looper; -import android.widget.Toast; +import java.io.File; +import java.io.IOException; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; + +import gnu.trove.iterator.TIntObjectIterator; +import gnu.trove.list.TLongList; +import gnu.trove.list.array.TIntArrayList; +import gnu.trove.list.array.TLongArrayList; +import gnu.trove.map.hash.TIntObjectHashMap; +import gnu.trove.set.TLongSet; +import gnu.trove.set.hash.TLongHashSet; public class MapRenderRepositories { // It is needed to not draw object twice if user have map index that intersects by boundaries @@ -753,11 +753,11 @@ public class MapRenderRepositories { now = System.currentTimeMillis(); Bitmap bmp; - boolean transparent = false; - RenderingRuleProperty rr = storage.PROPS.get("noPolygons"); - if (rr != null) { - transparent = renderingReq.getIntPropertyValue(rr) > 0; - } +// boolean transparent = false; +// RenderingRuleProperty rr = storage.PROPS.get("noPolygons"); +// if (rr != null) { +// transparent = renderingReq.getIntPropertyValue(rr) > 0; +// } // 1. generate image step by step Bitmap reuse = prevBmp; diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesAction.java b/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesAction.java index bcbd80ff92..71aafd58b8 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesAction.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesAction.java @@ -15,6 +15,7 @@ import net.osmand.plus.quickaction.QuickAction; import net.osmand.plus.quickaction.QuickActionType; import net.osmand.render.RenderingRuleProperty; +import static net.osmand.plus.dialogs.ConfigureMapMenu.refreshMapComplete; import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_ATTR; import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_DISABLED_VALUE; @@ -52,8 +53,7 @@ public class ContourLinesAction extends QuickAction { if (selected && !plugin.isActive() && !plugin.needsInstallation()) { OsmandPlugin.enablePlugin(activity, app, plugin, true); } - - SRTMPlugin.refreshMapComplete(activity); + refreshMapComplete(activity); } } }); diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java b/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java index 03c6fde1f2..3595d284e1 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java @@ -24,6 +24,7 @@ import net.osmand.render.RenderingRuleProperty; import java.io.IOException; import java.util.List; +import static net.osmand.plus.dialogs.ConfigureMapMenu.refreshMapComplete; import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_DENSITY_ATTR; import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_ATTR; import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_DISABLED_VALUE; @@ -109,7 +110,7 @@ public class ContourLinesMenu { @Override public void run() { mapActivity.getDashboard().refreshContent(true); - SRTMPlugin.refreshMapComplete(mapActivity); + refreshMapComplete(mapActivity); } }); } @@ -123,7 +124,7 @@ public class ContourLinesMenu { item.setDescription(plugin.getPrefDescription(app, contourLinesProp, pref)); adapter.notifyDataSetChanged(); } - SRTMPlugin.refreshMapComplete(mapActivity); + refreshMapComplete(mapActivity); } }); } else if (itemId == colorSchemeStringId) { @@ -135,7 +136,7 @@ public class ContourLinesMenu { item.setDescription(plugin.getPrefDescription(app, colorSchemeProp, colorPref)); adapter.notifyDataSetChanged(); } - SRTMPlugin.refreshMapComplete(mapActivity); + refreshMapComplete(mapActivity); } }); } else if (itemId == R.string.srtm_plugin_name) { @@ -150,7 +151,7 @@ public class ContourLinesMenu { item.setDescription(plugin.getPrefDescription(app, contourWidthProp, widthPref)); adapter.notifyDataSetChanged(); } - SRTMPlugin.refreshMapComplete(mapActivity); + refreshMapComplete(mapActivity); } }); } else if (contourDensityProp != null && itemId == contourDensityName.hashCode()) { @@ -162,7 +163,7 @@ public class ContourLinesMenu { item.setDescription(plugin.getPrefDescription(app, contourDensityProp, densityPref)); adapter.notifyDataSetChanged(); } - SRTMPlugin.refreshMapComplete(mapActivity); + refreshMapComplete(mapActivity); } }); } diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java index dcf9101695..e67bcd2556 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java @@ -44,6 +44,7 @@ import java.util.List; import static net.osmand.aidlapi.OsmAndCustomizationConstants.CONTOUR_LINES; import static net.osmand.aidlapi.OsmAndCustomizationConstants.TERRAIN; import static net.osmand.plus.ContextMenuAdapter.makeDeleteAction; +import static net.osmand.plus.dialogs.ConfigureMapMenu.refreshMapComplete; public class SRTMPlugin extends OsmandPlugin { @@ -507,12 +508,6 @@ public class SRTMPlugin extends OsmandPlugin { public void disable(OsmandApplication app) { } - public static void refreshMapComplete(final MapActivity activity) { - activity.getMyApplication().getResourceManager().getRenderer().clearCache(); - activity.updateMapSettings(); - activity.getMapView().refreshMap(true); - } - private static boolean isNightMode(Activity activity, OsmandApplication app) { if (activity == null || app == null) { return false; diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainAction.java b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainAction.java index 16a86c818c..632324780e 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainAction.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainAction.java @@ -13,6 +13,8 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.quickaction.QuickAction; import net.osmand.plus.quickaction.QuickActionType; +import static net.osmand.plus.dialogs.ConfigureMapMenu.refreshMapComplete; + public class TerrainAction extends QuickAction { public static final QuickActionType TYPE = new QuickActionType(30, @@ -40,7 +42,7 @@ public class TerrainAction extends QuickAction { OsmandPlugin.enablePlugin(activity, activity.getMyApplication(), plugin, true); } plugin.updateLayers(activity.getMapView(), activity); - SRTMPlugin.refreshMapComplete(activity); + refreshMapComplete(activity); } }); } From 84e1a544ce6f50e8d8856eafe258d874a704a153 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 9 Feb 2021 15:06:21 +0200 Subject: [PATCH 2/2] Move refreshMapComplete to MapActivity --- .../osmand/plus/activities/MapActivity.java | 8 +++++++- .../osmand/plus/dashboard/DashboardOnMap.java | 3 +-- .../osmand/plus/dialogs/ConfigureMapMenu.java | 19 +++++++------------ .../plus/dialogs/DetailsBottomSheet.java | 6 +++--- .../osmand/plus/dialogs/RasterMapMenu.java | 5 ++--- ...lectMapStyleBottomSheetDialogFragment.java | 2 +- .../net/osmand/plus/helpers/GpxUiHelper.java | 2 +- .../quickaction/actions/MapStyleAction.java | 3 +-- .../plus/rastermaps/MapUnderlayAction.java | 3 +-- .../rastermaps/OsmandRasterMapsPlugin.java | 4 +--- .../plus/render/MapRenderRepositories.java | 5 ----- .../plus/srtmplugin/ContourLinesAction.java | 3 +-- .../plus/srtmplugin/ContourLinesMenu.java | 11 +++++------ .../osmand/plus/srtmplugin/SRTMPlugin.java | 8 +++----- .../osmand/plus/srtmplugin/TerrainAction.java | 4 +--- .../plus/transport/TransportLinesMenu.java | 3 +-- 16 files changed, 36 insertions(+), 53 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index f15a93aba1..7adfd1a811 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -136,10 +136,10 @@ import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.OsmAndAppCustomization.OsmAndAppCustomizationListener; import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.plus.settings.datastorage.DataStorageFragment; import net.osmand.plus.settings.fragments.BaseSettingsFragment; import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType; import net.osmand.plus.settings.fragments.ConfigureProfileFragment; -import net.osmand.plus.settings.datastorage.DataStorageFragment; import net.osmand.plus.track.TrackAppearanceFragment; import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint; @@ -1664,6 +1664,12 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven getMapView().refreshMap(); } + public void refreshMapComplete() { + getMyApplication().getResourceManager().getRenderer().clearCache(); + updateMapSettings(); + getMapView().refreshMap(true); + } + public View getLayout() { return getWindow().getDecorView().findViewById(android.R.id.content); } diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index f1685b87c9..4afb671275 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -96,7 +96,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import static net.osmand.plus.dialogs.ConfigureMapMenu.refreshMapComplete; public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInformationListener { private static final org.apache.commons.logging.Log LOG = @@ -779,7 +778,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInfo plugin.registerLayers(mapActivity); } } - refreshMapComplete(mapActivity); + mapActivity.refreshMapComplete(); } else if (visibleType == DashboardType.WIKIPEDIA) { refreshContent(true); } diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java index 7a0bcb0e79..5b8f38d2b9 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java @@ -261,11 +261,6 @@ public class ConfigureMapMenu { app.getAidlApi().registerLayerContextMenu(adapter, activity); } - public static void refreshMapComplete(final MapActivity activity) { - activity.getMyApplication().getResourceManager().getRenderer().clearCache(); - activity.updateMapSettings(); - activity.getMapView().refreshMap(true); - } private void createRenderingAttributeItems(List customRules, final ContextMenuAdapter adapter, final MapActivity activity, @@ -347,7 +342,7 @@ public class ConfigureMapMenu { public void onClick(View v) { int which = (int) v.getTag(); view.getSettings().DAYNIGHT_MODE.set(DayNightMode.values()[which]); - refreshMapComplete(activity); + activity.refreshMapComplete(); activity.getDashboard().refreshContent(true); // adapter.getItem(pos).setDescription(s, getDayNightDescr(activity)); // ad.notifyDataSetInvalidated(); @@ -466,7 +461,7 @@ public class ConfigureMapMenu { public void onClick(View v) { int which = (int) v.getTag(); view.getSettings().TEXT_SCALE.set(txtValues[which]); - refreshMapComplete(activity); + activity.refreshMapComplete(); adapter.getItem(pos).setDescription(getScale(activity)); ad.notifyDataSetInvalidated(); } @@ -568,7 +563,7 @@ public class ConfigureMapMenu { int index = dlg.getListView().getCheckedItemPosition(); view.getSettings().MAP_PREFERRED_LOCALE.set( txtIds[index]); - refreshMapComplete(activity); + activity.refreshMapComplete(); String localeDescr = txtIds[index]; localeDescr = localeDescr == null || localeDescr.isEmpty() ? activity .getString(R.string.local_map_names) : localeDescr; @@ -712,7 +707,7 @@ public class ConfigureMapMenu { } adapter.getItem(pos).setColorRes(ContextMenuItem.INVALID_ID); a.notifyDataSetInvalidated(); - refreshMapComplete(activity); + activity.refreshMapComplete(); activity.getMapLayers().updateLayers(activity.getMapView()); } else { if (UI_CATEGORY_DETAILS.equals(category)) { @@ -883,7 +878,7 @@ public class ConfigureMapMenu { adapter.getItem(pos).setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); } a.notifyDataSetInvalidated(); - refreshMapComplete(activity); + activity.refreshMapComplete(); activity.getMapLayers().updateLayers(activity.getMapView()); } }); @@ -1041,7 +1036,7 @@ public class ConfigureMapMenu { @Override public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { pref.set(!pref.get()); - refreshMapComplete(activity); + activity.refreshMapComplete(); return false; } }) @@ -1096,7 +1091,7 @@ public class ConfigureMapMenu { } else { pref.set(p.getPossibleValues()[which - 1]); } - refreshMapComplete(activity); + activity.refreshMapComplete(); String description = AndroidUtils.getRenderingStringPropertyValue(activity, pref.get()); adapter.getItem(pos).setDescription(description); } diff --git a/OsmAnd/src/net/osmand/plus/dialogs/DetailsBottomSheet.java b/OsmAnd/src/net/osmand/plus/dialogs/DetailsBottomSheet.java index ff5b5d9a3d..673f1ce3e7 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/DetailsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/DetailsBottomSheet.java @@ -228,9 +228,9 @@ public class DetailsBottomSheet extends BasePreferenceBottomSheet { } Activity activity = getActivity(); if (activity instanceof MapActivity) { - MapActivity a = (MapActivity) activity; - ConfigureMapMenu.refreshMapComplete(a); - a.getMapLayers().updateLayers(a.getMapView()); + MapActivity mapActivity = (MapActivity) activity; + mapActivity.refreshMapComplete(); + mapActivity.getMapLayers().updateLayers(mapActivity.getMapView()); } super.onDismiss(dialog); } diff --git a/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java index 1cbdc27a8e..1e91810253 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java @@ -20,7 +20,6 @@ import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin; import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin.OnMapSelectedCallback; import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin.RasterMapType; -import static net.osmand.plus.dialogs.ConfigureMapMenu.refreshMapComplete; public class RasterMapMenu { private static final String TAG = "RasterMapMenu"; @@ -107,12 +106,12 @@ public class RasterMapMenu { @Override public void run() { plugin.toggleUnderlayState(mapActivity, type, onMapSelectedCallback); - refreshMapComplete(mapActivity); + mapActivity.refreshMapComplete(); } }); } else if (itemId == R.string.show_polygons) { hidePolygonsPref.set(!isChecked); - refreshMapComplete(mapActivity); + mapActivity.refreshMapComplete(); } else if (itemId == R.string.show_transparency_seekbar) { if (isChecked) { settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.set(currentMapTypeSeekbarMode); diff --git a/OsmAnd/src/net/osmand/plus/dialogs/SelectMapStyleBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/dialogs/SelectMapStyleBottomSheetDialogFragment.java index 93d05d86d7..f5515f11bd 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/SelectMapStyleBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/SelectMapStyleBottomSheetDialogFragment.java @@ -140,7 +140,7 @@ public class SelectMapStyleBottomSheetDialogFragment extends MenuBottomSheetDial OsmandMapTileView view = mapActivity.getMapView(); view.getSettings().RENDERER.set(selectedStyle); app.getRendererRegistry().setCurrentSelectedRender(loaded); - ConfigureMapMenu.refreshMapComplete(mapActivity); + mapActivity.refreshMapComplete(); mapActivity.getDashboard().refreshContent(true); } else { Toast.makeText(mapActivity, R.string.renderer_load_exception, Toast.LENGTH_SHORT).show(); diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java index 3d6c3c15c9..c2f3d831b8 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java @@ -593,7 +593,7 @@ public class GpxUiHelper { } } if (activity instanceof MapActivity) { - ConfigureMapMenu.refreshMapComplete((MapActivity) activity); + ((MapActivity) activity).refreshMapComplete(); } } GPXFile currentGPX = null; diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java index aff229fdc4..a526954365 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java @@ -15,7 +15,6 @@ import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.dialogs.ConfigureMapMenu; import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin; import net.osmand.plus.quickaction.QuickAction; import net.osmand.plus.quickaction.QuickActionType; @@ -92,7 +91,7 @@ public class MapStyleAction extends SwitchableAction { view.getSettings().RENDERER.set(params); app.getRendererRegistry().setCurrentSelectedRender(loaded); - ConfigureMapMenu.refreshMapComplete(activity); + activity.refreshMapComplete(); Toast.makeText(activity, activity.getString(R.string.quick_action_map_style_switch, getTranslatedItemName(activity, params)), Toast.LENGTH_SHORT).show(); diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java index b313009f4c..ed598a344b 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java @@ -28,7 +28,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import static net.osmand.plus.dialogs.ConfigureMapMenu.refreshMapComplete; public class MapUnderlayAction extends SwitchableAction> { @@ -144,7 +143,7 @@ public class MapUnderlayAction extends SwitchableAction> { settings.MAP_UNDERLAY_PREVIOUS.set(null); } plugin.updateMapLayers(activity.getMapView(), settings.MAP_UNDERLAY, activity.getMapLayers()); - refreshMapComplete(activity); + activity.refreshMapComplete(); Toast.makeText(activity, activity.getString(R.string.quick_action_map_underlay_switch, getTranslatedItemName(activity, params)), Toast.LENGTH_SHORT).show(); } diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java index bbb32923b9..ce4cf2664c 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java @@ -53,7 +53,6 @@ import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_U import static net.osmand.aidlapi.OsmAndCustomizationConstants.OVERLAY_MAP; import static net.osmand.aidlapi.OsmAndCustomizationConstants.UNDERLAY_MAP; import static net.osmand.plus.ContextMenuAdapter.makeDeleteAction; -import static net.osmand.plus.dialogs.ConfigureMapMenu.refreshMapComplete; public class OsmandRasterMapsPlugin extends OsmandPlugin { @@ -113,7 +112,6 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { hidePolygonsPref.set(settings.MAP_UNDERLAY.get() != null); } }; - // mapView.addLayer(overlayLayer, 0.7f); settings.MAP_UNDERLAY.addListener(underlayListener); return true; } @@ -354,7 +352,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { adapter.notifyDataSetChanged(); - refreshMapComplete(mapActivity); + mapActivity.refreshMapComplete(); } } } diff --git a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java index bc2fc2ee45..a531e2360d 100644 --- a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java +++ b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java @@ -753,11 +753,6 @@ public class MapRenderRepositories { now = System.currentTimeMillis(); Bitmap bmp; -// boolean transparent = false; -// RenderingRuleProperty rr = storage.PROPS.get("noPolygons"); -// if (rr != null) { -// transparent = renderingReq.getIntPropertyValue(rr) > 0; -// } // 1. generate image step by step Bitmap reuse = prevBmp; diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesAction.java b/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesAction.java index 71aafd58b8..15d33c8fa3 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesAction.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesAction.java @@ -15,7 +15,6 @@ import net.osmand.plus.quickaction.QuickAction; import net.osmand.plus.quickaction.QuickActionType; import net.osmand.render.RenderingRuleProperty; -import static net.osmand.plus.dialogs.ConfigureMapMenu.refreshMapComplete; import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_ATTR; import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_DISABLED_VALUE; @@ -53,7 +52,7 @@ public class ContourLinesAction extends QuickAction { if (selected && !plugin.isActive() && !plugin.needsInstallation()) { OsmandPlugin.enablePlugin(activity, app, plugin, true); } - refreshMapComplete(activity); + activity.refreshMapComplete(); } } }); diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java b/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java index 3595d284e1..86abdee880 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java @@ -24,7 +24,6 @@ import net.osmand.render.RenderingRuleProperty; import java.io.IOException; import java.util.List; -import static net.osmand.plus.dialogs.ConfigureMapMenu.refreshMapComplete; import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_DENSITY_ATTR; import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_ATTR; import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_DISABLED_VALUE; @@ -110,7 +109,7 @@ public class ContourLinesMenu { @Override public void run() { mapActivity.getDashboard().refreshContent(true); - refreshMapComplete(mapActivity); + mapActivity.refreshMapComplete(); } }); } @@ -124,7 +123,7 @@ public class ContourLinesMenu { item.setDescription(plugin.getPrefDescription(app, contourLinesProp, pref)); adapter.notifyDataSetChanged(); } - refreshMapComplete(mapActivity); + mapActivity.refreshMapComplete(); } }); } else if (itemId == colorSchemeStringId) { @@ -136,7 +135,7 @@ public class ContourLinesMenu { item.setDescription(plugin.getPrefDescription(app, colorSchemeProp, colorPref)); adapter.notifyDataSetChanged(); } - refreshMapComplete(mapActivity); + mapActivity.refreshMapComplete(); } }); } else if (itemId == R.string.srtm_plugin_name) { @@ -151,7 +150,7 @@ public class ContourLinesMenu { item.setDescription(plugin.getPrefDescription(app, contourWidthProp, widthPref)); adapter.notifyDataSetChanged(); } - refreshMapComplete(mapActivity); + mapActivity.refreshMapComplete(); } }); } else if (contourDensityProp != null && itemId == contourDensityName.hashCode()) { @@ -163,7 +162,7 @@ public class ContourLinesMenu { item.setDescription(plugin.getPrefDescription(app, contourDensityProp, densityPref)); adapter.notifyDataSetChanged(); } - refreshMapComplete(mapActivity); + mapActivity.refreshMapComplete(); } }); } diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java index e67bcd2556..e58bf4ef89 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java @@ -44,7 +44,6 @@ import java.util.List; import static net.osmand.aidlapi.OsmAndCustomizationConstants.CONTOUR_LINES; import static net.osmand.aidlapi.OsmAndCustomizationConstants.TERRAIN; import static net.osmand.plus.ContextMenuAdapter.makeDeleteAction; -import static net.osmand.plus.dialogs.ConfigureMapMenu.refreshMapComplete; public class SRTMPlugin extends OsmandPlugin { @@ -308,9 +307,8 @@ public class SRTMPlugin extends OsmandPlugin { item.setSelected(selected); adapter.notifyDataSetChanged(); } - refreshMapComplete(mapActivity); + mapActivity.refreshMapComplete(); } - } }); } else if (itemId == R.string.shared_string_terrain) { @@ -329,7 +327,7 @@ public class SRTMPlugin extends OsmandPlugin { adapter.notifyDataSetChanged(); } updateLayers(mapView, mapActivity); - refreshMapComplete(mapActivity); + mapActivity.refreshMapComplete(); } }); } @@ -487,7 +485,7 @@ public class SRTMPlugin extends OsmandPlugin { } else { pref.set(possibleValues[which - 1]); } - refreshMapComplete(activity); + activity.refreshMapComplete(); } } ); diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainAction.java b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainAction.java index 632324780e..fdeb099cfa 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainAction.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainAction.java @@ -13,8 +13,6 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.quickaction.QuickAction; import net.osmand.plus.quickaction.QuickActionType; -import static net.osmand.plus.dialogs.ConfigureMapMenu.refreshMapComplete; - public class TerrainAction extends QuickAction { public static final QuickActionType TYPE = new QuickActionType(30, @@ -42,7 +40,7 @@ public class TerrainAction extends QuickAction { OsmandPlugin.enablePlugin(activity, activity.getMyApplication(), plugin, true); } plugin.updateLayers(activity.getMapView(), activity); - refreshMapComplete(activity); + activity.refreshMapComplete(); } }); } diff --git a/OsmAnd/src/net/osmand/plus/transport/TransportLinesMenu.java b/OsmAnd/src/net/osmand/plus/transport/TransportLinesMenu.java index d02620120b..4e91d5700e 100644 --- a/OsmAnd/src/net/osmand/plus/transport/TransportLinesMenu.java +++ b/OsmAnd/src/net/osmand/plus/transport/TransportLinesMenu.java @@ -219,9 +219,8 @@ public class TransportLinesMenu { return transportPrefs; } - private static void refreshMap(MapActivity mapActivity) { - ConfigureMapMenu.refreshMapComplete(mapActivity); + mapActivity.refreshMapComplete(); mapActivity.getMapLayers().updateLayers(mapActivity.getMapView()); }