diff --git a/OsmAnd/res/layout/two_line_with_images_list_item.xml b/OsmAnd/res/layout/two_line_with_images_list_item.xml index 0ae308daf2..dbbda7119e 100644 --- a/OsmAnd/res/layout/two_line_with_images_list_item.xml +++ b/OsmAnd/res/layout/two_line_with_images_list_item.xml @@ -57,7 +57,7 @@ - diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index a086f24227..64b4d872fb 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -2002,4 +2002,6 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A Show free version banner Even if you have paid version you still can see free version banner BUY + Please activate Seamarks plugin + Please activate SRTM plugin diff --git a/OsmAnd/src/net/osmand/plus/download/items/ItemViewHolder.java b/OsmAnd/src/net/osmand/plus/download/items/ItemViewHolder.java index 3b77cc15a5..2274dc820c 100644 --- a/OsmAnd/src/net/osmand/plus/download/items/ItemViewHolder.java +++ b/OsmAnd/src/net/osmand/plus/download/items/ItemViewHolder.java @@ -1,7 +1,9 @@ package net.osmand.plus.download.items; +import android.content.Intent; import android.content.res.Resources; import android.graphics.drawable.Drawable; +import android.net.Uri; import android.util.TypedValue; import android.view.View; import android.widget.Button; @@ -14,6 +16,7 @@ import net.osmand.PlatformUtil; import net.osmand.access.AccessibleToast; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; +import net.osmand.plus.Version; import net.osmand.plus.WorldRegion; import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivityType; @@ -35,6 +38,7 @@ public class ItemViewHolder { private boolean freeVersion; private int textColorPrimary; private int textColorSecondary; + private RightButtonAction rightButtonAction; private enum RightButtonAction { UNKNOWN, @@ -72,10 +76,11 @@ public class ItemViewHolder { this.freeVersion = freeVersion; } - public void bindIndexItem(final IndexItem indexItem, final DownloadActivity context, boolean showTypeInTitle, boolean showTypeInDesc) { + public void bindIndexItem(final IndexItem indexItem, final DownloadActivity context, + boolean showTypeInTitle, boolean showTypeInDesc) { boolean disabled = false; String textButtonCaption = "GET"; - RightButtonAction rightButtonAction = RightButtonAction.UNKNOWN; + rightButtonAction = RightButtonAction.UNKNOWN; if (indexItem.getType() == DownloadActivityType.VOICE_FILE) { nameTextView.setText(indexItem.getVisibleName(context, @@ -118,7 +123,6 @@ public class ItemViewHolder { } else { descrTextView.setText(indexItem.getSizeDescription(context)); } - // TODO replace with imageView. rightImageButton.setVisibility(View.VISIBLE); rightImageButton.setImageDrawable(getContextIcon(context, R.drawable.ic_action_import)); progressBar.setVisibility(View.GONE); @@ -135,16 +139,26 @@ public class ItemViewHolder { public void onClick(View v) { switch (action) { case ASK_FOR_FULL_VERSION_PURCHASE: - AccessibleToast.makeText(context, "Please purchase Full version", Toast.LENGTH_SHORT).show(); + Intent intent = new Intent(Intent.ACTION_VIEW, + Uri.parse(Version.marketPrefix(context.getMyApplication()) + + "net.osmand.plus")); + context.startActivity(intent); break; case ASK_FOR_SEAMARKS_PLUGIN: - AccessibleToast.makeText(context.getApplicationContext(), "Please turn on Seamarks plugin", Toast.LENGTH_SHORT).show(); + context.startActivity(new Intent(context, + context.getMyApplication().getAppCustomization().getPluginsActivity())); + AccessibleToast.makeText(context.getApplicationContext(), + context.getString(R.string.activate_seamarks_plugin), Toast.LENGTH_SHORT).show(); break; case ASK_FOR_SRTM_PLUGIN_PURCHASE: - AccessibleToast.makeText(context, "Please purchase SRTM plugin", Toast.LENGTH_SHORT).show(); + OsmandPlugin plugin = OsmandPlugin.getPlugin(SRTMPlugin.class); + context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL()))); break; case ASK_FOR_SRTM_PLUGIN_ENABLE: - AccessibleToast.makeText(context, "Please activate SRTM plugin", Toast.LENGTH_SHORT).show(); + context.startActivity(new Intent(context, + context.getMyApplication().getAppCustomization().getPluginsActivity())); + AccessibleToast.makeText(context, + context.getString(R.string.activate_srtm_plugin), Toast.LENGTH_SHORT).show(); break; } } @@ -190,4 +204,8 @@ public class ItemViewHolder { private Drawable getContextIcon(DownloadActivity context, int resourceId, int color) { return context.getMyApplication().getIconsCache().getPaintedContentIcon(resourceId, color); } + + public boolean isItemAvailable() { + return rightButtonAction == RightButtonAction.UNKNOWN; + } } diff --git a/OsmAnd/src/net/osmand/plus/download/items/RegionItemsFragment.java b/OsmAnd/src/net/osmand/plus/download/items/RegionItemsFragment.java index cdd0e52288..8120415e58 100644 --- a/OsmAnd/src/net/osmand/plus/download/items/RegionItemsFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/items/RegionItemsFragment.java @@ -99,10 +99,13 @@ public class RegionItemsFragment extends OsmandExpandableListFragment { .onRegionSelected(region.getRegionId()); return true; } else if (obj instanceof ItemsListBuilder.ResourceItem) { - IndexItem indexItem = ((ItemsListBuilder.ResourceItem) obj).getIndexItem(); - ((BaseDownloadActivity) getActivity()) - .startDownload(indexItem); - return true; + if(((ItemViewHolder) v.getTag()).isItemAvailable()) { + IndexItem indexItem = ((ItemsListBuilder.ResourceItem) obj).getIndexItem(); + ((BaseDownloadActivity) getActivity()) + .startDownload(indexItem); + + return true; + } } return false; } diff --git a/OsmAnd/src/net/osmand/plus/download/newimplementation/DownloadsUiHelper.java b/OsmAnd/src/net/osmand/plus/download/newimplementation/DownloadsUiHelper.java index bcc3afb2bf..32a67ad694 100644 --- a/OsmAnd/src/net/osmand/plus/download/newimplementation/DownloadsUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/download/newimplementation/DownloadsUiHelper.java @@ -133,7 +133,6 @@ public final class DownloadsUiHelper { @Override public void onFinished() { - freeVersionBanner.setVisibility(View.VISIBLE); downloadProgressLayout.setVisibility(View.GONE); } }