diff --git a/OsmAnd-java/src/main/java/net/osmand/osm/edit/Entity.java b/OsmAnd-java/src/main/java/net/osmand/osm/edit/Entity.java index 6005f85035..7bb8edbf49 100644 --- a/OsmAnd-java/src/main/java/net/osmand/osm/edit/Entity.java +++ b/OsmAnd-java/src/main/java/net/osmand/osm/edit/Entity.java @@ -114,6 +114,8 @@ public abstract class Entity implements Serializable { public static final int MODIFY_DELETED = -1; public static final int MODIFY_MODIFIED = 1; public static final int MODIFY_CREATED = 2; + public static final String POI_TYPE_TAG = "poi_type_tag"; + public static final String REMOVE_TAG_PREFIX = "----"; public Entity(long id) { this.id = id; @@ -241,6 +243,11 @@ public abstract class Entity implements Serializable { return Collections.unmodifiableMap(tags); } + public boolean isNotValid(String tag) { + String val = getTag(tag); + return val == null || val.length() == 0 || tag.length() == 0 + || tag.startsWith(REMOVE_TAG_PREFIX) || tag.equals(POI_TYPE_TAG); + } public Collection getTagKeySet() { if (tags == null) { diff --git a/OsmAnd-telegram/res/values-es/strings.xml b/OsmAnd-telegram/res/values-es/strings.xml index 63c0fcf19b..29442e4212 100644 --- a/OsmAnd-telegram/res/values-es/strings.xml +++ b/OsmAnd-telegram/res/values-es/strings.xml @@ -268,4 +268,8 @@ Última respuesta: hace %1$s hace %1$s ERR + Exportar + Búfer de Logcat + Selecciona y comparte logs detallados de la app + Enviar informe \ No newline at end of file diff --git a/OsmAnd-telegram/res/values-nl/strings.xml b/OsmAnd-telegram/res/values-nl/strings.xml index b77535908e..ebddf36454 100644 --- a/OsmAnd-telegram/res/values-nl/strings.xml +++ b/OsmAnd-telegram/res/values-nl/strings.xml @@ -257,4 +257,8 @@ Afstand eenheden Definieer de eenheid voor snelheid. Eenheid van snelheid + Stuur rapport + Exporteer naar OSM + Logcat buffer + Controleer en deel gedetailleerde logs van de app \ No newline at end of file diff --git a/OsmAnd/res/layout/follow_track_options.xml b/OsmAnd/res/layout/follow_track_options.xml index 60c6a885b3..0877fcc307 100644 --- a/OsmAnd/res/layout/follow_track_options.xml +++ b/OsmAnd/res/layout/follow_track_options.xml @@ -55,6 +55,17 @@ android:textSize="@dimen/default_list_text_size" osmand:typeface="@string/font_roboto_medium" /> + + diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index 697326c31c..20b7fd68f2 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -3933,4 +3933,6 @@ Für das Schneemobilfahren mit speziellen Straßen und Tracks. Durchführen eines OAuth-Logins zur Nutzung der osmedit-Funktionen 2-Phasen-A*-Routing-Algorithmus verwenden + %1$s Daten sind nur auf den Straßen verfügbar, Sie müssen eine Route mit \"Route zwischen Punkten\" berechnen, um sie zu erhalten. + %1$s — %2$s \ No newline at end of file diff --git a/OsmAnd/res/values-eo/strings.xml b/OsmAnd/res/values-eo/strings.xml index ece67180a8..c469f7f4bd 100644 --- a/OsmAnd/res/values-eo/strings.xml +++ b/OsmAnd/res/values-eo/strings.xml @@ -3932,4 +3932,6 @@ Datumoj de %1$s estas disponeblaj nur por vojoj, vi devas kalkuli la kurson uzante “kalkuli kurson inter punktoj” por akiri ĝin. Atendado ĝis la kurso estos rekalkulita. \nDiagramo estos videbla post rekalkulado. + %1$s — %2$s + Manko \ No newline at end of file diff --git a/OsmAnd/res/values-es-rAR/strings.xml b/OsmAnd/res/values-es-rAR/strings.xml index 4da8d4966b..ad60cd64f0 100644 --- a/OsmAnd/res/values-es-rAR/strings.xml +++ b/OsmAnd/res/values-es-rAR/strings.xml @@ -3551,14 +3551,14 @@ Guardando el nuevo perfil No se pudo respaldar el perfil. ¿Borrar los datos registrados\? - Importación de datos de %1$s - Importación + Importando de datos de «%1$s» + Importando OsmAnd comprueba %1$s para ver si hay duplicados con los elementos existentes en la aplicación. \n \nPuede llevar algún tiempo. Elementos añadidos Importación completa - Todos los datos de %1$s son importados, puedes usar los botones de abajo para abrir la parte necesaria de la aplicación para manejarla. + Todos los datos de «%1$s» fueron importados. Puedes usar los botones de abajo para gestionar la sección necesaria de la aplicación. Min %1$s de %2$s Terreno diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index 2a4458f148..3dda9b8adc 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -3801,7 +3801,7 @@ Sélectionnez un fichier de trace à ouvrir. Terminé Remplacer la trace - Sélectionnez comment relier les points : par une ligne droite ou en calculant un itinéraire reliant les points comme indiqué ci-dessous. + Définissez comment relier les points : par une ligne droite ou en calculant un itinéraire avec le profil ci-dessous. Toute la trace sera recalculée en utilisant le profil sélectionné. Seul le prochain segment sera recalculé en utilisant le profil sélectionné. Ensuite, sélectionnez le profil de navigation pour détecter les routes autorisées et le seuil de distance afin de déplacer votre trace. diff --git a/OsmAnd/res/values-is/phrases.xml b/OsmAnd/res/values-is/phrases.xml index 07ff354d7e..564d5dfea5 100644 --- a/OsmAnd/res/values-is/phrases.xml +++ b/OsmAnd/res/values-is/phrases.xml @@ -3802,7 +3802,7 @@ Vatnsyfirborð: í kafi Vatnsyfirborð: að hluta í kafi Gróft - Merki til að finna staurinn + Internetaðgangur: viðskiptavinir Staða dælu: vantar bita Sog Undir þrýstingi @@ -3830,4 +3830,8 @@ LNG Brottfaratafla: nei Brottfaratafla + Meðfram götu + Skýli + Á þaki + GPX-punktur \ No newline at end of file diff --git a/OsmAnd/res/values-is/strings.xml b/OsmAnd/res/values-is/strings.xml index c5ce396f03..182d438a1c 100644 --- a/OsmAnd/res/values-is/strings.xml +++ b/OsmAnd/res/values-is/strings.xml @@ -3777,7 +3777,7 @@ \n \nVeldu %2$s: öllum gögnum sem tengjast hraðamyndavélum; t.d. aðvaranir, tilkynningar, staðsetningar o.fl. verður eytt þar til OsmAnd er sett inn aftur frá grunni. Veldu ferilskrá þar sem nýjum bút verður bætt inn. - Veldu hvernig eigi að tengja punkta; með beinni línu eða reikna leið milli þeirra eins og tiltekið er hér að neðan. + Veldu hvernig eigi að tengja punktana; með beinni línu eða reikna leið milli þeirra eins og tiltekið er hér að neðan. Allur ferillinn verður endurreiknaður með völdu sniði. Lokaður OSM-minnispunktur Allur ferillinn @@ -3914,4 +3914,35 @@ Veldu millibil skráninga í almenna leiðarskráningu (virkjað með viðmótshlutanum fyrir GPX-skráningu á kortinu). Setja skráningu í bið Halda áfram með skráningu + • Uppfærðar aðgerðir í skipulagningu leiða: mismunandi leiðsögn á hverjum bút auk slóða +\n +\n • Ný útlitsvalmynd fyrir slóðir: val á lit, þykkt, birting stefnuörva, táknmynda við upphaf/endi +\n +\n • Bættur sýnileiki hjólreiðahnúta. +\n +\n • Hægt að ýta á slóðir, hafa samhengisvalmynd með grunnupplýsingum. +\n +\n • Bætt reiknirit leitar +\n +\n • Bættir valkostir fyrir \'Fylgja slóð\' í leiðsögn +\n +\n • Lagfærð vandamál við inn/útflutning á stillingum sniða +\n +\n + Bíddu eftir endurútreikningi leiðar. +\nGrafið verður tiltækt eftir endurútreikning. + Fyrir akstur vélsleða á sérstökum vegum og slóðum. + %1$s gögn aðeins tiltæk á vegunum, þú þarft að reikna leið með “Leið milli punkta” til að fá hana. + Skrá hefur þegar verið flutt inn í OsmAnd + Bil + Takk fyrir að kaupa \'Hæðarlínur\' + Áskriftargjaldið verður rukkað miðað við valið tímabil. Þú getur sagt áskriftinni upp hvenær sem er á AppGallery. + Nota 2-umferða A* leiðararútreikning + Greiðsla verður gjaldfærð á AppGallery reikninginn þinn við staðfestingu á kaupunum. +\n +\n Áskrift endurnýjast sjálfkrafa nema hún sé felld niður fyrir endurnýjunardag. Reikningur þinn verður einungis gjaldfærður fyrir endurnýjunartímabil (mánuður / þrír mánuðir / ár) á endurnýjunardegi. +\n +\n Þú getur stýrt og aflýst áskriftunum þínum með því að fara í AppGallery stillingarnar þínar. + Graf + %1$s — %2$s \ No newline at end of file diff --git a/OsmAnd/res/values-it/strings.xml b/OsmAnd/res/values-it/strings.xml index 7b4c8ad764..e950feca34 100644 --- a/OsmAnd/res/values-it/strings.xml +++ b/OsmAnd/res/values-it/strings.xml @@ -3718,7 +3718,7 @@ Questi elementi sono nascosti dal menu, ma le opzioni rappresentate o i plugins continueranno a funzionare. Nascondere le opzioni le reimposta al loro valore originale. Azioni principali - Puoi accedere a queste azioni toccando il pulsante \"Azioni aggiuntive\". + Puoi accedere a queste azioni toccando il pulsante “%1$s”. Puoi spostare gli elementi solo all\'interno di questa categoria. Seleziona i linguaggi in cui gli articoli di Wikipedia appariranno sulla mappa. Puoi cambiare fra tutte le lingue disponibili mentre leggi questo articolo. Alcuni articoli di Wikipedia potrebbero non essere disponibili nella tua lingua. diff --git a/OsmAnd/res/values-ja/phrases.xml b/OsmAnd/res/values-ja/phrases.xml index 865fa35edc..495b894b2c 100644 --- a/OsmAnd/res/values-ja/phrases.xml +++ b/OsmAnd/res/values-ja/phrases.xml @@ -1479,7 +1479,7 @@ 持ち帰り不可 テイクアウト・持ち帰りのみ 遺跡の種類 - 医療機関 + 専門分野 総合診療医 眼科 婦人科 @@ -1487,7 +1487,7 @@ 整形外科 耳鼻咽喉科 小児科 - 医療機関:小児科:無し + 専門分野:小児科:無し 皮膚科 泌尿器科 一般外科 diff --git a/OsmAnd/res/values-nb/strings.xml b/OsmAnd/res/values-nb/strings.xml index 85f13702a1..12e10abaef 100644 --- a/OsmAnd/res/values-nb/strings.xml +++ b/OsmAnd/res/values-nb/strings.xml @@ -628,7 +628,7 @@ Oversiktskart (verden) Skikart (verden) Kroatisk - Nettfrakoblet beregning av OsmAnd-rutesegment + Frakoblet beregning av OsmAnd-rutesegment Beregn OsmAnd-rute for første og siste rutesegment Statuslinje Foretrukket språk for påskrifter på kartet (hvis utilgjengelig brukes engelsk eller lokale navn). @@ -3694,7 +3694,7 @@ Egendefinert Retningspiler tonn - Rute mellom punkter + Rut mellom punkter Enduro-motorsykkel Skjermkontroll Bruk systemets skjermtidsavbrudd @@ -3706,7 +3706,7 @@ Snu rute Overskriv spor Hele sporet blir beregnet på nytt med den valgte profilen. - Velg hvordan punkter skal forbindes; med en rett linje, eller beregn en rute mellom dem som spesifisert nedenfor. + Velg hvordan punktene skal forbindes; med en rett linje, eller beregn en rute mellom dem som spesifisert nedenfor. Kun det neste segmentet blir beregnet på nytt med den valgte profilen. Hele sporet Neste segment @@ -3872,4 +3872,6 @@ \nGraf vil være tilgjengelig etter omberegning. %1$s — %2$s Graf + %1$s-data er tilgjengelig kun på veiene, du må beregne en rute med “Rut mellom punkter”. + Spor rute \ No newline at end of file diff --git a/OsmAnd/res/values-nl/strings.xml b/OsmAnd/res/values-nl/strings.xml index 54c11b5a67..6557da422c 100644 --- a/OsmAnd/res/values-nl/strings.xml +++ b/OsmAnd/res/values-nl/strings.xml @@ -12,7 +12,7 @@ Kijkrichting Transparante widgets continu - Vectorkaarten worden vaak sneller weergegeven. Werkt niet op sommige apparaten. + Vectorkaarten worden vaak sneller weergegeven. Werkt niet op alle toestellen. Kies een stem en test door aankondigingen af te spelen: OsmAnd fout-opsporing en ontwikkeling Interne kaartgeneratie @@ -218,7 +218,7 @@ Taal niet ondersteund De gekozen taal wordt niet ondersteund door de geïnstalleerde Android TTS (tekst-naar-spraak) stemgenerator. De standaard TTS taal zal worden gebruikt. Zoek een andere TTS stemgenerator op de markt\? Ontbrekende gegevens - Geen gegevens voor de geselecteerde taal geïnstalleerd. Wil je naar de Play-store gaan om deze te installeren? + Geen gegevens voor de geselecteerde taal geïnstalleerd. Ga naar \"Play Store\" om deze te installeren\? Keer richting van GPX-track om Huidige bestemming gebruiken Volg de gehele track @@ -251,7 +251,7 @@ Fout bij offline zoeken. Zoek adres in de offline kaarten Systeem - App toon talen (OsmAnd dient opnieuw gestart). + App \"Toon talen\" (OsmAnd dient opnieuw gestart). Toon talen Wijzig de eenheid van afstand voor metingen. Afstand eenheden @@ -433,7 +433,7 @@ Naar signaal zoeken… Zoek bij het midden van de kaart Zoek dichtbij - Zelfde als apparaat-instelling + Zelfde als apparaatinstelling Portret Landschap Kaartscherm-oriëntatie @@ -642,7 +642,7 @@ \n \nRasterkaarten zijn direct via online bronnen verkrijgbaar of kunnen voor offline gebruik gereedgemaakt worden (en handmatig gekopieerd naar de OsmAnd gegevensmap) als SQLite database door diverse hulpprogramma\'s van derden. Instellingen om tracking en navigatie te kunnen gebruiken met het scherm uit (schakelt de GPS periodiek in). - "Maakt de toegankelijkheidsopties van het toestel rechtstreeks beschikbaar in OsmAnd. Hiermee kan o.a. de spreeksnelheid van tekst-naar-spraak-stemmen aangepast worden, D-pad schermnavigatie geconfigureerd worden, een trackball gebruikt worden voor de zoomregeling, of het gebruiken van meldingen via tekst-naar-spraak, bijvoorbeeld het automatisch melden van de positie." + Maakt de toegankelijkheidsopties van het toestel rechtstreeks beschikbaar in OsmAnd. Hiermee kan o.a. de spreeksnelheid van tekst-naar-spraak stemmen aangepast worden, D-pad schermnavigatie geconfigureerd worden, een trackball gebruikt worden voor de zoomregeling, of het gebruiken van meldingen via tekst-naar-spraak, bijvoorbeeld het automatisch melden van de positie. Deze plug-in toont de instellingen voor ontwikkel- en debug-opties, zoals routetest en -simulatie, schermweergave-prestaties, en spraaksturing. Deze instellingen zijn bedoeld voor programmeurs die OsmAnd willen verbeteren en zijn niet nodig voor normaal gebruik. Plugins beheren Schakel plugins in voor speciale functies en extra instellingen. @@ -750,7 +750,7 @@ OsmAnd is een open-source navigatiesysteem met online en offline kaarten OsmAnd (OSM Automated Navigation Directions) \n -\n OsmAnd is een open-source navigatie-app die toegang geeft tot een grote variëteit aan wereldwijde OSM-gegevens. Alle kaartgegevens (vector- of rasterkaarten) kunnen in het telefoongeheugen worden opgeslagen voor offline gebruik. OsmAnd biedt ook zowel offline als online routeaanwijzingen, met stembegeleiding. +\nOsmAnd is een open-source navigatie-app die toegang geeft tot een grote variëteit aan wereldwijde OSM-gegevens. Alle kaartgegevens (vector- of rasterkaarten) kunnen in het telefoongeheugen worden opgeslagen voor offline gebruik. OsmAnd biedt ook zowel offline als online routeaanwijzingen, met stembegeleiding. \n \n Enkele van de belangrijkste mogelijkheden: \n - Volledig offline gebruik (gedownloade vector- of rasterkaarten worden opgeslagen op het apparaat) @@ -767,9 +767,9 @@ \n \n Beperkingen van deze gratis versie van OsmAnd: \n - Beperkt aantal kaartdownloads -\n - Geen toegang tot offline Wikipedia POI\'s. +\n - Geen toegang tot offline Wikipedia POI\'s \n -\n OsmAnd wordt actief ontwikkeld en ons project en de verdere vooruitgang ervan is afhankelijk van +\nOsmAnd wordt actief ontwikkeld en ons project en de verdere vooruitgang ervan is afhankelijk van \nfinanciële bijdragen om de ontwikkeling en testen van nieuwe functionaliteit te kunnen bekostigen. \nWij verzoeken je om OsmAnd+ te kopen, of om een donatie over te maken via https://osmand.net. OsmAnd+ (OSM Automated Navigation Directions) @@ -1283,7 +1283,7 @@ Widgets Linker Kolom Kaart instellen Binnen - Anonieme gebruikesr kunnen geen + Anonieme gebruikers kunnen geen \n- groepen aanmaken; \n- groepen en apparaten synchroniseren met de server; \n- groepen en apparaten beheren in een eigen omgeving op de website. @@ -1437,7 +1437,7 @@ Start Stop Importeren - Export naar OSM + Exporteer naar OSM Meer… Meer acties Toon niet meer @@ -2285,10 +2285,10 @@ \n • Toon POIs (Points Of Interest) in uw omgeving \n • Draai de kaart in uw bewegingsrichting (of kompasrichting) \n • Toon uw positie en waar u naar kijkt -\n • Deel uw lokatie met vrienden +\n • Deel uw locatie met vrienden \n • Bewaar belangrijke plaatsen in ‘Favorieten’ \n • Toon namen in het Engels, de lokale taal, of fonetisch -\n • Toon extra online tiles, zoals een satellietfoto (van Bing), verschillende extra lagen zoals GPX-tracks voor navigatie e.d. met instelbare transparantie +\n • Toon extra online tegels, zoals een satellietfoto (van Bing), verschillende extra lagen zoals GPX-tracks voor navigatie e.d. met instelbare transparantie \n Skiën \nMet de OsmAnd Ski plug-in ziet u pistes met hun moeilijkheidsgraad, en extra informatie zoals liften en andere faciliteiten. @@ -2302,7 +2302,7 @@ \n • De kaart toont voetpaden en wandelpaden \n • Wikipedia kan je veel vertellen tijdens een stadswandeling, in je eigen taal \n • OV-haltes (tram, bus, trein, metro), inclusief lijnnummers, helpen je bij het reizen in een onbekende stad -\n • GPS-navigatie in voetgangermodus gebruikt voor het berekenen van de route voet- en wandelpaden +\n • GPS-navigatie in voetgangersmodus gebruikt voor het berekenen van de route voet- en wandelpaden \n • Upload en volg een GPX-route of neem er zelf één op en deel deze. \n Draag bij aan OpenStreetMap (OSM) @@ -2384,7 +2384,7 @@ \n • Kaart draaien in kompas- of bewegingsrichting \n • Bewaar belangrijke plaatsen in ‘Favorieten’. \n • Toon POI’s (points of interest) in de buurt -\n • Toon specifieke online tiles, satellietbeelden (van Bing), en extra lagen zoals GPX-tracks met rit-/routeinformatie e.d., met instelbare transparantie +\n • Toon specifieke online tegels, satellietbeelden (van Bing), en extra lagen zoals GPX-tracks met rit-/routeinformatie e.d., met instelbare transparantie \n • Toon plaatsnamen in het Engels, de lokale taal of fonetisch weergegeven \n Gebruik OSM- en Wikipedia-gegevens @@ -3235,7 +3235,7 @@ \'Freeride\' en \'Off-piste\' zijn officieuze routes en passages. Meestal onverzorgd en niet onderhouden, en niet \'s avonds gecontroleerd. Betreden op eigen risico. Verzamelde data Laatste OsmAnd uitvoering gecrasht. Help ons alstublieft OsmAnd te verbeteren door de foutmelding te delen. - Personal transporter + Persoonlijke transporteur Offroad WunderLINQ Wegtype @@ -3298,24 +3298,24 @@ Uitschakelen Nieuwe plug-in toegevoegd Segmenten samenvoegen - • App profiles: Create a custom profile for your own needs, with a custom icon and color -\n -\n • Nu aan te passen standaard en min / max snelheden voor elk profiel -\n -\n • Widget toegevoegd voor de huidige coördinaten -\n -\n • Opties toegevoegd om het kompas en een straalliniaal op de kaart te tonen -\n -\n • Fix background track logging -\n -\n • Improved background map downloads -\n -\n • \'Zet scherm aan\' optie is terug -\n -\n • Wikipedia taalkeuze aangepast -\n -\n • Vast kompasknop tijdens navigatie -\n + • App-profielen: maak een eigen profiel, met een aangepast pictogram en kleur +\n +\n • Nu aan te passen standaard en min / max snelheden voor elk profiel +\n +\n • Widget toegevoegd voor de huidige coördinaten +\n +\n • Opties toegevoegd om het kompas en een straalliniaal op de kaart te tonen +\n +\n • Trackregistratie op de achtergrond herstellen +\n +\n • Verbeterde downloads van achtergrondkaarten +\n +\n • \'Zet scherm aan\' optie is terug +\n +\n • Wikipedia taalkeuze aangepast +\n +\n • Vast kompasknop tijdens navigatie +\n \n • Andere fouten verholpen \n \n @@ -3567,7 +3567,7 @@ Vervang een ander punt door dit punt. Toerskiën Sneeuwscooter - Aangepaste OsmAnd-plug-in + Aangepaste OsmAnd plug-in Elementen Wijzigingen toegepast op het \'%1$s\'-profiel. Kon niet lezen van \'%1$s\'. @@ -3579,7 +3579,7 @@ Alle talen Om Wikipedia-POI’s op de kaart te tonen zijn extra kaarten nodig. Selecteer de talen voor Wikipedia-artikelen op de kaart. Tijdens het lezen van het artikel kan omgeschakeld worden naar een andere beschikbare taal. - Sommige Wikipedia-artikelen zijn mogelijk niet beschikbaar in de eigen taal. + Sommige Wikipedia-artikelen zijn mogelijk niet beschikbaar in je eigen taal. Kantonees Minnanyu Yoruba @@ -3624,8 +3624,8 @@ App-profiel wijzigingen Wereldoverzichtskaart (gedetailleerd) Niet ondersteund type - Geef de voertuigbreedte op, er zijn mogelijk routebeperkingen voor brede voertuigen. - Geef de voertuighoogte op, er zijn mogelijk routebeperkingen voor hoge voertuigen. + Geef de voertuigbreedte op, er zijn mogelijk routebeperkingen voor te brede voertuigen. + Geef de voertuighoogte op, er zijn mogelijk routebeperkingen voor te hoge voertuigen. Geef het voertuiggewicht op, er zijn mogelijk routebeperkingen voor zwaar verkeer. OsmAnd GPX is corrupt, neem contact op met het support team voor verder onderzoek. Altijd @@ -3636,7 +3636,7 @@ Scherm aanzetten bij elke routeaanwijzing. Routeaanwijzingen Uitgeschakeld. De instelling ‘Timeout na wakker worden’ moet ingesteld zijn op ‘Scherm aanlaten’. - Door op de aan/uit-knop te drukken gaat het scherm aan met OsmAnd op de voorgrond van het vergrendelscherm. + Door op de aan/uit knop te drukken gaat het scherm aan met OsmAnd op de voorgrond van het vergrendelde scherm. Aan/uit-knop Nabijheidssensor Selecteer de schermtimeout na wakker worden. (Kies “%1$s” om geen timeout te gebruiken.) @@ -3682,7 +3682,7 @@ Kies hoe gedownloade rasterkaartsegmenten worden opgeslagen. Geen overeenkomende profielen gevonden. Time-out van het scherm - Inschakelen om het zoomniveau van de kaart in te stellen met de volumeknoppen. + Regel het zoomniveau, van de kaart, met de volumeknop op het apparaat. Gebruik volumeknoppen om in en uit te zoomen Verkrijg informatie over POIs uit Wikipedia. Het is je offline reisgidsje - schakel de Wikipedia-plug-in in en geniet van artikelen over de bezienswaardigheden in je omgeving. Geef de voertuiglengte op, er zijn mogelijk routebeperkingen voor lange voertuigen. @@ -3707,7 +3707,7 @@ Het toegevoegde punt zal niet zichtbaar zijn op de kaart, aangezien de geselecteerde groep verborgen is, je kan het vinden in \"%s\". Standaard Route tussen punten - "Vervolgens, zet uw track vast op de dichtstbijzijnde toegestane weg met een van uw navigatieprofielen om deze optie te gebruiken." + Vervolgens, zet uw track vast op de dichtstbijzijnde toegestane weg met een van uw navigatieprofielen om deze optie te gebruiken. %1$s gegevens alleen beschikbaar op de wegen, u moet een route berekenen met behulp van \"Route tussen punten\" om deze te krijgen. Selecteer hoe de punten verbonden worden, via een rechte lijn, of een route berekenen tussen de punten zoals hieronder aangegeven. Alleen het volgende segment wordt opnieuw berekend met het geselecteerde profiel. @@ -3744,7 +3744,7 @@ Alleen de routelijn wordt opgeslagen, de waypoints worden verwijderd. Bewaar Route omkeren - "Selecteer een track waaraan je een nieuw segment wil toevoegen." + Selecteer een track waaraan je een nieuw segment wil toevoegen. Selecteer een trackbestand om te openen. Weet u zeker dat u alle wijzigingen in de geplande route wilt annuleren door deze te sluiten\? Opsmukken voor @@ -3771,4 +3771,12 @@ Maak een nieuwe route Open een bestaande track Plan een route + Gebruik 2-fasen A* routeringsalgoritme + Grafiek + Wacht op de herberekening van de route. +\nDe grafiek is beschikbaar na herberekening. + %1$s — %2$s + Kies een trackbestand om te volgen of importeer het, vanaf uw apparaat. + Kloof + Op maat \ No newline at end of file diff --git a/OsmAnd/res/values-pt-rBR/strings.xml b/OsmAnd/res/values-pt-rBR/strings.xml index 43ef613eb1..f6e3fc9f64 100644 --- a/OsmAnd/res/values-pt-rBR/strings.xml +++ b/OsmAnd/res/values-pt-rBR/strings.xml @@ -3819,7 +3819,7 @@ Rota reversa A trilha inteira será recalculada usando o perfil selecionado. Apenas o próximo segmento será recalculado usando o perfil selecionado. - Selecione como conectar pontos, por uma linha reta, ou calcular uma rota entre eles conforme especificado abaixo. + Escolha como conectar os pontos, por uma linha reta, ou calcular uma rota entre eles conforme especificado abaixo. Trilha inteira Próximo segmento Para usar esta opção, OsmAnd precisa ajustar sua trilha para as estradas do mapa. diff --git a/OsmAnd/res/values-zh-rTW/strings.xml b/OsmAnd/res/values-zh-rTW/strings.xml index e01741d9c3..c25c031f20 100644 --- a/OsmAnd/res/values-zh-rTW/strings.xml +++ b/OsmAnd/res/values-zh-rTW/strings.xml @@ -3821,7 +3821,7 @@ 反向路線 整個軌跡都會使用選定的設定檔重新計算。 僅下一個片段會使用選定的設定檔重新計算。 - 選取如何連接點,透過直線或以下面選定的方法計算其間的路徑。 + 選擇如何連接點,透過直線或以下面選定的方法計算其間的路徑。 整個軌道 下一段 接下來,使用您其中一個導航設定檔來將路線貼齊到最近可用的道路上以使用此選項。 diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 1905c224db..d5287d60bb 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -21,6 +21,7 @@ Amenity Gap %1$s — %2$s + Local maps Wait for the route recalculation.\nGraph will be available after recalculation. %1$s data available only on the roads, you need to calculate a route using “Route between points” to get it. Graph diff --git a/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java b/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java index b3d7ceb144..da9af5dca9 100644 --- a/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java +++ b/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java @@ -509,26 +509,27 @@ public class SQLiteTileSource implements ITileSource { if(db == null || coordinatesZoom > 25 ){ return null; } - SQLiteCursor q ; + SQLiteCursor cursor ; if (inversiveZoom) { int minZoom = (17 - minZ) + 1; // 17 - z = zoom, x << (25 - zoom) = 25th x tile = 8 + z, - q = db.rawQuery("SELECT max(x << (8+z)), min(x << (8+z)), max(y << (8+z)), min(y << (8+z))" + + cursor = db.rawQuery("SELECT max(x << (8+z)), min(x << (8+z)), max(y << (8+z)), min(y << (8+z))" + " from tiles where z < " + minZoom, new String[0]); } else { - q = db.rawQuery("SELECT max(x << (25-z)), min(x << (25-z)), max(y << (25-z)), min(y << (25-z))" + cursor = db.rawQuery("SELECT max(x << (25-z)), min(x << (25-z)), max(y << (25-z)), min(y << (25-z))" + " from tiles where z > " + minZ, new String[0]); } - q.moveToFirst(); - int right = (int) (q.getInt(0) >> (25 - coordinatesZoom)); - int left = (int) (q.getInt(1) >> (25 - coordinatesZoom)); - int top = (int) (q.getInt(3) >> (25 - coordinatesZoom)); - int bottom = (int) (q.getInt(2) >> (25 - coordinatesZoom)); + cursor.moveToFirst(); + int right = (int) (cursor.getInt(0) >> (25 - coordinatesZoom)); + int left = (int) (cursor.getInt(1) >> (25 - coordinatesZoom)); + int top = (int) (cursor.getInt(3) >> (25 - coordinatesZoom)); + int bottom = (int) (cursor.getInt(2) >> (25 - coordinatesZoom)); + + cursor.close(); + return new QuadRect(left, top, right, bottom); - - } public void deleteImage(int x, int y, int zoom) { diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index c28b110c85..b8d4ef0c92 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -44,6 +44,7 @@ import net.osmand.IProgress; import net.osmand.IndexConstants; import net.osmand.Location; import net.osmand.PlatformUtil; +import net.osmand.StateChangedListener; import net.osmand.data.DataTileManager; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; @@ -158,7 +159,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { public static final int AV_CAMERA_FOCUS_CONTINUOUS = 5; // photo shot: private static int shotId = 0; - private SoundPool sp = null; + private SoundPool soundPool = null; public static final int FULL_SCEEN_RESULT_DELAY_MS = 3000; public final CommonPreference AV_CAMERA_PICTURE_SIZE; @@ -596,6 +597,17 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { @Override public boolean init(@NonNull final OsmandApplication app, Activity activity) { + if (AV_PHOTO_PLAY_SOUND.get()) { + loadCameraSound(); + } + AV_PHOTO_PLAY_SOUND.addListener(new StateChangedListener() { + @Override + public void stateChanged(Boolean change) { + if (AV_PHOTO_PLAY_SOUND.get() && soundPool == null) { + loadCameraSound(); + } + } + }); // initializeRemoteControlRegistrationMethods(); // AudioManager am = (AudioManager) app.getSystemService(Context.AUDIO_SERVICE); // if (am != null) { @@ -604,6 +616,21 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { return true; } + private void loadCameraSound() { + if (soundPool == null) { + soundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 0); + } + if (shotId == 0) { + try { + AssetFileDescriptor assetFileDescriptor = app.getAssets().openFd("sounds/camera_click.ogg"); + shotId = soundPool.load(assetFileDescriptor, 1); + assetFileDescriptor.close(); + } catch (Exception e) { + log.error("cannot get shotId for sounds/camera_click.ogg"); + } + } + } + @Override public void registerLayers(MapActivity activity) { this.mapActivity = activity; @@ -1338,21 +1365,6 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { @Override public void surfaceCreated(SurfaceHolder holder) { try { - // load sound befor shot - if (AV_PHOTO_PLAY_SOUND.get()) { - if (sp == null) - sp = new SoundPool(5, AudioManager.STREAM_MUSIC, 0); - if (shotId == 0) { - try { - AssetFileDescriptor assetFileDescriptor = app.getAssets().openFd("sounds/camera_click.ogg"); - shotId = sp.load(assetFileDescriptor, 1); - assetFileDescriptor.close(); - } catch (Exception e) { - log.error("cannot get shotId for sounds/camera_click.ogg"); - } - } - } - Parameters parameters = cam.getParameters(); parameters.setPictureSize(selectedCamPicSize.width, selectedCamPicSize.height); log.debug("takePhotoWithCamera() set Picture size: width=" + selectedCamPicSize.width @@ -1734,6 +1746,11 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { @Override public void disable(OsmandApplication app) { + if (soundPool != null) { + soundPool.release(); + soundPool = null; + shotId = 0; + } // AudioManager am = (AudioManager) app.getSystemService(Context.AUDIO_SERVICE); // if (am != null) { // unregisterMediaListener(am); @@ -2043,8 +2060,8 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { photoJpegData = data; if (AV_PHOTO_PLAY_SOUND.get()) { - if (sp != null && shotId != 0) { - sp.play(shotId, 0.7f, 0.7f, 0, 0, 1); + if (soundPool != null && shotId != 0) { + soundPool.play(shotId, 0.7f, 0.7f, 0, 0, 1); } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/AddPOIAction.java b/OsmAnd/src/net/osmand/plus/osmedit/AddPOIAction.java index 81462b1d4d..1db6bd0542 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/AddPOIAction.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/AddPOIAction.java @@ -58,7 +58,7 @@ import java.util.List; import java.util.Map; import static net.osmand.plus.osmedit.AdvancedEditPoiFragment.addPoiToStringSet; -import static net.osmand.plus.osmedit.EditPoiData.POI_TYPE_TAG; +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; public class AddPOIAction extends QuickAction { public static final QuickActionType TYPE = new QuickActionType(13, @@ -140,7 +140,7 @@ public class AddPOIAction extends QuickAction { Node newNode = new Node(node.getLatitude(), node.getLongitude(), node.getId()); OsmPoint.Action action = newNode.getId() < 0 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY; for (Map.Entry tag : editPoiData.getTagValues().entrySet()) { - if (tag.getKey().equals(EditPoiData.POI_TYPE_TAG)) { + if (tag.getKey().equals(POI_TYPE_TAG)) { final PoiType poiType = editPoiData.getAllTranslatedSubTypes().get(tag.getValue().trim().toLowerCase()); if (poiType != null) { newNode.putTagNoLC(poiType.getEditOsmTag(), poiType.getEditOsmValue()); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java index 3eabf35f6c..b538ccd0c5 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java @@ -28,6 +28,7 @@ import net.osmand.osm.MapPoiTypes; import net.osmand.osm.PoiCategory; import net.osmand.osm.PoiFilter; import net.osmand.osm.PoiType; +import net.osmand.osm.edit.Entity; import net.osmand.osm.edit.OSMSettings; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -112,7 +113,7 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment if (Algorithms.objectEquals(anyTag, OSMSettings.OSMTagKey.NAME.getValue())) { updateName(); } - if (Algorithms.objectEquals(anyTag, EditPoiData.POI_TYPE_TAG)) { + if (Algorithms.objectEquals(anyTag, Entity.POI_TYPE_TAG)) { updatePoiType(); } } @@ -197,9 +198,9 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment currentPoiTypeKey = pt.getEditOsmTag(); } for (Entry tag : editPoiData.getTagValues().entrySet()) { - if (tag.getKey().equals(EditPoiData.POI_TYPE_TAG) + if (tag.getKey().equals(Entity.POI_TYPE_TAG) || tag.getKey().equals(OSMSettings.OSMTagKey.NAME.getValue()) - || tag.getKey().startsWith(EditPoiData.REMOVE_TAG_PREFIX) + || tag.getKey().startsWith(Entity.REMOVE_TAG_PREFIX) || tag.getKey().equals(currentPoiTypeKey)) continue; addTagView(tag.getKey(), tag.getValue()); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java index 9a47563fe4..eb2b7b8c2b 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuBuilder.java @@ -5,6 +5,7 @@ import android.view.View; import androidx.annotation.NonNull; import net.osmand.osm.PoiType; +import net.osmand.osm.edit.Entity; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.MenuBuilder; @@ -12,6 +13,8 @@ import net.osmand.plus.render.RenderingIcons; import java.util.Map; +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; + public class EditPOIMenuBuilder extends MenuBuilder { private final OsmPoint osmPoint; @@ -38,7 +41,7 @@ public class EditPOIMenuBuilder extends MenuBuilder { OpenstreetmapPoint point = (OpenstreetmapPoint) osmPoint; for (Map.Entry e : point.getEntity().getTags().entrySet()) { - if (EditPoiData.POI_TYPE_TAG.equals(e.getKey())) { + if (POI_TYPE_TAG.equals(e.getKey())) { String poiTranslation = e.getValue(); Map poiTypeMap = app.getPoiTypes().getAllTranslatedNames(false); PoiType poiType = poiTypeMap.get(poiTranslation.toLowerCase()); @@ -63,8 +66,8 @@ public class EditPOIMenuBuilder extends MenuBuilder { } for (Map.Entry e : point.getEntity().getTags().entrySet()) { - if (EditPoiData.POI_TYPE_TAG.equals(e.getKey()) || - e.getKey().startsWith(EditPoiData.REMOVE_TAG_PREFIX)) { + if (POI_TYPE_TAG.equals(e.getKey()) || + e.getKey().startsWith(Entity.REMOVE_TAG_PREFIX)) { continue; } String text = e.getKey() + "=" + e.getValue(); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java index 7d04c73252..8134e5a3be 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java @@ -18,6 +18,8 @@ import net.osmand.util.Algorithms; import java.util.Map; +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; + public class EditPOIMenuController extends MenuController { private OsmPoint osmPoint; @@ -166,7 +168,7 @@ public class EditPOIMenuController extends MenuController { if (osmPoint.getGroup() == OsmPoint.Group.POI) { OpenstreetmapPoint osmP = (OpenstreetmapPoint) osmPoint; int iconResId = 0; - String poiTranslation = osmP.getEntity().getTag(EditPoiData.POI_TYPE_TAG); + String poiTranslation = osmP.getEntity().getTag(POI_TYPE_TAG); MapActivity mapActivity = getMapActivity(); if (poiTranslation != null && mapActivity != null) { Map poiTypeMap = mapActivity.getMyApplication().getPoiTypes().getAllTranslatedNames(false); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java index b11c828436..7dab7780b0 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java @@ -17,15 +17,15 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; + public class EditPoiData { private static final Log LOG = PlatformUtil.getLog(EditPoiData.class); private Set mListeners = new HashSet<>(); - private LinkedHashMap tagValues = new LinkedHashMap(); + private final LinkedHashMap tagValues = new LinkedHashMap(); private boolean isInEdit = false; private Entity entity; - - public static final String POI_TYPE_TAG = "poi_type_tag"; - public static final String REMOVE_TAG_PREFIX = "----"; + public static final String REMOVE_TAG_VALUE = "DELETE"; private boolean hasChangesBeenMade = false; private Map allTranslatedSubTypes; @@ -123,7 +123,7 @@ public class EditPoiData { checkNotInEdit(); try { isInEdit = true; - tagValues.remove(REMOVE_TAG_PREFIX+tag); + tagValues.remove(Entity.REMOVE_TAG_PREFIX + tag); String oldValue = tagValues.get(tag); if (oldValue == null || !oldValue.equals(value)) { changedTags.add(tag); @@ -154,9 +154,9 @@ public class EditPoiData { public void removeTag(String tag) { checkNotInEdit(); - try { + try { isInEdit = true; - tagValues.put(REMOVE_TAG_PREFIX+tag, REMOVE_TAG_VALUE); + tagValues.put(Entity.REMOVE_TAG_PREFIX + tag, REMOVE_TAG_VALUE); tagValues.remove(tag); changedTags.remove(tag); notifyDatasetChanged(tag); @@ -216,7 +216,7 @@ public class EditPoiData { PoiType pt = getPoiTypeDefined(); String editOsmTag = pt != null ? pt.getEditOsmTag() : null; if (editOsmTag != null) { - removeTypeTagWithPrefix(!tagValues.containsKey(REMOVE_TAG_PREFIX + editOsmTag)); + removeTypeTagWithPrefix(!tagValues.containsKey(Entity.REMOVE_TAG_PREFIX + editOsmTag)); currentPoiType = pt; String tagVal = pt.getEditOsmValue() != null ? pt.getEditOsmValue() : ""; tagValues.put(editOsmTag, tagVal); @@ -237,11 +237,11 @@ public class EditPoiData { private void removeTypeTagWithPrefix(boolean needRemovePrefix) { if (currentPoiType != null) { if (needRemovePrefix) { - tagValues.put(REMOVE_TAG_PREFIX + currentPoiType.getEditOsmTag(), REMOVE_TAG_VALUE); - tagValues.put(REMOVE_TAG_PREFIX + currentPoiType.getOsmTag2(), REMOVE_TAG_VALUE); + tagValues.put(Entity.REMOVE_TAG_PREFIX + currentPoiType.getEditOsmTag(), REMOVE_TAG_VALUE); + tagValues.put(Entity.REMOVE_TAG_PREFIX + currentPoiType.getOsmTag2(), REMOVE_TAG_VALUE); } else { - tagValues.remove(REMOVE_TAG_PREFIX + currentPoiType.getEditOsmTag()); - tagValues.remove(REMOVE_TAG_PREFIX + currentPoiType.getOsmTag2()); + tagValues.remove(Entity.REMOVE_TAG_PREFIX + currentPoiType.getEditOsmTag()); + tagValues.remove(Entity.REMOVE_TAG_PREFIX + currentPoiType.getOsmTag2()); } removeCurrentTypeTag(); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java index 7c0edb7168..ecdc776c78 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java @@ -90,6 +90,8 @@ import java.util.Set; import studio.carbonylgroup.textfieldboxes.ExtendedEditText; +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; + public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { public static final String TAG = EditPoiDialogFragment.class.getSimpleName(); private static final Log LOG = PlatformUtil.getLog(EditPoiDialogFragment.class); @@ -499,21 +501,21 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { Action action = entity.getId() < 0 ? Action.CREATE : Action.MODIFY; for (Map.Entry tag : editPoiData.getTagValues().entrySet()) { - if (!Algorithms.isEmpty(tag.getKey()) && !Algorithms.isEmpty(tag.getValue()) && - !tag.getKey().equals(EditPoiData.POI_TYPE_TAG)) { + if (!Algorithms.isEmpty(tag.getKey()) && !Algorithms.isEmpty(tag.getValue()) && + !tag.getKey().equals(POI_TYPE_TAG)) { entity.putTagNoLC(tag.getKey(), tag.getValue()); } } - String poiTypeTag = editPoiData.getTagValues().get(EditPoiData.POI_TYPE_TAG); + String poiTypeTag = editPoiData.getTagValues().get(POI_TYPE_TAG); String comment = ""; if (poiTypeTag != null) { final PoiType poiType = editPoiData.getAllTranslatedSubTypes().get(poiTypeTag.trim().toLowerCase()); if (poiType != null) { entity.putTagNoLC(poiType.getEditOsmTag(), poiType.getEditOsmValue()); - entity.removeTag(EditPoiData.REMOVE_TAG_PREFIX + poiType.getEditOsmTag()); + entity.removeTag(Entity.REMOVE_TAG_PREFIX + poiType.getEditOsmTag()); if (poiType.getOsmTag2() != null) { entity.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2()); - entity.removeTag(EditPoiData.REMOVE_TAG_PREFIX + poiType.getOsmTag2()); + entity.removeTag(Entity.REMOVE_TAG_PREFIX + poiType.getOsmTag2()); } } else if (!Algorithms.isEmpty(poiTypeTag)) { PoiCategory category = editPoiData.getPoiCategory(); @@ -522,7 +524,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { } } if (offlineEdit && !Algorithms.isEmpty(poiTypeTag)) { - entity.putTagNoLC(EditPoiData.POI_TYPE_TAG, poiTypeTag); + entity.putTagNoLC(POI_TYPE_TAG, poiTypeTag); } String actionString = action == Action.CREATE ? getString(R.string.default_changeset_add) : getString(R.string.default_changeset_edit); comment = actionString + " " + poiTypeTag; diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java index c55e2099ed..26eda5f4e5 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java @@ -24,6 +24,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; + public class OpenstreetmapLocalUtil implements OpenstreetmapUtil { public final static Log LOG = PlatformUtil.getLog(OpenstreetmapLocalUtil.class); @@ -122,7 +124,7 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil { entity = new Node(loc.getLatitude(), loc.getLongitude(), entityId); } if (poiType != null) { - entity.putTagNoLC(EditPoiData.POI_TYPE_TAG, poiType.getTranslation()); + entity.putTagNoLC(POI_TYPE_TAG, poiType.getTranslation()); if (poiType.getOsmTag2() != null) { entity.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2()); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java index 69bc753ab4..d7c17c1ec2 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java @@ -28,7 +28,7 @@ public class OpenstreetmapPoint extends OsmPoint { String type = "amenity"; for (String k : entity.getTagKeySet()) { if (!OSMTagKey.NAME.getValue().equals(k) && !OSMTagKey.OPENING_HOURS.getValue().equals(k) && - !k.startsWith(EditPoiData.REMOVE_TAG_PREFIX)) { + !k.startsWith(Entity.REMOVE_TAG_PREFIX)) { type = k; break; } @@ -75,6 +75,20 @@ public class OpenstreetmapPoint extends OsmPoint { this.comment = comment; } + public String getTagsString() { + StringBuilder sb = new StringBuilder(); + for (String tag : entity.getTagKeySet()) { + String val = entity.getTag(tag); + if (entity.isNotValid(tag)) { + continue; + } + sb.append(tag).append(" : "); + sb.append(val).append("; "); + } + return sb.toString(); + } + + @Override public String toString() { return new StringBuffer("Openstreetmap Point ").append(this.getAction()).append(" ").append(this.getName()) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java index b90a22c0b9..8940093c19 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java @@ -39,7 +39,8 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; -import java.util.concurrent.ExecutionException; + +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { @@ -273,8 +274,8 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { throws IllegalArgumentException, IllegalStateException, IOException { for (String k : entity.getTagKeySet()) { String val = entity.getTag(k); - if (val.length() == 0 || k.length() == 0 || EditPoiData.POI_TYPE_TAG.equals(k) || - k.startsWith(EditPoiData.REMOVE_TAG_PREFIX) || k.contains(EditPoiData.REMOVE_TAG_PREFIX)) + if (val.length() == 0 || k.length() == 0 || POI_TYPE_TAG.equals(k) || + k.startsWith(Entity.REMOVE_TAG_PREFIX) || k.contains(Entity.REMOVE_TAG_PREFIX)) continue; ser.startTag(null, "tag"); //$NON-NLS-1$ ser.attribute(null, "k", k); //$NON-NLS-1$ @@ -455,7 +456,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { } private boolean deletedTag(Entity entity, String tag) { - return entity.getTagKeySet().contains(EditPoiData.REMOVE_TAG_PREFIX + tag); + return entity.getTagKeySet().contains(Entity.REMOVE_TAG_PREFIX + tag); } @Override @@ -542,12 +543,12 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { PoiType poiType = type.getPoiTypeByKeyName(subType); if (poiType != null && poiType.getEditOsmValue().equals(entity.getTag(poiType.getEditOsmTag()))) { entity.removeTag(poiType.getEditOsmTag()); - entity.putTagNoLC(EditPoiData.POI_TYPE_TAG, poiType.getTranslation()); + entity.putTagNoLC(POI_TYPE_TAG, poiType.getTranslation()); } else { for (PoiType pt : type.getPoiTypes()) { if (pt.getEditOsmValue().equals(entity.getTag(pt.getEditOsmTag()))) { entity.removeTag(pt.getEditOsmTag()); - entity.putTagNoLC(EditPoiData.POI_TYPE_TAG, pt.getTranslation()); + entity.putTagNoLC(POI_TYPE_TAG, pt.getTranslation()); } } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index ea779a93b1..5b9b9eb7ce 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -5,8 +5,12 @@ import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.Intent; +import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.AsyncTask; +import android.text.SpannableString; +import android.text.TextUtils; +import android.text.style.StyleSpan; import android.view.LayoutInflater; import android.view.View; import android.widget.ArrayAdapter; @@ -57,6 +61,7 @@ import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_C import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_OPEN_OSM_NOTE; import static net.osmand.aidlapi.OsmAndCustomizationConstants.OSM_EDITS; import static net.osmand.aidlapi.OsmAndCustomizationConstants.OSM_NOTES; +import static net.osmand.osm.edit.Entity.POI_TYPE_TAG; import static net.osmand.plus.ContextMenuAdapter.makeDeleteAction; @@ -528,6 +533,15 @@ public class OsmEditingPlugin extends OsmandPlugin { } } + public static SpannableString getTitle(OsmPoint osmPoint, Context ctx) { + SpannableString title = new SpannableString(getName(osmPoint)); + if (TextUtils.isEmpty(title)) { + title = SpannableString.valueOf(getCategory(osmPoint, ctx)); + title.setSpan(new StyleSpan(Typeface.ITALIC), 0, title.length(), 0); + } + return title; + } + public static String getName(OsmPoint point) { if (point.getGroup() == OsmPoint.Group.POI) { return ((OpenstreetmapPoint) point).getName(); @@ -541,7 +555,7 @@ public class OsmEditingPlugin extends OsmandPlugin { public static String getCategory(OsmPoint osmPoint, Context context) { String category = ""; if (osmPoint.getGroup() == OsmPoint.Group.POI) { - category = ((OpenstreetmapPoint) osmPoint).getEntity().getTag(EditPoiData.POI_TYPE_TAG); + category = ((OpenstreetmapPoint) osmPoint).getEntity().getTag(POI_TYPE_TAG); if (Algorithms.isEmpty(category)) { category = context.getString(R.string.shared_string_without_name); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java index f965318109..d4c2ad099f 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsAdapter.java @@ -1,11 +1,7 @@ package net.osmand.plus.osmedit; import android.content.Context; -import android.graphics.Typeface; import android.graphics.drawable.Drawable; -import android.text.SpannableString; -import android.text.TextUtils; -import android.text.style.StyleSpan; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -21,6 +17,7 @@ import androidx.annotation.NonNull; import androidx.core.content.ContextCompat; import net.osmand.osm.PoiType; +import net.osmand.osm.edit.Entity; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; @@ -182,7 +179,7 @@ public class OsmEditsAdapter extends ArrayAdapter { private void bindOsmEditViewHolder(final OsmEditViewHolder holder, final OsmPoint osmEdit, final int position) { setupBackground(holder.mainView); - holder.titleTextView.setText(getTitle(osmEdit)); + holder.titleTextView.setText(OsmEditingPlugin.getTitle(osmEdit, getContext())); holder.descriptionTextView.setText(getDescription(osmEdit)); Drawable icon = getIcon(osmEdit); if (icon != null) { @@ -243,20 +240,12 @@ public class OsmEditsAdapter extends ArrayAdapter { return items.size(); } - private SpannableString getTitle(OsmPoint osmPoint) { - SpannableString title = new SpannableString(OsmEditingPlugin.getName(osmPoint)); - if (TextUtils.isEmpty(title)) { - title = SpannableString.valueOf(getCategory(osmPoint)); - title.setSpan(new StyleSpan(Typeface.ITALIC), 0, title.length(), 0); - } - return title; - } private Drawable getIcon(OsmPoint point) { if (point.getGroup() == OsmPoint.Group.POI) { OpenstreetmapPoint osmPoint = (OpenstreetmapPoint) point; int iconResId = 0; - String poiTranslation = osmPoint.getEntity().getTag(EditPoiData.POI_TYPE_TAG); + String poiTranslation = osmPoint.getEntity().getTag(Entity.POI_TYPE_TAG); if (poiTranslation != null) { Map poiTypeMap = app.getPoiTypes().getAllTranslatedNames(false); PoiType poiType = poiTypeMap.get(poiTranslation.toLowerCase()); @@ -304,10 +293,6 @@ public class OsmEditsAdapter extends ArrayAdapter { return true; } - private String getCategory(OsmPoint point) { - return OsmEditingPlugin.getCategory(point, getContext()); - } - private String getDescription(OsmPoint point) { return OsmEditingPlugin.getDescription(point, getContext(), true); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java index f39b695d50..40f62e55b6 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java @@ -781,7 +781,7 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo if (point.getGroup() == Group.POI) { OpenstreetmapPoint p = (OpenstreetmapPoint) point; WptPt wpt = new WptPt(); - wpt.name = getTagsString(p); + wpt.name = p.getTagsString(); wpt.lat = p.getLatitude(); wpt.lon = p.getLongitude(); wpt.desc = "id: " + String.valueOf(p.getId()) + @@ -817,24 +817,6 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo return sb.toString(); } - private String getTagsString(OpenstreetmapPoint point) { - StringBuilder sb = new StringBuilder(); - for (String tag : point.getEntity().getTagKeySet()) { - String val = point.getEntity().getTag(tag); - if (isNotValid(tag, val)) { - continue; - } - sb.append(tag).append(" : "); - sb.append(val).append("; "); - } - return sb.toString(); - } - - private boolean isNotValid(String tag, String val) { - return val == null || val.length() == 0 || tag.length() == 0 - || tag.startsWith(EditPoiData.REMOVE_TAG_PREFIX) || tag.equals("poi_type_tag"); - } - private void writeContent(XmlSerializer sz, OsmPoint[] points, OsmPoint.Action a) throws IllegalArgumentException, IllegalStateException, IOException { for (OsmPoint point : points) { if (point.getGroup() == Group.POI) { @@ -878,7 +860,7 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo private void writeTags(XmlSerializer sz, Entity p) { for (String tag : p.getTagKeySet()) { String val = p.getTag(tag); - if (isNotValid(tag, val)) { + if (p.isNotValid(tag)) { continue; } try { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java index 99947c7de2..59c07afbaa 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java @@ -101,7 +101,7 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC if (osmPoint.getGroup() == OsmPoint.Group.POI) { OpenstreetmapPoint osmP = (OpenstreetmapPoint) osmPoint; int iconResId = 0; - String poiTranslation = osmP.getEntity().getTag(EditPoiData.POI_TYPE_TAG); + String poiTranslation = osmP.getEntity().getTag(Entity.POI_TYPE_TAG); if (poiTranslation != null && activity != null) { Map poiTypeMap = activity.getMyApplication().getPoiTypes().getAllTranslatedNames(false); PoiType poiType = poiTypeMap.get(poiTranslation.toLowerCase()); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java index 7af0286ae4..d402cdfe49 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java @@ -16,13 +16,13 @@ import androidx.appcompat.widget.SwitchCompat; import androidx.fragment.app.DialogFragment; import net.osmand.osm.PoiType; +import net.osmand.osm.edit.Entity; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.dialogs.ProgressDialogFragment; -import net.osmand.plus.osmedit.EditPoiData; import net.osmand.plus.osmedit.OpenstreetmapPoint; import net.osmand.plus.osmedit.OsmBugsLayer; import net.osmand.plus.osmedit.OsmEditingPlugin; @@ -152,7 +152,7 @@ public class SendPoiDialogFragment extends DialogFragment { for (OsmPoint p : poi) { if (p.getGroup() == OsmPoint.Group.POI) { OsmPoint.Action action = p.getAction(); - String type = ((OpenstreetmapPoint) p).getEntity().getTag(EditPoiData.POI_TYPE_TAG); + String type = ((OpenstreetmapPoint) p).getEntity().getTag(Entity.POI_TYPE_TAG); if (type == null) { continue; } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java index 8537c8df7a..d805cde0df 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java @@ -1,11 +1,8 @@ package net.osmand.plus.routepreparationmenu; -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.Intent; -import android.graphics.drawable.AnimationDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; @@ -19,7 +16,6 @@ import android.view.ViewGroup.MarginLayoutParams; import android.view.ViewTreeObserver.OnScrollChangedListener; import android.widget.FrameLayout; import android.widget.ImageButton; -import android.widget.ImageView; import android.widget.LinearLayout; import androidx.annotation.NonNull; @@ -37,6 +33,7 @@ import net.osmand.data.RotatedTileBox; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; +import net.osmand.plus.SimplePopUpMenuItemAdapter.SimplePopUpMenuItem; import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities.DialogButtonType; import net.osmand.plus.activities.MapActivity; @@ -44,6 +41,7 @@ import net.osmand.plus.base.ContextMenuScrollFragment; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; +import net.osmand.plus.helpers.enums.TracksSortByMode; import net.osmand.plus.importfiles.ImportHelper; import net.osmand.plus.importfiles.ImportHelper.OnGpxImportCompleteListener; import net.osmand.plus.measurementtool.GpxData; @@ -71,6 +69,7 @@ import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; import java.io.File; +import java.util.ArrayList; import java.util.List; @@ -89,6 +88,10 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca private GPXFile gpxFile; private View buttonsShadow; + private ImageButton sortButton; + + private TracksToFollowCard tracksCard; + private TracksSortByMode sortByMode = TracksSortByMode.BY_DATE; private boolean editingTrack; private boolean selectingTrack; @@ -166,6 +169,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca } setupCards(); setupButtons(view); + setupSortButton(view); setupScrollShadow(); if (!isPortrait()) { int widthNoShadow = getLandscapeNoShadowWidth(); @@ -202,10 +206,6 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca cardsContainer.removeAllViews(); if (gpxFile == null || selectingTrack) { - ImportTrackCard importTrackCard = new ImportTrackCard(mapActivity); - importTrackCard.setListener(this); - cardsContainer.addView(importTrackCard.build(mapActivity)); - setupTracksCard(); } else { String fileName = null; @@ -265,7 +265,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca List list = GpxUiHelper.getSortedGPXFilesInfo(dir, selectedTrackNames, false); if (list.size() > 0) { String defaultCategory = app.getString(R.string.shared_string_all); - TracksToFollowCard tracksCard = new TracksToFollowCard(mapActivity, list, defaultCategory); + tracksCard = new TracksToFollowCard(mapActivity, list, defaultCategory); tracksCard.setListener(FollowTrackFragment.this); getCardsContainer().addView(tracksCard.build(mapActivity)); } @@ -601,6 +601,36 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca } } + private void setupSortButton(View view) { + final ImageButton sortButton = view.findViewById(R.id.sort_button); + int colorId = isNightMode() ? R.color.inactive_buttons_and_links_bg_dark : R.color.inactive_buttons_and_links_bg_light; + Drawable background = app.getUIUtilities().getIcon(R.drawable.bg_dash_line_dark, colorId); + sortButton.setImageResource(sortByMode.getIconId()); + AndroidUtils.setBackground(sortButton, background); + sortButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + List items = new ArrayList<>(); + for (final TracksSortByMode mode : TracksSortByMode.values()) { + items.add(new SimplePopUpMenuItem(getString(mode.getNameId()), + app.getUIUtilities().getThemedIcon(mode.getIconId()), + new View.OnClickListener() { + @Override + public void onClick(View v) { + sortByMode = mode; + sortButton.setImageResource(mode.getIconId()); + if (tracksCard != null) { + tracksCard.setSortByMode(mode); + } + } + }, sortByMode == mode + )); + } + UiUtilities.showPopUpMenu(v, items); + } + }); + } + private void setupButtons(View view) { View buttonsContainer = view.findViewById(R.id.buttons_container); buttonsContainer.setBackgroundColor(AndroidUtils.getColorFromAttr(view.getContext(), R.attr.bg_color)); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksToFollowCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksToFollowCard.java index c21b508116..0897894730 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksToFollowCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TracksToFollowCard.java @@ -3,30 +3,36 @@ package net.osmand.plus.routepreparationmenu.cards; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import net.osmand.Collator; import net.osmand.IndexConstants; +import net.osmand.OsmAndCollator; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.GpxTrackAdapter; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; +import net.osmand.plus.helpers.enums.TracksSortByMode; import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter; import net.osmand.util.Algorithms; import java.io.File; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; public class TracksToFollowCard extends BaseCard { + private List gpxInfoList; private Map> gpxInfoCategories; - private List gpxInfoList; - private String selectedCategory; + private GpxTrackAdapter tracksAdapter; + private TracksSortByMode sortByMode = TracksSortByMode.BY_DATE; + private String defaultCategory; private String visibleCategory; - - private GpxTrackAdapter tracksAdapter; + private String selectedCategory; public TracksToFollowCard(MapActivity mapActivity, List gpxInfoList, String selectedCategory) { super(mapActivity); @@ -37,9 +43,10 @@ public class TracksToFollowCard extends BaseCard { gpxInfoCategories = getGpxInfoCategories(); } - public void setGpxInfoList(List gpxInfoList) { - this.gpxInfoList = gpxInfoList; + public void setSortByMode(TracksSortByMode sortByMode) { + this.sortByMode = sortByMode; gpxInfoCategories = getGpxInfoCategories(); + updateTracksAdapter(); } public List getGpxInfoList() { @@ -91,11 +98,8 @@ public class TracksToFollowCard extends BaseCard { @Override public void onItemSelected(HorizontalSelectionAdapter.HorizontalSelectionItem item) { selectedCategory = item.getTitle(); - List items = gpxInfoCategories.get(selectedCategory); tracksAdapter.setShowFolderName(showFoldersName()); - tracksAdapter.setGpxInfoList(items != null ? items : new ArrayList()); - tracksAdapter.notifyDataSetChanged(); - + updateTracksAdapter(); selectionAdapter.notifyDataSetChanged(); } }); @@ -106,6 +110,12 @@ public class TracksToFollowCard extends BaseCard { selectionAdapter.notifyDataSetChanged(); } + private void updateTracksAdapter() { + List items = gpxInfoCategories.get(selectedCategory); + tracksAdapter.setGpxInfoList(items != null ? items : new ArrayList()); + tracksAdapter.notifyDataSetChanged(); + } + private boolean showFoldersName() { return defaultCategory.equals(selectedCategory) || visibleCategory.equals(selectedCategory); } @@ -116,6 +126,7 @@ public class TracksToFollowCard extends BaseCard { gpxInfoCategories.put(visibleCategory, new ArrayList()); gpxInfoCategories.put(defaultCategory, new ArrayList()); + sortGPXInfoItems(gpxInfoList); for (GPXInfo info : gpxInfoList) { if (info.isSelected()) { addGpxInfoCategory(gpxInfoCategories, info, visibleCategory); @@ -141,4 +152,25 @@ public class TracksToFollowCard extends BaseCard { } items.add(info); } + + public void sortGPXInfoItems(List gpxInfoList) { + final Collator collator = OsmAndCollator.primaryCollator(); + Collections.sort(gpxInfoList, new Comparator() { + @Override + public int compare(GPXInfo i1, GPXInfo i2) { + if (sortByMode == TracksSortByMode.BY_NAME_ASCENDING) { + return collator.compare(i1.getFileName(), i2.getFileName()); + } else if (sortByMode == TracksSortByMode.BY_NAME_DESCENDING) { + return -collator.compare(i1.getFileName(), i2.getFileName()); + } else { + long time1 = i1.getLastModified(); + long time2 = i2.getLastModified(); + if (time1 == time2) { + return collator.compare(i1.getFileName(), i2.getFileName()); + } + return -((time1 < time2) ? -1 : ((time1 == time2) ? 0 : 1)); + } + } + }); + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java index b4cabfb389..4358938079 100644 --- a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java +++ b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java @@ -1,20 +1,22 @@ package net.osmand.plus.routing; +import android.content.res.AssetFileDescriptor; import android.media.AudioManager; import android.media.SoundPool; import net.osmand.Location; +import net.osmand.StateChangedListener; import net.osmand.binary.RouteDataObject; import net.osmand.data.PointDescription; -import net.osmand.plus.settings.backend.ApplicationMode; -import net.osmand.plus.settings.backend.OsmAndAppCustomization.OsmAndAppCustomizationListener; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper; import net.osmand.plus.routing.AlarmInfo.AlarmInfoType; import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo; import net.osmand.plus.routing.data.StreetName; +import net.osmand.plus.settings.backend.ApplicationMode; +import net.osmand.plus.settings.backend.OsmAndAppCustomization.OsmAndAppCustomizationListener; +import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.voice.AbstractPrologCommandPlayer; import net.osmand.plus.voice.CommandBuilder; import net.osmand.plus.voice.CommandPlayer; @@ -80,7 +82,10 @@ public class VoiceRouter { private int TURN_IN_DISTANCE; private int TURN_IN_DISTANCE_END; private int TURN_NOW_DISTANCE; - + + private SoundPool soundPool; + private int soundClick = -1; + private VoiceCommandPending pendingCommand = null; private RouteDirectionInfo nextRouteDirection; @@ -103,8 +108,36 @@ public class VoiceRouter { } }; app.getAppCustomization().addListener(customizationListener); + + if (!isMute()) { + loadCameraSound(); + } + settings.VOICE_MUTE.addListener(new StateChangedListener() { + @Override + public void stateChanged(Boolean change) { + if (!isMute() && soundPool == null) { + loadCameraSound(); + } + } + }); } - + + private void loadCameraSound() { + if (soundPool == null) { + soundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 0); + } + if (soundClick == -1) { + try { + // Taken unaltered from https://freesound.org/people/Corsica_S/sounds/91926/ under license http://creativecommons.org/licenses/by/3.0/ : + AssetFileDescriptor assetFileDescriptor = app.getAssets().openFd("sounds/ding.ogg"); + soundClick = soundPool.load(assetFileDescriptor, 1); + assetFileDescriptor.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + public void setPlayer(CommandPlayer player) { this.player = player; if (pendingCommand != null && player != null) { @@ -1015,18 +1048,8 @@ public class VoiceRouter { if (isMute()) { return; } - SoundPool sp = new SoundPool(5, AudioManager.STREAM_MUSIC, 0); - int soundClick = -1; - boolean success = true; - try { - // Taken unaltered from https://freesound.org/people/Corsica_S/sounds/91926/ under license http://creativecommons.org/licenses/by/3.0/ : - soundClick = sp.load(settings.getContext().getAssets().openFd("sounds/ding.ogg"), 1); - } catch (IOException e) { - e.printStackTrace(); - success = false; - } - if (success) { - sp.play(soundClick, 1 ,1, 0, 0, 1); + if (soundPool != null && soundClick != -1) { + soundPool.play(soundClick, 1, 1, 0, 0, 1); } } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java b/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java index 4f8420cb11..17901458ec 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java @@ -10,5 +10,8 @@ public enum ExportSettingsType { AVOID_ROADS, TRACKS, MULTIMEDIA_NOTES, - GLOBAL + GLOBAL, + OSM_NOTES, + OSM_EDITS, + OFFLINE_MAPS } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java index 357c0aadbf..097e64b0d2 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/FileSettingsItem.java @@ -21,11 +21,15 @@ import java.io.OutputStream; public class FileSettingsItem extends StreamSettingsItem { + + public enum FileSubtype { UNKNOWN("", null), OTHER("other", ""), ROUTING_CONFIG("routing_config", IndexConstants.ROUTING_PROFILES_DIR), RENDERING_STYLE("rendering_style", IndexConstants.RENDERERS_DIR), + WIKI_MAP("wiki_map", IndexConstants.WIKI_INDEX_DIR), + SRTM_MAP("srtm_map", IndexConstants.SRTM_INDEX_DIR), OBF_MAP("obf_map", IndexConstants.MAPS_PATH), TILES_MAP("tiles_map", IndexConstants.TILES_INDEX_DIR), GPX("gpx", IndexConstants.GPX_INDEX_DIR), @@ -41,6 +45,10 @@ public class FileSettingsItem extends StreamSettingsItem { this.subtypeFolder = subtypeFolder; } + public boolean isMap() { + return this == OBF_MAP || this == WIKI_MAP || this == SRTM_MAP; + } + public String getSubtypeName() { return subtypeName; } @@ -68,8 +76,18 @@ public class FileSettingsItem extends StreamSettingsItem { case UNKNOWN: case OTHER: break; + case SRTM_MAP: + if (name.endsWith(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT)) { + return subtype; + } + break; + case WIKI_MAP: + if (name.endsWith(IndexConstants.BINARY_WIKI_MAP_INDEX_EXT)) { + return subtype; + } + break; case OBF_MAP: - if (name.endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) { + if (name.endsWith(IndexConstants.BINARY_MAP_INDEX_EXT) && !name.contains(File.separator)) { return subtype; } break; @@ -93,6 +111,7 @@ public class FileSettingsItem extends StreamSettingsItem { protected File file; private File appPath; protected FileSubtype subtype; + private long size; public FileSettingsItem(@NonNull OsmandApplication app, @NonNull File file) throws IllegalArgumentException { super(app, file.getPath().replace(app.getAppPath(null).getPath(), "")); @@ -171,6 +190,14 @@ public class FileSettingsItem extends StreamSettingsItem { } } + public long getSize() { + return size; + } + + public void setSize(long size) { + this.size = size; + } + @NonNull public File getFile() { return file; diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java new file mode 100644 index 0000000000..03e1e39ad5 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java @@ -0,0 +1,199 @@ +package net.osmand.plus.settings.backend.backup; + +import android.content.Context; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; + +import net.osmand.osm.edit.Entity; +import net.osmand.osm.edit.Node; +import net.osmand.osm.edit.Way; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandPlugin; +import net.osmand.plus.R; +import net.osmand.plus.osmedit.OpenstreetmapPoint; +import net.osmand.plus.osmedit.OpenstreetmapsDbHelper; +import net.osmand.plus.osmedit.OsmEditingPlugin; +import net.osmand.plus.osmedit.OsmPoint; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class OsmEditsSettingsItem extends CollectionSettingsItem { + + public static final String ID_KEY = "id"; + public static final String NAME_KEY = "name"; + public static final String LAT_KEY = "lat"; + public static final String LON_KEY = "lon"; + public static final String COMMENT_KEY = "comment"; + public static final String ACTION_KEY = "action"; + public static final String TYPE_KEY = "type"; + public static final String TAGS_KEY = "tags"; + public static final String ENTITY_KEY = "entity"; + + public OsmEditsSettingsItem(@NonNull OsmandApplication app, @NonNull List items) { + super(app, null, items); + } + + public OsmEditsSettingsItem(@NonNull OsmandApplication app, @Nullable OsmEditsSettingsItem baseItem, + @NonNull List items) { + super(app, baseItem, items); + } + + public OsmEditsSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException { + super(app, json); + } + + @Override + protected void init() { + super.init(); + OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); + if (osmEditingPlugin != null) { + existingItems = osmEditingPlugin.getDBPOI().getOpenstreetmapPoints(); + } + } + + @NonNull + @Override + public SettingsItemType getType() { + return SettingsItemType.OSM_EDITS; + } + + @Override + public void apply() { + List newItems = getNewItems(); + if (!newItems.isEmpty() || !duplicateItems.isEmpty()) { + appliedItems = new ArrayList<>(newItems); + + for (OpenstreetmapPoint duplicate : duplicateItems) { + appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate)); + } + } + OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); + if (osmEditingPlugin != null) { + OpenstreetmapsDbHelper db = osmEditingPlugin.getDBPOI(); + for (OpenstreetmapPoint point : appliedItems) { + db.addOpenstreetmap(point); + } + } + } + + @Override + public boolean isDuplicate(@NonNull OpenstreetmapPoint item) { + return false; + } + + @NonNull + @Override + public OpenstreetmapPoint renameItem(@NonNull OpenstreetmapPoint item) { + return item; + } + + @NonNull + @Override + public String getName() { + return "osm_edits"; + } + + @NonNull + @Override + public String getPublicName(@NonNull Context ctx) { + return ctx.getString(R.string.osm_edits); + } + + @Override + public boolean shouldReadOnCollecting() { + return true; + } + + @Override + void readItemsFromJson(@NonNull JSONObject json) throws IllegalArgumentException { + try { + if (!json.has("items")) { + return; + } + JSONArray jsonArray = json.getJSONArray("items"); + for (int i = 0; i < jsonArray.length(); i++) { + JSONObject jsonPoint = jsonArray.getJSONObject(i); + String comment = jsonPoint.optString(COMMENT_KEY); + comment = comment.isEmpty() ? null : comment; + JSONObject entityJson = jsonPoint.getJSONObject(ENTITY_KEY); + long id = entityJson.getLong(ID_KEY); + double lat = entityJson.getDouble(LAT_KEY); + double lon = entityJson.getDouble(LON_KEY); + String tags = entityJson.getString(TAGS_KEY); + Map tagMap = new Gson().fromJson( + tags, new TypeToken>() { + }.getType() + ); + String action = entityJson.getString(ACTION_KEY); + Entity entity; + if (entityJson.get(TYPE_KEY).equals(Entity.EntityType.NODE.name())) { + entity = new Node(lat, lon, id); + } else { + entity = new Way(id); + entity.setLatitude(lat); + entity.setLongitude(lon); + } + entity.replaceTags(tagMap); + OpenstreetmapPoint point = new OpenstreetmapPoint(); + point.setComment(comment); + point.setEntity(entity); + point.setAction(action); + items.add(point); + } + } catch (JSONException e) { + warnings.add(app.getString(R.string.settings_item_read_error, String.valueOf(getType()))); + throw new IllegalArgumentException("Json parse error", e); + } + } + + @Override + void writeItemsToJson(@NonNull JSONObject json) { + JSONArray jsonArray = new JSONArray(); + if (!items.isEmpty()) { + try { + for (OpenstreetmapPoint point : items) { + JSONObject jsonPoint = new JSONObject(); + JSONObject jsonEntity = new JSONObject(); + jsonEntity.put(ID_KEY, point.getId()); + jsonEntity.put(NAME_KEY, point.getTagsString()); + jsonEntity.put(LAT_KEY, point.getLatitude()); + jsonEntity.put(LON_KEY, point.getLongitude()); + jsonEntity.put(TYPE_KEY, Entity.EntityType.valueOf(point.getEntity())); + JSONObject jsonTags = new JSONObject(point.getEntity().getTags()); + jsonEntity.put(TAGS_KEY, jsonTags); + jsonPoint.put(COMMENT_KEY, point.getComment()); + jsonEntity.put(ACTION_KEY, OsmPoint.stringAction.get(point.getAction())); + jsonPoint.put(ENTITY_KEY, jsonEntity); + jsonArray.put(jsonPoint); + } + json.put("items", jsonArray); + } catch (JSONException e) { + warnings.add(app.getString(R.string.settings_item_write_error, String.valueOf(getType()))); + SettingsHelper.LOG.error("Failed write to json", e); + } + } + } + + @Nullable + @Override + SettingsItemReader getReader() { + return getJsonReader(); + } + + @Nullable + @Override + SettingsItemWriter getWriter() { + return null; + } +} diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmNotesSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmNotesSettingsItem.java new file mode 100644 index 0000000000..afe23c2059 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmNotesSettingsItem.java @@ -0,0 +1,172 @@ +package net.osmand.plus.settings.backend.backup; + +import android.content.Context; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandPlugin; +import net.osmand.plus.R; +import net.osmand.plus.osmedit.OsmBugsDbHelper; +import net.osmand.plus.osmedit.OsmEditingPlugin; +import net.osmand.plus.osmedit.OsmNotesPoint; +import net.osmand.plus.osmedit.OsmPoint; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + +public class OsmNotesSettingsItem extends CollectionSettingsItem { + + public static final String ID_KEY = "id"; + public static final String TEXT_KEY = "text"; + public static final String LAT_KEY = "lat"; + public static final String LON_KEY = "lon"; + public static final String AUTHOR_KEY = "author"; + public static final String ACTION_KEY = "action"; + + public OsmNotesSettingsItem(@NonNull OsmandApplication app, @NonNull List items) { + super(app, null, items); + } + + public OsmNotesSettingsItem(@NonNull OsmandApplication app, @Nullable OsmNotesSettingsItem baseItem, + @NonNull List items) { + super(app, baseItem, items); + } + + public OsmNotesSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException { + super(app, json); + } + + @Override + protected void init() { + super.init(); + OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); + if (osmEditingPlugin != null) { + existingItems = osmEditingPlugin.getDBBug().getOsmbugsPoints(); + } + } + + @NonNull + @Override + public SettingsItemType getType() { + return SettingsItemType.OSM_NOTES; + } + + @Override + public void apply() { + List newItems = getNewItems(); + if (!newItems.isEmpty() || !duplicateItems.isEmpty()) { + appliedItems = new ArrayList<>(newItems); + + for (OsmNotesPoint duplicate : duplicateItems) { + appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate)); + } + OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); + if (osmEditingPlugin != null) { + OsmBugsDbHelper db = osmEditingPlugin.getDBBug(); + for (OsmNotesPoint point : appliedItems) { + db.addOsmbugs(point); + } + } + } + } + + @Override + public boolean isDuplicate(@NonNull OsmNotesPoint item) { + return false; + } + + @NonNull + @Override + public OsmNotesPoint renameItem(@NonNull OsmNotesPoint item) { + return item; + } + + @NonNull + @Override + public String getName() { + return "osm_notes"; + } + + @NonNull + @Override + public String getPublicName(@NonNull Context ctx) { + return ctx.getString(R.string.osm_notes); + } + + @Override + public boolean shouldReadOnCollecting() { + return true; + } + + @Override + void readItemsFromJson(@NonNull JSONObject json) throws IllegalArgumentException { + try { + if (!json.has("items")) { + return; + } + JSONArray jsonArray = json.getJSONArray("items"); + for (int i = 0; i < jsonArray.length(); i++) { + JSONObject object = jsonArray.getJSONObject(i); + long id = object.getLong(ID_KEY); + String text = object.optString(TEXT_KEY); + double lat = object.getDouble(LAT_KEY); + double lon = object.getDouble(LON_KEY); + String author = object.optString(AUTHOR_KEY); + author = author.isEmpty() ? null : author; + String action = object.getString(ACTION_KEY); + OsmNotesPoint point = new OsmNotesPoint(); + point.setId(id); + point.setText(text); + point.setLatitude(lat); + point.setLongitude(lon); + point.setAuthor(author); + point.setAction(action); + items.add(point); + } + } catch (JSONException e) { + warnings.add(app.getString(R.string.settings_item_read_error, String.valueOf(getType()))); + throw new IllegalArgumentException("Json parse error", e); + } + } + + @Override + void writeItemsToJson(@NonNull JSONObject json) { + JSONArray jsonArray = new JSONArray(); + if (!items.isEmpty()) { + try { + for (OsmNotesPoint point : items) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put(ID_KEY, point.getId()); + jsonObject.put(TEXT_KEY, point.getText()); + jsonObject.put(LAT_KEY, point.getLatitude()); + jsonObject.put(LON_KEY, point.getLongitude()); + jsonObject.put(AUTHOR_KEY, point.getAuthor()); + jsonObject.put(ACTION_KEY, OsmPoint.stringAction.get(point.getAction())); + jsonArray.put(jsonObject); + } + json.put("items", jsonArray); + } catch (JSONException e) { + warnings.add(app.getString(R.string.settings_item_write_error, String.valueOf(getType()))); + SettingsHelper.LOG.error("Failed write to json", e); + } + } + } + + @Nullable + @Override + SettingsItemReader getReader() { + return getJsonReader(); + } + + @Nullable + @Override + SettingsItemWriter getWriter() { + return null; + } +} diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java index 88a9fbc797..0cfa472ef0 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java @@ -16,11 +16,17 @@ import net.osmand.map.TileSourceManager.TileSourceTemplate; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.SQLiteTileSource; +import net.osmand.plus.activities.LocalIndexHelper; +import net.osmand.plus.activities.LocalIndexInfo; import net.osmand.plus.audionotes.AudioVideoNotesPlugin; import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording; +import net.osmand.plus.download.ui.AbstractLoadLocalIndexTask; import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; +import net.osmand.plus.osmedit.OpenstreetmapPoint; +import net.osmand.plus.osmedit.OsmEditingPlugin; +import net.osmand.plus.osmedit.OsmNotesPoint; import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.quickaction.QuickAction; import net.osmand.plus.quickaction.QuickActionRegistry; @@ -41,6 +47,7 @@ import java.util.Map; import java.util.Set; import static net.osmand.IndexConstants.OSMAND_SETTINGS_FILE_EXT; +import static net.osmand.plus.activities.LocalIndexHelper.*; /* Usage: @@ -513,9 +520,41 @@ public class SettingsHelper { } dataList.put(ExportSettingsType.PROFILE, appModeBeans); } + OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); + if (osmEditingPlugin != null) { + List notesPointList = osmEditingPlugin.getDBBug().getOsmbugsPoints(); + if (!notesPointList.isEmpty()) { + dataList.put(ExportSettingsType.OSM_NOTES, notesPointList); + } + List editsPointList = osmEditingPlugin.getDBPOI().getOpenstreetmapPoints(); + if (!editsPointList.isEmpty()) { + dataList.put(ExportSettingsType.OSM_EDITS, editsPointList); + } + } + List files = getLocalMapFiles(); + if (!files.isEmpty()) { + dataList.put(ExportSettingsType.OFFLINE_MAPS, files); + } return dataList; } + private List getLocalMapFiles() { + List files = new ArrayList<>(); + LocalIndexHelper helper = new LocalIndexHelper(app); + List localMapFileList = helper.getLocalIndexData(new AbstractLoadLocalIndexTask() { + @Override + public void loadFile(LocalIndexInfo... loaded) { + } + }); + for (LocalIndexInfo map : localMapFileList) { + File file = new File(map.getPathToData()); + if (file != null && file.exists() && map.getType() != LocalIndexType.TTS_VOICE_DATA) { + files.add(file); + } + } + return files; + } + public List prepareAdditionalSettingsItems(List data) { List settingsItems = new ArrayList<>(); List quickActions = new ArrayList<>(); @@ -523,6 +562,9 @@ public class SettingsHelper { List tileSourceTemplates = new ArrayList<>(); List avoidRoads = new ArrayList<>(); List appModeBeans = new ArrayList<>(); + List osmNotesPointList = new ArrayList<>(); + List osmEditsPointList = new ArrayList<>(); + for (Object object : data) { if (object instanceof QuickAction) { quickActions.add((QuickAction) object); @@ -540,6 +582,10 @@ public class SettingsHelper { avoidRoads.add((AvoidRoadInfo) object); } else if (object instanceof ApplicationModeBean) { appModeBeans.add((ApplicationModeBean) object); + } else if (object instanceof OsmNotesPoint) { + osmNotesPointList.add((OsmNotesPoint) object); + } else if (object instanceof OpenstreetmapPoint) { + osmEditsPointList.add((OpenstreetmapPoint) object); } } if (!quickActions.isEmpty()) { @@ -562,6 +608,12 @@ public class SettingsHelper { } } } + if (!osmNotesPointList.isEmpty()) { + settingsItems.add(new OsmNotesSettingsItem(app, osmNotesPointList)); + } + if (!osmEditsPointList.isEmpty()) { + settingsItems.add(new OsmEditsSettingsItem(app, osmEditsPointList)); + } return settingsItems; } @@ -575,8 +627,11 @@ public class SettingsHelper { List renderFilesList = new ArrayList<>(); List multimediaFilesList = new ArrayList<>(); List tracksFilesList = new ArrayList<>(); + List mapFilesList = new ArrayList<>(); List avoidRoads = new ArrayList<>(); List globalSettingsItems = new ArrayList<>(); + List notesPointList = new ArrayList<>(); + List editsPointList = new ArrayList<>(); for (SettingsItem item : settingsItems) { switch (item.getType()) { case PROFILE: @@ -592,6 +647,11 @@ public class SettingsHelper { multimediaFilesList.add(fileItem.getFile()); } else if (fileItem.getSubtype() == FileSettingsItem.FileSubtype.GPX) { tracksFilesList.add(fileItem.getFile()); + } else if (fileItem.getSubtype() == FileSettingsItem.FileSubtype.OBF_MAP + || fileItem.getSubtype() == FileSettingsItem.FileSubtype.WIKI_MAP + || fileItem.getSubtype() == FileSettingsItem.FileSubtype.SRTM_MAP + || fileItem.getSubtype() == FileSettingsItem.FileSubtype.TILES_MAP) { + mapFilesList.add(fileItem); } break; case QUICK_ACTIONS: @@ -629,6 +689,22 @@ public class SettingsHelper { case GLOBAL: globalSettingsItems.add((GlobalSettingsItem) item); break; + case OSM_NOTES: + OsmNotesSettingsItem osmNotesSettingsItem = (OsmNotesSettingsItem) item; + if (importComplete) { + notesPointList.addAll(osmNotesSettingsItem.getAppliedItems()); + } else { + notesPointList.addAll(osmNotesSettingsItem.getItems()); + } + break; + case OSM_EDITS: + OsmEditsSettingsItem osmEditsSettingsItem = (OsmEditsSettingsItem) item; + if (importComplete) { + editsPointList.addAll(osmEditsSettingsItem.getAppliedItems()); + } else { + editsPointList.addAll(osmEditsSettingsItem.getItems()); + } + break; default: break; } @@ -664,6 +740,15 @@ public class SettingsHelper { if (!globalSettingsItems.isEmpty()) { settingsToOperate.put(ExportSettingsType.GLOBAL, globalSettingsItems); } + if (!notesPointList.isEmpty()) { + settingsToOperate.put(ExportSettingsType.OSM_NOTES, notesPointList); + } + if (!editsPointList.isEmpty()) { + settingsToOperate.put(ExportSettingsType.OSM_EDITS, editsPointList); + } + if (!mapFilesList.isEmpty()) { + settingsToOperate.put(ExportSettingsType.OFFLINE_MAPS, mapFilesList); + } return settingsToOperate; } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsImporter.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsImporter.java index a06b8e8749..a03f363542 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsImporter.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsImporter.java @@ -15,8 +15,10 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; +import java.util.Enumeration; import java.util.List; import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; import java.util.zip.ZipInputStream; import static net.osmand.IndexConstants.OSMAND_SETTINGS_FILE_EXT; @@ -57,7 +59,9 @@ class SettingsImporter { } try { SettingsItemsFactory itemsFactory = new SettingsItemsFactory(app, itemsJson); - items.addAll(itemsFactory.getItems()); + List settingsItemList = itemsFactory.getItems(); + getFilesSize(file, settingsItemList); + items.addAll(settingsItemList); } catch (IllegalArgumentException e) { SettingsHelper.LOG.error("Error parsing items: " + itemsJson, e); throw new IllegalArgumentException("No items"); @@ -77,6 +81,22 @@ class SettingsImporter { return items; } + private void getFilesSize(@NonNull File file, List settingsItemList) throws IOException { + ZipFile zipfile = new ZipFile(file.getPath()); + Enumeration zipEnum = zipfile.entries(); + while (zipEnum.hasMoreElements()) { + ZipEntry zipEntry = zipEnum.nextElement(); + long size = zipEntry.getSize(); + for (SettingsItem settingsItem : settingsItemList) { + if (settingsItem instanceof FileSettingsItem + && zipEntry.getName().equals(settingsItem.getFileName())) { + ((FileSettingsItem) settingsItem).setSize(size); + break; + } + } + } + } + private List processItems(@NonNull File file, @Nullable List items) throws IllegalArgumentException, IOException { boolean collecting = items == null; if (collecting) { diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java index 1a25e24817..a513dc748c 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java @@ -12,5 +12,7 @@ public enum SettingsItemType { MAP_SOURCES, AVOID_ROADS, SUGGESTED_DOWNLOADS, - DOWNLOADS + DOWNLOADS, + OSM_NOTES, + OSM_EDITS, } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemsFactory.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemsFactory.java index d4a639da4d..8545b37503 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemsFactory.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemsFactory.java @@ -125,6 +125,12 @@ class SettingsItemsFactory { case DOWNLOADS: item = new DownloadsItem(app, json); break; + case OSM_NOTES: + item = new OsmNotesSettingsItem(app, json); + break; + case OSM_EDITS: + item = new OsmEditsSettingsItem(app, json); + break; } return item; } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java index acb9da8ee0..0f86486851 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportImportSettingsAdapter.java @@ -22,7 +22,11 @@ import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; import net.osmand.plus.audionotes.AudioVideoNotesPlugin; import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo; +import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.helpers.GpxUiHelper; +import net.osmand.plus.osmedit.OpenstreetmapPoint; +import net.osmand.plus.osmedit.OsmEditingPlugin; +import net.osmand.plus.osmedit.OsmNotesPoint; import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.profiles.ProfileIconColors; import net.osmand.plus.profiles.RoutingProfileDataObject.RoutingProfilesResources; @@ -32,6 +36,7 @@ import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean; import net.osmand.plus.settings.backend.ExportSettingsType; import net.osmand.plus.settings.backend.backup.GlobalSettingsItem; +import net.osmand.plus.settings.backend.backup.FileSettingsItem; import net.osmand.util.Algorithms; import net.osmand.view.ThreeStateCheckbox; @@ -44,6 +49,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import static net.osmand.plus.settings.backend.ExportSettingsType.*; +import static net.osmand.plus.settings.backend.backup.FileSettingsItem.*; import static net.osmand.view.ThreeStateCheckbox.State.CHECKED; import static net.osmand.view.ThreeStateCheckbox.State.MISC; import static net.osmand.view.ThreeStateCheckbox.State.UNCHECKED; @@ -103,7 +110,7 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { cardBottomDivider.setVisibility(importState && !isExpanded ? View.VISIBLE : View.GONE); final List listItems = itemsMap.get(type); - subTextTv.setText(getSelectedItemsAmount(listItems)); + subTextTv.setText(getSelectedItemsAmount(listItems, type)); if (data.containsAll(listItems)) { checkBox.setState(CHECKED); @@ -154,6 +161,7 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { TextView title = child.findViewById(R.id.title_tv); TextView subText = child.findViewById(R.id.sub_title_tv); + subText.setVisibility(View.GONE); final CheckBox checkBox = child.findViewById(R.id.check_box); ImageView icon = child.findViewById(R.id.icon); View lineDivider = child.findViewById(R.id.divider); @@ -198,9 +206,7 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { LOG.error("Error trying to get routing resource for " + routingProfileValue + "\n" + e); } } - if (Algorithms.isEmpty(routingProfile)) { - subText.setVisibility(View.GONE); - } else { + if (!Algorithms.isEmpty(routingProfile)) { subText.setText(String.format( app.getString(R.string.ltr_or_rtl_combine_via_colon), app.getString(R.string.nav_type_hint), @@ -214,38 +220,32 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { case QUICK_ACTIONS: title.setText(((QuickAction) currentItem).getName(app.getApplicationContext())); setupIcon(icon, ((QuickAction) currentItem).getIconRes(), itemSelected); - subText.setVisibility(View.GONE); break; case POI_TYPES: title.setText(((PoiUIFilter) currentItem).getName()); int iconRes = RenderingIcons.getBigIconResourceId(((PoiUIFilter) currentItem).getIconId()); setupIcon(icon, iconRes != 0 ? iconRes : R.drawable.ic_action_user, itemSelected); - subText.setVisibility(View.GONE); break; case MAP_SOURCES: title.setText(((ITileSource) currentItem).getName()); setupIcon(icon, R.drawable.ic_map, itemSelected); - subText.setVisibility(View.GONE); break; case CUSTOM_RENDER_STYLE: String renderName = ((File) currentItem).getName(); renderName = renderName.replace('_', ' ').replaceAll(IndexConstants.RENDERER_INDEX_EXT, ""); title.setText(renderName); setupIcon(icon, R.drawable.ic_action_map_style, itemSelected); - subText.setVisibility(View.GONE); break; case CUSTOM_ROUTING: String routingName = ((File) currentItem).getName(); routingName = routingName.replace('_', ' ').replaceAll(".xml", ""); title.setText(routingName); setupIcon(icon, R.drawable.ic_action_route_distance, itemSelected); - subText.setVisibility(View.GONE); break; case AVOID_ROADS: AvoidRoadInfo avoidRoadInfo = (AvoidRoadInfo) currentItem; title.setText(avoidRoadInfo.name); setupIcon(icon, R.drawable.ic_action_alert, itemSelected); - subText.setVisibility(View.GONE); break; case MULTIMEDIA_NOTES: File file = (File) currentItem; @@ -255,19 +255,53 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { iconId = R.drawable.ic_action_photo_dark; } setupIcon(icon, iconId, itemSelected); - subText.setVisibility(View.GONE); break; case TRACKS: String fileName = ((File) currentItem).getName(); title.setText(GpxUiHelper.getGpxTitle(fileName)); setupIcon(icon, R.drawable.ic_action_route_distance, itemSelected); - subText.setVisibility(View.GONE); break; case GLOBAL: String name = ((GlobalSettingsItem) currentItem).getPublicName(app); title.setText(name); setupIcon(icon, R.drawable.ic_action_settings, itemSelected); - subText.setVisibility(View.GONE); + break; + case OSM_NOTES: + title.setText(((OsmNotesPoint) currentItem).getText()); + setupIcon(icon, R.drawable.ic_action_osm_note_add, itemSelected); + break; + case OSM_EDITS: + title.setText(OsmEditingPlugin.getTitle((OpenstreetmapPoint) currentItem, app)); + setupIcon(icon, R.drawable.ic_action_info_dark, itemSelected); + break; + case OFFLINE_MAPS: + long size; + if (currentItem instanceof FileSettingsItem) { + FileSettingsItem currentFileItem = (FileSettingsItem) currentItem; + file = currentFileItem.getFile(); + size = currentFileItem.getSize(); + } else { + file = (File) currentItem; + size = file.length(); + } + title.setText(FileNameTranslationHelper.getFileName(app, + app.getResourceManager().getOsmandRegions(), + file.getName())); + FileSubtype subtype = FileSubtype.getSubtypeByFileName(file.getPath().replace( + app.getAppPath(null).getPath(), "")); + switch (subtype) { + case SRTM_MAP: + iconId = R.drawable.ic_plugin_srtm; + break; + case WIKI_MAP: + iconId = R.drawable.ic_plugin_wikipedia; + break; + default: + iconId = R.drawable.ic_map; + } + setupIcon(icon, iconId, itemSelected); + subText.setText(AndroidUtils.formatSize(app, size)); + subText.setVisibility(View.VISIBLE); break; default: return child; @@ -315,14 +349,20 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { return true; } - private String getSelectedItemsAmount(List listItems) { + private String getSelectedItemsAmount(List listItems, ExportSettingsType type) { int amount = 0; + long amountSize = 0; for (Object item : listItems) { if (data.contains(item)) { amount++; + if (type == OFFLINE_MAPS && item instanceof FileSettingsItem) { + amountSize += ((FileSettingsItem) item).getSize(); + } } } - return app.getString(R.string.n_items_of_z, String.valueOf(amount), String.valueOf(listItems.size())); + String itemsOf = app.getString(R.string.n_items_of_z, String.valueOf(amount), String.valueOf(listItems.size())); + return amountSize == 0 ? itemsOf : app.getString(R.string.ltr_or_rtl_combine_via_bold_point, itemsOf, + AndroidUtils.formatSize(app, amountSize)); } private int getGroupTitle(ExportSettingsType type) { @@ -347,6 +387,12 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { return R.string.audionotes_plugin_name; case GLOBAL: return R.string.general_settings_2; + case OSM_NOTES: + return R.string.osm_notes; + case OSM_EDITS: + return R.string.osm_edit_modified_poi; + case OFFLINE_MAPS: + return R.string.shared_string_local_maps; default: return R.string.access_empty_list; } @@ -386,4 +432,4 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { List getData() { return this.data; } -} +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportCompleteFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportCompleteFragment.java index 27278775f0..f11df23d09 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportCompleteFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportCompleteFragment.java @@ -1,6 +1,7 @@ package net.osmand.plus.settings.fragments; import android.app.Activity; +import android.content.Intent; import android.graphics.Typeface; import android.os.Build; import android.os.Bundle; @@ -31,6 +32,7 @@ import net.osmand.plus.quickaction.QuickActionListFragment; import net.osmand.plus.routepreparationmenu.AvoidRoadsBottomSheetDialogFragment; import net.osmand.plus.search.QuickSearchDialogFragment; import net.osmand.plus.settings.backend.ExportSettingsType; +import net.osmand.plus.settings.backend.OsmAndAppCustomization; import net.osmand.plus.settings.backend.backup.SettingsHelper; import net.osmand.plus.settings.backend.backup.SettingsItem; @@ -187,6 +189,14 @@ public class ImportCompleteFragment extends BaseOsmAndFragment { case AVOID_ROADS: new AvoidRoadsBottomSheetDialogFragment().show(fm, AvoidRoadsBottomSheetDialogFragment.TAG); break; + case OSM_NOTES: + case OSM_EDITS: + OsmAndAppCustomization appCustomization = app.getAppCustomization(); + final Intent favorites = new Intent(activity, appCustomization.getFavoritesActivity()); + favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + app.getSettings().FAVORITES_TAB.set(R.string.osm_edits); + startActivity(favorites); + break; default: break; } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java index 6002c8a58e..8250477d20 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java @@ -4,6 +4,7 @@ import android.app.Activity; import android.content.Context; import android.content.DialogInterface; import android.graphics.Typeface; +import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.text.style.StyleSpan; @@ -27,6 +28,7 @@ import androidx.fragment.app.FragmentManager; import com.google.android.material.appbar.CollapsingToolbarLayout; import net.osmand.AndroidUtils; +import net.osmand.IProgress; import net.osmand.PlatformUtil; import net.osmand.map.ITileSource; import net.osmand.map.TileSourceManager.TileSourceTemplate; @@ -38,10 +40,14 @@ import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.BaseOsmAndFragment; import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo; +import net.osmand.plus.osmedit.OpenstreetmapPoint; +import net.osmand.plus.osmedit.OsmNotesPoint; import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.quickaction.QuickAction; import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean; import net.osmand.plus.settings.backend.ExportSettingsType; +import net.osmand.plus.settings.backend.backup.OsmEditsSettingsItem; +import net.osmand.plus.settings.backend.backup.OsmNotesSettingsItem; import net.osmand.plus.settings.backend.backup.SettingsHelper; import net.osmand.plus.settings.backend.backup.AvoidRoadsSettingsItem; import net.osmand.plus.settings.backend.backup.FileSettingsItem; @@ -59,12 +65,12 @@ import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; import java.io.File; +import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - public class ImportSettingsFragment extends BaseOsmAndFragment implements View.OnClickListener { @@ -267,6 +273,7 @@ public class ImportSettingsFragment extends BaseOsmAndFragment if (succeed) { app.getRendererRegistry().updateExternalRenderers(); AppInitializer.loadRoutingFiles(app, null); + reloadIndexes(items); if (fm != null && file != null) { ImportCompleteFragment.showInstance(fm, items, file.getName()); } @@ -275,6 +282,43 @@ public class ImportSettingsFragment extends BaseOsmAndFragment }; } + private void reloadIndexes(@NonNull List items) { + for (SettingsItem item : items) { + if (item instanceof FileSettingsItem && ((FileSettingsItem) item).getSubtype().isMap()) { + Activity activity = getActivity(); + if (activity instanceof MapActivity) { + new ReloadIndexesTack((MapActivity) activity).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + } + break; + } + } + } + + private static class ReloadIndexesTack extends AsyncTask { + + private final WeakReference mapActivityRef; + private final OsmandApplication app; + + ReloadIndexesTack(@NonNull MapActivity mapActivity) { + this.mapActivityRef = new WeakReference<>(mapActivity); + this.app = mapActivity.getMyApplication(); + } + + @Override + protected Void doInBackground(Void[] params) { + app.getResourceManager().reloadIndexes(IProgress.EMPTY_PROGRESS, new ArrayList()); + return null; + } + + @Override + protected void onPostExecute(Void aVoid) { + MapActivity mapActivity = mapActivityRef.get(); + if (mapActivity != null) { + mapActivity.refreshMap(); + } + } + } + private SettingsHelper.CheckDuplicatesListener getDuplicatesListener() { return new SettingsHelper.CheckDuplicatesListener() { @Override @@ -374,6 +418,16 @@ public class ImportSettingsFragment extends BaseOsmAndFragment return null; } + @Nullable + private T getBaseItem(SettingsItemType settingsItemType, Class clazz) { + for (SettingsItem settingsItem : settingsItems) { + if (settingsItem.getType() == settingsItemType && clazz.isInstance(settingsItem)) { + return clazz.cast(settingsItem); + } + } + return null; + } + private List getSettingsItemsFromData(List data) { List settingsItems = new ArrayList<>(); List appModeBeans = new ArrayList<>(); @@ -381,6 +435,8 @@ public class ImportSettingsFragment extends BaseOsmAndFragment List poiUIFilters = new ArrayList<>(); List tileSourceTemplates = new ArrayList<>(); List avoidRoads = new ArrayList<>(); + List osmNotesPointList = new ArrayList<>(); + List osmEditsPointList = new ArrayList<>(); for (Object object : data) { if (object instanceof ApplicationModeBean) { appModeBeans.add((ApplicationModeBean) object); @@ -392,8 +448,14 @@ public class ImportSettingsFragment extends BaseOsmAndFragment tileSourceTemplates.add((ITileSource) object); } else if (object instanceof File) { settingsItems.add(new FileSettingsItem(app, (File) object)); + } else if (object instanceof FileSettingsItem) { + settingsItems.add((FileSettingsItem) object); } else if (object instanceof AvoidRoadInfo) { avoidRoads.add((AvoidRoadInfo) object); + } else if (object instanceof OsmNotesPoint) { + osmNotesPointList.add((OsmNotesPoint) object); + } else if (object instanceof OpenstreetmapPoint) { + osmEditsPointList.add((OpenstreetmapPoint) object); } } if (!appModeBeans.isEmpty()) { @@ -413,6 +475,14 @@ public class ImportSettingsFragment extends BaseOsmAndFragment if (!avoidRoads.isEmpty()) { settingsItems.add(new AvoidRoadsSettingsItem(app, getBaseAvoidRoadsSettingsItem(), avoidRoads)); } + if (!osmNotesPointList.isEmpty()) { + OsmNotesSettingsItem baseItem = getBaseItem(SettingsItemType.OSM_NOTES, OsmNotesSettingsItem.class); + settingsItems.add(new OsmNotesSettingsItem(app, baseItem, osmNotesPointList)); + } + if (!osmEditsPointList.isEmpty()) { + OsmEditsSettingsItem baseItem = getBaseItem(SettingsItemType.OSM_EDITS, OsmEditsSettingsItem.class); + settingsItems.add(new OsmEditsSettingsItem(app, baseItem, osmEditsPointList)); + } return settingsItems; } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportedSettingsItemsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportedSettingsItemsAdapter.java index 57198c2f04..7acd88ee4b 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportedSettingsItemsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportedSettingsItemsAdapter.java @@ -114,6 +114,14 @@ public class ImportedSettingsItemsAdapter extends holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_route_distance, activeColorRes)); holder.title.setText(R.string.shared_string_tracks); break; + case OSM_NOTES: + holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_osm_note_add, activeColorRes)); + holder.title.setText(R.string.osm_notes); + break; + case OSM_EDITS: + holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_info_dark, activeColorRes)); + holder.title.setText(R.string.osm_edit_modified_poi); + break; } } diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainLayer.java b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainLayer.java index 79e47de648..b58dc807a8 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainLayer.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/TerrainLayer.java @@ -35,7 +35,7 @@ import static net.osmand.plus.srtmplugin.TerrainMode.HILLSHADE; public class TerrainLayer extends MapTileLayer { private final static Log log = PlatformUtil.getLog(TerrainLayer.class); - private Map resources = new LinkedHashMap(); + private Map resources = new LinkedHashMap(); private final static String HILLSHADE_CACHE = "hillshade.cache"; private final static String SLOPE_CACHE = "slope.cache"; private int ZOOM_BOUNDARY = 15; @@ -68,7 +68,6 @@ public class TerrainLayer extends MapTileLayer { } else { // ignore } - } private void indexTerrainFiles(final OsmandApplication app) { @@ -77,7 +76,6 @@ public class TerrainLayer extends MapTileLayer { private String type = mode.name().toLowerCase(); @Override protected Void doInBackground(Void... params) { - File tilesDir = app.getAppPath(IndexConstants.TILES_INDEX_DIR); File cacheDir = app.getCacheDir(); // fix http://stackoverflow.com/questions/26937152/workaround-for-nexus-9-sqlite-file-write-operations-on-external-dirs @@ -91,17 +89,21 @@ public class TerrainLayer extends MapTileLayer { sqliteDb = null; } if (sqliteDb != null) { - if (sqliteDb.getVersion() == 0) { - sqliteDb.setVersion(1); - } - sqliteDb.execSQL("CREATE TABLE IF NOT EXISTS TILE_SOURCES(filename varchar2(256), date_modified int, left int, right int, top int, bottom int)"); + try { + if (sqliteDb.getVersion() == 0) { + sqliteDb.setVersion(1); + } + sqliteDb.execSQL("CREATE TABLE IF NOT EXISTS TILE_SOURCES(filename varchar2(256), date_modified int, left int, right int, top int, bottom int)"); - Map fileModified = new HashMap(); - Map rs = readFiles(app, tilesDir, fileModified); - indexCachedResources(fileModified, rs); - indexNonCachedResources(fileModified, rs); - sqliteDb.close(); - resources = rs; + Map fileModified = new HashMap(); + Map rs = readFiles(app, tilesDir, fileModified); + indexCachedResources(fileModified, rs); + indexNonCachedResources(fileModified, rs); + sqliteDb.close(); + resources = rs; + } catch (RuntimeException e) { + log.error(e.getMessage(), e); + } } return null; } @@ -150,7 +152,6 @@ public class TerrainLayer extends MapTileLayer { indexedResources.insert(filename, new QuadRect(left, top, right, bottom)); fileModified.remove(filename); } - } while(cursor.moveToNext()); } cursor.close(); @@ -172,7 +173,6 @@ public class TerrainLayer extends MapTileLayer { } return rs; } - }; executeTaskInBackground(task); }