diff --git a/OsmAnd-java/src/main/java/net/osmand/osm/MapRenderingTypes.java b/OsmAnd-java/src/main/java/net/osmand/osm/MapRenderingTypes.java
index 34e5048930..d996678e44 100644
--- a/OsmAnd-java/src/main/java/net/osmand/osm/MapRenderingTypes.java
+++ b/OsmAnd-java/src/main/java/net/osmand/osm/MapRenderingTypes.java
@@ -27,7 +27,7 @@ public abstract class MapRenderingTypes {
private static final Log log = PlatformUtil.getLog(MapRenderingTypes.class);
public static final String[] langs = new String[] { "af", "als", "ar", "az", "be", "bg", "bn", "bpy", "br", "bs", "ca", "ceb", "cs", "cy", "da", "de", "el", "eo", "es", "et", "eu", "fa", "fi", "fr", "fy", "ga", "gl", "he", "hi", "hsb",
- "hr", "ht", "hu", "hy", "id", "is", "it", "ja", "ka", "ko", "ku", "la", "lb", "lo", "lt", "lv", "mk", "ml", "mr", "ms", "nds", "new", "nl", "nn", "no", "nv", "os", "pl", "pms", "pt", "ro", "ru", "sc", "sh", "sk", "sl", "sq", "sr", "sv", "sw", "ta", "te", "th", "tl", "tr", "uk", "vi", "vo", "zh", "zh-hans", "zh-hant", };
+ "hr", "ht", "hu", "hy", "id", "is", "it", "ja", "ka", "kn", "ko", "ku", "la", "lb", "lo", "lt", "lv", "mk", "ml", "mr", "ms", "nds", "new", "nl", "nn", "no", "nv", "os", "pl", "pms", "pt", "ro", "ru", "sc", "sh", "sk", "sl", "sq", "sr", "sv", "sw", "ta", "te", "th", "tl", "tr", "uk", "vi", "vo", "zh", "zh-hans", "zh-hant", };
public final static byte RESTRICTION_NO_RIGHT_TURN = 1;
diff --git a/OsmAnd-telegram/res/values-ar/strings.xml b/OsmAnd-telegram/res/values-ar/strings.xml
index 1fb4149e0b..45b5d99ce7 100644
--- a/OsmAnd-telegram/res/values-ar/strings.xml
+++ b/OsmAnd-telegram/res/values-ar/strings.xml
@@ -267,4 +267,8 @@
تتبع حالة أوسماند
العودة إلى OsmAnd
%1$s منذ
+ إرسال التقرير
+ تصدير
+ سجل الاستخدام
+ التحقق من السجلات التفصيلية للتطبيق ومشاركتها
\ No newline at end of file
diff --git a/OsmAnd-telegram/res/values-es-rUS/strings.xml b/OsmAnd-telegram/res/values-es-rUS/strings.xml
index 86bfb79310..259192e6a8 100644
--- a/OsmAnd-telegram/res/values-es-rUS/strings.xml
+++ b/OsmAnd-telegram/res/values-es-rUS/strings.xml
@@ -268,4 +268,8 @@
Última respuesta: Hace %1$s
Hace %1$s
ERR
+ Exportar
+ Búfer de Logcat
+ Comprueba y comparte los registros detallados de la aplicación
+ Enviar informe
\ No newline at end of file
diff --git a/OsmAnd-telegram/res/values-pt/strings.xml b/OsmAnd-telegram/res/values-pt/strings.xml
index 21dfc6b4e9..9a516699e2 100644
--- a/OsmAnd-telegram/res/values-pt/strings.xml
+++ b/OsmAnd-telegram/res/values-pt/strings.xml
@@ -267,4 +267,8 @@
Última resposta: %1$s
Última atualização do Telegram: %1$s
ERR
+ Enviar o relatório
+ Exportar
+ Buffer de logcat
+ Verifique e compartilhe registos detalhados da app
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/ic_action_route_part.xml b/OsmAnd/res/drawable/ic_action_route_part.xml
new file mode 100644
index 0000000000..e06263ef8e
--- /dev/null
+++ b/OsmAnd/res/drawable/ic_action_route_part.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
diff --git a/OsmAnd/res/drawable/ic_logo_openplacereview.xml b/OsmAnd/res/drawable/ic_logo_openplacereview.xml
new file mode 100644
index 0000000000..fc5b26cbf3
--- /dev/null
+++ b/OsmAnd/res/drawable/ic_logo_openplacereview.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/OsmAnd/res/layout/bottom_sheet_item_slider_with_two_text.xml b/OsmAnd/res/layout/bottom_sheet_item_slider_with_two_text.xml
index b5cb11cf49..f386e8c59f 100644
--- a/OsmAnd/res/layout/bottom_sheet_item_slider_with_two_text.xml
+++ b/OsmAnd/res/layout/bottom_sheet_item_slider_with_two_text.xml
@@ -6,33 +6,37 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
-
+ osmand:typeface="@string/font_roboto_regular"
+ tools:text="Some very long title to check overlapped texts" />
+
+
+ osmand:typeface="@string/font_roboto_medium"
+ tools:text="summary" />
-
+
المسارات الرياضية
وسائل المواصلات
سمات أخرى للخريطة
- العناصر الاخرى
+ العناصر الأخرى
شريط المعلومات
العدادات على اليمين
العدادات على اليسار
@@ -3413,7 +3413,7 @@
سترى الأيقونة فقط أثناء الملاحة أو أثناء التحرك.
قيم
تظهر أيقونة الخريطة فقط على الخريطة ، وتتغير أثناء التنقل إلى أيقونة التنقل.
- تحقق وتبادل سجلات مفصلة من التطبيق
+ التحقق من السجلات التفصيلية للتطبيق ومشاركتها
تعذر تحليل الهدف الجغرافي \'%s\'.
الإذن مطلوب لاستخدام هذا الخيار.
اعراض جانبية: سيفقد المسار الخاص بك جميع الأقسام التي لم يتحقق فيها معيار الحد الأدنى للسرعة (على سبيل المثال ، حيث تدفع دراجتك أعلى تل شديد الانحدار). أيضا ، لن تكون هناك معلومات حول فترات الراحة ، مثل الاستراحات. هذا له تأثيرات على أي تحليل أو مرحلة ما بعد المعالجة ، مثل عند محاولة تحديد المدة الإجمالية لرحلتك ، أو وقت الحركة ، أو متوسط سرعتك.
@@ -3893,4 +3893,12 @@
الاسم: أ – ي
رموز البدء/الانتهاء
شكرا لشرائك \"خطوط الكنتور\"
+ رسوم الاشتراك ستفرض كل شهر. يمكنك إلغاء اشتراكك متى أردت عبر Google play.
+ سيتم تحصيل المبلغ على حساب AppGallery الخاص بك عند تأكيد الشراء.
+\n
+\nيتم تجديد الاشتراك تلقائيًا ما لم يتم إلغاؤه قبل تاريخ التجديد. سيتم خصم حسابك على فترة التجديد (شهر/ثلاثة أشهر/سنة) فقط في تاريخ التجديد.
+\n
+\nيمكنك إدارة وإلغاء الاشتراكات الخاصة بك عن طريق الانتقال إلى إعدادات AppGallery.
+ تجنب الممرات
+ تجنب الممرات
\ No newline at end of file
diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml
index 1fcf32f445..fcfcca7c77 100644
--- a/OsmAnd/res/values-de/strings.xml
+++ b/OsmAnd/res/values-de/strings.xml
@@ -3826,7 +3826,7 @@
Wählen Sie eine Trackdatei zum Öffnen aus.
Fertig
Track überschreiben
- Schwellenwert-Distanz
+ Maximaler Abstand
Als neuen Track speichern
Route umkehren
Der gesamte Track wird mit dem ausgewählten Profil neu berechnet.
@@ -3910,4 +3910,12 @@
Name: A – Z
Start-/Ziel-Symbole
Vielen Dank für den Kauf von \'Höhenlinien\'
+ Das Abonnement wird pro ausgewähltem Zeitraum berechnet. Sie können das Abonnement jederzeit über die AppGallery kündigen.
+ Die Bezahlung wird Ihrem AppGallery-Konto bei der Bestätigung des Kaufs belastet.
+\n
+\n Das Abonnement verlängert sich automatisch, sofern es nicht vor dem Verlängerungsdatum gekündigt wird. Ihr Konto wird für den Verlängerungszeitraum (Monat / drei Monate / Jahr) nur am Verlängerungsdatum belastet.
+\n
+\n Sie können Ihre Abonnements verwalten und kündigen, indem Sie zu Ihren AppGallery-Einstellungen gehen.
+ Vermeidet Fußwege
+ Keine Fußwege
\ 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 fcdccf360a..c6f59f41ea 100644
--- a/OsmAnd/res/values-es-rAR/strings.xml
+++ b/OsmAnd/res/values-es-rAR/strings.xml
@@ -3909,4 +3909,12 @@
Nombre: A – Z
Iconos de inicio/fin
Gracias por comprar las «Curvas de nivel»
+ La suscripción se cobra por el período elegido. Puedes cancelarlo en cualquier momento en AppGallery.
+ El pago será cargado a la cuenta de AppGallery al confirmar la compra.
+\n
+\nLa suscripción se renueva automáticamente a menos que se cancele antes de la fecha de renovación. La cuenta será cargada por el período de renovación (mes/trimestre/año) sólo en la fecha de renovación.
+\n
+\nPuedes administrar y cancelar las suscripciones accediendo a los ajustes de AppGallery.
+ Evita pasar por las veredas o aceras
+ Evitar veredas/aceras
\ No newline at end of file
diff --git a/OsmAnd/res/values-es-rUS/strings.xml b/OsmAnd/res/values-es-rUS/strings.xml
index 6ba4dcc29e..c42f0e0c5b 100644
--- a/OsmAnd/res/values-es-rUS/strings.xml
+++ b/OsmAnd/res/values-es-rUS/strings.xml
@@ -3905,4 +3905,13 @@
Nombre: A – Z
Último modificado
Iconos de inicio/fin
+ Gracias por comprar las «Curvas de nivel»
+ La suscripción se cobra por el período elegido. Puedes cancelarlo en cualquier momento en AppGallery.
+ El pago será cargado a la cuenta de AppGallery al confirmar la compra.
+\n
+\nLa suscripción se renueva automáticamente a menos que se cancele antes de la fecha de renovación. La cuenta será cargada por el período de renovación (mes/trimestre/año) sólo en la fecha de renovación.
+\n
+\nPuedes administrar y cancelar las suscripciones accediendo a los ajustes de AppGallery.
+ Evita pasar por aceras o veredas
+ Evitar aceras
\ No newline at end of file
diff --git a/OsmAnd/res/values-et/strings.xml b/OsmAnd/res/values-et/strings.xml
index 8e58fdad52..fe5cbbfa20 100644
--- a/OsmAnd/res/values-et/strings.xml
+++ b/OsmAnd/res/values-et/strings.xml
@@ -3764,4 +3764,13 @@
Nimi: A – Z
Ekraani väljalülitamine
Ratastool edasi
+ Väldi jalgteid
+ Väldi jalgteid
+ Täname „Kõrgusjoonte“ ostu eest
+ Ostukinnituse saabumisel arveldame tellimuse eest sinu AppGallery konto alusel.
+\n
+\nKui sa ei tühista tellimust enne uue perioodi algust, siis tellimus pikeneb automaatselt ning arveldame järgmise ajavahemiku eest (kuu/kvartal/aasta) selle alguses.
+\n
+\nTellimust saad hallata ja tühistada AppGallery seadistustest.
+ Arveldame tellimuse eest valitud ajavahemiku alusel. Seda saad sa vabalt valitud ajal tühistada AppGallery\'s.
\ No newline at end of file
diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml
index 41007cc7eb..401664b66e 100644
--- a/OsmAnd/res/values-fr/strings.xml
+++ b/OsmAnd/res/values-fr/strings.xml
@@ -3885,4 +3885,7 @@
Nom : A – Z
Icônes de départ / arrivée
Merci pour votre achat de \'Courbes de niveaux\'
+ Abonnement facturé pour chaque période sélectionnée. Annulation possible à tout moment sur AppGallery.
+ Éviter les trottoirs
+ Éviter les trottoirs
\ No newline at end of file
diff --git a/OsmAnd/res/values-iw/strings.xml b/OsmAnd/res/values-iw/strings.xml
index 42a840fa87..6b405f881a 100644
--- a/OsmAnd/res/values-iw/strings.xml
+++ b/OsmAnd/res/values-iw/strings.xml
@@ -3911,4 +3911,12 @@
שם: א – ת
סמלי התחלה/סיום
תודה לך על רכישת ‚קווי מתאר’
+ הימנעות משבילי הולכי רגל
+ הימנעות משבילי הולכי רגל
+ המינוי חויב לתקופה הנבחרת. ניתן לבטל דרך ה־AppGallery בכל עת.
+ התשלום יחויב דרך חשבון ה־AppGallery שלך עם אישור הרכישה.
+\n
+\nהמינוי מתחדש אוטומטי אלא אם כן בוטל בטרם תאריך החידוש. החשבון שלך יחויב על תקופת החידוש (חודש/שלושה חודשים/שנה) רק בתאריך החידוש.
+\n
+\nניתן לנהל ולבטל את המינויים שלך דרך ההגדרות ב־AppGallery שלך.
\ 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 1358007216..457106d81c 100644
--- a/OsmAnd/res/values-pt-rBR/strings.xml
+++ b/OsmAnd/res/values-pt-rBR/strings.xml
@@ -3901,4 +3901,12 @@
Nome: A – Z
Ícones de início/término
Obrigado por adquirir \'curvas de nível\'
+ Assinatura cobrada por período selecionado. Cancele no AppGallery a qualquer momento.
+ O pagamento será cobrado em sua conta AppGallery na confirmação da compra.
+\n
+\nA assinatura é renovada automaticamente, a menos que seja cancelada antes da data de renovação. Sua conta será cobrada pelo período de renovação (mês/três meses/ano) apenas na data de renovação.
+\n
+\nVocê pode gerenciar e cancelar suas assinaturas acessando as configurações do AppGallery.
+ Evite passarelas
+ Evite passarelas
\ No newline at end of file
diff --git a/OsmAnd/res/values-pt/strings.xml b/OsmAnd/res/values-pt/strings.xml
index 08c39f206e..cae1cc8c1e 100644
--- a/OsmAnd/res/values-pt/strings.xml
+++ b/OsmAnd/res/values-pt/strings.xml
@@ -3908,4 +3908,12 @@
Nome: A – Z
Ícones de início/fim
Obrigado por comprar \'Curvas de nível\'
+ Assinatura cobrada por período selecionado. Cancele-a na AppGallery a qualquer momento.
+ O pagamento será debitado na sua conta AppGallery no momento da confirmação da compra.
+\n
+\nA assinatura é renovada automaticamente, a menos que seja cancelada antes da data de renovação. A sua conta será cobrada pelo período de renovação (mês/três meses/ano) apenas na data de renovação.
+\n
+\nPode gerir e cancelar as suas subscrições a ir às definições da sua AppGallery.
+ Evitar passeios
+ Evitar passeios
\ No newline at end of file
diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml
index b6dd46c4e9..968f4e898e 100644
--- a/OsmAnd/res/values-ru/strings.xml
+++ b/OsmAnd/res/values-ru/strings.xml
@@ -73,7 +73,7 @@
Поиск почтового индекса
Запись аудио
Записать видео
- Фотозаметка
+ Сделать фото
OSM-заметка
Функции парковки
Благодарим вас за покупку платной версии OsmAnd.
@@ -531,10 +531,10 @@
Прозрачность наложения
Отрегулируйте прозрачность основной карты.
Прозрачность основной карты
- Карта подложки
+ Карта подложки…
Карта подложки
Выберите карту подложки
- Карта наложения
+ Карта наложения…
Карта наложения
Выберите слой наложения поверх основной карты
Карта уже установлена, настройки будут обновлены.
@@ -689,7 +689,7 @@
Маршрут
OSM-заметки (онлайн)
POI…
- Источник карты
+ Источник карты…
Слои
Поиск POI
Использовать трекбол для перемещения по карте.
@@ -1179,7 +1179,7 @@
Последний промежуточный пункт
Сделать начальной остановкой
Сделать последней остановкой
- Сделать начальной остановкой
+ Первый промежуточный пункт
Заменить пункт назначения
Пункт назначения уже задан
Пункт %1$s
@@ -3580,8 +3580,7 @@
Примечание: проверка скорости > 0: большинство модулей GPS сообщают значение скорости только в том случае, если алгоритм определяет, что вы движетесь, и ничего, если вы не перемещаетесь. Следовательно, использование параметра > 0 в этом фильтре в некотором смысле приводит к обнаружению факта перемещения модуля GPS. Но даже если мы не производим данную фильтрацию во время записи, то всё равно эта функция используется при анализе GPX для определения скорректированного расстояния, то есть значение, отображаемое в этом поле, является расстоянием, записанным во время движения.
Разделение записи
Укажите веб-адрес со следующими параметрами: lat={0}, lon={1}, timestamp={2}, hdop={3}, altitude={4}, speed={5}, bearing={6}.
- "Будут записываться только точки, отвечающие
-\n в минимальной точностью (в метрах/футах —зависит от настроек системы). Точность — это близость измерений к истинному положению, и она не связана напрямую с точностью, которая представляет собой разброс повторных измерений."
+ "Будут записываться только точки, отвечающие по показателю минимальной точности (в метрах или футах — зависит от настроек системы). Точность — это близость измерений к истинному положению, и она не связана напрямую с точностью, которая представляет собой разброс повторных измерений."
Рекомендация: попробуйте сначала воспользоваться детектором движения через фильтр минимального смещения (B), что может дать лучшие результаты и вы потеряете меньше данных. Если треки остаются шумными на низких скоростях, попробуйте использовать ненулевые значения. Обратите внимание, что некоторые измерения могут вообще не указывать значения скорости (некоторые сетевые методы), и в этом случае ничего не будет записываться.
Для визуализации крутизны рельефа используются цвета.
Подробнее об уклонах можно прочитать в %1$s.
@@ -3904,4 +3903,12 @@
Имя: А - Я
Значки старта и финиша
Спасибо за покупку \'Контурных линий\'
+ Избегать пешеходных дорожек
+ Избегать пешеходных дорожек
+ Подписка взимается за выбранный период. Отмените её в AppGallery в любое время.
+ Оплата будет снята с вашей учетной записи AppGallery при подтверждении покупки.
+\n
+\nПодписка продлевается автоматически, если она не будет отменена до даты продления. С вашего счета будет взиматься плата за период продления (месяц/три месяца/год) только в дату продления.
+\n
+\nВы можете управлять своими подписками и отменять их, перейдя в настройки AppGallery.
\ No newline at end of file
diff --git a/OsmAnd/res/values-sc/strings.xml b/OsmAnd/res/values-sc/strings.xml
index 57221ff561..ac6f4f667a 100644
--- a/OsmAnd/res/values-sc/strings.xml
+++ b/OsmAnd/res/values-sc/strings.xml
@@ -3887,7 +3887,7 @@
Torra a fàghere
• Funtzionalidade de pranificatione de un\'àndala agiornada: permitit de impreare castas diferentes de navigatzione pro segmentu e s\'inclusione de rastas
\n
-\n • New Appearance menu for tracks: select color, thickness, display direction arrows, start/finish icons
+\n • Menù de Aparèntzia nou pro sas rastas: ischerta su colore, grussària, visulaizatzione de sas fritzas de diretzione, iconas de incumintzu/fine
\n
\n • Visibilidade megiorada de sos nodos pro sas bitzicletas.
\n
@@ -3905,4 +3905,12 @@
Nùmene: A – Z
Iconas de incumintzu/fine
Gràtzias pro àere comporadu \'Curvas de livellu\'
+ Costu periòdicu de s\'abbonamentu. Lu podes anullare in AppGallery cando boles.
+ Su pagamentu at a èssere addebitadu a su contu tuo de AppGallery cando sa còmpora at a èssere cunfirmada.
+\n
+\nS\'abbonamentu si rinnovat a sa sola automaticamente, francu chi siat istadu annulladu in antis de sa die de su rinnovu. Su contu tuo at a bènnere addebitadu pro su perìodu de rinnovu (mese/tres meses/annu) in sa die de rinnovu ebbia.
+\n
+\nPodes amministrare e annullare sos abbonamentos tuos intrende in sas impostatziones de AppGallery tuas.
+ Èvita sos martzapiedis
+ Èvita sos martzapiedis
\ No newline at end of file
diff --git a/OsmAnd/res/values-sk/phrases.xml b/OsmAnd/res/values-sk/phrases.xml
index 28ac2c4297..db5f8d31a6 100644
--- a/OsmAnd/res/values-sk/phrases.xml
+++ b/OsmAnd/res/values-sk/phrases.xml
@@ -509,7 +509,7 @@
Matričný úrad
Dôchodkový fond
Imigračný úrad
- Daňová kontrola
+ Daňový úrad
Štvrť
Suchá bobová dráha
Kolotoč s hojdačkami
@@ -3652,4 +3652,5 @@
Búdka
Nie
Áno
+ Kancelária taxislužby
\ No newline at end of file
diff --git a/OsmAnd/res/values-sk/strings.xml b/OsmAnd/res/values-sk/strings.xml
index 6ce4134d80..f9b8f23366 100644
--- a/OsmAnd/res/values-sk/strings.xml
+++ b/OsmAnd/res/values-sk/strings.xml
@@ -3654,8 +3654,8 @@
Lombardsky
%1$s / %2$s
Platba bude stiahnutá z vášho účtu Google Play po potvrdení nákupu.
-\n
-\n Predplatné sa automaticky obnovuje ak nie je zrušené pred dátumom jeho obnovenia. Ďalšia platba za obdobie predplatného (mesiac/štvrťrok/rok) bude stiahnutá v deň obnovenia.
+\n
+\n Predplatné sa automaticky obnovuje, ak nie je zrušené pred dátumom jeho obnovenia. Ďalšia platba za obdobie predplatného (mesiac/štvrťrok/rok) bude stiahnutá v deň obnovenia.
\n
\n Vaše predplatné môžete spravovať a zrušiť v nastaveniach Google Play.
Hľadať typy bodov záujmu
@@ -3906,4 +3906,12 @@
Názov: A – Z
Ikony štartu/cieľa
Ďakujeme za zakúpenie modulu \'Vrstevnice\'
+ Predplatné bude spoplatnené v zvolenom intervale. Predplatné zrušte kedykoľvek na AppGallery.
+ Platba bude stiahnutá z vášho účtu AppGallery po potvrdení nákupu.
+\n
+\nPredplatné sa automaticky obnovuje, ak nie je zrušené pred dátumom jeho obnovenia. Ďalšia platba za obdobie predplatného (mesiac/štvrťrok/rok) bude stiahnutá v deň obnovenia.
+\n
+\n Vaše predplatné môžete spravovať a zrušiť v nastaveniach AppGallery.
+ Vyhnúť sa chodníkom pre chodcov
+ Vyhnúť sa chodníkom
\ No newline at end of file
diff --git a/OsmAnd/res/values-tr/strings.xml b/OsmAnd/res/values-tr/strings.xml
index 50a41c8562..071ecab230 100644
--- a/OsmAnd/res/values-tr/strings.xml
+++ b/OsmAnd/res/values-tr/strings.xml
@@ -3861,4 +3861,12 @@
İsim: A – Z
Başlangıç/bitiş simgeleri
\'Eş yükselti eğrileri\'ni satın aldığınız için teşekkürler
+ Abonelik seçilen dönem başına ücretlendirilir. İstediğiniz zaman AppGallery\'den iptal edin.
+ Ödeme, satın alma onaylandığında AppGallery hesabınızdan alınacaktır.
+\n
+\nYenileme tarihinden önce iptal edilmedikçe abonelik otomatik olarak yenilenir. Hesabınızdan yenileme süresi (ay/üç ay/yıl) için yalnızca yenileme tarihinde ücret alınacaktır.
+\n
+\n AppGallery ayarlarınıza giderek aboneliklerinizi yönetebilir ve iptal edebilirsiniz.
+ Yaya yollarından kaçın
+ Yaya yollarından kaçın
\ 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 cf0cc3fd99..1d6615754e 100644
--- a/OsmAnd/res/values-zh-rTW/strings.xml
+++ b/OsmAnd/res/values-zh-rTW/strings.xml
@@ -3901,4 +3901,12 @@
名稱:A – Z
開始/結束圖示
感謝您購買 \'Contour lines\'
+ 按選定週期收取訂閱費用。隨時在 AppGallery 上取消。
+ 確認購買後將會從您的 AppGallery 帳號中付款。
+\n
+\n除非在續訂日期前取消,否則就會自動續訂。您的帳號將只會在續訂日期收取訂閱週期(一個月/三個月/一年)的費用。
+\n
+\n您可以在您的 AppGallery 設定中管理與取消您的訂閱。
+ 避免人行道
+ 避免人行道
\ No newline at end of file
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 6093d106d4..95d20ec85b 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -15,6 +15,14 @@
Clear OpenStreetMap OAuth token
Log in via OAuth
Perform an OAuth Login to use osmedit features
+ Switch to Java (safe) Public Transport routing calculation
+ Native Public Transport development
+ Recalculates only the initial part of the route. Can be used for long trips.
+ Two-phase routing for car navigation.
+ Complex routing
+ OsmAnd Live data
+ OsmAnd Live data
+ Development
Avoid footways
Avoid footways
Payment will be charged to your AppGallery account at the confirmation of purchase.\n\nSubscription automatically renews unless it is canceled before the renewal date. Your account will be charged for renewal period(month/three month/year) only on the renewal date.\n\nYou can manage and cancel your subscriptions by going to your AppGallery settings.
@@ -3666,7 +3674,6 @@
You need to be online to install this plugin.
Get
Smart route recalculation
- For long trips, only recalculate the initial part of the route.
Do you like OsmAnd?
Your opinion and feedback is valued.
Rate this app
diff --git a/OsmAnd/res/xml/development_settings.xml b/OsmAnd/res/xml/development_settings.xml
index d01a1f169d..231bd469bc 100644
--- a/OsmAnd/res/xml/development_settings.xml
+++ b/OsmAnd/res/xml/development_settings.xml
@@ -25,46 +25,11 @@
android:summaryOn="@string/shared_string_enabled"
android:title="@string/safe_mode" />
-
-
-
-
-
-
-
-
-
-
subscriptionCancelledTime = ctx.getSettings().LIVE_UPDATES_PURCHASE_CANCELLED_TIME;
+ OsmandPreference subscriptionCancelledTime = ctx.getSettings().LIVE_UPDATES_PURCHASE_CANCELLED_TIME;
if (!subscribedToLiveUpdates && ctx.getSettings().LIVE_UPDATES_PURCHASED.get()) {
if (subscriptionCancelledTime.get() == 0) {
subscriptionCancelledTime.set(System.currentTimeMillis());
diff --git a/OsmAnd/src-huawei/net/osmand/plus/inapp/InAppPurchaseHelperImpl.java b/OsmAnd/src-huawei/net/osmand/plus/inapp/InAppPurchaseHelperImpl.java
index c3d6fc193c..0f3536e5d0 100644
--- a/OsmAnd/src-huawei/net/osmand/plus/inapp/InAppPurchaseHelperImpl.java
+++ b/OsmAnd/src-huawei/net/osmand/plus/inapp/InAppPurchaseHelperImpl.java
@@ -31,7 +31,7 @@ import net.osmand.plus.inapp.InAppPurchases.InAppSubscription;
import net.osmand.plus.inapp.InAppPurchases.InAppSubscriptionIntroductoryInfo;
import net.osmand.plus.inapp.InAppPurchasesImpl.InAppPurchaseLiveUpdatesOldSubscription;
import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference;
+import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.util.Algorithms;
import java.lang.ref.WeakReference;
diff --git a/OsmAnd/src/net/osmand/FileUtils.java b/OsmAnd/src/net/osmand/FileUtils.java
index 65ea676356..1f9a755be5 100644
--- a/OsmAnd/src/net/osmand/FileUtils.java
+++ b/OsmAnd/src/net/osmand/FileUtils.java
@@ -223,6 +223,19 @@ public class FileUtils {
return tempDir;
}
+ public static boolean isWritable(File dirToTest) {
+ boolean isWriteable;
+ try {
+ dirToTest.mkdirs();
+ File writeTestFile = File.createTempFile("osmand_", ".tmp", dirToTest);
+ isWriteable = writeTestFile.exists();
+ writeTestFile.delete();
+ } catch (IOException e) {
+ isWriteable = false;
+ }
+ return isWriteable;
+ }
+
public interface RenameCallback {
void renamedTo(File file);
}
diff --git a/OsmAnd/src/net/osmand/aidl/ConnectedApp.java b/OsmAnd/src/net/osmand/aidl/ConnectedApp.java
index 02f412887e..be25ab931d 100644
--- a/OsmAnd/src/net/osmand/aidl/ConnectedApp.java
+++ b/OsmAnd/src/net/osmand/aidl/ConnectedApp.java
@@ -18,10 +18,10 @@ import net.osmand.AndroidUtils;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.settings.backend.ApplicationMode;
-import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
import net.osmand.plus.views.OsmandMapLayer;
import net.osmand.plus.views.layers.AidlMapLayer;
import net.osmand.plus.views.layers.MapInfoLayer;
diff --git a/OsmAnd/src/net/osmand/core/android/MapRendererContext.java b/OsmAnd/src/net/osmand/core/android/MapRendererContext.java
index 03d88fa11c..d65880877c 100644
--- a/OsmAnd/src/net/osmand/core/android/MapRendererContext.java
+++ b/OsmAnd/src/net/osmand/core/android/MapRendererContext.java
@@ -25,7 +25,7 @@ import net.osmand.core.jni.ResolvedMapStyle;
import net.osmand.core.jni.SwigUtilities;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
+import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.render.RendererRegistry;
import net.osmand.render.RenderingRuleProperty;
import net.osmand.render.RenderingRuleStorageProperties;
diff --git a/OsmAnd/src/net/osmand/data/FavouritePoint.java b/OsmAnd/src/net/osmand/data/FavouritePoint.java
index e5f4f6c8ea..7205b4a422 100644
--- a/OsmAnd/src/net/osmand/data/FavouritePoint.java
+++ b/OsmAnd/src/net/osmand/data/FavouritePoint.java
@@ -13,8 +13,8 @@ import androidx.annotation.StringRes;
import net.osmand.GPXUtilities.WptPt;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.OsmandApplication;
-import net.osmand.plus.settings.backend.OsmandSettings.BooleanPreference;
-import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference;
+import net.osmand.plus.settings.backend.BooleanPreference;
+import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
import net.osmand.util.Algorithms;
diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java
index 0ae24b7c5f..78364460a7 100644
--- a/OsmAnd/src/net/osmand/plus/AppInitializer.java
+++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java
@@ -28,7 +28,7 @@ import net.osmand.map.OsmandRegions.RegionTranslation;
import net.osmand.map.WorldRegion;
import net.osmand.osm.AbstractPoiType;
import net.osmand.osm.MapPoiTypes;
-import net.osmand.plus.activities.DayNightHelper;
+import net.osmand.plus.helpers.DayNightHelper;
import net.osmand.plus.activities.LocalIndexHelper;
import net.osmand.plus.activities.LocalIndexInfo;
import net.osmand.plus.activities.SavingTrackHelper;
diff --git a/OsmAnd/src/net/osmand/plus/AppVersionUpgradeOnInit.java b/OsmAnd/src/net/osmand/plus/AppVersionUpgradeOnInit.java
index c49f0a12a2..9eeec4542b 100644
--- a/OsmAnd/src/net/osmand/plus/AppVersionUpgradeOnInit.java
+++ b/OsmAnd/src/net/osmand/plus/AppVersionUpgradeOnInit.java
@@ -3,7 +3,30 @@ package net.osmand.plus;
import android.annotation.SuppressLint;
import android.content.SharedPreferences;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.reflect.TypeToken;
+
+import net.osmand.data.FavouritePoint.SpecialPointType;
+import net.osmand.data.LatLon;
+import net.osmand.plus.AppInitializer.AppInitializeListener;
+import net.osmand.plus.AppInitializer.InitEvents;
+import net.osmand.plus.api.SettingsAPI;
+import net.osmand.plus.settings.backend.ApplicationMode;
+import net.osmand.plus.settings.backend.CommonPreference;
+import net.osmand.plus.settings.backend.EnumStringPreference;
+import net.osmand.plus.settings.backend.OsmandPreference;
+import net.osmand.plus.settings.backend.OsmandSettings;
+import net.osmand.util.Algorithms;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
class AppVersionUpgradeOnInit {
+
public static final String FIRST_TIME_APP_RUN = "FIRST_TIME_APP_RUN"; //$NON-NLS-1$
public static final String VERSION_INSTALLED_NUMBER = "VERSION_INSTALLED_NUMBER"; //$NON-NLS-1$
public static final String NUMBER_OF_STARTS = "NUMBER_OF_STARTS"; //$NON-NLS-1$
@@ -43,7 +66,7 @@ class AppVersionUpgradeOnInit {
@SuppressLint("ApplySharedPref")
void upgradeVersion(SharedPreferences startPrefs, int lastVersion) {
- if(!startPrefs.contains(NUMBER_OF_STARTS)) {
+ if (!startPrefs.contains(NUMBER_OF_STARTS)) {
startPrefs.edit().putInt(NUMBER_OF_STARTS, 1).commit();
} else {
startPrefs.edit().putInt(NUMBER_OF_STARTS, startPrefs.getInt(NUMBER_OF_STARTS, 0) + 1).commit();
@@ -59,27 +82,28 @@ class AppVersionUpgradeOnInit {
} else {
prevAppVersion = startPrefs.getInt(VERSION_INSTALLED_NUMBER, 0);
if (needsUpgrade(startPrefs, lastVersion)) {
+ OsmandSettings settings = app.getSettings();
if (prevAppVersion < VERSION_2_2) {
- app.getSettings().SHOW_DASHBOARD_ON_START.set(true);
- app.getSettings().SHOW_DASHBOARD_ON_MAP_SCREEN.set(true);
- app.getSettings().SHOW_CARD_TO_CHOOSE_DRAWER.set(true);
+ settings.SHOW_DASHBOARD_ON_START.set(true);
+ settings.SHOW_DASHBOARD_ON_MAP_SCREEN.set(true);
+ settings.SHOW_CARD_TO_CHOOSE_DRAWER.set(true);
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_2_2).commit();
}
if (prevAppVersion < VERSION_2_3) {
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_2_3).commit();
}
if (prevAppVersion < VERSION_3_2) {
- app.getSettings().BILLING_PURCHASE_TOKENS_SENT.set("");
+ settings.BILLING_PURCHASE_TOKENS_SENT.set("");
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_2).commit();
}
if (prevAppVersion < VERSION_3_5 || Version.getAppVersion(app).equals("3.5.3")
|| Version.getAppVersion(app).equals("3.5.4")) {
- app.getSettings().migratePreferences();
+ migratePreferences();
app.getAppInitializer().addListener(new AppInitializer.AppInitializeListener() {
@Override
public void onProgress(AppInitializer init, AppInitializer.InitEvents event) {
if (event.equals(AppInitializer.InitEvents.FAVORITES_INITIALIZED)) {
- app.getSettings().migrateHomeWorkParkingToFavorites();
+ migrateHomeWorkParkingToFavorites();
}
}
@@ -90,21 +114,22 @@ class AppVersionUpgradeOnInit {
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_5).commit();
}
if (prevAppVersion < VERSION_3_6) {
- app.getSettings().migratePreferences();
+ migratePreferences();
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_6).commit();
}
if (prevAppVersion < VERSION_3_7) {
- app.getSettings().migrateEnumPreferences();
+ migrateEnumPreferences();
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_7).commit();
}
if (prevAppVersion < VERSION_3_7_01) {
- app.getAppInitializer().addListener(new AppInitializer.AppInitializeListener() {
+ app.getAppInitializer().addListener(new AppInitializeListener() {
@Override
public void onProgress(AppInitializer init, AppInitializer.InitEvents event) {
- if (event.equals(AppInitializer.InitEvents.FAVORITES_INITIALIZED)) {
+ if (event.equals(InitEvents.FAVORITES_INITIALIZED)) {
app.getFavorites().fixBlackBackground();
}
}
+
@Override
public void onFinish(AppInitializer init) {
}
@@ -112,7 +137,7 @@ class AppVersionUpgradeOnInit {
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_7_01).commit();
}
if (prevAppVersion < VERSION_3_8_00) {
- app.getSettings().migrateQuickActionStates();
+ migrateQuickActionStates();
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_8_00).commit();
}
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, lastVersion).commit();
@@ -135,20 +160,20 @@ class AppVersionUpgradeOnInit {
}
public void resetFirstTimeRun(SharedPreferences startPrefs) {
- if(startPrefs != null) {
+ if (startPrefs != null) {
startPrefs.edit().remove(FIRST_TIME_APP_RUN).commit();
}
}
public int getNumberOfStarts(SharedPreferences startPrefs) {
- if(startPrefs == null) {
+ if (startPrefs == null) {
return 0;
}
return startPrefs.getInt(NUMBER_OF_STARTS, 1);
}
public long getFirstInstalledDays(SharedPreferences startPrefs) {
- if(startPrefs == null) {
+ if (startPrefs == null) {
return 0;
}
long nd = startPrefs.getLong(FIRST_INSTALLED, 0);
@@ -159,4 +184,165 @@ class AppVersionUpgradeOnInit {
public boolean isFirstTime() {
return firstTime;
}
-}
+
+ public void migratePreferences() {
+ OsmandSettings settings = app.getSettings();
+ migrateEnumPreferences();
+ SharedPreferences globalSharedPreferences = (SharedPreferences) settings.getGlobalPreferences();
+ Map globalPrefsMap = globalSharedPreferences.getAll();
+ for (String key : globalPrefsMap.keySet()) {
+ OsmandPreference> pref = settings.getPreference(key);
+ if (pref instanceof CommonPreference) {
+ CommonPreference> commonPreference = (CommonPreference>) pref;
+ if (!commonPreference.isGlobal()) {
+ for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
+ if (!commonPreference.isSetForMode(mode) && !commonPreference.hasDefaultValueForMode(mode)) {
+ settings.setPreference(key, globalPrefsMap.get(key), mode);
+ }
+ }
+ }
+ }
+ }
+ SharedPreferences defaultProfilePreferences = (SharedPreferences) settings.getProfilePreferences(ApplicationMode.DEFAULT);
+ Map defaultPrefsMap = defaultProfilePreferences.getAll();
+ for (String key : defaultPrefsMap.keySet()) {
+ OsmandPreference> pref = settings.getPreference(key);
+ if (pref instanceof CommonPreference) {
+ CommonPreference> commonPreference = (CommonPreference>) pref;
+ if (commonPreference.isGlobal() && !commonPreference.isSet()) {
+ settings.setPreference(key, defaultPrefsMap.get(key));
+ }
+ }
+ }
+ for (OsmandPreference> pref : getGeneralPrefs()) {
+ if (pref instanceof CommonPreference) {
+ CommonPreference> commonPref = (CommonPreference>) pref;
+ Object defaultVal = commonPref.getModeValue(ApplicationMode.DEFAULT);
+ for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
+ if (!commonPref.isSetForMode(mode) && !commonPref.hasDefaultValueForMode(mode)) {
+ settings.setPreference(commonPref.getId(), defaultVal, mode);
+ }
+ }
+ }
+ }
+ String json = settings.getSettingsAPI().getString(settings.getGlobalPreferences(), "custom_app_profiles", "");
+ if (!Algorithms.isEmpty(json)) {
+ Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
+ Type t = new TypeToken>() {
+ }.getType();
+ List customProfiles = gson.fromJson(json, t);
+ if (!Algorithms.isEmpty(customProfiles)) {
+ for (ApplicationMode.ApplicationModeBean modeBean : customProfiles) {
+ ApplicationMode.ApplicationModeBuilder builder = ApplicationMode.fromModeBean(app, modeBean);
+ ApplicationMode.saveProfile(builder, app);
+ }
+ }
+ }
+ }
+
+ public void migrateEnumPreferences() {
+ OsmandSettings settings = app.getSettings();
+ for (OsmandPreference> pref : settings.getRegisteredPreferences().values()) {
+ if (pref instanceof EnumStringPreference) {
+ EnumStringPreference> enumPref = (EnumStringPreference>) pref;
+ if (enumPref.isGlobal()) {
+ migrateEnumPref(enumPref, (SharedPreferences) settings.getGlobalPreferences());
+ } else {
+ for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
+ migrateEnumPref(enumPref, (SharedPreferences) settings.getProfilePreferences(mode));
+ }
+ }
+ }
+ }
+ }
+
+ public void migrateQuickActionStates() {
+ OsmandSettings settings = app.getSettings();
+ String quickActionsJson = settings.getSettingsAPI().getString(settings.getGlobalPreferences(), "quick_action_new", "");
+ if (!Algorithms.isEmpty(quickActionsJson)) {
+ Gson gson = new GsonBuilder().create();
+ Type type = new TypeToken>() {
+ }.getType();
+ HashMap quickActions = gson.fromJson(quickActionsJson, type);
+ if (!Algorithms.isEmpty(quickActions)) {
+ for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
+ settings.setQuickActions(quickActions, mode);
+ }
+ }
+ }
+ }
+
+ private void migrateEnumPref(EnumStringPreference enumPref, SharedPreferences sharedPreferences) {
+ Object value = sharedPreferences.getAll().get(enumPref.getId());
+ if (value instanceof Integer) {
+ int enumIndex = (int) value;
+ if (enumIndex >= 0 && enumIndex < enumPref.getValues().length) {
+ Enum savedValue = enumPref.getValues()[enumIndex];
+ enumPref.setValue(sharedPreferences, savedValue);
+ }
+ }
+ }
+
+ public void migrateHomeWorkParkingToFavorites() {
+ OsmandSettings settings = app.getSettings();
+ FavouritesDbHelper favorites = app.getFavorites();
+ SettingsAPI settingsAPI = settings.getSettingsAPI();
+ Object globalPreferences = settings.getGlobalPreferences();
+
+ LatLon homePoint = null;
+ float lat = settingsAPI.getFloat(globalPreferences, "home_point_lat", 0);
+ float lon = settingsAPI.getFloat(globalPreferences, "home_point_lon", 0);
+ if (lat != 0 || lon != 0) {
+ homePoint = new LatLon(lat, lon);
+ }
+ LatLon workPoint = null;
+ lat = settingsAPI.getFloat(globalPreferences, "work_point_lat", 0);
+ lon = settingsAPI.getFloat(globalPreferences, "work_point_lon", 0);
+ if (lat != 0 || lon != 0) {
+ workPoint = new LatLon(lat, lon);
+ }
+ if (homePoint != null) {
+ favorites.setSpecialPoint(homePoint, SpecialPointType.HOME, null);
+ }
+ if (workPoint != null) {
+ favorites.setSpecialPoint(workPoint, SpecialPointType.WORK, null);
+ }
+ }
+
+
+ public OsmandPreference>[] getGeneralPrefs() {
+ OsmandSettings settings = app.getSettings();
+ return new OsmandPreference[] {
+ settings.EXTERNAL_INPUT_DEVICE,
+ settings.CENTER_POSITION_ON_MAP,
+ settings.ROTATE_MAP,
+ settings.MAP_SCREEN_ORIENTATION,
+ settings.LIVE_MONITORING_URL,
+ settings.LIVE_MONITORING_MAX_INTERVAL_TO_SEND,
+ settings.LIVE_MONITORING_INTERVAL,
+ settings.LIVE_MONITORING,
+ settings.SHOW_TRIP_REC_NOTIFICATION,
+ settings.AUTO_SPLIT_RECORDING,
+ settings.SAVE_TRACK_MIN_SPEED,
+ settings.SAVE_TRACK_PRECISION,
+ settings.SAVE_TRACK_MIN_DISTANCE,
+ settings.SAVE_TRACK_INTERVAL,
+ settings.TRACK_STORAGE_DIRECTORY,
+ settings.SAVE_HEADING_TO_GPX,
+ settings.DISABLE_RECORDING_ONCE_APP_KILLED,
+ settings.SAVE_TRACK_TO_GPX,
+ settings.SAVE_GLOBAL_TRACK_REMEMBER,
+ settings.SAVE_GLOBAL_TRACK_INTERVAL,
+ settings.MAP_EMPTY_STATE_ALLOWED,
+ settings.DO_NOT_USE_ANIMATIONS,
+ settings.USE_KALMAN_FILTER_FOR_COMPASS,
+ settings.USE_MAGNETIC_FIELD_SENSOR_COMPASS,
+ settings.USE_TRACKBALL_FOR_MOVEMENTS,
+ settings.SPEED_SYSTEM,
+ settings.ANGULAR_UNITS,
+ settings.METRIC_SYSTEM,
+ settings.DRIVING_REGION,
+ settings.DRIVING_REGION_AUTOMATIC
+ };
+ }
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java
index 26e173d568..d85d6ddd68 100644
--- a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java
+++ b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java
@@ -38,9 +38,8 @@ import net.osmand.plus.dialogs.HelpArticleDialogFragment;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmAndAppCustomization;
-import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.ContextMenuItemsPreference;
-import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference;
+import net.osmand.plus.settings.backend.ContextMenuItemsPreference;
+import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
@@ -137,14 +136,18 @@ public class ContextMenuAdapter {
Collections.sort(items, new Comparator() {
@Override
public int compare(ContextMenuItem item1, ContextMenuItem item2) {
- if (DRAWER_SWITCH_PROFILE_ID.equals(item1.getId())) {
- return -1;
- }
- if (DRAWER_CONFIGURE_PROFILE_ID.equals(item1.getId()) && DRAWER_SWITCH_PROFILE_ID.equals(item2.getId())) {
+ if (DRAWER_CONFIGURE_PROFILE_ID.equals(item1.getId())
+ && DRAWER_SWITCH_PROFILE_ID.equals(item2.getId())) {
return 1;
- }
- if (DRAWER_CONFIGURE_PROFILE_ID.equals(item1.getId())) {
+ } else if (DRAWER_SWITCH_PROFILE_ID.equals(item1.getId())
+ && DRAWER_CONFIGURE_PROFILE_ID.equals(item2.getId())) {
return -1;
+ } else if (DRAWER_SWITCH_PROFILE_ID.equals(item1.getId())
+ || DRAWER_CONFIGURE_PROFILE_ID.equals(item1.getId())) {
+ return -1;
+ } else if (DRAWER_SWITCH_PROFILE_ID.equals(item2.getId())
+ || DRAWER_CONFIGURE_PROFILE_ID.equals(item2.getId())) {
+ return 1;
}
int order1 = item1.getOrder();
int order2 = item2.getOrder();
@@ -643,7 +646,7 @@ public class ContextMenuAdapter {
return makeDeleteAction(prefs.toArray(new OsmandPreference[prefs.size()]));
}
- private static void resetSetting(ApplicationMode appMode, OsmandSettings.OsmandPreference preference, boolean profileOnly) {
+ private static void resetSetting(ApplicationMode appMode, OsmandPreference preference, boolean profileOnly) {
if (profileOnly) {
preference.resetModeToDefault(appMode);
} else {
diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java
index 7217e8af5f..923bbe646a 100644
--- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java
+++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java
@@ -29,7 +29,7 @@ import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetAxisType;
import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType;
import net.osmand.plus.routing.RouteProvider;
-import net.osmand.plus.settings.backend.OsmandSettings.MetricsConstants;
+import net.osmand.plus.helpers.enums.MetricsConstants;
import net.osmand.plus.track.GpxSplitType;
import net.osmand.plus.track.GradientScaleType;
import net.osmand.util.Algorithms;
diff --git a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java
index 2ac142d06a..b58b3eba5e 100644
--- a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java
+++ b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java
@@ -15,9 +15,9 @@ import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiType;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.AngularConstants;
-import net.osmand.plus.settings.backend.OsmandSettings.MetricsConstants;
-import net.osmand.plus.settings.backend.OsmandSettings.SpeedConstants;
+import net.osmand.plus.helpers.enums.AngularConstants;
+import net.osmand.plus.helpers.enums.MetricsConstants;
+import net.osmand.plus.helpers.enums.SpeedConstants;
import net.osmand.util.Algorithms;
import java.text.DateFormatSymbols;
diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java
index 43c3a17f09..1a48650a4d 100644
--- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java
+++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java
@@ -30,6 +30,7 @@ import androidx.multidex.MultiDex;
import androidx.multidex.MultiDexApplication;
import net.osmand.AndroidUtils;
+import net.osmand.FileUtils;
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
import net.osmand.access.AccessibilityPlugin;
@@ -42,7 +43,7 @@ import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.io.NetworkUtils;
import net.osmand.plus.AppInitializer.AppInitializeListener;
import net.osmand.plus.access.AccessibilityMode;
-import net.osmand.plus.activities.DayNightHelper;
+import net.osmand.plus.helpers.DayNightHelper;
import net.osmand.plus.activities.ExitActivity;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SavingTrackHelper;
@@ -56,7 +57,9 @@ import net.osmand.plus.download.DownloadIndexesThread;
import net.osmand.plus.download.DownloadService;
import net.osmand.plus.download.IndexItem;
import net.osmand.plus.helpers.AvoidSpecificRoads;
+import net.osmand.plus.helpers.enums.DrivingRegion;
import net.osmand.plus.helpers.LockHelper;
+import net.osmand.plus.helpers.enums.MetricsConstants;
import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
@@ -189,7 +192,7 @@ public class OsmandApplication extends MultiDexApplication {
osmandSettings.initExternalStorageDirectory();
}
externalStorageDirectory = osmandSettings.getExternalStorageDirectory();
- if (!OsmandSettings.isWritable(externalStorageDirectory)) {
+ if (!FileUtils.isWritable(externalStorageDirectory)) {
externalStorageDirectoryReadOnly = true;
externalStorageDirectory = osmandSettings.getInternalAppPath();
}
@@ -983,15 +986,15 @@ public class OsmandApplication extends MultiDexApplication {
}
public void setupDrivingRegion(WorldRegion reg) {
- OsmandSettings.DrivingRegion drg = null;
+ DrivingRegion drg = null;
WorldRegion.RegionParams params = reg.getParams();
// boolean americanSigns = "american".equals(params.getRegionRoadSigns());
boolean leftHand = "yes".equals(params.getRegionLeftHandDriving());
- OsmandSettings.MetricsConstants mc1 = "miles".equals(params.getRegionMetric()) ?
- OsmandSettings.MetricsConstants.MILES_AND_FEET : OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS;
- OsmandSettings.MetricsConstants mc2 = "miles".equals(params.getRegionMetric()) ?
- OsmandSettings.MetricsConstants.MILES_AND_METERS : OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS;
- for (OsmandSettings.DrivingRegion r : OsmandSettings.DrivingRegion.values()) {
+ MetricsConstants mc1 = "miles".equals(params.getRegionMetric()) ?
+ MetricsConstants.MILES_AND_FEET : MetricsConstants.KILOMETERS_AND_METERS;
+ MetricsConstants mc2 = "miles".equals(params.getRegionMetric()) ?
+ MetricsConstants.MILES_AND_METERS : MetricsConstants.KILOMETERS_AND_METERS;
+ for (DrivingRegion r : DrivingRegion.values()) {
if (r.leftHandDriving == leftHand && (r.defMetrics == mc1 || r.defMetrics == mc2)) {
drg = r;
break;
diff --git a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java
index 0d887bc47f..4e9ca3d420 100644
--- a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java
@@ -47,6 +47,8 @@ import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
import net.osmand.plus.search.QuickSearchDialogFragment;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmandSettings;
+import net.osmand.plus.settings.backend.CommonPreference;
+import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.settings.fragments.BaseSettingsFragment;
import net.osmand.plus.skimapsplugin.SkiMapsPlugin;
import net.osmand.plus.srtmplugin.SRTMPlugin;
@@ -80,7 +82,7 @@ public abstract class OsmandPlugin {
protected OsmandApplication app;
- protected List pluginPreferences = new ArrayList<>();
+ protected List pluginPreferences = new ArrayList<>();
private boolean active;
private String installURL = null;
@@ -118,7 +120,7 @@ public abstract class OsmandPlugin {
return null;
}
- public List getPreferences() {
+ public List getPreferences() {
return pluginPreferences;
}
@@ -919,44 +921,44 @@ public abstract class OsmandPlugin {
}
}
- protected OsmandSettings.CommonPreference registerBooleanPreference(OsmandApplication app, String prefId, boolean defValue) {
- OsmandSettings.CommonPreference preference = app.getSettings().registerBooleanPreference(prefId, defValue);
+ protected CommonPreference registerBooleanPreference(OsmandApplication app, String prefId, boolean defValue) {
+ CommonPreference preference = app.getSettings().registerBooleanPreference(prefId, defValue);
pluginPreferences.add(preference);
return preference;
}
- private OsmandSettings.CommonPreference registerBooleanAccessibilityPreference(OsmandApplication app, String prefId, boolean defValue) {
- OsmandSettings.CommonPreference preference = app.getSettings().registerBooleanAccessibilityPreference(prefId, defValue);
+ private CommonPreference registerBooleanAccessibilityPreference(OsmandApplication app, String prefId, boolean defValue) {
+ CommonPreference preference = app.getSettings().registerBooleanAccessibilityPreference(prefId, defValue);
pluginPreferences.add(preference);
return preference;
}
- protected OsmandSettings.CommonPreference registerStringPreference(OsmandApplication app, String prefId, String defValue) {
- OsmandSettings.CommonPreference preference = app.getSettings().registerStringPreference(prefId, defValue);
+ protected CommonPreference registerStringPreference(OsmandApplication app, String prefId, String defValue) {
+ CommonPreference preference = app.getSettings().registerStringPreference(prefId, defValue);
pluginPreferences.add(preference);
return preference;
}
- protected OsmandSettings.CommonPreference registerIntPreference(OsmandApplication app, String prefId, int defValue) {
- OsmandSettings.CommonPreference preference = app.getSettings().registerIntPreference(prefId, defValue);
+ protected CommonPreference registerIntPreference(OsmandApplication app, String prefId, int defValue) {
+ CommonPreference preference = app.getSettings().registerIntPreference(prefId, defValue);
pluginPreferences.add(preference);
return preference;
}
- protected OsmandSettings.CommonPreference registerLongPreference(OsmandApplication app, String prefId, long defValue) {
- OsmandSettings.CommonPreference preference = app.getSettings().registerLongPreference(prefId, defValue);
+ protected CommonPreference registerLongPreference(OsmandApplication app, String prefId, long defValue) {
+ CommonPreference preference = app.getSettings().registerLongPreference(prefId, defValue);
pluginPreferences.add(preference);
return preference;
}
- protected OsmandSettings.CommonPreference registerFloatPreference(OsmandApplication app, String prefId, float defValue) {
- OsmandSettings.CommonPreference preference = app.getSettings().registerFloatPreference(prefId, defValue);
+ protected CommonPreference registerFloatPreference(OsmandApplication app, String prefId, float defValue) {
+ CommonPreference preference = app.getSettings().registerFloatPreference(prefId, defValue);
pluginPreferences.add(preference);
return preference;
}
- protected OsmandSettings.CommonPreference registerEnumIntPreference(OsmandApplication app, String prefId, Enum defaultValue, Enum[] values, Class clz) {
- OsmandSettings.CommonPreference preference = app.getSettings().registerEnumIntPreference(prefId, defaultValue, values, clz);
+ protected CommonPreference registerEnumIntPreference(OsmandApplication app, String prefId, Enum defaultValue, Enum[] values, Class clz) {
+ CommonPreference preference = app.getSettings().registerEnumIntPreference(prefId, defaultValue, values, clz);
pluginPreferences.add(preference);
return preference;
}
diff --git a/OsmAnd/src/net/osmand/plus/Version.java b/OsmAnd/src/net/osmand/plus/Version.java
index 86d26ec954..48dd9b1feb 100644
--- a/OsmAnd/src/net/osmand/plus/Version.java
+++ b/OsmAnd/src/net/osmand/plus/Version.java
@@ -1,13 +1,15 @@
package net.osmand.plus;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
+import android.content.pm.PackageManager;
import net.osmand.plus.inapp.InAppPurchaseHelper;
+import java.io.File;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
public class Version {
private final String appVersion;
@@ -149,4 +151,21 @@ public class Version {
return v;
}
-}
+ public static boolean isOpenGlAvailable(OsmandApplication app) {
+ if ("qnx".equals(System.getProperty("os.name"))) {
+ return false;
+ }
+ File nativeLibraryDir = new File(app.getApplicationInfo().nativeLibraryDir);
+ if (nativeLibraryDir.exists() && nativeLibraryDir.canRead()) {
+ File[] files = nativeLibraryDir.listFiles();
+ if (files != null) {
+ for (File file : files) {
+ if ("libOsmAndCoreWithJNI.so".equals(file.getName())) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java
index 91bf4ffbf9..b1a625d27e 100644
--- a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java
+++ b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java
@@ -43,6 +43,7 @@ import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
import net.osmand.plus.FavouritesDbHelper.FavoritesListener;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
@@ -96,7 +97,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
private Set groupsToDelete = new LinkedHashSet<>();
private ActionMode actionMode;
private Drawable arrowImageDisabled;
- private HashMap> preferenceCache = new HashMap<>();
+ private HashMap> preferenceCache = new HashMap<>();
private View footerView;
private Location lastLocation;
private float lastHeading;
@@ -763,8 +764,8 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
}
}
- private OsmandSettings.OsmandPreference getGroupExpandedPreference(String groupName) {
- OsmandSettings.OsmandPreference preference = preferenceCache.get(groupName);
+ private OsmandPreference getGroupExpandedPreference(String groupName) {
+ OsmandPreference preference = preferenceCache.get(groupName);
if (preference == null) {
String groupKey = groupName + GROUP_EXPANDED_POSTFIX;
preference = getSettings().registerBooleanPreference(groupKey, false);
diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
index 3baa33cb32..083c95d279 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
@@ -74,6 +74,9 @@ import net.osmand.plus.OsmAndConstants;
import net.osmand.plus.OsmAndLocationSimulation;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
+import net.osmand.plus.helpers.DayNightHelper;
+import net.osmand.plus.settings.backend.CommonPreference;
+import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
@@ -130,7 +133,6 @@ import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchTab;
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType;
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.settings.fragments.BaseSettingsFragment;
import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType;
import net.osmand.plus.settings.fragments.ConfigureProfileFragment;
@@ -533,7 +535,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
@Override
public void requestPrivateAccessRouting() {
if (!settings.FORCE_PRIVATE_ACCESS_ROUTING_ASKED.getModeValue(getRoutingHelper().getAppMode())) {
- final OsmandSettings.CommonPreference allowPrivate
+ final CommonPreference allowPrivate
= settings.getCustomRoutingBooleanProperty(GeneralRouter.ALLOW_PRIVATE, false);
final List modes = ApplicationMode.values(app);
for (ApplicationMode mode : modes) {
diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java
index 64f3ad8b9f..442e2f41a1 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityLayers.java
@@ -29,7 +29,7 @@ import net.osmand.plus.DialogListItemAdapter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
+import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.R;
import net.osmand.plus.SQLiteTileSource;
import net.osmand.plus.activities.MapActivity.ShowQuickSearchMode;
diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java
index 2187e801a2..316de777b0 100644
--- a/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java
@@ -25,13 +25,13 @@ import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.settings.backend.OsmandSettings;
+import net.osmand.plus.settings.backend.CommonPreference;
+import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.profiles.AppProfileArrayAdapter;
import net.osmand.plus.profiles.ProfileDataObject;
import net.osmand.plus.settings.backend.ApplicationMode;
-import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
-import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference;
import org.apache.commons.logging.Log;
diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java
index aaf206ca06..225384349c 100644
--- a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java
@@ -42,9 +42,9 @@ import net.osmand.osm.io.NetworkUtils;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.AngularConstants;
-import net.osmand.plus.settings.backend.OsmandSettings.DrivingRegion;
-import net.osmand.plus.settings.backend.OsmandSettings.MetricsConstants;
+import net.osmand.plus.helpers.enums.AngularConstants;
+import net.osmand.plus.helpers.enums.DrivingRegion;
+import net.osmand.plus.helpers.enums.MetricsConstants;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.base.MapViewTrackingUtilities;
diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java
index 260fd63719..a0a5c74992 100644
--- a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java
@@ -34,6 +34,12 @@ import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.helpers.enums.MetricsConstants;
+import net.osmand.plus.settings.backend.CommonPreference;
+import net.osmand.plus.settings.backend.OsmandSettings;
+import net.osmand.plus.helpers.enums.AutoZoomMap;
+import net.osmand.plus.settings.backend.OsmandPreference;
+import net.osmand.plus.helpers.enums.SpeedConstants;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.Version;
@@ -44,10 +50,6 @@ import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.settings.backend.ApplicationMode;
-import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.AutoZoomMap;
-import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference;
-import net.osmand.plus.settings.backend.OsmandSettings.SpeedConstants;
import net.osmand.plus.voice.CommandPlayer;
import net.osmand.router.GeneralRouter;
import net.osmand.router.GeneralRouter.GeneralRouterProfile;
@@ -171,7 +173,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
//array size must be equal!
Float[] speedLimitsKmhPos = new Float[]{0f, 5f, 7f, 10f, 15f, 20f};
Float[] speedLimitsMphPos = new Float[]{0f, 3f, 5f, 7f, 10f, 15f};
- if (settings.METRIC_SYSTEM.get() == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS) {
+ if (settings.METRIC_SYSTEM.get() == MetricsConstants.KILOMETERS_AND_METERS) {
String[] speedNames = new String[speedLimitsKmh.length];
String[] speedNamesPos = new String[speedLimitsKmhPos.length];
for (int i = 0; i < speedLimitsKmh.length; i++) {
@@ -407,7 +409,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
}
public static boolean isRoutingParameterSelected(OsmandSettings settings, ApplicationMode am, RoutingParameter routingParameter) {
- final OsmandSettings.CommonPreference property =
+ final CommonPreference property =
settings.getCustomRoutingBooleanProperty(routingParameter.getId(), routingParameter.getDefaultBoolean());
if(am != null) {
return property.getModeValue(am);
@@ -417,7 +419,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
}
public static void setRoutingParameterSelected(OsmandSettings settings, ApplicationMode am, String routingParameterId, boolean defaultBoolean, boolean isChecked) {
- final OsmandSettings.CommonPreference property = settings.getCustomRoutingBooleanProperty(routingParameterId, defaultBoolean);
+ final CommonPreference property = settings.getCustomRoutingBooleanProperty(routingParameterId, defaultBoolean);
if (am != null) {
property.setModeValue(am, isChecked);
} else {
diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java
index de3453550f..a68a8bc749 100644
--- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java
@@ -53,8 +53,8 @@ import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
-import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
-import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference;
+import net.osmand.plus.settings.backend.CommonPreference;
+import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
diff --git a/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java b/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java
index 09acdca8d8..8e911b04fc 100644
--- a/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java
+++ b/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java
@@ -38,7 +38,6 @@ import net.osmand.PlatformUtil;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
-import net.osmand.plus.settings.backend.OsmandSettings.NotesSortByMode;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.activities.ActionBarProgressActivity;
diff --git a/OsmAnd/src/net/osmand/plus/audionotes/NotesSortByMode.java b/OsmAnd/src/net/osmand/plus/audionotes/NotesSortByMode.java
new file mode 100644
index 0000000000..cf791dbf26
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/audionotes/NotesSortByMode.java
@@ -0,0 +1,14 @@
+package net.osmand.plus.audionotes;
+
+public enum NotesSortByMode {
+ BY_TYPE,
+ BY_DATE;
+
+ public boolean isByType() {
+ return this == BY_TYPE;
+ }
+
+ public boolean isByDate() {
+ return this == BY_DATE;
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/audionotes/SortByMenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/audionotes/SortByMenuBottomSheetDialogFragment.java
index de1208a735..06fa83f6ca 100644
--- a/OsmAnd/src/net/osmand/plus/audionotes/SortByMenuBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/audionotes/SortByMenuBottomSheetDialogFragment.java
@@ -3,8 +3,7 @@ package net.osmand.plus.audionotes;
import android.os.Bundle;
import android.view.View;
-import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.NotesSortByMode;
+import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.R;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
@@ -53,7 +52,7 @@ public class SortByMenuBottomSheetDialogFragment extends MenuBottomSheetDialogFr
}
private void selectSortByMode(NotesSortByMode mode) {
- final OsmandSettings.CommonPreference sortByMode = getMyApplication().getSettings().NOTES_SORT_BY_MODE;
+ final CommonPreference sortByMode = getMyApplication().getSettings().NOTES_SORT_BY_MODE;
if (sortByMode.get() != mode) {
sortByMode.set(mode);
if (listener != null) {
diff --git a/OsmAnd/src/net/osmand/plus/chooseplan/OsmLiveCancelledDialog.java b/OsmAnd/src/net/osmand/plus/chooseplan/OsmLiveCancelledDialog.java
index 43d95c266c..a62ffcd296 100644
--- a/OsmAnd/src/net/osmand/plus/chooseplan/OsmLiveCancelledDialog.java
+++ b/OsmAnd/src/net/osmand/plus/chooseplan/OsmLiveCancelledDialog.java
@@ -25,7 +25,7 @@ import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.Version;
import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference;
+import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndDialogFragment;
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashChooseAppDirFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashChooseAppDirFragment.java
index 9f37cd1b41..883010ea46 100644
--- a/OsmAnd/src/net/osmand/plus/dashboard/DashChooseAppDirFragment.java
+++ b/OsmAnd/src/net/osmand/plus/dashboard/DashChooseAppDirFragment.java
@@ -30,6 +30,7 @@ import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import net.osmand.AndroidUtils;
+import net.osmand.FileUtils;
import net.osmand.ValueHolder;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.settings.backend.OsmandSettings;
@@ -113,7 +114,7 @@ public class DashChooseAppDirFragment {
boolean copyFiles = !currentAppFile.getAbsolutePath().equals(selectedFile.getAbsolutePath()) && !mapsCopied;
warningReadonly.setVisibility(copyFiles ? View.VISIBLE : View.GONE);
if (copyFiles) {
- if (!OsmandSettings.isWritable(currentAppFile)) {
+ if (!FileUtils.isWritable(currentAppFile)) {
warningReadonly.setText(activity.getString(R.string.android_19_location_disabled,
currentAppFile.getAbsolutePath()));
} else {
@@ -385,7 +386,7 @@ public class DashChooseAppDirFragment {
@Override
public void onClick(View v) {
- boolean wr = OsmandSettings.isWritable(selectedFile);
+ boolean wr = FileUtils.isWritable(selectedFile);
if (wr) {
boolean changed = !currentAppFile.getAbsolutePath().equals(selectedFile.getAbsolutePath());
getMyApplication().setExternalStorageDirectory(type, selectedFile.getAbsolutePath());
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java
index 1689a4e298..725a8fefc6 100644
--- a/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java
@@ -24,7 +24,7 @@ import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
+import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
diff --git a/OsmAnd/src/net/osmand/plus/development/DevelopmentSettingsFragment.java b/OsmAnd/src/net/osmand/plus/development/DevelopmentSettingsFragment.java
index 7a3503e004..bad57f326b 100644
--- a/OsmAnd/src/net/osmand/plus/development/DevelopmentSettingsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/development/DevelopmentSettingsFragment.java
@@ -35,12 +35,7 @@ public class DevelopmentSettingsFragment extends BaseSettingsFragment {
setupOpenglRenderPref();
setupSafeModePref();
- setupPTSafeMode();
- setupDisableComplexRoutingPref();
- setupFastRecalculationPref();
- setupOsmLiveForRoutingPref();
- setupOsmLiveForPublicTransportPref();
setupSimulateYourLocationPref();
Preference debuggingAndDevelopment = findPreference("debugging_and_development");
@@ -62,13 +57,17 @@ public class DevelopmentSettingsFragment extends BaseSettingsFragment {
}
private void setupOpenglRenderPref() {
- SwitchPreferenceEx useOpenglRender = (SwitchPreferenceEx) findPreference(settings.USE_OPENGL_RENDER.getId());
- useOpenglRender.setDescription(getString(R.string.use_opengl_render_descr));
- useOpenglRender.setIconSpaceReserved(false);
+ SwitchPreferenceEx useOpenglRender = findPreference(settings.USE_OPENGL_RENDER.getId());
+ if (Version.isOpenGlAvailable(app)) {
+ useOpenglRender.setDescription(getString(R.string.use_opengl_render_descr));
+ useOpenglRender.setIconSpaceReserved(false);
+ } else {
+ useOpenglRender.setVisible(false);
+ }
}
private void setupSafeModePref() {
- SwitchPreferenceEx safeMode = (SwitchPreferenceEx) findPreference(settings.SAFE_MODE.getId());
+ SwitchPreferenceEx safeMode = findPreference(settings.SAFE_MODE.getId());
if (!Version.isBlackberry(app)) {
safeMode.setDescription(getString(R.string.safe_mode_description));
safeMode.setIconSpaceReserved(false);
@@ -82,40 +81,6 @@ public class DevelopmentSettingsFragment extends BaseSettingsFragment {
}
}
- private void setupPTSafeMode() {
- SwitchPreferenceEx ptSafeMode = (SwitchPreferenceEx) findPreference(settings.PT_SAFE_MODE.getId());
- if (!Version.isBlackberry(app)) {
- ptSafeMode.setDescription("Switch to Java (safe) Public Transport routing calculation");
- ptSafeMode.setIconSpaceReserved(false);
- } else {
- ptSafeMode.setVisible(false);
- }
- }
-
- private void setupDisableComplexRoutingPref() {
- SwitchPreferenceEx disableComplexRouting = (SwitchPreferenceEx) findPreference(settings.DISABLE_COMPLEX_ROUTING.getId());
- disableComplexRouting.setDescription(getString(R.string.disable_complex_routing_descr));
- disableComplexRouting.setIconSpaceReserved(false);
- }
-
- private void setupFastRecalculationPref() {
- SwitchPreferenceEx useFastRecalculation = (SwitchPreferenceEx) findPreference(settings.USE_FAST_RECALCULATION.getId());
- useFastRecalculation.setDescription(getString(R.string.use_fast_recalculation_desc));
- useFastRecalculation.setIconSpaceReserved(false);
- }
-
- private void setupOsmLiveForRoutingPref() {
- SwitchPreferenceEx useOsmLiveForRouting = (SwitchPreferenceEx) findPreference(settings.USE_OSM_LIVE_FOR_ROUTING.getId());
- useOsmLiveForRouting.setDescription(getString(R.string.use_osm_live_routing_description));
- useOsmLiveForRouting.setIconSpaceReserved(false);
- }
-
- private void setupOsmLiveForPublicTransportPref() {
- SwitchPreferenceEx useOsmLiveForPublicTransport = (SwitchPreferenceEx) findPreference(settings.USE_OSM_LIVE_FOR_PUBLIC_TRANSPORT.getId());
- useOsmLiveForPublicTransport.setDescription(getString(R.string.use_osm_live_public_transport_description));
- useOsmLiveForPublicTransport.setIconSpaceReserved(false);
- }
-
private void setupSimulateYourLocationPref() {
final Preference simulateYourLocation = findPreference(SIMULATE_YOUR_LOCATION);
simulateYourLocation.setIconSpaceReserved(false);
diff --git a/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java b/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java
index b5ea815bed..c500a28254 100644
--- a/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java
+++ b/OsmAnd/src/net/osmand/plus/development/SettingsDevelopmentActivity.java
@@ -14,11 +14,11 @@ import android.preference.PreferenceScreen;
import net.osmand.plus.OsmAndLocationSimulation;
import net.osmand.plus.OsmandApplication;
-import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.activities.SettingsBaseActivity;
import net.osmand.plus.render.NativeOsmandLibrary;
+import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.util.SunriseSunset;
import java.text.SimpleDateFormat;
@@ -34,41 +34,27 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
app.applyTheme(this);
super.onCreate(savedInstanceState);
getToolbar().setTitle(R.string.debugging_and_development);
- PreferenceScreen cat = getPreferenceScreen();
+ PreferenceScreen category = getPreferenceScreen();
Preference pref;
- cat.addPreference(createCheckBoxPreference(settings.USE_OPENGL_RENDER,
- R.string.use_opengl_render, R.string.use_opengl_render_descr));
+ if (Version.isOpenGlAvailable(app)) {
+ category.addPreference(createCheckBoxPreference(settings.USE_OPENGL_RENDER,
+ R.string.use_opengl_render, R.string.use_opengl_render_descr));
+ }
if (!Version.isBlackberry(app)) {
CheckBoxPreference nativeCheckbox = createCheckBoxPreference(settings.SAFE_MODE, R.string.safe_mode, R.string.safe_mode_description);
- CheckBoxPreference nativePTCheckbox = createCheckBoxPreference(settings.PT_SAFE_MODE, "Native PT routing development", "Switch to Java (safe) Public Transport routing calculation");
// disable the checkbox if the library cannot be used
if ((NativeOsmandLibrary.isLoaded() && !NativeOsmandLibrary.isSupported()) || settings.NATIVE_RENDERING_FAILED.get()) {
nativeCheckbox.setEnabled(false);
nativeCheckbox.setChecked(true);
}
- cat.addPreference(nativeCheckbox);
- cat.addPreference(nativePTCheckbox);
+ category.addPreference(nativeCheckbox);
}
PreferenceCategory navigation = new PreferenceCategory(this);
navigation.setTitle(R.string.routing_settings);
- cat.addPreference(navigation);
- navigation.addPreference(createCheckBoxPreference(settings.DISABLE_COMPLEX_ROUTING,
- R.string.disable_complex_routing, R.string.disable_complex_routing_descr));
-
- navigation.addPreference(createCheckBoxPreference(settings.USE_FAST_RECALCULATION,
- R.string.use_fast_recalculation, R.string.use_fast_recalculation_desc));
-
- navigation.addPreference(createCheckBoxPreference(settings.USE_OSM_LIVE_FOR_ROUTING,
- R.string.use_osm_live_routing,
- R.string.use_osm_live_routing_description));
-
- navigation.addPreference(createCheckBoxPreference(settings.USE_OSM_LIVE_FOR_PUBLIC_TRANSPORT,
- R.string.use_osm_live_public_transport,
- R.string.use_osm_live_public_transport_description));
-
+ category.addPreference(navigation);
pref = new Preference(this);
final Preference simulate = pref;
final OsmAndLocationSimulation sim = getMyApplication().getLocationProvider().getLocationSimulation();
@@ -95,7 +81,7 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
PreferenceCategory debug = new PreferenceCategory(this);
debug.setTitle(R.string.debugging_and_development);
- cat.addPreference(debug);
+ category.addPreference(debug);
CheckBoxPreference dbg = createCheckBoxPreference(settings.DEBUG_RENDERING_INFO,
R.string.trace_rendering, R.string.trace_rendering_descr);
@@ -125,10 +111,6 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
debug.addPreference(createCheckBoxPreference(settings.SHOULD_SHOW_FREE_VERSION_BANNER,
R.string.show_free_version_banner,
R.string.show_free_version_banner_description));
-
-
-
-
pref = new Preference(this);
pref.setTitle(R.string.test_voice_prompts);
@@ -141,7 +123,7 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
return true;
}
});
- cat.addPreference(pref);
+ category.addPreference(pref);
pref = new Preference(this);
pref.setTitle(R.string.logcat_buffer);
@@ -154,11 +136,11 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
return true;
}
});
- cat.addPreference(pref);
+ category.addPreference(pref);
PreferenceCategory info = new PreferenceCategory(this);
info.setTitle(R.string.info_button);
- cat.addPreference(info);
+ category.addPreference(info);
pref = new Preference(this);
pref.setTitle(R.string.global_app_allocated_memory);
diff --git a/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java b/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java
index f1cddde833..a9a0ba563e 100644
--- a/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java
+++ b/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java
@@ -19,7 +19,7 @@ import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import net.osmand.plus.OsmandApplication;
-import net.osmand.plus.settings.backend.OsmandSettings;
+import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.activities.OsmandActionBarActivity;
import net.osmand.plus.routing.data.StreetName;
@@ -151,7 +151,7 @@ public class TestVoiceActivity extends OsmandActionBarActivity {
v += "\n \u25CF BT SCO: The current app profile is not set to use 'Phone call audio'.";
}
- //OsmandSettings.OsmandPreference pref = ((OsmandApplication) getApplication()).getSettings().VOICE_PROMPT_DELAY[stream];
+ //OsmandPreference pref = ((OsmandApplication) getApplication()).getSettings().VOICE_PROMPT_DELAY[stream];
//if(pref != null) {
// v += "\n \u25CF Voice prompt delay for selected output: " + pref.get() + "\u00A0ms";
//}
@@ -299,7 +299,7 @@ public class TestVoiceActivity extends OsmandActionBarActivity {
}
if (description.startsWith("\u25BA (11.2)")) {
int ams = ((OsmandApplication) getApplication()).getSettings().AUDIO_MANAGER_STREAM.get();
- OsmandSettings.OsmandPreference pref = ((OsmandApplication) getApplication()).getSettings().VOICE_PROMPT_DELAY[ams];
+ OsmandPreference pref = ((OsmandApplication) getApplication()).getSettings().VOICE_PROMPT_DELAY[ams];
if (pref != null) {
if (pref.get() >= 3000) {
pref.set(0);
diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java
index 83c4e1942d..1c01808be8 100644
--- a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java
+++ b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java
@@ -33,6 +33,11 @@ import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.DialogListItemAdapter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
+import net.osmand.plus.helpers.enums.DayNightMode;
+import net.osmand.plus.settings.backend.OsmandPreference;
+import net.osmand.plus.settings.backend.OsmandSettings;
+import net.osmand.plus.settings.backend.CommonPreference;
+import net.osmand.plus.settings.backend.ListStringPreference;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
@@ -40,9 +45,6 @@ import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.render.RendererRegistry;
-import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
-import net.osmand.plus.settings.backend.OsmandSettings.ListStringPreference;
import net.osmand.plus.srtmplugin.SRTMPlugin;
import net.osmand.plus.transport.TransportLinesMenu;
import net.osmand.plus.views.OsmandMapTileView;
@@ -307,7 +309,7 @@ public class ConfigureMapMenu {
DateFormat dateFormat = DateFormat.getTimeInstance(DateFormat.SHORT);
String sunriseTime = dateFormat.format(sunriseSunset.getSunrise());
String sunsetTime = dateFormat.format(sunriseSunset.getSunset());
- OsmandSettings.DayNightMode dayNightMode = activity.getMyApplication().getSettings().DAYNIGHT_MODE.get();
+ DayNightMode dayNightMode = activity.getMyApplication().getSettings().DAYNIGHT_MODE.get();
if (dayNightMode.isDay() || dayNightMode.isNight()) {
if (sunriseSunset.isDaytime()) {
description = String.format(app.getString(R.string.sunset_at), sunsetTime);
@@ -334,9 +336,9 @@ public class ConfigureMapMenu {
final OsmandMapTileView view = activity.getMapView();
AlertDialog.Builder bld = new AlertDialog.Builder(new ContextThemeWrapper(view.getContext(), themeRes));
bld.setTitle(R.string.daynight);
- final String[] items = new String[OsmandSettings.DayNightMode.values().length];
+ final String[] items = new String[DayNightMode.values().length];
for (int i = 0; i < items.length; i++) {
- items[i] = OsmandSettings.DayNightMode.values()[i].toHumanString(app);
+ items[i] = DayNightMode.values()[i].toHumanString(app);
}
int i = view.getSettings().DAYNIGHT_MODE.get().ordinal();
bld.setNegativeButton(R.string.shared_string_dismiss, null);
@@ -345,7 +347,7 @@ public class ConfigureMapMenu {
@Override
public void onClick(View v) {
int which = (int) v.getTag();
- view.getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.values()[which]);
+ view.getSettings().DAYNIGHT_MODE.set(DayNightMode.values()[which]);
refreshMapComplete(activity);
activity.getDashboard().refreshContent(true);
// adapter.getItem(pos).setDescription(s, getDayNightDescr(activity));
@@ -376,7 +378,7 @@ public class ConfigureMapMenu {
return false;
}
final OsmandMapTileView view = activity.getMapView();
- final OsmandSettings.OsmandPreference mapDensity = view.getSettings().MAP_DENSITY;
+ final OsmandPreference mapDensity = view.getSettings().MAP_DENSITY;
AlertDialog.Builder bld = new AlertDialog.Builder(new ContextThemeWrapper(view.getContext(), themeRes));
int p = (int) (mapDensity.get() * 100);
final TIntArrayList tlist = new TIntArrayList(new int[]{25, 33, 50, 75, 100, 125, 150, 200, 300, 400});
@@ -669,25 +671,25 @@ public class ConfigureMapMenu {
@ColorInt final int selectedProfileColor) {
final List ps = new ArrayList<>();
- final List> prefs = new ArrayList<>();
+ final List> prefs = new ArrayList<>();
Iterator it = customRules.iterator();
while (it.hasNext()) {
RenderingRuleProperty p = it.next();
if (category.equals(p.getCategory()) && p.isBoolean()) {
ps.add(p);
- final OsmandSettings.CommonPreference pref = activity.getMyApplication().getSettings()
+ final CommonPreference pref = activity.getMyApplication().getSettings()
.getCustomRenderBooleanProperty(p.getAttrName());
prefs.add(pref);
it.remove();
}
}
if (prefs.size() > 0) {
- final List> includedPrefs = new ArrayList<>();
+ final List> includedPrefs = new ArrayList<>();
if (customRulesIncluded != null) {
for (RenderingRuleProperty p : customRulesIncluded) {
if (!p.isBoolean()) {
- final OsmandSettings.CommonPreference pref = activity.getMyApplication().getSettings()
+ final CommonPreference pref = activity.getMyApplication().getSettings()
.getCustomRenderProperty(p.getAttrName());
includedPrefs.add(pref);
}
@@ -729,14 +731,14 @@ public class ConfigureMapMenu {
.setId(id)
.setIcon(icon).setListener(clickListener);
boolean selected = false;
- for (OsmandSettings.CommonPreference p : prefs) {
+ for (CommonPreference p : prefs) {
if (p.get()) {
selected = true;
break;
}
}
if (!selected && includedPrefs.size() > 0) {
- for (OsmandSettings.CommonPreference p : includedPrefs) {
+ for (CommonPreference p : includedPrefs) {
if (!Algorithms.isEmpty(p.get())) {
selected = true;
break;
@@ -773,17 +775,17 @@ public class ConfigureMapMenu {
return null;
}
- protected String getDescription(final List> prefs,
- final List> includedPrefs) {
+ protected String getDescription(final List> prefs,
+ final List> includedPrefs) {
int count = 0;
int enabled = 0;
- for (OsmandSettings.CommonPreference p : prefs) {
+ for (CommonPreference p : prefs) {
count++;
if (p.get()) {
enabled++;
}
}
- for (OsmandSettings.CommonPreference p : includedPrefs) {
+ for (CommonPreference p : includedPrefs) {
count++;
if (!Algorithms.isEmpty(p.get())) {
enabled++;
@@ -856,11 +858,11 @@ public class ConfigureMapMenu {
prefs.get(i).set(tempPrefs[i]);
selected |= tempPrefs[i];
}
- final List> includedPrefs = new ArrayList<>();
+ final List> includedPrefs = new ArrayList<>();
if (customRulesIncluded != null) {
for (RenderingRuleProperty p : customRulesIncluded) {
if (p.getAttrName().equals(HIKING_ROUTES_OSMC_ATTR)) {
- final OsmandSettings.CommonPreference pref = activity.getMyApplication().getSettings()
+ final CommonPreference pref = activity.getMyApplication().getSettings()
.getCustomRenderProperty(p.getAttrName());
includedPrefs.add(pref);
if (hikingRouteOSMCValue == 0) {
@@ -894,7 +896,7 @@ public class ConfigureMapMenu {
if (customRulesIncluded != null) {
for (RenderingRuleProperty p : customRulesIncluded) {
if (!p.isBoolean()) {
- final OsmandSettings.CommonPreference pref = activity.getMyApplication().getSettings()
+ final CommonPreference pref = activity.getMyApplication().getSettings()
.getCustomRenderProperty(p.getAttrName());
View spinnerView = View.inflate(new ContextThemeWrapper(activity, themeRes), R.layout.spinner_rule_layout, null);
@@ -1031,7 +1033,7 @@ public class ConfigureMapMenu {
final String propertyDescr = SettingsActivity.getStringPropertyDescription(view.getContext(),
p.getAttrName(), p.getName());
if (p.isBoolean()) {
- final OsmandSettings.CommonPreference pref = view.getApplication().getSettings()
+ final CommonPreference pref = view.getApplication().getSettings()
.getCustomRenderBooleanProperty(p.getAttrName());
return ContextMenuItem.createBuilder(propertyName)
.setId(id)
@@ -1047,7 +1049,7 @@ public class ConfigureMapMenu {
.setSelected(pref.get())
.createItem();
} else {
- final OsmandSettings.CommonPreference pref = view.getApplication().getSettings()
+ final CommonPreference pref = view.getApplication().getSettings()
.getCustomRenderProperty(p.getAttrName());
final String descr;
if (!Algorithms.isEmpty(pref.get())) {
diff --git a/OsmAnd/src/net/osmand/plus/dialogs/DetailsBottomSheet.java b/OsmAnd/src/net/osmand/plus/dialogs/DetailsBottomSheet.java
index 4e8febb56e..ecb8f04b86 100644
--- a/OsmAnd/src/net/osmand/plus/dialogs/DetailsBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/dialogs/DetailsBottomSheet.java
@@ -27,7 +27,7 @@ import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemTwoChoicesButton.OnBo
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem;
import net.osmand.plus.helpers.FontCache;
-import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
+import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.settings.bottomsheets.BasePreferenceBottomSheet;
import net.osmand.render.RenderingRuleProperty;
import net.osmand.render.RenderingRuleStorageProperties;
diff --git a/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java
index 534c334aec..8219cc5a23 100644
--- a/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java
+++ b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java
@@ -10,8 +10,9 @@ import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
+import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.LayerTransparencySeekbarMode;
+import net.osmand.plus.rastermaps.LayerTransparencySeekbarMode;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivityLayers;
@@ -39,9 +40,9 @@ public class RasterMapMenu {
final OsmandSettings settings = app.getSettings();
final OsmandRasterMapsPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class);
assert plugin != null;
- final OsmandSettings.CommonPreference mapTransparencyPreference;
- final OsmandSettings.CommonPreference mapTypePreference;
- final OsmandSettings.CommonPreference exMapTypePreference;
+ final CommonPreference mapTransparencyPreference;
+ final CommonPreference mapTypePreference;
+ final CommonPreference exMapTypePreference;
final LayerTransparencySeekbarMode currentMapTypeSeekbarMode =
type == RasterMapType.OVERLAY ? LayerTransparencySeekbarMode.OVERLAY : LayerTransparencySeekbarMode.UNDERLAY;
@StringRes final int mapTypeString;
@@ -62,7 +63,7 @@ public class RasterMapMenu {
throw new RuntimeException("Unexpected raster map type");
}
- final OsmandSettings.CommonPreference hidePolygonsPref =
+ final CommonPreference hidePolygonsPref =
mapActivity.getMyApplication().getSettings().getCustomRenderBooleanProperty("noPolygons");
String mapTypeDescr = mapTypePreference.get();
@@ -181,8 +182,8 @@ public class RasterMapMenu {
@NonNull
public static Boolean isSeekbarVisible(OsmandApplication app, RasterMapType type) {
- final OsmandSettings.LayerTransparencySeekbarMode currentMapTypeSeekbarMode =
- type == RasterMapType.OVERLAY ? OsmandSettings.LayerTransparencySeekbarMode.OVERLAY : OsmandSettings.LayerTransparencySeekbarMode.UNDERLAY;
+ final LayerTransparencySeekbarMode currentMapTypeSeekbarMode =
+ type == RasterMapType.OVERLAY ? LayerTransparencySeekbarMode.OVERLAY : LayerTransparencySeekbarMode.UNDERLAY;
LayerTransparencySeekbarMode seekbarMode = app.getSettings().LAYER_TRANSPARENCY_SEEKBAR_MODE.get();
return seekbarMode == LayerTransparencySeekbarMode.UNDEFINED || seekbarMode == currentMapTypeSeekbarMode;
}
diff --git a/OsmAnd/src/net/osmand/plus/dialogs/SendAnalyticsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/dialogs/SendAnalyticsBottomSheetDialogFragment.java
index f84ac5239e..983315c503 100644
--- a/OsmAnd/src/net/osmand/plus/dialogs/SendAnalyticsBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/dialogs/SendAnalyticsBottomSheetDialogFragment.java
@@ -19,7 +19,7 @@ import androidx.fragment.app.FragmentManager;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference;
+import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton;
diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java
index 450d7e4b0d..7e0aadfa3b 100644
--- a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java
+++ b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java
@@ -23,7 +23,7 @@ import net.osmand.map.WorldRegion;
import net.osmand.map.WorldRegion.RegionParams;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference;
+import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.base.BasicProgressAsyncTask;
diff --git a/OsmAnd/src/net/osmand/plus/download/ui/DataStoragePlaceDialogFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/DataStoragePlaceDialogFragment.java
index dceeac1862..f97784cb36 100644
--- a/OsmAnd/src/net/osmand/plus/download/ui/DataStoragePlaceDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/download/ui/DataStoragePlaceDialogFragment.java
@@ -21,6 +21,7 @@ import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentManager;
import net.osmand.AndroidUtils;
+import net.osmand.FileUtils;
import net.osmand.IProgress;
import net.osmand.plus.OnDismissDialogFragmentListener;
import net.osmand.plus.OsmandApplication;
@@ -71,7 +72,7 @@ public class DataStoragePlaceDialogFragment extends BottomSheetDialogFragment {
File internalStorage = getInternalStorageDirectory(activity);
File external1Storage = getExternal1StorageDirectory(activity);
- if (external1Storage != null && external1Storage.exists() && OsmandSettings.isWritable(external1Storage)) {
+ if (external1Storage != null && external1Storage.exists() && FileUtils.isWritable(external1Storage)) {
deviceStorage = external1Storage;
deviceStorageType = OsmandSettings.EXTERNAL_STORAGE_TYPE_EXTERNAL_FILE;
deviceStorageName = getString(R.string.storage_directory_external);
@@ -246,7 +247,7 @@ public class DataStoragePlaceDialogFragment extends BottomSheetDialogFragment {
};
public boolean saveFilesLocation(int type, File selectedFile, Activity context) {
- boolean wr = OsmandSettings.isWritable(selectedFile);
+ boolean wr = FileUtils.isWritable(selectedFile);
if (wr) {
((OsmandApplication) context.getApplication())
.setExternalStorageDirectory(type, selectedFile.getAbsolutePath());
diff --git a/OsmAnd/src/net/osmand/plus/activities/DayNightHelper.java b/OsmAnd/src/net/osmand/plus/helpers/DayNightHelper.java
similarity index 98%
rename from OsmAnd/src/net/osmand/plus/activities/DayNightHelper.java
rename to OsmAnd/src/net/osmand/plus/helpers/DayNightHelper.java
index f9ca2afca4..d3ebe9d6ae 100644
--- a/OsmAnd/src/net/osmand/plus/activities/DayNightHelper.java
+++ b/OsmAnd/src/net/osmand/plus/helpers/DayNightHelper.java
@@ -1,20 +1,6 @@
-package net.osmand.plus.activities;
+package net.osmand.plus.helpers;
-import java.util.Date;
-import java.util.List;
-import java.util.TimeZone;
-
-import net.osmand.Location;
-import net.osmand.PlatformUtil;
-import net.osmand.StateChangedListener;
-import net.osmand.plus.settings.backend.ApplicationMode;
-import net.osmand.plus.OsmandApplication;
-import net.osmand.plus.settings.backend.OsmandSettings.DayNightMode;
-import net.osmand.util.SunriseSunset;
-
-import org.apache.commons.logging.Log;
-
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
@@ -22,6 +8,20 @@ import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.location.LocationManager;
+import net.osmand.Location;
+import net.osmand.PlatformUtil;
+import net.osmand.StateChangedListener;
+import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.helpers.enums.DayNightMode;
+import net.osmand.plus.settings.backend.ApplicationMode;
+import net.osmand.util.SunriseSunset;
+
+import org.apache.commons.logging.Log;
+
+import java.util.Date;
+import java.util.List;
+import java.util.TimeZone;
+
/**
* Class to help determine if we want to render day or night map - it uses the
* DayNightMode enumeration for its behavior
diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java
index 989bbaa0f8..47650dc2ec 100644
--- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java
+++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java
@@ -80,6 +80,10 @@ import net.osmand.plus.OsmAndConstants;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
+import net.osmand.plus.helpers.enums.MetricsConstants;
+import net.osmand.plus.helpers.enums.SpeedConstants;
+import net.osmand.plus.settings.backend.CommonPreference;
+import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.Version;
@@ -93,7 +97,6 @@ import net.osmand.plus.dialogs.GpxAppearanceAdapter;
import net.osmand.plus.dialogs.GpxAppearanceAdapter.AppearanceListItem;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.routing.RouteCalculationResult;
-import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.render.RenderingRuleProperty;
import net.osmand.render.RenderingRulesStorage;
import net.osmand.router.RouteStatisticsHelper;
@@ -514,9 +517,9 @@ public class GpxUiHelper {
} else {
final View apprTitleView = View.inflate(new ContextThemeWrapper(activity, themeRes), R.layout.select_gpx_appearance_title, null);
- final OsmandSettings.CommonPreference prefWidth
+ final CommonPreference prefWidth
= app.getSettings().getCustomRenderProperty(CURRENT_TRACK_WIDTH_ATTR);
- final OsmandSettings.CommonPreference prefColor
+ final CommonPreference prefColor
= app.getSettings().getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR);
updateAppearanceTitle(activity, app, trackWidthProp, renderer, apprTitleView, prefWidth.get(), prefColor.get());
@@ -574,7 +577,7 @@ public class GpxUiHelper {
if (SHOW_START_FINISH_ATTR.equals(entry.getKey())) {
app.getSettings().SHOW_START_FINISH_ICONS.set("true".equals(entry.getValue()));
} else {
- final OsmandSettings.CommonPreference pref
+ final CommonPreference pref
= app.getSettings().getCustomRenderProperty(entry.getKey());
pref.set(entry.getValue());
}
@@ -1039,7 +1042,7 @@ public class GpxUiHelper {
private static float setupAxisDistance(OsmandApplication ctx, AxisBase axisBase, float meters) {
OsmandSettings settings = ctx.getSettings();
- OsmandSettings.MetricsConstants mc = settings.METRIC_SYSTEM.get();
+ MetricsConstants mc = settings.METRIC_SYSTEM.get();
float divX;
String format1 = "{0,number,0.#} ";
@@ -1048,10 +1051,10 @@ public class GpxUiHelper {
float granularity = 1f;
int mainUnitStr;
float mainUnitInMeters;
- if (mc == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS) {
+ if (mc == MetricsConstants.KILOMETERS_AND_METERS) {
mainUnitStr = R.string.km;
mainUnitInMeters = METERS_IN_KILOMETER;
- } else if (mc == OsmandSettings.MetricsConstants.NAUTICAL_MILES) {
+ } else if (mc == MetricsConstants.NAUTICAL_MILES) {
mainUnitStr = R.string.nm;
mainUnitInMeters = METERS_IN_ONE_NAUTICALMILE;
} else {
@@ -1065,10 +1068,10 @@ public class GpxUiHelper {
if (meters >= 100 * mainUnitInMeters ||
meters > 9.99f * mainUnitInMeters ||
meters > 0.999f * mainUnitInMeters ||
- mc == OsmandSettings.MetricsConstants.MILES_AND_FEET && meters > 0.249f * mainUnitInMeters ||
- mc == OsmandSettings.MetricsConstants.MILES_AND_METERS && meters > 0.249f * mainUnitInMeters ||
- mc == OsmandSettings.MetricsConstants.MILES_AND_YARDS && meters > 0.249f * mainUnitInMeters ||
- mc == OsmandSettings.MetricsConstants.NAUTICAL_MILES && meters > 0.99f * mainUnitInMeters) {
+ mc == MetricsConstants.MILES_AND_FEET && meters > 0.249f * mainUnitInMeters ||
+ mc == MetricsConstants.MILES_AND_METERS && meters > 0.249f * mainUnitInMeters ||
+ mc == MetricsConstants.MILES_AND_YARDS && meters > 0.249f * mainUnitInMeters ||
+ mc == MetricsConstants.NAUTICAL_MILES && meters > 0.99f * mainUnitInMeters) {
divX = mainUnitInMeters;
if (fmt == null) {
@@ -1078,13 +1081,13 @@ public class GpxUiHelper {
} else {
fmt = null;
granularity = 1f;
- if (mc == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS || mc == OsmandSettings.MetricsConstants.MILES_AND_METERS) {
+ if (mc == MetricsConstants.KILOMETERS_AND_METERS || mc == MetricsConstants.MILES_AND_METERS) {
divX = 1f;
mainUnitStr = R.string.m;
- } else if (mc == OsmandSettings.MetricsConstants.MILES_AND_FEET) {
+ } else if (mc == MetricsConstants.MILES_AND_FEET) {
divX = 1f / FEET_IN_ONE_METER;
mainUnitStr = R.string.foot;
- } else if (mc == OsmandSettings.MetricsConstants.MILES_AND_YARDS) {
+ } else if (mc == MetricsConstants.MILES_AND_YARDS) {
divX = 1f / YARDS_IN_ONE_METER;
mainUnitStr = R.string.yard;
} else {
@@ -1306,8 +1309,8 @@ public class GpxUiHelper {
boolean drawFilled,
boolean calcWithoutGaps) {
OsmandSettings settings = ctx.getSettings();
- OsmandSettings.MetricsConstants mc = settings.METRIC_SYSTEM.get();
- boolean useFeet = (mc == OsmandSettings.MetricsConstants.MILES_AND_FEET) || (mc == OsmandSettings.MetricsConstants.MILES_AND_YARDS);
+ MetricsConstants mc = settings.METRIC_SYSTEM.get();
+ boolean useFeet = (mc == MetricsConstants.MILES_AND_FEET) || (mc == MetricsConstants.MILES_AND_YARDS);
boolean light = settings.isLightContent();
final float convEle = useFeet ? 3.28084f : 1.0f;
@@ -1408,19 +1411,19 @@ public class GpxUiHelper {
divX = setupAxisDistance(ctx, xAxis, calcWithoutGaps ? analysis.totalDistanceWithoutGaps : analysis.totalDistance);
}
- OsmandSettings.SpeedConstants sps = settings.SPEED_SYSTEM.get();
+ SpeedConstants sps = settings.SPEED_SYSTEM.get();
float mulSpeed = Float.NaN;
float divSpeed = Float.NaN;
final String mainUnitY = sps.toShortString(ctx);
- if (sps == OsmandSettings.SpeedConstants.KILOMETERS_PER_HOUR) {
+ if (sps == SpeedConstants.KILOMETERS_PER_HOUR) {
mulSpeed = 3.6f;
- } else if (sps == OsmandSettings.SpeedConstants.MILES_PER_HOUR) {
+ } else if (sps == SpeedConstants.MILES_PER_HOUR) {
mulSpeed = 3.6f * METERS_IN_KILOMETER / METERS_IN_ONE_MILE;
- } else if (sps == OsmandSettings.SpeedConstants.NAUTICALMILES_PER_HOUR) {
+ } else if (sps == SpeedConstants.NAUTICALMILES_PER_HOUR) {
mulSpeed = 3.6f * METERS_IN_KILOMETER / METERS_IN_ONE_NAUTICALMILE;
- } else if (sps == OsmandSettings.SpeedConstants.MINUTES_PER_KILOMETER) {
+ } else if (sps == SpeedConstants.MINUTES_PER_KILOMETER) {
divSpeed = METERS_IN_KILOMETER / 60;
- } else if (sps == OsmandSettings.SpeedConstants.MINUTES_PER_MILE) {
+ } else if (sps == SpeedConstants.MINUTES_PER_MILE) {
divSpeed = METERS_IN_ONE_MILE / 60;
} else {
mulSpeed = 1f;
@@ -1571,8 +1574,8 @@ public class GpxUiHelper {
}
OsmandSettings settings = ctx.getSettings();
boolean light = settings.isLightContent();
- OsmandSettings.MetricsConstants mc = settings.METRIC_SYSTEM.get();
- boolean useFeet = (mc == OsmandSettings.MetricsConstants.MILES_AND_FEET) || (mc == OsmandSettings.MetricsConstants.MILES_AND_YARDS);
+ MetricsConstants mc = settings.METRIC_SYSTEM.get();
+ boolean useFeet = (mc == MetricsConstants.MILES_AND_FEET) || (mc == MetricsConstants.MILES_AND_YARDS);
final float convEle = useFeet ? 3.28084f : 1.0f;
final float totalDistance = calcWithoutGaps ? analysis.totalDistanceWithoutGaps : analysis.totalDistance;
diff --git a/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java b/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java
index b0f34058d3..ddbb06f2be 100644
--- a/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java
+++ b/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java
@@ -20,7 +20,8 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.routing.VoiceRouter.VoiceMessageListener;
import net.osmand.plus.settings.backend.OsmAndAppCustomization.OsmAndAppCustomizationListener;
import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
+import net.osmand.plus.settings.backend.CommonPreference;
+import net.osmand.plus.routing.VoiceRouter.VoiceMessageListener;
import org.apache.commons.logging.Log;
diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java
index b143653754..7f20de3e60 100644
--- a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java
+++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java
@@ -24,6 +24,9 @@ import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.IntermediatePointsDialog;
import net.osmand.plus.base.PointImageDrawable;
+import net.osmand.plus.helpers.enums.DrivingRegion;
+import net.osmand.plus.helpers.enums.MetricsConstants;
+import net.osmand.plus.helpers.enums.SpeedConstants;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.render.RenderingIcons;
import net.osmand.plus.routing.AlarmInfo;
@@ -31,8 +34,6 @@ import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
import net.osmand.plus.routing.RouteCalculationResult;
import net.osmand.plus.routing.VoiceRouter;
import net.osmand.plus.settings.backend.ApplicationMode;
-import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.MetricsConstants;
import net.osmand.util.MapUtils;
import java.util.ArrayList;
@@ -193,7 +194,7 @@ public class WaypointHelper {
return found;
}
- public AlarmInfo getMostImportantAlarm(OsmandSettings.SpeedConstants sc, boolean showCameras) {
+ public AlarmInfo getMostImportantAlarm(SpeedConstants sc, boolean showCameras) {
Location lastProjection = app.getRoutingHelper().getLastProjection();
float mxspeed = route.getCurrentMaxSpeed();
float delta = app.getSettings().SPEED_LIMIT_EXCEED_KMH.get() / 3.6f;
@@ -291,7 +292,7 @@ public class WaypointHelper {
}
public AlarmInfo calculateMostImportantAlarm(RouteDataObject ro, Location loc, MetricsConstants mc,
- OsmandSettings.SpeedConstants sc, boolean showCameras) {
+ SpeedConstants sc, boolean showCameras) {
float mxspeed = ro.getMaximumSpeed(ro.bearingVsRouteDirection(loc));
float delta = app.getSettings().SPEED_LIMIT_EXCEED_KMH.get() / 3.6f;
AlarmInfo speedAlarm = createSpeedAlarm(sc, mxspeed, loc, delta);
@@ -331,7 +332,7 @@ public class WaypointHelper {
return null;
}
- private static AlarmInfo createSpeedAlarm(OsmandSettings.SpeedConstants sc, float mxspeed, Location loc, float delta) {
+ private static AlarmInfo createSpeedAlarm(SpeedConstants sc, float mxspeed, Location loc, float delta) {
AlarmInfo speedAlarm = null;
if (mxspeed != 0 && loc != null && loc.hasSpeed() && mxspeed != RouteDataObject.NONE_MAX_SPEED) {
if (loc.getSpeed() > mxspeed + delta) {
@@ -790,7 +791,7 @@ public class WaypointHelper {
} else if (type == ALARMS) {
//assign alarm list icons manually for now
String typeString = ((AlarmInfo) point).getType().toString();
- OsmandSettings.DrivingRegion region = app.getSettings().DRIVING_REGION.get();
+ DrivingRegion region = app.getSettings().DRIVING_REGION.get();
if (typeString.equals("SPEED_CAMERA")) {
return AppCompatResources.getDrawable(uiCtx, R.drawable.mx_highway_speed_camera);
} else if (typeString.equals("BORDER_CONTROL")) {
diff --git a/OsmAnd/src/net/osmand/plus/helpers/enums/AngularConstants.java b/OsmAnd/src/net/osmand/plus/helpers/enums/AngularConstants.java
new file mode 100644
index 0000000000..4041380fe1
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/helpers/enums/AngularConstants.java
@@ -0,0 +1,27 @@
+package net.osmand.plus.helpers.enums;
+
+import android.content.Context;
+
+import net.osmand.plus.R;
+
+public enum AngularConstants {
+ DEGREES(R.string.shared_string_degrees, "°"),
+ DEGREES360(R.string.shared_string_degrees, "°"),
+ MILLIRADS(R.string.shared_string_milliradians, "mil");
+
+ private final int key;
+ private final String unit;
+
+ AngularConstants(int key, String unit) {
+ this.key = key;
+ this.unit = unit;
+ }
+
+ public String toHumanString(Context ctx) {
+ return ctx.getString(key);
+ }
+
+ public String getUnitSymbol() {
+ return unit;
+ }
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/helpers/enums/AutoZoomMap.java b/OsmAnd/src/net/osmand/plus/helpers/enums/AutoZoomMap.java
new file mode 100644
index 0000000000..ad09424924
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/helpers/enums/AutoZoomMap.java
@@ -0,0 +1,19 @@
+package net.osmand.plus.helpers.enums;
+
+import net.osmand.plus.R;
+
+public enum AutoZoomMap {
+ FARTHEST(R.string.auto_zoom_farthest, 1f, 15.5f),
+ FAR(R.string.auto_zoom_far, 1.4f, 17f),
+ CLOSE(R.string.auto_zoom_close, 2f, 19f);
+
+ public final float coefficient;
+ public final int name;
+ public final float maxZoom;
+
+ AutoZoomMap(int name, float coefficient, float maxZoom) {
+ this.name = name;
+ this.coefficient = coefficient;
+ this.maxZoom = maxZoom;
+ }
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/helpers/enums/DayNightMode.java b/OsmAnd/src/net/osmand/plus/helpers/enums/DayNightMode.java
new file mode 100644
index 0000000000..77f0eb8876
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/helpers/enums/DayNightMode.java
@@ -0,0 +1,62 @@
+package net.osmand.plus.helpers.enums;
+
+import android.content.Context;
+import android.hardware.Sensor;
+import android.hardware.SensorManager;
+
+import androidx.annotation.DrawableRes;
+import androidx.annotation.StringRes;
+
+import net.osmand.plus.R;
+
+public enum DayNightMode {
+ AUTO(R.string.daynight_mode_auto, R.drawable.ic_action_map_sunset),
+ DAY(R.string.daynight_mode_day, R.drawable.ic_action_map_day),
+ NIGHT(R.string.daynight_mode_night, R.drawable.ic_action_map_night),
+ SENSOR(R.string.daynight_mode_sensor, R.drawable.ic_action_map_light_sensor);
+
+ private final int key;
+ @DrawableRes
+ private final int drawableRes;
+
+ DayNightMode(@StringRes int key, @DrawableRes int drawableRes) {
+ this.key = key;
+ this.drawableRes = drawableRes;
+ }
+
+ public String toHumanString(Context ctx) {
+ return ctx.getString(key);
+ }
+
+ @DrawableRes
+ public int getIconRes() {
+ return drawableRes;
+ }
+
+ public boolean isSensor() {
+ return this == SENSOR;
+ }
+
+ public boolean isAuto() {
+ return this == AUTO;
+ }
+
+ public boolean isDay() {
+ return this == DAY;
+ }
+
+ public boolean isNight() {
+ return this == NIGHT;
+ }
+
+ public static DayNightMode[] possibleValues(Context context) {
+ SensorManager mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
+ Sensor mLight = mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
+ boolean isLightSensorEnabled = mLight != null;
+ if (isLightSensorEnabled) {
+ return DayNightMode.values();
+ } else {
+ return new DayNightMode[]{AUTO, DAY, NIGHT};
+ }
+ }
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/helpers/enums/DrivingRegion.java b/OsmAnd/src/net/osmand/plus/helpers/enums/DrivingRegion.java
new file mode 100644
index 0000000000..60902c46b5
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/helpers/enums/DrivingRegion.java
@@ -0,0 +1,62 @@
+package net.osmand.plus.helpers.enums;
+
+import android.content.Context;
+
+import net.osmand.plus.R;
+
+import java.util.Locale;
+
+/**
+ * Class represents specific for driving region
+ * Signs, leftHandDriving
+ */
+public enum DrivingRegion {
+
+ EUROPE_ASIA(R.string.driving_region_europe_asia, MetricsConstants.KILOMETERS_AND_METERS, false),
+ US(R.string.driving_region_us, MetricsConstants.MILES_AND_FEET, false),
+ CANADA(R.string.driving_region_canada, MetricsConstants.KILOMETERS_AND_METERS, false),
+ UK_AND_OTHERS(R.string.driving_region_uk, MetricsConstants.MILES_AND_METERS, true),
+ JAPAN(R.string.driving_region_japan, MetricsConstants.KILOMETERS_AND_METERS, true),
+ AUSTRALIA(R.string.driving_region_australia, MetricsConstants.KILOMETERS_AND_METERS, true);
+
+ public final boolean leftHandDriving;
+ public final MetricsConstants defMetrics;
+ public final int name;
+
+ DrivingRegion(int name, MetricsConstants def, boolean leftHandDriving) {
+ this.name = name;
+ defMetrics = def;
+ this.leftHandDriving = leftHandDriving;
+ }
+
+ public boolean isAmericanTypeSigns() {
+ return this == DrivingRegion.AUSTRALIA ||
+ this == DrivingRegion.US ||
+ this == DrivingRegion.CANADA;
+ }
+
+ public String getDescription(Context ctx) {
+ return ctx.getString(leftHandDriving ? R.string.left_side_navigation : R.string.right_side_navigation) +
+ ", " +
+ defMetrics.toHumanString(ctx).toLowerCase();
+ }
+
+ public static DrivingRegion getDrivingRegionByLocale() {
+ Locale df = Locale.getDefault();
+ if (df == null) {
+ return DrivingRegion.EUROPE_ASIA;
+ }
+ if (df.getCountry().equalsIgnoreCase(Locale.US.getCountry())) {
+ return DrivingRegion.US;
+ } else if (df.getCountry().equalsIgnoreCase(Locale.CANADA.getCountry())) {
+ return DrivingRegion.CANADA;
+ } else if (df.getCountry().equalsIgnoreCase(Locale.JAPAN.getCountry())) {
+ return DrivingRegion.JAPAN;
+ } else if (df.getCountry().equalsIgnoreCase("au")) {
+ return DrivingRegion.AUSTRALIA;
+ } else if (df.getCountry().equalsIgnoreCase(Locale.UK.getCountry())) {
+ return DrivingRegion.UK_AND_OTHERS;
+ }
+ return DrivingRegion.EUROPE_ASIA;
+ }
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/helpers/enums/MetricsConstants.java b/OsmAnd/src/net/osmand/plus/helpers/enums/MetricsConstants.java
new file mode 100644
index 0000000000..20f3804a6a
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/helpers/enums/MetricsConstants.java
@@ -0,0 +1,29 @@
+package net.osmand.plus.helpers.enums;
+
+import android.content.Context;
+
+import net.osmand.plus.R;
+
+public enum MetricsConstants {
+ KILOMETERS_AND_METERS(R.string.si_km_m, "km-m"),
+ MILES_AND_FEET(R.string.si_mi_feet, "mi-f"),
+ MILES_AND_METERS(R.string.si_mi_meters, "mi-m"),
+ MILES_AND_YARDS(R.string.si_mi_yard, "mi-y"),
+ NAUTICAL_MILES(R.string.si_nm, "nm");
+
+ private final int key;
+ private final String ttsString;
+
+ MetricsConstants(int key, String ttsString) {
+ this.key = key;
+ this.ttsString = ttsString;
+ }
+
+ public String toHumanString(Context ctx) {
+ return ctx.getString(key);
+ }
+
+ public String toTTSString() {
+ return ttsString;
+ }
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/helpers/enums/SpeedConstants.java b/OsmAnd/src/net/osmand/plus/helpers/enums/SpeedConstants.java
new file mode 100644
index 0000000000..1a4c512b8c
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/helpers/enums/SpeedConstants.java
@@ -0,0 +1,32 @@
+package net.osmand.plus.helpers.enums;
+
+import android.content.Context;
+
+import net.osmand.plus.R;
+
+public enum SpeedConstants {
+ KILOMETERS_PER_HOUR(R.string.km_h, R.string.si_kmh, false),
+ MILES_PER_HOUR(R.string.mile_per_hour, R.string.si_mph, true),
+ METERS_PER_SECOND(R.string.m_s, R.string.si_m_s, false),
+ MINUTES_PER_MILE(R.string.min_mile, R.string.si_min_m, true),
+ MINUTES_PER_KILOMETER(R.string.min_km, R.string.si_min_km, false),
+ NAUTICALMILES_PER_HOUR(R.string.nm_h, R.string.si_nm_h, true);
+
+ public final int key;
+ public final int descr;
+ public final boolean imperial;
+
+ SpeedConstants(int key, int descr, boolean imperial) {
+ this.key = key;
+ this.descr = descr;
+ this.imperial = imperial;
+ }
+
+ public String toHumanString(Context ctx) {
+ return ctx.getString(descr);
+ }
+
+ public String toShortString(Context ctx) {
+ return ctx.getString(key);
+ }
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/helpers/enums/TracksSortByMode.java b/OsmAnd/src/net/osmand/plus/helpers/enums/TracksSortByMode.java
new file mode 100644
index 0000000000..6b4177c701
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/helpers/enums/TracksSortByMode.java
@@ -0,0 +1,38 @@
+package net.osmand.plus.helpers.enums;
+
+import androidx.annotation.DrawableRes;
+import androidx.annotation.StringRes;
+
+import net.osmand.plus.R;
+
+public enum TracksSortByMode {
+ BY_DATE(R.string.sort_last_modified, R.drawable.ic_action_time_start),
+ BY_NAME_ASCENDING(R.string.sort_name_ascending, R.drawable.ic_action_sort_by_name_ascending),
+ BY_NAME_DESCENDING(R.string.sort_name_descending, R.drawable.ic_action_sort_by_name_descending);
+
+ private final int iconId;
+ private final int nameId;
+
+ TracksSortByMode(int nameId, int iconId) {
+ this.nameId = nameId;
+ this.iconId = iconId;
+ }
+
+ public boolean isByName() {
+ return this == BY_NAME_ASCENDING || this == BY_NAME_DESCENDING;
+ }
+
+ public boolean isByDate() {
+ return this == BY_DATE;
+ }
+
+ @StringRes
+ public int getNameId() {
+ return nameId;
+ }
+
+ @DrawableRes
+ public int getIconId() {
+ return iconId;
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/inapp/InAppPurchaseHelper.java b/OsmAnd/src/net/osmand/plus/inapp/InAppPurchaseHelper.java
index 1364d7b154..543c3a819d 100644
--- a/OsmAnd/src/net/osmand/plus/inapp/InAppPurchaseHelper.java
+++ b/OsmAnd/src/net/osmand/plus/inapp/InAppPurchaseHelper.java
@@ -17,6 +17,8 @@ import net.osmand.AndroidNetworkUtils.OnRequestsResultListener;
import net.osmand.AndroidNetworkUtils.RequestResponse;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.settings.backend.OsmandSettings;
+import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.inapp.InAppPurchases.InAppPurchase;
diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java
index d9824cce8f..c503162910 100644
--- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java
+++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java
@@ -35,6 +35,8 @@ import androidx.fragment.app.FragmentManager;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.settings.backend.CommonPreference;
+import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.activities.LocalIndexHelper;
@@ -49,7 +51,6 @@ import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseListener;
import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseTaskType;
import net.osmand.plus.inapp.InAppPurchases.InAppSubscription;
import net.osmand.plus.resources.IncrementalChangesManager;
-import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.util.Algorithms;
import java.io.File;
@@ -312,7 +313,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
}
public void add(LocalIndexInfo info) {
- OsmandSettings.CommonPreference preference = preferenceLiveUpdatesOn(
+ CommonPreference preference = preferenceLiveUpdatesOn(
info.getFileName(), app.getSettings());
if (preference.get()) {
dataShouldUpdate.add(info);
@@ -324,8 +325,8 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
public void notifyLiveUpdatesChanged() {
Set changedSet = new HashSet<>();
for (LocalIndexInfo localIndexInfo : dataShouldUpdate) {
- OsmandSettings.CommonPreference preference =
- preferenceLiveUpdatesOn(localIndexInfo.getFileName(), app.getSettings());
+ CommonPreference preference =
+ preferenceLiveUpdatesOn(localIndexInfo.getFileName(), getSettings());
if (!preference.get()) {
changedSet.add(localIndexInfo);
}
@@ -334,8 +335,8 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
dataShouldNotUpdate.addAll(changedSet);
changedSet.clear();
for (LocalIndexInfo localIndexInfo : dataShouldNotUpdate) {
- OsmandSettings.CommonPreference preference =
- preferenceLiveUpdatesOn(localIndexInfo.getFileName(), app.getSettings());
+ CommonPreference preference =
+ preferenceLiveUpdatesOn(localIndexInfo.getFileName(), getSettings());
if (preference.get()) {
changedSet.add(localIndexInfo);
}
@@ -473,10 +474,10 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
String fileName = li.getFileName();
PendingIntent alarmIntent = getPendingIntent(ctx, fileName);
if (enable) {
- final OsmandSettings.CommonPreference updateFrequencyPreference =
- preferenceUpdateFrequency(fileName, app.getSettings());
- final OsmandSettings.CommonPreference timeOfDayPreference =
- preferenceTimeOfDayToUpdate(fileName, app.getSettings());
+ final CommonPreference updateFrequencyPreference =
+ preferenceUpdateFrequency(fileName, getSettings());
+ final CommonPreference timeOfDayPreference =
+ preferenceTimeOfDayToUpdate(fileName, getSettings());
UpdateFrequency updateFrequency = UpdateFrequency.values()[updateFrequencyPreference.get()];
TimeOfDay timeOfDayToUpdate = TimeOfDay.values()[timeOfDayPreference.get()];
setAlarmForPendingIntent(alarmIntent, alarmMgr, updateFrequency, timeOfDayToUpdate);
@@ -570,7 +571,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
public void bindLocalIndexInfo(@NonNull final String item, boolean isLastChild) {
OsmandApplication context = fragment.getMyActivity().getMyApplication();
- final OsmandSettings.CommonPreference shouldUpdatePreference =
+ final CommonPreference shouldUpdatePreference =
preferenceLiveUpdatesOn(item, fragment.getSettings());
IncrementalChangesManager changesManager = context.getResourceManager().getChangesManager();
@@ -600,7 +601,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
Algorithms.getFileNameWithoutExtension(new File(item));
final long timestamp = changesManager.getTimestamp(fileNameWithoutExtension);
final long lastCheck = preferenceLastCheck(item, fragment.getSettings()).get();
- OsmandSettings.CommonPreference liveUpdateOn = preferenceLiveUpdatesOn(item, fragment.getSettings());
+ CommonPreference liveUpdateOn = preferenceLiveUpdatesOn(item, fragment.getSettings());
if(liveUpdateOn.get() && lastCheck != DEFAULT_LAST_CHECK) {
String lastCheckString = formatDateTime(fragment.getActivity(), lastCheck );
descriptionTextView.setText(context.getString(R.string.last_update, lastCheckString));
diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesHelper.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesHelper.java
index ec4afd6861..ce9d3d9c5b 100644
--- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesHelper.java
+++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesHelper.java
@@ -8,6 +8,7 @@ import android.os.AsyncTask;
import androidx.annotation.NonNull;
+import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.OsmandActionBarActivity;
@@ -32,7 +33,7 @@ public class LiveUpdatesHelper {
public static final int DEFAULT_LAST_CHECK = -1;
- private static OsmandSettings.CommonPreference checkPref(OsmandSettings.CommonPreference p) {
+ private static CommonPreference checkPref(CommonPreference p) {
if (p.isSet()) {
T vl = p.get();
p = p.makeGlobal();
@@ -44,37 +45,37 @@ public class LiveUpdatesHelper {
}
return p;
}
- public static OsmandSettings.CommonPreference preferenceForLocalIndex(
+ public static CommonPreference preferenceForLocalIndex(
String fileName, OsmandSettings settings) {
final String settingId = fileName + LIVE_UPDATES_ON_POSTFIX;
return checkPref(settings.registerBooleanPreference(settingId, false));
}
- public static OsmandSettings.CommonPreference preferenceLiveUpdatesOn(
+ public static CommonPreference preferenceLiveUpdatesOn(
String fileName, OsmandSettings settings) {
final String settingId = fileName + LIVE_UPDATES_ON_POSTFIX;
return checkPref(settings.registerBooleanPreference(settingId, false));
}
- public static OsmandSettings.CommonPreference preferenceDownloadViaWiFi(
+ public static CommonPreference preferenceDownloadViaWiFi(
String fileName, OsmandSettings settings) {
final String settingId = fileName + DOWNLOAD_VIA_WIFI_POSTFIX;
return checkPref(settings.registerBooleanPreference(settingId, false));
}
- public static OsmandSettings.CommonPreference preferenceUpdateFrequency(
+ public static CommonPreference preferenceUpdateFrequency(
String fileName, OsmandSettings settings) {
final String settingId = fileName + UPDATE_TIMES_POSTFIX;
return checkPref(settings.registerIntPreference(settingId, UpdateFrequency.HOURLY.ordinal()));
}
- public static OsmandSettings.CommonPreference preferenceTimeOfDayToUpdate(
+ public static CommonPreference preferenceTimeOfDayToUpdate(
String fileName, OsmandSettings settings) {
final String settingId = fileName + TIME_OF_DAY_TO_UPDATE_POSTFIX;
return checkPref(settings.registerIntPreference(settingId, TimeOfDay.NIGHT.ordinal()));
}
- public static OsmandSettings.CommonPreference preferenceLastCheck(
+ public static CommonPreference preferenceLastCheck(
String fileName, OsmandSettings settings) {
final String settingId = fileName + LAST_UPDATE_ATTEMPT_ON_POSTFIX;
return checkPref(settings.registerLongPreference(settingId, DEFAULT_LAST_CHECK));
diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesSettingsDialogFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesSettingsDialogFragment.java
index d3f8f2ed4e..d27e733d7a 100644
--- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesSettingsDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesSettingsDialogFragment.java
@@ -23,6 +23,7 @@ import androidx.fragment.app.DialogFragment;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.download.AbstractDownloadActivity;
@@ -85,7 +86,7 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment {
final long lastCheck = preferenceLastCheck(fileName, getSettings()).get();
- OsmandSettings.CommonPreference preference = preferenceLiveUpdatesOn(fileName,
+ CommonPreference preference = preferenceLiveUpdatesOn(fileName,
getSettings());
if (preference.get() && lastCheck != DEFAULT_LAST_CHECK) {
String lastCheckString = formatDateTime(getActivity(), lastCheck);
@@ -94,13 +95,13 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment {
lastUpdateTextView.setVisibility(View.GONE);
}
- final OsmandSettings.CommonPreference liveUpdatePreference =
+ final CommonPreference liveUpdatePreference =
preferenceForLocalIndex(fileName, getSettings());
- final OsmandSettings.CommonPreference downloadViaWiFiPreference =
+ final CommonPreference downloadViaWiFiPreference =
preferenceDownloadViaWiFi(fileName, getSettings());
- final OsmandSettings.CommonPreference updateFrequencyPreference =
+ final CommonPreference updateFrequencyPreference =
preferenceUpdateFrequency(fileName, getSettings());
- final OsmandSettings.CommonPreference timeOfDayPreference =
+ final CommonPreference timeOfDayPreference =
preferenceTimeOfDayToUpdate(fileName, getSettings());
downloadOverWiFiCheckBox.setChecked(!liveUpdatePreference.get() || downloadViaWiFiPreference.get());
diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java b/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java
index c95ac1a2a6..4cebb245f9 100644
--- a/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java
+++ b/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java
@@ -9,6 +9,7 @@ import androidx.annotation.NonNull;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.download.AbstractDownloadActivity;
@@ -50,7 +51,7 @@ public class PerformLiveUpdateAsyncTask
activity.setSupportProgressBarIndeterminateVisibility(true);
}
final OsmandApplication myApplication = getMyApplication();
- OsmandSettings.CommonPreference lastCheckPreference =
+ CommonPreference lastCheckPreference =
LiveUpdatesHelper.preferenceLastCheck(localIndexFileName, myApplication.getSettings());
lastCheckPreference.set(System.currentTimeMillis());
}
@@ -148,7 +149,7 @@ public class PerformLiveUpdateAsyncTask
public static void tryRescheduleDownload(@NonNull Context context,
@NonNull OsmandSettings settings,
@NonNull String localIndexFileName) {
- final OsmandSettings.CommonPreference updateFrequencyPreference =
+ final CommonPreference updateFrequencyPreference =
preferenceUpdateFrequency(localIndexFileName, settings);
final Integer frequencyOrdinal = updateFrequencyPreference.get();
if (LiveUpdatesHelper.UpdateFrequency.values()[frequencyOrdinal]
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/CollapsableView.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/CollapsableView.java
index 5daa14ba27..394547f570 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/CollapsableView.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/CollapsableView.java
@@ -4,7 +4,7 @@ import android.view.View;
import androidx.annotation.NonNull;
-import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference;
+import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.mapcontextmenu.MenuBuilder.CollapseExpandListener;
public class CollapsableView {
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
index 5f88a13607..7977a9ddc6 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
@@ -58,6 +58,8 @@ import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.LockableScrollView;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.settings.backend.MainContextMenuItemsSettings;
+import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.UiUtilities.DialogButtonType;
@@ -74,7 +76,6 @@ import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController;
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController;
import net.osmand.plus.routepreparationmenu.ChooseRouteFragment;
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
-import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.OsmandMapTileView;
@@ -642,7 +643,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
// Action buttons
ContextMenuAdapter adapter = menu.getActionsContextMenuAdapter(false);
List items = adapter.getVisibleItems();
- List mainIds = ((OsmandSettings.MainContextMenuItemsSettings) mapActivity.getMyApplication()
+ List mainIds = ((MainContextMenuItemsSettings) mapActivity.getMyApplication()
.getSettings().CONTEXT_MENU_ACTIONS_ITEMS.get()).getMainIds();
ContextMenuAdapter mainAdapter = new ContextMenuAdapter(requireMyApplication());
ContextMenuAdapter additionalAdapter = new ContextMenuAdapter(requireMyApplication());
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java
index 5a4618ca4f..f0d33b68dd 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java
@@ -36,8 +36,7 @@ import net.osmand.plus.mapcontextmenu.CollapsableView;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.osmedit.OsmEditingPlugin;
import net.osmand.plus.poi.PoiUIFilter;
-import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.MetricsConstants;
+import net.osmand.plus.helpers.enums.MetricsConstants;
import net.osmand.plus.views.layers.POIMapLayer;
import net.osmand.plus.widgets.TextViewEx;
import net.osmand.plus.widgets.tools.ClickableSpanTouchListener;
@@ -70,7 +69,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
private static final String WIKI_LINK = ".wikipedia.org/w";
public final static Log LOG = PlatformUtil.getLog(AmenityMenuBuilder.class);
private final static DecimalFormat DF = new DecimalFormat("#.##");
- private OsmandSettings.MetricsConstants metricSystem;
+ private MetricsConstants metricSystem;
private final Amenity amenity;
@@ -714,10 +713,10 @@ public class AmenityMenuBuilder extends MenuBuilder {
case "seamark_height":
if (Algorithms.isFloat(value)) {
double valueAsDouble = Double.valueOf(value);
- if (metricSystem == OsmandSettings.MetricsConstants.MILES_AND_FEET) {
+ if (metricSystem == MetricsConstants.MILES_AND_FEET) {
formattedValue = String.valueOf(DF.format(valueAsDouble * OsmAndFormatter.FEET_IN_ONE_METER))
+ " " + mapActivity.getResources().getString(R.string.foot);
- } else if (metricSystem == OsmandSettings.MetricsConstants.MILES_AND_YARDS) {
+ } else if (metricSystem == MetricsConstants.MILES_AND_YARDS) {
formattedValue = String.valueOf(DF.format(valueAsDouble * OsmAndFormatter.YARDS_IN_ONE_METER))
+ " " + mapActivity.getResources().getString(R.string.yard);
} else {
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java
index 3cdf3398a6..b8f5789d47 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapMarkerMenuController.java
@@ -13,7 +13,7 @@ import androidx.core.content.ContextCompat;
import net.osmand.data.PointDescription;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker;
-import net.osmand.plus.settings.backend.OsmandSettings;
+import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.MapMarkerDialogHelper;
@@ -56,7 +56,7 @@ public class MapMarkerMenuController extends MenuController {
public void buttonPressed() {
MapActivity activity = getMapActivity();
if (activity != null) {
- OsmandSettings.OsmandPreference indication
+ OsmandPreference indication
= activity.getMyApplication().getSettings().MARKERS_DISTANCE_INDICATION_ENABLED;
if (!indication.get()) {
indication.set(true);
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java
index cf769223f1..f3bf7cfb7a 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java
@@ -6,6 +6,7 @@ import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
+import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
@@ -83,7 +84,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
@Override
public void onClick(View v) {
if (listener != null) {
- OsmandSettings.CommonPreference pref = settings.COORDS_INPUT_TWO_DIGITS_LONGTITUDE;
+ CommonPreference pref = settings.COORDS_INPUT_TWO_DIGITS_LONGTITUDE;
pref.set(!pref.get());
listener.onInputSettingsChanged();
}
@@ -108,7 +109,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia
@Override
public void onClick(View v) {
if (listener != null) {
- OsmandSettings.CommonPreference pref = settings.COORDS_INPUT_USE_RIGHT_SIDE;
+ CommonPreference pref = settings.COORDS_INPUT_USE_RIGHT_SIDE;
pref.set(!pref.get());
listener.onHandChanged();
}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java
index a68bd4c714..aef217f347 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java
@@ -67,6 +67,7 @@ import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.Version;
@@ -1023,7 +1024,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
}
private void changeOsmandKeyboardSetting() {
- OsmandSettings.OsmandPreference pref = getMyApplication().getSettings().COORDS_INPUT_USE_OSMAND_KEYBOARD;
+ OsmandPreference pref = getMyApplication().getSettings().COORDS_INPUT_USE_OSMAND_KEYBOARD;
pref.set(!pref.get());
}
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java
index 485f294c94..d624ec7947 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java
@@ -32,8 +32,7 @@ import com.github.ksoichiro.android.observablescrollview.ScrollState;
import net.osmand.AndroidUtils;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.MapMarkersMode;
-import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference;
+import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersMode.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersMode.java
new file mode 100644
index 0000000000..a9cf23ea75
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersMode.java
@@ -0,0 +1,37 @@
+package net.osmand.plus.mapmarkers;
+
+import android.content.Context;
+
+import net.osmand.plus.R;
+
+public enum MapMarkersMode {
+ TOOLBAR(R.string.shared_string_topbar),
+ WIDGETS(R.string.shared_string_widgets),
+ NONE(R.string.shared_string_none);
+
+ private final int key;
+
+ MapMarkersMode(int key) {
+ this.key = key;
+ }
+
+ public String toHumanString(Context ctx) {
+ return ctx.getString(key);
+ }
+
+ public boolean isToolbar() {
+ return this == TOOLBAR;
+ }
+
+ public boolean isWidgets() {
+ return this == WIDGETS;
+ }
+
+ public boolean isNone() {
+ return this == NONE;
+ }
+
+ public static MapMarkersMode[] possibleValues(Context context) {
+ return new MapMarkersMode[]{TOOLBAR, WIDGETS, NONE};
+ }
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/OptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/OptionsBottomSheetDialogFragment.java
index 487ee2073c..4627ed764b 100644
--- a/OsmAnd/src/net/osmand/plus/mapmarkers/OptionsBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapmarkers/OptionsBottomSheetDialogFragment.java
@@ -14,7 +14,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import net.osmand.AndroidUtils;
-import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.base.BottomSheetDialogFragment;
import net.osmand.plus.helpers.AndroidUiHelper;
@@ -63,7 +62,7 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
}
((ImageView) mainView.findViewById(R.id.sort_by_icon)).setImageDrawable(getContentIcon(R.drawable.ic_sort_waypoint_dark));
- OsmandSettings.MapMarkersMode mode = getMyApplication().getSettings().MAP_MARKERS_MODE.get();
+ MapMarkersMode mode = getMyApplication().getSettings().MAP_MARKERS_MODE.get();
int displayedCount = getMyApplication().getSettings().DISPLAYED_MARKERS_WIDGETS_COUNT.get();
ImageView showDirectionIcon = (ImageView) mainView.findViewById(R.id.show_direction_icon);
int imageResId = 0;
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java
index 83ef171fda..0cb1ae2f33 100644
--- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java
+++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java
@@ -1,6 +1,5 @@
package net.osmand.plus.measurementtool;
-import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
@@ -61,6 +60,7 @@ import net.osmand.plus.measurementtool.OptionsBottomSheetDialogFragment.OptionsF
import net.osmand.plus.measurementtool.RouteBetweenPointsBottomSheetDialogFragment.RouteBetweenPointsDialogMode;
import net.osmand.plus.measurementtool.RouteBetweenPointsBottomSheetDialogFragment.RouteBetweenPointsDialogType;
import net.osmand.plus.measurementtool.RouteBetweenPointsBottomSheetDialogFragment.RouteBetweenPointsFragmentListener;
+import net.osmand.plus.measurementtool.SaveGpxRouteAsyncTask.SaveGpxRouteListener;
import net.osmand.plus.measurementtool.SelectedPointBottomSheetDialogFragment.SelectedPointFragmentListener;
import net.osmand.plus.measurementtool.adapter.MeasurementToolAdapter;
import net.osmand.plus.measurementtool.adapter.MeasurementToolAdapter.MeasurementAdapterListener;
@@ -83,6 +83,8 @@ import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarView;
import net.osmand.router.RoutePlannerFrontEnd.GpxRouteApproximation;
import java.io.File;
+import java.lang.ref.WeakReference;
+import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@@ -145,9 +147,6 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
private MeasurementEditingContext editingCtx = new MeasurementEditingContext();
private LatLon initialPoint;
- private OsmandApplication app;
- private MapActivity mapActivity;
- private MeasurementToolLayer measurementToolLayer;
enum SaveType {
ROUTE_POINT,
@@ -160,6 +159,10 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
SHOW_IS_SAVED_FRAGMENT
}
+ protected MeasurementEditingContext getEditingCtx() {
+ return editingCtx;
+ }
+
private void setEditingCtx(MeasurementEditingContext editingCtx) {
this.editingCtx = editingCtx;
}
@@ -168,7 +171,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
this.initialPoint = initialPoint;
}
- void setMode(int mode, boolean on) {
+ private void setMode(int mode, boolean on) {
int modes = this.modes;
if (on) {
modes |= mode;
@@ -207,7 +210,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
- @Nullable Bundle savedInstanceState) {
+ @Nullable Bundle savedInstanceState) {
final MapActivity mapActivity = (MapActivity) getActivity();
if (mapActivity == null) {
return null;
@@ -1059,7 +1062,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
}
@Nullable
- GpxData setupGpxData(@Nullable GPXFile gpxFile) {
+ private GpxData setupGpxData(@Nullable GPXFile gpxFile) {
GpxData gpxData = null;
if (gpxFile != null) {
QuadRect rect = gpxFile.getRect();
@@ -1524,25 +1527,118 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
return displayedName;
}
- private void saveNewGpx(File dir, String fileName, boolean showOnMap, SaveType saveType, FinalSaveAction finalSaveAction) {
- saveGpx(dir, fileName, showOnMap, null, null, saveType, finalSaveAction);
+ private void saveNewGpx(@NonNull File dir, @NonNull String fileName, boolean showOnMap, SaveType saveType, FinalSaveAction finalSaveAction) {
+ saveGpx(new File(dir, fileName), null, null, saveType, finalSaveAction, showOnMap);
}
- private void saveExistingGpx(GPXFile gpx, boolean showOnMap, ActionType actionType, SaveType saveType,
- FinalSaveAction finalSaveAction) {
- saveGpx(null, null, showOnMap, gpx, actionType, saveType, finalSaveAction);
+ private void saveExistingGpx(@NonNull GPXFile gpx, boolean showOnMap, ActionType actionType,
+ SaveType saveType, FinalSaveAction finalSaveAction) {
+ saveGpx(new File(gpx.path), gpx, actionType, saveType, finalSaveAction, showOnMap);
}
- @SuppressLint("StaticFieldLeak")
- private void saveGpx(final File dir,
- final String fileName,
- final boolean showOnMap,
- final GPXFile gpxFile,
- final ActionType actionType,
- final SaveType saveType,
- final FinalSaveAction finalSaveAction) {
+ private void saveGpx(@NonNull final File outFile, @Nullable GPXFile gpxFile, final ActionType actionType,
+ SaveType saveType, final FinalSaveAction finalSaveAction, final boolean showOnMap) {
+ SaveGpxRouteListener saveGpxRouteListener = new SaveGpxRouteListener() {
+ @Override
+ public void gpxSavingFinished(Exception warning, GPXFile savedGpxFile, File backupFile) {
+ onGpxSaved(warning, savedGpxFile, outFile, backupFile, actionType, finalSaveAction, showOnMap);
+ }
+ };
- new SaveGPX(this, gpxFile, dir, fileName, saveType, showOnMap, actionType, finalSaveAction, app, mapActivity, measurementToolLayer, nightMode).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ SaveGpxRouteAsyncTask saveTask = new SaveGpxRouteAsyncTask(this, outFile, gpxFile, actionType, saveType, showOnMap, saveGpxRouteListener);
+ saveTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ }
+
+ private void onGpxSaved(Exception warning, GPXFile savedGpxFile, final File outFile, final File backupFile,
+ final ActionType actionType, FinalSaveAction finalSaveAction, final boolean showOnMap) {
+ MapActivity mapActivity = getMapActivity();
+ if (mapActivity == null) {
+ return;
+ }
+ mapActivity.refreshMap();
+ if (warning == null) {
+ if (editingCtx.isNewData() && savedGpxFile != null) {
+ QuadRect rect = savedGpxFile.getRect();
+ TrkSegment segment = savedGpxFile.getNonEmptyTrkSegment();
+ GpxData gpxData = new GpxData(savedGpxFile, rect, ActionType.EDIT_SEGMENT, segment);
+ editingCtx.setGpxData(gpxData);
+ updateToolbar();
+ }
+ if (isInEditMode()) {
+ editingCtx.setChangesSaved();
+ dismiss(mapActivity);
+ } else {
+ switch (finalSaveAction) {
+ case SHOW_SNACK_BAR_AND_CLOSE:
+ final WeakReference mapActivityRef = new WeakReference<>(mapActivity);
+ snackbar = Snackbar.make(mapActivity.getLayout(),
+ MessageFormat.format(getString(R.string.gpx_saved_sucessfully), outFile.getName()),
+ Snackbar.LENGTH_LONG)
+ .setAction(R.string.shared_string_undo, new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ MapActivity mapActivity = mapActivityRef.get();
+ if (mapActivity != null) {
+ OsmandApplication app = mapActivity.getMyApplication();
+ FileUtils.removeGpxFile(app, outFile);
+ if (backupFile != null) {
+ FileUtils.renameGpxFile(app, backupFile, outFile);
+ GPXFile gpx = GPXUtilities.loadGPXFile(outFile);
+ setupGpxData(gpx);
+ if (showOnMap) {
+ showGpxOnMap(app, gpx, actionType, false);
+ }
+ } else {
+ setupGpxData(null);
+ }
+ setMode(UNDO_MODE, true);
+ MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(),
+ editingCtx, modes);
+ }
+ }
+ })
+ .addCallback(new Snackbar.Callback() {
+ @Override
+ public void onDismissed(Snackbar transientBottomBar, int event) {
+ if (event != DISMISS_EVENT_ACTION) {
+ editingCtx.setChangesSaved();
+ }
+ super.onDismissed(transientBottomBar, event);
+ }
+ });
+ snackbar.getView().findViewById(com.google.android.material.R.id.snackbar_action)
+ .setAllCaps(false);
+ UiUtilities.setupSnackbar(snackbar, nightMode);
+ snackbar.show();
+ dismiss(mapActivity, false);
+ break;
+ case SHOW_IS_SAVED_FRAGMENT:
+ editingCtx.setChangesSaved();
+ SavedTrackBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(),
+ outFile.getAbsolutePath());
+ dismiss(mapActivity);
+ break;
+ case SHOW_TOAST:
+ editingCtx.setChangesSaved();
+ if (savedGpxFile != null && !savedGpxFile.showCurrentTrack) {
+ Toast.makeText(mapActivity,
+ MessageFormat.format(getString(R.string.gpx_saved_sucessfully), outFile.getAbsolutePath()),
+ Toast.LENGTH_LONG).show();
+ }
+ }
+ }
+ } else {
+ Toast.makeText(mapActivity, warning.getMessage(), Toast.LENGTH_LONG).show();
+ }
+ }
+
+ protected static void showGpxOnMap(OsmandApplication app, GPXFile gpx, ActionType actionType, boolean isNewGpx) {
+ SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpx, true, false);
+ if (sf != null && !isNewGpx) {
+ if (actionType == ActionType.ADD_SEGMENT || actionType == ActionType.EDIT_SEGMENT) {
+ sf.processPoints(app);
+ }
+ }
}
private void updateUndoRedoButton(boolean enable, View view) {
@@ -1575,7 +1671,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
updateToolbar();
}
- void updateToolbar() {
+ private void updateToolbar() {
MapActivity mapActivity = getMapActivity();
if (mapActivity == null) {
return;
@@ -1706,7 +1802,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
}
}
- void dismiss(@NonNull MapActivity mapActivity) {
+ private void dismiss(@NonNull MapActivity mapActivity) {
dismiss(mapActivity, true);
}
@@ -1928,5 +2024,4 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
public boolean isNightModeForMapControls() {
return nightMode;
}
-
-}
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/SaveGPX.java b/OsmAnd/src/net/osmand/plus/measurementtool/SaveGPX.java
deleted file mode 100644
index de47191ab5..0000000000
--- a/OsmAnd/src/net/osmand/plus/measurementtool/SaveGPX.java
+++ /dev/null
@@ -1,297 +0,0 @@
-package net.osmand.plus.measurementtool;
-
-import android.annotation.SuppressLint;
-import android.app.ProgressDialog;
-import android.os.AsyncTask;
-import android.view.View;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.google.android.material.snackbar.Snackbar;
-
-import net.osmand.FileUtils;
-import net.osmand.GPXUtilities;
-import net.osmand.data.QuadRect;
-import net.osmand.plus.GpxSelectionHelper;
-import net.osmand.plus.OsmandApplication;
-import net.osmand.plus.R;
-import net.osmand.plus.UiUtilities;
-import net.osmand.plus.Version;
-import net.osmand.plus.activities.MapActivity;
-import net.osmand.util.Algorithms;
-
-import java.io.File;
-import java.lang.ref.WeakReference;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-import static net.osmand.IndexConstants.GPX_FILE_EXT;
-
-class SaveGPX extends AsyncTask {
-
- private final MeasurementToolFragment measurementToolFragment;
- private final GPXUtilities.GPXFile gpxFile;
- private final File dir;
- private final String fileName;
- private final MeasurementToolFragment.SaveType saveType;
- private final boolean showOnMap;
- private final GpxData.ActionType actionType;
- private final MeasurementToolFragment.FinalSaveAction finalSaveAction;
- private final OsmandApplication app;
- @SuppressLint("StaticFieldLeak")
- private final MapActivity mapActivity;
- private MeasurementToolLayer measurementToolLayer;
- private boolean nightMode;
- private ProgressDialog progressDialog;
- private File backupFile;
- private File outFile;
- private GPXUtilities.GPXFile savedGpxFile;
- public MeasurementEditingContext editingCtx = new MeasurementEditingContext();
- private static final int UNDO_MODE = 0x8;
-
- public SaveGPX(MeasurementToolFragment measurementToolFragment, GPXUtilities.GPXFile gpxFile, File dir, String fileName, MeasurementToolFragment.SaveType saveType, boolean showOnMap, GpxData.ActionType actionType, MeasurementToolFragment.FinalSaveAction finalSaveAction, OsmandApplication app, MapActivity mapActivity, MeasurementToolLayer measurementToolLayer, boolean nightMode) {
- this.measurementToolFragment = measurementToolFragment;
- this.gpxFile = gpxFile;
- this.dir = dir;
- this.fileName = fileName;
- this.saveType = saveType;
- this.showOnMap = showOnMap;
- this.actionType = actionType;
- this.finalSaveAction = finalSaveAction;
- this.app = app;
- this.mapActivity = mapActivity;
- this.measurementToolLayer = measurementToolLayer;
- this.nightMode = nightMode;
- }
-
- @Override
- protected void onPreExecute() {
- measurementToolFragment.cancelModes();
- if (mapActivity != null) {
- progressDialog = new ProgressDialog(mapActivity);
- progressDialog.setMessage(measurementToolFragment.getString(R.string.saving_gpx_tracks));
- progressDialog.show();
- }
- }
-
- @Override
- protected Exception doInBackground(Void... voids) {
- if (app == null) {
- return null;
- }
- List points = editingCtx.getPoints();
- GPXUtilities.TrkSegment before = editingCtx.getBeforeTrkSegmentLine();
- GPXUtilities.TrkSegment after = editingCtx.getAfterTrkSegmentLine();
- if (gpxFile == null) {
- outFile = new File(dir, fileName);
- String trackName = fileName.substring(0, fileName.length() - GPX_FILE_EXT.length());
- GPXUtilities.GPXFile gpx = new GPXUtilities.GPXFile(Version.getFullVersion(app));
- if (measurementToolLayer != null) {
- if (saveType == MeasurementToolFragment.SaveType.LINE) {
- GPXUtilities.TrkSegment segment = new GPXUtilities.TrkSegment();
- if (editingCtx.hasRoute()) {
- segment.points.addAll(editingCtx.getRoutePoints());
- } else {
- segment.points.addAll(before.points);
- segment.points.addAll(after.points);
- }
- GPXUtilities.Track track = new GPXUtilities.Track();
- track.name = trackName;
- track.segments.add(segment);
- gpx.tracks.add(track);
- } else if (saveType == MeasurementToolFragment.SaveType.ROUTE_POINT) {
- if (editingCtx.hasRoute()) {
- GPXUtilities.GPXFile newGpx = editingCtx.exportRouteAsGpx(trackName);
- if (newGpx != null) {
- gpx = newGpx;
- }
- }
- gpx.addRoutePoints(points);
- }
- }
- Exception res = GPXUtilities.writeGpxFile(outFile, gpx);
- gpx.path = outFile.getAbsolutePath();
- savedGpxFile = gpx;
- if (showOnMap) {
- showGpxOnMap(app, gpx, true);
- }
- return res;
- } else {
- GPXUtilities.GPXFile gpx = gpxFile;
- outFile = new File(gpx.path);
- backupFile = FileUtils.backupFile(app, outFile);
- String trackName = Algorithms.getFileNameWithoutExtension(outFile);
- if (measurementToolLayer != null) {
- if (measurementToolFragment.isPlanRouteMode()) {
- if (saveType == MeasurementToolFragment.SaveType.LINE) {
- GPXUtilities.TrkSegment segment = new GPXUtilities.TrkSegment();
- if (editingCtx.hasRoute()) {
- segment.points.addAll(editingCtx.getRoutePoints());
- } else {
- segment.points.addAll(before.points);
- segment.points.addAll(after.points);
- }
- GPXUtilities.Track track = new GPXUtilities.Track();
- track.name = trackName;
- track.segments.add(segment);
- gpx.tracks.add(track);
- } else if (saveType == MeasurementToolFragment.SaveType.ROUTE_POINT) {
- if (editingCtx.hasRoute()) {
- GPXUtilities.GPXFile newGpx = editingCtx.exportRouteAsGpx(trackName);
- if (newGpx != null) {
- gpx = newGpx;
- }
- }
- gpx.addRoutePoints(points);
- }
- } else if (actionType != null) {
- GpxData gpxData = editingCtx.getGpxData();
- switch (actionType) {
- case ADD_SEGMENT: {
- List snappedPoints = new ArrayList<>();
- snappedPoints.addAll(before.points);
- snappedPoints.addAll(after.points);
- gpx.addTrkSegment(snappedPoints);
- break;
- }
- case ADD_ROUTE_POINTS: {
- gpx.replaceRoutePoints(points);
- break;
- }
- case EDIT_SEGMENT: {
- if (gpxData != null) {
- GPXUtilities.TrkSegment segment = new GPXUtilities.TrkSegment();
- segment.points.addAll(points);
- gpx.replaceSegment(gpxData.getTrkSegment(), segment);
- }
- break;
- }
- case OVERWRITE_SEGMENT: {
- if (gpxData != null) {
- List snappedPoints = new ArrayList<>();
- snappedPoints.addAll(before.points);
- snappedPoints.addAll(after.points);
- GPXUtilities.TrkSegment segment = new GPXUtilities.TrkSegment();
- segment.points.addAll(snappedPoints);
- gpx.replaceSegment(gpxData.getTrkSegment(), segment);
- }
- break;
- }
- }
- } else {
- gpx.addRoutePoints(points);
- }
- }
- Exception res = null;
- if (!gpx.showCurrentTrack) {
- res = GPXUtilities.writeGpxFile(outFile, gpx);
- }
- savedGpxFile = gpx;
- if (showOnMap) {
- showGpxOnMap(app, gpx, false);
- }
- return res;
- }
- }
-
- private void showGpxOnMap(OsmandApplication app, GPXUtilities.GPXFile gpx, boolean isNewGpx) {
- GpxSelectionHelper.SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpx, true, false);
- if (sf != null && !isNewGpx) {
- if (actionType == GpxData.ActionType.ADD_SEGMENT || actionType == GpxData.ActionType.EDIT_SEGMENT) {
- sf.processPoints(app);
- }
- }
- }
-
- @Override
- protected void onPostExecute(Exception warning) {
- onGpxSaved(warning);
- }
-
- private void onGpxSaved(Exception warning) {
- if (mapActivity == null) {
- return;
- }
- if (progressDialog != null && progressDialog.isShowing()) {
- progressDialog.dismiss();
- }
- mapActivity.refreshMap();
- if (warning == null) {
- if (editingCtx.isNewData() && savedGpxFile != null) {
- QuadRect rect = savedGpxFile.getRect();
- GPXUtilities.TrkSegment segment = savedGpxFile.getNonEmptyTrkSegment();
- GpxData gpxData = new GpxData(savedGpxFile, rect, GpxData.ActionType.EDIT_SEGMENT, segment);
- editingCtx.setGpxData(gpxData);
- measurementToolFragment.updateToolbar();
- }
- if (measurementToolFragment.isInEditMode()) {
- editingCtx.setChangesSaved();
- measurementToolFragment.dismiss(mapActivity);
- } else {
- switch (finalSaveAction) {
- case SHOW_SNACK_BAR_AND_CLOSE:
- final WeakReference mapActivityRef = new WeakReference<>(mapActivity);
- Snackbar snackbar = Snackbar.make(mapActivity.getLayout(),
- MessageFormat.format(measurementToolFragment.getString(R.string.gpx_saved_sucessfully), outFile.getName()),
- Snackbar.LENGTH_LONG)
- .setAction(R.string.shared_string_undo, new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- MapActivity mapActivity = mapActivityRef.get();
- if (mapActivity != null) {
- if (outFile != null) {
- OsmandApplication app = mapActivity.getMyApplication();
- FileUtils.removeGpxFile(app, outFile);
- if (backupFile != null) {
- FileUtils.renameGpxFile(app, backupFile, outFile);
- GPXUtilities.GPXFile gpx = GPXUtilities.loadGPXFile(outFile);
- measurementToolFragment.setupGpxData(gpx);
- if (showOnMap) {
- showGpxOnMap(app, gpx, false);
- }
- } else {
- measurementToolFragment.setupGpxData(null);
- }
- }
- measurementToolFragment.setMode(UNDO_MODE, true);
- MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager()
- );
- }
- }
- })
- .addCallback(new Snackbar.Callback() {
- @Override
- public void onDismissed(Snackbar transientBottomBar, int event) {
- if (event != DISMISS_EVENT_ACTION) {
- editingCtx.setChangesSaved();
- }
- super.onDismissed(transientBottomBar, event);
- }
- });
- snackbar.getView().findViewById(com.google.android.material.R.id.snackbar_action)
- .setAllCaps(false);
- UiUtilities.setupSnackbar(snackbar, nightMode);
- snackbar.show();
- measurementToolFragment.dismiss(mapActivity);
- break;
- case SHOW_IS_SAVED_FRAGMENT:
- editingCtx.setChangesSaved();
- SavedTrackBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(),
- outFile.getAbsolutePath());
- measurementToolFragment.dismiss(mapActivity);
- break;
- case SHOW_TOAST:
- editingCtx.setChangesSaved();
- if (!savedGpxFile.showCurrentTrack) {
- Toast.makeText(mapActivity,
- MessageFormat.format(measurementToolFragment.getString(R.string.gpx_saved_sucessfully), outFile.getAbsolutePath()),
- Toast.LENGTH_LONG).show();
- }
- }
- }
- } else {
- Toast.makeText(mapActivity, warning.getMessage(), Toast.LENGTH_LONG).show();
- }
- }
-}
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/SaveGpxRouteAsyncTask.java b/OsmAnd/src/net/osmand/plus/measurementtool/SaveGpxRouteAsyncTask.java
new file mode 100644
index 0000000000..ddae8ed26d
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/measurementtool/SaveGpxRouteAsyncTask.java
@@ -0,0 +1,210 @@
+package net.osmand.plus.measurementtool;
+
+import android.app.ProgressDialog;
+import android.content.Context;
+import android.os.AsyncTask;
+
+import net.osmand.AndroidUtils;
+import net.osmand.FileUtils;
+import net.osmand.GPXUtilities;
+import net.osmand.GPXUtilities.GPXFile;
+import net.osmand.GPXUtilities.Track;
+import net.osmand.GPXUtilities.TrkSegment;
+import net.osmand.GPXUtilities.WptPt;
+import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.R;
+import net.osmand.plus.Version;
+import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.measurementtool.GpxData.ActionType;
+import net.osmand.plus.measurementtool.MeasurementToolFragment.SaveType;
+import net.osmand.util.Algorithms;
+
+import java.io.File;
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.List;
+
+import static net.osmand.IndexConstants.GPX_FILE_EXT;
+
+class SaveGpxRouteAsyncTask extends AsyncTask {
+
+ private WeakReference fragmentRef;
+ private ProgressDialog progressDialog;
+
+ private SaveType saveType;
+ private ActionType actionType;
+
+ private File outFile;
+ private File backupFile;
+ private GPXFile gpxFile;
+ private GPXFile savedGpxFile;
+ private boolean showOnMap;
+
+ private SaveGpxRouteListener saveGpxRouteListener;
+
+
+ public SaveGpxRouteAsyncTask(MeasurementToolFragment fragment, File outFile, GPXFile gpxFile,
+ ActionType actionType, SaveType saveType, boolean showOnMap, SaveGpxRouteListener saveGpxRouteListener) {
+ fragmentRef = new WeakReference<>(fragment);
+ this.outFile = outFile;
+ this.showOnMap = showOnMap;
+ this.gpxFile = gpxFile;
+ this.actionType = actionType;
+ this.saveType = saveType;
+ this.saveGpxRouteListener = saveGpxRouteListener;
+ }
+
+ @Override
+ protected void onPreExecute() {
+ MeasurementToolFragment fragment = fragmentRef.get();
+ if (fragment != null && fragment.getContext() != null) {
+ fragment.cancelModes();
+
+ Context ctx = fragment.getContext();
+ progressDialog = new ProgressDialog(ctx);
+ progressDialog.setMessage(ctx.getString(R.string.saving_gpx_tracks));
+ progressDialog.show();
+ }
+ }
+
+ @Override
+ protected Exception doInBackground(Void... voids) {
+ MeasurementToolFragment fragment = fragmentRef.get();
+ if (fragment == null || fragment.getActivity() == null) {
+ return null;
+ }
+ MapActivity mapActivity = (MapActivity) fragment.getActivity();
+ OsmandApplication app = mapActivity.getMyApplication();
+ MeasurementToolLayer measurementLayer = mapActivity.getMapLayers().getMeasurementToolLayer();
+ MeasurementEditingContext editingCtx = fragment.getEditingCtx();
+
+ List points = editingCtx.getPoints();
+ TrkSegment before = editingCtx.getBeforeTrkSegmentLine();
+ TrkSegment after = editingCtx.getAfterTrkSegmentLine();
+ if (gpxFile == null) {
+ String fileName = outFile.getName();
+ String trackName = fileName.substring(0, fileName.length() - GPX_FILE_EXT.length());
+ GPXFile gpx = new GPXFile(Version.getFullVersion(app));
+ if (measurementLayer != null) {
+ if (saveType == MeasurementToolFragment.SaveType.LINE) {
+ TrkSegment segment = new TrkSegment();
+ if (editingCtx.hasRoute()) {
+ segment.points.addAll(editingCtx.getRoutePoints());
+ } else {
+ segment.points.addAll(before.points);
+ segment.points.addAll(after.points);
+ }
+ Track track = new Track();
+ track.name = trackName;
+ track.segments.add(segment);
+ gpx.tracks.add(track);
+ } else if (saveType == MeasurementToolFragment.SaveType.ROUTE_POINT) {
+ if (editingCtx.hasRoute()) {
+ GPXFile newGpx = editingCtx.exportRouteAsGpx(trackName);
+ if (newGpx != null) {
+ gpx = newGpx;
+ }
+ }
+ gpx.addRoutePoints(points);
+ }
+ }
+ Exception res = GPXUtilities.writeGpxFile(outFile, gpx);
+ gpx.path = outFile.getAbsolutePath();
+ savedGpxFile = gpx;
+ if (showOnMap) {
+ MeasurementToolFragment.showGpxOnMap(app, gpx, actionType, true);
+ }
+ return res;
+ } else {
+ GPXFile gpx = gpxFile;
+ backupFile = FileUtils.backupFile(app, outFile);
+ String trackName = Algorithms.getFileNameWithoutExtension(outFile);
+ if (measurementLayer != null) {
+ if (fragment.isPlanRouteMode()) {
+ if (saveType == MeasurementToolFragment.SaveType.LINE) {
+ TrkSegment segment = new TrkSegment();
+ if (editingCtx.hasRoute()) {
+ segment.points.addAll(editingCtx.getRoutePoints());
+ } else {
+ segment.points.addAll(before.points);
+ segment.points.addAll(after.points);
+ }
+ Track track = new Track();
+ track.name = trackName;
+ track.segments.add(segment);
+ gpx.tracks.add(track);
+ } else if (saveType == MeasurementToolFragment.SaveType.ROUTE_POINT) {
+ if (editingCtx.hasRoute()) {
+ GPXFile newGpx = editingCtx.exportRouteAsGpx(trackName);
+ if (newGpx != null) {
+ gpx = newGpx;
+ }
+ }
+ gpx.addRoutePoints(points);
+ }
+ } else if (actionType != null) {
+ GpxData gpxData = editingCtx.getGpxData();
+ switch (actionType) {
+ case ADD_SEGMENT: {
+ List snappedPoints = new ArrayList<>();
+ snappedPoints.addAll(before.points);
+ snappedPoints.addAll(after.points);
+ gpx.addTrkSegment(snappedPoints);
+ break;
+ }
+ case ADD_ROUTE_POINTS: {
+ gpx.replaceRoutePoints(points);
+ break;
+ }
+ case EDIT_SEGMENT: {
+ if (gpxData != null) {
+ TrkSegment segment = new TrkSegment();
+ segment.points.addAll(points);
+ gpx.replaceSegment(gpxData.getTrkSegment(), segment);
+ }
+ break;
+ }
+ case OVERWRITE_SEGMENT: {
+ if (gpxData != null) {
+ List snappedPoints = new ArrayList<>();
+ snappedPoints.addAll(before.points);
+ snappedPoints.addAll(after.points);
+ TrkSegment segment = new TrkSegment();
+ segment.points.addAll(snappedPoints);
+ gpx.replaceSegment(gpxData.getTrkSegment(), segment);
+ }
+ break;
+ }
+ }
+ } else {
+ gpx.addRoutePoints(points);
+ }
+ }
+ Exception res = null;
+ if (!gpx.showCurrentTrack) {
+ res = GPXUtilities.writeGpxFile(outFile, gpx);
+ }
+ savedGpxFile = gpx;
+ if (showOnMap) {
+ MeasurementToolFragment.showGpxOnMap(app, gpx, actionType, false);
+ }
+ return res;
+ }
+ }
+
+ @Override
+ protected void onPostExecute(Exception warning) {
+ MeasurementToolFragment fragment = fragmentRef.get();
+ if (fragment != null && progressDialog != null && AndroidUtils.isActivityNotDestroyed(fragment.getActivity())) {
+ progressDialog.dismiss();
+ }
+ if (saveGpxRouteListener != null) {
+ saveGpxRouteListener.gpxSavingFinished(warning, savedGpxFile, backupFile);
+ }
+ }
+
+ public interface SaveGpxRouteListener {
+
+ void gpxSavingFinished(Exception warning, GPXFile savedGpxFile, File backupFile);
+ }
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/SelectFileBottomSheet.java b/OsmAnd/src/net/osmand/plus/measurementtool/SelectFileBottomSheet.java
index 24d3ec8282..c155ec493c 100644
--- a/OsmAnd/src/net/osmand/plus/measurementtool/SelectFileBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/measurementtool/SelectFileBottomSheet.java
@@ -25,6 +25,7 @@ import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.helpers.GpxTrackAdapter;
import net.osmand.plus.helpers.GpxTrackAdapter.OnItemClickListener;
import net.osmand.plus.helpers.GpxUiHelper.GPXInfo;
+import net.osmand.plus.helpers.enums.TracksSortByMode;
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter;
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionAdapterListener;
@@ -38,7 +39,6 @@ import java.util.Map;
import static net.osmand.plus.SimplePopUpMenuItemAdapter.*;
import static net.osmand.plus.helpers.GpxUiHelper.getSortedGPXFilesInfo;
-import static net.osmand.plus.settings.backend.OsmandSettings.*;
import static net.osmand.util.Algorithms.collectDirs;
public class SelectFileBottomSheet extends BottomSheetBehaviourDialogFragment {
diff --git a/OsmAnd/src/net/osmand/plus/monitoring/MonitoringSettingsFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/MonitoringSettingsFragment.java
index eeaa98ff8c..901348a6d3 100644
--- a/OsmAnd/src/net/osmand/plus/monitoring/MonitoringSettingsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/monitoring/MonitoringSettingsFragment.java
@@ -13,7 +13,8 @@ import androidx.preference.Preference;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmAndAppCustomization;
import net.osmand.plus.OsmandPlugin;
-import net.osmand.plus.settings.backend.OsmandSettings;
+import net.osmand.plus.settings.backend.CommonPreference;
+import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.FontCache;
@@ -288,11 +289,11 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment
@Override
public void onApplyPreferenceChange(String prefId, boolean applyToAllProfiles, Object newValue) {
if (SAVE_GLOBAL_TRACK_INTERVAL.equals(prefId)) {
- OsmandSettings.OsmandPreference pref = settings.getPreference(prefId);
+ OsmandPreference pref = settings.getPreference(prefId);
if (newValue instanceof Boolean) {
applyPreference(settings.SAVE_GLOBAL_TRACK_REMEMBER.getId(), applyToAllProfiles, false);
- } else if (pref instanceof OsmandSettings.CommonPreference
- && !((OsmandSettings.CommonPreference) pref).hasDefaultValueForMode(getSelectedAppMode())) {
+ } else if (pref instanceof CommonPreference
+ && !((CommonPreference) pref).hasDefaultValueForMode(getSelectedAppMode())) {
applyPreference(SAVE_GLOBAL_TRACK_INTERVAL, applyToAllProfiles, newValue);
applyPreference(settings.SAVE_GLOBAL_TRACK_REMEMBER.getId(), applyToAllProfiles, true);
}
diff --git a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java
index fae190ea01..31cb5375fe 100644
--- a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java
+++ b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java
@@ -84,7 +84,7 @@ import net.osmand.plus.mapmarkers.CoordinateInputDialogFragment;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.osmedit.OsmEditingPlugin;
import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.TracksSortByMode;
+import net.osmand.plus.helpers.enums.TracksSortByMode;
import java.io.File;
import java.text.DateFormat;
diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java
index 3d9e065a5e..4451354fc8 100644
--- a/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java
+++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackActivityFragmentAdapter.java
@@ -50,14 +50,14 @@ import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.settings.backend.CommonPreference;
+import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.TrackActivity;
import net.osmand.plus.dialogs.GpxAppearanceAdapter;
import net.osmand.plus.measurementtool.GpxData;
import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener;
-import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
import net.osmand.plus.track.GpxSplitType;
import net.osmand.plus.track.SplitTrackAsyncTask;
import net.osmand.plus.track.SplitTrackAsyncTask.SplitTrackListener;
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java
index f1b33b8f79..5030530f88 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditingPlugin.java
@@ -25,6 +25,12 @@ import net.osmand.osm.PoiType;
import net.osmand.osm.edit.Entity;
import net.osmand.plus.*;
import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
+import net.osmand.plus.ContextMenuItem;
+import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.OsmandPlugin;
+import net.osmand.plus.settings.backend.OsmandPreference;
+import net.osmand.plus.settings.backend.OsmandSettings;
+import net.osmand.plus.R;
import net.osmand.plus.activities.EnumAdapter;
import net.osmand.plus.activities.EnumAdapter.IEnumWithResource;
import net.osmand.plus.activities.MapActivity;
@@ -342,7 +348,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
@Override
public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
if (itemId == R.string.layer_osm_bugs) {
- OsmandSettings.OsmandPreference showOsmBugs = settings.SHOW_OSM_BUGS;
+ OsmandPreference showOsmBugs = settings.SHOW_OSM_BUGS;
showOsmBugs.set(isChecked);
adapter.getItem(pos).setColorRes(showOsmBugs.get() ?
R.color.osmand_orange : ContextMenuItem.INVALID_ID);
@@ -365,7 +371,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
@Override
public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
if (itemId == R.string.layer_osm_edits) {
- OsmandSettings.OsmandPreference showOsmEdits = settings.SHOW_OSM_EDITS;
+ OsmandPreference showOsmEdits = settings.SHOW_OSM_EDITS;
showOsmEdits.set(isChecked);
adapter.getItem(pos).setColorRes(showOsmEdits.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesMenu.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesMenu.java
index 80fa80a7f0..3c7c387a36 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesMenu.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesMenu.java
@@ -14,8 +14,8 @@ import net.osmand.plus.DialogListItemAdapter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
-import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference;
+import net.osmand.plus.settings.backend.CommonPreference;
+import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java
index 038f9c9830..d131721376 100644
--- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java
@@ -7,7 +7,6 @@ import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.format.DateFormat;
-import android.text.format.Time;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
@@ -27,6 +26,8 @@ import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
+import net.osmand.plus.settings.backend.OsmandSettings;
+import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
@@ -34,20 +35,15 @@ import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.quickaction.QuickActionType;
import net.osmand.plus.settings.backend.ApplicationMode;
-import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.layers.MapInfoLayer;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget;
-import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
-import java.util.Date;
import java.util.List;
-import java.util.Locale;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_MARK_AS_PARKING_LOC;
diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/DayNightModeAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/DayNightModeAction.java
index 0be5c0f715..8314341371 100644
--- a/OsmAnd/src/net/osmand/plus/quickaction/actions/DayNightModeAction.java
+++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/DayNightModeAction.java
@@ -6,8 +6,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import net.osmand.plus.OsmandApplication;
-import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.DayNightMode;
+import net.osmand.plus.helpers.enums.DayNightMode;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.quickaction.QuickAction;
@@ -27,9 +26,9 @@ public class DayNightModeAction extends QuickAction {
@Override
public void execute(MapActivity activity) {
if (activity.getMyApplication().getDaynightHelper().isNightMode()) {
- activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.DAY);
+ activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(DayNightMode.DAY);
} else {
- activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.NIGHT);
+ activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(DayNightMode.NIGHT);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/LayerTransparencySeekbarMode.java b/OsmAnd/src/net/osmand/plus/rastermaps/LayerTransparencySeekbarMode.java
new file mode 100644
index 0000000000..1fd8b2f91d
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/rastermaps/LayerTransparencySeekbarMode.java
@@ -0,0 +1,22 @@
+package net.osmand.plus.rastermaps;
+
+import android.content.Context;
+
+import net.osmand.plus.R;
+
+public enum LayerTransparencySeekbarMode {
+ OVERLAY(R.string.overlay_transparency),
+ UNDERLAY(R.string.map_transparency),
+ OFF(R.string.shared_string_off),
+ UNDEFINED(R.string.shared_string_none);
+
+ private final int key;
+
+ LayerTransparencySeekbarMode(int key) {
+ this.key = key;
+ }
+
+ public String toHumanString(Context ctx) {
+ return ctx.getString(key);
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java
index 575196f8a2..7972b264aa 100644
--- a/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java
+++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapOverlayAction.java
@@ -16,7 +16,6 @@ import com.google.gson.reflect.TypeToken;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.LayerTransparencySeekbarMode;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
@@ -137,7 +136,7 @@ public class MapOverlayAction extends SwitchableAction> {
if (settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.get() == LayerTransparencySeekbarMode.UNDEFINED) {
settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.set(LayerTransparencySeekbarMode.OVERLAY);
}
- if (settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.get() == OsmandSettings.LayerTransparencySeekbarMode.OVERLAY) {
+ if (settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.get() == LayerTransparencySeekbarMode.OVERLAY) {
activity.getMapLayers().getMapControlsLayer().showTransparencyBar(settings.MAP_OVERLAY_TRANSPARENCY, true);
}
} else {
diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java b/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java
index 12f6f909cf..ca79cb4895 100644
--- a/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java
+++ b/OsmAnd/src/net/osmand/plus/rastermaps/MapUnderlayAction.java
@@ -15,8 +15,8 @@ import com.google.gson.reflect.TypeToken;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
+import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.LayerTransparencySeekbarMode;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
@@ -144,7 +144,7 @@ public class MapUnderlayAction extends SwitchableAction> {
}
- final OsmandSettings.CommonPreference hidePolygonsPref =
+ final CommonPreference hidePolygonsPref =
activity.getMyApplication().getSettings().getCustomRenderBooleanProperty("noPolygons");
hidePolygonsPref.set(hasUnderlay);
diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java
index da7a7882d3..942a34cbf1 100644
--- a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java
@@ -29,6 +29,8 @@ import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.DialogListItemAdapter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
+import net.osmand.plus.settings.backend.OsmandSettings;
+import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.activities.DownloadTilesDialog;
@@ -38,9 +40,6 @@ import net.osmand.plus.activities.MapActivityLayers;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.dialogs.RasterMapMenu;
import net.osmand.plus.quickaction.QuickActionType;
-import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
-import net.osmand.plus.settings.backend.OsmandSettings.LayerTransparencySeekbarMode;
import net.osmand.plus.views.MapTileLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.util.Algorithms;
@@ -559,10 +558,10 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
}
MapActivityLayers mapLayers = mapActivity.getMapLayers();
ITileSource map = layer.getMap();
- final OsmandSettings.LayerTransparencySeekbarMode currentMapTypeSeekbarMode = type ==
+ final LayerTransparencySeekbarMode currentMapTypeSeekbarMode = type ==
OsmandRasterMapsPlugin.RasterMapType.OVERLAY
- ? OsmandSettings.LayerTransparencySeekbarMode.OVERLAY
- : OsmandSettings.LayerTransparencySeekbarMode.UNDERLAY;
+ ? LayerTransparencySeekbarMode.OVERLAY
+ : LayerTransparencySeekbarMode.UNDERLAY;
if (map != null) {
mapTypePreference.set(null);
if (callback != null) {
diff --git a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java
index 1f2750cff5..8bc8d1b51a 100644
--- a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java
+++ b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java
@@ -43,7 +43,7 @@ import net.osmand.plus.settings.backend.OsmAndAppCustomization.OsmAndAppCustomiz
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
+import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.R;
import net.osmand.plus.development.OsmandDevelopmentPlugin;
import net.osmand.plus.render.OsmandRenderer.RenderingContext;
diff --git a/OsmAnd/src/net/osmand/plus/resources/RegionAddressRepositoryBinary.java b/OsmAnd/src/net/osmand/plus/resources/RegionAddressRepositoryBinary.java
index 6da4f7ecab..702028d851 100644
--- a/OsmAnd/src/net/osmand/plus/resources/RegionAddressRepositoryBinary.java
+++ b/OsmAnd/src/net/osmand/plus/resources/RegionAddressRepositoryBinary.java
@@ -18,7 +18,7 @@ import net.osmand.data.MapObject;
import net.osmand.data.QuadRect;
import net.osmand.data.QuadTree;
import net.osmand.data.Street;
-import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference;
+import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.resources.ResourceManager.BinaryMapReaderResource;
import net.osmand.plus.resources.ResourceManager.BinaryMapReaderResourceType;
import net.osmand.util.MapUtils;
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/AvoidRoadsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AvoidRoadsBottomSheetDialogFragment.java
index 9d7a8f3ab1..78773b5171 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/AvoidRoadsBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AvoidRoadsBottomSheetDialogFragment.java
@@ -20,7 +20,7 @@ import androidx.fragment.app.Fragment;
import net.osmand.AndroidUtils;
import net.osmand.data.LatLon;
import net.osmand.plus.OsmandApplication;
-import net.osmand.plus.settings.backend.OsmandSettings;
+import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
@@ -292,7 +292,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
GeneralRouter.RoutingParameter parameter = routingOptionsHelper.getRoutingPrefsForAppModeById(app.getRoutingHelper().getAppMode(), parameterId);
if (parameter != null) {
boolean checked = entry.getValue();
- OsmandSettings.CommonPreference preference = app.getSettings().getCustomRoutingBooleanProperty(parameter.getId(), parameter.getDefaultBoolean());
+ CommonPreference preference = app.getSettings().getCustomRoutingBooleanProperty(parameter.getId(), parameter.getDefaultBoolean());
preference.setModeValue(app.getRoutingHelper().getAppMode(), checked);
}
}
@@ -318,7 +318,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
List avoidParameters = routingOptionsHelper.getAvoidRoutingPrefsForAppMode(app.getRoutingHelper().getAppMode());
for (GeneralRouter.RoutingParameter parameter : avoidParameters) {
- OsmandSettings.CommonPreference preference = app.getSettings().getCustomRoutingBooleanProperty(parameter.getId(), parameter.getDefaultBoolean());
+ CommonPreference preference = app.getSettings().getCustomRoutingBooleanProperty(parameter.getId(), parameter.getDefaultBoolean());
res.put(parameter.getId(), preference.getModeValue(app.getRoutingHelper().getAppMode()));
}
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
index 69bed394cc..927a085c8c 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
@@ -54,6 +54,9 @@ import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.settings.backend.OsmandSettings;
+import net.osmand.plus.settings.backend.CommonPreference;
+import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
@@ -102,9 +105,6 @@ import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.TransportRoutingHelper;
import net.osmand.plus.search.QuickSearchHelper;
import net.osmand.plus.settings.backend.ApplicationMode;
-import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
-import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference;
import net.osmand.plus.widgets.TextViewExProgress;
import net.osmand.router.GeneralRouter;
import net.osmand.router.GeneralRouter.RoutingParameter;
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java
index c2681b2f7b..f9f8f5ce7b 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java
@@ -27,6 +27,9 @@ import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.DialogListItemAdapter;
import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.settings.backend.CommonPreference;
+import net.osmand.plus.settings.backend.OsmandPreference;
+import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
@@ -192,7 +195,7 @@ public class RoutingOptionsHelper {
public void applyVoiceProvider(MapActivity mapActivity, String provider, boolean applyAllModes) {
OsmandApplication app = mapActivity.getMyApplication();
ApplicationMode selectedAppMode = app.getRoutingHelper().getAppMode();
- OsmandSettings.OsmandPreference VP = app.getSettings().VOICE_PROVIDER;
+ OsmandPreference VP = app.getSettings().VOICE_PROVIDER;
if (applyAllModes) {
for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {
VP.setModeValue(mode, provider);
@@ -668,7 +671,7 @@ public class RoutingOptionsHelper {
}
public boolean isSelected(OsmandSettings settings) {
- final OsmandSettings.CommonPreference property =
+ final CommonPreference property =
settings.getCustomRoutingBooleanProperty(routingParameter.getId(), routingParameter.getDefaultBoolean());
if (am != null) {
return property.getModeValue(am);
@@ -678,7 +681,7 @@ public class RoutingOptionsHelper {
}
public void setSelected(OsmandSettings settings, boolean isChecked) {
- final OsmandSettings.CommonPreference property =
+ final CommonPreference property =
settings.getCustomRoutingBooleanProperty(routingParameter.getId(), routingParameter.getDefaultBoolean());
if (am != null) {
property.setModeValue(am, isChecked);
diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java
index eb7765e9af..a21b8898e6 100644
--- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java
+++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java
@@ -22,19 +22,18 @@ import net.osmand.data.LocationPoint;
import net.osmand.data.WptLocationPoint;
import net.osmand.osm.io.NetworkUtils;
import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.settings.backend.OsmandSettings;
+import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.Version;
import net.osmand.plus.render.NativeOsmandLibrary;
import net.osmand.plus.settings.backend.ApplicationMode;
-import net.osmand.plus.settings.backend.OsmandSettings;
-import net.osmand.plus.settings.backend.OsmandSettings.CommonPreference;
import net.osmand.router.GeneralRouter;
import net.osmand.router.GeneralRouter.RoutingParameter;
import net.osmand.router.GeneralRouter.RoutingParameterType;
import net.osmand.router.PrecalculatedRouteDirection;
-import net.osmand.router.RouteCalculationProgress;
import net.osmand.router.RouteExporter;
import net.osmand.router.RouteImporter;
import net.osmand.router.RoutePlannerFrontEnd;
diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java
index 4fd5b1dd65..e92c8c0504 100644
--- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java
+++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java
@@ -21,6 +21,7 @@ import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
+import net.osmand.plus.helpers.enums.MetricsConstants;
import net.osmand.plus.notifications.OsmandNotification.NotificationType;
import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo;
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
@@ -408,8 +409,8 @@ public class RoutingHelper {
} else if (mode.getRouteService() == RouteService.DIRECT_TO) {
return -1.0f;
} else if (mode.getRouteService() == RouteService.STRAIGHT) {
- OsmandSettings.MetricsConstants mc = settings.METRIC_SYSTEM.getModeValue(mode);
- if (mc == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS || mc == OsmandSettings.MetricsConstants.MILES_AND_METERS) {
+ MetricsConstants mc = settings.METRIC_SYSTEM.getModeValue(mode);
+ if (mc == MetricsConstants.KILOMETERS_AND_METERS || mc == MetricsConstants.MILES_AND_METERS) {
return 500.f;
} else {
// 1/4 mile
diff --git a/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java
index b883a56bd1..4fa70f4c9f 100644
--- a/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java
+++ b/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java
@@ -16,6 +16,7 @@ import net.osmand.osm.edit.Node;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
+import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.render.NativeOsmandLibrary;
@@ -478,7 +479,7 @@ public class TransportRoutingHelper {
GeneralRouter.RoutingParameter pr = e.getValue();
String vl;
if(pr.getType() == GeneralRouter.RoutingParameterType.BOOLEAN) {
- OsmandSettings.CommonPreference pref = settings.getCustomRoutingBooleanProperty(key, pr.getDefaultBoolean());
+ CommonPreference pref = settings.getCustomRoutingBooleanProperty(key, pr.getDefaultBoolean());
Boolean bool = pref.getModeValue(params.mode);
vl = bool ? "true" : null;
} else {
diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/BooleanAccessibilityPreference.java b/OsmAnd/src/net/osmand/plus/settings/backend/BooleanAccessibilityPreference.java
new file mode 100644
index 0000000000..145a566b77
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/settings/backend/BooleanAccessibilityPreference.java
@@ -0,0 +1,28 @@
+package net.osmand.plus.settings.backend;
+
+class BooleanAccessibilityPreference extends BooleanPreference {
+
+ BooleanAccessibilityPreference(OsmandSettings osmandSettings, String id, boolean defaultValue) {
+ super(osmandSettings, id, defaultValue);
+ }
+
+ @Override
+ public Boolean get() {
+ return getContext().accessibilityEnabled() ? super.get() : getDefaultValue();
+ }
+
+ @Override
+ public Boolean getModeValue(ApplicationMode mode) {
+ return getContext().accessibilityEnabledForMode(mode) ? super.getModeValue(mode) : getDefaultValue();
+ }
+
+ @Override
+ public boolean set(Boolean obj) {
+ return getContext().accessibilityEnabled() && super.set(obj);
+ }
+
+ @Override
+ public boolean setModeValue(ApplicationMode mode, Boolean obj) {
+ return getContext().accessibilityEnabledForMode(mode) && super.setModeValue(mode, obj);
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/BooleanPreference.java b/OsmAnd/src/net/osmand/plus/settings/backend/BooleanPreference.java
new file mode 100644
index 0000000000..9ff4d3069d
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/settings/backend/BooleanPreference.java
@@ -0,0 +1,23 @@
+package net.osmand.plus.settings.backend;
+
+public class BooleanPreference extends CommonPreference {
+
+ BooleanPreference(OsmandSettings settings, String id, boolean defaultValue) {
+ super(settings, id, defaultValue);
+ }
+
+ @Override
+ protected Boolean getValue(Object prefs, Boolean defaultValue) {
+ return getSettingsAPI().getBoolean(prefs, getId(), defaultValue);
+ }
+
+ @Override
+ protected boolean setValue(Object prefs, Boolean val) {
+ return getSettingsAPI().edit(prefs).putBoolean(getId(), val).commit();
+ }
+
+ @Override
+ public Boolean parseString(String s) {
+ return Boolean.parseBoolean(s);
+ }
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/BooleanStringPreference.java b/OsmAnd/src/net/osmand/plus/settings/backend/BooleanStringPreference.java
new file mode 100644
index 0000000000..1928fa60a7
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/settings/backend/BooleanStringPreference.java
@@ -0,0 +1,25 @@
+package net.osmand.plus.settings.backend;
+
+public class BooleanStringPreference extends BooleanPreference {
+
+ public BooleanStringPreference(OsmandSettings osmandSettings, String id, boolean defaultValue) {
+ super(osmandSettings, id, defaultValue);
+ }
+
+ @Override
+ protected Boolean getValue(Object prefs, Boolean defaultValue) {
+ Boolean value;
+ try {
+ value = parseString(getSettingsAPI().getString(prefs, getId(), defaultValue.toString()));
+ } catch (ClassCastException e) {
+ value = getSettingsAPI().getBoolean(prefs, getId(), defaultValue);
+ setValue(prefs, value);
+ }
+ return value;
+ }
+
+ @Override
+ protected boolean setValue(Object prefs, Boolean val) {
+ return getSettingsAPI().edit(prefs).putString(getId(), val != null ? val.toString() : null).commit();
+ }
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/CommonPreference.java b/OsmAnd/src/net/osmand/plus/settings/backend/CommonPreference.java
new file mode 100644
index 0000000000..62ce3a2450
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/settings/backend/CommonPreference.java
@@ -0,0 +1,249 @@
+package net.osmand.plus.settings.backend;
+
+import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.api.SettingsAPI;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public abstract class CommonPreference extends PreferenceWithListener {
+
+ private OsmandSettings settings;
+ private Object cachedPreference;
+
+ private final String id;
+
+ private T cachedValue;
+ private T defaultValue;
+ private Map defaultValues;
+
+ private boolean cache;
+ private boolean global;
+
+
+ public CommonPreference(OsmandSettings settings, String id, T defaultValue) {
+ this.settings = settings;
+ this.id = id;
+ this.defaultValue = defaultValue;
+ settings.registerInternalPreference(id, this);
+ }
+
+ // Methods to possibly override
+ protected abstract T getValue(Object prefs, T defaultValue);
+
+ protected abstract boolean setValue(Object prefs, T val);
+
+ public abstract T parseString(String s);
+
+ protected String toString(T o) {
+ return o == null ? null : o.toString();
+ }
+
+ protected SettingsAPI getSettingsAPI() {
+ return settings.getSettingsAPI();
+ }
+
+ protected ApplicationMode getApplicationMode() {
+ return settings.getApplicationMode();
+ }
+
+ protected OsmandApplication getContext() {
+ return settings.getContext();
+ }
+
+ // common methods
+
+ public final CommonPreference makeGlobal() {
+ global = true;
+ return this;
+ }
+
+ public final CommonPreference cache() {
+ cache = true;
+ return this;
+ }
+
+ public final CommonPreference makeProfile() {
+ global = false;
+ return this;
+ }
+
+ protected final Object getPreferences() {
+ return settings.getPreferences(global);
+
+ }
+
+ public final void setModeDefaultValue(ApplicationMode mode, T defValue) {
+ if (defaultValues == null) {
+ defaultValues = new LinkedHashMap();
+ }
+ defaultValues.put(mode, defValue);
+ }
+
+ // TODO final
+ @Override
+ public boolean setModeValue(ApplicationMode mode, T obj) {
+ if (global) {
+ return set(obj);
+ }
+
+ Object profilePrefs = settings.getProfilePreferences(mode);
+ boolean valueSaved = setValue(profilePrefs, obj);
+ if (valueSaved && cache && cachedPreference == profilePrefs) {
+ cachedValue = obj;
+ }
+ fireEvent(obj);
+
+ return valueSaved;
+ }
+
+ // TODO final
+ public T getProfileDefaultValue(ApplicationMode mode) {
+ if (global) {
+ return defaultValue;
+ }
+ if (defaultValues != null && defaultValues.containsKey(mode)) {
+ return defaultValues.get(mode);
+ }
+ ApplicationMode pt = mode.getParent();
+ if (pt != null) {
+ return getProfileDefaultValue(pt);
+ }
+ return defaultValue;
+ }
+
+ public final boolean hasDefaultValues() {
+ return defaultValues != null && !defaultValues.isEmpty();
+ }
+
+ public final boolean hasDefaultValueForMode(ApplicationMode mode) {
+ return defaultValues != null && defaultValues.containsKey(mode);
+ }
+
+ // TODO final
+ protected T getDefaultValue() {
+ return getProfileDefaultValue(settings.APPLICATION_MODE.get());
+ }
+
+ @Override
+ public final void overrideDefaultValue(T newDefaultValue) {
+ this.defaultValue = newDefaultValue;
+ }
+
+ // TODO final
+ @Override
+ public T getModeValue(ApplicationMode mode) {
+ if (global) {
+ return get();
+ }
+ T defaultV = getProfileDefaultValue(mode);
+ return getValue(settings.getProfilePreferences(mode), defaultV);
+ }
+
+ // TODO final
+ @Override
+ public T get() {
+ if (cache && cachedValue != null && cachedPreference == getPreferences()) {
+ return cachedValue;
+ }
+ cachedPreference = getPreferences();
+ cachedValue = getValue(cachedPreference, getProfileDefaultValue(settings.APPLICATION_MODE.get()));
+ return cachedValue;
+ }
+
+ @Override
+ public final String getId() {
+ return id;
+ }
+
+ @Override
+ public final void resetToDefault() {
+ T o = getProfileDefaultValue(settings.APPLICATION_MODE.get());
+ set(o);
+ }
+
+ @Override
+ public final void resetModeToDefault(ApplicationMode mode) {
+ if (global) {
+ resetToDefault();
+ } else {
+ T o = getProfileDefaultValue(mode);
+ setModeValue(mode, o);
+ }
+ }
+
+ // TODO final
+ @Override
+ public boolean set(T obj) {
+ Object prefs = getPreferences();
+ if (setValue(prefs, obj)) {
+ cachedValue = obj;
+ cachedPreference = prefs;
+ fireEvent(obj);
+ return true;
+ }
+ return false;
+ }
+
+ public final boolean isSet() {
+ return settings.isSet(global, getId());
+ }
+
+ public boolean isSetForMode(ApplicationMode mode) {
+ return settings.isSet(mode, getId());
+ }
+
+ public final boolean isGlobal() {
+ return global;
+ }
+
+ // TODO final
+ @Override
+ public boolean writeToJson(JSONObject json, ApplicationMode appMode) throws JSONException {
+ if (appMode != null) {
+ if (!global) {
+ String value = asStringModeValue(appMode);
+ if (value != null) {
+ json.put(getId(), value);
+ }
+ return true;
+ }
+ } else if (global) {
+ String value = asString();
+ if (value != null) {
+ json.put(getId(), value);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ // TODO final
+ @Override
+ public void readFromJson(JSONObject json, ApplicationMode appMode) throws JSONException {
+ if (appMode != null) {
+ if (!global) {
+ String modeValue = json.getString(getId());
+ setModeValue(appMode, parseString(modeValue));
+ }
+ } else if (global) {
+ String globalValue = json.getString(getId());
+ set(parseString(globalValue));
+ }
+ }
+
+ @Override
+ public final String asString() {
+ T o = get();
+ return toString(o);
+ }
+
+ @Override
+ public final String asStringModeValue(ApplicationMode m) {
+ T v = getModeValue(m);
+ return toString(v);
+ }
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/ContextMenuItemsPreference.java b/OsmAnd/src/net/osmand/plus/settings/backend/ContextMenuItemsPreference.java
new file mode 100644
index 0000000000..12a83ea229
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/settings/backend/ContextMenuItemsPreference.java
@@ -0,0 +1,46 @@
+package net.osmand.plus.settings.backend;
+
+import androidx.annotation.NonNull;
+
+public class ContextMenuItemsPreference extends CommonPreference {
+ @NonNull
+ private String idScheme;
+
+ ContextMenuItemsPreference(OsmandSettings settings, String id, @NonNull String idScheme, @NonNull ContextMenuItemsSettings defValue) {
+ super(settings, id, defValue);
+ this.idScheme = idScheme;
+ }
+
+ @Override
+ protected ContextMenuItemsSettings getValue(Object prefs, ContextMenuItemsSettings defaultValue) {
+ String s = getSettingsAPI().getString(prefs, getId(), "");
+ return readValue(s);
+ }
+
+ @Override
+ protected boolean setValue(Object prefs, ContextMenuItemsSettings val) {
+ return getSettingsAPI().edit(prefs).putString(getId(), val.writeToJsonString(idScheme)).commit();
+ }
+
+
+ @Override
+ protected String toString(ContextMenuItemsSettings o) {
+ return o.writeToJsonString(idScheme);
+ }
+
+ @Override
+ public ContextMenuItemsSettings parseString(String s) {
+ return readValue(s);
+ }
+
+ private ContextMenuItemsSettings readValue(String s) {
+ ContextMenuItemsSettings value = getDefaultValue().newInstance();
+ value.readFromJsonString(s, idScheme);
+ return value;
+ }
+
+ @NonNull
+ public String getIdScheme() {
+ return idScheme;
+ }
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/ContextMenuItemsSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/ContextMenuItemsSettings.java
new file mode 100644
index 0000000000..2c51f2607d
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/settings/backend/ContextMenuItemsSettings.java
@@ -0,0 +1,102 @@
+package net.osmand.plus.settings.backend;
+
+import androidx.annotation.NonNull;
+
+import net.osmand.PlatformUtil;
+import net.osmand.util.Algorithms;
+
+import org.apache.commons.logging.Log;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class ContextMenuItemsSettings implements Serializable {
+
+ private static final Log LOG = PlatformUtil.getLog(ContextMenuItemsSettings.class.getName());
+
+ private static final String HIDDEN = "hidden";
+ private static final String ORDER = "order";
+
+ private List hiddenIds = new ArrayList<>();
+ private List orderIds = new ArrayList<>();
+
+ public ContextMenuItemsSettings() {
+
+ }
+
+ public ContextMenuItemsSettings(@NonNull List hiddenIds, @NonNull List orderIds) {
+ this.hiddenIds = hiddenIds;
+ this.orderIds = orderIds;
+ }
+
+ public ContextMenuItemsSettings newInstance() {
+ return new ContextMenuItemsSettings();
+ }
+
+ public void readFromJsonString(String jsonString, @NonNull String idScheme) {
+ if (Algorithms.isEmpty(jsonString)) {
+ return;
+ }
+ try {
+ JSONObject json = new JSONObject(jsonString);
+ readFromJson(json, idScheme);
+ } catch (JSONException e) {
+ LOG.error("Error converting to json string: " + e);
+ }
+ }
+
+ public void readFromJson(JSONObject json, String idScheme) {
+ hiddenIds = readIdsList(json.optJSONArray(HIDDEN), idScheme);
+ orderIds = readIdsList(json.optJSONArray(ORDER), idScheme);
+ }
+
+ protected List readIdsList(JSONArray jsonArray, @NonNull String idScheme) {
+ List list = new ArrayList<>();
+ if (jsonArray != null) {
+ for (int i = 0; i < jsonArray.length(); i++) {
+ String id = jsonArray.optString(i);
+ list.add(idScheme + id);
+ }
+ }
+ return list;
+ }
+
+ public String writeToJsonString(@NonNull String idScheme) {
+ try {
+ JSONObject json = new JSONObject();
+ writeToJson(json, idScheme);
+ return json.toString();
+ } catch (JSONException e) {
+ LOG.error("Error converting to json string: " + e);
+ }
+ return "";
+ }
+
+ public void writeToJson(JSONObject json, String idScheme) throws JSONException {
+ json.put(HIDDEN, getJsonArray(hiddenIds, idScheme));
+ json.put(ORDER, getJsonArray(orderIds, idScheme));
+ }
+
+ protected JSONArray getJsonArray(List ids, @NonNull String idScheme) {
+ JSONArray jsonArray = new JSONArray();
+ if (ids != null && !ids.isEmpty()) {
+ for (String id : ids) {
+ jsonArray.put(id.replace(idScheme, ""));
+ }
+ }
+ return jsonArray;
+ }
+
+ public List getHiddenIds() {
+ return Collections.unmodifiableList(hiddenIds);
+ }
+
+ public List getOrderIds() {
+ return Collections.unmodifiableList(orderIds);
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/EnumStringPreference.java b/OsmAnd/src/net/osmand/plus/settings/backend/EnumStringPreference.java
new file mode 100644
index 0000000000..d51deca152
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/settings/backend/EnumStringPreference.java
@@ -0,0 +1,47 @@
+package net.osmand.plus.settings.backend;
+
+public class EnumStringPreference> extends CommonPreference {
+
+ private final E[] values;
+
+ EnumStringPreference(OsmandSettings settings, String id, E defaultValue, E[] values) {
+ super(settings, id, defaultValue);
+ this.values = values;
+ }
+
+ @Override
+ protected E getValue(Object prefs, E defaultValue) {
+ try {
+ String name = getSettingsAPI().getString(prefs, getId(), defaultValue.name());
+ E value = parseString(name);
+ return value != null ? value : defaultValue;
+ } catch (ClassCastException ex) {
+ setValue(prefs, defaultValue);
+ }
+ return defaultValue;
+ }
+
+ @Override
+ public boolean setValue(Object prefs, E val) {
+ return getSettingsAPI().edit(prefs).putString(getId(), val.name()).commit();
+ }
+
+ @Override
+ protected String toString(E o) {
+ return o.name();
+ }
+
+ @Override
+ public E parseString(String s) {
+ for (E value : values) {
+ if (value.name().equals(s)) {
+ return value;
+ }
+ }
+ return null;
+ }
+
+ public E[] getValues() {
+ return values;
+ }
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/FloatPreference.java b/OsmAnd/src/net/osmand/plus/settings/backend/FloatPreference.java
new file mode 100644
index 0000000000..d9a98f7a01
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/settings/backend/FloatPreference.java
@@ -0,0 +1,23 @@
+package net.osmand.plus.settings.backend;
+
+public class FloatPreference extends CommonPreference {
+
+ FloatPreference(OsmandSettings settings, String id, float defaultValue) {
+ super(settings, id, defaultValue);
+ }
+
+ @Override
+ protected Float getValue(Object prefs, Float defaultValue) {
+ return getSettingsAPI().getFloat(prefs, getId(), defaultValue);
+ }
+
+ @Override
+ protected boolean setValue(Object prefs, Float val) {
+ return getSettingsAPI().edit(prefs).putFloat(getId(), val).commit();
+ }
+
+ @Override
+ public Float parseString(String s) {
+ return Float.parseFloat(s);
+ }
+}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/ImpassableRoadsStorage.java b/OsmAnd/src/net/osmand/plus/settings/backend/ImpassableRoadsStorage.java
new file mode 100644
index 0000000000..80242478e5
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/settings/backend/ImpassableRoadsStorage.java
@@ -0,0 +1,193 @@
+package net.osmand.plus.settings.backend;
+
+import net.osmand.data.LatLon;
+import net.osmand.data.PointDescription;
+import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+class ImpassableRoadsStorage extends SettingsMapPointsStorage {
+
+ protected String roadsIdsKey;
+ protected String appModeKey;
+
+ public ImpassableRoadsStorage(OsmandSettings osmandSettings) {
+ super(osmandSettings);
+ pointsKey = OsmandSettings.IMPASSABLE_ROAD_POINTS;
+ descriptionsKey = OsmandSettings.IMPASSABLE_ROADS_DESCRIPTIONS;
+ roadsIdsKey = OsmandSettings.IMPASSABLE_ROADS_IDS;
+ appModeKey = OsmandSettings.IMPASSABLE_ROADS_APP_MODE_KEYS;
+ }
+
+ public List getRoadIds(int size) {
+ List list = new ArrayList<>();
+ String roadIds = getSettingsAPI().getString(getOsmandSettings().getGlobalPreferences(), roadsIdsKey, "");
+ if (roadIds.trim().length() > 0) {
+ StringTokenizer tok = new StringTokenizer(roadIds, ",");
+ while (tok.hasMoreTokens() && list.size() <= size) {
+ list.add(Long.parseLong(tok.nextToken()));
+ }
+ }
+ while (list.size() < size) {
+ list.add(0L);
+ }
+ return list;
+ }
+
+ public List getAppModeKeys(int size) {
+ List list = new ArrayList<>();
+ String roadIds = getSettingsAPI().getString(getOsmandSettings().getGlobalPreferences(), appModeKey, "");
+ if (roadIds.trim().length() > 0) {
+ StringTokenizer tok = new StringTokenizer(roadIds, ",");
+ while (tok.hasMoreTokens() && list.size() <= size) {
+ list.add(tok.nextToken());
+ }
+ }
+ while (list.size() < size) {
+ list.add("");
+ }
+ return list;
+ }
+
+ public List getImpassableRoadsInfo() {
+ List points = getPoints();
+ List roadIds = getRoadIds(points.size());
+ List appModeKeys = getAppModeKeys(points.size());
+ List descriptions = getPointDescriptions(points.size());
+
+ List avoidRoadsInfo = new ArrayList<>();
+
+ for (int i = 0; i < points.size(); i++) {
+ LatLon latLon = points.get(i);
+ PointDescription description = PointDescription.deserializeFromString(descriptions.get(i), null);
+
+ AvoidRoadInfo avoidRoadInfo = new AvoidRoadInfo();
+ avoidRoadInfo.id = roadIds.get(i);
+ avoidRoadInfo.latitude = latLon.getLatitude();
+ avoidRoadInfo.longitude = latLon.getLongitude();
+ avoidRoadInfo.name = description.getName();
+ avoidRoadInfo.appModeKey = appModeKeys.get(i);
+ avoidRoadsInfo.add(avoidRoadInfo);
+ }
+
+ return avoidRoadsInfo;
+ }
+
+ public boolean addImpassableRoadInfo(AvoidRoadInfo avoidRoadInfo) {
+ List points = getPoints();
+ List roadIds = getRoadIds(points.size());
+ List appModeKeys = getAppModeKeys(points.size());
+ List descriptions = getPointDescriptions(points.size());
+
+ roadIds.add(0, avoidRoadInfo.id);
+ points.add(0, new LatLon(avoidRoadInfo.latitude, avoidRoadInfo.longitude));
+ appModeKeys.add(0, avoidRoadInfo.appModeKey);
+ descriptions.add(0, PointDescription.serializeToString(new PointDescription("", avoidRoadInfo.name)));
+
+ return saveAvoidRoadData(points, descriptions, roadIds, appModeKeys);
+ }
+
+ public boolean updateImpassableRoadInfo(AvoidRoadInfo avoidRoadInfo) {
+ List points = getPoints();
+
+ int index = points.indexOf(new LatLon(avoidRoadInfo.latitude, avoidRoadInfo.longitude));
+ if (index != -1) {
+ List roadIds = getRoadIds(points.size());
+ List appModeKeys = getAppModeKeys(points.size());
+ List descriptions = getPointDescriptions(points.size());
+
+ roadIds.set(index, avoidRoadInfo.id);
+ appModeKeys.set(index, avoidRoadInfo.appModeKey);
+ descriptions.set(index, PointDescription.serializeToString(new PointDescription("", avoidRoadInfo.name)));
+ return saveAvoidRoadData(points, descriptions, roadIds, appModeKeys);
+ }
+ return false;
+ }
+
+ @Override
+ public boolean deletePoint(int index) {
+ List points = getPoints();
+ List roadIds = getRoadIds(points.size());
+ List appModeKeys = getAppModeKeys(points.size());
+ List descriptions = getPointDescriptions(points.size());
+
+ if (index < points.size()) {
+ points.remove(index);
+ roadIds.remove(index);
+ appModeKeys.remove(index);
+ descriptions.remove(index);
+ return saveAvoidRoadData(points, descriptions, roadIds, appModeKeys);
+ }
+ return false;
+ }
+
+ @Override
+ public boolean deletePoint(LatLon latLon) {
+ List points = getPoints();
+ List roadIds = getRoadIds(points.size());
+ List