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"> تحديد صورة %1$s * %2$s الألمانية (تقليدية) + يمكنك استخدام بيانات الارتفاع للنظر في الصعود / الهبوط لرحلتك + طائرة \ No newline at end of file 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 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 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 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 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 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 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 была приостановлена 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 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 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/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); } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java index d7c17c1ec2..c2fb1ac98e 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java @@ -1,5 +1,6 @@ package net.osmand.plus.osmedit; +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 +98,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..9275143cec 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesPoint.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesPoint.java @@ -1,5 +1,7 @@ package net.osmand.plus.osmedit; +import net.osmand.data.LatLon; + public class OsmNotesPoint extends OsmPoint { private static final long serialVersionUID = 729654300829771468L; @@ -68,4 +70,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/osmedit/dialogs/SendGpxBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java index ecf089c0b1..759f924d10 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendGpxBottomSheetFragment.java @@ -2,12 +2,10 @@ package net.osmand.plus.osmedit.dialogs; import android.graphics.Rect; import android.os.AsyncTask; -import android.os.Build; import android.os.Bundle; import android.text.Editable; import android.view.LayoutInflater; import android.view.View; -import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.widget.LinearLayout; import android.widget.ScrollView; @@ -57,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; @@ -136,26 +137,18 @@ public class SendGpxBottomSheetFragment extends MenuBottomSheetDialogFragment { @Override public void onGlobalLayout() { Rect visibleDisplayFrame = new Rect(); - int buttonsHeight = getResources().getDimensionPixelSize(R.dimen.dialog_button_ex_max_width); - 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_max_width); + shadowHeight = getResources().getDimensionPixelSize(R.dimen.bottom_sheet_top_shadow_height); + scrollView = getView().findViewById(R.id.scroll_view); scrollView.getWindowVisibleDisplayFrame(visibleDisplayFrame); - int height = scrollView.getHeight(); + int viewHeight = scrollView.getHeight(); int contentHeight = visibleDisplayFrame.bottom - visibleDisplayFrame.top - buttonsHeight; - if (contentHeightPrevious != contentHeight || contentHeight < height) { - if (scrollView.getHeight() + shadowHeight > contentHeight) { - scrollView.getLayoutParams().height = contentHeight; - } else { - scrollView.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT; - } + if (contentHeightPrevious != contentHeight) { + boolean showTopShadow; + showTopShadow = viewHeight + shadowHeight < contentHeight; 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; + drawTopShadow(showTopShadow); } } }; 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()); 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();