diff --git a/OsmAnd/res/drawable/buy_background_light.xml b/OsmAnd/res/drawable/buy_background_light.xml
new file mode 100644
index 0000000000..c3cafcd530
--- /dev/null
+++ b/OsmAnd/res/drawable/buy_background_light.xml
@@ -0,0 +1,10 @@
+
+
+ -
+
+
+
+
+
+
+
diff --git a/OsmAnd/res/layout/list_group_title_with_descr.xml b/OsmAnd/res/layout/list_group_title_with_descr.xml
new file mode 100644
index 0000000000..6d16169a28
--- /dev/null
+++ b/OsmAnd/res/layout/list_group_title_with_descr.xml
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/list_group_title_with_switch.xml b/OsmAnd/res/layout/list_group_title_with_switch.xml
index e9f039eeee..15b58ce2f9 100644
--- a/OsmAnd/res/layout/list_group_title_with_switch.xml
+++ b/OsmAnd/res/layout/list_group_title_with_switch.xml
@@ -18,8 +18,9 @@
diff --git a/OsmAnd/res/layout/list_group_title_with_switch_light.xml b/OsmAnd/res/layout/list_group_title_with_switch_light.xml
new file mode 100644
index 0000000000..a92ad249ed
--- /dev/null
+++ b/OsmAnd/res/layout/list_group_title_with_switch_light.xml
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/list_item_icon_and_download.xml b/OsmAnd/res/layout/list_item_icon_and_download.xml
new file mode 100644
index 0000000000..8b4b7d1f5a
--- /dev/null
+++ b/OsmAnd/res/layout/list_item_icon_and_download.xml
@@ -0,0 +1,97 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/list_item_icon_and_right_btn.xml b/OsmAnd/res/layout/list_item_icon_and_right_btn.xml
new file mode 100644
index 0000000000..7fecc3d9d2
--- /dev/null
+++ b/OsmAnd/res/layout/list_item_icon_and_right_btn.xml
@@ -0,0 +1,121 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index f357c4c31b..ad8b6b4558 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,6 +9,9 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
+ For view contour lines on the map, you need to download contour line map of this region.
+ Plugin
+ To see contour lines on the map, you need to buy and install plugin
Color scheme
Display from zoom level
Allow private access
diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java
index bc8019141a..a588c41cb7 100644
--- a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java
+++ b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java
@@ -222,7 +222,12 @@ public class ContextMenuAdapter {
int secondaryDrawable = item.getSecondaryIcon();
if (secondaryDrawable != ContextMenuItem.INVALID_ID) {
@ColorRes
- int colorRes = lightTheme ? R.color.icon_color_light : R.color.dialog_inactive_text_color_dark;
+ int colorRes;
+ if (secondaryDrawable == R.drawable.ic_action_additional_option) {
+ colorRes = lightTheme ? R.color.icon_color_light : R.color.dialog_inactive_text_color_dark;
+ } else {
+ colorRes = lightTheme ? R.color.icon_color : R.color.color_white;
+ }
Drawable drawable = mIconsCache.getIcon(item.getSecondaryIcon(), colorRes);
ImageView imageView = (ImageView) convertView.findViewById(R.id.secondary_icon);
imageView.setImageDrawable(drawable);
@@ -287,19 +292,27 @@ public class ContextMenuAdapter {
}
}
- if (convertView.findViewById(R.id.ProgressBar) != null) {
- ProgressBar bar = (ProgressBar) convertView.findViewById(R.id.ProgressBar);
+ View progressBar = convertView.findViewById(R.id.ProgressBar);
+ if (progressBar != null) {
+ ProgressBar bar = (ProgressBar) progressBar;
if (item.isLoading()) {
+ int progress = item.getProgress();
+ if (progress == ContextMenuItem.INVALID_ID) {
+ bar.setIndeterminate(true);
+ } else {
+ bar.setIndeterminate(false);
+ bar.setProgress(progress);
+ }
bar.setVisibility(View.VISIBLE);
} else {
- bar.setVisibility(View.INVISIBLE);
+ bar.setVisibility(View.GONE);
}
}
View descriptionTextView = convertView.findViewById(R.id.description);
if (descriptionTextView != null) {
String itemDescr = item.getDescription();
- if (itemDescr != null) {
+ if (itemDescr != null && (progressBar == null || !item.isLoading())) {
((TextView) descriptionTextView).setText(itemDescr);
descriptionTextView.setVisibility(View.VISIBLE);
} else {
@@ -328,7 +341,18 @@ public class ContextMenuAdapter {
public interface ItemClickListener {
//boolean return type needed to desribe if drawer needed to be close or not
- boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int position, boolean isChecked);
+ boolean onContextMenuClick(ArrayAdapter adapter,
+ int itemId,
+ int position,
+ boolean isChecked);
+ }
+
+ public interface ProgressListener {
+ boolean onProgressChanged(Object progressObject,
+ int progress,
+ ArrayAdapter adapter,
+ int itemId,
+ int position);
}
public interface OnIntegerValueChangedListener {
diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuItem.java b/OsmAnd/src/net/osmand/plus/ContextMenuItem.java
index d821ca946f..9fdaf96b94 100644
--- a/OsmAnd/src/net/osmand/plus/ContextMenuItem.java
+++ b/OsmAnd/src/net/osmand/plus/ContextMenuItem.java
@@ -20,7 +20,7 @@ public class ContextMenuItem {
@ColorRes
private int colorRes;
@DrawableRes
- private final int secondaryIcon;
+ private int secondaryIcon;
private Boolean selected;
private int progress;
@LayoutRes
@@ -32,6 +32,7 @@ public class ContextMenuItem {
private String description;
private final ContextMenuAdapter.ItemClickListener itemClickListener;
private final ContextMenuAdapter.OnIntegerValueChangedListener integerListener;
+ private final ContextMenuAdapter.ProgressListener progressListener;
private final boolean hideDivider;
private final int minHeight;
private final int tag;
@@ -50,6 +51,7 @@ public class ContextMenuItem {
String description,
ContextMenuAdapter.ItemClickListener itemClickListener,
ContextMenuAdapter.OnIntegerValueChangedListener integerListener,
+ ContextMenuAdapter.ProgressListener progressListener,
boolean hideDivider,
int minHeight,
int tag) {
@@ -68,6 +70,7 @@ public class ContextMenuItem {
this.description = description;
this.itemClickListener = itemClickListener;
this.integerListener = integerListener;
+ this.progressListener = progressListener;
this.hideDivider = hideDivider;
this.minHeight = minHeight;
this.tag = tag;
@@ -148,6 +151,10 @@ public class ContextMenuItem {
return integerListener;
}
+ public ContextMenuAdapter.ProgressListener getProgressListener() {
+ return progressListener;
+ }
+
public boolean shouldSkipPainting() {
return skipPaintingWithoutColor;
}
@@ -164,6 +171,10 @@ public class ContextMenuItem {
this.mIcon = iconId;
}
+ public void setSecondaryIcon(int secondaryIcon) {
+ this.secondaryIcon = secondaryIcon;
+ }
+
public void setColorRes(int colorRes) {
this.colorRes = colorRes;
}
@@ -216,6 +227,7 @@ public class ContextMenuItem {
private String mDescription = null;
private ContextMenuAdapter.ItemClickListener mItemClickListener = null;
private ContextMenuAdapter.OnIntegerValueChangedListener mIntegerListener = null;
+ private ContextMenuAdapter.ProgressListener mProgressListener = null;
private boolean mSkipPaintingWithoutColor;
private boolean mHideDivider;
private int mMinHeight;
@@ -295,6 +307,11 @@ public class ContextMenuItem {
return this;
}
+ public ItemBuilder setProgressListener(ContextMenuAdapter.ProgressListener progressListener) {
+ mProgressListener = progressListener;
+ return this;
+ }
+
public ItemBuilder setSkipPaintingWithoutColor(boolean skipPaintingWithoutColor) {
mSkipPaintingWithoutColor = skipPaintingWithoutColor;
return this;
@@ -322,8 +339,8 @@ public class ContextMenuItem {
public ContextMenuItem createItem() {
return new ContextMenuItem(mTitleId, mTitle, mIcon, mColorRes, mSecondaryIcon,
mSelected, mProgress, mLayout, mLoading, mIsCategory, mSkipPaintingWithoutColor,
- mPosition, mDescription, mItemClickListener, mIntegerListener, mHideDivider,
- mMinHeight, mTag);
+ mPosition, mDescription, mItemClickListener, mIntegerListener, mProgressListener,
+ mHideDivider, mMinHeight, mTag);
}
}
}
diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
index 4f95bc2c42..411f6b2e6c 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
@@ -1310,6 +1310,9 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
if (fragmentRef != null) {
fragmentRef.get().newDownloadIndexes();
}
+ if (dashboardOnMap.isVisible()) {
+ dashboardOnMap.onNewDownloadIndexes();
+ }
refreshMap();
}
@@ -1323,6 +1326,9 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
if (fragmentRef != null) {
fragmentRef.get().downloadInProgress();
}
+ if (dashboardOnMap.isVisible()) {
+ dashboardOnMap.onDownloadInProgress();
+ }
}
@Override
@@ -1335,6 +1341,9 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
if (fragmentRef != null) {
fragmentRef.get().downloadHasFinished();
}
+ if (dashboardOnMap.isVisible()) {
+ dashboardOnMap.onDownloadHasFinished();
+ }
refreshMap();
}
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
index c492eb3db1..2143f61a14 100644
--- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
+++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
@@ -63,6 +63,8 @@ import net.osmand.plus.dashboard.tools.TransactionBuilder;
import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.dialogs.RasterMapMenu;
import net.osmand.plus.download.DownloadActivity;
+import net.osmand.plus.download.DownloadIndexesThread;
+import net.osmand.plus.download.IndexItem;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.MapMarkerDialogHelper;
import net.osmand.plus.helpers.MapMarkerDialogHelper.MapMarkersDialogHelperCallbacks;
@@ -86,6 +88,7 @@ import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener;
import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.DismissCallbacks;
import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.Undoable;
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry;
+import net.osmand.search.core.ObjectType;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
@@ -886,7 +889,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
&& visibleType != DashboardType.MAP_MARKERS
&& visibleType != DashboardType.MAP_MARKERS_SELECTION
&& visibleType != DashboardType.CONFIGURE_SCREEN
- && visibleType != DashboardType.CONFIGURE_MAP) {
+ && visibleType != DashboardType.CONFIGURE_MAP
+ && visibleType != DashboardType.CONTOUR_LINES) {
listView.setDivider(dividerDrawable);
listView.setDividerHeight(dpToPx(1f));
} else {
@@ -982,6 +986,37 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
updateListAdapter(listAdapter, listener);
}
+ public void onNewDownloadIndexes() {
+ if (visibleType == DashboardType.CONTOUR_LINES) {
+ refreshContent(true);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void onDownloadInProgress() {
+ if (visibleType == DashboardType.CONTOUR_LINES) {
+ DownloadIndexesThread downloadThread = getMyApplication().getDownloadThread();
+ IndexItem downloadIndexItem = downloadThread.getCurrentDownloadingItem();
+ if (downloadIndexItem != null) {
+ int downloadProgress = downloadThread.getCurrentDownloadingItemProgress();
+ ArrayAdapter adapter = (ArrayAdapter) listAdapter;
+ for (int i = 0; i < adapter.getCount(); i++) {
+ ContextMenuItem item = adapter.getItem(i);
+ if (item != null && item.getProgressListener() != null) {
+ item.getProgressListener().onProgressChanged(
+ downloadIndexItem, downloadProgress, adapter, (int) adapter.getItemId(i), i);
+ }
+ }
+ }
+ }
+ }
+
+ public void onDownloadHasFinished() {
+ if (visibleType == DashboardType.CONTOUR_LINES) {
+ refreshContent(true);
+ }
+ }
+
public void refreshContent(boolean force) {
if (visibleType == DashboardType.WAYPOINTS
|| visibleType == DashboardType.MAP_MARKERS
@@ -989,7 +1024,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|| visibleType == DashboardType.CONFIGURE_SCREEN
|| force) {
updateListAdapter();
- } else if (visibleType == DashboardType.CONFIGURE_MAP || visibleType == DashboardType.ROUTE_PREFERENCES) {
+ } else if (visibleType == DashboardType.CONFIGURE_MAP
+ || visibleType == DashboardType.ROUTE_PREFERENCES) {
int index = listView.getFirstVisiblePosition();
View v = listView.getChildAt(0);
int top = (v == null) ? 0 : (v.getTop() - listView.getPaddingTop());
diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java b/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java
index ed436c97c2..901cba0548 100644
--- a/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java
+++ b/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java
@@ -1,8 +1,14 @@
package net.osmand.plus.srtmplugin;
+import android.content.Intent;
import android.view.View;
import android.widget.ArrayAdapter;
+import net.osmand.binary.BinaryMapDataObject;
+import net.osmand.binary.BinaryMapIndexReader;
+import net.osmand.data.LatLon;
+import net.osmand.map.OsmandRegions;
+import net.osmand.map.WorldRegion;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmandApplication;
@@ -10,11 +16,20 @@ import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
-import net.osmand.plus.activities.SettingsActivity;
-import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
+import net.osmand.plus.activities.PluginActivity;
+import net.osmand.plus.download.DownloadActivityType;
+import net.osmand.plus.download.DownloadIndexesThread;
+import net.osmand.plus.download.DownloadValidationManager;
+import net.osmand.plus.download.IndexItem;
import net.osmand.plus.views.GPXLayer;
import net.osmand.plus.views.RouteLayer;
import net.osmand.render.RenderingRuleProperty;
+import net.osmand.util.MapUtils;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_ATTR;
import static net.osmand.plus.srtmplugin.SRTMPlugin.CONTOUR_LINES_DISABLED_VALUE;
@@ -24,6 +39,10 @@ public class ContourLinesMenu {
private static final String TAG = "ContourLinesMenu";
public static ContextMenuAdapter createListAdapter(final MapActivity mapActivity) {
+ SRTMPlugin plugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
+ if (plugin != null && !plugin.isActive() && !plugin.needsInstallation()) {
+ OsmandPlugin.enablePlugin(mapActivity, mapActivity.getMyApplication(), plugin, true);
+ }
ContextMenuAdapter adapter = new ContextMenuAdapter();
adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
createLayersItems(adapter, mapActivity);
@@ -35,6 +54,7 @@ public class ContourLinesMenu {
final OsmandApplication app = mapActivity.getMyApplication();
final OsmandSettings settings = app.getSettings();
final SRTMPlugin plugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
+ final boolean srtmEnabled = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null;
final RenderingRuleProperty contourLinesProp = app.getRendererRegistry().getCustomRenderingRuleProperty(CONTOUR_LINES_ATTR);
final RenderingRuleProperty colorSchemeProp = app.getRendererRegistry().getCustomRenderingRuleProperty(CONTOUR_LINES_SCHEME_ATTR);
@@ -102,6 +122,11 @@ public class ContourLinesMenu {
refreshMapComplete(mapActivity);
}
});
+ } else if (itemId == R.string.srtm_plugin_name) {
+ Intent intent = new Intent(mapActivity, PluginActivity.class);
+ intent.putExtra(PluginActivity.EXTRA_PLUGIN_ID, plugin.getId());
+ mapActivity.startActivity(intent);
+ closeDashboard(mapActivity);
}
return false;
}
@@ -122,7 +147,6 @@ public class ContourLinesMenu {
.setTitleId(toggleActionStringId, mapActivity)
.setIcon(toggleIconId)
.setColor(toggleIconColorId)
- .hideDivider(true)
.setListener(l)
.setSelected(selected).createItem());
if (selected) {
@@ -130,17 +154,130 @@ public class ContourLinesMenu {
.setTitleId(showZoomLevelStringId, mapActivity)
.setLayout(R.layout.list_item_single_line_descrition_narrow)
.setIcon(R.drawable.ic_action_map_magnifier)
- .hideDivider(true)
.setDescription(plugin.getPrefDescription(app, contourLinesProp, pref))
.setListener(l).createItem());
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(colorSchemeStringId, mapActivity)
.setLayout(R.layout.list_item_single_line_descrition_narrow)
.setIcon(R.drawable.ic_action_appearance)
- .hideDivider(true)
.setDescription(plugin.getPrefDescription(app, colorSchemeProp, colorPref))
.setListener(l).createItem());
}
+
+ if (!srtmEnabled) {
+ contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.srtm_purchase_header, mapActivity)
+ .setCategory(true).setLayout(R.layout.list_group_title_with_switch_light).createItem());
+ contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
+ .setTitleId(R.string.srtm_plugin_name, mapActivity)
+ .setLayout(R.layout.list_item_icon_and_right_btn)
+ .setIcon(R.drawable.ic_plugin_srtm)
+ .setColor(R.color.osmand_orange)
+ .setDescription(app.getString(R.string.shared_string_plugin))
+ .setListener(l).createItem());
+ } else {
+ final DownloadIndexesThread downloadThread = app.getDownloadThread();
+ if (!downloadThread.getIndexes().isDownloadedFromInternet) {
+ if (settings.isInternetConnectionAvailable()) {
+ downloadThread.runReloadIndexFiles();
+ }
+ }
+ final boolean downloadIndexes = settings.isInternetConnectionAvailable()
+ && !downloadThread.getIndexes().isDownloadedFromInternet
+ && !downloadThread.getIndexes().downloadFromInternetFailed;
+
+ if (downloadIndexes) {
+ contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
+ .setTitleId(R.string.shared_string_download_map, mapActivity)
+ .setDescription(app.getString(R.string.srtm_menu_download_descr))
+ .setCategory(true)
+ .setLayout(R.layout.list_group_title_with_descr).createItem());
+ contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
+ .setLayout(R.layout.list_item_icon_and_download)
+ .setTitleId(R.string.downloading_list_indexes, mapActivity)
+ .setLoading(true)
+ .setListener(l).createItem());
+ } else {
+ try {
+ IndexItem currentDownloadingItem = downloadThread.getCurrentDownloadingItem();
+ int currentDownloadingProgress = downloadThread.getCurrentDownloadingItemProgress();
+ List srtms = findSrtmIndexItems(app, mapActivity.getMapLocation());
+ if (srtms.size() > 0) {
+ contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
+ .setTitleId(R.string.shared_string_download_map, mapActivity)
+ .setDescription(app.getString(R.string.srtm_menu_download_descr))
+ .setCategory(true)
+ .setLayout(R.layout.list_group_title_with_descr).createItem());
+ for (final IndexItem indexItem : srtms) {
+ ContextMenuItem.ItemBuilder itemBuilder = new ContextMenuItem.ItemBuilder()
+ .setLayout(R.layout.list_item_icon_and_download)
+ .setTitle(indexItem.getVisibleName(app, app.getRegions(), false))
+ .setDescription(app.getString(R.string.srtm_plugin_name) + " • " + indexItem.getSizeDescription(app))
+ .setIcon(R.drawable.ic_plugin_srtm)
+ .setListener(new ContextMenuAdapter.ItemClickListener() {
+ @Override
+ public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int position, boolean isChecked) {
+ ContextMenuItem item = adapter.getItem(position);
+ if (downloadThread.isDownloading(indexItem)) {
+ downloadThread.cancelDownload(indexItem);
+ if (item != null) {
+ item.setProgress(ContextMenuItem.INVALID_ID);
+ item.setLoading(false);
+ item.setSecondaryIcon(R.drawable.ic_action_import);
+ adapter.notifyDataSetChanged();
+ }
+ } else {
+ new DownloadValidationManager(app).startDownload(mapActivity, indexItem);
+ if (item != null) {
+ item.setProgress(ContextMenuItem.INVALID_ID);
+ item.setLoading(true);
+ item.setSecondaryIcon(R.drawable.ic_action_remove_dark);
+ adapter.notifyDataSetChanged();
+ }
+ }
+ return false;
+ }
+ })
+ .setProgressListener(new ContextMenuAdapter.ProgressListener() {
+ @Override
+ public boolean onProgressChanged(Object progressObject, int progress,
+ ArrayAdapter adapter,
+ int itemId, int position) {
+ if (progressObject != null && progressObject instanceof IndexItem) {
+ IndexItem progressItem = (IndexItem) progressObject;
+ if (indexItem.compareTo(progressItem) == 0) {
+ ContextMenuItem item = adapter.getItem(position);
+ if (item != null) {
+ item.setProgress(progress);
+ item.setLoading(true);
+ item.setSecondaryIcon(R.drawable.ic_action_remove_dark);
+ adapter.notifyDataSetChanged();
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+ });
+
+ if (indexItem == currentDownloadingItem) {
+ itemBuilder.setLoading(true)
+ .setProgress(currentDownloadingProgress)
+ .setSecondaryIcon(R.drawable.ic_action_remove_dark);
+ } else {
+ itemBuilder.setSecondaryIcon(R.drawable.ic_action_import);
+ }
+ contextMenuAdapter.addItem(itemBuilder.createItem());
+ }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ public static void closeDashboard(MapActivity mapActivity) {
+ mapActivity.getDashboard().hideDashboard(false);
}
public static void refreshMapComplete(final MapActivity activity) {
@@ -156,4 +293,53 @@ public class ContourLinesMenu {
}
activity.getMapView().refreshMap(true);
}
+
+ public static List findSrtmIndexItems(OsmandApplication app, LatLon latLon) throws IOException {
+
+ List res = new ArrayList<>();
+ OsmandRegions regions = app.getRegions();
+ DownloadIndexesThread downloadThread = app.getDownloadThread();
+
+ int point31x = MapUtils.get31TileNumberX(latLon.getLongitude());
+ int point31y = MapUtils.get31TileNumberY(latLon.getLatitude());
+
+ List mapDataObjects;
+ try {
+ mapDataObjects = regions.queryBbox(point31x, point31x, point31y, point31y);
+ } catch (IOException e) {
+ throw new IOException("Error while calling queryBbox");
+ }
+ if (mapDataObjects != null) {
+ Iterator it = mapDataObjects.iterator();
+ while (it.hasNext()) {
+ BinaryMapDataObject o = it.next();
+ if (o.getTypes() != null) {
+ boolean isRegion = true;
+ for (int i = 0; i < o.getTypes().length; i++) {
+ BinaryMapIndexReader.TagValuePair tp = o.getMapIndex().decodeType(o.getTypes()[i]);
+ if ("boundary".equals(tp.value)) {
+ isRegion = false;
+ break;
+ }
+ }
+ WorldRegion downloadRegion = regions.getRegionData(regions.getFullName(o));
+ if (downloadRegion == null || !isRegion || !regions.contain(o, point31x, point31y)) {
+ it.remove();
+ }
+ List otherIndexItems = new ArrayList<>(downloadThread.getIndexes().getIndexItems(downloadRegion));
+ for (IndexItem indexItem : otherIndexItems) {
+ if (indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE
+ && !res.contains(indexItem)) {
+ if (indexItem.isDownloaded()) {
+ res.clear();
+ return res;
+ }
+ res.add(indexItem);
+ }
+ }
+ }
+ }
+ }
+ return res;
+ }
}
diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java
index fb28967e10..725fe0d3a7 100644
--- a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java
@@ -141,21 +141,29 @@ public class SRTMPlugin extends OsmandPlugin {
toggleContourLines(mapActivity, isChecked, new Runnable() {
@Override
public void run() {
- ContextMenuItem item = adapter.getItem(position);
- if (item != null) {
- RenderingRuleProperty contourLinesProp = app.getRendererRegistry().getCustomRenderingRuleProperty(CONTOUR_LINES_ATTR);
- if (contourLinesProp != null) {
- OsmandSettings settings = app.getSettings();
- final OsmandSettings.CommonPreference pref =
- settings.getCustomRenderProperty(contourLinesProp.getAttrName());
- boolean selected = !pref.get().equals(CONTOUR_LINES_DISABLED_VALUE);
+ RenderingRuleProperty contourLinesProp = app.getRendererRegistry().getCustomRenderingRuleProperty(CONTOUR_LINES_ATTR);
+ if (contourLinesProp != null) {
+ OsmandSettings settings = app.getSettings();
+ final OsmandSettings.CommonPreference pref =
+ settings.getCustomRenderProperty(contourLinesProp.getAttrName());
+ boolean selected = !pref.get().equals(CONTOUR_LINES_DISABLED_VALUE);
+
+ SRTMPlugin plugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
+ if (selected && plugin != null && !plugin.isActive() && !plugin.needsInstallation()) {
+ OsmandPlugin.enablePlugin(mapActivity, mapActivity.getMyApplication(), plugin, true);
+ }
+
+ ContextMenuItem item = adapter.getItem(position);
+ if (item != null) {
item.setDescription(app.getString(R.string.display_zoom_level,
getPrefDescription(app, contourLinesProp, pref)));
item.setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
item.setSelected(selected);
adapter.notifyDataSetChanged();
}
+ ContourLinesMenu.refreshMapComplete(mapActivity);
}
+
}
});
} else if (itemId == R.string.layer_hillshade) {