From d6902df052665dbeb558e82536ea1180e0fa48ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Allan=20Nordh=C3=B8y?= Date: Sun, 29 Apr 2018 09:12:07 +0200 Subject: [PATCH 01/20] Language rework 3 --- OsmAnd/res/values/strings.xml | 239 +++++++++++++++++----------------- 1 file changed, 119 insertions(+), 120 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 109049064c..30a91915c2 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -13,18 +13,18 @@ Popular destinations Paid app Paid plugin - We prepared updates and fixes in the Wikivoyage data, update the file to see them. - Download this Wikivoyage travel guides file to view articles about places around the world without an internet connection. - Update is available + New Wikivoyage data available, update it to enjoy. + Download these Wikivoyage travel guides to view articles about places around the world without a connection to the Internet. + Update available Download file - The free worldwide travel guide that anyone can edit. - Travel is based on Wikivoyage. During open beta testing you have the opportunity to evaluate all the features for free. After the end of the beta period, Travel will be available to subscribers of OsmAnd Unlimited and the owners of OsmAnd+ - You can edit any article on Wikivoyage, and we hope that you do. We need your knowledge, your experience, your talent, and your attention + The libre worldwide travel guide anyone can edit. + Travel is based on Wikivoyage. Test all features during open beta testing, for free. Afterwards, Travel will be available to subscribers of OsmAnd Unlimited and owners of OsmAnd+ + You can and should edit any article on Wikivoyage. Share knowledge, experience, talent, and your attention Start editing Get unlimited access - Welcome, to the open beta! - Travel Guide - Browse the Wikivoyage guides to the most interesting places on the planet inside OsmAnd without an internet connection. + Welcome to the open beta + Wikivoyage Travel Guide + Guides to the most interesting places on the planet, inside OsmAnd, without a connection to the Internet. Map updates: Every month Map updates: Every hour In-app purchase @@ -69,7 +69,7 @@ Travel Waypoints removed from map markers Could not find anything: - You can add all of the track\'s waypoints, or select separate categories. + Add all of the track\'s waypoints, or select separate categories. Total Clear all intermediate points Group deleted @@ -154,12 +154,12 @@ Track waypoints Favorites category Add a group - You can import groups from favorites or track waypoints. + Import groups from favorites or track waypoints. Create map markers! Long or short tap \'Places\', then tap the marker flag button. Import groups - You can import favorite groups or track waypoints as markers. - @string/shared_string_history + Import favorite groups or track waypoints as markers. + @string/shared_string_history Markers marked as passed will appear on this screen. Two One @@ -194,7 +194,7 @@ Route calculated Round trip You must add at least one marker to use this function. - Exception occurred: The note was not modified + Could not modify note Modify note Modify OSM note Add copy of starting point as destination. @@ -260,7 +260,7 @@ Add point after Options OsmAnd will connect the points with routes for the selected profile. - You can save the points either as route points or as a line. + Save the points either as route points or as a line. Select navigation profile Please add at least one point. GPX file name: @@ -286,7 +286,7 @@ Type username View only images added by Username - You can filter images by submitter or by date. Filters only apply for closeup zoom. + Filter images by submitter or by date. Only active in closeup zoom. Radius ruler Permissions OsmAnd cannot import the file. Please check if OsmAnd has permission to read file from its location. @@ -372,7 +372,7 @@ Automatic Don\'t send anonymous app usage statistics OsmAnd collects info about which parts of the app you open. Your location is never sent, nor is anything you enter into the app or details of areas you view, search, or download. - Don\'t show messages at startup + Don\'t show startup messages Don\'t show app discounts & special local event messages. Parking options Thank you for purchasing the paid version of OsmAnd. @@ -385,8 +385,8 @@ Preferred terrain: Flat or hilly. Slope Add new folder - Point(s) deleted. - You are going to delete %1$d point(s). Are you sure? + Points deleted. + You are going to delete %1$d points. Are you sure? Turns to pass on this route Prominent points on this route Track @@ -467,7 +467,7 @@ Add the legacy search to the drawer list. Allow motorways Allow motorways. - You can upload your OSM Note anonymously or by using your OpenStreetMap.org profile. + Upload your OSM Note anonymously or by using your OpenStreetMap.org profile. Nearby Wikipedia articles Search city or region Take %1$d exit and go @@ -497,11 +497,11 @@ and more… Contour lines color scheme - Logging minimum speed + Logging min speed Filter: No logging of points below this speed. - Logging minimum displacement - Filter: Set minimum distance a point to log a new one. - Logging minimum accuracy + Logging min displacement + Filter: Set min distance from a point to log a new one. + Logging min accuracy Filter: No logging unless this accuracy is reached. Christmas POI Anticipating Christmas and New Year holidays, you can choose to display the POI associated with Christmas: Christmas trees, markets, etc. @@ -719,7 +719,7 @@ Data not available Remove Read more - "You can remove downloaded updates and get back to the original map edition" + "Remove downloaded updates and get back to the original map edition" Add time span Road blocked Select @@ -792,13 +792,13 @@ Reopen note Close note Note created - Exception occurred: Note was not created + Could not create note Note closed - Exception occurred: Note not closed + Could not close note OSM password (optional) Message Author name - Exception occurred: Comment not added + Could not add comment Comment added Commit Delete GPX waypoint? @@ -818,7 +818,7 @@ World basemap (covering the whole world at low zoom level) missing or outdated. Please consider downloading it for a global overview. QR code Map downloaded - You can now use the downloaded %1$s map. + The %1$s map is ready for use. Show map "Sets the flag indicating first app startup, keeps all other settings unchanged." Simulate first app start @@ -1049,7 +1049,7 @@ More… More actions Do not show again - Remember my choice + Remember choice Refresh Download Downloading @@ -1100,7 +1100,7 @@ Touring map view Activating this view changes OsmAnd\'s map style to \'Touring view\', this is a special high-detail view for travelers and professional drivers. - \n\nThis view provides, at any given map zoom, the maximum amount of travel details available in the map data (particularly roads, tracks, paths, and orientation marks). + \n\nThis view provides, at any given map zoom, the max amount of travel details available in the map data (particularly roads, tracks, paths, and orientation marks). \n\nIt also clearly depicts all types of roads unambiguously by color coding, which is useful when e.g. driving large vehicles. \n\nAnd it provides special touring options like showing bicycle routes or Alpine mountain routes. \n\nA special map download is not needed, the view is created from our standard maps. @@ -1145,7 +1145,6 @@ In order to display nautical maps, the special offline map needs to be downloaded Edit group Parking spot - REMOVE THE TAG GPS status Download nightly builds. Builds @@ -1155,7 +1154,7 @@ Privacy Points Start navigation along track? - You can trigger an alternative route by selecting roads to avoid + Trigger an alternative route by selecting roads to avoid Pedestrian crosswalks Road style Road style @@ -1340,7 +1339,7 @@ Start time: %1$tF, %1$tT End time: %1$tF, %1$tT Average speed: %1$s - Maximum speed: %1$s + Max speed: %1$s Average altitude: %1$s Altitude range: %1$s Descent/ascent: %1$s @@ -1407,7 +1406,7 @@ Latvian Lithuanian Marathi - Norwegian + Norwegian Bokmål Persian Polish Portuguese @@ -1439,21 +1438,21 @@ Route preferences Route info Prefer motorways - Prefer motorways. + Prefer motorways Avoid toll roads - Avoid toll roads. + Avoid toll roads Avoid unpaved roads Avoid unpaved roads. Avoid ferries - Avoid ferries. + Avoid ferries Avoid motorways - Avoid motorways. + Avoid motorways Avoid stairs - Avoid stairs. + Avoid stairs Avoid border crossing - Avoid crossing a border into another country. + Avoid crossing national borders Weight limit - Specify vehicle weight to be permitted on routes. + Specify permitted vehicle weight limit on routes. Height limit Specify vehicle height to be permitted on routes. Since Android version 4.4 (KitKat) you cannot download and update maps to the old storage folder (%s). Copy all OsmAnd files to new storage location? @@ -1481,7 +1480,7 @@ Aircraft You are going to delete %1$d OSM changes. Are you sure? Please calculate the route first - Simulate using calculated route + Simulate using calculated route Simulate using GPX track Please add intermediate destinations if no path is found for this long route within 10 mins. No auto zoom @@ -1496,8 +1495,8 @@ Zooms downloaded: %1$s Expire (minutes): %1$s Downloadable: %1$s - Maximum zoom: %1$s - Minimum zoom: %1$s + Max zoom: %1$s + Min zoom: %1$s Tile data: %1$s Tilesource %1$s was saved Elliptic mercator @@ -1545,8 +1544,8 @@ Optimized order of intermediate destinations en-route to the destination. Sort door-to-door OSM change file was generated %1$s - Backup OSM changes failed - Backup as OSM change + Could not back up OSM changes + Back up as OSM change Delete Point time accuracy @@ -1563,7 +1562,7 @@ Finish editing Begin a new subtrack Clear all points - Open existing GPX + Open existing GPX track Please wait until current task is finished Reduces noise in compass readings but adds inertia. Use Kalman filter @@ -1579,9 +1578,9 @@ Not connected to Wi-Fi. Use current connection to the Internet to download? Street name House number - Web site + Website Phone - Shows settings for turning on tracking and navigation in background mode by periodically waking up the GPS device (with the screen off). + Shows settings for turning on background tracking and navigation by periodically waking up the GPS device (with the screen off). Install version Choose how the app looks. App theme @@ -1622,15 +1621,15 @@ Default widget action Select the video output format. Video output format - Use the system recorder for video. + Use system recorder for video. Use system recorder Use the system app for photos. Use camera app Configure audio and video settings. - Audio/video settings - Error occurred while recording - Camera is not available - Audio/video is being recorded. To stop it tap the AV widget. + Audio/video settings + Recording failed + Camera not available + Recording Audio/video. Stop by tapping the AV widget. An audio from the specified recording is being played.\n%1$s Open external player Delete this recording? @@ -1724,7 +1723,7 @@ 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.\n\n + OsmAnd is a copyleft, libre 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:\n - Complete offline functionality (store downloaded vector or tile maps in the device storage)\n @@ -1739,7 +1738,7 @@ - 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:\n + Limitations of this gratis version of OsmAnd:\n - Number of map downloads limited\n - No offline access to Wikipedia POIs\n\n @@ -1752,22 +1751,22 @@ GPS navigation\n - • You can choose between offline (no roaming charges when you are abroad) or online (faster) mode\n + • 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 + • 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 + • 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 + • Record your own or upload a GPX track and follow it\n 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 + • Shows your location and the direction you are looking in\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 @@ -1779,9 +1778,9 @@ Cycling\n - • You can find cycling paths on the map\n + • 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 + • 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 @@ -1791,7 +1790,7 @@ • 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 + • Upload and follow a GPX route or record and share your own\n Contribute to OSM\n @@ -1800,7 +1799,7 @@ • 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.\n + OsmAnd is actively developed copyleft, libre software. Everyone can contribute to the app by reporting bugs, improving translations or coding new features. Additionally the project 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 @@ -1820,7 +1819,7 @@ 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.\n\n + OsmAnd+ is a copyleft, libre 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.\n\n @@ -1853,7 +1852,7 @@ • 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 + • Search for places by address, by type (e.g: Restaurant, hotel, gas station, museum), or by geographical coordinates\n Map Viewing\n @@ -1891,12 +1890,12 @@ • Display of contour lines and hillshading (via additional plugin) - Directly Contribute to OSM\n + Contribute directly 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. + OsmAnd is actively developed copyleft, libre software. Everyone can contribute to the app by reporting bugs, improving translations or coding new features. Additionally the project relies on financial contributions to fund coding and testing of new functionalities.\n Approximate map coverage and quality:\n @@ -2003,7 +2002,7 @@ Polygons Rendering mode Optimize map for - + Display from zoom level (requires contour data): Show contour lines Increase amount of map detail shown. @@ -2016,10 +2015,10 @@ Public transport search A way to search for favorites OsmAnd offline navigation is temporarily not available. - Left-hand driving - Select for countries with left-hand traffic. + Left-hand traffic + For countries where people drive on the left side of the road. Tap any existing item to see more details, long-tap to deactivate or delete. Current data on device (%1$s free): - Starting point is not yet determined + Starting point not yet determined Position not yet known Modify transparency (0 - transparent, 255 - opaque) Cancel file download? @@ -2039,7 +2038,7 @@ Select a voice and test by playing prompts Native rendering Test voice prompts - No offline vector map present for this location. You can download one in \'Settings\' (\'Manage map files\'), or switch to the \'Online maps\' plugin. + No offline vector map present for this location. Download one in \'Settings\' (\'Manage map files\'), or switch to the \'Online maps\' plugin. Send GPX files to OSM? Visibility Tags @@ -2126,7 +2125,7 @@ Log track using GPX widget or via \'Trip recording\' settings. Show current track This free OsmAnd version is limited to %1$s map downloads (to add or update maps) and does not support offline Wikipedia articles. - Free version + Gratis version Show POI description. North America Europe - Netherlands @@ -2159,7 +2158,7 @@ Needed for openstreetmap.org submissions. Your OSM password Background mode - OsmAnd keeps running in the background while the screen is off. + OsmAnd runs in the background with the screen off. There is not enough free space to download %1$s MB (free: %2$s). Transparent theme Native library not supported on this device. @@ -2265,7 +2264,7 @@ Phone call audio (also to interrupt car BT stereos) Notification audio Media/music audio - The app cannot download map layer %1$s, please try to reinstall it. + The app cannot download the map layer %1$s, reinstalling it might help. Modify the overlay transparency. Overlay transparency Modify the base map transparency. @@ -2281,16 +2280,16 @@ Unable to perform operation without a connection to the Internet. Install more… Use raster maps for anything beyond this level. - Min. vector zoom level + Min vector zoom level Online OSM map classification with images. - Error in offline search. + Could not perform offline search. Could not parse geo intent \'%s\'. - Search geo location + Search by geo location System - Select display language (please restart OsmAnd after changing). + Select display language (takes effect when OsmAnd is restarted). Display language incomplete - Change units of length. + Change what distance is measured in. Units of length Miles/feet Miles/yards @@ -2367,14 +2366,14 @@ Enable to calculate fastest route or disable for fuel-saving route. At zoom {0} download {1} tiles ({2} MB) Download map - Select maximum zoom to preload + Select max zoom to preload This map could not be downloaded Continuous rendering Display continuous rendering instead of image-at-once. - Error occurred while rendering selected area + Could not draw selected area Use location… Renderer loaded - Exception occurred: Renderer not loaded + Could not load renderer Vector renderer Choose the rendering appearance. Show POI website @@ -2392,15 +2391,15 @@ No GPX files found in the tracks folder GPX track… - Error reading GPX data + Could not read GPX data Offline vector maps Search transport at stop Modify POI Delete POI Compass direction Movement direction - Do not rotate (north always upwards) - Select the map screen alignment. + No rotation (north always upwards) + Select map screen alignment. Map orientation Route details Favorites imported @@ -2409,9 +2408,9 @@ Favorites saved to {0} No favorite points to save Favorites shared via OsmAnd - Error occurred while loading GPX + Could not load GPX Send report - No offline data for regions found on memory card. Download regions from the Internet. + Could not find any downloaded maps on memory card. Type to find a POI Any Thanks to Yandex for traffic info. @@ -2422,10 +2421,10 @@ Map source… Map layers Search POI - Use trackball to move the map. + Use a rolling ball device to move the map. Use trackball - Set the maximum waiting time for each background position fix. - Maximum wait for fix + Sets highest waiting time allowed for each background position fix. + Max wait for fix Where am I? OsmAnd navigation service Network @@ -2433,9 +2432,9 @@ seconds min. Set wake-up interval used by the background service. - Select the location provider used by the background service. + Select tracking method used by the background service. Location provider - Runs OsmAnd in the background to track your position while screen is off. + Tracks your position while the screen is off. Run OsmAnd in background The background navigation service requires a location provider to be turned on. Hide filter @@ -2448,7 +2447,7 @@ Specified voice data is corrupted Selected voice data is not available Memory card not accessible.\nYou won\'t be able to see maps or find things. - Memory card read-only.\nYou can only see the preloaded map and can\'t download from the Internet. + Memory card read-only.\nIt is now only possible to see the preloaded map, not download new areas. Unzipping file… Turn right and go Turn sharply right and go @@ -2460,7 +2459,7 @@ Head Later Download regions - Searching for signal… + Awaiting signal… Search near current map center Search nearby Same as device @@ -2468,7 +2467,7 @@ Landscape Screen orientation Portrait, landscape, or device. - Opening hours format is not supported for editing + Opening hours format can not be changed Add new rule Routes Stop @@ -2486,10 +2485,10 @@ Show transport stops OsmAnd navigation app POI data was updated ({0} were loaded) - Error updating local POI list - Error while loading data from server + Could not update local POI list + Could not load data from server No offline POI data available for this area - Updating POIs is not available for small zoom levels + Zooming in lets you update POIs Update POI Update local data from the Internet? City: {0} @@ -2516,7 +2515,7 @@ Offline data for {0} already exists ({1}). Update it ({2})? Address Downloading list of available regions… - The list of regions was not retrieved from https://osmand.net. + Could not fetch list of regions from https://osmand.net. Favorite point was edited No favorite points exist Replace @@ -2531,16 +2530,16 @@ Loading POI… Authorization failed failed - Converting native/English names… + Converting local/English names… Loading streets/buildings… Loading postcodes… Loading streets… Loading cities… POI - Error while saving GPX - Error calculating route - Error occurred while calculating route - Error: Calculated route is empty + Could not save GPX track + Could not calculate route + Could not calculate route + Calculated route is empty New route calculated, distance You have arrived at your destination Invalid coordinates @@ -2628,7 +2627,7 @@ change delete Action {0} completed. - Unexpected error while performing action {0}. + Could not perform action {0}. I/O error while performing action {0}. Info about node was not loaded Open @@ -2703,8 +2702,8 @@ %1$s downloads left Roads Downloading - %1$d file - Show free version banner - Display the free version banner even in the paid version. + Show gratis version banner + Display the gratis version banner even in the paid version. Buy Please activate \'Seamarks\' plugin Please activate \'SRTM\' plugin @@ -2727,7 +2726,7 @@ Plugins First use How to download maps, set basic settings. - Setup navigation. + Set up navigation. Planning a trip FAQ Frequently asked questions @@ -2805,7 +2804,7 @@ Quick action name duplicate Tapping this action button shows or hides the favorite points on the map. Tapping this action button shows or hides POIs on the map. - Show/hide favorites + Show/hide Favorites Show Favorites Hide Favorites Show/hide POI @@ -2815,16 +2814,16 @@ Create items Configure map Navigation - Leave blank to use the address or place name automatically. + Leave blank to use the address or place name. This message is included in the comment field. Message Select the category to save the favorite in. Select an optional category. POI list - You can add one or more POI categories to display on the map. + Add one or more POI categories to display on the map. Tapping this action button pages through the list below. Add a map style - Parameters should not be empty + Fill out all parameters Map styles Change map overlay Map overlays @@ -2839,7 +2838,7 @@ Add map source The map source has been changed to \"%s\". Change button position - Long-taping and dragggin the button changes its position on the screen. + Long-tapping and dragging the button changes its position on the screen. Action name You need to be connected to the Internet to view photos from Mapillary. Retry @@ -2853,7 +2852,7 @@ Add and Record Tracks Record or import tracks to view. Add Favorites - Add favorites on the map or import them from a file. + Import or mark favorites on the map. Import track File %1$s does not contain waypoints, import it as a track? Move Point @@ -2865,13 +2864,13 @@ Touring view (contrast and details) Nautical Copy Point/POI name - Location has no name + Unnamed location Tunnel ahead Tunnels Download the Wikipedia articles for %1$s to read them offline. Download Wikipedia data Open article online - View this article in a browser. + View article in a web browser. this region Searching for the necessary wiki article Article not found From d43b3b2e555dbd3307f668552c154683c68932a7 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 30 Apr 2018 16:49:11 +0300 Subject: [PATCH 02/20] Fix popular articles --- OsmAnd/src/net/osmand/plus/api/SQLiteAPI.java | 2 + .../net/osmand/plus/api/SQLiteAPIImpl.java | 6 + .../plus/wikivoyage/data/TravelDbHelper.java | 105 ++++++++++++++---- 3 files changed, 91 insertions(+), 22 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/api/SQLiteAPI.java b/OsmAnd/src/net/osmand/plus/api/SQLiteAPI.java index f5f022371f..c0d2a2a974 100644 --- a/OsmAnd/src/net/osmand/plus/api/SQLiteAPI.java +++ b/OsmAnd/src/net/osmand/plus/api/SQLiteAPI.java @@ -49,6 +49,8 @@ public interface SQLiteAPI { byte[] getBlob(int ind); + boolean isNull(int ind); + void close(); diff --git a/OsmAnd/src/net/osmand/plus/api/SQLiteAPIImpl.java b/OsmAnd/src/net/osmand/plus/api/SQLiteAPIImpl.java index 66ad5b8356..a1f368d89a 100644 --- a/OsmAnd/src/net/osmand/plus/api/SQLiteAPIImpl.java +++ b/OsmAnd/src/net/osmand/plus/api/SQLiteAPIImpl.java @@ -75,11 +75,17 @@ public class SQLiteAPIImpl implements SQLiteAPI { public void close() { c.close(); } + + public boolean isNull(int ind) { + return c.isNull(ind); + } + @Override public double getDouble(int ind) { return c.getDouble(ind); } + @Override public long getLong(int ind) { diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java index 6320fc652c..d6795b435f 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java @@ -3,7 +3,6 @@ package net.osmand.plus.wikivoyage.data; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.text.TextUtils; - import net.osmand.Collator; import net.osmand.CollatorStringMatcher; import net.osmand.CollatorStringMatcher.StringMatcherMode; @@ -45,7 +44,9 @@ public class TravelDbHelper { private static final Log LOG = PlatformUtil.getLog(TravelDbHelper.class); private static final String ARTICLES_TABLE_NAME = "wikivoyage_articles"; + private static final String POPULAR_TABLE_NAME = "popular_articles"; private static final String ARTICLES_COL_ID = "article_id"; + private static final String ARTICLES_POP_INDEX = "popularity_index"; private static final String ARTICLES_COL_TITLE = "title"; private static final String ARTICLES_COL_CONTENT = "content_gz"; private static final String ARTICLES_COL_IS_PART_OF = "is_part_of"; @@ -74,6 +75,15 @@ public class TravelDbHelper { ARTICLES_COL_CONTENTS_JSON + ", " + ARTICLES_COL_AGGREGATED_PART_OF + " FROM " + ARTICLES_TABLE_NAME; + + private static final String POP_ARTICLES_TABLE_SELECT = "SELECT " + + ARTICLES_COL_TITLE + ", " + + ARTICLES_COL_LAT + ", " + + ARTICLES_COL_LON + ", " + + ARTICLES_COL_CITY_ID + ", " + + ARTICLES_COL_LANG + ", " + + ARTICLES_POP_INDEX + + " FROM " + POPULAR_TABLE_NAME; private static final String SEARCH_TABLE_NAME = "wikivoyage_search"; private static final String SEARCH_COL_SEARCH_TERM = "search_term"; @@ -81,6 +91,8 @@ public class TravelDbHelper { private static final String SEARCH_COL_ARTICLE_TITLE = "article_title"; private static final String SEARCH_COL_LANG = "lang"; + private static final int POPULAR_LIMIT = 25; + private final OsmandApplication application; private TravelLocalDataHelper localDataHelper; @@ -91,7 +103,8 @@ public class TravelDbHelper { private File selectedTravelBook = null; private List existingTravelBooks = new ArrayList<>(); private List popularArticles = new ArrayList(); - + + public TravelDbHelper(OsmandApplication application) { this.application = application; collator = OsmAndCollator.primaryCollator(); @@ -216,22 +229,40 @@ public class TravelDbHelper { @NonNull public List loadPopularArticles() { List res = new ArrayList<>(); + String language = application.getLanguage(); + List popReadArticles = new ArrayList<>(); SQLiteConnection conn = openConnection(); if (conn != null) { - TravelArticle travelArticle; - SQLiteCursor cursor = conn.rawQuery("SELECT * FROM " - + ARTICLES_TABLE_NAME - + " WHERE article_id IN (SELECT article_id FROM " - + ARTICLES_TABLE_NAME - + " ORDER BY RANDOM() LIMIT 20) LIMIT 20", null); + SQLiteCursor cursor = conn.rawQuery(POP_ARTICLES_TABLE_SELECT, null); if (cursor.moveToFirst()) { do { - travelArticle = readArticle(cursor); - res.add(travelArticle); + PopularArticle travelArticle = PopularArticle.readArticle(cursor); + if(language.equals(travelArticle.lang)) { + popReadArticles.add(travelArticle); + } } while (cursor.moveToNext()); } cursor.close(); } + sortPopArticlesByDistance(popReadArticles); + StringBuilder bld = new StringBuilder(); + bld.append(ARTICLES_TABLE_SELECT).append(" WHERE "+ARTICLES_COL_LANG+" = '"+language+"'" + + " and "+ARTICLES_COL_CITY_ID+" IN ("); + for (int i = 0; i < popReadArticles.size() && i < POPULAR_LIMIT; i++) { + if (i > 0) { + bld.append(", "); + } + bld.append(popReadArticles.get(i).cityId); + } + bld.append(")"); + SQLiteCursor cursor = conn.rawQuery(bld.toString(), null); + if (cursor.moveToFirst()) { + do { + TravelArticle travelArticle = readArticle(cursor); + res.add(travelArticle); + } while (cursor.moveToNext()); + } + cursor.close(); sortArticlesByDistance(res); popularArticles = res; return res; @@ -264,15 +295,21 @@ public class TravelDbHelper { 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; - } + return Double.compare(MapUtils.getDistance(loc, article1.getLat(), article1.getLon()), MapUtils.getDistance(loc, article2.getLat(), article2.getLon())); + } + }); + } + } + + private void sortPopArticlesByDistance(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(PopularArticle article1, PopularArticle article2) { + return Double.compare(MapUtils.getDistance(loc, article1.lat, article1.lon), + MapUtils.getDistance(loc, article2.lat, article2.lon)); } }); } @@ -463,11 +500,11 @@ public class TravelDbHelper { LOG.error(e.getMessage(), e); } res.isPartOf = cursor.getString(3); - res.lat = cursor.getDouble(4); - res.lon = cursor.getDouble(5); + res.lat = cursor.isNull(4) ? Double.NaN : cursor.getDouble(4); + res.lon = cursor.isNull(5) ? Double.NaN : cursor.getDouble(5); res.imageTitle = cursor.getString(6); res.cityId = cursor.getLong(8); - res.originalId = cursor.getLong(9); + res.originalId = cursor.isNull(9) ? 0 : cursor.getLong(9); res.lang = cursor.getString(10); res.contentsJson = cursor.getString(11); res.aggregatedPartOf = cursor.getString(12); @@ -501,4 +538,28 @@ public class TravelDbHelper { } return file; } + + private static class PopularArticle { + long cityId; + String title; + String lang; + int popIndex; + double lat; + double lon; + + public boolean isLocationSpecified() { + return !Double.isNaN(lat) && !Double.isNaN(lon); + } + + public static PopularArticle readArticle(SQLiteCursor cursor) { + PopularArticle res = new PopularArticle(); + res.title = cursor.getString(0); + res.lat = cursor.isNull(1) ? Double.NaN : cursor.getDouble(1); + res.lon = cursor.isNull(2) ? Double.NaN : cursor.getDouble(2); + res.cityId = cursor.getLong(3); + res.lang = cursor.getString(4); + res.popIndex = cursor.isNull(5) ? 0 : cursor.getInt(5); + return res; + } + } } From ad4d3e360397807742e7a69ce661787fa898ae34 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Mon, 30 Apr 2018 17:23:44 +0300 Subject: [PATCH 03/20] Invalidate list in ExploreRvAdapter#setItems --- .../src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java index 1b2c5ffad4..99b00c9f99 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java @@ -116,6 +116,7 @@ public class ExploreRvAdapter extends RecyclerView.Adapter items) { this.items.clear(); this.items.addAll(items); + notifyDataSetChanged(); } private void removeItem(int position) { From e342ad8226616feb5cbdad1525410b30a0162e98 Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 30 Apr 2018 18:05:03 +0300 Subject: [PATCH 04/20] fixed ?attr in xml drawables --- ..._card_bg.xml => dialog_active_card_bg_dark.xml} | 4 ++-- .../res/drawable/dialog_active_card_bg_light.xml | 13 +++++++++++++ ...{travel_card_bg.xml => travel_card_bg_dark.xml} | 2 +- OsmAnd/res/drawable/travel_card_bg_light.xml | 12 ++++++++++++ ...troke_bg.xml => travel_card_stroke_bg_dark.xml} | 2 +- .../res/drawable/travel_card_stroke_bg_light.xml | 12 ++++++++++++ ...n_bg.xml => wikivoyage_primary_btn_bg_dark.xml} | 2 +- .../drawable/wikivoyage_primary_btn_bg_light.xml | 9 +++++++++ ...bg.xml => wikivoyage_secondary_btn_bg_dark.xml} | 4 ++-- .../drawable/wikivoyage_secondary_btn_bg_light.xml | 9 +++++++++ .../layout/fragment_wikivoyage_explore_dialog.xml | 2 +- .../fragment_wikivoyage_show_images_first_time.xml | 6 +++--- OsmAnd/res/layout/purchase_dialog_active_card.xml | 2 +- OsmAnd/res/layout/purchase_dialog_card.xml | 2 +- OsmAnd/res/layout/purchase_dialog_card_button.xml | 2 +- OsmAnd/res/layout/purchase_dialog_fragment.xml | 2 +- OsmAnd/res/layout/travel_download_update_card.xml | 8 ++++---- OsmAnd/res/layout/wikivoyage_open_beta_card.xml | 2 +- .../res/layout/wikivoyage_start_editing_card.xml | 2 +- OsmAnd/res/values/attrs.xml | 7 +++++++ OsmAnd/res/values/styles.xml | 14 ++++++++++++++ .../travelcards/TravelDownloadUpdateCard.java | 4 ++-- 22 files changed, 99 insertions(+), 23 deletions(-) rename OsmAnd/res/drawable/{dialog_active_card_bg.xml => dialog_active_card_bg_dark.xml} (72%) create mode 100644 OsmAnd/res/drawable/dialog_active_card_bg_light.xml rename OsmAnd/res/drawable/{travel_card_bg.xml => travel_card_bg_dark.xml} (82%) create mode 100644 OsmAnd/res/drawable/travel_card_bg_light.xml rename OsmAnd/res/drawable/{travel_card_stroke_bg.xml => travel_card_stroke_bg_dark.xml} (78%) create mode 100644 OsmAnd/res/drawable/travel_card_stroke_bg_light.xml rename OsmAnd/res/drawable/{wikivoyage_primary_btn_bg.xml => wikivoyage_primary_btn_bg_dark.xml} (76%) create mode 100644 OsmAnd/res/drawable/wikivoyage_primary_btn_bg_light.xml rename OsmAnd/res/drawable/{wikivoyage_secondary_btn_bg.xml => wikivoyage_secondary_btn_bg_dark.xml} (61%) create mode 100644 OsmAnd/res/drawable/wikivoyage_secondary_btn_bg_light.xml diff --git a/OsmAnd/res/drawable/dialog_active_card_bg.xml b/OsmAnd/res/drawable/dialog_active_card_bg_dark.xml similarity index 72% rename from OsmAnd/res/drawable/dialog_active_card_bg.xml rename to OsmAnd/res/drawable/dialog_active_card_bg_dark.xml index ccf3936585..1806a6d0ce 100644 --- a/OsmAnd/res/drawable/dialog_active_card_bg.xml +++ b/OsmAnd/res/drawable/dialog_active_card_bg_dark.xml @@ -5,8 +5,8 @@ - - + + diff --git a/OsmAnd/res/drawable/dialog_active_card_bg_light.xml b/OsmAnd/res/drawable/dialog_active_card_bg_light.xml new file mode 100644 index 0000000000..ebae968061 --- /dev/null +++ b/OsmAnd/res/drawable/dialog_active_card_bg_light.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/OsmAnd/res/drawable/travel_card_bg.xml b/OsmAnd/res/drawable/travel_card_bg_dark.xml similarity index 82% rename from OsmAnd/res/drawable/travel_card_bg.xml rename to OsmAnd/res/drawable/travel_card_bg_dark.xml index de280be397..2fbb593bc9 100644 --- a/OsmAnd/res/drawable/travel_card_bg.xml +++ b/OsmAnd/res/drawable/travel_card_bg_dark.xml @@ -5,7 +5,7 @@ - + diff --git a/OsmAnd/res/drawable/travel_card_bg_light.xml b/OsmAnd/res/drawable/travel_card_bg_light.xml new file mode 100644 index 0000000000..b8c94363a4 --- /dev/null +++ b/OsmAnd/res/drawable/travel_card_bg_light.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/OsmAnd/res/drawable/travel_card_stroke_bg.xml b/OsmAnd/res/drawable/travel_card_stroke_bg_dark.xml similarity index 78% rename from OsmAnd/res/drawable/travel_card_stroke_bg.xml rename to OsmAnd/res/drawable/travel_card_stroke_bg_dark.xml index e629d12875..511f882de9 100644 --- a/OsmAnd/res/drawable/travel_card_stroke_bg.xml +++ b/OsmAnd/res/drawable/travel_card_stroke_bg_dark.xml @@ -5,7 +5,7 @@ + android:color="@color/wikivoyage_card_divider_dark"/> diff --git a/OsmAnd/res/drawable/travel_card_stroke_bg_light.xml b/OsmAnd/res/drawable/travel_card_stroke_bg_light.xml new file mode 100644 index 0000000000..f7e37d2cec --- /dev/null +++ b/OsmAnd/res/drawable/travel_card_stroke_bg_light.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/OsmAnd/res/drawable/wikivoyage_primary_btn_bg.xml b/OsmAnd/res/drawable/wikivoyage_primary_btn_bg_dark.xml similarity index 76% rename from OsmAnd/res/drawable/wikivoyage_primary_btn_bg.xml rename to OsmAnd/res/drawable/wikivoyage_primary_btn_bg_dark.xml index e709c76cc1..a1d6ff94c7 100644 --- a/OsmAnd/res/drawable/wikivoyage_primary_btn_bg.xml +++ b/OsmAnd/res/drawable/wikivoyage_primary_btn_bg_dark.xml @@ -2,7 +2,7 @@ - + diff --git a/OsmAnd/res/drawable/wikivoyage_primary_btn_bg_light.xml b/OsmAnd/res/drawable/wikivoyage_primary_btn_bg_light.xml new file mode 100644 index 0000000000..581c0d9f2e --- /dev/null +++ b/OsmAnd/res/drawable/wikivoyage_primary_btn_bg_light.xml @@ -0,0 +1,9 @@ + + + + + + + + diff --git a/OsmAnd/res/drawable/wikivoyage_secondary_btn_bg.xml b/OsmAnd/res/drawable/wikivoyage_secondary_btn_bg_dark.xml similarity index 61% rename from OsmAnd/res/drawable/wikivoyage_secondary_btn_bg.xml rename to OsmAnd/res/drawable/wikivoyage_secondary_btn_bg_dark.xml index 7b42cd135b..738d47c6cc 100644 --- a/OsmAnd/res/drawable/wikivoyage_secondary_btn_bg.xml +++ b/OsmAnd/res/drawable/wikivoyage_secondary_btn_bg_dark.xml @@ -1,8 +1,8 @@ + android:shape="rectangle"> - + diff --git a/OsmAnd/res/drawable/wikivoyage_secondary_btn_bg_light.xml b/OsmAnd/res/drawable/wikivoyage_secondary_btn_bg_light.xml new file mode 100644 index 0000000000..5ae606dd50 --- /dev/null +++ b/OsmAnd/res/drawable/wikivoyage_secondary_btn_bg_light.xml @@ -0,0 +1,9 @@ + + + + + + + + diff --git a/OsmAnd/res/layout/fragment_wikivoyage_explore_dialog.xml b/OsmAnd/res/layout/fragment_wikivoyage_explore_dialog.xml index 4c834efca3..76c66b9e89 100644 --- a/OsmAnd/res/layout/fragment_wikivoyage_explore_dialog.xml +++ b/OsmAnd/res/layout/fragment_wikivoyage_explore_dialog.xml @@ -75,7 +75,7 @@ android:layout_height="wrap_content" android:layout_marginLeft="@dimen/text_margin_small" android:layout_marginRight="@dimen/text_margin_small" - android:background="@drawable/wikivoyage_search_card_bg"> + android:background="?attr/wikivoyage_travel_card_bg"> + android:background="?attr/wikivoyage_secondary_btn_bg"> + android:background="?attr/wikivoyage_secondary_btn_bg"> + android:background="?attr/wikivoyage_primary_btn_bg"> diff --git a/OsmAnd/res/layout/purchase_dialog_card.xml b/OsmAnd/res/layout/purchase_dialog_card.xml index dfbc449d67..d511f68ece 100644 --- a/OsmAnd/res/layout/purchase_dialog_card.xml +++ b/OsmAnd/res/layout/purchase_dialog_card.xml @@ -7,7 +7,7 @@ android:layout_marginBottom="@dimen/list_header_padding" android:layout_marginLeft="@dimen/card_padding" android:layout_marginRight="@dimen/card_padding" - android:background="@drawable/dialog_card_bg" + android:background="?attr/wikivoyage_travel_card_bg" android:orientation="vertical"> diff --git a/OsmAnd/res/layout/purchase_dialog_card_button.xml b/OsmAnd/res/layout/purchase_dialog_card_button.xml index 7e70c781ac..bbe40ddedc 100644 --- a/OsmAnd/res/layout/purchase_dialog_card_button.xml +++ b/OsmAnd/res/layout/purchase_dialog_card_button.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="@drawable/wikivoyage_active_card_bg"> + android:background="?attr/wikivoyage_primary_btn_bg"> + android:background="?attr/wikivoyage_travel_card_bg"> @@ -135,7 +135,7 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" - android:background="@drawable/wikivoyage_secondary_btn_bg"> + android:background="?attr/wikivoyage_secondary_btn_bg"> + android:background="?attr/wikivoyage_primary_btn_bg"> + android:background="?attr/wikivoyage_travel_card_bg"> + + + + + + + diff --git a/OsmAnd/res/values/styles.xml b/OsmAnd/res/values/styles.xml index bcbd3ed781..85d654d46d 100644 --- a/OsmAnd/res/values/styles.xml +++ b/OsmAnd/res/values/styles.xml @@ -213,6 +213,13 @@ @color/wikivoyage_primary_btn_text_light @color/wikivoyage_welcome_bg_light @color/wikivoyage_primary_text_light + + @drawable/travel_card_bg_light + @drawable/travel_card_stroke_bg_light + @drawable/wikivoyage_secondary_btn_bg_light + @drawable/wikivoyage_primary_btn_bg_light + @drawable/dialog_active_card_bg_light +