diff --git a/OsmAnd-java/src/main/java/com/jwetherell/openmap/common/MGRSPoint.java b/OsmAnd-java/src/main/java/com/jwetherell/openmap/common/MGRSPoint.java index 8cbb306b7e..6e99eec8b5 100644 --- a/OsmAnd-java/src/main/java/com/jwetherell/openmap/common/MGRSPoint.java +++ b/OsmAnd-java/src/main/java/com/jwetherell/openmap/common/MGRSPoint.java @@ -14,6 +14,10 @@ package com.jwetherell.openmap.common; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + public class MGRSPoint extends ZonedUTMPoint { /** @@ -104,6 +108,15 @@ public class MGRSPoint extends ZonedUTMPoint { * an UPPERCASE coordinate string is expected. */ protected void decode(String mgrsString) throws NumberFormatException { + if (mgrsString.contains(" ")) { + String[] parts = mgrsString.split(" "); + StringBuilder s = new StringBuilder(); + for (String i : parts) { + s.append(i); + } + mgrsString = s.toString(); + } + if (mgrsString == null || mgrsString.length() == 0) { throw new NumberFormatException("MGRSPoint coverting from nothing"); } @@ -633,6 +646,97 @@ public class MGRSPoint extends ZonedUTMPoint { return twoLetter; } + public String toFlavoredString() { + try { + List all = new ArrayList<>(); + for (int i = 0; i <= mgrs.length(); i++) { + if (Character.isAlphabetic(mgrs.charAt(i))){ + all.add(mgrs.substring(0,i+1)); + all.add(mgrs.substring(i+1,i+3)); + String remains = mgrs.substring(i+3); + all.add(remains.substring(0,remains.length()/2)); + all.add(remains.substring(remains.length()/2)); + break; + } + } + StringBuilder os = new StringBuilder(); + for(String part: all){ + if (os.length() > 0) os.append(" "); + os.append(part); + } + return os.toString(); + }catch (Exception e){ + return mgrs; + } + } + + public String toFlavoredString(int accuracy) { + try { + List all = new ArrayList<>(); + for (int i = 0; i <= mgrs.length(); i++) { + if (Character.isAlphabetic(mgrs.charAt(i))){ + all.add(mgrs.substring(0,i+1)); + all.add(mgrs.substring(i+1,i+3)); + String remains = mgrs.substring(i+3); + int easting = Integer.parseInt(remains.substring(0,remains.length()/2)); + int northing = Integer.parseInt(remains.substring(remains.length()/2)); + double resolution = Math.pow(10, getAccuracy() - accuracy); + long roundedEasting = Math.round(easting/resolution); + long roundedNorthing = Math.round(northing/resolution); + int eastShift = 0; + int northShift = 0; + if (roundedEasting == resolution*10){ + roundedEasting = 0L; + eastShift = 1; + } + if (roundedNorthing == resolution*10){ + roundedNorthing = 0L; + northShift = 1; + } + if (eastShift != 0 || northShift != 0){ + all.set(1, shiftChar(all.get(1), eastShift, northShift)); + String zero = ""; + } + + + all.add(String.format("%0" + accuracy + "d", roundedEasting)); + all.add(String.format("%0" + accuracy + "d", roundedNorthing)); + break; + } + } + StringBuilder os = new StringBuilder(); + for(String part: all){ + if (os.length() > 0) os.append(" "); + os.append(part); + } + return os.toString(); + }catch (Exception e){ + return toFlavoredString(); + } + } + + private static String shiftChar(String chars, int east, int north){ + ArrayList keys = new ArrayList( + Arrays.asList('A','B','C','D','E','F','G','H','J','K','L','M','N','P','Q','R','S','T','U','V','W','X','Y','Z')); + StringBuilder s = new StringBuilder(); + if (east != 0){ + int idx = keys.indexOf(chars.charAt(0)); + idx += east; + if (idx >= keys.size()) idx -= keys.size(); + if (idx < 0) idx += keys.size(); + s.append(keys.get(idx)); + }else s.append(chars.charAt(0)); + if (north != 0){ + int idx = keys.indexOf(chars.charAt(1)); + idx += north; + if (idx >= keys.size()) idx -= keys.size(); + if (idx < 0) idx += keys.size(); + s.append(keys.get(idx)); + }else s.append(chars.charAt(1)); + return s.toString(); + } + + /** * {@inheritDoc} */ diff --git a/OsmAnd-java/src/main/java/net/osmand/LocationConvert.java b/OsmAnd-java/src/main/java/net/osmand/LocationConvert.java index 0f4ec96883..88eb471840 100644 --- a/OsmAnd-java/src/main/java/net/osmand/LocationConvert.java +++ b/OsmAnd-java/src/main/java/net/osmand/LocationConvert.java @@ -15,6 +15,7 @@ public class LocationConvert { public static final int FORMAT_SECONDS = 2; public static final int UTM_FORMAT = 3; public static final int OLC_FORMAT = 4; + public static final int MGRS_FORMAT = 5; private static final char DELIM = ':'; private static final char DELIMITER_DEGREES = '°'; private static final char DELIMITER_MINUTES = '′'; diff --git a/OsmAnd-java/src/main/java/net/osmand/util/LocationParser.java b/OsmAnd-java/src/main/java/net/osmand/util/LocationParser.java index 100c4f014d..efa4cdaf42 100644 --- a/OsmAnd-java/src/main/java/net/osmand/util/LocationParser.java +++ b/OsmAnd-java/src/main/java/net/osmand/util/LocationParser.java @@ -3,6 +3,7 @@ package net.osmand.util; import com.google.openlocationcode.OpenLocationCode; import com.google.openlocationcode.OpenLocationCode.CodeArea; import com.jwetherell.openmap.common.LatLonPoint; +import com.jwetherell.openmap.common.MGRSPoint; import com.jwetherell.openmap.common.UTMPoint; import net.osmand.data.LatLon; @@ -111,7 +112,7 @@ public class LocationParser { return null; } // detect UTM - if (all.size() == 4 && d.size() == 3 && all.get(1) instanceof String) { + if (all.size() == 4 && d.size() == 3 && all.get(1) instanceof String && ((String) all.get(1)).length() == 1) { char ch = all.get(1).toString().charAt(0); if (Character.isLetter(ch)) { UTMPoint upoint = new UTMPoint(d.get(2), d.get(1), d.get(0).intValue(), ch); @@ -120,7 +121,7 @@ public class LocationParser { } } - if (all.size() == 3 && d.size() == 2 && all.get(1) instanceof String) { + if (all.size() == 3 && d.size() == 2 && all.get(1) instanceof String && ((String) all.get(1)).length() == 1) { char ch = all.get(1).toString().charAt(0); String combined = strings.get(2); if (Character.isLetter(ch)) { @@ -135,6 +136,17 @@ public class LocationParser { } } } + + //detect MGRS + if (all.size() >= 3 && (d.size() == 2 || d.size() == 3) && all.get(1) instanceof String) { + try { + MGRSPoint mgrsPoint = new MGRSPoint(locPhrase); + LatLonPoint ll = mgrsPoint.toLatLonPoint(); + return validateAndCreateLatLon(ll.getLatitude(), ll.getLongitude()); + } catch (NumberFormatException e) { + //do nothing + } + } // try to find split lat/lon position int jointNumbers = 0; int lastJoin = 0; diff --git a/OsmAnd-telegram/res/values-is/strings.xml b/OsmAnd-telegram/res/values-is/strings.xml new file mode 100644 index 0000000000..a6b3daec93 --- /dev/null +++ b/OsmAnd-telegram/res/values-is/strings.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/OsmAnd-telegram/res/values-it/strings.xml b/OsmAnd-telegram/res/values-it/strings.xml index 15986c05a0..04ca50389d 100644 --- a/OsmAnd-telegram/res/values-it/strings.xml +++ b/OsmAnd-telegram/res/values-it/strings.xml @@ -265,4 +265,5 @@ Ultima risposta: %1$s Ultimo aggiornamento da Telegram: %1$s ERR + Controlla e condividi i log dettagliati dell\'applicazione \ No newline at end of file diff --git a/OsmAnd/res/drawable/ic_action_logout.xml b/OsmAnd/res/drawable/ic_action_logout.xml new file mode 100644 index 0000000000..e1f0b60564 --- /dev/null +++ b/OsmAnd/res/drawable/ic_action_logout.xml @@ -0,0 +1,12 @@ + + + + diff --git a/OsmAnd/res/drawable/ic_action_openstreetmap_logo_colored.xml b/OsmAnd/res/drawable/ic_action_openstreetmap_logo_colored.xml new file mode 100644 index 0000000000..2d2472c970 --- /dev/null +++ b/OsmAnd/res/drawable/ic_action_openstreetmap_logo_colored.xml @@ -0,0 +1,14 @@ + + + + diff --git a/OsmAnd/res/drawable/ic_action_user_account.xml b/OsmAnd/res/drawable/ic_action_user_account.xml new file mode 100644 index 0000000000..51beae9b6e --- /dev/null +++ b/OsmAnd/res/drawable/ic_action_user_account.xml @@ -0,0 +1,17 @@ + + + + + diff --git a/OsmAnd/res/layout/search_advanced_coords.xml b/OsmAnd/res/layout/search_advanced_coords.xml index 75b3ee5b4e..a93991c38b 100644 --- a/OsmAnd/res/layout/search_advanced_coords.xml +++ b/OsmAnd/res/layout/search_advanced_coords.xml @@ -324,6 +324,52 @@ + + + + + + + + + + + + + + + + + + + + + + + رسم بياني %2$s — %1$s فجوة + الخرائط المحلية + راحة + خاص + نقل + خدمة + الرموز + رياضة + الطوارئ + سفر \ No newline at end of file diff --git a/OsmAnd/res/values-bg/strings.xml b/OsmAnd/res/values-bg/strings.xml index f5c84b1d29..8a5ad86232 100644 --- a/OsmAnd/res/values-bg/strings.xml +++ b/OsmAnd/res/values-bg/strings.xml @@ -2170,4 +2170,20 @@ Възстановяване на всички настройки на профила\? Наистина ли искате да изчистите записаните данни\? Преизчисляване на маршрута в случай на отклонение + Успешно излязохте + Файлът вече е импортиран в OsmAnd + Използване на 2-стъпков A* рутиращ алгоритъм + Изчакайте преизчисляването на маршрута. +\nГрафиката ще бъде достъпна след преизчисляване. + Местни карти + %1$s — %2$s + Пропуск + Удобства + Специални + Транспорт + Услуги + Символи + Спорт + Аварийни служби + Пътуване \ No newline at end of file diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index 20b7fd68f2..559fb70a06 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -3224,8 +3224,10 @@ %1$s für die ersten %2$s Einstellungen für Profil: OsmAnd verwendet den UTM-Standard, der ähnlich, aber nicht identisch zum UTM-NATO-Format ist. + OsmAnd verwendet MGRS, das identisch zum UTM-NATO-Format ist. Beispiel UTM-Standard + MGRS Das gewählte Format wird in der gesamten App angewandt. Für Profile wird als Vorgabe diese Einstellung gewählt: %s Einstellung ändern diff --git a/OsmAnd/res/values-et/strings.xml b/OsmAnd/res/values-et/strings.xml index 3930c5b18f..2a0af4fbbf 100644 --- a/OsmAnd/res/values-et/strings.xml +++ b/OsmAnd/res/values-et/strings.xml @@ -3786,4 +3786,13 @@ OsmAnd andmed reaalajas Mootorsaanide sõitmine eraldi määratud teedel ja radadel. %1$s — %2$s + Eriteenused + Mugavus + Kohalikud kaardid + Reisimine + Hädaabi + Sport + Sümbolid + Teenused + Transport \ No newline at end of file diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index 3dda9b8adc..18fd7f8009 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -3914,4 +3914,13 @@ Graphique Écart %1$s - %2$s + Cartes locales + Loisir + Spécial + Transport + Service + Symboles + Sport + Urgence + Voyage \ No newline at end of file diff --git a/OsmAnd/res/values-hu/strings.xml b/OsmAnd/res/values-hu/strings.xml index 9ae52a9644..f3762a3fd1 100644 --- a/OsmAnd/res/values-hu/strings.xml +++ b/OsmAnd/res/values-hu/strings.xml @@ -3834,7 +3834,7 @@ Egyszerűsített nyomvonal Kész elmentve - Jelölje ki, hogyan legyenek összekötve a pontok: egyenes vonallal vagy az alábbiak szerint kiszámított útvonallal. + Válassza ki, hogyan legyenek összekötve a pontok: egyenes vonallal vagy az alábbiak szerint kiszámított útvonallal. Teljes nyomvonal Megjegyzés: Ha a GPS közvetlenül a felvétel előtt ki volt kapcsolva, akkor rosszabb lehet az első mért pont pontossága. A kódban ezért szeretnénk majd talán várni egy-két másodpercet egy pont rögzítése előtt (vagy a 3 egymást követő pont közül a legjobbat rögzíteni vagy valami hasonló), de ezt még nem programoztuk le. Cím törlése @@ -3926,4 +3926,13 @@ %1$s adatok csak az utakról állnak rendelkezésre. Használja az „Útvonal tervezése pontok között” funkciót. Várja meg az útvonal újraszámítását. \nAz ábra az újraszámítás után lesz látható. + Helyi térképek + Hasznos és fontos létesítmény + Különleges + Közlekedés + Szolgáltatás + Jelképek + Sport + Vészhelyzet + Utazás \ No newline at end of file diff --git a/OsmAnd/res/values-is/strings.xml b/OsmAnd/res/values-is/strings.xml index 182d438a1c..3414adba28 100644 --- a/OsmAnd/res/values-is/strings.xml +++ b/OsmAnd/res/values-is/strings.xml @@ -3945,4 +3945,13 @@ \n Þú getur stýrt og aflýst áskriftunum þínum með því að fara í AppGallery stillingarnar þínar. Graf %1$s — %2$s + Staðkort + Aðstaða + Sértákn + Samgöngur + Þjónusta + Tákn + Íþróttir + Neyðartilfelli + Ferðalög \ No newline at end of file diff --git a/OsmAnd/res/values-iw/strings.xml b/OsmAnd/res/values-iw/strings.xml index 7334c5dbb9..c82e5e3b8d 100644 --- a/OsmAnd/res/values-iw/strings.xml +++ b/OsmAnd/res/values-iw/strings.xml @@ -3837,7 +3837,7 @@ נא לבחור קובץ מסלול שבו יתווסף המקטע החדש. כל המסלול יחושב מחדש באמצעות הפרופיל הנבחר. רק המקטע הבא יחושב מחודש באמצעות הפרופיל הנבחר. - נא לבחור כיצד לחבר נקודות, בקו ישר, או לחבר מסלול ביניהן כפי שצוין להלן. + נא לבחור כיצד לחבר את הנקודות, בקו ישר, או לחבר מסלול ביניהן כפי שצוין להלן. בשלב הבא עליך להצמיד את הדרך המורשית הקרובה ביותר לאחד מפרופילי הניווט שלך כדי להשתמש באפשרות הזו. תמונות ברמת רחוב להתעלם מהשינויים במסלול המתוכנן על ידי סגירתו\? @@ -3939,4 +3939,13 @@ נא להמתין לחישוב המסלול מחדש. \nהתרשים יהיה זמין לאחר החישוב מחדש. %1$s ‏— %2$s + מפות מקומיות + שירות לציבור + מיוחד + תחבורה + שירות + סמלים + ספורט + חירום + טיול \ No newline at end of file diff --git a/OsmAnd/res/values-ja/phrases.xml b/OsmAnd/res/values-ja/phrases.xml index 495b894b2c..3ddebc7b5a 100644 --- a/OsmAnd/res/values-ja/phrases.xml +++ b/OsmAnd/res/values-ja/phrases.xml @@ -990,7 +990,7 @@ ベトナム語 wiki ボラピュク語 wiki 中国語 wiki - 係船柱 + 自転車用車止め オートバイ用車止め ブロック @@ -1260,8 +1260,8 @@ 掃除機 ディーゼル排気用液(AdBlue・尿素水) ドライブスルー - 有り - 無し + + ドライブスルー: 不可 91UL 無鉛航空燃料 100LL 有鉛航空燃料 JET A-1ジェット燃料 @@ -1577,7 +1577,7 @@ スカイスポーツの対応要素 季節営業 ドライブイン - 無し + ドライブイン: 不可 有り ボーイスカウト用キャンプ 肯定 @@ -1710,7 +1710,7 @@ 南インドのタミル伝統医学 ユナニ医学・南アジアの伝統医学 医療事務 - 有り + 代替医療の専門種 往診 無し @@ -3835,4 +3835,8 @@ ギブボックス(提供品置場) 簡易給水栓 液化天然ガス + GPXポイント + 待避所 + 車庫 + 屋上 \ No newline at end of file diff --git a/OsmAnd/res/values-ja/strings.xml b/OsmAnd/res/values-ja/strings.xml index 86695fc95d..be920969b3 100644 --- a/OsmAnd/res/values-ja/strings.xml +++ b/OsmAnd/res/values-ja/strings.xml @@ -2754,7 +2754,7 @@ POIの更新は利用できません OSMメモ、POI、またはその両方用にエクスポートします。 全てのデータ OSMメモ - 明日開く + 明日以降の次の時間に営業 名無し • 一部の機種で起動時にクラッシュしていた問題を修正 \n @@ -2775,11 +2775,11 @@ POIの更新は利用できません 駐車上限時刻 時間制限なし 記事の全文を読む - 以下の場所から開く - 以下の所まで開く - 閉店時間 - 開店予定時間 - 営業予定時刻 + 次の時間から営業 + 次の時間まで営業 + 営業終了時間 + 営業開始時間 + 営業開始時間 マップマーカーを作成しよう! 通過した地点のマーカーと通過予定地点のマーカーがこの画面に表示されます。 diff --git a/OsmAnd/res/values-nl/strings.xml b/OsmAnd/res/values-nl/strings.xml index 6557da422c..129ae33b02 100644 --- a/OsmAnd/res/values-nl/strings.xml +++ b/OsmAnd/res/values-nl/strings.xml @@ -636,7 +636,7 @@ Gebruik online kaarten (download en bewaar deze op SD-kaart). Online kaarten Configureer online of bewaarde kaarttegels. - Geeft toegang tot vele soorten online (zogenaamde tile of raster) kaarten, van vooraf gedefinieerde OSM tiles (zoals Mapnik) tot satellietbeelden en lagen voor speciale doeleinden zoals weerkaarten, klimaatkaarten, geologische kaarten, reliëfschaduwlagen, enz. + Geeft toegang tot vele soorten online (zogenaamde tile of raster) kaarten, van vooraf gedefinieerde OSM tiles (zoals Mapnik) tot satellietbeelden en lagen voor speciale doeleinden zoals weerkaarten, klimaatkaarten, geologische kaarten, reliëf schaduwlagen, enz. \n \nAl deze kaarten kunnen worden gebruikt als de hoofd(basis)kaart, of als een extra laag of een achtergrondlaag bij een andere basiskaart (zoals de normale offline kaarten van OsmAnd). Om een achtergrondlaag beter te kunnen zien, kunt u elementen van de OsmAnd vectorkaarten eenvoudig verbergen via het menu \'Kaart instellen\'. \n @@ -769,9 +769,7 @@ \n - Beperkt aantal kaartdownloads \n - Geen toegang tot offline Wikipedia POI\'s \n -\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. +\n OsmAnd wordt actief ontwikkeld en ons project en de verdere vooruitgang ervan is afhankelijk van financiële bijdragen om de ontwikkeling en testen van nieuwe functionaliteit te kunnen bekostigen. Wij verzoeken je om OsmAnd+ te kopen, of om een donatie over te maken via https://osmand.net. OsmAnd+ (OSM Automated Navigation Directions) \n \nOsmAnd+ is een open-source app voor navigatie die gebruikmaakt van de wereldwijde verzameling van OSM-gegevens. Alle kaartmateriaal (vector- en rasterkaarten) kunnen worden opgeslagen in het telefoongeheugen voor offline gebruik. De app biedt ook offline- en online-navigatie, met stembegeleiding. @@ -1283,7 +1281,7 @@ Widgets Linker Kolom Kaart instellen Binnen - Anonieme gebruikers 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. @@ -1532,7 +1530,7 @@ Hoogte van het voertuig Geef de hoogte die minimaal toegestaan moet zijn op de route. Slim opnieuw berekenen van routes - Herbereken alleen het begin van de route voor lange trajecten. + Herbereken alleen het begin van de route. Kan gebruikt worden voor lange trajecten. Verwijder OSM-wijziging Uitgeschakeld Kleuren naar Wandelroute-netwerk @@ -3336,7 +3334,7 @@ U kunt geen standaard OsmAnd profielen verwijderen, maar u kunt ze deactiveren (in het vorige scherm), of naar onderen verplaatsen. Wijzig profielen \'Navigatietype\' bepaalt hoe routes berekend worden. - Profiel aanzicht + Profiel weergave Icoon, kleur en naam Wijzig lijst met profielen Geselecteerd profiel @@ -3779,4 +3777,121 @@ Kies een trackbestand om te volgen of importeer het, vanaf uw apparaat. Kloof Op maat + Voer een OAuth-login uit om osm edit functies te gebruiken + "• Bijgewerkte app- en profielinstellingen: instellingen zijn nu gerangschikt op type. Elk profiel kan afzonderlijk worden aangepast. +\n +\n • Nieuw dialoogvenster voor het downloaden van kaarten waarin wordt voorgesteld een kaart te downloaden tijdens het browsen +\n +\n • Donkere thema-fixes +\n +\n • Verschillende routeringsproblemen over de hele wereld opgelost +\n +\n • Bijgewerkte basiskaart met meer gedetailleerd wegennet +\n +\n • Vaste overstroomde gebieden over de hele wereld +\n +\n • Skirouting: hoogteprofiel en routecomplexiteit toegevoegd aan de routedetails +\n +\n • Andere bugs opgelost +\n +\n" + "• Profielen: nu kunt u de volgorde wijzigen, het pictogram voor de kaart instellen, alle instellingen voor basisprofielen wijzigen en ze terugzetten naar de standaardinstellingen +\n +\n • Exitnummer toegevoegd in de navigatie +\n +\n • Herwerkte plug-in instellingen +\n +\n • Herwerkt instellingenscherm voor snelle toegang tot alle profielen +\n +\n • Optie toegevoegd om instellingen van een ander profiel te kopiëren +\n +\n • Mogelijkheid toegevoegd om een volgorde te wijzigen of POI-categorieën in Zoeken te verbergen +\n +\n • Correct uitgelijnde POI-pictogrammen op de kaart +\n +\n • Zonsondergang / zonsopganggegevens toegevoegd om de kaart te configureren +\n +\n • Thuis/werk-pictogrammen toegevoegd op de kaart +\n +\n • Ondersteuning toegevoegd voor meerdere regels beschrijving bij Instellingen +\n +\n • Correcte transliteratie toegevoegd aan de kaart van Japan +\n +\n • Antarctica-kaart toegevoegd +\n +\n" + Wat is er nieuw + Voor sneeuwscooter, rijden met speciale wegen en tracks. + Stel aantal werkdagen in om door te gaan + Selecteer het interval waarmee markeringen met afstand of tijd op de track worden weergegeven. + Selecteer de gewenste splitsingsoptie: op tijd of op afstand. + Vaste + Overschrijf track + Drempelafstand + Navigatieprofiel + In geval van een omgekeerde richting + Routes + Routes + Routes + Log track naar GPX-bestand + Volg route + Voeg trackbestanden toe + Voeg een trackwaypoint toe + Volg de track + Kies een trackbestand om te volgen + Selecteer een andere track + Navigeer vanaf mijn positie naar de track + Track starten + Dichtstbijzijnde punt + Aan wegen koppelen + Adres verwijderen + Adres ingeven + Adres ingeven + Bestandsnaam + %s trackbestanden geselecteerd + Zal trackregistratie onderbreken wanneer de app wordt uitgeschakeld (via recente apps). (OsmAnd-achtergrondindicatie verdwijnt uit de Android-berichtenbalk.) + Vorig segment + Alle voorgaande segmenten + Alleen het geselecteerde segment wordt opnieuw berekend met het geselecteerde profiel. + Alle voorgaande segmenten worden opnieuw berekend met het geselecteerde profiel. + Open opgeslagen track + wordt opgeslagen + Voeg ten minste twee punten toe. + Opnieuw doen + Laatst gewijzigd + Naam: A – Z + Naam: A – Z + Start/stop iconen + Bedankt voor het kopen van \'Contourlijnen\' + Abonnement berekend per geselecteerde periode. Annuleer het op elk moment op AppGallery. + De betaling wordt bij de bevestiging van de aankoop in rekening gebracht op uw AppGallery-account. +\n +\nHet abonnement wordt automatisch verlengd, tenzij het vóór de verlengingsdatum wordt opgezegd. Uw account wordt alleen op de verlengingsdatum in rekening gebracht voor de verlengingsperiode (maand / drie maanden / jaar). +\n +\nU kunt uw abonnementen beheren en annuleren door naar uw AppGallery-instellingen te gaan. + Vermijd voetpaden + Vermijd voetpaden + Ontwikkeling + OsmAnd Live gegevens + OsmAnd Live gegevens + Twee stappen routeberekening voor autonavigatie. + Eigen ontwikkeling van het openbaar vervoer + Schakel over naar Java (veilige) routeberekening voor het openbaar vervoer + Inloggen via OAuth + Wis OpenStreetMap OAuth-token + Uitloggen gelukt + Het bestand is al geïmporteerd in OsmAnd + Lokale kaarten + Aangenaam + Speciaal + Transport + Onderhoud + Symbolen + Sport + Noodtoestand + Reizen + Trackbestanden importeren of opnemen + Track waypoint toevoegen + Opslaan als trackbestand + Rec \ 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 f6e3fc9f64..0d88da8148 100644 --- a/OsmAnd/res/values-pt-rBR/strings.xml +++ b/OsmAnd/res/values-pt-rBR/strings.xml @@ -3929,4 +3929,13 @@ Aguarde o recálculo da rota. \nO gráfico estará disponível após o recálculo. %1$s — %2$s + Mapas locais + Amenidade + Especial + Transporte + Serviço + Símbolos + Esporte + Emergência + Viagem \ No newline at end of file diff --git a/OsmAnd/res/values-ru/phrases.xml b/OsmAnd/res/values-ru/phrases.xml index 7b0db11a82..36b7e66d59 100644 --- a/OsmAnd/res/values-ru/phrases.xml +++ b/OsmAnd/res/values-ru/phrases.xml @@ -3762,7 +3762,7 @@ Тип монастыря: монашество Магазин защиты и безопасности Горноспасательная станция - Сигнал для поиска полюса + Доступ в Интернет: клиенты Многоуровневые маршруты: нет Многоуровневые маршруты: есть Взрывной залп: вторая или более поздняя детонация залпового теста @@ -3833,4 +3833,6 @@ Магазин орехов Улей СПГ + Навесы + Точка GPX \ No newline at end of file diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index 145cd10775..ef0b614441 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -3924,4 +3924,17 @@ Файл уже импортирован Дождитесь пересчёта маршрута. \nГрафик будет доступен после пересчёта. - + Разрыв + Сервис + Специальные + Для езды на снегоходах по выделенным дорогам и трассам. + Разработка + Местная карта + %1$s — %2$s + Удобства + Транспорт + Символы + Спорт + Экстренные службы + Путешествие + \ No newline at end of file diff --git a/OsmAnd/res/values-sk/strings.xml b/OsmAnd/res/values-sk/strings.xml index 9f57bcf8fd..1ae947c024 100644 --- a/OsmAnd/res/values-sk/strings.xml +++ b/OsmAnd/res/values-sk/strings.xml @@ -3935,4 +3935,13 @@ \nGraf bude dostupný po prepočte. %1$s — %2$s Medzera + Lokálne mapy + Občianska vybavenosť + Špeciálne + Doprava + Služby + Symboly + Šport + Núdzová situácia/Záchrana + Cestovanie \ No newline at end of file diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml index aec06b50db..f75ae53dfc 100644 --- a/OsmAnd/res/values-uk/strings.xml +++ b/OsmAnd/res/values-uk/strings.xml @@ -3931,4 +3931,13 @@ \nГрафік буде доступний після переобчислення. Розрив %1$s — %2$s + Місцеві мапи + Зручності + Спеціальні + Транспорт + Послуги + Знаки + Спорт + Аварійні служби + Мандрівка \ No newline at end of file diff --git a/OsmAnd/res/values-zh-rTW/strings.xml b/OsmAnd/res/values-zh-rTW/strings.xml index c25c031f20..980ed0c113 100644 --- a/OsmAnd/res/values-zh-rTW/strings.xml +++ b/OsmAnd/res/values-zh-rTW/strings.xml @@ -3930,4 +3930,13 @@ \n重新計算後即可使用圖表。 %1$s — %2$s 分隔 + 本機地圖 + 便利設施 + 特殊 + 運輸 + 服務 + 符號 + 運動 + 警急 + 旅行 \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index d5287d60bb..7861393b31 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -628,8 +628,10 @@ Configure profile Settings for profile: OsmAnd uses the UTM Standard, which is similar but not identical to the UTM NATO format. + OsmAnd uses MGRS, which is similar to the UTM NATO format. Example UTM Standard + MGRS Open Location Code The selected format will be applied throughout the app. This setting is selected by default for profiles: %s @@ -2209,6 +2211,7 @@ Map language Transport stops Zone + MGRS Open Location Code Invalid OLC\n diff --git a/OsmAnd/res/xml/coordinates_format.xml b/OsmAnd/res/xml/coordinates_format.xml index 083f42182b..6f2635e71f 100644 --- a/OsmAnd/res/xml/coordinates_format.xml +++ b/OsmAnd/res/xml/coordinates_format.xml @@ -27,6 +27,12 @@ android:persistent="false" android:title="@string/navigate_point_format_utm" /> + + points = new ArrayList<>(); + public FavoriteGroup() { + } + + public FavoriteGroup(String name, boolean visible, int color) { + this.name = name; + this.visible = visible; + this.color = color; + } + + public FavoriteGroup(String name, List points, int color, boolean visible) { + this.name = name; + this.color = color; + this.points = points; + this.visible = visible; + } + public boolean isPersonal() { return isPersonal(name); } @@ -640,7 +656,7 @@ public class FavouritesDbHelper { return asGpxFile(cachedFavoritePoints); } - private GPXFile asGpxFile(List favoritePoints) { + public GPXFile asGpxFile(List favoritePoints) { GPXFile gpx = new GPXFile(Version.getFullVersion(context)); for (FavouritePoint p : favoritePoints) { context.getSelectedGpxHelper().addPoint(p.toWpt(context), gpx); diff --git a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java index b58b3eba5e..f9d3315bf5 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java @@ -4,6 +4,7 @@ import android.content.Context; import android.text.format.DateUtils; import com.jwetherell.openmap.common.LatLonPoint; +import com.jwetherell.openmap.common.MGRSPoint; import com.jwetherell.openmap.common.UTMPoint; import net.osmand.LocationConvert; @@ -53,6 +54,7 @@ public class OsmAndFormatter { public static final int FORMAT_SECONDS = LocationConvert.FORMAT_SECONDS; public static final int UTM_FORMAT = LocationConvert.UTM_FORMAT; public static final int OLC_FORMAT = LocationConvert.OLC_FORMAT; + public static final int MGRS_FORMAT = LocationConvert.MGRS_FORMAT; private static final char DELIMITER_DEGREES = '°'; private static final char DELIMITER_MINUTES = '′'; private static final char DELIMITER_SECONDS = '″'; @@ -518,6 +520,9 @@ public class OsmAndFormatter { r = "0, 0"; } result.append(r); + } else if (outputFormat == MGRS_FORMAT) { + MGRSPoint pnt = new MGRSPoint(new LatLonPoint(lat, lon)); + result.append(pnt.toFlavoredString(5)); } return result.toString(); } diff --git a/OsmAnd/src/net/osmand/plus/activities/NavigatePointFragment.java b/OsmAnd/src/net/osmand/plus/activities/NavigatePointFragment.java index 0d88642e4b..7b0ca4c17c 100644 --- a/OsmAnd/src/net/osmand/plus/activities/NavigatePointFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/NavigatePointFragment.java @@ -21,6 +21,7 @@ import android.widget.TextView; import androidx.fragment.app.Fragment; import com.jwetherell.openmap.common.LatLonPoint; +import com.jwetherell.openmap.common.MGRSPoint; import com.jwetherell.openmap.common.UTMPoint; import net.osmand.LocationConvert; @@ -70,8 +71,8 @@ public class NavigatePointFragment extends Fragment implements SearchActivityChi } currentFormat = app.getSettings().COORDINATES_FORMAT.get(); initUI(location.getLatitude(), location.getLongitude()); - if(savedInstanceState != null && savedInstanceState.containsKey(SEARCH_LAT) && savedInstanceState.containsKey(SEARCH_LON) && - currentFormat != PointDescription.UTM_FORMAT) { + if(savedInstanceState != null && savedInstanceState.containsKey(SEARCH_LAT) && savedInstanceState.containsKey(SEARCH_LON) && + currentFormat != PointDescription.UTM_FORMAT && currentFormat != PointDescription.MGRS_FORMAT) { String lat = savedInstanceState.getString(SEARCH_LAT); String lon = savedInstanceState.getString(SEARCH_LON); if(lat != null && lon != null && lat.length() > 0 && lon.length() > 0) { @@ -152,23 +153,52 @@ public class NavigatePointFragment extends Fragment implements SearchActivityChi protected void showCurrentFormat(LatLon l) { final EditText latEdit = ((EditText)view.findViewById(R.id.LatitudeEdit)); final EditText lonEdit = ((EditText)view.findViewById(R.id.LongitudeEdit)); - boolean utm = currentFormat == PointDescription.UTM_FORMAT; - view.findViewById(R.id.easting_row).setVisibility(utm ? View.VISIBLE : View.GONE); - view.findViewById(R.id.northing_row).setVisibility(utm ? View.VISIBLE : View.GONE); - view.findViewById(R.id.zone_row).setVisibility(utm ? View.VISIBLE : View.GONE); - view.findViewById(R.id.lat_row).setVisibility(!utm ? View.VISIBLE : View.GONE); - view.findViewById(R.id.lon_row).setVisibility(!utm ? View.VISIBLE : View.GONE); - if(currentFormat == PointDescription.UTM_FORMAT) { - final EditText northingEdit = ((EditText)view.findViewById(R.id.NorthingEdit)); - final EditText eastingEdit = ((EditText)view.findViewById(R.id.EastingEdit)); - final EditText zoneEdit = ((EditText)view.findViewById(R.id.ZoneEdit)); - UTMPoint pnt = new UTMPoint(new LatLonPoint(l.getLatitude(), l.getLongitude())); - zoneEdit.setText(pnt.zone_number + ""+pnt.zone_letter); - northingEdit.setText(((long)pnt.northing)+""); - eastingEdit.setText(((long)pnt.easting)+""); - } else { - latEdit.setText(LocationConvert.convert(MapUtils.checkLatitude(l.getLatitude()), currentFormat)); - lonEdit.setText(LocationConvert.convert(MapUtils.checkLongitude(l.getLongitude()), currentFormat)); + switch (currentFormat){ + case PointDescription.UTM_FORMAT: { + view.findViewById(R.id.easting_row).setVisibility(View.VISIBLE); + view.findViewById(R.id.northing_row).setVisibility(View.VISIBLE); + view.findViewById(R.id.zone_row).setVisibility(View.VISIBLE); + view.findViewById(R.id.lat_row).setVisibility(View.GONE); + view.findViewById(R.id.lon_row).setVisibility(View.GONE); + view.findViewById(R.id.mgrs_row).setVisibility(View.GONE); + + final EditText northingEdit = ((EditText) view.findViewById(R.id.NorthingEdit)); + final EditText eastingEdit = ((EditText) view.findViewById(R.id.EastingEdit)); + final EditText zoneEdit = ((EditText) view.findViewById(R.id.ZoneEdit)); + UTMPoint pnt = new UTMPoint(new LatLonPoint(l.getLatitude(), l.getLongitude())); + zoneEdit.setText(pnt.zone_number + "" + pnt.zone_letter); + northingEdit.setText(((long) pnt.northing) + ""); + eastingEdit.setText(((long) pnt.easting) + ""); + break; + } + + case PointDescription.MGRS_FORMAT: { + view.findViewById(R.id.easting_row).setVisibility(View.GONE); + view.findViewById(R.id.northing_row).setVisibility(View.GONE); + view.findViewById(R.id.zone_row).setVisibility(View.GONE); + view.findViewById(R.id.lat_row).setVisibility(View.GONE); + view.findViewById(R.id.lon_row).setVisibility(View.GONE); + view.findViewById(R.id.mgrs_row).setVisibility(View.VISIBLE); + + final EditText mgrsEdit = ((EditText) view.findViewById(R.id.MGRSEdit)); + MGRSPoint pnt = new MGRSPoint(new LatLonPoint(l.getLatitude(), l.getLongitude())); + mgrsEdit.setText(pnt.toFlavoredString(5)); + break; + } + + default: { + view.findViewById(R.id.easting_row).setVisibility(View.GONE); + view.findViewById(R.id.northing_row).setVisibility(View.GONE); + view.findViewById(R.id.zone_row).setVisibility(View.GONE); + view.findViewById(R.id.lat_row).setVisibility(View.VISIBLE); + view.findViewById(R.id.lon_row).setVisibility(View.VISIBLE); + view.findViewById(R.id.mgrs_row).setVisibility(View.GONE); + + + latEdit.setText(LocationConvert.convert(MapUtils.checkLatitude(l.getLatitude()), currentFormat)); + lonEdit.setText(LocationConvert.convert(MapUtils.checkLongitude(l.getLongitude()), currentFormat)); + } + } } @@ -199,6 +229,7 @@ public class NavigatePointFragment extends Fragment implements SearchActivityChi PointDescription.formatToHumanString(this.getContext(), PointDescription.FORMAT_MINUTES), PointDescription.formatToHumanString(this.getContext(), PointDescription.FORMAT_SECONDS), PointDescription.formatToHumanString(this.getContext(), PointDescription.UTM_FORMAT), + PointDescription.formatToHumanString(this.getContext(), PointDescription.MGRS_FORMAT), }); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); format.setAdapter(adapter); @@ -217,6 +248,8 @@ public class NavigatePointFragment extends Fragment implements SearchActivityChi newFormat = PointDescription.FORMAT_SECONDS; } else if (PointDescription.formatToHumanString(NavigatePointFragment.this.getContext(), PointDescription.UTM_FORMAT).equals(itm)) { newFormat = PointDescription.UTM_FORMAT; + } else if (PointDescription.formatToHumanString(NavigatePointFragment.this.getContext(), PointDescription.MGRS_FORMAT).equals(itm)) { + newFormat = PointDescription.MGRS_FORMAT; } try { LatLon loc = parseLocation(); diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java b/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java index 541300a7ec..16fb083f13 100644 --- a/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java +++ b/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java @@ -650,8 +650,8 @@ public class ImportHelper { } } - protected static List asFavourites(OsmandApplication app, List wptPts, String fileName, boolean forceImportFavourites) { - final List favourites = new ArrayList<>(); + public static List asFavourites(OsmandApplication app, List wptPts, String fileName, boolean forceImportFavourites) { + List favourites = new ArrayList<>(); for (WptPt p : wptPts) { if (p.name != null) { final String fpCat; @@ -664,18 +664,18 @@ public class ImportHelper { } else { fpCat = p.category; } - final FavouritePoint fp = new FavouritePoint(p.lat, p.lon, p.name, fpCat); + FavouritePoint point = new FavouritePoint(p.lat, p.lon, p.name, fpCat); if (p.desc != null) { - fp.setDescription(p.desc); + point.setDescription(p.desc); } - fp.setAddress(p.getExtensionsToRead().get("address")); - fp.setColor(p.getColor(0)); + point.setAddress(p.getExtensionsToRead().get("address")); + point.setColor(p.getColor(0)); String iconName = p.getIconName(); if (iconName != null) { - fp.setIconIdFromName(app, iconName); + point.setIconIdFromName(app, iconName); } - fp.setBackgroundType(BackgroundType.getByTypeName(p.getBackgroundType(), DEFAULT_BACKGROUND_TYPE)); - favourites.add(fp); + point.setBackgroundType(BackgroundType.getByTypeName(p.getBackgroundType(), DEFAULT_BACKGROUND_TYPE)); + favourites.add(point); } } return favourites; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 00d0a8cc20..e18beeeb01 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -676,9 +676,15 @@ public class MenuBuilder { LinearLayout llv = buildCollapsableContentView(mapActivity, true, true); for (final Map.Entry line : locationData.entrySet()) { final TextViewEx button = buildButtonInCollapsableView(mapActivity, false, false); - if (line.getKey() == OsmAndFormatter.UTM_FORMAT || line.getKey() == OsmAndFormatter.OLC_FORMAT) { + if (line.getKey() == OsmAndFormatter.UTM_FORMAT || line.getKey() == OsmAndFormatter.OLC_FORMAT || line.getKey() == OsmAndFormatter.MGRS_FORMAT) { SpannableStringBuilder ssb = new SpannableStringBuilder(); - ssb.append(line.getKey() == OsmAndFormatter.UTM_FORMAT ? "UTM: " : "OLC: "); + if (line.getKey() == OsmAndFormatter.UTM_FORMAT) { + ssb.append("UTM: "); + } else if (line.getKey() == OsmAndFormatter.MGRS_FORMAT) { + ssb.append("MGRS: "); + } else if (line.getKey() == OsmAndFormatter.OLC_FORMAT){ + ssb.append("OLC: "); + } ssb.setSpan(new ForegroundColorSpan(app.getResources().getColor(R.color.text_color_secondary_light)), 0, 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); ssb.append(line.getValue()); button.setText(ssb); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java index 5b9b9eb7ce..285e323867 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java @@ -323,9 +323,9 @@ public class OsmEditingPlugin extends OsmandPlugin { @Override public void addMyPlacesTab(FavoritesActivity favoritesActivity, List mTabs, Intent intent) { - mTabs.add(favoritesActivity.getTabIndicator(R.string.osm_edits, OsmEditsFragment.class)); + mTabs.add(favoritesActivity.getTabIndicator(OSM_EDIT_TAB, OsmEditsFragment.class)); if (intent != null && "OSM".equals(intent.getStringExtra("TAB"))) { - app.getSettings().FAVORITES_TAB.set(R.string.osm_edits); + app.getSettings().FAVORITES_TAB.set(OSM_EDIT_TAB); } } diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchCoordinatesFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchCoordinatesFragment.java index 902f4bea4b..78383f3179 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchCoordinatesFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchCoordinatesFragment.java @@ -29,6 +29,7 @@ import androidx.fragment.app.DialogFragment; import com.google.openlocationcode.OpenLocationCode; import com.jwetherell.openmap.common.LatLonPoint; +import com.jwetherell.openmap.common.MGRSPoint; import com.jwetherell.openmap.common.UTMPoint; import net.osmand.AndroidUtils; @@ -73,6 +74,7 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os private static final String QUICK_SEARCH_COORDS_NORTH_KEY = "quick_search_coords_north_key"; private static final String QUICK_SEARCH_COORDS_EAST_KEY = "quick_search_coords_east_key"; private static final String QUICK_SEARCH_COORDS_ZONE_KEY = "quick_search_coords_zone_key"; + private static final String QUICK_SEARCH_COORDS_MGRS_KEY = "quick_search_coords_mgrs_key"; private static final String QUICK_SEARCH_COORDS_OLC_KEY = "quick_search_coords_olc_key"; private static final String QUICK_SEARCH_COORDS_OLC_INFO_KEY = "quick_search_coords_olc_info_key"; private static final String QUICK_SEARCH_COORDS_FORMAT_KEY = "quick_search_coords_format_key"; @@ -89,6 +91,7 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os private EditText northingEdit; private EditText eastingEdit; private EditText zoneEdit; + private EditText mgrsEdit; private EditText olcEdit; private TextView olcInfo; private EditText formatEdit; @@ -153,6 +156,7 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os northingEdit = ((EditText) view.findViewById(R.id.northingEditText)); eastingEdit = ((EditText) view.findViewById(R.id.eastingEditText)); zoneEdit = ((EditText) view.findViewById(R.id.zoneEditText)); + mgrsEdit = ((EditText) view.findViewById(R.id.mgrsEditText)); olcEdit = ((EditText) view.findViewById(R.id.olcEditText)); olcInfo = ((TextView) view.findViewById(R.id.olcInfoTextView)); formatEdit = ((EditText) view.findViewById(R.id.formatEditText)); @@ -160,6 +164,7 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os String defaultLat = ""; String defaultZone = ""; + String defaultMgrs = ""; String defaultOlc = ""; boolean coordinatesApplied = false; if (getArguments() != null) { @@ -167,6 +172,8 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os if (!Algorithms.isEmpty(text)) { if (currentFormat == PointDescription.UTM_FORMAT) { defaultZone = text.trim(); + } else if (currentFormat == PointDescription.MGRS_FORMAT) { + defaultMgrs = text.trim(); } else if (currentFormat == PointDescription.OLC_FORMAT) { defaultOlc = text.trim(); } else { @@ -188,6 +195,7 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os String northingStr = getStringValue(savedInstanceState, QUICK_SEARCH_COORDS_NORTH_KEY, ""); String eastingStr = getStringValue(savedInstanceState, QUICK_SEARCH_COORDS_EAST_KEY, ""); String zoneStr = getStringValue(savedInstanceState, QUICK_SEARCH_COORDS_ZONE_KEY, defaultZone); + String mgrsStr = getStringValue(savedInstanceState, QUICK_SEARCH_COORDS_MGRS_KEY, defaultMgrs); String olcStr = getStringValue(savedInstanceState, QUICK_SEARCH_COORDS_OLC_KEY, defaultOlc); String olcInfoStr = getStringValue(savedInstanceState, QUICK_SEARCH_COORDS_OLC_INFO_KEY, defaultOlc); @@ -209,6 +217,8 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os eastingEdit.setSelection(eastingStr.length()); zoneEdit.setText(zoneStr); zoneEdit.setSelection(zoneStr.length()); + mgrsEdit.setText(mgrsStr); + mgrsEdit.setSelection(mgrsStr.length()); olcEdit.setText(olcStr); olcEdit.setSelection(olcStr.length()); olcInfo.setText(olcInfoStr); @@ -242,6 +252,7 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os northingEdit.addTextChangedListener(textWatcher); eastingEdit.addTextChangedListener(textWatcher); zoneEdit.addTextChangedListener(textWatcher); + mgrsEdit.addTextChangedListener(textWatcher); olcEdit.addTextChangedListener(textWatcher); OnEditorActionListener doneListener = new OnEditorActionListener() { @@ -258,6 +269,7 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os lonEdit.setOnEditorActionListener(doneListener); zoneEdit.setOnEditorActionListener(doneListener); + mgrsEdit.setOnEditorActionListener(doneListener); olcEdit.setOnEditorActionListener(doneListener); UiUtilities ic = app.getUIUtilities(); @@ -318,6 +330,15 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os olcEdit.setText(""); } }); + ImageButton mgrsClearButton = (ImageButton) view.findViewById(R.id.mgrsClearButton); + mgrsClearButton.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_remove_dark)); + mgrsClearButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + mgrsEdit.setText(""); + } + }); + ImageButton formatSelectButton = (ImageButton) view.findViewById(R.id.formatSelectButton); formatSelectButton.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_arrow_drop_down)); formatSelectButton.setOnClickListener(new View.OnClickListener() { @@ -364,6 +385,7 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os final TextView northEdit = ((TextView) view.findViewById(R.id.northingEditText)); final TextView eastEdit = ((TextView) view.findViewById(R.id.eastingEditText)); final TextView zoneEdit = ((TextView) view.findViewById(R.id.zoneEditText)); + final TextView mgrsEdit = ((TextView) view.findViewById(R.id.mgrsEditText)); final TextView olcEdit = ((TextView) view.findViewById(R.id.olcEditText)); final TextView olcInfo = ((TextView) view.findViewById(R.id.olcInfoTextView)); outState.putString(QUICK_SEARCH_COORDS_LAT_KEY, latEdit.getText().toString()); @@ -371,6 +393,7 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os outState.putString(QUICK_SEARCH_COORDS_NORTH_KEY, northEdit.getText().toString()); outState.putString(QUICK_SEARCH_COORDS_EAST_KEY, eastEdit.getText().toString()); outState.putString(QUICK_SEARCH_COORDS_ZONE_KEY, zoneEdit.getText().toString()); + outState.putString(QUICK_SEARCH_COORDS_MGRS_KEY, mgrsEdit.getText().toString()); outState.putString(QUICK_SEARCH_COORDS_OLC_KEY, olcEdit.getText().toString()); outState.putString(QUICK_SEARCH_COORDS_OLC_INFO_KEY, olcInfo.getText().toString()); } @@ -470,23 +493,52 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os } private void updateControlsVisibility() { - if (currentFormat == PointDescription.OLC_FORMAT) { - view.findViewById(R.id.eastingLayout).setVisibility(View.GONE); - view.findViewById(R.id.northingLayout).setVisibility(View.GONE); - view.findViewById(R.id.zoneLayout).setVisibility(View.GONE); - view.findViewById(R.id.olcLayout).setVisibility(View.VISIBLE); - view.findViewById(R.id.olcInfoLayout).setVisibility(View.VISIBLE); - view.findViewById(R.id.latitudeLayout).setVisibility(View.GONE); - view.findViewById(R.id.longitudeLayout).setVisibility(View.GONE); - } else { - boolean utm = currentFormat == PointDescription.UTM_FORMAT; - view.findViewById(R.id.eastingLayout).setVisibility(utm ? View.VISIBLE : View.GONE); - view.findViewById(R.id.northingLayout).setVisibility(utm ? View.VISIBLE : View.GONE); - view.findViewById(R.id.zoneLayout).setVisibility(utm ? View.VISIBLE : View.GONE); - view.findViewById(R.id.olcLayout).setVisibility(View.GONE); - view.findViewById(R.id.olcInfoLayout).setVisibility(View.GONE); - view.findViewById(R.id.latitudeLayout).setVisibility(!utm ? View.VISIBLE : View.GONE); - view.findViewById(R.id.longitudeLayout).setVisibility(!utm ? View.VISIBLE : View.GONE); + switch (currentFormat){ + + case PointDescription.OLC_FORMAT: { + view.findViewById(R.id.eastingLayout).setVisibility(View.GONE); + view.findViewById(R.id.northingLayout).setVisibility(View.GONE); + view.findViewById(R.id.zoneLayout).setVisibility(View.GONE); + view.findViewById(R.id.olcLayout).setVisibility(View.VISIBLE); + view.findViewById(R.id.olcInfoLayout).setVisibility(View.VISIBLE); + view.findViewById(R.id.latitudeLayout).setVisibility(View.GONE); + view.findViewById(R.id.longitudeLayout).setVisibility(View.GONE); + view.findViewById(R.id.mgrsLayout).setVisibility(View.GONE); + break; + } + case PointDescription.UTM_FORMAT: { + view.findViewById(R.id.eastingLayout).setVisibility(View.VISIBLE); + view.findViewById(R.id.northingLayout).setVisibility(View.VISIBLE); + view.findViewById(R.id.zoneLayout).setVisibility(View.VISIBLE); + view.findViewById(R.id.olcLayout).setVisibility(View.GONE); + view.findViewById(R.id.olcInfoLayout).setVisibility(View.GONE); + view.findViewById(R.id.latitudeLayout).setVisibility(View.GONE); + view.findViewById(R.id.longitudeLayout).setVisibility(View.GONE); + view.findViewById(R.id.mgrsLayout).setVisibility(View.GONE); + break; + } + case PointDescription.MGRS_FORMAT: { + view.findViewById(R.id.eastingLayout).setVisibility(View.GONE); + view.findViewById(R.id.northingLayout).setVisibility(View.GONE); + view.findViewById(R.id.zoneLayout).setVisibility(View.GONE); + view.findViewById(R.id.olcLayout).setVisibility(View.GONE); + view.findViewById(R.id.olcInfoLayout).setVisibility(View.GONE); + view.findViewById(R.id.latitudeLayout).setVisibility(View.GONE); + view.findViewById(R.id.longitudeLayout).setVisibility(View.GONE); + view.findViewById(R.id.mgrsLayout).setVisibility(View.VISIBLE); + break; + } + default: { + view.findViewById(R.id.eastingLayout).setVisibility(View.GONE); + view.findViewById(R.id.northingLayout).setVisibility(View.GONE); + view.findViewById(R.id.zoneLayout).setVisibility(View.GONE); + view.findViewById(R.id.olcLayout).setVisibility(View.GONE); + view.findViewById(R.id.olcInfoLayout).setVisibility(View.GONE); + view.findViewById(R.id.latitudeLayout).setVisibility(View.VISIBLE); + view.findViewById(R.id.longitudeLayout).setVisibility(View.VISIBLE); + view.findViewById(R.id.mgrsLayout).setVisibility(View.GONE); + break; + } } } @@ -544,11 +596,28 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os zoneEdit.setText(olcEdit.getText()); northingEdit.setText(""); eastingEdit.setText(""); + } else if (prevFormat == PointDescription.MGRS_FORMAT) { + zoneEdit.setText(mgrsEdit.getText()); + northingEdit.setText(""); + eastingEdit.setText(""); } else { zoneEdit.setText(latEdit.getText()); northingEdit.setText(""); eastingEdit.setText(""); } + } else if (currentFormat == PointDescription.MGRS_FORMAT) { + final EditText mgrsEdit = ((EditText) view.findViewById(R.id.mgrsEditText)); + if (latLon != null) { + MGRSPoint pnt = new MGRSPoint(new LatLonPoint(latLon.getLatitude(), latLon.getLongitude())); + mgrsEdit.setText(pnt.toFlavoredString(5)); + } else if (prevFormat == PointDescription.UTM_FORMAT) { + mgrsEdit.setText(zoneEdit.getText()); + } else if (prevFormat == PointDescription.OLC_FORMAT) { + mgrsEdit.setText(olcEdit.getText()); + } else { + mgrsEdit.setText(latEdit.getText()); + + } } else if (currentFormat == PointDescription.OLC_FORMAT) { if (latLon != null) { String olc = OpenLocationCode.encode(latLon.getLatitude(), latLon.getLongitude()); @@ -557,6 +626,9 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os } else if (prevFormat == PointDescription.UTM_FORMAT) { olcEdit.setText(zoneEdit.getText()); olcInfo.setText(provideOlcInfo(olcEdit.getText().toString())); + } else if (prevFormat == PointDescription.MGRS_FORMAT) { + olcEdit.setText(mgrsEdit.getText()); + olcInfo.setText(provideOlcInfo(olcEdit.getText().toString())); } else { olcEdit.setText(latEdit.getText()); olcInfo.setText(provideOlcInfo(olcEdit.getText().toString())); @@ -568,6 +640,9 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os } else if (prevFormat == PointDescription.UTM_FORMAT) { latEdit.setText(zoneEdit.getText()); lonEdit.setText(""); + } else if (prevFormat == PointDescription.MGRS_FORMAT) { + latEdit.setText(mgrsEdit.getText()); + lonEdit.setText(""); } else if (prevFormat == PointDescription.OLC_FORMAT) { latEdit.setText(olcEdit.getText()); lonEdit.setText(""); @@ -591,6 +666,11 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os UTMPoint upoint = new UTMPoint(northing, easting, z, c); LatLonPoint ll = upoint.toLatLonPoint(); loc = new LatLon(ll.getLatitude(), ll.getLongitude()); + } else if (currentFormat == LocationConvert.MGRS_FORMAT) { + String mgrs = (mgrsEdit.getText().toString()); + MGRSPoint upoint = new MGRSPoint(mgrs); + LatLonPoint ll = upoint.toLatLonPoint(); + loc = new LatLon(ll.getLatitude(), ll.getLongitude()); } else if (currentFormat == LocationConvert.OLC_FORMAT) { String olcText = olcEdit.getText().toString(); olcInfo.setText(provideOlcInfo(olcText)); @@ -851,12 +931,13 @@ public class QuickSearchCoordinatesFragment extends DialogFragment implements Os @Override public Dialog onCreateDialog(Bundle savedInstanceState) { final QuickSearchCoordinatesFragment parent = (QuickSearchCoordinatesFragment) getParentFragment(); - String[] entries = new String[5]; + String[] entries = new String[6]; entries[0] = PointDescription.formatToHumanString(getContext(), PointDescription.FORMAT_DEGREES); entries[1] = PointDescription.formatToHumanString(getContext(), PointDescription.FORMAT_MINUTES); entries[2] = PointDescription.formatToHumanString(getContext(), PointDescription.FORMAT_SECONDS); entries[3] = PointDescription.formatToHumanString(getContext(), PointDescription.UTM_FORMAT); entries[4] = PointDescription.formatToHumanString(getContext(), PointDescription.OLC_FORMAT); + entries[5] = PointDescription.formatToHumanString(getContext(), PointDescription.MGRS_FORMAT); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.coords_format) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java b/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java index 17901458ec..591e5ae55b 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/ExportSettingsType.java @@ -13,5 +13,6 @@ public enum ExportSettingsType { GLOBAL, OSM_NOTES, OSM_EDITS, - OFFLINE_MAPS + OFFLINE_MAPS, + FAVORITES } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/AvoidRoadsSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/AvoidRoadsSettingsItem.java index 3088d9e86f..61b5f28541 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/AvoidRoadsSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/AvoidRoadsSettingsItem.java @@ -174,6 +174,6 @@ public class AvoidRoadsSettingsItem extends CollectionSettingsItem getWriter() { - return null; + return getJsonWriter(); } } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/DownloadsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/DownloadsItem.java index 67b9d5812e..7c9318ad37 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/DownloadsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/DownloadsItem.java @@ -97,6 +97,6 @@ public class DownloadsItem extends SettingsItem { @Nullable @Override SettingsItemWriter getWriter() { - return null; + return getJsonWriter(); } } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/FavoritesSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/FavoritesSettingsItem.java new file mode 100644 index 0000000000..8e8c4c6f36 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/FavoritesSettingsItem.java @@ -0,0 +1,197 @@ +package net.osmand.plus.settings.backend.backup; + +import android.content.Context; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import net.osmand.GPXUtilities; +import net.osmand.GPXUtilities.GPXFile; +import net.osmand.data.FavouritePoint; +import net.osmand.plus.FavouritesDbHelper; +import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import static net.osmand.IndexConstants.GPX_FILE_EXT; +import static net.osmand.plus.importfiles.ImportHelper.asFavourites; + +public class FavoritesSettingsItem extends CollectionSettingsItem { + + private FavouritesDbHelper favoritesHelper; + + public FavoritesSettingsItem(@NonNull OsmandApplication app, @NonNull List items) { + super(app, null, items); + } + + public FavoritesSettingsItem(@NonNull OsmandApplication app, @Nullable FavoritesSettingsItem baseItem, @NonNull List items) { + super(app, baseItem, items); + } + + FavoritesSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException { + super(app, json); + } + + @Override + protected void init() { + super.init(); + favoritesHelper = app.getFavorites(); + existingItems = new ArrayList<>(favoritesHelper.getFavoriteGroups()); + } + + @NonNull + @Override + public SettingsItemType getType() { + return SettingsItemType.FAVOURITES; + } + + @NonNull + @Override + public String getName() { + return "favourites"; + } + + @NonNull + @Override + public String getPublicName(@NonNull Context ctx) { + return ctx.getString(R.string.shared_string_favorites); + } + + @NonNull + public String getDefaultFileName() { + return getName() + getDefaultFileExtension(); + } + + @NonNull + public String getDefaultFileExtension() { + return GPX_FILE_EXT; + } + + @Override + public void apply() { + List newItems = getNewItems(); + if (!newItems.isEmpty() || !duplicateItems.isEmpty()) { + appliedItems = new ArrayList<>(newItems); + + for (FavoriteGroup duplicate : duplicateItems) { + if (shouldReplace) { + FavoriteGroup existingGroup = favoritesHelper.getGroup(duplicate.getName()); + if (existingGroup != null) { + List favouritePoints = new ArrayList<>(existingGroup.getPoints()); + for (FavouritePoint favouritePoint : favouritePoints) { + favoritesHelper.deleteFavourite(favouritePoint, false); + } + } + } + appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate)); + } + List favourites = getPointsFromGroups(appliedItems); + for (FavouritePoint favourite : favourites) { + favoritesHelper.addFavourite(favourite, false); + } + favoritesHelper.sortAll(); + favoritesHelper.saveCurrentPointsIntoFile(); + } + } + + @Override + public boolean isDuplicate(@NonNull FavoriteGroup favoriteGroup) { + String name = favoriteGroup.getName(); + for (FavoriteGroup group : existingItems) { + if (group.getName().equals(name)) { + return true; + } + } + return false; + } + + @Override + public boolean shouldReadOnCollecting() { + return true; + } + + @NonNull + @Override + public FavoriteGroup renameItem(@NonNull FavoriteGroup item) { + int number = 0; + while (true) { + number++; + String name = item.getName() + " (" + number + ")"; + FavoriteGroup renamedItem = new FavoriteGroup(name, item.getPoints(), item.getColor(), item.isVisible()); + if (!isDuplicate(renamedItem)) { + for (FavouritePoint point : renamedItem.getPoints()) { + point.setCategory(renamedItem.getName()); + } + return renamedItem; + } + } + } + + @Nullable + @Override + SettingsItemReader getReader() { + return new SettingsItemReader(this) { + + @Override + public void readFromStream(@NonNull InputStream inputStream) throws IllegalArgumentException { + GPXFile gpxFile = GPXUtilities.loadGPXFile(inputStream); + if (gpxFile.error != null) { + warnings.add(app.getString(R.string.settings_item_read_error, String.valueOf(getType()))); + SettingsHelper.LOG.error("Failed read gpx file", gpxFile.error); + } else { + Map flatGroups = new LinkedHashMap<>(); + List favourites = asFavourites(app, gpxFile.getPoints(), fileName, false); + for (FavouritePoint point : favourites) { + FavoriteGroup group = flatGroups.get(point.getCategory()); + if (group == null) { + group = new FavoriteGroup(point.getCategory(), point.isVisible(), point.getColor()); + flatGroups.put(group.getName(), group); + items.add(group); + } + group.getPoints().add(point); + } + } + } + }; + } + + private List getPointsFromGroups(List groups) { + List favouritePoints = new ArrayList<>(); + for (FavoriteGroup group : groups) { + favouritePoints.addAll(group.getPoints()); + } + return favouritePoints; + } + + @Nullable + @Override + SettingsItemWriter getWriter() { + return new SettingsItemWriter(this) { + + @Override + public boolean writeToStream(@NonNull OutputStream outputStream) throws IOException { + List favourites = getPointsFromGroups(items); + GPXFile gpxFile = favoritesHelper.asGpxFile(favourites); + Exception error = GPXUtilities.writeGpx(new OutputStreamWriter(outputStream, "UTF-8"), gpxFile); + if (error != null) { + warnings.add(app.getString(R.string.settings_item_write_error, String.valueOf(getType()))); + SettingsHelper.LOG.error("Failed write to gpx file", error); + return false; + } + return true; + } + }; + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/GlobalSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/GlobalSettingsItem.java index d30c4d94d8..bcf837de54 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/GlobalSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/GlobalSettingsItem.java @@ -19,6 +19,10 @@ public class GlobalSettingsItem extends OsmandSettingsItem { super(settings); } + public GlobalSettingsItem(@NonNull OsmandSettings settings, @NonNull JSONObject json) throws JSONException { + super(SettingsItemType.GLOBAL, settings, json); + } + @NonNull @Override public SettingsItemType getType() { diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/MapSourcesSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/MapSourcesSettingsItem.java index 82cf840b94..4c38a07892 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/MapSourcesSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/MapSourcesSettingsItem.java @@ -236,6 +236,6 @@ public class MapSourcesSettingsItem extends CollectionSettingsItem @Nullable @Override SettingsItemWriter getWriter() { - return null; + return getJsonWriter(); } } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java index 03e1e39ad5..287f6dc9de 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java @@ -194,6 +194,6 @@ public class OsmEditsSettingsItem extends CollectionSettingsItem getWriter() { - return null; + return getJsonWriter(); } } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmNotesSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmNotesSettingsItem.java index afe23c2059..edcaa350e3 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmNotesSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmNotesSettingsItem.java @@ -167,6 +167,6 @@ public class OsmNotesSettingsItem extends CollectionSettingsItem @Nullable @Override SettingsItemWriter getWriter() { - return null; + return getJsonWriter(); } } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/PoiUiFiltersSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/PoiUiFiltersSettingsItem.java index 8d1c464761..29e20679d9 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/PoiUiFiltersSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/PoiUiFiltersSettingsItem.java @@ -173,6 +173,6 @@ public class PoiUiFiltersSettingsItem extends CollectionSettingsItem getWriter() { - return null; + return getJsonWriter(); } } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/QuickActionsSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/QuickActionsSettingsItem.java index b2e597ab60..499ac2a833 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/QuickActionsSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/QuickActionsSettingsItem.java @@ -178,6 +178,6 @@ public class QuickActionsSettingsItem extends CollectionSettingsItem getWriter() { - return null; + return getJsonWriter(); } } 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 0cfa472ef0..7d79ef3481 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java @@ -13,6 +13,7 @@ import net.osmand.data.LatLon; import net.osmand.map.ITileSource; import net.osmand.map.TileSourceManager; import net.osmand.map.TileSourceManager.TileSourceTemplate; +import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.SQLiteTileSource; @@ -47,7 +48,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.*; +import static net.osmand.plus.activities.LocalIndexHelper.LocalIndexType; /* Usage: @@ -535,6 +536,10 @@ public class SettingsHelper { if (!files.isEmpty()) { dataList.put(ExportSettingsType.OFFLINE_MAPS, files); } + List favoriteGroups = app.getFavorites().getFavoriteGroups(); + if (!favoriteGroups.isEmpty()) { + dataList.put(ExportSettingsType.FAVORITES, favoriteGroups); + } return dataList; } @@ -562,6 +567,7 @@ public class SettingsHelper { List tileSourceTemplates = new ArrayList<>(); List avoidRoads = new ArrayList<>(); List appModeBeans = new ArrayList<>(); + List favoriteGroups = new ArrayList<>(); List osmNotesPointList = new ArrayList<>(); List osmEditsPointList = new ArrayList<>(); @@ -586,6 +592,8 @@ public class SettingsHelper { osmNotesPointList.add((OsmNotesPoint) object); } else if (object instanceof OpenstreetmapPoint) { osmEditsPointList.add((OpenstreetmapPoint) object); + } else if (object instanceof FavoriteGroup) { + favoriteGroups.add((FavoriteGroup) object); } } if (!quickActions.isEmpty()) { @@ -614,6 +622,9 @@ public class SettingsHelper { if (!osmEditsPointList.isEmpty()) { settingsItems.add(new OsmEditsSettingsItem(app, osmEditsPointList)); } + if (!favoriteGroups.isEmpty()) { + settingsItems.add(new FavoritesSettingsItem(app, favoriteGroups)); + } return settingsItems; } @@ -632,6 +643,8 @@ public class SettingsHelper { List globalSettingsItems = new ArrayList<>(); List notesPointList = new ArrayList<>(); List editsPointList = new ArrayList<>(); + List favoriteGroups = new ArrayList<>(); + for (SettingsItem item : settingsItems) { switch (item.getType()) { case PROFILE: @@ -705,6 +718,10 @@ public class SettingsHelper { editsPointList.addAll(osmEditsSettingsItem.getItems()); } break; + case FAVOURITES: + FavoritesSettingsItem favoritesSettingsItem = (FavoritesSettingsItem) item; + favoriteGroups.addAll(favoritesSettingsItem.getItems()); + break; default: break; } @@ -749,6 +766,9 @@ public class SettingsHelper { if (!mapFilesList.isEmpty()) { settingsToOperate.put(ExportSettingsType.OFFLINE_MAPS, mapFilesList); } + if (!favoriteGroups.isEmpty()) { + settingsToOperate.put(ExportSettingsType.FAVORITES, favoriteGroups); + } return settingsToOperate; } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItem.java index caf2d57301..c80eb4cec2 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItem.java @@ -142,7 +142,6 @@ public abstract class SettingsItem { } json.put("file", fileName); } - writeItemsToJson(json); } String toJson() throws JSONException { 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 a513dc748c..bb6b68b3ce 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemType.java @@ -15,4 +15,5 @@ public enum SettingsItemType { DOWNLOADS, OSM_NOTES, OSM_EDITS, + FAVOURITES } \ 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 8545b37503..9669099003 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemsFactory.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsItemsFactory.java @@ -90,7 +90,7 @@ class SettingsItemsFactory { OsmandSettings settings = app.getSettings(); switch (type) { case GLOBAL: - item = new GlobalSettingsItem(settings); + item = new GlobalSettingsItem(settings, json); break; case PROFILE: item = new ProfileSettingsItem(app, json); @@ -131,6 +131,9 @@ class SettingsItemsFactory { case OSM_EDITS: item = new OsmEditsSettingsItem(app, json); break; + case FAVOURITES: + item = new FavoritesSettingsItem(app, json); + break; } return item; } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SuggestedDownloadsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SuggestedDownloadsItem.java index d2dd9a8554..d6411fb89d 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SuggestedDownloadsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SuggestedDownloadsItem.java @@ -123,6 +123,6 @@ public class SuggestedDownloadsItem extends SettingsItem { @Nullable @Override SettingsItemWriter getWriter() { - return null; + return getJsonWriter(); } } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/CoordinatesFormatFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/CoordinatesFormatFragment.java index 51b5d817a0..fd62f6df3c 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/CoordinatesFormatFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/CoordinatesFormatFragment.java @@ -31,11 +31,13 @@ public class CoordinatesFormatFragment extends BaseSettingsFragment { public static final String TAG = CoordinatesFormatFragment.class.getSimpleName(); private static final String UTM_FORMAT_WIKI_LINK = "https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system"; + private static final String MGRS_FORMAT_WIKI_LINK = "https://en.wikipedia.org/wiki/Military_Grid_Reference_System"; private static final String FORMAT_DEGREES = "format_degrees"; private static final String FORMAT_MINUTES = "format_minutes"; private static final String FORMAT_SECONDS = "format_seconds"; private static final String UTM_FORMAT = "utm_format"; + private static final String MGRS_FORMAT = "mgrs_format"; private static final String OLC_FORMAT = "olc_format"; @Override @@ -44,6 +46,7 @@ public class CoordinatesFormatFragment extends BaseSettingsFragment { CheckBoxPreference minutesPref = (CheckBoxPreference) findPreference(FORMAT_MINUTES); CheckBoxPreference secondsPref = (CheckBoxPreference) findPreference(FORMAT_SECONDS); CheckBoxPreference utmPref = (CheckBoxPreference) findPreference(UTM_FORMAT); + CheckBoxPreference mgrsPref = (CheckBoxPreference) findPreference(MGRS_FORMAT); CheckBoxPreference olcPref = (CheckBoxPreference) findPreference(OLC_FORMAT); Location loc = app.getLocationProvider().getLastKnownLocation(); @@ -52,6 +55,7 @@ public class CoordinatesFormatFragment extends BaseSettingsFragment { minutesPref.setSummary(getCoordinatesFormatSummary(loc, PointDescription.FORMAT_MINUTES)); secondsPref.setSummary(getCoordinatesFormatSummary(loc, PointDescription.FORMAT_SECONDS)); utmPref.setSummary(getCoordinatesFormatSummary(loc, PointDescription.UTM_FORMAT)); + mgrsPref.setSummary(getCoordinatesFormatSummary(loc, PointDescription.MGRS_FORMAT)); olcPref.setSummary(getCoordinatesFormatSummary(loc, PointDescription.OLC_FORMAT)); int currentFormat = settings.COORDINATES_FORMAT.getModeValue(getSelectedAppMode()); @@ -69,6 +73,12 @@ public class CoordinatesFormatFragment extends BaseSettingsFragment { summaryView.setOnTouchListener(new ClickableSpanTouchListener()); } } + if (MGRS_FORMAT.equals(preference.getKey())) { + TextView summaryView = (TextView) holder.findViewById(android.R.id.summary); + if (summaryView != null) { + summaryView.setOnTouchListener(new ClickableSpanTouchListener()); + } + } } private CharSequence getCoordinatesFormatSummary(Location loc, int format) { @@ -106,6 +116,36 @@ public class CoordinatesFormatFragment extends BaseSettingsFragment { return spannableBuilder; } + if (format == PointDescription.MGRS_FORMAT) { + SpannableStringBuilder spannableBuilder = new SpannableStringBuilder(); + String combined = getString(R.string.ltr_or_rtl_combine_via_colon, getString(R.string.shared_string_example), formattedCoordinates); + spannableBuilder.append(combined); + spannableBuilder.append("\n"); + spannableBuilder.append(getString(R.string.mgrs_format_descr)); + + int start = spannableBuilder.length(); + spannableBuilder.append(" "); + spannableBuilder.append(getString(R.string.shared_string_read_more)); + + ClickableSpan clickableSpan = new ClickableSpan() { + @Override + public void onClick(@NonNull View widget) { + Context ctx = getContext(); + if (ctx != null) { + WikipediaDialogFragment.showFullArticle(ctx, Uri.parse(MGRS_FORMAT_WIKI_LINK), isNightMode()); + } + } + + @Override + public void updateDrawState(@NonNull TextPaint ds) { + super.updateDrawState(ds); + ds.setUnderlineText(false); + } + }; + spannableBuilder.setSpan(clickableSpan, start, spannableBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + + return spannableBuilder; + } return getString(R.string.ltr_or_rtl_combine_via_colon, getString(R.string.shared_string_example), formattedCoordinates); } @@ -159,6 +199,8 @@ public class CoordinatesFormatFragment extends BaseSettingsFragment { return PointDescription.FORMAT_SECONDS; case UTM_FORMAT: return PointDescription.UTM_FORMAT; + case MGRS_FORMAT: + return PointDescription.MGRS_FORMAT; case OLC_FORMAT: return PointDescription.OLC_FORMAT; default: @@ -176,6 +218,8 @@ public class CoordinatesFormatFragment extends BaseSettingsFragment { return FORMAT_SECONDS; case PointDescription.UTM_FORMAT: return UTM_FORMAT; + case PointDescription.MGRS_FORMAT: + return MGRS_FORMAT; case PointDescription.OLC_FORMAT: return OLC_FORMAT; default: diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java index 8160e81e6e..d90f4b7429 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java @@ -13,6 +13,7 @@ import net.osmand.AndroidUtils; import net.osmand.IndexConstants; import net.osmand.PlatformUtil; import net.osmand.map.ITileSource; +import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; import net.osmand.plus.audionotes.AudioVideoNotesPlugin; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.settings.backend.ApplicationMode; @@ -148,6 +149,10 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter multimediaFilesList = new ArrayList<>(); List trackFilesList = new ArrayList<>(); List avoidRoads = new ArrayList<>(); + List favoriteGroups = new ArrayList<>(); for (Object object : duplicatesList) { if (object instanceof ApplicationMode.ApplicationModeBean) { @@ -201,6 +203,8 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment implements View } } else if (object instanceof AvoidRoadInfo) { avoidRoads.add((AvoidRoadInfo) object); + } else if (object instanceof FavoriteGroup) { + favoriteGroups.add((FavoriteGroup) object); } } if (!profiles.isEmpty()) { @@ -239,6 +243,10 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment implements View duplicates.add(getString(R.string.avoid_road)); duplicates.addAll(avoidRoads); } + if (!favoriteGroups.isEmpty()) { + duplicates.add(getString(R.string.shared_string_favorites)); + duplicates.addAll(favoriteGroups); + } return duplicates; } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java index 8250477d20..5cffbf5898 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportSettingsFragment.java @@ -33,6 +33,7 @@ import net.osmand.PlatformUtil; import net.osmand.map.ITileSource; import net.osmand.map.TileSourceManager.TileSourceTemplate; import net.osmand.plus.AppInitializer; +import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.SQLiteTileSource; @@ -46,6 +47,8 @@ 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.FavoritesSettingsItem; +import net.osmand.plus.settings.backend.backup.GlobalSettingsItem; import net.osmand.plus.settings.backend.backup.OsmEditsSettingsItem; import net.osmand.plus.settings.backend.backup.OsmNotesSettingsItem; import net.osmand.plus.settings.backend.backup.SettingsHelper; @@ -437,6 +440,7 @@ public class ImportSettingsFragment extends BaseOsmAndFragment List avoidRoads = new ArrayList<>(); List osmNotesPointList = new ArrayList<>(); List osmEditsPointList = new ArrayList<>(); + List favoriteGroups = new ArrayList<>(); for (Object object : data) { if (object instanceof ApplicationModeBean) { appModeBeans.add((ApplicationModeBean) object); @@ -456,6 +460,10 @@ public class ImportSettingsFragment extends BaseOsmAndFragment osmNotesPointList.add((OsmNotesPoint) object); } else if (object instanceof OpenstreetmapPoint) { osmEditsPointList.add((OpenstreetmapPoint) object); + } else if (object instanceof FavoriteGroup) { + favoriteGroups.add((FavoriteGroup) object); + } else if (object instanceof GlobalSettingsItem) { + settingsItems.add((GlobalSettingsItem) object); } } if (!appModeBeans.isEmpty()) { @@ -483,6 +491,10 @@ public class ImportSettingsFragment extends BaseOsmAndFragment OsmEditsSettingsItem baseItem = getBaseItem(SettingsItemType.OSM_EDITS, OsmEditsSettingsItem.class); settingsItems.add(new OsmEditsSettingsItem(app, baseItem, osmEditsPointList)); } + if (!favoriteGroups.isEmpty()) { + FavoritesSettingsItem baseItem = getBaseItem(SettingsItemType.FAVOURITES, FavoritesSettingsItem.class); + settingsItems.add(new FavoritesSettingsItem(app, baseItem, favoriteGroups)); + } 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 7acd88ee4b..d50b00ae6f 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ImportedSettingsItemsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ImportedSettingsItemsAdapter.java @@ -122,6 +122,18 @@ public class ImportedSettingsItemsAdapter extends holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_info_dark, activeColorRes)); holder.title.setText(R.string.osm_edit_modified_poi); break; + case FAVORITES: + holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_favorite, activeColorRes)); + holder.title.setText(R.string.shared_string_favorites); + break; + case OFFLINE_MAPS: + holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_map, activeColorRes)); + holder.title.setText(R.string.shared_string_local_maps); + break; + case GLOBAL: + holder.icon.setImageDrawable(uiUtils.getIcon(R.drawable.ic_action_settings, activeColorRes)); + holder.title.setText(R.string.general_settings_2); + break; } } diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index 565fb872c0..d8101b487d 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -33,6 +33,7 @@ import androidx.core.graphics.drawable.DrawableCompat; import com.google.android.material.snackbar.Snackbar; import com.jwetherell.openmap.common.LatLonPoint; +import com.jwetherell.openmap.common.MGRSPoint; import com.jwetherell.openmap.common.UTMPoint; import net.osmand.AndroidUtils; @@ -1251,6 +1252,13 @@ public class MapInfoWidgetsFactory { UTMPoint pnt = new UTMPoint(new LatLonPoint(lat, lon)); String utmLocation = pnt.zone_number + "" + pnt.zone_letter + " " + ((long) pnt.easting) + " " + ((long) pnt.northing); latitudeText.setText(utmLocation); + } else if (f == PointDescription.MGRS_FORMAT) { + AndroidUiHelper.updateVisibility(lonCoordinatesContainer, false); + AndroidUiHelper.updateVisibility(coordinatesDivider, false); + AndroidUiHelper.updateVisibility(latitudeIcon, true); + latitudeIcon.setImageDrawable(iconsCache.getIcon(nightMode ? R.drawable.widget_coordinates_utm_night : R.drawable.widget_coordinates_utm_day)); + MGRSPoint pnt = new MGRSPoint(new LatLonPoint(lat, lon)); + latitudeText.setText(pnt.toFlavoredString(5)); } else if (f == PointDescription.OLC_FORMAT) { AndroidUiHelper.updateVisibility(lonCoordinatesContainer, false); AndroidUiHelper.updateVisibility(coordinatesDivider, false);