From 372e35c46b48855342c23d727cced436866bbe4d Mon Sep 17 00:00:00 2001 From: androiddevkkotlin Date: Wed, 2 Dec 2020 14:28:31 +0200 Subject: [PATCH 01/17] Bottom sheet should scroll outside the screen, bottom sheets behavior with keyboard Bottom sheet should scroll outside the screen Check keyboard doesn't show after open If the bottom sheet contains "text field" taping on it will show the keyboard, bottom sheet main buttons should be above the keyboard. --- OsmAnd/res/layout/bottom_sheet_menu_base.xml | 3 ++- OsmAnd/res/layout/send_gpx_fragment.xml | 2 ++ .../dialogs/SendGpxBottomSheetFragment.java | 24 +++++++------------ 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/OsmAnd/res/layout/bottom_sheet_menu_base.xml b/OsmAnd/res/layout/bottom_sheet_menu_base.xml index cb4716cf00..4d62622dd6 100644 --- a/OsmAnd/res/layout/bottom_sheet_menu_base.xml +++ b/OsmAnd/res/layout/bottom_sheet_menu_base.xml @@ -8,7 +8,8 @@ + android:layout_height="0dp" + android:layout_weight="1"> contentHeight) { - scrollView.getLayoutParams().height = contentHeight; + if (contentHeightPrevious != contentHeight && activity != null) { + if (viewHeight + shadowHeight < contentHeight) { + AndroidUtils.setBackground(getView(), getPortraitBg(activity)); } else { - scrollView.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT; + AndroidUtils.setBackground(getView(), getColoredBg(activity)); } scrollView.requestLayout(); - int delay = Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP ? 300 : 1000; - scrollView.postDelayed(new Runnable() { - public void run() { - scrollView.scrollTo(0, scrollView.getHeight()); - } - }, delay); - contentHeightPrevious = contentHeight; } } }; From 5240191d51e8cdc6b5f04d5dee1170f2b0c54f11 Mon Sep 17 00:00:00 2001 From: androiddevkkotlin Date: Wed, 2 Dec 2020 22:13:30 +0200 Subject: [PATCH 02/17] Update SendGpxBottomSheetFragment.java --- .../dialogs/SendGpxBottomSheetFragment.java | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java index 4d2a6e7e73..ca7bf3ec53 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java @@ -30,6 +30,7 @@ import net.osmand.plus.UiUtilities.DialogButtonType; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; +import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter; import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionAdapterListener; import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionItem; @@ -56,7 +57,7 @@ public class SendGpxBottomSheetFragment extends MenuBottomSheetDialogFragment { private TextInputEditText tagsField; private TextInputEditText messageField; - private final int contentHeightPrevious = 0; + private int contentHeightPrevious = 0; public void setGpxInfos(GpxInfo[] gpxInfos) { this.gpxInfos = gpxInfos; @@ -139,17 +140,32 @@ public class SendGpxBottomSheetFragment extends MenuBottomSheetDialogFragment { Activity activity = getActivity(); int buttonsHeight = getResources().getDimensionPixelSize(R.dimen.dialog_button_ex_max_width); int shadowHeight = getResources().getDimensionPixelSize(R.dimen.bottom_sheet_top_shadow_height); + boolean showTopShadow; final ScrollView scrollView = getView().findViewById(R.id.scroll_view); scrollView.getWindowVisibleDisplayFrame(visibleDisplayFrame); int viewHeight = scrollView.getHeight(); int contentHeight = visibleDisplayFrame.bottom - visibleDisplayFrame.top - buttonsHeight; if (contentHeightPrevious != contentHeight && activity != null) { - if (viewHeight + shadowHeight < contentHeight) { - AndroidUtils.setBackground(getView(), getPortraitBg(activity)); - } else { - AndroidUtils.setBackground(getView(), getColoredBg(activity)); - } + showTopShadow = viewHeight + shadowHeight < contentHeight; scrollView.requestLayout(); + contentHeightPrevious = contentHeight; + drawTopShadow(showTopShadow); + } + } + + private void drawTopShadow(boolean showTopShadow) { + final Activity activity = getActivity(); + View mainView = getView(); + if (activity == null || mainView == null) { + return; + } + if (AndroidUiHelper.isOrientationPortrait(activity)) { + AndroidUtils.setBackground(mainView, showTopShadow ? getPortraitBg(activity) : getColoredBg(activity)); + if (!showTopShadow) { + mainView.setPadding(0, 0, 0, 0); + } + } else { + AndroidUtils.setBackground(mainView, showTopShadow ? getLandscapeTopsidesBg(activity) : getLandscapeSidesBg(activity)); } } }; From 1fc03ce50c1fccd024797944274ffd8a3bb4455a Mon Sep 17 00:00:00 2001 From: ssantos Date: Wed, 2 Dec 2020 16:24:07 +0000 Subject: [PATCH 03/17] Translated using Weblate (Portuguese) Currently translated at 100.0% (3574 of 3574 strings) --- OsmAnd/res/values-pt/strings.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/values-pt/strings.xml b/OsmAnd/res/values-pt/strings.xml index 24862b4584..539a28aacc 100644 --- a/OsmAnd/res/values-pt/strings.xml +++ b/OsmAnd/res/values-pt/strings.xml @@ -4002,4 +4002,7 @@ Selecione a imagem Mude para usar dev.openstreetmap.org ao invés de openstreetmap.org para testar enviar uma OSM Nota / POI / GPX. %1$s * %2$s + Alemão (casual) + Pode usar os dados de elevação para considerar a ascensão / descida na sua viagem + Aeronaves ligeiras \ No newline at end of file From 6b89a1f9a69e26ce8fa8955d7abf6cb551f357e6 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 2 Dec 2020 22:46:13 +0000 Subject: [PATCH 04/17] Translated using Weblate (German) Currently translated at 99.9% (3573 of 3574 strings) --- OsmAnd/res/values-de/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index a29f18e979..7bac4c4162 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -4004,4 +4004,6 @@ Bild kann nicht hochgeladen werden, bitte versuchen Sie es später erneut Bild auswählen %1$s * %2$s + Sie können Höhendaten für die Berücksichtigung von Aufstieg / Abstieg auf Ihrer Strecke verwenden + Kleinflugzeug \ No newline at end of file From 714c6e4a6a90fa86d0b7671ecc9d33639ed658c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuz=20Ersen?= Date: Wed, 2 Dec 2020 15:16:34 +0000 Subject: [PATCH 05/17] Translated using Weblate (Turkish) Currently translated at 100.0% (3574 of 3574 strings) --- OsmAnd/res/values-tr/strings.xml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/OsmAnd/res/values-tr/strings.xml b/OsmAnd/res/values-tr/strings.xml index 2b389e2483..97c1941ddd 100644 --- a/OsmAnd/res/values-tr/strings.xml +++ b/OsmAnd/res/values-tr/strings.xml @@ -3543,7 +3543,7 @@ Daire Sekizgen Kare - Min + Asgari Başka bir noktayı bununla değiştirin. Kayak turu Kar arabası @@ -3903,13 +3903,13 @@ Acil Seyahat En az iki nokta eklemelisiniz - OpenStreetMap için oturum aç - OpenStreetMap.org için oturum aç - Yenilikleri veya değişiklikleri karşıya yüklemek için oturum açın, + OpenStreetMap\'te oturum aç + OpenStreetMap.org\'da oturum aç + Yenilikleri veya değişiklikleri karşıya yüklemek için oturum açmanız gerekir. \n -\nOAuth ile oturum açabilir veya kullanıcı adı ve parolanızı kullanabilirsiniz. - Kullanıcı adı ve parola ile oturum aç - Kullanıcı adı +\nGüvenli OAuth yöntemini kullanarak oturum açabilir veya giriş bilgilerinizi ve parolanızı kullanabilirsiniz. + Giriş bilgisi ve parola kullan + Giriş bilgisi Hesap Aboneliği yönet Aboneliğinizle ilgili bir sorun var. Ödeme yönteminizi düzeltmek üzere Google Play abonelik ayarlarına gitmek için düğmeye tıklayın. @@ -3926,11 +3926,11 @@ \"Takip edilebilir\", izlemenin herkese açık herhangi bir listede gösterilmediği, ancak (sizinle doğrudan ilişkilendirilemeyen) zaman damgaları olan işlenen izleme noktalarının herkese açık GPS API\'sinden indirmeler yoluyla göründüğü anlamına gelir. OSM Notunu Kapat OSM Notuna Yorum Yap - Güvenli OAuth yöntemini kullanarak oturum açın veya kullanıcı adınızı ve parolanızı kullanın. + Güvenli OAuth yöntemini kullanarak oturum açabilir veya giriş bilgilerinizi ve parolanızı kullanabilirsiniz. Fotoğraf ekle OpenPlaceReviews.org\'a \nkaydolun - Daha da fazla fotoğraf yüklemek için açık veri projesi web sitesi OpenPlaceReviews.org\'da oturum açın. + Fotoğraflar açık veri projesi OpenPlaceReviews.org tarafından sağlanmaktadır. Fotoğraflarınızı yüklemek için web sitesine kaydolmanız gerekir. Yeni hesap oluştur Zaten bir hesabım var Arama geçmişi @@ -3952,4 +3952,10 @@ İçe aktarılacak ögeleri seçin. OSM Notu/POI/GPX yüklemeyi test etmek için openstreetmap.org yerine dev.openstreetmap.org kullanmaya geçin. dev.openstreetmap.org\'u kullan + Almanca (gündelik) + Resim yüklenemiyor, lütfen daha sonra tekrar deneyin + Resim seç + %1$s * %2$s + Yolculuğunuzun Çıkış / İniş değerleri için Yükseklik verilerini kullanabilirsiniz + Hafif uçak \ No newline at end of file From bcfa975f2a455f37c1d25d85ad4807833a9a78b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Babos=20G=C3=A1bor?= Date: Wed, 2 Dec 2020 15:27:06 +0000 Subject: [PATCH 06/17] Translated using Weblate (Hungarian) Currently translated at 99.9% (3573 of 3574 strings) --- OsmAnd/res/values-hu/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-hu/strings.xml b/OsmAnd/res/values-hu/strings.xml index ec57f089ad..34b05bcc92 100644 --- a/OsmAnd/res/values-hu/strings.xml +++ b/OsmAnd/res/values-hu/strings.xml @@ -3992,4 +3992,6 @@ Kép kijelölése német (tegeződő) %1$s * %2$s + A magassági adatokat az utazás során előforduló emelkedés/lejtés megfontolásához használhatja + Könnyű légi jármű \ No newline at end of file From b05cb42775564f145d4f373c5402df668edd87c0 Mon Sep 17 00:00:00 2001 From: x Date: Wed, 2 Dec 2020 14:08:32 +0000 Subject: [PATCH 07/17] Translated using Weblate (Italian) Currently translated at 89.5% (3201 of 3574 strings) --- OsmAnd/res/values-it/strings.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OsmAnd/res/values-it/strings.xml b/OsmAnd/res/values-it/strings.xml index d5785755cd..cd7ba3fc5b 100644 --- a/OsmAnd/res/values-it/strings.xml +++ b/OsmAnd/res/values-it/strings.xml @@ -3342,7 +3342,7 @@ Impossibile avviare il motore dal-testo-alla-voce. Simula la mia posizione utilizzando una traccia GPX registrata. Utilizzata per stimare l\'orario d\'arrivo per le strade di tipo sconosciute e come limite di velocità per tutte le strade (può influenzare il calcolo del percorso) - Esporta il profilo + Esporta profilo Profilo OsmAnd: %1$s Il profilo \'%1$s\' c\'è già. Sovrascriverlo\? Esportazione del profilo non riuscita. @@ -3389,7 +3389,7 @@ Seleziona il colore Non puoi cancellare i profili preimpostati di OsmAnd, ma puoi disabilitarli nello schermo precedente o spostarli in basso. Modifica il profilo - Il tipo di navigazione influenza le regole di calcolo dei percorsi. + Il \'Tipo di navigazione\' determina il modo in cui vengono calcolati i percorsi. Aspetto del profilo Scegli l\'icona, il colore e il nome Modifica la lista dei profili @@ -3633,7 +3633,7 @@ La guida ai simboli della mappa. Profili di navigazione Tipo non supportato - Il GPX OsmAnd non è ben formattato, per favore contatta il supporto per ulteriori informazioni. + OsmAnd GPX non è ben formato, contatta il team di supporto per approfondire. Sempre Controllo dello schermo Spegni lo schermo dopo il tempo di spegnimento di sistema dello schermo. @@ -3977,7 +3977,7 @@ Immetti le etichette separate dalla virgola. \"Pubblico\" significa che la traccia è visualizzata pubblicamente nelle tue tracce GPS, nelle liste pubbliche di tracce GPS con le informazioni temporali in forma grezza. I dati forniti attraverso le API non conducono alla tua pagina delle tracce. Le informazioni temporali dei punti traccia non sono disponibili attraverso le API GPS pubbliche, e i punti della traccia non sono ordinati cronologicamente. \"Privato\" significa che la traccia non è visualizzabile in alcuna lista pubblica ma i suoi punti, in ordine non cronologico, sono disponibili attraverso le API GPS senza le informazioni temporali. - \"Identificabile\" significa che la traccia è visualizzabile nelle Mie tracce GPS e nelle liste pubbliche, es. gli altri utenti potranno scaricare la traccia grezza e associarla con il tuo nome utente. I punti della traccia, con le loro informazioni temporali, saranno riconducibili, attraverso le API GPS, alla tua traccia originale. + \"Identificabile\" significa che la traccia è visualizzabile nelle Mie tracce GPS e nelle liste pubbliche, ad es. gli altri utenti potranno scaricare la traccia grezza e associarla con il tuo nome utente. I punti della traccia, con le loro informazioni temporali, saranno riconducibili, attraverso le API GPS, alla tua traccia originale. \"Tracciabile\" significa che la traccia non è visualizzabile in alcuna lista pubblica, ma solo i suoi punti, processati, con le informazioni temporali (che non possono essere direttamente associati a te) attraverso le API GPS pubbliche. Aggiungi a Mapillary Aggiungi a OpenPlaceReviews From 3ac692265500d27bcb2d3caba54fd9ae97a15e39 Mon Sep 17 00:00:00 2001 From: jan madsen Date: Wed, 2 Dec 2020 19:14:17 +0000 Subject: [PATCH 08/17] Translated using Weblate (Danish) Currently translated at 93.2% (3332 of 3574 strings) --- OsmAnd/res/values-da/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-da/strings.xml b/OsmAnd/res/values-da/strings.xml index d5278f0b53..1267fcdc3e 100644 --- a/OsmAnd/res/values-da/strings.xml +++ b/OsmAnd/res/values-da/strings.xml @@ -3861,4 +3861,6 @@ Vælg emner, der skal importeres. Skift til dev.openstreetmap.org i stedet for openstreetmap.org for at teste overførelse af OSM-note / IP / GPX. Brug dev.openstreetmap.org + Kan ikke overføre billedet, prøv igen senere + Vælg billede \ No newline at end of file From fbeb493972008816f8bb3b8b7ee6e4754c892fe8 Mon Sep 17 00:00:00 2001 From: Ahmad Alfrhood Date: Wed, 2 Dec 2020 10:00:57 +0000 Subject: [PATCH 09/17] Translated using Weblate (Arabic) Currently translated at 100.0% (3574 of 3574 strings) --- OsmAnd/res/values-ar/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-ar/strings.xml b/OsmAnd/res/values-ar/strings.xml index e4937c35f5..f2ce63b2ed 100644 --- a/OsmAnd/res/values-ar/strings.xml +++ b/OsmAnd/res/values-ar/strings.xml @@ -3988,4 +3988,6 @@ تحديد صورة %1$s * %2$s الألمانية (تقليدية) + يمكنك استخدام بيانات الارتفاع للنظر في الصعود / الهبوط لرحلتك + طائرة \ No newline at end of file From 16bb79f31672b0d884d2d5b2f346c99fd107625a Mon Sep 17 00:00:00 2001 From: Eduardo Addad de Oliveira Date: Wed, 2 Dec 2020 20:52:19 +0000 Subject: [PATCH 10/17] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (3574 of 3574 strings) --- OsmAnd/res/values-pt-rBR/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-pt-rBR/strings.xml b/OsmAnd/res/values-pt-rBR/strings.xml index 408aa0149c..9e353d63cb 100644 --- a/OsmAnd/res/values-pt-rBR/strings.xml +++ b/OsmAnd/res/values-pt-rBR/strings.xml @@ -3996,4 +3996,6 @@ Selecione a foto %1$s * %2$s Alemão (casual) + Você pode usar os dados de elevação para consideração de subida / descida para sua viagem + Avião leve \ No newline at end of file From 88925a6244eb5930a2087940961082f9c32c710f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuz=20Ersen?= Date: Wed, 2 Dec 2020 15:20:33 +0000 Subject: [PATCH 11/17] Translated using Weblate (Turkish) Currently translated at 80.9% (3124 of 3860 strings) --- OsmAnd/res/values-tr/phrases.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/values-tr/phrases.xml b/OsmAnd/res/values-tr/phrases.xml index 8489842899..9e98900756 100644 --- a/OsmAnd/res/values-tr/phrases.xml +++ b/OsmAnd/res/values-tr/phrases.xml @@ -3132,4 +3132,7 @@ Gölet Konsolosluk Büyük elçilik + Vatandaş hizmetleri + Göçmen vizeleri + Göçmen olmayan vizeleri \ No newline at end of file From 60b9cbd91f7eac15d814dd58eb8032b401aa07d2 Mon Sep 17 00:00:00 2001 From: androiddevkkotlin Date: Thu, 3 Dec 2020 12:03:23 +0200 Subject: [PATCH 12/17] Refactor --- .../base/MenuBottomSheetDialogFragment.java | 25 +++++++++----- .../dialogs/SendGpxBottomSheetFragment.java | 33 +++++-------------- .../VehicleParametersBottomSheet.java | 32 +++++------------- 3 files changed, 33 insertions(+), 57 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java index 84bd292aa5..71192fafe6 100644 --- a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java @@ -187,18 +187,27 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra // 8dp is the shadow height boolean showTopShadow = screenHeight - statusBarHeight - mainView.getHeight() >= AndroidUtils.dpToPx(activity, 8); - if (AndroidUiHelper.isOrientationPortrait(activity)) { - AndroidUtils.setBackground(mainView, showTopShadow ? getPortraitBg(activity) : getColoredBg(activity)); - if (!showTopShadow) { - mainView.setPadding(0, 0, 0, 0); - } - } else { - AndroidUtils.setBackground(mainView, showTopShadow ? getLandscapeTopsidesBg(activity) : getLandscapeSidesBg(activity)); - } + drawTopShadow(showTopShadow); } }); } + protected void drawTopShadow(boolean showTopShadow) { + final Activity activity = getActivity(); + View mainView = getView(); + if (activity == null || mainView == null) { + return; + } + if (AndroidUiHelper.isOrientationPortrait(activity)) { + AndroidUtils.setBackground(mainView, showTopShadow ? getPortraitBg(activity) : getColoredBg(activity)); + if (!showTopShadow) { + mainView.setPadding(0, 0, 0, 0); + } + } else { + AndroidUtils.setBackground(mainView, showTopShadow ? getLandscapeTopsidesBg(activity) : getLandscapeSidesBg(activity)); + } + } + private int getContentHeight(int availableScreenHeight) { int customHeight = getCustomHeight(); int buttonsHeight; diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java index ca7bf3ec53..759f924d10 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java @@ -1,6 +1,5 @@ package net.osmand.plus.osmedit.dialogs; -import android.app.Activity; import android.graphics.Rect; import android.os.AsyncTask; import android.os.Bundle; @@ -22,7 +21,6 @@ import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.textfield.TextInputEditText; -import net.osmand.AndroidUtils; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; @@ -30,7 +28,6 @@ import net.osmand.plus.UiUtilities.DialogButtonType; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; -import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter; import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionAdapterListener; import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionItem; @@ -58,6 +55,9 @@ public class SendGpxBottomSheetFragment extends MenuBottomSheetDialogFragment { private TextInputEditText tagsField; private TextInputEditText messageField; private int contentHeightPrevious = 0; + private int buttonsHeight; + private int shadowHeight; + private ScrollView scrollView; public void setGpxInfos(GpxInfo[] gpxInfos) { this.gpxInfos = gpxInfos; @@ -137,37 +137,20 @@ public class SendGpxBottomSheetFragment extends MenuBottomSheetDialogFragment { @Override public void onGlobalLayout() { Rect visibleDisplayFrame = new Rect(); - Activity activity = getActivity(); - int buttonsHeight = getResources().getDimensionPixelSize(R.dimen.dialog_button_ex_max_width); - int shadowHeight = getResources().getDimensionPixelSize(R.dimen.bottom_sheet_top_shadow_height); - boolean showTopShadow; - final ScrollView scrollView = getView().findViewById(R.id.scroll_view); + buttonsHeight = getResources().getDimensionPixelSize(R.dimen.dialog_button_ex_max_width); + shadowHeight = getResources().getDimensionPixelSize(R.dimen.bottom_sheet_top_shadow_height); + scrollView = getView().findViewById(R.id.scroll_view); scrollView.getWindowVisibleDisplayFrame(visibleDisplayFrame); int viewHeight = scrollView.getHeight(); int contentHeight = visibleDisplayFrame.bottom - visibleDisplayFrame.top - buttonsHeight; - if (contentHeightPrevious != contentHeight && activity != null) { + if (contentHeightPrevious != contentHeight) { + boolean showTopShadow; showTopShadow = viewHeight + shadowHeight < contentHeight; scrollView.requestLayout(); contentHeightPrevious = contentHeight; drawTopShadow(showTopShadow); } } - - private void drawTopShadow(boolean showTopShadow) { - final Activity activity = getActivity(); - View mainView = getView(); - if (activity == null || mainView == null) { - return; - } - if (AndroidUiHelper.isOrientationPortrait(activity)) { - AndroidUtils.setBackground(mainView, showTopShadow ? getPortraitBg(activity) : getColoredBg(activity)); - if (!showTopShadow) { - mainView.setPadding(0, 0, 0, 0); - } - } else { - AndroidUtils.setBackground(mainView, showTopShadow ? getLandscapeTopsidesBg(activity) : getLandscapeSidesBg(activity)); - } - } }; } diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/VehicleParametersBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/VehicleParametersBottomSheet.java index b3f160f910..8f4b4b4181 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/VehicleParametersBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/VehicleParametersBottomSheet.java @@ -1,7 +1,6 @@ package net.osmand.plus.settings.bottomsheets; import android.annotation.SuppressLint; -import android.app.Activity; import android.graphics.Rect; import android.os.Build; import android.os.Bundle; @@ -23,13 +22,11 @@ import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.recyclerview.widget.RecyclerView; -import net.osmand.AndroidUtils; import net.osmand.PlatformUtil; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; -import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.fragments.ApplyQueryType; @@ -52,6 +49,9 @@ public class VehicleParametersBottomSheet extends BasePreferenceBottomSheet { private float currentValue; private int contentHeightPrevious = 0; private EditText text; + private int buttonsHeight; + private int shadowHeight; + private ScrollView scrollView; @Override public void createMenuItems(Bundle savedInstanceState) { @@ -164,13 +164,13 @@ public class VehicleParametersBottomSheet extends BasePreferenceBottomSheet { @Override public void onGlobalLayout() { Rect visibleDisplayFrame = new Rect(); - int buttonsHeight = getResources().getDimensionPixelSize(R.dimen.dialog_button_ex_height); - int shadowHeight = getResources().getDimensionPixelSize(R.dimen.bottom_sheet_top_shadow_height); - final ScrollView scrollView = getView().findViewById(R.id.scroll_view); + buttonsHeight = getResources().getDimensionPixelSize(R.dimen.dialog_button_ex_height); + shadowHeight = getResources().getDimensionPixelSize(R.dimen.bottom_sheet_top_shadow_height); + scrollView = getView().findViewById(R.id.scroll_view); scrollView.getWindowVisibleDisplayFrame(visibleDisplayFrame); - boolean showTopShadow; int contentHeight = visibleDisplayFrame.bottom - visibleDisplayFrame.top - buttonsHeight; if (contentHeightPrevious != contentHeight) { + boolean showTopShadow; if (scrollView.getHeight() + shadowHeight > contentHeight) { scrollView.getLayoutParams().height = contentHeight; showTopShadow = false; @@ -189,22 +189,6 @@ public class VehicleParametersBottomSheet extends BasePreferenceBottomSheet { drawTopShadow(showTopShadow); } } - - private void drawTopShadow(boolean showTopShadow) { - final Activity activity = getActivity(); - View mainView = getView(); - if (activity == null || mainView == null) { - return; - } - if (AndroidUiHelper.isOrientationPortrait(activity)) { - AndroidUtils.setBackground(mainView, showTopShadow ? getPortraitBg(activity) : getColoredBg(activity)); - if (!showTopShadow) { - mainView.setPadding(0, 0, 0, 0); - } - } else { - AndroidUtils.setBackground(mainView, showTopShadow ? getLandscapeTopsidesBg(activity) : getLandscapeSidesBg(activity)); - } - } }; } @@ -225,7 +209,7 @@ public class VehicleParametersBottomSheet extends BasePreferenceBottomSheet { } public static void showInstance(@NonNull FragmentManager fm, String key, Fragment target, - boolean usedOnMap, @Nullable ApplicationMode appMode) { + boolean usedOnMap, @Nullable ApplicationMode appMode) { try { if (!fm.isStateSaved()) { Bundle args = new Bundle(); From 161d0dcd5b8fad5c83181af851ade3ce24147d9b Mon Sep 17 00:00:00 2001 From: PaulStets Date: Thu, 3 Dec 2020 14:51:40 +0200 Subject: [PATCH 13/17] Fixed duplication of osm notes/edits with import --- .../plus/osmedit/OpenstreetmapPoint.java | 42 +++++++++++++++++++ .../osmand/plus/osmedit/OsmNotesPoint.java | 29 +++++++++++++ .../backend/backup/OsmEditsSettingsItem.java | 28 ++++++++----- .../backend/backup/OsmNotesSettingsItem.java | 30 +++++++++---- 4 files changed, 111 insertions(+), 18 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java index d7c17c1ec2..43749ca019 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java @@ -1,5 +1,8 @@ package net.osmand.plus.osmedit; +import com.google.protobuf.Message; + +import net.osmand.data.LatLon; import net.osmand.osm.edit.Entity; import net.osmand.osm.edit.OSMSettings.OSMTagKey; import net.osmand.util.Algorithms; @@ -97,4 +100,43 @@ public class OpenstreetmapPoint extends OsmPoint { .append(" (").append(this.getLatitude()).append(", ").append(this.getLongitude()) .append(")]").toString(); } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if (!(other instanceof OpenstreetmapPoint)) { + return false; + } + OpenstreetmapPoint otherPoint = (OpenstreetmapPoint) other; + boolean res = this.getName() != null && this.getName().equals(otherPoint.getName()); + LatLon thisLatLon = new LatLon(this.getLatitude(), this.getLongitude()); + LatLon otherLatLon = new LatLon(otherPoint.getLatitude(), otherPoint.getLongitude()); + res = res || thisLatLon.equals(otherLatLon); + if (getType() != null) + res = res || getType().equals(otherPoint.getType()); + if (getSubtype() != null) + res = res || getSubtype().equals(otherPoint.getSubtype()); + if (getTagsString() != null) + res = res || getTagsString().equals(otherPoint.getTagsString()); + res = res || getId() == otherPoint.getId(); + return res; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 0; + int temp; + temp = (int) Math.floor(getLatitude() * 10000); + result = prime * result + temp; + temp = (int) Math.floor(getLongitude() * 10000); + result = prime * result + temp; + result = prime * result + (getType() != null ? getType().hashCode() : 0); + result = prime * result + (getSubtype() != null ? getSubtype().hashCode() : 0); + result = prime * result + (getTagsString() != null ? getTagsString().hashCode() : 0); + result = prime * result + Long.valueOf(getId()).hashCode(); + return result; + } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesPoint.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesPoint.java index da72273750..e26b47f97e 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesPoint.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesPoint.java @@ -1,5 +1,9 @@ package net.osmand.plus.osmedit; +import net.osmand.data.LatLon; + +import java.util.Objects; + public class OsmNotesPoint extends OsmPoint { private static final long serialVersionUID = 729654300829771468L; @@ -68,4 +72,29 @@ public class OsmNotesPoint extends OsmPoint { .append(" (").append(this.getLatitude()).append(", ").append(this.getLongitude()) .append(")]").toString(); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof OsmNotesPoint)) return false; + OsmNotesPoint that = (OsmNotesPoint) o; + LatLon thisPos = new LatLon(latitude, longitude); + LatLon thatPos = new LatLon(that.latitude, that.longitude); + boolean res = thisPos.equals(thatPos); + res = res || text != null && text.equals(that.text); + return res; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 0; + int temp; + temp = (int) Math.floor(latitude * 10000); + result = prime * result + temp; + temp = (int) Math.floor(longitude * 10000); + result = prime * result + temp; + result = prime * result + (text != null ? text.hashCode() : 0); + return result; + } } diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java index 287f6dc9de..d97f8f6c8f 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/OsmEditsSettingsItem.java @@ -74,22 +74,25 @@ public class OsmEditsSettingsItem extends CollectionSettingsItem(newItems); - for (OpenstreetmapPoint duplicate : duplicateItems) { - appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate)); - } - } - OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); - if (osmEditingPlugin != null) { - OpenstreetmapsDbHelper db = osmEditingPlugin.getDBPOI(); - for (OpenstreetmapPoint point : appliedItems) { - db.addOpenstreetmap(point); + OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); + if (osmEditingPlugin != null) { + OpenstreetmapsDbHelper db = osmEditingPlugin.getDBPOI(); + for (OpenstreetmapPoint duplicate : duplicateItems) { + db.deletePOI(duplicate); + db.addOpenstreetmap(duplicate); + } + for (OpenstreetmapPoint point : appliedItems) { + db.addOpenstreetmap(point); + } } + + } } @Override public boolean isDuplicate(@NonNull OpenstreetmapPoint item) { - return false; + return existingItems.contains(item); } @NonNull @@ -115,6 +118,11 @@ public class OsmEditsSettingsItem extends CollectionSettingsItem { - public static final String ID_KEY = "id"; public static final String TEXT_KEY = "text"; public static final String LAT_KEY = "lat"; public static final String LON_KEY = "lon"; @@ -63,12 +62,20 @@ public class OsmNotesSettingsItem extends CollectionSettingsItem if (!newItems.isEmpty() || !duplicateItems.isEmpty()) { appliedItems = new ArrayList<>(newItems); - for (OsmNotesPoint duplicate : duplicateItems) { - appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate)); - } OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); if (osmEditingPlugin != null) { OsmBugsDbHelper db = osmEditingPlugin.getDBBug(); + for (OsmNotesPoint duplicate : duplicateItems) { + int ind = existingItems.indexOf(duplicate); + if (ind != -1 && ind < existingItems.size()) { + OsmNotesPoint original = existingItems.get(ind); + if (original != null) { + db.deleteAllBugModifications(original); + } + db.addOsmbugs(duplicate); + } + } + for (OsmNotesPoint point : appliedItems) { db.addOsmbugs(point); } @@ -78,7 +85,7 @@ public class OsmNotesSettingsItem extends CollectionSettingsItem @Override public boolean isDuplicate(@NonNull OsmNotesPoint item) { - return false; + return existingItems.contains(item); } @NonNull @@ -104,16 +111,23 @@ public class OsmNotesSettingsItem extends CollectionSettingsItem return true; } + @Override + public boolean shouldShowDuplicates() { + return false; + } + @Override void readItemsFromJson(@NonNull JSONObject json) throws IllegalArgumentException { try { if (!json.has("items")) { return; } + OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); + long minId = osmEditingPlugin != null ? osmEditingPlugin.getDBBug().getMinID() - 1 : -2; + int idOffset = 0; JSONArray jsonArray = json.getJSONArray("items"); for (int i = 0; i < jsonArray.length(); i++) { JSONObject object = jsonArray.getJSONObject(i); - long id = object.getLong(ID_KEY); String text = object.optString(TEXT_KEY); double lat = object.getDouble(LAT_KEY); double lon = object.getDouble(LON_KEY); @@ -121,13 +135,14 @@ public class OsmNotesSettingsItem extends CollectionSettingsItem author = author.isEmpty() ? null : author; String action = object.getString(ACTION_KEY); OsmNotesPoint point = new OsmNotesPoint(); - point.setId(id); + point.setId(Math.min(-2, minId - idOffset)); point.setText(text); point.setLatitude(lat); point.setLongitude(lon); point.setAuthor(author); point.setAction(action); items.add(point); + idOffset++; } } catch (JSONException e) { warnings.add(app.getString(R.string.settings_item_read_error, String.valueOf(getType()))); @@ -142,7 +157,6 @@ public class OsmNotesSettingsItem extends CollectionSettingsItem try { for (OsmNotesPoint point : items) { JSONObject jsonObject = new JSONObject(); - jsonObject.put(ID_KEY, point.getId()); jsonObject.put(TEXT_KEY, point.getText()); jsonObject.put(LAT_KEY, point.getLatitude()); jsonObject.put(LON_KEY, point.getLongitude()); From 412cf1fca8be457e45c820a6f25b56b40c205a74 Mon Sep 17 00:00:00 2001 From: PaulStets Date: Thu, 3 Dec 2020 14:53:06 +0200 Subject: [PATCH 14/17] Fixed extra import --- OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java index 43749ca019..c2fb1ac98e 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java @@ -1,7 +1,5 @@ package net.osmand.plus.osmedit; -import com.google.protobuf.Message; - import net.osmand.data.LatLon; import net.osmand.osm.edit.Entity; import net.osmand.osm.edit.OSMSettings.OSMTagKey; From d111a1fd2b72265703fbd9d5004f81066ccfb44d Mon Sep 17 00:00:00 2001 From: PaulStets Date: Thu, 3 Dec 2020 14:54:14 +0200 Subject: [PATCH 15/17] Fixed extra import --- OsmAnd/src/net/osmand/plus/osmedit/OsmNotesPoint.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesPoint.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesPoint.java index e26b47f97e..9275143cec 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesPoint.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesPoint.java @@ -2,8 +2,6 @@ package net.osmand.plus.osmedit; import net.osmand.data.LatLon; -import java.util.Objects; - public class OsmNotesPoint extends OsmPoint { private static final long serialVersionUID = 729654300829771468L; From c091fb6cc0b23864cf6aa9f1163e7ac7dae59ab6 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Thu, 3 Dec 2020 18:15:16 +0300 Subject: [PATCH 16/17] Fix saving straight lines while planning route --- .../MeasurementEditingContext.java | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java index 3563ab77a6..6c3411b004 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java @@ -281,24 +281,23 @@ public class MeasurementEditingContext { } public boolean isApproximationNeeded() { - boolean hasDefaultPoints = false; + boolean hasDefaultPointsOnly = false; boolean newData = isNewData(); if (!newData) { List points = getPoints(); - WptPt prevPoint = null; + hasDefaultPointsOnly = true; for (WptPt point : points) { - if (!point.hasProfile() && (prevPoint == null || !prevPoint.hasProfile())) { - hasDefaultPoints = true; + if (point.hasProfile()) { + hasDefaultPointsOnly = false; break; } - prevPoint = point; } } - return !newData && hasDefaultPoints && getPoints().size() > 2; + return !newData && hasDefaultPointsOnly && getPoints().size() > 2; } public boolean isSelectionNeedApproximation() { - boolean hasDefaultPoints = false; + boolean hasDefaultPointsOnly = false; boolean newData = isNewData(); if (!newData && selectedPointPosition != -1) { WptPt selectedPoint = getPoints().get(selectedPointPosition); @@ -309,18 +308,17 @@ public class MeasurementEditingContext { points = segment.points; } } - WptPt prevPoint = null; - if (points != null) { + if (!Algorithms.isEmpty(points)) { + hasDefaultPointsOnly = true; for (WptPt point : points) { - if (!point.hasProfile() && (prevPoint == null || !prevPoint.hasProfile())) { - hasDefaultPoints = true; + if (point.hasProfile()) { + hasDefaultPointsOnly = false; break; } - prevPoint = point; } } } - return !newData && hasDefaultPoints && getPoints().size() > 2; + return !newData && hasDefaultPointsOnly && getPoints().size() > 2; } public void clearSnappedToRoadPoints() { @@ -625,7 +623,7 @@ public class MeasurementEditingContext { WptPt startPoint = points.get(i); WptPt endPoint = points.get(i + 1); Pair pair = new Pair<>(startPoint, endPoint); - if (roadSegmentData.get(pair) == null && startPoint.hasProfile()) { + if (roadSegmentData.get(pair) == null && (startPoint.hasProfile() || hasRoute())) { res.add(pair); } } From 992d0654b6b7967e2db4b4b76c330382c9f1e0d6 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Thu, 3 Dec 2020 18:12:04 +0200 Subject: [PATCH 17/17] Fix ru string --- OsmAnd/res/values-ru/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index 25e450c5d3..698a7c2e76 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -3954,7 +3954,7 @@ Вход в OpenStreetMap.org Войти через OpenStreetMap Аккаунт - Пользователь + Авторизоваться Управление подпиской Срок действия подписки OsmAnd Live истёк Подписка OsmAnd Live была приостановлена