diff --git a/OsmAnd/res/layout/travel_needed_map_item.xml b/OsmAnd/res/layout/travel_needed_map_item.xml
index 796217baa0..2f7860f4cd 100644
--- a/OsmAnd/res/layout/travel_needed_map_item.xml
+++ b/OsmAnd/res/layout/travel_needed_map_item.xml
@@ -76,6 +76,7 @@
+ osmand:typeface="@string/font_roboto_regular"/>
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index a2d845e36b..97c2b1d22f 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -12,7 +12,7 @@
You have cancel OsmAnd Live subscription
Renew subscription to continue use the all features:
- You read articles: %1$s. Based on this, we suggest you download these maps:
+ Based on the articles you saved, we recommend you to download following maps:
Maps you need
OsmAnd team
Popular destinations
diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java
index 99b00c9f99..e1ffdc77a3 100644
--- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java
+++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java
@@ -19,13 +19,16 @@ import net.osmand.plus.wikivoyage.explore.travelcards.StartEditingTravelCard;
import net.osmand.plus.wikivoyage.explore.travelcards.StartEditingTravelCard.StartEditingTravelVH;
import net.osmand.plus.wikivoyage.explore.travelcards.TravelDownloadUpdateCard;
import net.osmand.plus.wikivoyage.explore.travelcards.TravelDownloadUpdateCard.DownloadUpdateVH;
+import net.osmand.plus.wikivoyage.explore.travelcards.TravelNeededMapsCard;
+import net.osmand.plus.wikivoyage.explore.travelcards.TravelNeededMapsCard.NeededMapsVH;
import java.util.ArrayList;
import java.util.List;
public class ExploreRvAdapter extends RecyclerView.Adapter {
- private static final int DOWNLOAD_UPDATE_CARD_POSITION = 0;
+ private static final int FIRST_POSITION = 0;
+ private static final int SECOND_POSITION = 1;
private final List items = new ArrayList<>();
@@ -48,6 +51,9 @@ public class ExploreRvAdapter extends RecyclerView.Adapter DOWNLOAD_UPDATE_CARD_POSITION) {
- BaseTravelCard card = getItem(DOWNLOAD_UPDATE_CARD_POSITION);
- if (card.getCardType() == TravelDownloadUpdateCard.TYPE) {
- removeItem(DOWNLOAD_UPDATE_CARD_POSITION);
- notifyItemRemoved(DOWNLOAD_UPDATE_CARD_POSITION);
- }
+ int pos = getDownloadUpdateCardPosition();
+ if (downloadUpdateCardExists(pos)) {
+ removeItem(pos);
+ notifyItemRemoved(pos);
}
}
+
+ private int getDownloadUpdateCardPosition() {
+ return FIRST_POSITION;
+ }
+
+ private boolean downloadUpdateCardExists(int position) {
+ return items.size() > position && items.get(position).getCardType() == TravelDownloadUpdateCard.TYPE;
+ }
}
diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java
index 746e4e116c..19dd01e526 100644
--- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java
+++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java
@@ -34,6 +34,7 @@ import net.osmand.plus.wikivoyage.explore.travelcards.HeaderTravelCard;
import net.osmand.plus.wikivoyage.explore.travelcards.OpenBetaTravelCard;
import net.osmand.plus.wikivoyage.explore.travelcards.StartEditingTravelCard;
import net.osmand.plus.wikivoyage.explore.travelcards.TravelDownloadUpdateCard;
+import net.osmand.plus.wikivoyage.explore.travelcards.TravelNeededMapsCard;
import java.io.File;
import java.io.IOException;
@@ -153,6 +154,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadIn
this.mainIndexItem = mainIndexItem;
this.neededIndexItems = neededIndexItems;
addDownloadUpdateCard();
+ addNeededMapsCard();
}
private void addDownloadUpdateCard() {
@@ -209,6 +211,12 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadIn
}
}
+ private void addNeededMapsCard() {
+ if (!neededIndexItems.isEmpty()) {
+ adapter.setNeededMapsCard(new TravelNeededMapsCard(getMyApplication(), nightMode, neededIndexItems));
+ }
+ }
+
@NonNull
private String getWikivoyageFileName() {
File selectedTravelBook = getMyApplication().getTravelDbHelper().getSelectedTravelBook();
diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelDownloadUpdateCard.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelDownloadUpdateCard.java
index b7c1226887..a8b8987727 100644
--- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelDownloadUpdateCard.java
+++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelDownloadUpdateCard.java
@@ -128,7 +128,7 @@ public class TravelDownloadUpdateCard extends BaseTravelCard {
@NonNull
private String getFileTitle() {
- return indexItem == null ? "" : indexItem.getBasename().replace("_", " ");
+ return indexItem == null ? "" : indexItem.getVisibleName(app, app.getRegions(), false);
}
@NonNull
diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelNeededMapsCard.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelNeededMapsCard.java
new file mode 100644
index 0000000000..a987764b76
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelNeededMapsCard.java
@@ -0,0 +1,96 @@
+package net.osmand.plus.wikivoyage.explore.travelcards;
+
+import android.graphics.drawable.Drawable;
+import android.support.annotation.NonNull;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.R;
+import net.osmand.plus.download.IndexItem;
+
+import java.util.List;
+
+public class TravelNeededMapsCard extends BaseTravelCard {
+
+ public static final int TYPE = 70;
+
+ private List items;
+
+ private Drawable downloadIcon;
+
+ public TravelNeededMapsCard(OsmandApplication app, boolean nightMode, List items) {
+ super(app, nightMode);
+ this.items = items;
+ downloadIcon = getActiveIcon(R.drawable.ic_action_import);
+ }
+
+ @Override
+ public void bindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder) {
+ if (viewHolder instanceof NeededMapsVH) {
+ NeededMapsVH holder = (NeededMapsVH) viewHolder;
+ adjustChildCount(holder.itemsContainer);
+ for (int i = 0; i < items.size(); i++) {
+ boolean lastItem = i == items.size() - 1;
+ IndexItem item = items.get(i);
+ View view = holder.itemsContainer.getChildAt(i);
+ ((ImageView) view.findViewById(R.id.icon))
+ .setImageDrawable(getActiveIcon(item.getType().getIconResource()));
+ ((TextView) view.findViewById(R.id.title)).setText(item.getVisibleName(app, app.getRegions(), false));
+ ((TextView) view.findViewById(R.id.description)).setText(getItemDescription(item));
+ ((ImageView) view.findViewById(R.id.icon_action)).setImageDrawable(downloadIcon);
+ view.findViewById(R.id.divider).setVisibility(lastItem ? View.GONE : View.VISIBLE);
+ }
+ }
+ }
+
+ @Override
+ public int getCardType() {
+ return TYPE;
+ }
+
+ private void adjustChildCount(LinearLayout itemsContainer) {
+ int itemsCount = items.size();
+ int childCount = itemsContainer.getChildCount();
+ if (itemsCount == childCount) {
+ return;
+ }
+ if (itemsCount > childCount) {
+ LayoutInflater inflater = LayoutInflater.from(itemsContainer.getContext());
+ for (int i = childCount; i < itemsCount; i++) {
+ inflater.inflate(R.layout.travel_needed_map_item, itemsContainer);
+ }
+ } else if (itemsCount < childCount) {
+ itemsContainer.removeViews(0, childCount - itemsCount);
+ }
+ }
+
+ private String getItemDescription(IndexItem item) {
+ return app.getString(R.string.file_size_in_mb, item.getArchiveSizeMB()) + " • " + item.getType().getString(app);
+ }
+
+ public static class NeededMapsVH extends RecyclerView.ViewHolder {
+
+ final LinearLayout itemsContainer;
+ final View secondaryBtnContainer;
+ final TextView secondaryBtn;
+ final View buttonsDivider;
+ final View primaryBtnContainer;
+ final TextView primaryButton;
+
+ @SuppressWarnings("RedundantCast")
+ public NeededMapsVH(View itemView) {
+ super(itemView);
+ itemsContainer = (LinearLayout) itemView.findViewById(R.id.items_container);
+ secondaryBtnContainer = itemView.findViewById(R.id.secondary_btn_container);
+ secondaryBtn = (TextView) itemView.findViewById(R.id.secondary_button);
+ buttonsDivider = itemView.findViewById(R.id.buttons_divider);
+ primaryBtnContainer = itemView.findViewById(R.id.primary_btn_container);
+ primaryButton = (TextView) itemView.findViewById(R.id.primary_button);
+ }
+ }
+}