diff --git a/OsmAnd/res/layout/wikivoyage_open_beta_card.xml b/OsmAnd/res/layout/wikivoyage_open_beta_card.xml index c103c226e7..58e971d386 100644 --- a/OsmAnd/res/layout/wikivoyage_open_beta_card.xml +++ b/OsmAnd/res/layout/wikivoyage_open_beta_card.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" - android:layout_marginTop="@dimen/list_content_padding" + android:layout_marginTop="@dimen/content_padding_small" android:layout_marginLeft="@dimen/text_margin_small" android:layout_marginRight="@dimen/text_margin_small" android:background="@drawable/travel_card_bg" @@ -62,9 +62,9 @@ android:layout_width="match_parent" android:layout_height="@dimen/bottom_sheet_title_height" android:layout_gravity="center" - android:paddingBottom="@dimen/abp__shadow_height" android:background="?attr/selectableItemBackground" - android:gravity="center" + android:gravity="center_horizontal" + android:paddingTop="@dimen/wikivoyage_travel_card_button_padding" android:textColor="?attr/color_dialog_buttons" android:textSize="@dimen/default_desc_text_size" osmand:typeface="@string/font_roboto_medium" diff --git a/OsmAnd/res/layout/wikivoyage_start_editing_card.xml b/OsmAnd/res/layout/wikivoyage_start_editing_card.xml index bb04621e54..0ecfab8230 100644 --- a/OsmAnd/res/layout/wikivoyage_start_editing_card.xml +++ b/OsmAnd/res/layout/wikivoyage_start_editing_card.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" - android:layout_marginTop="@dimen/list_content_padding" + android:layout_marginTop="@dimen/content_padding_small" android:layout_marginLeft="@dimen/text_margin_small" android:layout_marginRight="@dimen/text_margin_small" android:background="@drawable/travel_card_bg"> @@ -69,7 +69,8 @@ android:layout_width="match_parent" android:layout_height="@dimen/bottom_sheet_title_height" android:layout_gravity="center" - android:gravity="center" + android:gravity="center_horizontal" + android:paddingTop="@dimen/wikivoyage_travel_card_button_padding" android:background="?attr/selectableItemBackground" android:textColor="?attr/color_dialog_buttons" android:textSize="@dimen/default_desc_text_size" diff --git a/OsmAnd/res/values-large/sizes.xml b/OsmAnd/res/values-large/sizes.xml index 6f317ee4ca..53875d577c 100644 --- a/OsmAnd/res/values-large/sizes.xml +++ b/OsmAnd/res/values-large/sizes.xml @@ -208,4 +208,6 @@ 33dp 82dp 216dp + 22dp + \ No newline at end of file diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index edd674425e..7875a4e4d9 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -291,6 +291,7 @@ 14dp 22dp 64dp + 15dp 144dp diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java index 1b4ef91f95..6a77f4b2c8 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java @@ -221,6 +221,9 @@ public class TravelDbHelper { } cursor.close(); } + + sortPopularArticles(res); + return res; } @@ -244,6 +247,27 @@ public class TravelDbHelper { }); } + private void sortPopularArticles(List list) { + Location location = application.getLocationProvider().getLastKnownLocation(); + if (location != null) { + final LatLon loc = new LatLon(location.getLatitude(), location.getLongitude()); + Collections.sort(list, new Comparator() { + @Override + public int compare(TravelArticle article1, TravelArticle article2) { + int d1 = (int) MapUtils.getDistance(loc, article1.getLat(), article1.getLon()); + int d2 = (int) MapUtils.getDistance(loc, article2.getLat(), article2.getLon()); + if (d1 > d2) { + return 1; + } else if (d1 == d2) { + return 0; + } else { + return -1; + } + } + }); + } + } + private Collection groupSearchResultsByCityId(List res) { String baseLng = application.getLanguage(); TLongObjectHashMap wikivoyage = new TLongObjectHashMap<>(); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java index 0159998fd8..5aa89c2a9b 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java @@ -9,12 +9,10 @@ import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.ProgressBar; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.Version; -import net.osmand.plus.Version; import net.osmand.plus.activities.LocalIndexHelper; import net.osmand.plus.activities.LocalIndexInfo; import net.osmand.plus.activities.OsmandActionBarActivity; @@ -63,15 +61,11 @@ public class ExploreTabFragment extends BaseOsmAndFragment { addDownloadUpdateCard(); startEditingTravelCard = new StartEditingTravelCard(app, nightMode); - items.add(new OpenBetaTravelCard(app, nightMode, getFragmentManager())); - items.add(startEditingTravelCard); - addPopularDestinations(app); - addDownloadUpdateCard(nightMode); addOpenBetaTravelCard(items, nightMode); - startEditingTravelCard = new StartEditingTravelCard(app, nightMode); items.add(startEditingTravelCard); items.add(getString(R.string.popular_destinations)); - addPopularDestinations(app, nightMode); + addPopularDestinations(app); + return items; } @@ -92,10 +86,10 @@ public class ExploreTabFragment extends BaseOsmAndFragment { private void addPopularDestinations(OsmandApplication app) { PopularDestinationsSearchTask popularDestinationsSearchTask = new PopularDestinationsSearchTask( - app.getTravelDbHelper(), getMyActivity(), adapter, nightMode, startEditingTravelCard, progressBar - ); + app.getTravelDbHelper(), getMyActivity(), adapter, nightMode, startEditingTravelCard); popularDestinationsSearchTask.execute(); } + private void addOpenBetaTravelCard(List items, final boolean nightMode) { final OsmandApplication app = getMyApplication(); if ((Version.isFreeVersion(app) && !app.getSettings().LIVE_UPDATES_PURCHASED.get() @@ -103,6 +97,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment { items.add(new OpenBetaTravelCard(app, nightMode, getFragmentManager())); } } + private static class CheckWorldWikivoyageTask extends AsyncTask { private OsmandApplication app; @@ -151,7 +146,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment { private boolean nightMode; PopularDestinationsSearchTask(TravelDbHelper travelDbHelper, - OsmandActionBarActivity context, ExploreRvAdapter adapter, boolean nightMode, StartEditingTravelCard startEditingTravelCard, View progressBar) { + OsmandActionBarActivity context, ExploreRvAdapter adapter, boolean nightMode, StartEditingTravelCard startEditingTravelCard) { this.travelDbHelper = travelDbHelper; weakContext = new WeakReference<>(context); weakAdapter = new WeakReference<>(adapter);