From 811c74babe5cdd40f1c4510488efbb683e1158ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Allan=20Nordh=C3=B8y?= Date: Sun, 15 Apr 2018 12:08:54 +0200 Subject: [PATCH 01/17] Search for, linebreaks --- OsmAnd/res/values/strings.xml | 268 +++++++++++++++++----------------- 1 file changed, 134 insertions(+), 134 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index cc14704027..0b3b66e697 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -1682,196 +1682,196 @@ OsmAnd Maps & Navigation Global Mobile Map Viewing & Navigation for Offline and Online OSM Maps - OsmAnd (OSM Automated Navigation Directions) + OsmAnd (OSM Automated Navigation Directions)\n\n - OsmAnd is an open source software navigation app with access to a wide variety of global OpenStreetMap (OSM) data. All map data (vector or tile maps) can be stored on the phone memory card for offline usage. Offline and online routing functionality is also offered, including turn-by-turn voice guidance. + OsmAnd is an open source software navigation app with access to a wide variety of global OpenStreetMap (OSM) data. All map data (vector or tile maps) can be stored on the phone memory card for offline usage. Offline and online routing functionality is also offered, including turn-by-turn voice guidance.\n\n - Some of the core features: - - Complete offline functionality (store downloaded vector or tile maps in the device storage) - - Compact offline vector maps for the whole world available - - Download of country or region maps directly from the app - - Overlay of several map layers possible, like GPX or navigation tracks, Points of Interest, favorites, contour lines, public transport stops, additional maps with customizable transparency - - Offline search for addresses and places (POIs) - - Offline routing for medium-range distances - - Car, bicycle, and pedestrian modes with optional: - - Automated day/night view switching - - Speed-dependent map zooming - - Map alignment according to compass or direction of motion - - Lane guidance, speed limit display, recorded and TTS voices + Some of the core features:\n + - Complete offline functionality (store downloaded vector or tile maps in the device storage)\n + - Compact offline vector maps for the whole world available\n + - Download of country or region maps directly from the app\n + - Overlay of several map layers possible, like GPX or navigation tracks, Points of Interest, favorites, contour lines, public transport stops, additional maps with customizable transparency\n + - Offline search for addresses and places (POIs)\n + - Offline routing for medium-range distances\n + - Car, bicycle, and pedestrian modes with optional:\n + - Automated day/night view switching\n + - Speed-dependent map zooming\n + - Map alignment according to compass or direction of motion\n + - Lane guidance, speed limit display, recorded and TTS voices\n\n - Limitations of this free version of OsmAnd: - - Number of map downloads limited - - No offline access to Wikipedia POIs + Limitations of this free version of OsmAnd:\n + - Number of map downloads limited\n + - No offline access to Wikipedia POIs\n\n OsmAnd is actively being developed and our project and its continued progress relies on financial contributions for development and testing of new functionality. Please consider buying OsmAnd+, or funding specific new features or making a general donation on https://osmand.net. - OsmAnd (OSM Automated Navigation Directions) is a map and navigation app with access to the free, worldwide, and high-quality OpenStreetMap (OSM) data. + OsmAnd (OSM Automated Navigation Directions) is a map and navigation app with access to the free, worldwide, and high-quality OpenStreetMap (OSM) data.\n\n Enjoy voice and optical navigator, viewing POIs (points of interest), creating and managing GPX tracks, using contour lines visualization and altitude info (through plugin), a choice between driving, cycling, pedestrian modes, OSM editing and much more. - GPS navigation - • You can choose between offline (no roaming charges when you are abroad) or online (faster) mode - • Turn-by-turn voice guidance leads you along the way (recorded and synthesized voices) - • The route gets rebuilt whenever you deviate from it - • Lane guidance, street names, and estimated time of arrival will help along the way - • To make your trip safer, day/night mode switches automatically - • You can choose to show speed limits, and get reminders if you exceed it - • Map zoom adjusts to your speed - • You can searches destinations by address, by type (e.g: parking, restaurant, hotel, gas station, museum), or by geographical coordinates - • Supports intermediate points on your itinerary - • You can record your own or upload a GPX track and follow it + GPS navigation\n + • You can choose between offline (no roaming charges when you are abroad) or online (faster) mode\n + • Turn-by-turn voice guidance leads you along the way (recorded and synthesized voices)\n + • The route gets rebuilt whenever you deviate from it\n + • Lane guidance, street names, and estimated time of arrival will help along the way\n + • To make your trip safer, day/night mode switches automatically\n + • You can choose to show speed limits, and get reminders if you exceed it\n + • Map zoom adjusts to your speed\n + • You can search for destinations by address, type (e.g: parking, restaurant, hotel, gas station, museum), or geographical coordinates\n + • Supports intermediate points on your itinerary\n + • You can record your own or upload a GPX track and follow it\n - Map - • Displays POIs (point of interests) around you - • Adjusts the map to your direction of motion (or compass) - • Shows where you are and where you are looking at - • Share your location so that your friends can find you - • Keeps your most important places in \'Favorites\' - • Allows you to choose how to display names on the map: In English, local, or phonetic spelling - • Displays specialized online tiles, satellite view (from Bing), different overlays like touring/navigation GPX tracks and additional layers with customizable transparency + Map\n + • Displays POIs (point of interests) around you\n + • Adjusts the map to your direction of motion (or compass)\n + • Shows where you are and where you are looking at\n + • Share your location so that your friends can find you\n + • Keeps your most important places in \'Favorites\'\n + • Allows you to choose how to display names on the map: In English, local, or phonetic spelling\n + • Displays specialized online tiles, satellite view (from Bing), different overlays like touring/navigation GPX tracks and additional layers with customizable transparency\n - Skiing + Skiing\n OsmAnd ski maps plugin enables you to see ski tracks with level of complexity and some additional information, like location of lifts and other facilities. - Cycling - • You can find cycling paths on the map - • GPS navigation in cycling mode builds your route using cycling paths - • You can see your speed and altitude - • GPX recording option enables you to record your trip and share it + Cycling\n + • You can find cycling paths on the map\n + • GPS navigation in cycling mode builds your route using cycling paths\n + • You can see your speed and altitude\n + • GPX recording option enables you to record your trip and share it\n • Via an additional plugin you can enable contour lines and hillshading - Walking, hiking, city tour - • The map shows you walking and hiking paths - • Wikipedia in your preferred language can tell you a lot during a city tour - • Public transport stops (bus, tram, train), including line names, help to navigate in a new city - • GPS navigation in pedestrian mode builds your route using walking paths - • You can upload and follow a GPX route or record and share your own + Walking, hiking, city tour\n + • The map shows you walking and hiking paths\n + • Wikipedia in your preferred language can tell you a lot during a city tour\n + • Public transport stops (bus, tram, train), including line names, help to navigate in a new city\n + • GPS navigation in pedestrian mode builds your route using walking paths\n + • You can upload and follow a GPX route or record and share your own\n - Contribute to OSM - • Report data bugs - • Upload GPX tracks to OSM directly from the app - • Add POIs and directly upload them to OSM (or later if offline) + Contribute to OSM\n + • Report data bugs\n + • Upload GPX tracks to OSM directly from the app\n + • Add POIs and directly upload them to OSM (or later if offline)\n - OsmAnd is open-source and actively being developed. Everyone can contribute to the app by reporting bugs, improving translations or coding new features. The project is in a lively state of continuous improvement by all these forms of developer and user interaction. The project progress also relies on financial contributions to fund coding and testing of new functionalities. - Approximate map coverage and quality: - • Western Europe: **** - • Eastern Europe: *** - • Russia: *** - • North America: *** - • South America: ** - • Asia: ** - • Japan & Korea: *** - • Middle East: ** - • Africa: ** - • Antarctica: * - Most countries around the globe are available for download! + OsmAnd is open-source and actively being developed. Everyone can contribute to the app by reporting bugs, improving translations or coding new features. The project is in a lively state of continuous improvement by all these forms of developer and user interaction. The project progress also relies on financial contributions to fund coding and testing of new functionalities.\n + Approximate map coverage and quality:\n + • Western Europe: ****\n + • Eastern Europe: ***\n + • Russia: ***\n + • North America: ***\n + • South America: **\n + • Asia: **\n + • Japan & Korea: ***\n + • Middle East: **\n + • Africa: **\n + • Antarctica: *\n + Most countries around the globe are available for download!\n Get a reliable navigator in your country - be it France, Germany, Mexico, UK, Spain, Netherlands, USA, Russia, Brazil or any other. OsmAnd+ Maps & Navigation Global Mobile Map Viewing & Navigation for Offline and Online OSM Maps - OsmAnd+ (OSM Automated Navigation Directions) + OsmAnd+ (OSM Automated Navigation Directions)\n\n - OsmAnd+ is an open source software navigation app with access to a wide variety of global OpenStreetMap (OSM) data. All map data (vector or tile maps) can be stored on the phone memory card for offline use. Offline and online routing functionality is also offered, including turn-by-turn voice guidance. + OsmAnd+ is an open source software navigation app with access to a wide variety of global OpenStreetMap (OSM) data. All map data (vector or tile maps) can be stored on the phone memory card for offline use. Offline and online routing functionality is also offered, including turn-by-turn voice guidance.\n\n - OsmAnd+ is the paid app version, by buying it you support the project, fund the development of new features, and receive the latest updates. + OsmAnd+ is the paid app version, by buying it you support the project, fund the development of new features, and receive the latest updates.\n\n - Some of the core features: - - Complete offline functionality (store downloaded vector or tile maps in the device storage) - - Compact offline vector maps for the whole world available - - Unlimited downloading of country or region maps directly from the app - - Offline Wikipedia feature (download Wikipedia POIs), great for sightseeing - - Overlay of several map layers possible, like GPX or navigation tracks, Points of Interest, favorites, contour lines, public transport stops, additional maps with customizable transparency - - Offline search for addresses and places (POIs) - - Offline routing for medium-range distances - - Car, bicycle, and pedestrian modes with optional: - - Automated day/night view switching - - Speed-dependent map zooming - - Map alignment according to compass or direction of motion - - Lane guidance, speed limit display, recorded and TTS voices + Some of the core features:\n + - Complete offline functionality (store downloaded vector or tile maps in the device storage)\n + - Compact offline vector maps for the whole world available\n + - Unlimited downloading of country or region maps directly from the app\n + - Offline Wikipedia feature (download Wikipedia POIs), great for sightseeing\n + - Overlay of several map layers possible, like GPX or navigation tracks, Points of Interest, favorites, contour lines, public transport stops, additional maps with customizable transparency\n\n + - Offline search for addresses and places (POIs)\n + - Offline routing for medium-range distances\n + - Car, bicycle, and pedestrian modes with optional:\n + - Automated day/night view switching\n + - Speed-dependent map zooming\n + - Map alignment according to compass or direction of motion\n + - Lane guidance, speed limit display, recorded and TTS voices\n - OsmAnd+ (OSM Automated Navigation Directions) is a map and navigation app with access to the free, worldwide, and high-quality OpenStreetMap (OSM) data. - Enjoy voice and optical navigation, viewing POIs (points of interest), creating and managing GPX tracks, using contour lines visualization and altitude info, a choice between driving, cycling, pedestrian modes, OSM editing and much more. + OsmAnd+ (OSM Automated Navigation Directions) is a map and navigation app with access to the free, worldwide, and high-quality OpenStreetMap (OSM) data.\n + Enjoy voice and optical navigation, viewing POIs (points of interest), creating and managing GPX tracks, using contour lines visualization and altitude info, a choice between driving, cycling, pedestrian modes, OSM editing and much more.\n\n - OsmAnd+ is the paid app version. By buying it, you support the project, fund the development of new features, and receive the latest updates. + OsmAnd+ is the paid app version. By buying it, you support the project, fund the development of new features, and receive the latest updates.\n\n Some of the main features: - Navigation - • Works online (fast) or offline (no roaming charges when you are abroad) - • Turn-by-turn voice guidance (recorded and synthesized voices) - • Optional lane guidance, street name display, and estimated time of arrival - • Supports intermediate points on your itinerary - • Automatic re-routing whenever you deviate from the route - • Search for places by address, by type (e.g: restaurant, hotel, gas station, museum), or by geographical coordinates + Navigation\n + • Works online (fast) or offline (no roaming charges when you are abroad)\n + • Turn-by-turn voice guidance (recorded and synthesized voices)\n + • Optional lane guidance, street name display, and estimated time of arrival\n + • Supports intermediate points on your itinerary\n + • Automatic re-routing whenever you deviate from the route\n + • Search for places by address, by type (e.g: restaurant, hotel, gas station, museum), or by geographical coordinates\n - Map Viewing - • Display your position and orientation - • Optionally align the picture according to compass or your direction of motion - • Save your most important places as Favorites - • Display POIs (point of interests) around you - • Display specialized online tiles, satellite view (from Bing), different overlays like touring/navigation GPX tracks and additional layers with customizable transparency - • Optionally display place names in English, local, or phonetic spelling + Map Viewing\n + • Display your position and orientation\n + • Optionally align the picture according to compass or your direction of motion\n + • Save your most important places as favorites\n + • Display POIs (point of interests) around you\n + • Display specialized online tiles, satellite view (from Bing), different overlays like touring/navigation GPX tracks and additional layers with customizable transparency\n + • Optionally display place names in English, local, or phonetic spelling\n - Use OSM and Wikipedia Data - • High-quality information from the best collaborative projects of the world - • OSM data available per country or region - • Wikipedia POIs, great for sightseeing - • Unlimited free downloads, directly from the app - • Compact offline vector maps updated at least once a month + Use OSM and Wikipedia Data\n + • High-quality information from the best collaborative projects of the world\n + • OSM data available per country or region\n + • Wikipedia POIs, great for sightseeing\n + • Unlimited free downloads, directly from the app\n + • Compact offline vector maps updated at least once a month\n\n • Selection between complete region data and just road network (Example: All of Japan is 700 MB or 200 MB for the road network part thereof) - Safety Features - • Optional automated day/night view switching - • Optional speed limit display, with reminder if you exceed it - • Optional speed-dependent zooming - • Share your location so that your friends can find you + Safety Features\n + • Optional automated day/night view switching\n + • Optional speed limit display, with reminder if you exceed it\n + • Optional speed-dependent zooming\n + • Share your location so that your friends can find you\n - Bicycle and Pedestrian Features - • Viewing foot, hiking, and bike paths, great for outdoor activities - • Special routing and display modes for bike and pedestrian - • Optional public transport stops (bus, tram, train) including line names - • Optional trip recording to local GPX file or online service - • Optional speed and altitude display + Bicycle and Pedestrian Features\n + • Viewing foot, hiking, and bike paths, great for outdoor activities\n + • Special routing and display modes for bike and pedestrian\n + • Optional public transport stops (bus, tram, train) including line names\n + • Optional trip recording to local GPX file or online service\n + • Optional speed and altitude display\n • Display of contour lines and hillshading (via additional plugin) - Directly Contribute to OSM - • Report data bugs - • Upload GPX tracks to OSM directly from the app - • Add POIs and directly upload them to OSM (or later if offline) - • Optional trip recording also in background mode (while device is in sleep mode) + Directly Contribute to OSM\n + • Report data bugs\n + • Upload GPX tracks to OSM directly from the app\n + • Add POIs and directly upload them to OSM (or later if offline)\n + • Optional trip recording also in background mode (while device is in sleep mode)\n OsmAnd is open-source software in active development. Everyone can contribute to the app by reporting bugs, improving translations or coding new features or user interaction. The project progress also relies on financial contributions for coding and testing new functionality. - Approximate map coverage and quality: - • Western Europe: **** - • Eastern Europe: *** - • Russia: *** - • North America: *** - • South America: ** - • Asia: ** - • Japan & Korea: *** - • Middle East: ** - • Africa: ** - • Antarctica: * - Most countries around the globe available as downloads! - From Afghanistan to Zimbabwe, from Australia to the USA. Argentina, Brazil, Canada, France, Germany, Mexico, UK, Spain, … + Approximate map coverage and quality:\n + • Western Europe: ****\n + • Eastern Europe: ***\n + • Russia: ***\n + • North America: ***\n + • South America: **\n + • Asia: **\n + • Japan & Korea: ***\n + • Middle East: **\n + • Africa: **\n + • Antarctica: *\n + Most countries around the globe available as downloads\n + From Afghanistan to Zimbabwe, from Australia to the USA. Argentina, Brazil, Canada, France, Germany, Mexico, UK, Spain, …\n Create POI filter Transport mode: From b88daa60acba33bd79dc732e6537ee037fd5d0d9 Mon Sep 17 00:00:00 2001 From: Chumva Date: Wed, 25 Apr 2018 14:43:52 +0300 Subject: [PATCH 02/17] add asynkTask for popular destinations --- .../wikivoyage/explore/ExploreRvAdapter.java | 1 + .../explore/ExploreTabFragment.java | 77 ++++++++++++++++--- .../travelcards/ArticleTravelCard.java | 7 ++ 3 files changed, 75 insertions(+), 10 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java index 16f41fb6e8..6392aa48c3 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java @@ -63,6 +63,7 @@ public class ExploreRvAdapter extends RecyclerView.Adapter items = new ArrayList<>(); final OsmandApplication app = getMyApplication(); final boolean nightMode = !getSettings().isLightContent(); - + startEditingTravelCard = new StartEditingTravelCard(app, nightMode); items.add(new OpenBetaTravelCard(app, nightMode, getFragmentManager())); - items.add(new StartEditingTravelCard(app, nightMode)); - addPopularDestinations(items, nightMode); + items.add(startEditingTravelCard); + addPopularDestinations(app, nightMode); return items; } - private void addPopularDestinations(@NonNull List items, boolean nightMode) { - OsmandApplication app = getMyApplication(); - List savedArticles = app.getTravelDbHelper().searchPopular(); - if (!savedArticles.isEmpty()) { - items.add(getString(R.string.popular_destinations)); - for (TravelArticle article : savedArticles) { - items.add(new ArticleTravelCard(app, nightMode, article, getFragmentManager())); + private void addPopularDestinations(OsmandApplication app, boolean nightMode) { + popularDestinationsSearchTask = new PopularDestinationsSearchTask(app.getTravelDbHelper(), getMyActivity(), adapter, nightMode, startEditingTravelCard); + popularDestinationsSearchTask.execute(); + } + + private static class PopularDestinationsSearchTask extends AsyncTask> { + + private TravelDbHelper travelDbHelper; + private WeakReference weakContext; + private WeakReference weakAdapter; + private WeakReference weakStartEditingTravelCard; + private boolean nightMode; + + PopularDestinationsSearchTask(TravelDbHelper travelDbHelper, + OsmandActionBarActivity context, ExploreRvAdapter adapter, boolean nightMode, StartEditingTravelCard startEditingTravelCard) { + this.travelDbHelper = travelDbHelper; + weakContext = new WeakReference<>(context); + weakAdapter = new WeakReference<>(adapter); + weakStartEditingTravelCard = new WeakReference<>(startEditingTravelCard); + this.nightMode = nightMode; + } + + @Override + protected List doInBackground(ExploreRvAdapter... exploreRvAdapters) { + List articles = travelDbHelper.searchPopular(); + List items = new ArrayList<>(); + if (!articles.isEmpty()) { + OsmandActionBarActivity activity = weakContext.get(); + if (activity != null) { + for (TravelArticle article : articles) { + items.add(new ArticleTravelCard(activity.getMyApplication(), nightMode, article, activity.getSupportFragmentManager())); + } + } } + return items; + } + + @Override + protected void onPostExecute(List items) { + OsmandActionBarActivity activity = weakContext.get(); + ExploreRvAdapter adapter = weakAdapter.get(); + + List adapterItems = adapter.getItems(); + StartEditingTravelCard startEditingTravelCard = weakStartEditingTravelCard.get(); + + adapterItems.remove(startEditingTravelCard); + adapterItems.add(activity.getResources().getString(R.string.popular_destinations)); + adapterItems.addAll(items); + adapterItems.add(startEditingTravelCard); + + adapter.notifyDataSetChanged(); + } + } + + @Override + public void onPause() { + super.onPause(); + if (popularDestinationsSearchTask != null && popularDestinationsSearchTask.getStatus() == AsyncTask.Status.RUNNING) { + popularDestinationsSearchTask.cancel(false); } } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/ArticleTravelCard.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/ArticleTravelCard.java index eb80af9b00..5c4649c0a5 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/ArticleTravelCard.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/ArticleTravelCard.java @@ -30,6 +30,7 @@ public class ArticleTravelCard extends BaseTravelCard { private TravelArticle article; private final Drawable readIcon; private FragmentManager fragmentManager; + private boolean isLastItem; public ArticleTravelCard(OsmandApplication app, boolean nightMode, TravelArticle article, FragmentManager fragmentManager) { super(app, nightMode); @@ -73,6 +74,8 @@ public class ArticleTravelCard extends BaseTravelCard { holder.itemView.setOnClickListener(readClickListener); holder.leftButton.setCompoundDrawablesWithIntrinsicBounds(readIcon, null, null, null); updateSaveButton(holder); + holder.divider.setVisibility(isLastItem ? View.GONE : View.VISIBLE); + holder.shadow.setVisibility(isLastItem ? View.VISIBLE : View.GONE); } } @@ -124,6 +127,10 @@ public class ArticleTravelCard extends BaseTravelCard { } } + public void setLastItem(boolean lastItem) { + isLastItem = lastItem; + } + @Override public int getCardType() { return TYPE; From db3955cd504df56b62edc657cebeb5d485170fd8 Mon Sep 17 00:00:00 2001 From: Chumva Date: Wed, 25 Apr 2018 15:16:58 +0300 Subject: [PATCH 03/17] fix article shadow --- .../plus/wikivoyage/explore/ExploreRvAdapter.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java index 6392aa48c3..5ce3eb023b 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java @@ -63,7 +63,7 @@ public class ExploreRvAdapter extends RecyclerView.Adapter 0; i--) { + Object o = items.get(i); + if (o instanceof ArticleTravelCard) { + return i; + } + } + return 0; + } + private Object getItem(int position) { return items.get(position); } From 607a32ad46f8a3d7bedce57f22ffb0ac2231861c Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Wed, 25 Apr 2018 18:46:36 +0300 Subject: [PATCH 04/17] Added choose plan dialog to configure map srtm/hillshade settings --- .../net/osmand/plus/inapp/InAppPurchaseHelper.java | 2 +- .../net/osmand/plus/srtmplugin/ContourLinesMenu.java | 6 ++++-- .../src/net/osmand/plus/srtmplugin/HillshadeMenu.java | 11 +++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/inapp/InAppPurchaseHelper.java b/OsmAnd/src/net/osmand/plus/inapp/InAppPurchaseHelper.java index d30665dfc7..1a74139640 100644 --- a/OsmAnd/src/net/osmand/plus/inapp/InAppPurchaseHelper.java +++ b/OsmAnd/src/net/osmand/plus/inapp/InAppPurchaseHelper.java @@ -252,7 +252,7 @@ public class InAppPurchaseHelper { } public boolean needRequestInventory() { - return !ctx.getSettings().BILLING_PURCHASE_TOKEN_SENT.get() + return (ctx.getSettings().LIVE_UPDATES_PURCHASED.get() && !ctx.getSettings().BILLING_PURCHASE_TOKEN_SENT.get()) || System.currentTimeMillis() - lastValidationCheckTime > PURCHASE_VALIDATION_PERIOD_MSEC; } diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java b/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java index f7e5099b9f..bcf8804b92 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/ContourLinesMenu.java @@ -1,6 +1,5 @@ package net.osmand.plus.srtmplugin; -import android.content.Intent; import android.view.View; import android.widget.ArrayAdapter; @@ -11,8 +10,8 @@ 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.PluginActivity; import net.osmand.plus.activities.SettingsActivity; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.download.DownloadIndexesThread; import net.osmand.plus.download.DownloadResources; @@ -135,9 +134,12 @@ public class ContourLinesMenu { } }); } else if (itemId == R.string.srtm_plugin_name) { + ChoosePlanDialogFragment.showHillshadeSrtmPluginInstance(mapActivity.getSupportFragmentManager()); + /* Intent intent = new Intent(mapActivity, PluginActivity.class); intent.putExtra(PluginActivity.EXTRA_PLUGIN_ID, plugin.getId()); mapActivity.startActivity(intent); + */ closeDashboard(mapActivity); } else if (contourWidthProp != null && itemId == contourWidthName.hashCode()) { plugin.selectPropertyValue(mapActivity, contourWidthProp, widthPref, new Runnable() { diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/HillshadeMenu.java b/OsmAnd/src/net/osmand/plus/srtmplugin/HillshadeMenu.java index 2a1979fefc..821def2866 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/HillshadeMenu.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/HillshadeMenu.java @@ -10,6 +10,7 @@ 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.chooseplan.ChoosePlanDialogFragment; import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.download.DownloadIndexesThread; import net.osmand.plus.download.DownloadResources; @@ -19,6 +20,8 @@ import net.osmand.plus.download.IndexItem; import java.io.IOException; import java.util.List; +import static net.osmand.plus.srtmplugin.ContourLinesMenu.closeDashboard; + public class HillshadeMenu { private static final String TAG = "HillshadeMenu"; @@ -71,6 +74,14 @@ public class HillshadeMenu { }); } }); + } else if (itemId == R.string.srtm_plugin_name) { + ChoosePlanDialogFragment.showHillshadeSrtmPluginInstance(mapActivity.getSupportFragmentManager()); + /* + Intent intent = new Intent(mapActivity, PluginActivity.class); + intent.putExtra(PluginActivity.EXTRA_PLUGIN_ID, plugin.getId()); + mapActivity.startActivity(intent); + */ + closeDashboard(mapActivity); } return false; } From ab9cb78c530214fbe4d4f43e64ec5c4ae2085f98 Mon Sep 17 00:00:00 2001 From: Chumva Date: Wed, 25 Apr 2018 18:48:41 +0300 Subject: [PATCH 05/17] refactor asynctask and add progressbar --- OsmAnd/res/layout/fragment_explore_tab.xml | 7 +++ .../plus/wikivoyage/data/TravelDbHelper.java | 9 +++- .../explore/ExploreTabFragment.java | 46 +++++++++++-------- 3 files changed, 42 insertions(+), 20 deletions(-) diff --git a/OsmAnd/res/layout/fragment_explore_tab.xml b/OsmAnd/res/layout/fragment_explore_tab.xml index 0d82ee83b9..97565b853f 100644 --- a/OsmAnd/res/layout/fragment_explore_tab.xml +++ b/OsmAnd/res/layout/fragment_explore_tab.xml @@ -6,6 +6,13 @@ android:gravity="center" android:orientation="vertical"> + + > { + private static class PopularDestinationsSearchTask extends AsyncTask> { private TravelDbHelper travelDbHelper; private WeakReference weakContext; private WeakReference weakAdapter; private WeakReference weakStartEditingTravelCard; private boolean nightMode; + private View progressBar; PopularDestinationsSearchTask(TravelDbHelper travelDbHelper, - OsmandActionBarActivity context, ExploreRvAdapter adapter, boolean nightMode, StartEditingTravelCard startEditingTravelCard) { + OsmandActionBarActivity context, ExploreRvAdapter adapter, boolean nightMode, StartEditingTravelCard startEditingTravelCard, View progressBar) { this.travelDbHelper = travelDbHelper; weakContext = new WeakReference<>(context); weakAdapter = new WeakReference<>(adapter); weakStartEditingTravelCard = new WeakReference<>(startEditingTravelCard); this.nightMode = nightMode; + this.progressBar = progressBar; } @Override - protected List doInBackground(ExploreRvAdapter... exploreRvAdapters) { - List articles = travelDbHelper.searchPopular(); - List items = new ArrayList<>(); - if (!articles.isEmpty()) { - OsmandActionBarActivity activity = weakContext.get(); - if (activity != null) { - for (TravelArticle article : articles) { - items.add(new ArticleTravelCard(activity.getMyApplication(), nightMode, article, activity.getSupportFragmentManager())); - } - } - } - return items; + protected void onPreExecute() { + super.onPreExecute(); + progressBar.setVisibility(View.VISIBLE); } @Override - protected void onPostExecute(List items) { + protected List doInBackground(ExploreRvAdapter... exploreRvAdapters) { + return travelDbHelper.searchPopular(); + } + + @Override + protected void onPostExecute(List items) { OsmandActionBarActivity activity = weakContext.get(); ExploreRvAdapter adapter = weakAdapter.get(); @@ -102,10 +103,17 @@ public class ExploreTabFragment extends BaseOsmAndFragment { StartEditingTravelCard startEditingTravelCard = weakStartEditingTravelCard.get(); adapterItems.remove(startEditingTravelCard); - adapterItems.add(activity.getResources().getString(R.string.popular_destinations)); - adapterItems.addAll(items); - adapterItems.add(startEditingTravelCard); + if (!items.isEmpty()) { + if (activity != null) { + adapterItems.add(activity.getResources().getString(R.string.popular_destinations)); + for (TravelArticle article : items) { + adapterItems.add(new ArticleTravelCard(activity.getMyApplication(), nightMode, article, activity.getSupportFragmentManager())); + } + } + } + progressBar.setVisibility(View.GONE); + adapterItems.add(startEditingTravelCard); adapter.notifyDataSetChanged(); } } From be9d2fdecd4b70f9294225815e528ff5bf454d50 Mon Sep 17 00:00:00 2001 From: Chumva Date: Wed, 25 Apr 2018 18:56:12 +0300 Subject: [PATCH 06/17] add weakProgressBar --- .../plus/wikivoyage/explore/ExploreTabFragment.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java index 2d17e768e6..8c95179b34 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java @@ -70,8 +70,8 @@ public class ExploreTabFragment extends BaseOsmAndFragment { private WeakReference weakContext; private WeakReference weakAdapter; private WeakReference weakStartEditingTravelCard; + private WeakReference weakProgressBar; private boolean nightMode; - private View progressBar; PopularDestinationsSearchTask(TravelDbHelper travelDbHelper, OsmandActionBarActivity context, ExploreRvAdapter adapter, boolean nightMode, StartEditingTravelCard startEditingTravelCard, View progressBar) { @@ -79,14 +79,14 @@ public class ExploreTabFragment extends BaseOsmAndFragment { weakContext = new WeakReference<>(context); weakAdapter = new WeakReference<>(adapter); weakStartEditingTravelCard = new WeakReference<>(startEditingTravelCard); + weakProgressBar = new WeakReference<>(progressBar); this.nightMode = nightMode; - this.progressBar = progressBar; } @Override protected void onPreExecute() { super.onPreExecute(); - progressBar.setVisibility(View.VISIBLE); + weakProgressBar.get().setVisibility(View.VISIBLE); } @Override @@ -112,7 +112,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment { } } } - progressBar.setVisibility(View.GONE); + weakProgressBar.get().setVisibility(View.GONE); adapterItems.add(startEditingTravelCard); adapter.notifyDataSetChanged(); } From e17cf751a765ef3c6048aa074bc457b8cb546117 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Wed, 25 Apr 2018 19:07:44 +0300 Subject: [PATCH 07/17] Refactor ExploreTabFragment --- .../explore/ExploreTabFragment.java | 70 +++++++------------ 1 file changed, 27 insertions(+), 43 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java index 4a24ed3eed..4be8b7a8c3 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java @@ -23,7 +23,6 @@ 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 java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; @@ -33,8 +32,6 @@ public class ExploreTabFragment extends BaseOsmAndFragment { private ExploreRvAdapter adapter = new ExploreRvAdapter(); - private AddDownloadUpdateCardTask addDownloadUpdateCardTask; - @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { @@ -49,19 +46,6 @@ public class ExploreTabFragment extends BaseOsmAndFragment { return mainView; } - @Override - public void onDestroyView() { - cancelAddDownloadUpdateCardTask(); - super.onDestroyView(); - } - - private void cancelAddDownloadUpdateCardTask() { - if (addDownloadUpdateCardTask != null) { - addDownloadUpdateCardTask.cancel(true); - addDownloadUpdateCardTask = null; - } - } - private List generateItems() { final List items = new ArrayList<>(); final OsmandApplication app = getMyApplication(); @@ -75,9 +59,19 @@ public class ExploreTabFragment extends BaseOsmAndFragment { return items; } - private void addDownloadUpdateCard(boolean nightMode) { - addDownloadUpdateCardTask = new AddDownloadUpdateCardTask(getMyApplication(), adapter, nightMode); - addDownloadUpdateCardTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + private void addDownloadUpdateCard(final boolean nightMode) { + final OsmandApplication app = getMyApplication(); + new CheckWorldWikivoyageTask(app, new CheckWorldWikivoyageTask.Callback() { + @Override + public void onCheckFinished(boolean worldWikivoyageDownloaded) { + if (!worldWikivoyageDownloaded && adapter != null) { + TravelDownloadUpdateCard card = new TravelDownloadUpdateCard(app, nightMode, true); + if (adapter.addItem(DOWNLOAD_UPDATE_CARD_POSITION, card)) { + adapter.notifyDataSetChanged(); + } + } + } + }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } private void addPopularDestinations(@NonNull List items, boolean nightMode) { @@ -91,23 +85,19 @@ public class ExploreTabFragment extends BaseOsmAndFragment { } } - private static class AddDownloadUpdateCardTask extends AsyncTask { + private static class CheckWorldWikivoyageTask extends AsyncTask { private OsmandApplication app; - private WeakReference adapterWr; + private Callback callback; - private boolean nightMode; - - AddDownloadUpdateCardTask(OsmandApplication app, ExploreRvAdapter adapter, boolean nightMode) { + CheckWorldWikivoyageTask(OsmandApplication app, Callback callback) { this.app = app; - this.adapterWr = new WeakReference<>(adapter); - this.nightMode = nightMode; + this.callback = callback; } @Override - protected TravelDownloadUpdateCard doInBackground(Void... voids) { + protected Boolean doInBackground(Void... voids) { final boolean[] worldWikivoyageDownloaded = new boolean[1]; - new LocalIndexHelper(app).getLocalTravelFiles(new AbstractLoadLocalIndexTask() { @Override public void loadFile(LocalIndexInfo... loaded) { @@ -118,25 +108,19 @@ public class ExploreTabFragment extends BaseOsmAndFragment { } } }); - - if (!worldWikivoyageDownloaded[0] && !isCancelled()) { - TravelDownloadUpdateCard card = new TravelDownloadUpdateCard(app, nightMode, true); - return card; - } - - return null; + return worldWikivoyageDownloaded[0]; } @Override - protected void onPostExecute(TravelDownloadUpdateCard card) { - if (!isCancelled() && card != null) { - ExploreRvAdapter adapter = adapterWr.get(); - if (adapter != null) { - if (adapter.addItem(DOWNLOAD_UPDATE_CARD_POSITION, card)) { - adapter.notifyItemInserted(DOWNLOAD_UPDATE_CARD_POSITION); - } - } + protected void onPostExecute(Boolean worldWikivoyageDownloaded) { + if (callback != null) { + callback.onCheckFinished(worldWikivoyageDownloaded); } + callback = null; + } + + interface Callback { + void onCheckFinished(boolean worldWikivoyageDownloaded); } } } From bdd3d42c74afebf8948e1eb7be4461fe0ca13b85 Mon Sep 17 00:00:00 2001 From: Chumva Date: Wed, 25 Apr 2018 19:10:23 +0300 Subject: [PATCH 08/17] fix doInBackground --- .../plus/wikivoyage/explore/ExploreTabFragment.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java index 8c95179b34..783bd8e215 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java @@ -64,7 +64,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment { popularDestinationsSearchTask.execute(); } - private static class PopularDestinationsSearchTask extends AsyncTask> { + private static class PopularDestinationsSearchTask extends AsyncTask> { private TravelDbHelper travelDbHelper; private WeakReference weakContext; @@ -84,14 +84,14 @@ public class ExploreTabFragment extends BaseOsmAndFragment { } @Override - protected void onPreExecute() { - super.onPreExecute(); - weakProgressBar.get().setVisibility(View.VISIBLE); + protected List doInBackground(Void... voids) { + return travelDbHelper.searchPopular(); } @Override - protected List doInBackground(ExploreRvAdapter... exploreRvAdapters) { - return travelDbHelper.searchPopular(); + protected void onPreExecute() { + super.onPreExecute(); + weakProgressBar.get().setVisibility(View.VISIBLE); } @Override From 16378b7e763cc9b33d03fa1de7ca908445a0495d Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Wed, 25 Apr 2018 19:29:39 +0300 Subject: [PATCH 09/17] Added images for purchased features --- OsmAnd/res/drawable/img_feature_purchased.xml | 19 +++++++++++++++ .../res/layout/purchase_dialog_card_row.xml | 10 ++++++++ .../purchase_dialog_card_selected_row.xml | 10 ++++++++ OsmAnd/res/values/colors.xml | 3 ++- .../chooseplan/ChoosePlanDialogFragment.java | 23 +++++++++++++++++-- 5 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 OsmAnd/res/drawable/img_feature_purchased.xml diff --git a/OsmAnd/res/drawable/img_feature_purchased.xml b/OsmAnd/res/drawable/img_feature_purchased.xml new file mode 100644 index 0000000000..e82f078224 --- /dev/null +++ b/OsmAnd/res/drawable/img_feature_purchased.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/purchase_dialog_card_row.xml b/OsmAnd/res/layout/purchase_dialog_card_row.xml index e389577a71..b58b2afc25 100644 --- a/OsmAnd/res/layout/purchase_dialog_card_row.xml +++ b/OsmAnd/res/layout/purchase_dialog_card_row.xml @@ -23,6 +23,16 @@ android:src="@drawable/ic_action_plus" android:tint="?attr/wikivoyage_active_color"/> + + + + + #78cc5c + #212121 #cccccc #212121 @@ -11,7 +13,6 @@ #b3b3b3 #4d4d4d - #bfbfbf #c5d2e6 #3db878 diff --git a/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java index baa2a32d15..a55cfd1502 100644 --- a/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java @@ -83,11 +83,12 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment case UNLOCK_ALL_FEATURES: case DONATION_TO_OSM: return false; + case SEA_DEPTH_MAPS: + return ctx.getSettings().DEPTH_CONTOURS_PURCHASED.get(); case WIKIVOYAGE_OFFLINE: return ctx.getSettings().TRAVEL_ARTICLES_PURCHASED.get(); case CONTOUR_LINES_HILLSHADE_MAPS: - boolean srtmEnabled = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null; - return srtmEnabled && ctx.getSettings().DEPTH_CONTOURS_PURCHASED.get(); + return OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null; } return false; } @@ -234,6 +235,15 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment String featureName = feature.toHumanString(ctx); View featureRow = inflate(hasSelectedOsmLiveFeature(feature) ? R.layout.purchase_dialog_card_selected_row : R.layout.purchase_dialog_card_row, cardView); + AppCompatImageView imgView = (AppCompatImageView) featureRow.findViewById(R.id.img); + AppCompatImageView imgPurchasedView = (AppCompatImageView) featureRow.findViewById(R.id.img_purchased); + if (feature.isFeaturePurchased(app)) { + imgView.setVisibility(View.GONE); + imgPurchasedView.setVisibility(View.VISIBLE); + } else { + imgView.setVisibility(View.VISIBLE); + imgPurchasedView.setVisibility(View.GONE); + } TextViewEx titleView = (TextViewEx) featureRow.findViewById(R.id.title); titleView.setText(featureName); featureRowDiv = featureRow.findViewById(R.id.div); @@ -325,6 +335,15 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment String featureName = feature.toHumanString(ctx); featureRow = inflate(hasSelectedPlanTypeFeature(feature) ? R.layout.purchase_dialog_card_selected_row : R.layout.purchase_dialog_card_row, cardView); + AppCompatImageView imgView = (AppCompatImageView) featureRow.findViewById(R.id.img); + AppCompatImageView imgPurchasedView = (AppCompatImageView) featureRow.findViewById(R.id.img_purchased); + if (feature.isFeaturePurchased(app)) { + imgView.setVisibility(View.GONE); + imgPurchasedView.setVisibility(View.VISIBLE); + } else { + imgView.setVisibility(View.VISIBLE); + imgPurchasedView.setVisibility(View.GONE); + } TextViewEx titleView = (TextViewEx) featureRow.findViewById(R.id.title); titleView.setText(featureName); rowsContainer.addView(featureRow); From 162a692c407f781a77dac87671def53251ca99af Mon Sep 17 00:00:00 2001 From: Chumva Date: Wed, 25 Apr 2018 19:41:54 +0300 Subject: [PATCH 10/17] fix conflicts --- .../wikivoyage/explore/ExploreRvAdapter.java | 14 ++++ .../explore/ExploreTabFragment.java | 81 ++++++++++++++++--- 2 files changed, 83 insertions(+), 12 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java index 02a50602cb..5bed8a0d98 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java @@ -68,6 +68,10 @@ public class ExploreRvAdapter extends RecyclerView.Adapter 0; i--) { + Object o = items.get(i); + if (o instanceof ArticleTravelCard) { + return i; + } + } + return 0; + } + private Object getItem(int position) { return items.get(position); } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java index 4be8b7a8c3..7df07075b9 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java @@ -9,20 +9,24 @@ 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.activities.LocalIndexHelper; import net.osmand.plus.activities.LocalIndexInfo; +import net.osmand.plus.activities.OsmandActionBarActivity; import net.osmand.plus.base.BaseOsmAndFragment; import net.osmand.plus.download.DownloadResources; import net.osmand.plus.download.ui.AbstractLoadLocalIndexTask; import net.osmand.plus.wikivoyage.data.TravelArticle; +import net.osmand.plus.wikivoyage.data.TravelDbHelper; import net.osmand.plus.wikivoyage.explore.travelcards.ArticleTravelCard; 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 java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; @@ -31,6 +35,9 @@ public class ExploreTabFragment extends BaseOsmAndFragment { private static final int DOWNLOAD_UPDATE_CARD_POSITION = 0; private ExploreRvAdapter adapter = new ExploreRvAdapter(); + private PopularDestinationsSearchTask popularDestinationsSearchTask; + private StartEditingTravelCard startEditingTravelCard; + private ProgressBar progressBar; @Nullable @Override @@ -40,6 +47,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment { adapter.setItems(generateItems()); final RecyclerView rv = (RecyclerView) mainView.findViewById(R.id.recycler_view); + progressBar = (ProgressBar) mainView.findViewById(R.id.progressBar); rv.setLayoutManager(new LinearLayoutManager(getContext())); rv.setAdapter(adapter); @@ -52,9 +60,10 @@ public class ExploreTabFragment extends BaseOsmAndFragment { final boolean nightMode = !getSettings().isLightContent(); addDownloadUpdateCard(nightMode); + startEditingTravelCard = new StartEditingTravelCard(app, nightMode); items.add(new OpenBetaTravelCard(app, nightMode, getFragmentManager())); - items.add(new StartEditingTravelCard(app, nightMode)); - addPopularDestinations(items, nightMode); + items.add(startEditingTravelCard); + addPopularDestinations(app, nightMode); return items; } @@ -74,15 +83,9 @@ public class ExploreTabFragment extends BaseOsmAndFragment { }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } - private void addPopularDestinations(@NonNull List items, boolean nightMode) { - OsmandApplication app = getMyApplication(); - List savedArticles = app.getTravelDbHelper().searchPopular(); - if (!savedArticles.isEmpty()) { - items.add(getString(R.string.popular_destinations)); - for (TravelArticle article : savedArticles) { - items.add(new ArticleTravelCard(app, nightMode, article, getFragmentManager())); - } - } + private void addPopularDestinations(OsmandApplication app, boolean nightMode) { + popularDestinationsSearchTask = new PopularDestinationsSearchTask(app.getTravelDbHelper(), getMyActivity(), adapter, nightMode, startEditingTravelCard, progressBar); + popularDestinationsSearchTask.execute(); } private static class CheckWorldWikivoyageTask extends AsyncTask { @@ -123,4 +126,58 @@ public class ExploreTabFragment extends BaseOsmAndFragment { void onCheckFinished(boolean worldWikivoyageDownloaded); } } -} + + private static class PopularDestinationsSearchTask extends AsyncTask> { + + private TravelDbHelper travelDbHelper; + private WeakReference weakContext; + private WeakReference weakAdapter; + private WeakReference weakStartEditingTravelCard; + private WeakReference weakProgressBar; + private boolean nightMode; + + PopularDestinationsSearchTask(TravelDbHelper travelDbHelper, + OsmandActionBarActivity context, ExploreRvAdapter adapter, boolean nightMode, StartEditingTravelCard startEditingTravelCard, View progressBar) { + this.travelDbHelper = travelDbHelper; + weakContext = new WeakReference<>(context); + weakAdapter = new WeakReference<>(adapter); + weakStartEditingTravelCard = new WeakReference<>(startEditingTravelCard); + weakProgressBar = new WeakReference<>(progressBar); + this.nightMode = nightMode; + } + + @Override + protected List doInBackground(Void... voids) { + return travelDbHelper.searchPopular(); + } + + @Override + protected void onPreExecute() { + super.onPreExecute(); + weakProgressBar.get().setVisibility(View.VISIBLE); + } + + @Override + protected void onPostExecute(List items) { + OsmandActionBarActivity activity = weakContext.get(); + ExploreRvAdapter adapter = weakAdapter.get(); + + List adapterItems = adapter.getItems(); + StartEditingTravelCard startEditingTravelCard = weakStartEditingTravelCard.get(); + + adapterItems.remove(startEditingTravelCard); + + if (!items.isEmpty()) { + if (activity != null) { + adapterItems.add(activity.getResources().getString(R.string.popular_destinations)); + for (TravelArticle article : items) { + adapterItems.add(new ArticleTravelCard(activity.getMyApplication(), nightMode, article, activity.getSupportFragmentManager())); + } + } + } + weakProgressBar.get().setVisibility(View.GONE); + adapterItems.add(startEditingTravelCard); + adapter.notifyDataSetChanged(); + } + } +} \ No newline at end of file From 168b90a01fd0d8c2d9218431a9f3628b622336a3 Mon Sep 17 00:00:00 2001 From: Chumva Date: Wed, 25 Apr 2018 19:53:25 +0300 Subject: [PATCH 11/17] fix npe --- .../osmand/plus/wikivoyage/explore/ExploreTabFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java index 7df07075b9..beb27539ee 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java @@ -43,11 +43,11 @@ public class ExploreTabFragment extends BaseOsmAndFragment { @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { final View mainView = inflater.inflate(R.layout.fragment_explore_tab, container, false); + progressBar = (ProgressBar) mainView.findViewById(R.id.progressBar); + final RecyclerView rv = (RecyclerView) mainView.findViewById(R.id.recycler_view); adapter.setItems(generateItems()); - final RecyclerView rv = (RecyclerView) mainView.findViewById(R.id.recycler_view); - progressBar = (ProgressBar) mainView.findViewById(R.id.progressBar); rv.setLayoutManager(new LinearLayoutManager(getContext())); rv.setAdapter(adapter); From bfefdecaf8110c209d670198efc5e7e8d1078920 Mon Sep 17 00:00:00 2001 From: Chumva Date: Wed, 25 Apr 2018 19:55:53 +0300 Subject: [PATCH 12/17] change sql query --- OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java index 61bd62a1e2..1b4ef91f95 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java @@ -210,7 +210,7 @@ public class TravelDbHelper { TravelArticle travelArticle; SQLiteCursor cursor = conn.rawQuery("SELECT * FROM " + ARTICLES_TABLE_NAME - + " WHERE title IN (SELECT title FROM " + + " WHERE article_id IN (SELECT article_id FROM " + ARTICLES_TABLE_NAME + " ORDER BY RANDOM() LIMIT 100) LIMIT 100", null); if (cursor.moveToFirst()) { From d77a7536a3743c3e9f74bae559429844e781f55c Mon Sep 17 00:00:00 2001 From: Chumva Date: Wed, 25 Apr 2018 20:00:08 +0300 Subject: [PATCH 13/17] removed variable --- .../net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java index beb27539ee..a62172d333 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java @@ -35,7 +35,6 @@ public class ExploreTabFragment extends BaseOsmAndFragment { private static final int DOWNLOAD_UPDATE_CARD_POSITION = 0; private ExploreRvAdapter adapter = new ExploreRvAdapter(); - private PopularDestinationsSearchTask popularDestinationsSearchTask; private StartEditingTravelCard startEditingTravelCard; private ProgressBar progressBar; @@ -84,7 +83,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment { } private void addPopularDestinations(OsmandApplication app, boolean nightMode) { - popularDestinationsSearchTask = new PopularDestinationsSearchTask(app.getTravelDbHelper(), getMyActivity(), adapter, nightMode, startEditingTravelCard, progressBar); + PopularDestinationsSearchTask popularDestinationsSearchTask = new PopularDestinationsSearchTask(app.getTravelDbHelper(), getMyActivity(), adapter, nightMode, startEditingTravelCard, progressBar); popularDestinationsSearchTask.execute(); } From 2d533853376da201128d2d6acdcf87567491785e Mon Sep 17 00:00:00 2001 From: xmd5a Date: Wed, 25 Apr 2018 21:05:47 +0300 Subject: [PATCH 14/17] Add phrases --- OsmAnd/res/values-ru/phrases.xml | 13 +++++++++++++ OsmAnd/res/values/phrases.xml | 15 +++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/OsmAnd/res/values-ru/phrases.xml b/OsmAnd/res/values-ru/phrases.xml index e11e171e92..1a6bc3cf32 100644 --- a/OsmAnd/res/values-ru/phrases.xml +++ b/OsmAnd/res/values-ru/phrases.xml @@ -3783,4 +3783,17 @@ Количество тросов Сложность + Тип ледника + + Ледниковый покров + Ледниковое поле + Плато + Долинный ледник + Горный + Висячий + Rock + Шельфовый + Останец + Ледяной язык + diff --git a/OsmAnd/res/values/phrases.xml b/OsmAnd/res/values/phrases.xml index 4bf23631a5..4e131b3e3e 100644 --- a/OsmAnd/res/values/phrases.xml +++ b/OsmAnd/res/values/phrases.xml @@ -105,6 +105,7 @@ CEE blue output Schuko output Car service + Glacier type Store @@ -3803,4 +3804,18 @@ Cable number Difficulty + Icecap + Icefield + Plateau + Valley + Outlet + Tidewater + Mountain + Hanging + Icefall + Rock + Shelf + Remnant + Ice tongue + From 98e309022e173f300adf5d70e740fc3097568fd9 Mon Sep 17 00:00:00 2001 From: xmd5a Date: Wed, 25 Apr 2018 22:51:45 +0300 Subject: [PATCH 15/17] Add phrases --- OsmAnd/res/values-ru/phrases.xml | 4 ++++ OsmAnd/res/values/phrases.xml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/OsmAnd/res/values-ru/phrases.xml b/OsmAnd/res/values-ru/phrases.xml index 1a6bc3cf32..31a9cce1f0 100644 --- a/OsmAnd/res/values-ru/phrases.xml +++ b/OsmAnd/res/values-ru/phrases.xml @@ -3796,4 +3796,8 @@ Останец Ледяной язык + Высшая точка + Низшая точка + Средний уклон + diff --git a/OsmAnd/res/values/phrases.xml b/OsmAnd/res/values/phrases.xml index 4e131b3e3e..58580b534f 100644 --- a/OsmAnd/res/values/phrases.xml +++ b/OsmAnd/res/values/phrases.xml @@ -3818,4 +3818,8 @@ Remnant Ice tongue + Highest point + Lowest point + Average slope + From be1b21ba4f76af244329811111b3baadc37f7ab0 Mon Sep 17 00:00:00 2001 From: vshcherb Date: Wed, 25 Apr 2018 23:48:55 +0200 Subject: [PATCH 16/17] Update LICENSE --- LICENSE | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/LICENSE b/LICENSE index f92e0c13e5..30c2895d1f 100644 --- a/LICENSE +++ b/LICENSE @@ -2,7 +2,7 @@ OsmAnd – OSM Automated Navigation Directions – navigation software based on OpenStreetMap. Copyright © 2010–2017 OsmAnd BV (Amstelveen, Netherlands - KvK 62066714, BTW 854627704B01). - The code in that repository is mainly covered by *GPLv3* (for code) and *CC-BY-ND-NC* (for artwork with restriction), except some 3rd party libs and resources. + The code in that repository is mainly covered by *GPLv3* (for code) and [ CC-BY-NC-ND 4.0 ](https://creativecommons.org/licenses/by-nc-nd/4.0/) (for artwork with restriction), except some 3rd party libs and resources. ATTENTION: please be aware that some artwork has proprietary license. Main AUTHORS (more detailed list in AUTHORS): @@ -36,9 +36,9 @@ - https://github.com/osmandapp/OsmAnd-tools - https://github.com/osmandapp/OsmAnd-resources - * UI Design and UX work, such as layout, icons is covered by CC-BY-ND-NC + * UI Design and UX work, such as layout, icons is covered by CC-BY-NC-ND - https://github.com/osmandapp/Osmand/tree/master/OsmAnd/res and others - Restriction to UI/UX CC-BY-ND-NC: + Restriction to UI/UX CC-BY-NC-ND: * Publishing applications using the OsmAnd UI/UX code to Google Play, Amazon Market or Apple Store must be done with written permission* @@ -167,4 +167,4 @@ - Mobile_DEM_1255: Amante, C.J., M.R. Love, L.A. Taylor, and B.W. Eakins, 2011. Digital Elevation Models of Mobile, Alabama: Procedures, Data Sources and Analysis, NOAA Technical Memorandum NESDIS NGDC-44, Dept. of Commerce, Boulder, CO, 43 pp. - Panama_City_DEM_1276: Amante, C.J., M.R. Love, L.A. Taylor, and B.W. Eakins, 2011. Digital Elevation Models of Panama City, Florida: Procedures, Data Sources and Analysis, NOAA Technical Memorandum NESDIS NGDC-50, U.S. Dept. of Commerce, Boulder, CO, 46 pp. - Great Lakes: National Centers for Environmental Information (NCEI) - \ No newline at end of file + From d553e2ae722e72400caba09e39f5bc21c8dc1176 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 26 Apr 2018 00:24:12 +0200 Subject: [PATCH 17/17] Update opening hours (fix osm) --- .../src/net/osmand/util/OpeningHoursParser.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/util/OpeningHoursParser.java b/OsmAnd-java/src/net/osmand/util/OpeningHoursParser.java index 908a154565..b51ce15682 100644 --- a/OsmAnd-java/src/net/osmand/util/OpeningHoursParser.java +++ b/OsmAnd-java/src/net/osmand/util/OpeningHoursParser.java @@ -38,11 +38,11 @@ public class OpeningHoursParser { static { DateFormatSymbols dateFormatSymbols = DateFormatSymbols.getInstance(Locale.US); monthsStr = dateFormatSymbols.getShortMonths(); - daysStr = getTwoLettersStringArray(dateFormatSymbols.getShortWeekdays()); + daysStr = getLettersStringArray(dateFormatSymbols.getShortWeekdays(), 2); dateFormatSymbols = DateFormatSymbols.getInstance(); localMothsStr = dateFormatSymbols.getShortMonths(); - localDaysStr = getTwoLettersStringArray(dateFormatSymbols.getShortWeekdays()); + localDaysStr = getLettersStringArray(dateFormatSymbols.getShortWeekdays(), 3); additionalStrings.put("off", "off"); additionalStrings.put("is_open", "Open"); @@ -75,12 +75,12 @@ public class OpeningHoursParser { */ private static String endOfDay = "24:00"; - private static String[] getTwoLettersStringArray(String[] strings) { + private static String[] getLettersStringArray(String[] strings, int letters) { String[] newStrings = new String[strings.length]; for (int i = 0; i < strings.length; i++) { if (strings[i] != null) { - if (strings[i].length() > 3) { - newStrings[i] = Algorithms.capitalizeFirstLetter(strings[i].substring(0, 3)); + if (strings[i].length() > letters) { + newStrings[i] = Algorithms.capitalizeFirstLetter(strings[i].substring(0, letters)); } else { newStrings[i] = Algorithms.capitalizeFirstLetter(strings[i]); }