This commit is contained in:
Vitaliy 2021-02-09 03:41:27 +02:00
parent d6fe7dff8d
commit 9653acecc1
9 changed files with 79 additions and 72 deletions

View file

@ -96,6 +96,8 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static net.osmand.plus.dialogs.ConfigureMapMenu.refreshMapComplete;
public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInformationListener { public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInformationListener {
private static final org.apache.commons.logging.Log LOG = private static final org.apache.commons.logging.Log LOG =
PlatformUtil.getLog(DashboardOnMap.class); PlatformUtil.getLog(DashboardOnMap.class);
@ -777,7 +779,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInfo
plugin.registerLayers(mapActivity); plugin.registerLayers(mapActivity);
} }
} }
SRTMPlugin.refreshMapComplete(mapActivity); refreshMapComplete(mapActivity);
} else if (visibleType == DashboardType.WIKIPEDIA) { } else if (visibleType == DashboardType.WIKIPEDIA) {
refreshContent(true); refreshContent(true);
} }

View file

@ -20,6 +20,8 @@ import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin.OnMapSelectedCallback; import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin.OnMapSelectedCallback;
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin.RasterMapType; import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin.RasterMapType;
import static net.osmand.plus.dialogs.ConfigureMapMenu.refreshMapComplete;
public class RasterMapMenu { public class RasterMapMenu {
private static final String TAG = "RasterMapMenu"; private static final String TAG = "RasterMapMenu";
public static ContextMenuAdapter createListAdapter(final MapActivity mapActivity, public static ContextMenuAdapter createListAdapter(final MapActivity mapActivity,
@ -180,10 +182,4 @@ public class RasterMapMenu {
LayerTransparencySeekbarMode seekbarMode = app.getSettings().LAYER_TRANSPARENCY_SEEKBAR_MODE.get(); LayerTransparencySeekbarMode seekbarMode = app.getSettings().LAYER_TRANSPARENCY_SEEKBAR_MODE.get();
return seekbarMode == LayerTransparencySeekbarMode.UNDEFINED || seekbarMode == currentMapTypeSeekbarMode; return seekbarMode == LayerTransparencySeekbarMode.UNDEFINED || seekbarMode == currentMapTypeSeekbarMode;
} }
public static void refreshMapComplete(final MapActivity activity) {
activity.getMyApplication().getResourceManager().getRenderer().clearCache();
activity.updateMapSettings();
activity.getMapView().refreshMap(true);
}
} }

View file

@ -15,20 +15,21 @@ import com.google.gson.reflect.TypeToken;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; 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.R;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.quickaction.QuickAction; import net.osmand.plus.quickaction.QuickAction;
import net.osmand.plus.quickaction.QuickActionType; import net.osmand.plus.quickaction.QuickActionType;
import net.osmand.plus.quickaction.SwitchableAction; import net.osmand.plus.quickaction.SwitchableAction;
import net.osmand.plus.settings.backend.OsmandSettings;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static net.osmand.plus.dialogs.ConfigureMapMenu.refreshMapComplete;
public class MapUnderlayAction extends SwitchableAction<Pair<String, String>> { public class MapUnderlayAction extends SwitchableAction<Pair<String, String>> {
private final static String KEY_UNDERLAYS = "underlays"; private final static String KEY_UNDERLAYS = "underlays";
@ -141,14 +142,9 @@ public class MapUnderlayAction extends SwitchableAction<Pair<String, String>> {
settings.MAP_UNDERLAY.set(null); settings.MAP_UNDERLAY.set(null);
activity.getMapLayers().getMapControlsLayer().hideTransparencyBar(); activity.getMapLayers().getMapControlsLayer().hideTransparencyBar();
settings.MAP_UNDERLAY_PREVIOUS.set(null); settings.MAP_UNDERLAY_PREVIOUS.set(null);
} }
final CommonPreference<Boolean> hidePolygonsPref =
activity.getMyApplication().getSettings().getCustomRenderBooleanProperty("noPolygons");
hidePolygonsPref.set(hasUnderlay);
plugin.updateMapLayers(activity.getMapView(), settings.MAP_UNDERLAY, activity.getMapLayers()); plugin.updateMapLayers(activity.getMapView(), settings.MAP_UNDERLAY, activity.getMapLayers());
refreshMapComplete(activity);
Toast.makeText(activity, activity.getString(R.string.quick_action_map_underlay_switch, Toast.makeText(activity, activity.getString(R.string.quick_action_map_underlay_switch,
getTranslatedItemName(activity, params)), Toast.LENGTH_SHORT).show(); getTranslatedItemName(activity, params)), Toast.LENGTH_SHORT).show();
} }

View file

@ -29,17 +29,16 @@ import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.DialogListItemAdapter; import net.osmand.plus.DialogListItemAdapter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; 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.R;
import net.osmand.plus.Version; import net.osmand.plus.Version;
import net.osmand.plus.activities.DownloadTilesDialog; import net.osmand.plus.activities.DownloadTilesDialog;
import net.osmand.plus.mapsource.EditMapSourceDialogFragment;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivityLayers; import net.osmand.plus.activities.MapActivityLayers;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType; 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.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.MapTileLayer;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.util.Algorithms; 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.OVERLAY_MAP;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.UNDERLAY_MAP; import static net.osmand.aidlapi.OsmAndCustomizationConstants.UNDERLAY_MAP;
import static net.osmand.plus.ContextMenuAdapter.makeDeleteAction; import static net.osmand.plus.ContextMenuAdapter.makeDeleteAction;
import static net.osmand.plus.dialogs.ConfigureMapMenu.refreshMapComplete;
public class OsmandRasterMapsPlugin extends OsmandPlugin { public class OsmandRasterMapsPlugin extends OsmandPlugin {
@ -66,6 +66,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
private MapTileLayer overlayLayer; private MapTileLayer overlayLayer;
private MapTileLayer underlayLayer; private MapTileLayer underlayLayer;
private StateChangedListener<String> underlayListener;
private StateChangedListener<Integer> overlayLayerListener; private StateChangedListener<Integer> overlayLayerListener;
public OsmandRasterMapsPlugin(OsmandApplication app) { public OsmandRasterMapsPlugin(OsmandApplication app) {
@ -103,6 +104,20 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
return "feature_articles/online-maps-plugin.html"; return "feature_articles/online-maps-plugin.html";
} }
@Override
public boolean init(@NonNull final OsmandApplication app, Activity activity) {
final CommonPreference<Boolean> hidePolygonsPref = settings.getCustomRenderBooleanProperty("noPolygons");
underlayListener = new StateChangedListener<String>() {
@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 @Override
public void registerLayers(MapActivity activity) { public void registerLayers(MapActivity activity) {
createLayers(); createLayers();
@ -147,10 +162,10 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
mapView.removeLayer(underlayLayer); mapView.removeLayer(underlayLayer);
underlayLayer.setMap(null); 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) { underlayLayer.getMap() != null || underlayLayer.getMapTileAdapter() != null) {
layers.getMapControlsLayer().showTransparencyBar(settings.MAP_TRANSPARENCY, true); 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) { overlayLayer.getMap() != null || overlayLayer.getMapTileAdapter() != null) {
layers.getMapControlsLayer().showTransparencyBar(settings.MAP_OVERLAY_TRANSPARENCY, true); layers.getMapControlsLayer().showTransparencyBar(settings.MAP_OVERLAY_TRANSPARENCY, true);
} else { } else {
@ -339,7 +354,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
RasterMapMenu.refreshMapComplete(mapActivity); refreshMapComplete(mapActivity);
} }
} }
} }

View file

@ -1,26 +1,11 @@
package net.osmand.plus.render; package net.osmand.plus.render;
import gnu.trove.iterator.TIntObjectIterator; import android.content.Context;
import gnu.trove.list.TLongList; import android.graphics.Bitmap;
import gnu.trove.list.array.TIntArrayList; import android.graphics.Bitmap.Config;
import gnu.trove.list.array.TLongArrayList; import android.os.Handler;
import gnu.trove.map.hash.TIntObjectHashMap; import android.os.Looper;
import gnu.trove.set.TLongSet; import android.widget.Toast;
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 net.osmand.IProgress; import net.osmand.IProgress;
import net.osmand.NativeLibrary.NativeSearchResult; import net.osmand.NativeLibrary.NativeSearchResult;
@ -39,14 +24,14 @@ import net.osmand.data.QuadPointDouble;
import net.osmand.data.QuadRect; import net.osmand.data.QuadRect;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
import net.osmand.map.MapTileDownloader; import net.osmand.map.MapTileDownloader;
import net.osmand.plus.settings.backend.OsmAndAppCustomization.OsmAndAppCustomizationListener;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; 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.R;
import net.osmand.plus.development.OsmandDevelopmentPlugin; import net.osmand.plus.development.OsmandDevelopmentPlugin;
import net.osmand.plus.render.OsmandRenderer.RenderingContext; 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.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.render.RenderingRuleProperty; import net.osmand.render.RenderingRuleProperty;
import net.osmand.render.RenderingRuleSearchRequest; import net.osmand.render.RenderingRuleSearchRequest;
@ -55,16 +40,31 @@ import net.osmand.render.RenderingRulesStorage;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import net.osmand.util.MapAlgorithms; import net.osmand.util.MapAlgorithms;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import net.osmand.util.TransliterationHelper; import net.osmand.util.TransliterationHelper;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import android.content.Context; import java.io.File;
import android.graphics.Bitmap; import java.io.IOException;
import android.graphics.Bitmap.Config; import java.text.MessageFormat;
import android.os.Handler; import java.util.ArrayList;
import android.os.Looper; import java.util.Arrays;
import android.widget.Toast; 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 { public class MapRenderRepositories {
// It is needed to not draw object twice if user have map index that intersects by boundaries // 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(); now = System.currentTimeMillis();
Bitmap bmp; Bitmap bmp;
boolean transparent = false; // boolean transparent = false;
RenderingRuleProperty rr = storage.PROPS.get("noPolygons"); // RenderingRuleProperty rr = storage.PROPS.get("noPolygons");
if (rr != null) { // if (rr != null) {
transparent = renderingReq.getIntPropertyValue(rr) > 0; // transparent = renderingReq.getIntPropertyValue(rr) > 0;
} // }
// 1. generate image step by step // 1. generate image step by step
Bitmap reuse = prevBmp; Bitmap reuse = prevBmp;

View file

@ -15,6 +15,7 @@ import net.osmand.plus.quickaction.QuickAction;
import net.osmand.plus.quickaction.QuickActionType; import net.osmand.plus.quickaction.QuickActionType;
import net.osmand.render.RenderingRuleProperty; 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_ATTR;
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_DISABLED_VALUE; 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()) { if (selected && !plugin.isActive() && !plugin.needsInstallation()) {
OsmandPlugin.enablePlugin(activity, app, plugin, true); OsmandPlugin.enablePlugin(activity, app, plugin, true);
} }
refreshMapComplete(activity);
SRTMPlugin.refreshMapComplete(activity);
} }
} }
}); });

View file

@ -24,6 +24,7 @@ import net.osmand.render.RenderingRuleProperty;
import java.io.IOException; import java.io.IOException;
import java.util.List; 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_DENSITY_ATTR;
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_ATTR; import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_ATTR;
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_DISABLED_VALUE; import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_DISABLED_VALUE;
@ -109,7 +110,7 @@ public class ContourLinesMenu {
@Override @Override
public void run() { public void run() {
mapActivity.getDashboard().refreshContent(true); mapActivity.getDashboard().refreshContent(true);
SRTMPlugin.refreshMapComplete(mapActivity); refreshMapComplete(mapActivity);
} }
}); });
} }
@ -123,7 +124,7 @@ public class ContourLinesMenu {
item.setDescription(plugin.getPrefDescription(app, contourLinesProp, pref)); item.setDescription(plugin.getPrefDescription(app, contourLinesProp, pref));
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
SRTMPlugin.refreshMapComplete(mapActivity); refreshMapComplete(mapActivity);
} }
}); });
} else if (itemId == colorSchemeStringId) { } else if (itemId == colorSchemeStringId) {
@ -135,7 +136,7 @@ public class ContourLinesMenu {
item.setDescription(plugin.getPrefDescription(app, colorSchemeProp, colorPref)); item.setDescription(plugin.getPrefDescription(app, colorSchemeProp, colorPref));
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
SRTMPlugin.refreshMapComplete(mapActivity); refreshMapComplete(mapActivity);
} }
}); });
} else if (itemId == R.string.srtm_plugin_name) { } else if (itemId == R.string.srtm_plugin_name) {
@ -150,7 +151,7 @@ public class ContourLinesMenu {
item.setDescription(plugin.getPrefDescription(app, contourWidthProp, widthPref)); item.setDescription(plugin.getPrefDescription(app, contourWidthProp, widthPref));
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
SRTMPlugin.refreshMapComplete(mapActivity); refreshMapComplete(mapActivity);
} }
}); });
} else if (contourDensityProp != null && itemId == contourDensityName.hashCode()) { } else if (contourDensityProp != null && itemId == contourDensityName.hashCode()) {
@ -162,7 +163,7 @@ public class ContourLinesMenu {
item.setDescription(plugin.getPrefDescription(app, contourDensityProp, densityPref)); item.setDescription(plugin.getPrefDescription(app, contourDensityProp, densityPref));
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
SRTMPlugin.refreshMapComplete(mapActivity); refreshMapComplete(mapActivity);
} }
}); });
} }

View file

@ -44,6 +44,7 @@ import java.util.List;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.CONTOUR_LINES; import static net.osmand.aidlapi.OsmAndCustomizationConstants.CONTOUR_LINES;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.TERRAIN; import static net.osmand.aidlapi.OsmAndCustomizationConstants.TERRAIN;
import static net.osmand.plus.ContextMenuAdapter.makeDeleteAction; import static net.osmand.plus.ContextMenuAdapter.makeDeleteAction;
import static net.osmand.plus.dialogs.ConfigureMapMenu.refreshMapComplete;
public class SRTMPlugin extends OsmandPlugin { public class SRTMPlugin extends OsmandPlugin {
@ -507,12 +508,6 @@ public class SRTMPlugin extends OsmandPlugin {
public void disable(OsmandApplication app) { 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) { private static boolean isNightMode(Activity activity, OsmandApplication app) {
if (activity == null || app == null) { if (activity == null || app == null) {
return false; return false;

View file

@ -13,6 +13,8 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.quickaction.QuickAction; import net.osmand.plus.quickaction.QuickAction;
import net.osmand.plus.quickaction.QuickActionType; import net.osmand.plus.quickaction.QuickActionType;
import static net.osmand.plus.dialogs.ConfigureMapMenu.refreshMapComplete;
public class TerrainAction extends QuickAction { public class TerrainAction extends QuickAction {
public static final QuickActionType TYPE = new QuickActionType(30, public static final QuickActionType TYPE = new QuickActionType(30,
@ -40,7 +42,7 @@ public class TerrainAction extends QuickAction {
OsmandPlugin.enablePlugin(activity, activity.getMyApplication(), plugin, true); OsmandPlugin.enablePlugin(activity, activity.getMyApplication(), plugin, true);
} }
plugin.updateLayers(activity.getMapView(), activity); plugin.updateLayers(activity.getMapView(), activity);
SRTMPlugin.refreshMapComplete(activity); refreshMapComplete(activity);
} }
}); });
} }