From f1569fd5fb8c05939869df897fed5cae435389fb Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Sun, 24 Jan 2021 23:48:41 +0200 Subject: [PATCH 001/125] Travel GPX card --- .../main/java/net/osmand/data/Amenity.java | 4 + .../res/layout/wikivoyage_travel_gpx_card.xml | 242 ++++++++++++++++++ .../plus/wikivoyage/data/TravelGpx.java | 8 + .../wikivoyage/explore/ExploreRvAdapter.java | 13 +- .../explore/ExploreTabFragment.java | 8 +- .../explore/travelcards/TravelGpxCard.java | 120 +++++++++ 6 files changed, 392 insertions(+), 3 deletions(-) create mode 100644 OsmAnd/res/layout/wikivoyage_travel_gpx_card.xml create mode 100644 OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelGpx.java create mode 100644 OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java diff --git a/OsmAnd-java/src/main/java/net/osmand/data/Amenity.java b/OsmAnd-java/src/main/java/net/osmand/data/Amenity.java index 3ef6a54652..959669a665 100644 --- a/OsmAnd-java/src/main/java/net/osmand/data/Amenity.java +++ b/OsmAnd-java/src/main/java/net/osmand/data/Amenity.java @@ -273,6 +273,10 @@ public class Amenity extends MapObject { return null; } + public String getTagContent(String tag) { + return getTagContent(tag, null); + } + public String getTagContent(String tag, String lang) { if (lang != null) { String translateName = getAdditionalInfo(tag + ":" + lang); diff --git a/OsmAnd/res/layout/wikivoyage_travel_gpx_card.xml b/OsmAnd/res/layout/wikivoyage_travel_gpx_card.xml new file mode 100644 index 0000000000..eb97f02c0b --- /dev/null +++ b/OsmAnd/res/layout/wikivoyage_travel_gpx_card.xml @@ -0,0 +1,242 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelGpx.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelGpx.java new file mode 100644 index 0000000000..8393ec98a6 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelGpx.java @@ -0,0 +1,8 @@ +package net.osmand.plus.wikivoyage.data; + +public class TravelGpx extends TravelArticle { + public String user; + public float totalDistance = 0; + public double diffElevationUp = 0; + public double diffElevationDown = 0; +} diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java index a95614bdb8..5341edcb9d 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java @@ -20,6 +20,8 @@ import net.osmand.plus.wikivoyage.explore.travelcards.StartEditingTravelCard; import net.osmand.plus.wikivoyage.explore.travelcards.StartEditingTravelCard.StartEditingTravelVH; import net.osmand.plus.wikivoyage.explore.travelcards.TravelDownloadUpdateCard; import net.osmand.plus.wikivoyage.explore.travelcards.TravelDownloadUpdateCard.DownloadUpdateVH; +import net.osmand.plus.wikivoyage.explore.travelcards.TravelGpxCard; +import net.osmand.plus.wikivoyage.explore.travelcards.TravelGpxCard.TravelGpxVH; import net.osmand.plus.wikivoyage.explore.travelcards.TravelNeededMapsCard; import net.osmand.plus.wikivoyage.explore.travelcards.TravelNeededMapsCard.NeededMapsVH; @@ -48,6 +50,9 @@ public class ExploreRvAdapter extends RecyclerView.Adapter 0; i--) { BaseTravelCard o = items.get(i); - if (o instanceof ArticleTravelCard) { + if (o instanceof ArticleTravelCard || o instanceof TravelGpxCard) { return i; } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java index c53027fb7a..ae6b0cace7 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java @@ -28,6 +28,7 @@ import net.osmand.plus.download.DownloadResources; import net.osmand.plus.download.DownloadValidationManager; import net.osmand.plus.download.IndexItem; import net.osmand.plus.wikivoyage.data.TravelArticle; +import net.osmand.plus.wikivoyage.data.TravelGpx; import net.osmand.plus.wikivoyage.data.TravelHelper; import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; import net.osmand.plus.wikivoyage.explore.travelcards.ArticleTravelCard; @@ -36,6 +37,7 @@ import net.osmand.plus.wikivoyage.explore.travelcards.HeaderTravelCard; import net.osmand.plus.wikivoyage.explore.travelcards.OpenBetaTravelCard; import net.osmand.plus.wikivoyage.explore.travelcards.StartEditingTravelCard; import net.osmand.plus.wikivoyage.explore.travelcards.TravelDownloadUpdateCard; +import net.osmand.plus.wikivoyage.explore.travelcards.TravelGpxCard; import net.osmand.plus.wikivoyage.explore.travelcards.TravelNeededMapsCard; import java.io.IOException; @@ -183,7 +185,11 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv List popularArticles = app.getTravelHelper().getPopularArticles(); for (TravelArticle article : popularArticles) { - items.add(new ArticleTravelCard(app, nightMode, article, fm)); + if (article instanceof TravelGpx) { + items.add(new TravelGpxCard(app, nightMode, (TravelGpx) article, fm)); + } else { + items.add(new ArticleTravelCard(app, nightMode, article, fm)); + } } } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java new file mode 100644 index 0000000000..32790cc094 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java @@ -0,0 +1,120 @@ +package net.osmand.plus.wikivoyage.explore.travelcards; + +import android.graphics.drawable.Drawable; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.FragmentManager; +import androidx.recyclerview.widget.RecyclerView; + +import net.osmand.plus.OsmAndFormatter; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.wikipedia.WikiArticleHelper; +import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment; +import net.osmand.plus.wikivoyage.data.TravelGpx; +import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; + +public class TravelGpxCard extends BaseTravelCard { + + public static final int TYPE = 3; + + private final TravelGpx article; + private final Drawable readIcon; + private final FragmentManager fragmentManager; + private boolean isLastItem; + + public TravelGpxCard(@NonNull OsmandApplication app, boolean nightMode, @NonNull TravelGpx article, + @NonNull FragmentManager fragmentManager) { + super(app, nightMode); + this.article = article; + readIcon = getActiveIcon(R.drawable.ic_action_read_article); + this.fragmentManager = fragmentManager; + } + + @Override + public void bindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder) { + if (viewHolder instanceof TravelGpxVH) { + final TravelGpxVH holder = (TravelGpxVH) viewHolder; + holder.title.setText(article.getTitle()); + holder.content.setText(WikiArticleHelper.getPartialContent(article.getContent())); + holder.distance.setText(OsmAndFormatter.getFormattedDistance(article.totalDistance,app)); + holder.diffElevationUp.setText(OsmAndFormatter.getFormattedAlt(article.diffElevationUp,app)); + holder.diffElevationDown.setText(OsmAndFormatter.getFormattedAlt(article.diffElevationDown,app)); + holder.leftButton.setText(app.getString(R.string.shared_string_view)); + View.OnClickListener readClickListener = new View.OnClickListener() { + @Override + public void onClick(View v) { + if (fragmentManager != null) { + WikivoyageArticleDialogFragment.showInstance(app, fragmentManager, + article.generateIdentifier(), article.getLang()); + } + } + }; + holder.leftButton.setOnClickListener(readClickListener); + holder.itemView.setOnClickListener(readClickListener); + holder.leftButton.setCompoundDrawablesWithIntrinsicBounds(readIcon, null, null, null); + updateSaveButton(holder); + holder.divider.setVisibility(isLastItem ? View.GONE : View.VISIBLE); + holder.shadow.setVisibility(isLastItem ? View.VISIBLE : View.GONE); + } + } + + private void updateSaveButton(final TravelGpxVH holder) { + if (article != null) { + final TravelLocalDataHelper helper = app.getTravelHelper().getBookmarksHelper(); + final boolean saved = helper.isArticleSaved(article); + Drawable icon = getActiveIcon(saved ? R.drawable.ic_action_read_later_fill : R.drawable.ic_action_read_later); + holder.rightButton.setText(saved ? R.string.shared_string_remove : R.string.shared_string_save); + holder.rightButton.setCompoundDrawablesWithIntrinsicBounds(null, null, icon, null); + holder.rightButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (saved) { + helper.removeArticleFromSaved(article); + } else { + app.getTravelHelper().createGpxFile(article); + helper.addArticleToSaved(article); + } + updateSaveButton(holder); + } + }); + } + } + + public static class TravelGpxVH extends RecyclerView.ViewHolder { + + final TextView title; + final TextView content; + final TextView distance; + final TextView diffElevationUp; + final TextView diffElevationDown; + final TextView leftButton; + final TextView rightButton; + final View divider; + final View shadow; + + public TravelGpxVH(final View itemView) { + super(itemView); + title = itemView.findViewById(R.id.title); + content = itemView.findViewById(R.id.content); + distance = itemView.findViewById(R.id.distance); + diffElevationUp = itemView.findViewById(R.id.diff_ele_up); + diffElevationDown = itemView.findViewById(R.id.diff_ele_down); + leftButton = itemView.findViewById(R.id.left_button); + rightButton = itemView.findViewById(R.id.right_button); + divider = itemView.findViewById(R.id.divider); + shadow = itemView.findViewById(R.id.shadow); + } + } + + public void setLastItem(boolean lastItem) { + isLastItem = lastItem; + } + + @Override + public int getCardType() { + return TYPE; + } +} From 0f0a41283d46c3aa94535f009f0dbe156d7ca21e Mon Sep 17 00:00:00 2001 From: Dmitry Date: Mon, 25 Jan 2021 14:55:52 +0200 Subject: [PATCH 002/125] Added icon: user account 16dp --- .../res/drawable/ic_action_user_account_16.xml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 OsmAnd/res/drawable/ic_action_user_account_16.xml diff --git a/OsmAnd/res/drawable/ic_action_user_account_16.xml b/OsmAnd/res/drawable/ic_action_user_account_16.xml new file mode 100644 index 0000000000..f05533e018 --- /dev/null +++ b/OsmAnd/res/drawable/ic_action_user_account_16.xml @@ -0,0 +1,17 @@ + + + + + From 184923e877b73fc6456b5fa07e177eb294dfad0b Mon Sep 17 00:00:00 2001 From: vshcherb Date: Mon, 25 Jan 2021 15:15:12 +0100 Subject: [PATCH 003/125] Update no_translate.xml --- OsmAnd/no_translate.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/no_translate.xml b/OsmAnd/no_translate.xml index d8e4108d4a..c52342f9ab 100644 --- a/OsmAnd/no_translate.xml +++ b/OsmAnd/no_translate.xml @@ -40,7 +40,7 @@ items modified OsmAnd Unlimited Markers - https://test.openplacereviews.org/ + https://openplacereviews.org/ v8G8r9NLJZGMV4he5lwbQlz620FNVARKjI9Bm5UJ jDvM95Ne1Bq2BDTmIfB6b3ZMxvdK87WGfp6DC07J Ti2qq3fo4i4Wmuox3SiWRIGq3obZisBHnxmcM05y From 046ea91b3adcb7d57965a45949543454a3511dca Mon Sep 17 00:00:00 2001 From: cepprice Date: Mon, 25 Jan 2021 19:17:55 +0500 Subject: [PATCH 004/125] Fix #10565 --- .../net/osmand/plus/osmedit/OpenstreetmapPoint.java | 10 +++++----- OsmAnd/src/net/osmand/plus/osmedit/OsmNotesPoint.java | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java index c2fb1ac98e..3a9757c8f6 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapPoint.java @@ -111,14 +111,14 @@ public class OpenstreetmapPoint extends OsmPoint { 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); + res = res && thisLatLon.equals(otherLatLon); if (getType() != null) - res = res || getType().equals(otherPoint.getType()); + res = res && getType().equals(otherPoint.getType()); if (getSubtype() != null) - res = res || getSubtype().equals(otherPoint.getSubtype()); + res = res && getSubtype().equals(otherPoint.getSubtype()); if (getTagsString() != null) - res = res || getTagsString().equals(otherPoint.getTagsString()); - res = res || getId() == otherPoint.getId(); + res = res && getTagsString().equals(otherPoint.getTagsString()); + res = res && getId() == otherPoint.getId(); return res; } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesPoint.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesPoint.java index 9275143cec..d9faf7d51c 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesPoint.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmNotesPoint.java @@ -79,7 +79,9 @@ public class OsmNotesPoint extends OsmPoint { 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); + if (text != null) { + res = res && text.equals(that.text); + } return res; } From becf77ca6062b500122874719556dc223ff00623 Mon Sep 17 00:00:00 2001 From: Skalii Date: Mon, 25 Jan 2021 17:26:03 +0200 Subject: [PATCH 005/125] fix align title text to the left side --- .../net/osmand/plus/onlinerouting/ui/OnlineRoutingCard.java | 2 ++ OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingCard.java b/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingCard.java index b18ee19fdb..39951b4c2c 100644 --- a/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingCard.java +++ b/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingCard.java @@ -2,6 +2,7 @@ package net.osmand.plus.onlinerouting.ui; import android.text.Editable; import android.text.TextWatcher; +import android.view.Gravity; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnFocusChangeListener; @@ -79,6 +80,7 @@ public class OnlineRoutingCard extends BaseCard { int activeColor = ContextCompat.getColor(app, appMode.getIconColorInfo().getColor(nightMode)); textFieldBoxes.setPrimaryColor(activeColor); + textFieldBoxes.setGravityFloatingLabel(Gravity.START); editText.addTextChangedListener(new TextWatcher() { @Override diff --git a/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java b/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java index 612d293271..b2ab7de5a5 100644 --- a/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java +++ b/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java @@ -29,4 +29,8 @@ public class OsmandTextFieldBoxes extends TextFieldBoxes { int paddingH = getResources().getDimensionPixelSize(R.dimen.route_info_card_details_margin); inputLayout.setPadding(0, paddingH, 0, paddingH); } + + public void setGravityFloatingLabel(int gravity) { + floatingLabel.setGravity(gravity); + } } From af828884247e3dd62ecf0d133ca4da4a0c90d358 Mon Sep 17 00:00:00 2001 From: Skalii Date: Mon, 25 Jan 2021 18:30:26 +0200 Subject: [PATCH 006/125] fix bottom padding if title text has more than one line --- .../net/osmand/plus/widgets/OsmandTextFieldBoxes.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java b/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java index b2ab7de5a5..bbc94d126e 100644 --- a/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java +++ b/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java @@ -3,6 +3,7 @@ package net.osmand.plus.widgets; import android.content.Context; import android.util.AttributeSet; import android.view.View; +import android.widget.RelativeLayout; import net.osmand.plus.R; @@ -33,4 +34,13 @@ public class OsmandTextFieldBoxes extends TextFieldBoxes { public void setGravityFloatingLabel(int gravity) { floatingLabel.setGravity(gravity); } + + @Override + public void setLabelText(String labelText) { + super.setLabelText(labelText); + if (!floatingLabel.isSingleLine()) { + RelativeLayout.LayoutParams rl = (RelativeLayout.LayoutParams) floatingLabel.getLayoutParams(); + rl.bottomMargin = rl.topMargin; + } + } } From 522631c1353549605dccd3ac9abc83845c4e26e8 Mon Sep 17 00:00:00 2001 From: vshcherb Date: Mon, 25 Jan 2021 19:14:34 +0100 Subject: [PATCH 007/125] Update NetworkUtils.java --- .../src/main/java/net/osmand/osm/io/NetworkUtils.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/osm/io/NetworkUtils.java b/OsmAnd-java/src/main/java/net/osmand/osm/io/NetworkUtils.java index 7f5c008efd..5119f9eede 100644 --- a/OsmAnd-java/src/main/java/net/osmand/osm/io/NetworkUtils.java +++ b/OsmAnd-java/src/main/java/net/osmand/osm/io/NetworkUtils.java @@ -29,7 +29,7 @@ public class NetworkUtils { if(userNamePassword != null) { conn.setRequestProperty("Authorization", "Basic " + Base64.encode(userNamePassword)); //$NON-NLS-1$ //$NON-NLS-2$ } - conn.setRequestProperty("User-Agent", "OsmAnd"); //$NON-NLS-1$ //$NON-NLS-2$ + conn.setRequestProperty("User-Agent", "OsmAnd"); //$NON-NLS-1$ //$NON-NLS-2$ log.info("Response code and message : " + conn.getResponseCode() + " " + conn.getResponseMessage()); if(conn.getResponseCode() != 200){ return conn.getResponseMessage(); @@ -69,7 +69,7 @@ public class NetworkUtils { conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY); OutputStream ous = conn.getOutputStream(); ous.write(("--" + BOUNDARY + "\r\n").getBytes()); - ous.write(("content-disposition: form-data; name=\"" + "file" + "\"; filename=\"" + "image1" + "\"\r\n").getBytes()); //$NON-NLS-1$ //$NON-NLS-2$ + ous.write(("Content-Disposition: form-data; name=\"" + "file" + "\"; filename=\"" + "image1" + "\"\r\n").getBytes()); //$NON-NLS-1$ //$NON-NLS-2$ ous.write(("Content-Type: application/octet-stream\r\n\r\n").getBytes()); //$NON-NLS-1$ Algorithms.streamCopy(data, ous); ous.write(("\r\n--" + BOUNDARY + "--\r\n").getBytes()); //$NON-NLS-1$ //$NON-NLS-2$ @@ -146,9 +146,9 @@ public class NetworkUtils { conn.setRequestProperty("Authorization", "Basic " + Base64.encode(userNamePassword)); //$NON-NLS-1$ //$NON-NLS-2$ } } - conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY); //$NON-NLS-1$ //$NON-NLS-2$ - conn.setRequestProperty("User-Agent", "OsmAnd"); //$NON-NLS-1$ //$NON-NLS-2$ - OutputStream ous = conn.getOutputStream(); + conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY); //$NON-NLS-1$ //$NON-NLS-2$ + conn.setRequestProperty("User-Agent", "OsmAnd"); //$NON-NLS-1$ //$NON-NLS-2$ + OutputStream ous = conn.getOutputStream(); ous.write(("--" + BOUNDARY + "\r\n").getBytes()); String filename = fileToUpload.getName(); if (gzip) { From 6547fe3adf24f8a9a3a8386032d741d115cb647d Mon Sep 17 00:00:00 2001 From: vshcherb Date: Mon, 25 Jan 2021 19:16:11 +0100 Subject: [PATCH 008/125] Update MenuBuilder.java --- OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 41a7abbf27..aa41508f7d 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -575,7 +575,7 @@ public class MenuBuilder { BufferedInputStream bufferedInputStream = new BufferedInputStream(image); Bitmap bmp = BitmapFactory.decodeStream(bufferedInputStream); ByteArrayOutputStream os = new ByteArrayOutputStream(); - bmp.compress(Bitmap.CompressFormat.PNG, 70, os); + bmp.compress(Bitmap.CompressFormat.JPEG, 90, os); return os.toByteArray(); } From 3f69fcbe07b2c0f0aeb4135015a8c777e7449727 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 25 Jan 2021 19:22:50 +0100 Subject: [PATCH 009/125] Fix extension for uploading images --- .../java/net/osmand/osm/io/NetworkUtils.java | 4 +-- .../plus/mapcontextmenu/MenuBuilder.java | 25 ++++++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/osm/io/NetworkUtils.java b/OsmAnd-java/src/main/java/net/osmand/osm/io/NetworkUtils.java index 5119f9eede..9e4d858436 100644 --- a/OsmAnd-java/src/main/java/net/osmand/osm/io/NetworkUtils.java +++ b/OsmAnd-java/src/main/java/net/osmand/osm/io/NetworkUtils.java @@ -57,7 +57,7 @@ public class NetworkUtils { } } - public static String sendPostDataRequest(String urlText, InputStream data) { + public static String sendPostDataRequest(String urlText, String formName, String fileName, InputStream data) { try { log.info("POST : " + urlText); HttpURLConnection conn = getHttpURLConnection(urlText); @@ -69,7 +69,7 @@ public class NetworkUtils { conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY); OutputStream ous = conn.getOutputStream(); ous.write(("--" + BOUNDARY + "\r\n").getBytes()); - ous.write(("Content-Disposition: form-data; name=\"" + "file" + "\"; filename=\"" + "image1" + "\"\r\n").getBytes()); //$NON-NLS-1$ //$NON-NLS-2$ + ous.write(("Content-Disposition: form-data; name=\"" + formName + "\"; filename=\"" + fileName + "\"\r\n").getBytes()); //$NON-NLS-1$ //$NON-NLS-2$ ous.write(("Content-Type: application/octet-stream\r\n\r\n").getBytes()); //$NON-NLS-1$ Algorithms.streamCopy(data, ous); ous.write(("\r\n--" + BOUNDARY + "--\r\n").getBytes()); //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index aa41508f7d..3890046fac 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -9,6 +9,7 @@ import android.content.res.ColorStateList; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Color; +import android.graphics.Matrix; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; @@ -98,6 +99,7 @@ import static net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCa public class MenuBuilder { private static final int PICK_IMAGE = 1231; + private static final int MAX_IMAGE_LENGTH = 2048; private static final Log LOG = PlatformUtil.getLog(MenuBuilder.class); public static final float SHADOW_HEIGHT_TOP_DP = 17f; public static final int TITLE_LIMIT = 60; @@ -505,10 +507,11 @@ public class MenuBuilder { } private void uploadImageToPlace(InputStream image) { - InputStream serverData = new ByteArrayInputStream(compressImage(image)); + InputStream serverData = new ByteArrayInputStream(compressImageToJpeg(image)); final String baseUrl = OPRConstants.getBaseUrl(app); + // all these should be constant String url = baseUrl + "api/ipfs/image"; - String response = NetworkUtils.sendPostDataRequest(url, serverData); + String response = NetworkUtils.sendPostDataRequest(url, "file", "compressed.jpeg", serverData); if (response != null) { int res = 0; try { @@ -571,10 +574,26 @@ public class MenuBuilder { } } - private byte[] compressImage(InputStream image) { + private byte[] compressImageToJpeg(InputStream image) { BufferedInputStream bufferedInputStream = new BufferedInputStream(image); Bitmap bmp = BitmapFactory.decodeStream(bufferedInputStream); ByteArrayOutputStream os = new ByteArrayOutputStream(); + int h = bmp.getHeight(); + int w = bmp.getWidth(); + boolean scale = false; + while (w > MAX_IMAGE_LENGTH || h > MAX_IMAGE_LENGTH) { + w = w / 2; + h = h / 2; + scale = true; + } + if (scale) { + Matrix matrix = new Matrix(); + matrix.postScale(w, h); + Bitmap resizedBitmap = Bitmap.createBitmap( + bmp, 0, 0, w, h, matrix, false); + bmp.recycle(); + bmp = resizedBitmap; + } bmp.compress(Bitmap.CompressFormat.JPEG, 90, os); return os.toByteArray(); } From 0c623d57f6c8819dead735435229796220520ee1 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 25 Jan 2021 19:35:08 +0100 Subject: [PATCH 010/125] Add test url --- OsmAnd/no_translate.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/no_translate.xml b/OsmAnd/no_translate.xml index c52342f9ab..d5ecc7c149 100644 --- a/OsmAnd/no_translate.xml +++ b/OsmAnd/no_translate.xml @@ -41,6 +41,7 @@ OsmAnd Unlimited Markers https://openplacereviews.org/ + https://test.openplacereviews.org/ v8G8r9NLJZGMV4he5lwbQlz620FNVARKjI9Bm5UJ jDvM95Ne1Bq2BDTmIfB6b3ZMxvdK87WGfp6DC07J Ti2qq3fo4i4Wmuox3SiWRIGq3obZisBHnxmcM05y From a914efaa286353dbbfd9cb920de442773590de3f Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Mon, 25 Jan 2021 23:30:43 +0200 Subject: [PATCH 011/125] Sort travel GPX card and travel article, UI --- .../res/layout/wikivoyage_travel_gpx_card.xml | 78 +++++++--- .../plus/wikivoyage/data/TravelObfHelper.java | 143 ++++++++++++------ .../explore/ExploreTabFragment.java | 27 ++-- .../explore/travelcards/TravelGpxCard.java | 22 +-- 4 files changed, 184 insertions(+), 86 deletions(-) diff --git a/OsmAnd/res/layout/wikivoyage_travel_gpx_card.xml b/OsmAnd/res/layout/wikivoyage_travel_gpx_card.xml index eb97f02c0b..44077a0dcd 100644 --- a/OsmAnd/res/layout/wikivoyage_travel_gpx_card.xml +++ b/OsmAnd/res/layout/wikivoyage_travel_gpx_card.xml @@ -10,17 +10,13 @@ android:id="@+id/background_view" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="@dimen/content_padding_small" - android:layout_marginStart="@dimen/content_padding" - android:layout_marginEnd="@dimen/content_padding" - android:background="?attr/wikivoyage_travel_card_bg"> + android:background="?attr/wikivoyage_card_bg_color"> + + + + - + android:orientation="vertical" + android:paddingTop="@dimen/content_padding_half" + android:paddingBottom="@dimen/content_padding_small"> + + + + + + android:layout_height="wrap_content" + android:paddingTop="@dimen/content_padding_small_half" + android:paddingBottom="@dimen/content_padding_small_half"> loadPopularArticles() { String lang = app.getLanguage(); List popularArticles = new ArrayList<>(); - for (BinaryMapIndexReader reader : getReaders()) { + final List> amenities = new ArrayList<>(); + final LatLon location = app.getMapViewTrackingUtilities().getMapLocation(); + for (final BinaryMapIndexReader reader : getReaders()) { try { - final LatLon location = app.getMapViewTrackingUtilities().getMapLocation(); - SearchRequest req = BinaryMapIndexReader.buildSearchPoiRequest( - location, POPULAR_ARTICLES_SEARCH_RADIUS, -1, getSearchFilter(false), null); - List amenities = reader.searchPoi(req); - if (amenities.size() > 0) { - for (Amenity amenity : amenities) { - if (!Algorithms.isEmpty(amenity.getName(lang))) { - TravelArticle article = cacheTravelArticles(reader.getFile(), amenity, lang, false); - if (article != null) { - popularArticles.add(article); - if (popularArticles.size() >= MAX_POPULAR_ARTICLES_COUNT) { - break; - } - } - } - } - Collections.sort(popularArticles, new Comparator() { - @Override - public int compare(TravelArticle article1, TravelArticle article2) { - int d1 = (int) (MapUtils.getDistance(article1.getLat(), article1.getLon(), - location.getLatitude(), location.getLongitude())); - int d2 = (int) (MapUtils.getDistance(article2.getLat(), article2.getLon(), - location.getLatitude(), location.getLongitude())); - return d1 < d2 ? -1 : (d1 == d2 ? 0 : 1); - } - }); - } + searchAmenity(amenities, location, reader, POPULAR_ARTICLES_SEARCH_RADIUS, -1, ROUTE_ARTICLE); + searchAmenity(amenities, location, reader, GPX_TRACKS_SEARCH_RADIUS, 15, ROUTE_TRACK); } catch (Exception e) { LOG.error(e.getMessage(), e); } } + + if (amenities.size() > 0) { + Collections.sort(amenities, new Comparator>() { + @Override + public int compare(Pair article1, Pair article2) { + int d1 = (int) (MapUtils.getDistance(((Amenity) article1.second).getLocation(), location)); + int d2 = (int) (MapUtils.getDistance(((Amenity) article2.second).getLocation(), location)); + return d1 < d2 ? -1 : (d1 == d2 ? 0 : 1); + } + }); + for (Pair amenity : amenities) { + if (!Algorithms.isEmpty(amenity.second.getName(lang))) { + TravelArticle article = cacheTravelArticles(amenity.first, amenity.second, lang, false); + if (article != null) { + popularArticles.add(article); + if (popularArticles.size() >= MAX_POPULAR_ARTICLES_COUNT) { + break; + } + } + } + } + } this.popularArticles = popularArticles; return popularArticles; } + private void searchAmenity(final List> amenitiesList, LatLon location, + final BinaryMapIndexReader reader, int searchRadius, int zoom, + String searchFilter) throws IOException { + reader.searchPoi(BinaryMapIndexReader.buildSearchPoiRequest( + location, searchRadius, zoom, getSearchFilter(searchFilter), new ResultMatcher() { + @Override + public boolean publish(Amenity object) { + amenitiesList.add(new Pair<>(reader.getFile(), object)); + return false; + } + + @Override + public boolean isCancelled() { + return false; + } + })); + } + @Nullable private TravelArticle cacheTravelArticles(File file, Amenity amenity, String lang, boolean readPoints) { TravelArticle article = null; - Map articles = readArticles(file, amenity, false); + Map articles; + if (amenity.getSubType().equals(ROUTE_TRACK)) { + articles = readRoutePoint(file, amenity); + } else { + articles = readArticles(file, amenity, false); + } if (!Algorithms.isEmpty(articles)) { TravelArticleIdentifier newArticleId = articles.values().iterator().next().generateIdentifier(); cachedArticles.put(newArticleId, articles); @@ -139,12 +165,38 @@ public class TravelObfHelper implements TravelHelper { return article; } - @NonNull - private SearchPoiTypeFilter getSearchFilter(final boolean articlePoints) { - return new SearchPoiTypeFilter() { + private Map readRoutePoint(File file, Amenity amenity) { + Map articles = new HashMap<>(); + TravelGpx res = new TravelGpx(); + String title = amenity.getName("en"); + res.title = capitalizeFirstLetter(getGpxTitle(Algorithms.isEmpty(title) ? amenity.getName() : title)); + res.routeId = Algorithms.emptyIfNull(amenity.getTagContent(Amenity.ROUTE_ID)); + try { + res.totalDistance = Float.parseFloat(Algorithms.emptyIfNull(amenity.getTagContent("distance"))); + } catch (NumberFormatException e) { + LOG.debug(e.getMessage(), e); + } + try { + res.diffElevationUp = Double.parseDouble(Algorithms.emptyIfNull(amenity.getTagContent("diff_ele_up"))); + } catch (NumberFormatException e) { + LOG.debug(e.getMessage(), e); + } + try { + res.diffElevationDown = Double.parseDouble(Algorithms.emptyIfNull(amenity.getTagContent("diff_ele_down"))); + } catch (NumberFormatException e) { + LOG.debug(e.getMessage(), e); + } + res.user = Algorithms.emptyIfNull(amenity.getTagContent("user")); + articles.put("en", res); + return articles; + } + + + private BinaryMapIndexReader.SearchPoiTypeFilter getSearchFilter(final String filterSubcategory) { + return new BinaryMapIndexReader.SearchPoiTypeFilter() { @Override public boolean accept(PoiCategory type, String subcategory) { - return subcategory.equals(articlePoints ? ROUTE_ARTICLE_POINT : ROUTE_ARTICLE); + return subcategory.equals(filterSubcategory); } @Override @@ -175,9 +227,9 @@ public class TravelObfHelper implements TravelHelper { res.isParentOf = Algorithms.emptyIfNull(amenity.getTagContent(Amenity.IS_PARENT_OF, lang)); res.lat = amenity.getLocation().getLatitude(); res.lon = amenity.getLocation().getLongitude(); - res.imageTitle = Algorithms.emptyIfNull(amenity.getTagContent(Amenity.IMAGE_TITLE, null)); - res.routeId = Algorithms.emptyIfNull(amenity.getTagContent(Amenity.ROUTE_ID, null)); - res.routeSource = Algorithms.emptyIfNull(amenity.getTagContent(Amenity.ROUTE_SOURCE, null)); + res.imageTitle = Algorithms.emptyIfNull(amenity.getTagContent(Amenity.IMAGE_TITLE)); + res.routeId = Algorithms.emptyIfNull(amenity.getTagContent(Amenity.ROUTE_ID)); + res.routeSource = Algorithms.emptyIfNull(amenity.getTagContent(Amenity.ROUTE_SOURCE)); res.originalId = 0; res.lang = lang; res.contentsJson = Algorithms.emptyIfNull(amenity.getTagContent(Amenity.CONTENT_JSON, lang)); @@ -214,14 +266,14 @@ public class TravelObfHelper implements TravelHelper { } SearchRequest req = BinaryMapIndexReader.buildSearchPoiRequest(0, 0, Algorithms.emptyIfNull(article.title), 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, - getSearchFilter(true), new ResultMatcher() { + getSearchFilter(ROUTE_ARTICLE_POINT), new ResultMatcher() { @Override public boolean publish(Amenity amenity) { String amenityLang = amenity.getTagSuffix(Amenity.LANG_YES + ":"); if (Algorithms.stringsEqual(lang, amenityLang) && Algorithms.stringsEqual(article.routeId, - Algorithms.emptyIfNull(amenity.getTagContent(Amenity.ROUTE_ID, null)))) { + Algorithms.emptyIfNull(amenity.getTagContent(Amenity.ROUTE_ID)))) { pointList.add(amenity); } return false; @@ -263,7 +315,7 @@ public class TravelObfHelper implements TravelHelper { } String category = amenity.getTagSuffix("category_"); if (category != null) { - wptPt.category = Algorithms.capitalizeFirstLetter(category); + wptPt.category = capitalizeFirstLetter(category); } return wptPt; } @@ -283,7 +335,7 @@ public class TravelObfHelper implements TravelHelper { for (BinaryMapIndexReader reader : getReaders()) { try { SearchRequest searchRequest = BinaryMapIndexReader.buildSearchPoiRequest(0, 0, searchQuery, - 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, getSearchFilter(false), new ResultMatcher() { + 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, getSearchFilter(ROUTE_ARTICLE), new ResultMatcher() { @Override public boolean publish(Amenity object) { List otherNames = object.getAllNames(false); @@ -458,7 +510,7 @@ public class TravelObfHelper implements TravelHelper { for (BinaryMapIndexReader reader : getReaders()) { try { SearchRequest req = BinaryMapIndexReader.buildSearchPoiRequest( - 0, 0, title, 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, getSearchFilter(false), + 0, 0, title, 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, getSearchFilter(ROUTE_ARTICLE), new ResultMatcher() { boolean done = false; @@ -531,12 +583,13 @@ public class TravelObfHelper implements TravelHelper { } SearchRequest req = BinaryMapIndexReader.buildSearchPoiRequest(0, 0, Algorithms.emptyIfNull(articleId.title), 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, - getSearchFilter(false), new ResultMatcher() { + getSearchFilter(ROUTE_ARTICLE), new ResultMatcher() { boolean done = false; @Override public boolean publish(Amenity amenity) { - if (Algorithms.stringsEqual(articleId.routeId, Algorithms.emptyIfNull(amenity.getTagContent(Amenity.ROUTE_ID, null))) || isDbArticle) { + if (Algorithms.stringsEqual(articleId.routeId, + Algorithms.emptyIfNull(amenity.getTagContent(Amenity.ROUTE_ID))) || isDbArticle) { amenities.add(amenity); done = true; } @@ -604,7 +657,7 @@ public class TravelObfHelper implements TravelHelper { for (BinaryMapIndexReader reader : getReaders()) { try { SearchRequest req = BinaryMapIndexReader.buildSearchPoiRequest( - x, y, title, left, right, top, bottom, getSearchFilter(false), + x, y, title, left, right, top, bottom, getSearchFilter(ROUTE_ARTICLE), new ResultMatcher() { boolean done = false; diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java index e520487740..ce6f4475af 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java @@ -180,20 +180,21 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv List popularArticles = app.getTravelHelper().getPopularArticles(); for (TravelArticle article : popularArticles) { - if (article instanceof TravelGpx) { - items.add(new TravelGpxCard(app, nightMode, (TravelGpx) article, fm)); - } else { - items.add(new ArticleTravelCard(app, nightMode, article, activity.getSupportFragmentManager())); + if (article instanceof TravelGpx) { + items.add(new TravelGpxCard(app, nightMode, (TravelGpx) article, activity.getSupportFragmentManager())); + } else { + items.add(new ArticleTravelCard(app, nightMode, article, activity.getSupportFragmentManager())); + } + } + items.add(new StartEditingTravelCard(activity, nightMode)); + adapter.setItems(items); + final DownloadIndexesThread downloadThread = app.getDownloadThread(); + if (!downloadThread.getIndexes().isDownloadedFromInternet) { + waitForIndexes = true; + downloadThread.runReloadIndexFilesSilent(); + } else { + checkDownloadIndexes(); } - } - items.add(new StartEditingTravelCard(activity, nightMode)); - adapter.setItems(items); - final DownloadIndexesThread downloadThread = app.getDownloadThread(); - if (!downloadThread.getIndexes().isDownloadedFromInternet) { - waitForIndexes = true; - downloadThread.runReloadIndexFilesSilent(); - } else { - checkDownloadIndexes(); } } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java index 32790cc094..608b0b812f 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java @@ -8,11 +8,11 @@ import androidx.annotation.NonNull; import androidx.fragment.app.FragmentManager; import androidx.recyclerview.widget.RecyclerView; +import net.osmand.AndroidUtils; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.wikipedia.WikiArticleHelper; -import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment; import net.osmand.plus.wikivoyage.data.TravelGpx; import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; @@ -38,17 +38,21 @@ public class TravelGpxCard extends BaseTravelCard { if (viewHolder instanceof TravelGpxVH) { final TravelGpxVH holder = (TravelGpxVH) viewHolder; holder.title.setText(article.getTitle()); - holder.content.setText(WikiArticleHelper.getPartialContent(article.getContent())); - holder.distance.setText(OsmAndFormatter.getFormattedDistance(article.totalDistance,app)); - holder.diffElevationUp.setText(OsmAndFormatter.getFormattedAlt(article.diffElevationUp,app)); - holder.diffElevationDown.setText(OsmAndFormatter.getFormattedAlt(article.diffElevationDown,app)); + Drawable icon = getActiveIcon(R.drawable.ic_action_user_account_16); + holder.user.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); + holder.user.setText(WikiArticleHelper.getPartialContent(article.user)); + AndroidUtils.setBackground(app, holder.user, nightMode, R.drawable.btn_border_bg_light, R.drawable.btn_border_bg_dark); + holder.distance.setText(OsmAndFormatter.getFormattedDistance(article.totalDistance, app)); + holder.diffElevationUp.setText(OsmAndFormatter.getFormattedAlt(article.diffElevationUp, app)); + holder.diffElevationDown.setText(OsmAndFormatter.getFormattedAlt(article.diffElevationDown, app)); holder.leftButton.setText(app.getString(R.string.shared_string_view)); View.OnClickListener readClickListener = new View.OnClickListener() { @Override public void onClick(View v) { if (fragmentManager != null) { - WikivoyageArticleDialogFragment.showInstance(app, fragmentManager, - article.generateIdentifier(), article.getLang()); +// WikivoyageArticleDialogFragment.showInstance(app, fragmentManager, +// article.generateIdentifier(), article.getLang()); + app.getTravelHelper().createGpxFile(article); } } }; @@ -86,7 +90,7 @@ public class TravelGpxCard extends BaseTravelCard { public static class TravelGpxVH extends RecyclerView.ViewHolder { final TextView title; - final TextView content; + final TextView user; final TextView distance; final TextView diffElevationUp; final TextView diffElevationDown; @@ -98,7 +102,7 @@ public class TravelGpxCard extends BaseTravelCard { public TravelGpxVH(final View itemView) { super(itemView); title = itemView.findViewById(R.id.title); - content = itemView.findViewById(R.id.content); + user = itemView.findViewById(R.id.user_name); distance = itemView.findViewById(R.id.distance); diffElevationUp = itemView.findViewById(R.id.diff_ele_up); diffElevationDown = itemView.findViewById(R.id.diff_ele_down); From c01a4791b0810ef398a9440459a8c0171ec7df43 Mon Sep 17 00:00:00 2001 From: vshcherb Date: Mon, 25 Jan 2021 22:42:49 +0100 Subject: [PATCH 012/125] Update no_translate.xml --- OsmAnd/no_translate.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/no_translate.xml b/OsmAnd/no_translate.xml index d5ecc7c149..92d3a4034f 100644 --- a/OsmAnd/no_translate.xml +++ b/OsmAnd/no_translate.xml @@ -40,7 +40,7 @@ items modified OsmAnd Unlimited Markers - https://openplacereviews.org/ + https://test.openplacereviews.org/ https://test.openplacereviews.org/ v8G8r9NLJZGMV4he5lwbQlz620FNVARKjI9Bm5UJ jDvM95Ne1Bq2BDTmIfB6b3ZMxvdK87WGfp6DC07J From 6fa05b0748f6cefa5a7e5390997ff130a70a2268 Mon Sep 17 00:00:00 2001 From: Skalii Date: Tue, 26 Jan 2021 04:02:49 +0200 Subject: [PATCH 013/125] fix padding between title and input text if title has more than one line --- .../plus/widgets/OsmandTextFieldBoxes.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java b/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java index bbc94d126e..45eb6a703b 100644 --- a/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java +++ b/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java @@ -3,7 +3,6 @@ package net.osmand.plus.widgets; import android.content.Context; import android.util.AttributeSet; import android.view.View; -import android.widget.RelativeLayout; import net.osmand.plus.R; @@ -38,9 +37,18 @@ public class OsmandTextFieldBoxes extends TextFieldBoxes { @Override public void setLabelText(String labelText) { super.setLabelText(labelText); - if (!floatingLabel.isSingleLine()) { - RelativeLayout.LayoutParams rl = (RelativeLayout.LayoutParams) floatingLabel.getLayoutParams(); - rl.bottomMargin = rl.topMargin; - } + floatingLabel.post(new Runnable() { + @Override + public void run() { + if (floatingLabel.getLineCount() > 1) { + inputLayout.setPadding( + inputLayout.getPaddingLeft(), + inputLayout.getPaddingTop() + getResources().getDimensionPixelSize(R.dimen.pages_item_padding), + inputLayout.getPaddingRight(), + inputLayout.getPaddingBottom() + ); + } + } + }); } } From 7e29530f59d45c9b9800fca28e67b09772676688 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Tue, 26 Jan 2021 10:52:43 +0300 Subject: [PATCH 014/125] Limit popular tralev acticles to 30. Fix infinite loop. --- OsmAnd/src/net/osmand/plus/download/DownloadResources.java | 5 ++++- .../src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadResources.java b/OsmAnd/src/net/osmand/plus/download/DownloadResources.java index 4f820bac2a..56d137a696 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadResources.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadResources.java @@ -13,6 +13,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.download.DownloadOsmandIndexesHelper.AssetIndexItem; import net.osmand.plus.inapp.InAppPurchaseHelper; +import net.osmand.plus.wikivoyage.data.TravelDbHelper; import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; @@ -358,7 +359,9 @@ public class DownloadResources extends DownloadResourceGroup { continue; } if (ii.getType() == DownloadActivityType.WIKIVOYAGE_FILE) { - wikivoyageMaps.addItem(ii); + if (app.getTravelHelper() instanceof TravelDbHelper) { + wikivoyageMaps.addItem(ii); + } continue; } if (ii.getType() == DownloadActivityType.TRAVEL_FILE) { diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index 65f2da58a8..237e8174d1 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -56,7 +56,7 @@ public class TravelObfHelper implements TravelHelper { public static final String ROUTE_ARTICLE_POINT = "route_article_point"; public static final int POPULAR_ARTICLES_SEARCH_RADIUS = 100000; public static final int ARTICLE_SEARCH_RADIUS = 50000; - public static final int MAX_POPULAR_ARTICLES_COUNT = 100; + public static final int MAX_POPULAR_ARTICLES_COUNT = 30; private final OsmandApplication app; private final Collator collator; @@ -510,7 +510,7 @@ public class TravelObfHelper implements TravelHelper { } } } - if (article == null) { + if (article == null && articles == null) { article = findArticleById(articleId, lang); } if (article != null && !article.gpxFileRead && forceReadPoints) { From cf1866d8d5d7ec5edcf97b087954e7a3204caa66 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Tue, 26 Jan 2021 11:52:24 +0300 Subject: [PATCH 015/125] Speedup gpx generation for travel articles --- OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index 237e8174d1..9a2c80940c 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -513,7 +513,7 @@ public class TravelObfHelper implements TravelHelper { if (article == null && articles == null) { article = findArticleById(articleId, lang); } - if (article != null && !article.gpxFileRead && forceReadPoints) { + if (article != null && !article.gpxFileRead && forceReadPoints && !Algorithms.isEmpty(lang)) { article.gpxFile = buildGpxFile(article); article.gpxFileRead = true; } From f161a609a5bdbc47872aecc741d48e15f20b7771 Mon Sep 17 00:00:00 2001 From: Damjan Gerl Date: Sun, 24 Jan 2021 14:29:34 +0000 Subject: [PATCH 016/125] Translated using Weblate (Slovenian) Currently translated at 72.9% (2659 of 3645 strings) --- OsmAnd/res/values-sl/strings.xml | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/OsmAnd/res/values-sl/strings.xml b/OsmAnd/res/values-sl/strings.xml index 9a0e2bec9b..89091ce1d4 100644 --- a/OsmAnd/res/values-sl/strings.xml +++ b/OsmAnd/res/values-sl/strings.xml @@ -3271,4 +3271,38 @@ Ustvari novo pot Končano Prepiši sled + Mape + Izberi mapo + Izberi mapo ali dodaj novo + Prazno + Analiziraj po intervalih (razdelitveni interval) + Naloži v OpenStreetMap + Uredi sled + Preimenuj sled + Spremeni mapo + sek + Pristop + Pripravi se + Izven poti + Prihod na cilj + Zavoj + Intervali časa in razdalje + Čas objave različnih glasovnih pozivov je odvisen od vrste poziva, trenutne hitrosti navigacije in privzete hitrosti navigacije. + Čas objave + Začni snemanje + Invalidski voziček + Hoja + Pohodništvo + Električno kolesarjenje + Gorsko kolesarjenje + Cestno kolesarjenje + Redno kolesarjenje + Težko tovorno vozilo + Majhno tovorno vozilo + Tovorno vozilo + Skuter + Dirkalno kolo + MTB + Napaka strežnika: %1$s + To ime že obstaja \ No newline at end of file From 4ce1c211074e78c2cabc20ee2cbcad4394793acc Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 23 Jan 2021 21:52:05 +0000 Subject: [PATCH 017/125] Translated using Weblate (German) Currently translated at 99.9% (3642 of 3645 strings) --- OsmAnd/res/values-de/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index 434aa506d8..30daf76d2f 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -3998,4 +3998,8 @@ Mountainbike Server-Fehler: %1$s Der Name ist bereits vorhanden + Beim Passieren + Abweichung von der Route + Ankunft am Ziel + Annährung ans Ziel \ No newline at end of file From 504ed0e2899c96fd81c1d56bcbaa8da2e2a2adf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Babos=20G=C3=A1bor?= Date: Mon, 25 Jan 2021 21:53:03 +0000 Subject: [PATCH 018/125] Translated using Weblate (Hungarian) Currently translated at 100.0% (3645 of 3645 strings) --- OsmAnd/res/values-hu/strings.xml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/OsmAnd/res/values-hu/strings.xml b/OsmAnd/res/values-hu/strings.xml index ba55ac197f..cbc176d6fe 100644 --- a/OsmAnd/res/values-hu/strings.xml +++ b/OsmAnd/res/values-hu/strings.xml @@ -661,7 +661,7 @@ \n \nA csempés térképek letölthetők internetes forrásokból, vagy előkészíthetők kapcsolat nélküli használathoz (kézzel átmásolva az OsmAnd adatmappájába) SQLite adatbázisként, amely különféle harmadik féltől származó térkép-előkészítő eszközökkel állítható elő. Megjeleníti a háttérben futó nyomvonalrögzítés és navigáció beállításait, ami periodikusan felébreszti a GPS modult (kikapcsolt képernyőnél). - Elérhetővé teszi az eszköz akadálymentesítési lehetőségeit közvetlenül az OsmAndban. Ez megkönnyíti például a szövegfelolvasó (TTS) hangok beszédsebességének állítását, az irányító gombok képernyő navigációjának beállítását, egy görgető használatát a nagyítás vezérléséhez, vagy szövegfelolvasó visszajelzés használatát, például a pozíció automatikus bejelentésénél. + Elérhetővé teszi az eszköz akadálymentesítési lehetőségeit közvetlenül az OsmAndban. Ez megkönnyíti például a szövegfelolvasó (TTS) hangok beszédsebességének állítását, az irányító gombok képernyő navigációjának beállítását, egy görgető használatát a nagyítás vezérléséhez, vagy szövegfelolvasó visszajelzés használatát, például a pozíció automatikus bemondásánál. Beállítások fejlesztői és hibakeresési szolgáltatásokhoz, mint például navigáció szimulálása, a megjelenítés teljesítménye vagy hangutasítások. Fejlesztőknek szánt funkciók, nem szükségesek a normál használathoz. Bővítmények A bővítmények speciális beállításokat és kiegészítő funkciókat aktiválnak. @@ -1178,7 +1178,7 @@ Útvonal megosztása GPX-ben OsmAnd segítségével megosztott útvonal Érkezés bemondása - Milyen korán szeretnéd hallani az érkezés bejelentését\? + Milyen korán szeretné hallani az érkezés bemondását\? Csak kézzel (koppintás a nyílra) Navigációs utasítások újra bemondása rendszeres időközönként. Navigációs utasítások ismétlése @@ -1948,10 +1948,10 @@ Hanggal jelölje a célpont irányát. Rezgő irányjelzés Rezgéssel jelölje a célpont irányát. - Okos automatikus bejelentés + Intelligens automatikus bemondás Figyelmeztetés, csak ha a célpont iránya megváltozott. - Automatikus bejelentések időköz - A bejelentések közötti legkisebb időköz. + Bemondások gyakorisága + A bemondások közötti legkisebb időköz. magyar (magázó) Jelenlegi nyomvonal Jelölő helyének módosítása @@ -3051,7 +3051,7 @@ Tömeg, magasság, hossz, sebesség Jármű paraméterek A hangbemondások csak navigáció közben kerülnek lejátszásra. - Navigációs utasítások és bejelentések + Navigációs utasítások és bemondások Hangutasítások Képernyő riasztások Útvonal paraméterek testreszabása @@ -3340,7 +3340,7 @@ Videojegyzetek Fényképes jegyzetek Útvonal újraszámítása - Bejelentés + Bemondás Felhasználónév és jelszó Ezek a bővítménybeállítások globálisak, és minden profilra vonatkoznak OSM-szerkesztés @@ -3986,9 +3986,12 @@ Hegyi kerékpározás Verenykerékpározás Rendes kerékpározás - Tgk. - Nehéz tgk. + Teherautó + Nehéz teherautó Kisteherautó Szerverhiba: %1$s Ez a név már létezik + A különféle hangutasítások bemondási ideje függ az utasítás típusától, az aktuális navigációs sebességtől és az alapértelmezett navigációs sebességtől. + Bemondás ideje + Roller \ No newline at end of file From 4b114232366e3415ca52b46d848ebc57a6b95199 Mon Sep 17 00:00:00 2001 From: Ihor Hordiichuk Date: Mon, 25 Jan 2021 22:41:37 +0000 Subject: [PATCH 019/125] Translated using Weblate (Ukrainian) Currently translated at 100.0% (3645 of 3645 strings) --- OsmAnd/res/values-uk/strings.xml | 46 ++++++++++++++++---------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml index 843c7adc62..e66ec0fbe9 100644 --- a/OsmAnd/res/values-uk/strings.xml +++ b/OsmAnd/res/values-uk/strings.xml @@ -22,12 +22,12 @@ Автономна навігація OsmAnd тимчасово не доступна. Лівосторонній рух Для країн з лівостороннім рухом. - Початкове місцезнаходження ще не визначено. + Початкове місцеперебування ще не визначено. Розташування ще не визначено. Встановити прозорість (0 – прозорий, 255 – непрозорий) Скасувати завантаження\? Дякуємо за користування OsmAnd. Завантажуйте регіональні дані для користування в автономному режимі за допомогою пункту меню \'Налаштування\' → \'Керування мапами\' для перегляду мап, пошуку адрес, POI, громадського транспорту тощо. - Основна мапа, необхідна для забезпечення основних можливостей, знаходиться у черзі завантаження. + Основна мапа, необхідна для забезпечення основних можливостей, перебуває у черзі завантаження. Нічого не знайдено. Якщо Ви не знайшли свій регіон, Ви можете створити його самостійно (див. https://osmand.net). Мережеві та кешовані растрові мапи Звичайні мапи (векторні) @@ -312,8 +312,8 @@ Поділитись, використовуючи Координати: %1$s\n%2$s Щоб побачити розташування, перейдіть за веб-посиланням %1$s або intent-посиланням Android %2$s - Надіслати місцезнаходження - Поділитись місцезнаходженням + Надіслати місцеперебування + Поділитись місцеперебуванням Маршрутну точку GPX \"{0}\" додано Додати точку до записаного треку Адміністративні @@ -575,7 +575,7 @@ Закрити Дані завантажуються… Зчитування даних… - Помилка у роботі застосунку. Файл журналу знаходиться тут {0}. Будь ласка, напишіть розробнику про помилку (з вкладеним журнальним файлом). + Помилка роботи застосунку. Файл журналу розміщено тут {0}. Повідомте розробника про помилку (з вкладеним файлом журналу). Збереження GPX-файлу… Закінчено Використовувати Інтернет для прокладання маршруту. @@ -843,7 +843,7 @@ Запустити програму в безпечному режимі (використовує повільніші Android-функції замість власних). Безпечний режим Програму запущено в безпечному режимі (вимкніть його в \'Налаштуваннях\'). - Оберіть \"Використати місцезнаходження...\" для прив\'язки нотатки до даного місцезнаходження. + Виберіть \"Використати місцеперебування...\" для прив\'язки нотатки до поточного розташування. Службу OsmAnd у тлі досі запущено. Зупинити її роботу також\? Закрити набір змін Програма \'ZXing Barcode Scanner\' не встановлена. Шукати в Google Play? @@ -1589,7 +1589,7 @@ Себуанська У Вас є старі несумісні дані з Вікіпедії. Заархівувати їх? Завантажити додаткові дані з Вікіпедії (%1$s Мб)\? - Служба визначення місцезнаходження вимкнена. Увімкнути? + Служба визначення розташування вимкнена. Увімкнути\? Запобігти самостійному логуваню Імпортувати до OsmAnd Читати повну статтю (мережево) @@ -1656,7 +1656,7 @@ Показати мапу Імітувати перший запуск застосунку гео: - Поділитись місцезнаходженням + Поділитись місцеперебуванням Надіслати Будь ласка, використовуйте назву категорії, яка ще не існує. Назва категорії @@ -1790,7 +1790,7 @@ OSM правки, поширені через OsmAnd Заплановані обʼєкти Ви дійсно хочете зберегти POI, не вказавши його тип? - Надання доступу до даних про місцезнаходження. + Надання доступу до даних про місцеперебування. Надання доступу до камери. Надання доступу до мікрофона. Відстань: @@ -2039,7 +2039,7 @@ Неможливо визначити місце розташування З’єднання з Інтернетом відсутнє Необхідно завантажити мапи. - Визначення місцезнаходження… + Визначення місцеперебування… Вільне місце Сховище даних OsmAnd (мапи, файли з треками, тощо): %1$s. Дати дозвіл @@ -2210,7 +2210,7 @@ Шукати знову Збільшити радіус пошуку Нічого не знайдено - Місце призначення знаходиться в області з приватним доступом. Дозволити доступ по приватних дорогах для цієї подорожі\? + Місце призначення розташовано в області з приватним доступом. Дозволити доступ до приватних доріг у цій подорожі\? Змініть пошуковий запит або ж розширте пошуковий радіус. Показати/приховати OSM-нотатки Показати OSM-нотатки @@ -2304,12 +2304,12 @@ \n Катання на лижах \nOsmAnd-втулок лижних мап дозволяє бачити лижні траси з рівнем складності та деякою додатковими відомостями на зразок розташування підйомників та інших об’єктів. - Їзда на велосипеді -\n• Знаходьте велосипедні доріжки на мапі -\n• GPS-навігація у велосипедному режимі будує маршрут з використанням велосипедних доріжок -\n• Ви можете бачити свою швидкість та висотне положення -\n• Опція запису GPX дозволяє вам записувати Вашу подорож та ділитися нею -\n• Через додатковий втулок Ви можете увімкнути відображення горизонталей та рельєфу + Їзда на велосипеді +\n• Знаходьте велосипедні доріжки на мапі +\n• GPS-навігація у велосипедному режимі будує маршрут з використанням велосипедних доріжок +\n• Ви можете бачити свою швидкість та висотне положення +\n• Параметр запису GPX дозволяє вам записувати вашу подорож та ділитися нею +\n• Через додатковий втулок ви можете увімкнути показ горизонталей та рельєфу Прогулянки, походи, екскурсія по місту \n• Мапа показує доріжки для прогулянок та походів \n• Вікіпедія Вашою обраною мовою може багато розповісти під час екскурсії містом @@ -2382,9 +2382,9 @@ Безпосередній вклад у OSM \n• Звітуйте про помилки в даних \n• Вивантажуйте GPX-треки в OSM безпосередньо з програми -\n• Додавайте POI (цікаві точки) та безпосередньо вивантажуйте їх в OSM (чи пізніше, якщо зараз Ви в офлайні) -\n• Опція запису подорожі також і в режимі тла (в той час як пристрій знаходиться в сплячому режимі) -\nOsmAnd — вільне й відкрите програмне забезпечення, що активно розвивається. Кожен може внести свій вклад, звітуючи про помилки, поліпшуючи переклад чи розробляючи нові функції. Також проєкт покладається на фінансові внески для оплати розробки та тестування нових функціональних можливостей. +\n• Додавайте POI (цікаві точки) та безпосередньо вивантажуйте їх в OSM (чи пізніше, якщо зараз ви в автономному режимі) +\n• Параметр запису подорожі також і в тлі (коли пристрій перебуває в режимі сну) +\nOsmAnd — вільне й відкрите програмне забезпечення, що активно розвивається. Кожен може допомогти, звітуючи про помилки, поліпшуючи переклад чи розробляючи нові функції. Також проєкт покладається на фінансові внески для оплати розробки та тестування нових функціональних можливостей. \n Приблизне охоплення мап та якість: \n • Західна Європа: **** @@ -2505,7 +2505,7 @@ Сортувати за: Використовувати розташування Додати Ваше місце розташування як точку початку при плануванні маршруту. - Моє місцезнаходження + Моє місцеперебування Фініш Планувати маршрут Впорядкувати @@ -3339,11 +3339,11 @@ Розмір зображення, якість звуку та відео Логін, пароль, редагування в безмережному режимі Оберіть значок, колір та назву - Дозволяє ділитися поточним місцезнаходженням, використовуючи запис поїздки. + Дозволяє ділитися поточним місцеперебуванням, використовуючи запис поїздки. Мережеве відстеження Точність журналювання Ви можете знайти всі записи в %1$s або в теці OsmAnd за допомогою файлового провідника. - Ваші нотатки OSM знаходяться в %1$s. + Ваші нотатки OSM розміщено в %1$s. Відеонотатки Фотонотатки Перерахунок маршруту From eb086b2df68c647215b95acc9877ce6d0b3f92d5 Mon Sep 17 00:00:00 2001 From: ace shadow Date: Mon, 25 Jan 2021 22:43:09 +0000 Subject: [PATCH 020/125] Translated using Weblate (Slovak) Currently translated at 100.0% (3645 of 3645 strings) --- OsmAnd/res/values-sk/strings.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OsmAnd/res/values-sk/strings.xml b/OsmAnd/res/values-sk/strings.xml index e89e617204..95f34a3db1 100644 --- a/OsmAnd/res/values-sk/strings.xml +++ b/OsmAnd/res/values-sk/strings.xml @@ -160,7 +160,7 @@ Vymazať úpravu Asynchrónne upravovanie OSM: OSM POI/poznámky uložené v zariadení - Zobraziť a spravovať OSM bodu záujmu/poznámky uložené v databáze v zariadení. + Zobraziť a spravovať OSM body záujmu/poznámky uložené v databáze v zariadení. Určiť interval stopovania naživo. Interval stopovania naživo Zadajte webovú adresu stopovania naživo so syntaxom parametrov: lat={0}, lon={1}, timestamp={2}, hdop={3}, altitude={4}, speed={5}, bearing={6}. @@ -698,7 +698,7 @@ Filter \'%1$s\' bol vytvorený Východzí bod nebol zatiaľ zistený. Zrušiť sťahovanie\? - Základná potrebná pre základné funkcie aplikácie bola zaradená na stiahnutie. + Základná mapa potrebná pre základné funkcie aplikácie bola zaradená na stiahnutie. Názov Kategória DDD.DDDDD @@ -1091,7 +1091,7 @@ Svetové korekcie nadmorskej výšky Svetové námorné značky Svetové platby bitcoinom - Svetová základná mapa + Svetová prehľadová mapa Svetová lyžiarska mapa Chorvátsky (Hrvatski) Čínsky (中国的) @@ -2696,7 +2696,7 @@ Záložka Skryť celý popis Zobraziť celý popis - Pre jazdenie mimo cesty v teréne (off-road) založený na štýle \'Topo\' a pre použitie s podkladovou mapou zo zelených satelitných snímok. Znížená hrúbka ciest, zvýšená hrúbka poľných ciest, chorníkov, cyklistických a iných trás. + Pre jazdenie mimo cesty v teréne (off-road) založený na štýle \'Topo\' a pre použitie s podkladovou mapou zo zelených satelitných snímok. Znížená hrúbka ciest, zvýšená hrúbka poľných ciest, chodníkov, cyklistických a iných trás. Pre námornú navigáciu. Obsahuje bóje, majáky, vodné cesty, morské trasy a značky, prístavy, námorné služby a hĺbkové vrstevnice. Pre lyžovanie. Obsahuje zjazdovky, lyžiarske vleky a iné objekty pre lyžiarov. Druhoradé objekty na mape sú menej výrazné. Jednoduchý štýl pre navigáciu auta. Príjemný nočný režim, vrstevnice, kontrastné oranžové cesty, druhoradé objekty na mape sú menej výrazné. From 46c5f92470370b8b483f884bb273e42c9a9ae27e Mon Sep 17 00:00:00 2001 From: Yaron Shahrabani Date: Tue, 26 Jan 2021 09:29:21 +0000 Subject: [PATCH 021/125] Translated using Weblate (Hebrew) Currently translated at 99.6% (3634 of 3645 strings) --- OsmAnd/res/values-iw/strings.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/OsmAnd/res/values-iw/strings.xml b/OsmAnd/res/values-iw/strings.xml index 2d8c31ec67..5cefe14bd4 100644 --- a/OsmAnd/res/values-iw/strings.xml +++ b/OsmAnd/res/values-iw/strings.xml @@ -3986,4 +3986,11 @@ אופני הרים שגיאת שרת: %1$s השם כבר קיים + סטייה ממסלול + הגעה ליעד + הצגת המסלול על המפה + רכיבה חשמלית + רכיבת הרים + רכיבת כביש + רכיבה רגילה \ No newline at end of file From badd53e160247c0cf86985249487766b2ffaa11e Mon Sep 17 00:00:00 2001 From: Ajeje Brazorf Date: Sun, 24 Jan 2021 15:30:22 +0000 Subject: [PATCH 022/125] Translated using Weblate (Sardinian) Currently translated at 99.2% (3619 of 3645 strings) --- OsmAnd/res/values-sc/strings.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/OsmAnd/res/values-sc/strings.xml b/OsmAnd/res/values-sc/strings.xml index c4b514317b..c0caa235d6 100644 --- a/OsmAnd/res/values-sc/strings.xml +++ b/OsmAnd/res/values-sc/strings.xml @@ -3964,4 +3964,22 @@ Ischerta sa cartella Ischerta una cartella o crea·nde una noa Bòidu + Intervallos de tempus e de distàntzia + Incumintza a registrare + Ammustra sa rasta in sa mapa + Cadira a rodas + Escursionismu + A pee + Tziclismu elètricu + Tziclismu de monte + Tziclismu in carreras + Tziclismu regulare + Veìculu de trasportu + Camioneta + Càmion + Motorinu (Scooter) + Bitzicleta de cursa + MTB (motosilurante) + Errore de su serbidore: %1$s + Su nùmene esistit giai \ No newline at end of file From 356de76cba6ba479bfa5b1638d8a6164350dbc2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1ns?= Date: Mon, 25 Jan 2021 16:24:59 +0000 Subject: [PATCH 023/125] Translated using Weblate (Galician) Currently translated at 99.6% (3631 of 3645 strings) --- OsmAnd/res/values-gl/strings.xml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/OsmAnd/res/values-gl/strings.xml b/OsmAnd/res/values-gl/strings.xml index 9ee8d8b590..c39329ec8e 100644 --- a/OsmAnd/res/values-gl/strings.xml +++ b/OsmAnd/res/values-gl/strings.xml @@ -3976,4 +3976,26 @@ Lon %2$s Selecionar cartafol ou engadir un novo Seleccionar cartafol Baleiro + Chegar ao destino + Xiro + Intres de tempo e distancia + A hora do anuncio das diferentes indicacións por voz depende do tipo de mensaxe, a velocidade de navegación actual e a velocidade de navegación predefinida. + Hora do anuncio + Comezar gravación + Amosar pista no mapa + Cadeira de rodas + Sendeirismo + Camiñando + Ciclismo eléctrico + Ciclismo de montaña + Ciclismo de estrada + Ciclismo regular + Vehículos pesados + Camión pequeno + Camión + Scooter + Bicicleta de carreiras + Bicicleta de montaña + Erro do servidor: %1$s + O nome xa existe \ No newline at end of file From 9173a177b561f183a8f2af5a7b18a646ac8975ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sveinn=20=C3=AD=20Felli?= Date: Sun, 24 Jan 2021 09:55:27 +0000 Subject: [PATCH 024/125] Translated using Weblate (Icelandic) Currently translated at 100.0% (3645 of 3645 strings) --- OsmAnd/res/values-is/strings.xml | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/OsmAnd/res/values-is/strings.xml b/OsmAnd/res/values-is/strings.xml index 168f905c8b..ebb0385e37 100644 --- a/OsmAnd/res/values-is/strings.xml +++ b/OsmAnd/res/values-is/strings.xml @@ -3966,4 +3966,43 @@ Hjólandi Bíll Afrita heimilisfang + Leiðagerð af netinu + Leiðagerð af netinu + Möppur + Veldu möppu + Veldu möppu eða bættu við nýrri + Tómt + Greina eftir millibilum (uppskipting millibila) + Senda inn í OpenStreetMap + Breyta ferli + Endurnefna feril + Skipta um möppu + sek + Framhjá + Aðkoma + Langur undirbúningur + Undirbúa + Utan leiðar + Koma á áfangastað + Beygja + Millibil tíma og vegalengda + Tilkynningar mismunandi talskilaboða fara eftir tegund skilaboða, fyrirliggjandi hraða leiðsagnar og sjálfgefnum hraða leiðsagnar. + Tími tilkynninga + Hefja upptöku + Birta feril á korti + Hjólastólar + Gönguferðir + Gangandi + Rafmagnshjól + Fjallahjól + Götuhjól + Venjulegar hjólreiðar + Þyngri vöruflutningabifreiðar + Litlar vöruflutningabifreiðar + Flutningabifreiðar + Skellinöðrur + Götukeppnishjól + Fjallahjól + Villa í netþjóni: %1$s + Nafnið er þegar til staðar \ No newline at end of file From 3305cfc0e4263d38d5157b632cdda6943e268c43 Mon Sep 17 00:00:00 2001 From: jilv220 Date: Sun, 24 Jan 2021 15:45:55 +0000 Subject: [PATCH 025/125] Translated using Weblate (Chinese (Simplified)) Currently translated at 67.9% (2477 of 3645 strings) --- OsmAnd/res/values-zh-rCN/strings.xml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/values-zh-rCN/strings.xml b/OsmAnd/res/values-zh-rCN/strings.xml index 97d64f7faf..6b188df900 100644 --- a/OsmAnd/res/values-zh-rCN/strings.xml +++ b/OsmAnd/res/values-zh-rCN/strings.xml @@ -491,7 +491,7 @@ 靠右行驶 隐藏多边形 渲染模式 - + 显示等高线 显示更多地图细节 路线规划数据 格式 @@ -1120,7 +1120,7 @@ 不要发送匿名应用使用统计信息 恢复购买内容 可见性 - OsmAnd 会搜集您打开应用的哪一部分的信息。您的位置永远不会被发送至服务器,您输入进应用的任何数据或者浏览的区域、搜索内容和下载内容同样不会被搜集。 + OsmAnd 只会搜集您打开应用的那一部分的信息。您的位置永远不会被发送至服务器,您输入进应用的任何数据或者浏览的区域、搜索内容和下载内容同样不会被搜集。 不要在启动时显示信息 感谢您购买完整版本的 OsmAnd! 操作名称 @@ -1915,7 +1915,7 @@ 音频/视频注记 轻触\"使用位置 …\"以在此添加注记。 音频注记 - + 高山远足表(SAC) 依据 SAC 分级计算路径 徒步旅行符号叠加层 根据 OSMC 轨迹渲染路径。 @@ -3112,4 +3112,16 @@ 添加地址 输入地址 REC + OsmAnd将为选择的配置文件连接路线点。 + 在之前添加点 + 在之后添加点 + 路线点 + 保存为路线点 + 路线点1 + 保存路线点 + 用于在线跟踪的时间缓冲区 + 添加轨迹航点 + 添加轨迹航点 + 将轨迹记录到GPX文件 + 当应用程序被杀死时,跟踪日志将被暂停(通过最近的应用程序)。(OsmAnd背景指示会从Android通知栏中消失)。 \ No newline at end of file From 03e48eaa03df42b1325a67389a9603bbbce7a154 Mon Sep 17 00:00:00 2001 From: Ihor Hordiichuk Date: Mon, 25 Jan 2021 22:31:10 +0000 Subject: [PATCH 026/125] Translated using Weblate (Ukrainian) Currently translated at 100.0% (271 of 271 strings) Translation: OsmAnd/Telegram Translate-URL: https://hosted.weblate.org/projects/osmand/telegram/uk/ --- OsmAnd-telegram/res/values-uk/strings.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/OsmAnd-telegram/res/values-uk/strings.xml b/OsmAnd-telegram/res/values-uk/strings.xml index 8e706abe85..40c91d4ed3 100644 --- a/OsmAnd-telegram/res/values-uk/strings.xml +++ b/OsmAnd-telegram/res/values-uk/strings.xml @@ -93,9 +93,9 @@ Поділитися Назад Оберіть час - Оберіть контакти та групи, з якими ви бажаєте поділитися своїм місцезнаходженням. + Виберіть контакти та групи, з якими ви бажаєте поділитися своїм місцеперебуванням. Пошук: Група або контакт - Поділитися місцезнаходженням + Поділитися розташуванням Показати на карті OsmAnd онлайн GPS Tracker Номер телефону @@ -111,7 +111,7 @@ Запуск Вихід із системи Закриття - Служба визначення місцезнаходження вимкнена. Увімкнути\? + Служба визначення розташування вимкнена. Увімкнути\? Ви не увійшли до системи Продовжити Скасувати @@ -225,8 +225,8 @@ Дата початку - кінця Налаштування GPX Ми не збирали дані за вибраний день - Надіслати місцезнаходження як - Виберіть, як виглядатимуть повідомлення з вашим місцезнаходженням. + Надіслати місцеперебування як + Виберіть, як виглядатимуть повідомлення з вашим місцеперебуванням. Час руху Показати кількість зібраних та відправлених GPS-точок. Виберіть час для відображення @@ -234,7 +234,7 @@ Не рухається Встановити денний час для всіх Видимий час для всіх - Встановіть час, коли вибрані контакти та групи будуть бачити ваше місцезнаходження в режимі реального часу. + Встановіть час, коли вибрані контакти та групи бачитимуть ваше місцеперебування в режимі реального часу. Виберіть одного з локальних постачальників, щоб поділитися своїм місцеположенням. Пошук контактів Пошук у всіх своїх групах та контактах. From 2f20e7e5c1c1247e0d8f0941ff8b6f8eddf7f2a8 Mon Sep 17 00:00:00 2001 From: Skalii Date: Tue, 26 Jan 2021 13:52:43 +0200 Subject: [PATCH 027/125] "Show/hide action" blue background should be shown whilte tapping; Don't show statistic if it doesn't have data. --- .../net/osmand/plus/track/OverviewCard.java | 196 +++++++++++------- 1 file changed, 120 insertions(+), 76 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/track/OverviewCard.java b/OsmAnd/src/net/osmand/plus/track/OverviewCard.java index d5d8e44ce4..71c31a7c6c 100644 --- a/OsmAnd/src/net/osmand/plus/track/OverviewCard.java +++ b/OsmAnd/src/net/osmand/plus/track/OverviewCard.java @@ -16,6 +16,7 @@ import android.widget.TextView; import androidx.annotation.ColorRes; import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.widget.AppCompatImageView; import androidx.recyclerview.widget.DefaultItemAnimator; import androidx.recyclerview.widget.LinearLayoutManager; @@ -28,6 +29,7 @@ import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType; import net.osmand.plus.myplaces.SegmentActionsListener; @@ -36,7 +38,6 @@ import net.osmand.plus.widgets.TextViewEx; import net.osmand.util.Algorithms; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import static net.osmand.plus.myplaces.TrackActivityFragmentAdapter.isGpxFileSelected; @@ -44,6 +45,7 @@ import static net.osmand.plus.track.OptionsCard.APPEARANCE_BUTTON_INDEX; import static net.osmand.plus.track.OptionsCard.DIRECTIONS_BUTTON_INDEX; import static net.osmand.plus.track.OptionsCard.EDIT_BUTTON_INDEX; import static net.osmand.plus.track.OptionsCard.SHOW_ON_MAP_BUTTON_INDEX; +import static net.osmand.plus.track.OverviewCard.StatBlock.ItemType.*; public class OverviewCard extends BaseCard { @@ -55,15 +57,19 @@ public class OverviewCard extends BaseCard { private final TrackDisplayHelper displayHelper; private final GPXFile gpxFile; - private final GpxDisplayItemType[] filterTypes = new GpxDisplayItemType[] {GpxDisplayItemType.TRACK_SEGMENT}; + private final GpxDisplayItemType[] filterTypes = {GpxDisplayItemType.TRACK_SEGMENT}; private final SegmentActionsListener listener; + private boolean gpxFileSelected; + private GpxDisplayItem gpxItem; public OverviewCard(@NonNull MapActivity mapActivity, @NonNull TrackDisplayHelper displayHelper, @NonNull SegmentActionsListener listener) { super(mapActivity); this.displayHelper = displayHelper; - this.gpxFile = displayHelper.getGpx(); this.listener = listener; + gpxFile = displayHelper.getGpx(); + gpxFileSelected = isGpxFileSelected(app, gpxFile); + gpxItem = TrackDisplayHelper.flatten(displayHelper.getOriginalGroups(filterTypes)).get(0); } @Override @@ -93,87 +99,82 @@ public class OverviewCard extends BaseCard { } void initStatBlocks() { - GpxDisplayItem gpxItem = TrackDisplayHelper.flatten(displayHelper.getOriginalGroups(filterTypes)).get(0); GPXTrackAnalysis analysis = gpxItem.analysis; - boolean joinSegments = displayHelper.isJoinSegments(); - float totalDistance = !joinSegments && gpxItem.isGeneralTrack() ? analysis.totalDistanceWithoutGaps : analysis.totalDistance; - float timeSpan = !joinSegments && gpxItem.isGeneralTrack() ? analysis.timeSpanWithoutGaps : analysis.timeSpan; - String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app); - String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app); - String avg = OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app); - String max = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app); + if (analysis != null) { + boolean joinSegments = displayHelper.isJoinSegments(); + float totalDistance = !joinSegments && gpxItem.isGeneralTrack() ? analysis.totalDistanceWithoutGaps : analysis.totalDistance; + float timeSpan = !joinSegments && gpxItem.isGeneralTrack() ? analysis.timeSpanWithoutGaps : analysis.timeSpan; + String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app); + String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app); + String avg = OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app); + String max = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app); + List items = new ArrayList<>(); - StatBlock sDistance = new StatBlock(app.getString(R.string.distance), OsmAndFormatter.getFormattedDistance(totalDistance, app), - R.drawable.ic_action_track_16, R.color.icon_color_default_light, GPXDataSetType.ALTITUDE, GPXDataSetType.SPEED); - StatBlock sAscent = new StatBlock(app.getString(R.string.altitude_ascent), asc, - R.drawable.ic_action_arrow_up_16, R.color.gpx_chart_red, GPXDataSetType.SLOPE, null); - StatBlock sDescent = new StatBlock(app.getString(R.string.altitude_descent), desc, - R.drawable.ic_action_arrow_down_16, R.color.gpx_pale_green, GPXDataSetType.ALTITUDE, GPXDataSetType.SLOPE); - StatBlock sAvSpeed = new StatBlock(app.getString(R.string.average_speed), avg, - R.drawable.ic_action_speed_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null); - StatBlock sMaxSpeed = new StatBlock(app.getString(R.string.max_speed), max, - R.drawable.ic_action_max_speed_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null); - StatBlock sTimeSpan = new StatBlock(app.getString(R.string.shared_string_time_span), - Algorithms.formatDuration((int) (timeSpan / 1000), app.accessibilityEnabled()), - R.drawable.ic_action_time_span_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null); + StatBlock.prepareData(analysis, items, app.getString(R.string.distance), OsmAndFormatter.getFormattedDistance(totalDistance, app), + R.drawable.ic_action_track_16, R.color.icon_color_default_light, GPXDataSetType.ALTITUDE, GPXDataSetType.SPEED, ITEM_DISTANCE); + StatBlock.prepareData(analysis, items, app.getString(R.string.altitude_ascent), asc, + R.drawable.ic_action_arrow_up_16, R.color.gpx_chart_red, GPXDataSetType.SLOPE, null, ITEM_ALTITUDE); + StatBlock.prepareData(analysis, items, app.getString(R.string.altitude_descent), desc, + R.drawable.ic_action_arrow_down_16, R.color.gpx_pale_green, GPXDataSetType.ALTITUDE, GPXDataSetType.SLOPE, ITEM_ALTITUDE); + StatBlock.prepareData(analysis, items, app.getString(R.string.average_speed), avg, + R.drawable.ic_action_speed_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null, ITEM_SPEED); + StatBlock.prepareData(analysis, items, app.getString(R.string.max_speed), max, + R.drawable.ic_action_max_speed_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null, ITEM_SPEED); + StatBlock.prepareData(analysis, items, app.getString(R.string.shared_string_time_span), + Algorithms.formatDuration((int) (timeSpan / 1000), app.accessibilityEnabled()), + R.drawable.ic_action_time_span_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null, ITEM_TIME); - LinearLayoutManager llManager = new LinearLayoutManager(app); - llManager.setOrientation(LinearLayoutManager.HORIZONTAL); - rvOverview.setLayoutManager(llManager); - rvOverview.setItemAnimator(new DefaultItemAnimator()); - List items = Arrays.asList(sDistance, sAscent, sDescent, sAvSpeed, sMaxSpeed, sTimeSpan); - final StatBlockAdapter siAdapter = new StatBlockAdapter(items); - rvOverview.setAdapter(siAdapter); - rvOverview.addItemDecoration(new HorizontalDividerDecoration(app)); + final StatBlockAdapter sbAdapter = new StatBlockAdapter(items); + LinearLayoutManager llManager = new LinearLayoutManager(app); + llManager.setOrientation(LinearLayoutManager.HORIZONTAL); + rvOverview.setLayoutManager(llManager); + rvOverview.setItemAnimator(new DefaultItemAnimator()); + rvOverview.setAdapter(sbAdapter); + rvOverview.addItemDecoration(new HorizontalDividerDecoration(app)); + } } private void initShowButton(final int iconColorDef, final int iconColorPres) { - final AppCompatImageView image = showButton.findViewById(R.id.image); - final AppCompatImageView filled = showButton.findViewById(R.id.filled); - final int iconShowResId = R.drawable.ic_action_view; - final int iconHideResId = R.drawable.ic_action_hide; - final boolean[] gpxFileSelected = {isGpxFileSelected(app, gpxFile)}; - filled.setImageResource(R.drawable.bg_topbar_shield_exit_ref); - filled.setAlpha(gpxFileSelected[0] ? 1f : 0.1f); - setImageDrawable(image, gpxFileSelected[0] ? iconShowResId : iconHideResId, - gpxFileSelected[0] ? iconColorPres : iconColorDef); - showButton.setOnClickListener(new View.OnClickListener() { + initButton(showButton, SHOW_ON_MAP_BUTTON_INDEX, null, iconColorDef, iconColorPres, new StatBlockCallback() { @Override - public void onClick(View v) { - gpxFileSelected[0] = !gpxFileSelected[0]; - filled.setAlpha(gpxFileSelected[0] ? 1f : 0.1f); - setImageDrawable(image, gpxFileSelected[0] ? iconShowResId : iconHideResId, - gpxFileSelected[0] ? iconColorPres : iconColorDef); - CardListener listener = getListener(); - if (listener != null) { - listener.onCardButtonPressed(OverviewCard.this, SHOW_ON_MAP_BUTTON_INDEX); - } + public void run(AppCompatImageView image) { + gpxFileSelected = isGpxFileSelected(app, gpxFile); + setImageDrawable(image, gpxFileSelected ? R.drawable.ic_action_view : R.drawable.ic_action_hide, iconColorDef); + image.requestLayout(); } }); } - private void initAppearanceButton(int iconColorDef, int iconColorPres) { - initButton(appearanceButton, APPEARANCE_BUTTON_INDEX, R.drawable.ic_action_appearance, iconColorDef, iconColorPres); + private void initAppearanceButton(@ColorRes int iconColorDef, @ColorRes int iconColorPres) { + initButton(appearanceButton, APPEARANCE_BUTTON_INDEX, R.drawable.ic_action_appearance, iconColorDef, iconColorPres, null); } - private void initEditButton(int iconColorDef, int iconColorPres) { - initButton(editButton, EDIT_BUTTON_INDEX, R.drawable.ic_action_edit_dark, iconColorDef, iconColorPres); + private void initEditButton(@ColorRes int iconColorDef, @ColorRes int iconColorPres) { + initButton(editButton, EDIT_BUTTON_INDEX, R.drawable.ic_action_edit_dark, iconColorDef, iconColorPres, null); } - private void initDirectionsButton(int iconColorDef, int iconColorPres) { - initButton(directionsButton, DIRECTIONS_BUTTON_INDEX, R.drawable.ic_action_gdirections_dark, iconColorDef, iconColorPres); + private void initDirectionsButton(@ColorRes int iconColorDef, @ColorRes int iconColorPres) { + initButton(directionsButton, DIRECTIONS_BUTTON_INDEX, R.drawable.ic_action_gdirections_dark, iconColorDef, iconColorPres, null); } - private void initButton(View item, final int buttonIndex, int iconResId, int iconColorDef, int iconColorPres) { - final AppCompatImageView image = item.findViewById(R.id.image); + private void initButton(View item, final int buttonIndex, @DrawableRes Integer iconResId, + @ColorRes int iconColorDef, @ColorRes int iconColorPres, @Nullable final StatBlockCallback callback) { + final AppCompatImageView icon = item.findViewById(R.id.image); final AppCompatImageView filled = item.findViewById(R.id.filled); filled.setImageResource(R.drawable.bg_topbar_shield_exit_ref); filled.setAlpha(0.1f); - setImageDrawable(image, iconResId, iconColorDef); - setOnTouchItem(item, image, filled, iconResId, iconColorDef, iconColorPres); + if (callback != null) { + callback.run(icon); + } else { + setImageDrawable(icon, iconResId, iconColorDef); + } + setOnTouchItem(item, icon, filled, iconResId, iconColorDef, iconColorPres); item.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + if (callback != null) { + callback.run(icon); + } CardListener listener = getListener(); if (listener != null) { listener.onCardButtonPressed(OverviewCard.this, buttonIndex); @@ -182,12 +183,13 @@ public class OverviewCard extends BaseCard { }); } - private void setImageDrawable(ImageView iv, @DrawableRes int resId, @ColorRes int color) { - Drawable icon = app.getUIUtilities().getIcon(resId, color); + private void setImageDrawable(ImageView iv, @DrawableRes Integer resId, @ColorRes int color) { + Drawable icon = resId != null ? app.getUIUtilities().getIcon(resId, color) + : UiUtilities.tintDrawable(iv.getDrawable(), getResolvedColor(color)); iv.setImageDrawable(icon); } - private void setOnTouchItem(View item, final ImageView image, final ImageView filled, @DrawableRes final int resId, @ColorRes final int colorDef, @ColorRes final int colorPres) { + private void setOnTouchItem(View item, final ImageView image, final ImageView filled, @DrawableRes final Integer resId, @ColorRes final int colorDef, @ColorRes final int colorPres) { item.setOnTouchListener(new View.OnTouchListener() { @SuppressLint("ClickableViewAccessibility") @Override @@ -210,6 +212,10 @@ public class OverviewCard extends BaseCard { }); } + private interface StatBlockCallback { + void run(AppCompatImageView image); + } + private class StatBlockAdapter extends RecyclerView.Adapter { private final List statBlocks; @@ -242,18 +248,17 @@ public class OverviewCard extends BaseCard { holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - GpxDisplayItem gpxItem = TrackDisplayHelper.flatten(displayHelper.getOriginalGroups(filterTypes)).get(0); if (gpxItem != null && gpxItem.analysis != null) { ArrayList list = new ArrayList<>(); - if (item.firstType != null) { - list.add(item.firstType); - } - if (item.secondType != null) { - list.add(item.secondType); - } - if (list.size() > 0) { - gpxItem.chartTypes = list.toArray(new GPXDataSetType[0]); + if (gpxItem.analysis.hasElevationData || gpxItem.analysis.isSpeedSpecified() || gpxItem.analysis.hasSpeedData) { + if (item.firstType != null) { + list.add(item.firstType); + } + if (item.secondType != null) { + list.add(item.secondType); + } } + gpxItem.chartTypes = list.size() > 0 ? list.toArray(new GPXDataSetType[0]) : null; gpxItem.locationOnMap = gpxItem.locationStart; listener.openAnalyzeOnMap(gpxItem); @@ -285,7 +290,7 @@ public class OverviewCard extends BaseCard { private final int marginH; public HorizontalDividerDecoration(Context context) { - int[] ATTRS = new int[] {android.R.attr.listDivider}; + int[] ATTRS = {android.R.attr.listDivider}; final TypedArray ta = context.obtainStyledAttributes(ATTRS); divider = ta.getDrawable(0); // DrawableCompat.setTint(divider, context.getResources().getColor(R.color.divider_color_light)); //todo change drawable color @@ -317,7 +322,7 @@ public class OverviewCard extends BaseCard { } } - private static class StatBlock { + protected static class StatBlock { private final String title; private final String value; @@ -325,15 +330,54 @@ public class OverviewCard extends BaseCard { private final int imageColorId; private final GPXDataSetType firstType; private final GPXDataSetType secondType; + private final ItemType itemType; public StatBlock(String title, String value, @DrawableRes int imageResId, @ColorRes int imageColorId, - GPXDataSetType firstType, GPXDataSetType secondType) { + GPXDataSetType firstType, GPXDataSetType secondType, ItemType itemType) { this.title = title; this.value = value; this.imageResId = imageResId; this.imageColorId = imageColorId; this.firstType = firstType; this.secondType = secondType; + this.itemType = itemType; + } + + public static void prepareData(GPXTrackAnalysis analysis, List listItems, String title, + String value, @DrawableRes int imageResId, @ColorRes int imageColorId, + GPXDataSetType firstType, GPXDataSetType secondType, ItemType itemType) { + StatBlock statBlock = new StatBlock(title, value, imageResId, imageColorId, firstType, secondType, itemType); + switch (statBlock.itemType) { + case ITEM_DISTANCE: { + listItems.add(statBlock); + break; + } + case ITEM_ALTITUDE: { + if (analysis.hasElevationData) { + listItems.add(statBlock); + } + break; + } + case ITEM_SPEED: { + if (analysis.isSpeedSpecified()) { + listItems.add(statBlock); + } + break; + } + case ITEM_TIME: { + if (analysis.hasSpeedData) { + listItems.add(statBlock); + } + break; + } + } + } + + public enum ItemType { + ITEM_DISTANCE, + ITEM_ALTITUDE, + ITEM_SPEED, + ITEM_TIME; } } } \ No newline at end of file From 198be0c573d19c7160cd84ad8f347e199a4ff0cd Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 26 Jan 2021 14:07:56 +0200 Subject: [PATCH 028/125] Change group color --- .../plus/myplaces/EditTrackGroupDialogFragment.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java index a38c9e993c..19c398685c 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java @@ -81,11 +81,15 @@ public class EditTrackGroupDialogFragment extends MenuBottomSheetDialogFragment } items.add(new TitleItem(getCategoryName(app, group.getName()))); + boolean trackPoints = group.getType() == GpxDisplayItemType.TRACK_POINTS; SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(group.getGpx().path); - if (group.getType() == GpxDisplayItemType.TRACK_POINTS && selectedGpxFile != null) { + if (trackPoints && selectedGpxFile != null) { items.add(createShowOnMapItem(selectedGpxFile)); } items.add(createEditNameItem()); + if (trackPoints) { + items.add(createChangeColorItem()); + } items.add(new OptionsDividerItem(app)); // items.add(createCopyToMarkersItem()); @@ -272,8 +276,10 @@ public class EditTrackGroupDialogFragment extends MenuBottomSheetDialogFragment final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; final View changeColorView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.change_fav_color, null); - ((ImageView) changeColorView.findViewById(R.id.change_color_icon)) - .setImageDrawable(getContentIcon(R.drawable.ic_action_appearance)); + ImageView icon = ((ImageView) changeColorView.findViewById(R.id.change_color_icon)); + icon.setImageDrawable(getContentIcon(R.drawable.ic_action_appearance)); + int margin = getResources().getDimensionPixelSize(R.dimen.bottom_sheet_icon_margin_large); + UiUtilities.setMargins(icon, 0, 0, margin, 0); updateColorView((ImageView) changeColorView.findViewById(R.id.colorImage)); return new BaseBottomSheetItem.Builder() .setCustomView(changeColorView) From 40638958a3ef3f3abef7a4836c81dd384ce5f043 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 26 Jan 2021 14:23:47 +0200 Subject: [PATCH 029/125] AvailableGPXFragment --- .../plus/myplaces/AvailableGPXFragment.java | 28 ++++++++----------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java index 06a38d3ef2..6b404cd842 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java @@ -13,8 +13,6 @@ import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.os.Handler; -import android.text.Editable; -import android.text.TextWatcher; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -27,7 +25,6 @@ import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; -import android.widget.EditText; import android.widget.ExpandableListView; import android.widget.Filter; import android.widget.Filterable; @@ -103,14 +100,12 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.regex.Pattern; import static net.osmand.plus.GpxSelectionHelper.CURRENT_TRACK; import static net.osmand.plus.myplaces.FavoritesActivity.GPX_TAB; -import static net.osmand.plus.myplaces.FavoritesActivity.OPEN_GPX_REQUEST; import static net.osmand.plus.myplaces.FavoritesActivity.TAB_ID; +import static net.osmand.plus.track.TrackMenuFragment.OPEN_TRACK_MENU; import static net.osmand.util.Algorithms.capitalizeFirstLetter; -import static net.osmand.util.Algorithms.collectDirs; import static net.osmand.util.Algorithms.formatDuration; import static net.osmand.util.Algorithms.objectEquals; import static net.osmand.util.Algorithms.removeAllFiles; @@ -348,10 +343,10 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement currentGpxView.findViewById(R.id.current_track_info).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Intent newIntent = new Intent(getActivity(), getMyApplication().getAppCustomization().getTrackActivity()); - newIntent.putExtra(TrackActivity.CURRENT_RECORDING, true); - newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(newIntent); + FragmentActivity activity = getActivity(); + if (activity != null) { + openTrack(activity, null); + } } }); listView.addHeaderView(currentGpxView); @@ -419,16 +414,15 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement updateCurrentTrack(); } - public static void openTrack(Activity a, final File f) { - Intent newIntent = new Intent(a, ((OsmandApplication) a.getApplication()).getAppCustomization().getTrackActivity()); - // causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + public static void openTrack(Activity activity, final File f) { + Bundle bundle = new Bundle(); + bundle.putBoolean(OPEN_TRACK_MENU, true); if (f == null) { - newIntent.putExtra(TrackActivity.CURRENT_RECORDING, true); + bundle.putBoolean(TrackActivity.CURRENT_RECORDING, true); } else { - newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, f.getAbsolutePath()); + bundle.putString(TrackActivity.TRACK_FILE_NAME, f.getAbsolutePath()); } - newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - a.startActivityForResult(newIntent, OPEN_GPX_REQUEST); + MapActivity.launchMapActivityMoveToTop(activity, null, null, bundle); } public void reloadTracks() { From 34ecacb9fc7c4992df140a4ee8acc401ac0ff59f Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 26 Jan 2021 14:36:18 +0200 Subject: [PATCH 030/125] Open track menu fragment initial commit --- .../net/osmand/plus/helpers/IntentHelper.java | 9 +++++++++ .../osmand/plus/importfiles/ImportHelper.java | 6 ++---- .../builders/WptPtMenuBuilder.java | 14 ++++---------- .../SelectedGpxMenuController.java | 19 ++----------------- .../CoordinateInputDialogFragment.java | 7 ++----- .../mapmarkers/MapMarkersDialogFragment.java | 8 +++----- .../MeasurementToolFragment.java | 7 ++----- .../SavedTrackBottomSheetDialogFragment.java | 8 +++----- .../plus/myplaces/AvailableGPXFragment.java | 8 ++++---- .../backend/OsmAndAppCustomization.java | 4 ---- .../osmand/plus/track/TrackMenuFragment.java | 4 +++- .../views/AddGpxPointBottomSheetHelper.java | 16 +++++----------- .../WikivoyageArticleDialogFragment.java | 10 +++------- 13 files changed, 42 insertions(+), 78 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java b/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java index e4e6fac9dd..0d569ba880 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java @@ -27,6 +27,7 @@ import net.osmand.plus.settings.backend.ApplicationMode; 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.track.TrackMenuFragment; import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; @@ -37,6 +38,8 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import static net.osmand.plus.activities.TrackActivity.CURRENT_RECORDING; +import static net.osmand.plus.activities.TrackActivity.TRACK_FILE_NAME; import static net.osmand.plus.osmedit.oauth.OsmOAuthHelper.OsmAuthorizationListener; public class IntentHelper { @@ -250,6 +253,12 @@ public class IntentHelper { } mapActivity.setIntent(null); } + if (intent.hasExtra(TrackMenuFragment.OPEN_TRACK_MENU)) { + String path = intent.getStringExtra(TRACK_FILE_NAME); + boolean currentRecording = intent.getBooleanExtra(CURRENT_RECORDING, false); + TrackMenuFragment.showInstance(mapActivity, path, currentRecording); + mapActivity.setIntent(null); + } } } diff --git a/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java b/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java index a46ae659b8..05b84cdd58 100644 --- a/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java +++ b/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java @@ -66,6 +66,7 @@ import static net.osmand.IndexConstants.SQLITE_CHART_FILE_EXT; import static net.osmand.IndexConstants.SQLITE_EXT; import static net.osmand.IndexConstants.WPT_CHART_FILE_EXT; import static net.osmand.data.FavouritePoint.DEFAULT_BACKGROUND_TYPE; +import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; import static net.osmand.plus.myplaces.FavoritesActivity.GPX_TAB; import static net.osmand.plus.myplaces.FavoritesActivity.TAB_ID; import static net.osmand.plus.settings.backend.backup.SettingsHelper.REPLACE_KEY; @@ -596,10 +597,7 @@ public class ImportHelper { private void showGpxInDetailsActivity(String gpxFilePath) { if (!Algorithms.isEmpty(gpxFilePath)) { - Intent newIntent = new Intent(activity, app.getAppCustomization().getTrackActivity()); - newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, gpxFilePath); - newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - activity.startActivity(newIntent); + openTrack(activity, new File(gpxFilePath)); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java index 2a4912f232..9231ca53b0 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java @@ -1,7 +1,6 @@ package net.osmand.plus.mapcontextmenu.builders; import android.content.Context; -import android.content.Intent; import android.view.View; import android.widget.LinearLayout; @@ -16,13 +15,11 @@ import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; -import net.osmand.plus.settings.backend.OsmAndAppCustomization; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.TrackActivity; -import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.CollapsableView; +import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.views.layers.POIMapLayer; import net.osmand.plus.widgets.TextViewEx; import net.osmand.util.Algorithms; @@ -32,6 +29,8 @@ import java.text.DateFormat; import java.util.Date; import java.util.List; +import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; + public class WptPtMenuBuilder extends MenuBuilder { private final WptPt wpt; @@ -181,12 +180,7 @@ public class WptPtMenuBuilder extends MenuBuilder { button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - OsmAndAppCustomization appCustomization = app.getAppCustomization(); - final Intent intent = new Intent(context, appCustomization.getTrackActivity()); - intent.putExtra(TrackActivity.TRACK_FILE_NAME, gpxFile.path); - intent.putExtra(TrackActivity.OPEN_POINTS_TAB, true); - intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); - context.startActivity(intent); + openTrack(mapActivity, new File(gpxFile.path)); } }); view.addView(button); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java index 8a86fbe134..427e0cce35 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java @@ -1,7 +1,6 @@ package net.osmand.plus.mapcontextmenu.controllers; import android.app.ProgressDialog; -import android.content.Intent; import android.graphics.drawable.Drawable; import android.os.AsyncTask; @@ -17,9 +16,7 @@ import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; 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.activities.TrackActivity; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.mapcontextmenu.builders.SelectedGpxMenuBuilder; @@ -45,21 +42,9 @@ public class SelectedGpxMenuController extends MenuController { leftTitleButtonController = new TitleButtonController() { @Override public void buttonPressed() { - OsmandApplication app = mapActivity.getMyApplication(); SelectedGpxFile selectedGpxFile = selectedGpxPoint.getSelectedGpxFile(); - if (Version.isDeveloperVersion(app)) { - mapActivity.getContextMenu().hide(false); - TrackMenuFragment.showInstance(mapActivity, selectedGpxFile.getGpxFile().path, selectedGpxFile.isShowCurrentTrack()); - } else { - Intent intent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getTrackActivity()); - if (selectedGpxFile.isShowCurrentTrack()) { - intent.putExtra(TrackActivity.CURRENT_RECORDING, true); - } else { - intent.putExtra(TrackActivity.TRACK_FILE_NAME, selectedGpxFile.getGpxFile().path); - } - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - mapActivity.startActivity(intent); - } + mapActivity.getContextMenu().hide(false); + TrackMenuFragment.showInstance(mapActivity, selectedGpxFile.getGpxFile().path, selectedGpxFile.isShowCurrentTrack()); } }; leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_open_track); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index 09eef3d06c..33a1220629 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -92,6 +92,7 @@ import java.util.Locale; import static android.content.ClipDescription.MIMETYPE_TEXT_PLAIN; import static android.content.Context.CLIPBOARD_SERVICE; +import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; public class CoordinateInputDialogFragment extends DialogFragment implements OsmAndCompassListener, OsmAndLocationListener { @@ -1097,11 +1098,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm .setAction(R.string.shared_string_show, new View.OnClickListener() { @Override public void onClick(View view) { - Intent intent = new Intent(app, app.getAppCustomization().getTrackActivity()); - intent.putExtra(TrackActivity.OPEN_POINTS_TAB, true); - intent.putExtra(TrackActivity.TRACK_FILE_NAME, getGpx().path); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(intent); + openTrack(app, new File(getGpx().path)); } }); UiUtilities.setupSnackbar(snackbar, !lightTheme); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java index 2a50192d03..7a19141567 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java @@ -42,12 +42,14 @@ import net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.MarkerOptions import net.osmand.plus.mapmarkers.OrderByBottomSheetDialogFragment.OrderByFragmentListener; import net.osmand.plus.mapmarkers.SaveAsTrackBottomSheetDialogFragment.MarkerSaveAsTrackFragmentListener; +import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import static net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.GROUPS_MARKERS_MENU; import static net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.HISTORY_MARKERS_MENU; +import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; public class MapMarkersDialogFragment extends DialogFragment implements OnGroupSyncedListener { @@ -486,11 +488,7 @@ public class MapMarkersDialogFragment extends DialogFragment implements OnGroupS .setAction(R.string.shared_string_show, new View.OnClickListener() { @Override public void onClick(View view) { - Intent intent = new Intent(mapActivity, getMyApplication().getAppCustomization().getTrackActivity()); - intent.putExtra(TrackActivity.TRACK_FILE_NAME, gpxPath); - intent.putExtra(TrackActivity.OPEN_POINTS_TAB, true); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(intent); + openTrack(mapActivity, new File(gpxPath)); } }); UiUtilities.setupSnackbar(snackbar, !lightTheme); diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index 6fb7aa7cab..01a39ce793 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -104,6 +104,7 @@ import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCo import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCommandMode.AFTER; import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCommandMode.ALL; import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCommandMode.BEFORE; +import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; public class MeasurementToolFragment extends BaseOsmAndFragment implements RouteBetweenPointsFragmentListener, OptionsFragmentListener, GpxApproximationFragmentListener, SelectedPointFragmentListener, @@ -1914,11 +1915,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route GpxData gpxData = editingCtx.getGpxData(); GPXFile gpx = gpxData != null ? gpxData.getGpxFile() : null; if (gpx != null) { - Intent newIntent = new Intent(mapActivity, app.getAppCustomization().getTrackActivity()); - newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, gpx.path); - newIntent.putExtra(TrackActivity.OPEN_TRACKS_LIST, true); - newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(newIntent); + openTrack(mapActivity, new File(gpx.path)); } } editingCtx.resetRouteSettingsListener(); diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/SavedTrackBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/SavedTrackBottomSheetDialogFragment.java index fc4f5aeece..c7d5eb67da 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/SavedTrackBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/SavedTrackBottomSheetDialogFragment.java @@ -24,6 +24,8 @@ import net.osmand.util.Algorithms; import java.io.File; +import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; + public class SavedTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { public static final String TAG = SavedTrackBottomSheetDialogFragment.class.getSimpleName(); @@ -60,11 +62,7 @@ public class SavedTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFr public void onClick(View v) { FragmentActivity activity = getActivity(); if (activity != null && !Algorithms.isEmpty(fileName)) { - OsmandApplication app = ((OsmandApplication) activity.getApplication()); - Intent newIntent = new Intent(activity, app.getAppCustomization().getTrackActivity()); - newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, fileName); - newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - activity.startActivity(newIntent); + openTrack(activity, new File(fileName)); } dismiss(); } diff --git a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java index 6b404cd842..e7d04884bc 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java @@ -414,15 +414,15 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement updateCurrentTrack(); } - public static void openTrack(Activity activity, final File f) { + public static void openTrack(Context context, File file) { Bundle bundle = new Bundle(); bundle.putBoolean(OPEN_TRACK_MENU, true); - if (f == null) { + if (file == null) { bundle.putBoolean(TrackActivity.CURRENT_RECORDING, true); } else { - bundle.putString(TrackActivity.TRACK_FILE_NAME, f.getAbsolutePath()); + bundle.putString(TrackActivity.TRACK_FILE_NAME, file.getAbsolutePath()); } - MapActivity.launchMapActivityMoveToTop(activity, null, null, bundle); + MapActivity.launchMapActivityMoveToTop(context, null, null, bundle); } public void reloadTracks() { diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndAppCustomization.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndAppCustomization.java index 2a7158ac11..485ada9072 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndAppCustomization.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndAppCustomization.java @@ -178,10 +178,6 @@ public class OsmAndAppCustomization { return MapActivity.class; } - public Class getTrackActivity() { - return TrackActivity.class; - } - public Class getFavoritesActivity() { return FavoritesActivity.class; } diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index f169248511..5d1d64192c 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -110,6 +110,8 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card SegmentActionsListener, RenameCallback, OnTrackFileMoveListener, OnPointsDeleteListener, OsmAndLocationListener, OsmAndCompassListener { + public static final String OPEN_TRACK_MENU = "open_track_menu"; + public static final String TAG = TrackMenuFragment.class.getName(); private static final Log log = PlatformUtil.getLog(TrackMenuFragment.class); @@ -199,7 +201,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(Bundle savedInstanceState) {// super.onCreate(savedInstanceState); app = requireMyApplication(); GpxDbHelper gpxDbHelper = app.getGpxDbHelper(); diff --git a/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java b/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java index a317fece3f..c1f20a4ea0 100644 --- a/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java +++ b/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java @@ -1,6 +1,5 @@ package net.osmand.plus.views; -import android.content.Intent; import android.graphics.PointF; import android.view.View; import android.widget.ImageView; @@ -14,7 +13,6 @@ import net.osmand.data.RotatedTileBox; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.editors.RtePtEditor; import net.osmand.plus.mapcontextmenu.editors.WptPtEditor; @@ -22,6 +20,10 @@ import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener; import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.views.layers.ContextMenuLayer; +import java.io.File; + +import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; + public class AddGpxPointBottomSheetHelper implements OnDismissListener { private final View view; private final TextView title; @@ -149,18 +151,10 @@ public class AddGpxPointBottomSheetHelper implements OnDismissListener { if (fragment != null) { fragment.show(); } else { - openTrackActivity(); + openTrack(mapActivity, new File(newGpxPoint.getGpx().path)); } } - private void openTrackActivity() { - Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getTrackActivity()); - newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, newGpxPoint.getGpx().path); - newIntent.putExtra(TrackActivity.OPEN_POINTS_TAB, true); - newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - mapActivity.startActivity(newIntent); - } - public static class NewGpxPoint { private PointDescription pointDescription; private GPXFile gpx; diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index 9e2339f3ee..5354d90ec9 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -27,14 +27,12 @@ import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager.BackStackEntry; import net.osmand.AndroidUtils; -import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; import net.osmand.IndexConstants; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; -import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.development.OsmandDevelopmentPlugin; import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.settings.backend.OsmandSettings; @@ -53,6 +51,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; +import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; import static net.osmand.plus.wikipedia.WikiArticleShowImages.OFF; @@ -151,11 +150,8 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme return; } TravelHelper travelHelper = getMyApplication().getTravelHelper(); - File path = travelHelper.createGpxFile(article); - Intent newIntent = new Intent(activity, getMyApplication().getAppCustomization().getTrackActivity()); - newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, path.getAbsolutePath()); - newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(newIntent); + File file = travelHelper.createGpxFile(article); + openTrack(activity, new File(file.getAbsolutePath())); } }); From 0b3225a423cf51ea0bed171a8c1851253431140e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Babos=20G=C3=A1bor?= Date: Tue, 26 Jan 2021 12:33:40 +0000 Subject: [PATCH 031/125] Translated using Weblate (Hungarian) Currently translated at 100.0% (3651 of 3651 strings) --- OsmAnd/res/values-hu/strings.xml | 36 +++++++++++++++++++------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/OsmAnd/res/values-hu/strings.xml b/OsmAnd/res/values-hu/strings.xml index cbc176d6fe..d883e7189b 100644 --- a/OsmAnd/res/values-hu/strings.xml +++ b/OsmAnd/res/values-hu/strings.xml @@ -312,7 +312,7 @@ \n \nÁtmenetileg átállítva online CloudMade-re. Nem sikerült megtalálni a megadott mappát. - Adatok tárolási helye + Adatok tárolási mappája {0} verzió telepítve ({1}). Összeállítás letöltése… OsmAnd {0} – {1}, {2} MB. Telepíted? @@ -362,7 +362,7 @@ Tömegközlekedés keresésének alaphelyzetbe állítása Felvett hang Nincs betöltött vektoros térkép - Nem található GPX fálj a tracks könyvtárban + Nem található GPX-fálj a tracks mappában Nem sikerült beolvasni a GPX-adatokat. Vektoros OSM térkép Közlekedés keresése megállónál @@ -491,7 +491,7 @@ Teljes távolság %1$s, utazási idő %2$d óra %3$d perc. Online vagy offline útvonaltervező szolgáltatás. Útvonaltervező szolgáltatás - A tárolási könyvtár nem érhető el a memóriakártyán! + A tárolási mappa nem érhető el a memóriakártyán! Letöltés {0} - {1} ? {0} régióhoz már le van töltve offline adat ({1}). Frissíted ({2})? Cím @@ -547,7 +547,7 @@ Jelenlegi nyomvonal mentése A navigáció alatti nyomvonalfelvételhez adja meg a naplózási intervallumot Naplózási intervallum navigáció közben - Navigáció közben a GPX útvonal automatikusan mentésre kerül az OsmAnd „tracks” könyvtárába. + Navigáció közben a GPX útvonal automatikusan mentésre kerül az OsmAnd „tracks” mappájába. Térképcsempe újratöltése Célpont Hozzáadás a „Kedvencek”-hez @@ -1818,7 +1818,7 @@ Éjjel Hónap és ország: Eltávolítás - Az alkalmazás átváltott belső memóriára, mert a kijelölt adattároló mappa írásvédett. Kérjük, jelöljön ki egy írható tárolási mappát. + Az alkalmazás átváltott belső memóriára, mert a kijelölt adattároló mappa írásvédett. Kérjük, jelöljön ki egy írható tárolómappát. Osztott memória Felső sáv Útvonal újraszámítása @@ -2157,7 +2157,7 @@ Érvényes teljes OLC \nA következő területet jeleníti meg: %1$s x %2$s Gomb, amely lépteti az alábbi listát. - GPX fájlok könyvtárának kijelölése + GPX-fájlok mappájának kijelölése Nem sikerült áthelyezni a fájlt. Áthelyezés Nyomvonalak @@ -2191,7 +2191,7 @@ Mellékutak előnyben részesítése Előnyben részesített terep: sík vagy dombos. Lejtő - Új mappa létrehozása + Új mappa hozzáadása Pont(ok) törölve. Biztosan törli ez(eke)t a ponto(ka)t: %1$d\? Érintendő fordulók az útvonalon @@ -3059,7 +3059,7 @@ Bővítménybeállítások Töltsd le a részletes %s térképet a terület megtekintéséhez. Az OsmAnd belső tárolója (felhasználók és más alkalmazások számára rejtett). - Tárolás mappájának módosítása + Tároló mappa módosítása Szélességkorlátozás Adja meg az útvonalakon a járművekre vonatkozó szélességkorlátozást. Bizonyos útvonalak és úttípusok elkerülése @@ -3086,10 +3086,10 @@ Szövegfelolvasó motor indítása sikertelen. %1$s • %2$s %1$s GB szabad (%2$s GB-ból) - Add meg a könyvtár elérési útvonalát - Könyvtár… - OsmAnd adatok elérési útvonalának beillesztése - Módosítod az OsmAnd adatokat tároló könyvtárat\? + Add meg a mappa elérési útvonalát + Mappa… + Az OsmAnd-adatokat tartalmazó mappa elérési útvonalának beillesztése + Módosítod az OsmAnd adatok mappáját\? Áthelyezés az új helyre %1$s TB %1$s GB @@ -3103,11 +3103,11 @@ Domborzatárnyékolás megjelenítése Domborzatárnyékolás elrejtése Domborzatárnyékolás megjelenítése/elrejtése - Nyomvonal tárolási könyvtára - A nyomvonalak a \'rec\' könyvtárban tárolhatók, havi vagy napi bontás szerinti könyvtárakban. + Nyomvonal tárolási mappája + A nyomvonalak tárolhatók a \'rec\' mappában, illetve havi vagy napi bontás szerinti mappákban. Nyomvonalak felvétele a \'rec\' mappába Nyomvonalak felvétele napi bontású mappákba - Nyomvonalak rögzítése a rögzítés napja szerinti almappákba (pl. 2018-01-01). + Nyomvonalak felvétele a felvétel napja szerinti almappákba (pl. 2018-01-01). Profil exportálása OsmAnd profil: %1$s \'%1$s\' már létezik. Felülírja\? @@ -3994,4 +3994,10 @@ A különféle hangutasítások bemondási ideje függ az utasítás típusától, az aktuális navigációs sebességtől és az alapértelmezett navigációs sebességtől. Bemondás ideje Roller + Törli ezt az online útvonaltervezőt\? + Az egész elolvasása + Leírás szerkesztése + Útpontok törlése + Másolás a térképjelölők közé + Másolás a kedvencek közé \ No newline at end of file From 569493f32bc37a67396e140bfe5510fb00d4ec9c Mon Sep 17 00:00:00 2001 From: Ldm Public Date: Tue, 26 Jan 2021 12:44:02 +0000 Subject: [PATCH 032/125] Translated using Weblate (French) Currently translated at 100.0% (3651 of 3651 strings) --- OsmAnd/res/values-fr/strings.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index 27659178d3..e9c1c87b65 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -3990,4 +3990,10 @@ Vélo tout terrain Vélo électrique Vélo + Copier vers les marques de carte + Copier vers les favoris + Supprimer ce moteur de routage en ligne \? + Lire la suite + Modifier la description + Supprimer les points de passage \ No newline at end of file From 959e7f411c0e2b6fd498eebcfbd19638d4d3ba94 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Tue, 26 Jan 2021 14:54:33 +0200 Subject: [PATCH 033/125] Upload Photo: bottom sheet with the progress bar Uplaod progress dialog Upload complete dialog --- .../layout/bottom_sheet_with_progress_bar.xml | 49 +++++ OsmAnd/res/values/strings.xml | 5 +- ...UploadPhotoWithProgressBarBottomSheet.java | 111 ++++++++++ .../plus/mapcontextmenu/MenuBuilder.java | 157 +++----------- .../mapcontextmenu/UploadPhotosAsyncTask.java | 203 ++++++++++++++++++ 5 files changed, 393 insertions(+), 132 deletions(-) create mode 100644 OsmAnd/res/layout/bottom_sheet_with_progress_bar.xml create mode 100644 OsmAnd/src/net/osmand/plus/dialogs/UploadPhotoWithProgressBarBottomSheet.java create mode 100644 OsmAnd/src/net/osmand/plus/mapcontextmenu/UploadPhotosAsyncTask.java diff --git a/OsmAnd/res/layout/bottom_sheet_with_progress_bar.xml b/OsmAnd/res/layout/bottom_sheet_with_progress_bar.xml new file mode 100644 index 0000000000..fd1f27bbae --- /dev/null +++ b/OsmAnd/res/layout/bottom_sheet_with_progress_bar.xml @@ -0,0 +1,49 @@ + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 79d3a211b4..4b4b94826e 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,7 +11,10 @@ Thx - Hardy --> - + Uploaded %1$s of %2$d + Uploading %1$s of %2$d + Upload completed + Uploading Copy to favorites Copy to map markers Delete waypoints diff --git a/OsmAnd/src/net/osmand/plus/dialogs/UploadPhotoWithProgressBarBottomSheet.java b/OsmAnd/src/net/osmand/plus/dialogs/UploadPhotoWithProgressBarBottomSheet.java new file mode 100644 index 0000000000..73e09845a3 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/dialogs/UploadPhotoWithProgressBarBottomSheet.java @@ -0,0 +1,111 @@ +package net.osmand.plus.dialogs; + +import android.app.Activity; +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.ProgressBar; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.FragmentManager; + +import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; +import net.osmand.plus.UiUtilities.DialogButtonType; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.base.MenuBottomSheetDialogFragment; +import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem; +import net.osmand.plus.widgets.TextViewEx; + +public class UploadPhotoWithProgressBarBottomSheet extends MenuBottomSheetDialogFragment { + + public static final String TAG = UploadPhotoWithProgressBarBottomSheet.class.getSimpleName(); + + private ProgressBar progressBar; + private TextView uploadedPhotosCounter; + private TextViewEx uploadedPhotosTitle; + private int maxProgress; + + @Override + public void createMenuItems(Bundle savedInstanceState) { + Context context = requireContext(); + LayoutInflater inflater = UiUtilities.getInflater(context, nightMode); + View view = inflater.inflate(R.layout.bottom_sheet_with_progress_bar, null); + + progressBar = view.findViewById(R.id.progress_bar); + progressBar.setMax(maxProgress); + uploadedPhotosCounter = view.findViewById(R.id.description); + + uploadedPhotosTitle = view.findViewById(R.id.title); + + BaseBottomSheetItem descriptionItem = new BottomSheetItemWithDescription.Builder() + .setDescription(getString(R.string.uploading_count, progressBar.getProgress(), maxProgress)) + .setTitle(getString(R.string.upload_photo)) + .setCustomView(view) + .create(); + items.add(descriptionItem); + + int padding = getResources().getDimensionPixelSize(R.dimen.content_padding_small); + items.add(new DividerSpaceItem(requireContext(), padding)); + } + + public void onProgressUpdate(int progress) { + progressBar.setProgress(progress); + uploadedPhotosCounter.setText((getString(R.string.uploading_count, progressBar.getProgress(), maxProgress))); + } + + public void onUploadingFinished() { + TextViewEx dismissButtonText = dismissButton.findViewById(R.id.button_text); + setDismissButtonTextId(R.string.shared_string_close); + dismissButtonText.setText(R.string.shared_string_close); + uploadedPhotosTitle.setText(R.string.upload_photo_completed); + uploadedPhotosCounter.setText((getString(R.string.uploaded_count, progressBar.getProgress(), maxProgress))); + } + + @Override + protected boolean useVerticalButtons() { + return true; + } + + @Override + protected int getDismissButtonTextId() { + return R.string.shared_string_cancel; + } + + @Override + protected DialogButtonType getRightBottomButtonType() { + return DialogButtonType.PRIMARY; + } + + @Override + public int getSecondDividerHeight() { + return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_icon_margin); + } + + @Override + protected void onRightBottomButtonClick() { + dismiss(); + } + + @Nullable + public MapActivity getMapActivity() { + Activity activity = getActivity(); + if (activity instanceof MapActivity) { + return (MapActivity) activity; + } + return null; + } + + public static UploadPhotoWithProgressBarBottomSheet showInstance(@NonNull FragmentManager fragmentManager, int maxProgress) { + UploadPhotoWithProgressBarBottomSheet fragment = new UploadPhotoWithProgressBarBottomSheet(); + fragment.maxProgress = maxProgress; + fragment.setRetainInstance(true); + fragmentManager.beginTransaction().add(fragment, TAG).commitAllowingStateLoss(); + return fragment; + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 3890046fac..98198d65f3 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -1,22 +1,19 @@ package net.osmand.plus.mapcontextmenu; import android.app.Activity; +import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.res.ColorStateList; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.graphics.Color; -import android.graphics.Matrix; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; import android.net.Uri; import android.os.AsyncTask; -import android.os.Handler; -import android.os.Looper; +import android.os.Build; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.TextUtils; @@ -46,7 +43,6 @@ import net.osmand.data.PointDescription; import net.osmand.data.QuadRect; import net.osmand.osm.PoiCategory; import net.osmand.osm.PoiType; -import net.osmand.osm.io.NetworkUtils; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; @@ -54,6 +50,7 @@ import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.Version; import net.osmand.plus.activities.ActivityResultListener; +import net.osmand.plus.activities.ActivityResultListener.OnActivityResultListener; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.FontCache; import net.osmand.plus.mapcontextmenu.builders.cards.AbstractCard; @@ -80,12 +77,7 @@ import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; import org.apache.commons.logging.Log; -import org.openplacereviews.opendb.util.exception.FailedVerificationException; -import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -99,7 +91,6 @@ import static net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCa public class MenuBuilder { private static final int PICK_IMAGE = 1231; - private static final int MAX_IMAGE_LENGTH = 2048; private static final Log LOG = PlatformUtil.getLog(MenuBuilder.class); public static final float SHADOW_HEIGHT_TOP_DP = 17f; public static final int TITLE_LIMIT = 60; @@ -425,7 +416,7 @@ public class MenuBuilder { if (false) { AddPhotosBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager()); } else { - registerResultListener(view); + registerResultListener(); final String baseUrl = OPRConstants.getBaseUrl(app); final String name = app.getSettings().OPR_USERNAME.get(); final String privateKey = app.getSettings().OPR_ACCESS_TOKEN.get(); @@ -443,6 +434,9 @@ public class MenuBuilder { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); + if (Build.VERSION.SDK_INT > 18) { + intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); + } mapActivity.startActivityForResult(Intent.createChooser(intent, mapActivity.getString(R.string.select_picture)), PICK_IMAGE); } @@ -472,132 +466,33 @@ public class MenuBuilder { false, null, false); } - private void registerResultListener(final View view) { - mapActivity.registerActivityResultListener(new ActivityResultListener(PICK_IMAGE, new ActivityResultListener. - OnActivityResultListener() { + private void registerResultListener() { + mapActivity.registerActivityResultListener(new ActivityResultListener(PICK_IMAGE, new OnActivityResultListener() { @Override public void onResult(int resultCode, Intent resultData) { if (resultData != null) { - handleSelectedImage(view, resultData.getData()); + List imagesUri = new ArrayList<>(); + Uri data = resultData.getData(); + if (data != null) { + imagesUri.add(data); + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + ClipData clipData = resultData.getClipData(); + if (clipData != null) { + for (int i = 0; i < clipData.getItemCount(); i++) { + Uri uri = resultData.getClipData().getItemAt(i).getUri(); + if (uri != null) { + imagesUri.add(uri); + } + } + } + } + execute(new UploadPhotosAsyncTask(mapActivity, imagesUri, getLatLon(), placeId, getAdditionalCardParams(), imageCardListener)); } } })); } - private void handleSelectedImage(final View view, final Uri uri) { - Thread t = new Thread(new Runnable() { - @Override - public void run() { - InputStream inputStream = null; - try { - inputStream = app.getContentResolver().openInputStream(uri); - if (inputStream != null) { - uploadImageToPlace(inputStream); - } - } catch (Exception e) { - LOG.error(e); - String str = app.getString(R.string.cannot_upload_image); - showToastMessage(str); - } finally { - Algorithms.closeStream(inputStream); - } - } - }); - t.start(); - } - - private void uploadImageToPlace(InputStream image) { - InputStream serverData = new ByteArrayInputStream(compressImageToJpeg(image)); - final String baseUrl = OPRConstants.getBaseUrl(app); - // all these should be constant - String url = baseUrl + "api/ipfs/image"; - String response = NetworkUtils.sendPostDataRequest(url, "file", "compressed.jpeg", serverData); - if (response != null) { - int res = 0; - try { - StringBuilder error = new StringBuilder(); - String privateKey = app.getSettings().OPR_ACCESS_TOKEN.get(); - String username = app.getSettings().OPR_USERNAME.get(); - res = openDBAPI.uploadImage( - placeId, - baseUrl, - privateKey, - username, - response, error); - if (res != 200) { - showToastMessage(error.toString()); - } else { - //ok, continue - } - } catch (FailedVerificationException e) { - LOG.error(e); - checkTokenAndShowScreen(); - } - if (res != 200) { - //image was uploaded but not added to blockchain - checkTokenAndShowScreen(); - } else { - String str = app.getString(R.string.successfully_uploaded_pattern, 1, 1); - showToastMessage(str); - //refresh the image - execute(new GetImageCardsTask(mapActivity, getLatLon(), getAdditionalCardParams(), imageCardListener)); - } - } else { - checkTokenAndShowScreen(); - } - } - - private void showToastMessage(final String str) { - new Handler(Looper.getMainLooper()).post(new Runnable() { - @Override - public void run() { - Toast.makeText(mapActivity.getBaseContext(), str, Toast.LENGTH_LONG).show(); - } - }); - } - - //This method runs on non main thread - private void checkTokenAndShowScreen() { - final String baseUrl = OPRConstants.getBaseUrl(app); - final String name = app.getSettings().OPR_USERNAME.get(); - final String privateKey = app.getSettings().OPR_ACCESS_TOKEN.get(); - if (openDBAPI.checkPrivateKeyValid(baseUrl, name, privateKey)) { - String str = app.getString(R.string.cannot_upload_image); - showToastMessage(str); - } else { - app.runInUIThread(new Runnable() { - @Override - public void run() { - OprStartFragment.showInstance(mapActivity.getSupportFragmentManager()); - } - }); - } - } - - private byte[] compressImageToJpeg(InputStream image) { - BufferedInputStream bufferedInputStream = new BufferedInputStream(image); - Bitmap bmp = BitmapFactory.decodeStream(bufferedInputStream); - ByteArrayOutputStream os = new ByteArrayOutputStream(); - int h = bmp.getHeight(); - int w = bmp.getWidth(); - boolean scale = false; - while (w > MAX_IMAGE_LENGTH || h > MAX_IMAGE_LENGTH) { - w = w / 2; - h = h / 2; - scale = true; - } - if (scale) { - Matrix matrix = new Matrix(); - matrix.postScale(w, h); - Bitmap resizedBitmap = Bitmap.createBitmap( - bmp, 0, 0, w, h, matrix, false); - bmp.recycle(); - bmp = resizedBitmap; - } - bmp.compress(Bitmap.CompressFormat.JPEG, 90, os); - return os.toByteArray(); - } - private void startLoadingImages() { if (onlinePhotoCardsRow == null) { return; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/UploadPhotosAsyncTask.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/UploadPhotosAsyncTask.java new file mode 100644 index 0000000000..ce59999a11 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/UploadPhotosAsyncTask.java @@ -0,0 +1,203 @@ +package net.osmand.plus.mapcontextmenu; + +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Matrix; +import android.net.Uri; +import android.os.AsyncTask; + +import androidx.fragment.app.FragmentActivity; + +import net.osmand.AndroidUtils; +import net.osmand.PlatformUtil; +import net.osmand.data.LatLon; +import net.osmand.osm.io.NetworkUtils; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.dialogs.UploadPhotoWithProgressBarBottomSheet; +import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask; +import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask.GetImageCardsListener; +import net.osmand.plus.openplacereviews.OPRConstants; +import net.osmand.plus.openplacereviews.OprStartFragment; +import net.osmand.plus.osmedit.opr.OpenDBAPI; +import net.osmand.util.Algorithms; + +import org.apache.commons.logging.Log; +import org.openplacereviews.opendb.util.exception.FailedVerificationException; + +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.lang.ref.WeakReference; +import java.util.List; +import java.util.Map; + +public class UploadPhotosAsyncTask extends AsyncTask { + + private static final Log LOG = PlatformUtil.getLog(UploadPhotosAsyncTask.class); + + private static final int MAX_IMAGE_LENGTH = 2048; + + private final OsmandApplication app; + private final WeakReference activityRef; + private UploadPhotoWithProgressBarBottomSheet progress; + + private final OpenDBAPI openDBAPI = new OpenDBAPI(); + private final LatLon latLon; + private final List data; + private final String[] placeId; + private final Map params; + private final GetImageCardsListener imageCardListener; + + public UploadPhotosAsyncTask(MapActivity activity, List data, LatLon latLon, String[] placeId, + Map params, GetImageCardsListener imageCardListener) { + app = (OsmandApplication) activity.getApplicationContext(); + activityRef = new WeakReference<>(activity); + this.data = data; + this.latLon = latLon; + this.params = params; + this.placeId = placeId; + this.imageCardListener = imageCardListener; + } + + @Override + protected void onPreExecute() { + FragmentActivity activity = activityRef.get(); + if (AndroidUtils.isActivityNotDestroyed(activity)) { + progress = UploadPhotoWithProgressBarBottomSheet.showInstance(activity.getSupportFragmentManager(), data.size()); + } + } + + protected Void doInBackground(Void... uris) { + for (int i = 0; i < data.size(); i++) { + if (isCancelled()) { + break; + } + Uri uri = data.get(i); + handleSelectedImage(uri); + publishProgress(i); + } + return null; + } + + @Override + protected void onProgressUpdate(Integer... values) { + if (progress != null) { + progress.onProgressUpdate(values[0]); + } + } + + @Override + protected void onPostExecute(Void aVoid) { + if (progress != null) { + progress.onUploadingFinished(); + } + } + + private void handleSelectedImage(final Uri uri) { + InputStream inputStream = null; + try { + inputStream = app.getContentResolver().openInputStream(uri); + if (inputStream != null) { + uploadImageToPlace(inputStream); + } + } catch (Exception e) { + LOG.error(e); + app.showToastMessage(R.string.cannot_upload_image); + } finally { + Algorithms.closeStream(inputStream); + } + } + + private void uploadImageToPlace(InputStream image) { + InputStream serverData = new ByteArrayInputStream(compressImageToJpeg(image)); + final String baseUrl = OPRConstants.getBaseUrl(app); + // all these should be constant + String url = baseUrl + "api/ipfs/image"; + String response = NetworkUtils.sendPostDataRequest(url, "file", "compressed.jpeg", serverData); + if (response != null) { + int res = 0; + try { + StringBuilder error = new StringBuilder(); + String privateKey = app.getSettings().OPR_ACCESS_TOKEN.get(); + String username = app.getSettings().OPR_USERNAME.get(); + res = openDBAPI.uploadImage( + placeId, + baseUrl, + privateKey, + username, + response, error); + if (res != 200) { + app.showToastMessage(error.toString()); + } else { + //ok, continue + } + } catch (FailedVerificationException e) { + LOG.error(e); + checkTokenAndShowScreen(); + } + if (res != 200) { + //image was uploaded but not added to blockchain + checkTokenAndShowScreen(); + } else { + String str = app.getString(R.string.successfully_uploaded_pattern, 1, 1); + app.showToastMessage(str); + //refresh the image + + MapActivity activity = activityRef.get(); + if (activity != null) { + MenuBuilder.execute(new GetImageCardsTask(activity, latLon, params, imageCardListener)); + } + } + } else { + checkTokenAndShowScreen(); + } + } + + //This method runs on non main thread + private void checkTokenAndShowScreen() { + final String baseUrl = OPRConstants.getBaseUrl(app); + final String name = app.getSettings().OPR_USERNAME.get(); + final String privateKey = app.getSettings().OPR_ACCESS_TOKEN.get(); + if (openDBAPI.checkPrivateKeyValid(baseUrl, name, privateKey)) { + String str = app.getString(R.string.cannot_upload_image); + app.showToastMessage(str); + } else { + app.runInUIThread(new Runnable() { + @Override + public void run() { + MapActivity activity = activityRef.get(); + if (activity != null) { + OprStartFragment.showInstance(activity.getSupportFragmentManager()); + } + } + }); + } + } + + private byte[] compressImageToJpeg(InputStream image) { + BufferedInputStream bufferedInputStream = new BufferedInputStream(image); + Bitmap bmp = BitmapFactory.decodeStream(bufferedInputStream); + ByteArrayOutputStream os = new ByteArrayOutputStream(); + int h = bmp.getHeight(); + int w = bmp.getWidth(); + boolean scale = false; + while (w > MAX_IMAGE_LENGTH || h > MAX_IMAGE_LENGTH) { + w = w / 2; + h = h / 2; + scale = true; + } + if (scale) { + Matrix matrix = new Matrix(); + matrix.postScale(w, h); + Bitmap resizedBitmap = Bitmap.createBitmap( + bmp, 0, 0, w, h, matrix, false); + bmp.recycle(); + bmp = resizedBitmap; + } + bmp.compress(Bitmap.CompressFormat.JPEG, 90, os); + return os.toByteArray(); + } +} \ No newline at end of file From 3d8f0cde147bdb9a74f51e97c45bc5860cef70a5 Mon Sep 17 00:00:00 2001 From: Skalii Date: Tue, 26 Jan 2021 15:42:56 +0200 Subject: [PATCH 034/125] fix last divider in the statistic information block; fix title width in the statistic information item; fix disappearing of the block statistic information after view was hidden under tabs; --- OsmAnd/res/layout/gpx_overview_fragment.xml | 2 +- OsmAnd/res/layout/item_gpx_stat_block.xml | 2 +- OsmAnd/src/net/osmand/plus/track/OverviewCard.java | 14 +++++--------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/OsmAnd/res/layout/gpx_overview_fragment.xml b/OsmAnd/res/layout/gpx_overview_fragment.xml index 0acb712fc6..3c5fe507c7 100644 --- a/OsmAnd/res/layout/gpx_overview_fragment.xml +++ b/OsmAnd/res/layout/gpx_overview_fragment.xml @@ -9,7 +9,7 @@ Date: Tue, 26 Jan 2021 15:57:23 +0200 Subject: [PATCH 035/125] Fix opening gpx files --- .../net/osmand/plus/GpxSelectionHelper.java | 4 +- .../osmand/plus/activities/MapActivity.java | 4 +- .../osmand/plus/importfiles/ImportHelper.java | 5 +- .../builders/WptPtMenuBuilder.java | 5 +- .../CoordinateInputDialogFragment.java | 7 +- .../mapmarkers/MapMarkersDialogFragment.java | 12 +-- .../MeasurementToolFragment.java | 5 +- .../SavedTrackBottomSheetDialogFragment.java | 8 +- .../plus/monitoring/DashTrackFragment.java | 11 +- .../SaveGPXBottomSheetFragment.java | 3 +- .../plus/myplaces/AvailableGPXFragment.java | 20 +--- .../net/osmand/plus/track/OverviewCard.java | 67 ++++++------ .../osmand/plus/track/TrackMenuFragment.java | 100 ++++++++++++++---- .../views/AddGpxPointBottomSheetHelper.java | 4 +- .../WikivoyageArticleDialogFragment.java | 4 +- 15 files changed, 150 insertions(+), 109 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index f23320d091..5dd44bf989 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -153,12 +153,12 @@ public class GpxSelectionHelper { return followTrackListener; } - private static class GpxFileLoaderTask extends AsyncTask { + public static class GpxFileLoaderTask extends AsyncTask { private File fileToLoad; private CallbackWithObject callback; - GpxFileLoaderTask(File fileToLoad, CallbackWithObject callback) { + public GpxFileLoaderTask(File fileToLoad, CallbackWithObject callback) { this.fileToLoad = fileToLoad; this.callback = callback; } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index eb6dcbfbb7..316d5c36b2 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -1628,8 +1628,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven launchMapActivityMoveToTop(activity, null); } - public static void launchMapActivityMoveToTop(Context activity, Bundle intentParams) { - launchMapActivityMoveToTop(activity, intentParams, null, null); + public static void launchMapActivityMoveToTop(Context activity, Bundle prevIntentParams) { + launchMapActivityMoveToTop(activity, prevIntentParams, null, null); } public static void clearPrevActivityIntent() { diff --git a/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java b/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java index 05b84cdd58..3f1456a659 100644 --- a/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java +++ b/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java @@ -29,7 +29,6 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.ActivityResultListener; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.dialogs.ImportGpxBottomSheetDialogFragment; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; @@ -37,6 +36,7 @@ import net.osmand.plus.measurementtool.MeasurementToolFragment; import net.osmand.plus.settings.backend.ExportSettingsType; import net.osmand.plus.settings.backend.backup.SettingsHelper; import net.osmand.plus.settings.backend.backup.SettingsItem; +import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.util.Algorithms; @@ -66,7 +66,6 @@ import static net.osmand.IndexConstants.SQLITE_CHART_FILE_EXT; import static net.osmand.IndexConstants.SQLITE_EXT; import static net.osmand.IndexConstants.WPT_CHART_FILE_EXT; import static net.osmand.data.FavouritePoint.DEFAULT_BACKGROUND_TYPE; -import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; import static net.osmand.plus.myplaces.FavoritesActivity.GPX_TAB; import static net.osmand.plus.myplaces.FavoritesActivity.TAB_ID; import static net.osmand.plus.settings.backend.backup.SettingsHelper.REPLACE_KEY; @@ -597,7 +596,7 @@ public class ImportHelper { private void showGpxInDetailsActivity(String gpxFilePath) { if (!Algorithms.isEmpty(gpxFilePath)) { - openTrack(activity, new File(gpxFilePath)); + TrackMenuFragment.openTrack(activity, new File(gpxFilePath), null); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java index 9231ca53b0..c6a287f86b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java @@ -20,6 +20,7 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.CollapsableView; import net.osmand.plus.mapcontextmenu.MenuBuilder; +import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.views.layers.POIMapLayer; import net.osmand.plus.widgets.TextViewEx; import net.osmand.util.Algorithms; @@ -29,8 +30,6 @@ import java.text.DateFormat; import java.util.Date; import java.util.List; -import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; - public class WptPtMenuBuilder extends MenuBuilder { private final WptPt wpt; @@ -180,7 +179,7 @@ public class WptPtMenuBuilder extends MenuBuilder { button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - openTrack(mapActivity, new File(gpxFile.path)); + TrackMenuFragment.openTrack(mapActivity, new File(gpxFile.path), null); } }); view.addView(button); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index 33a1220629..32e045948d 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -5,7 +5,6 @@ import android.app.Dialog; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; -import android.content.Intent; import android.content.res.ColorStateList; import android.graphics.Rect; import android.graphics.drawable.Drawable; @@ -66,7 +65,6 @@ import net.osmand.plus.GpxSelectionHelper; 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; @@ -78,6 +76,8 @@ import net.osmand.plus.mapmarkers.CoordinateInputFormats.DDM; import net.osmand.plus.mapmarkers.CoordinateInputFormats.DMS; import net.osmand.plus.mapmarkers.CoordinateInputFormats.Format; import net.osmand.plus.mapmarkers.adapters.CoordinateInputAdapter; +import net.osmand.plus.settings.backend.OsmandPreference; +import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.widgets.EditTextEx; import net.osmand.util.Algorithms; import net.osmand.util.LocationParser; @@ -92,7 +92,6 @@ import java.util.Locale; import static android.content.ClipDescription.MIMETYPE_TEXT_PLAIN; import static android.content.Context.CLIPBOARD_SERVICE; -import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; public class CoordinateInputDialogFragment extends DialogFragment implements OsmAndCompassListener, OsmAndLocationListener { @@ -1098,7 +1097,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm .setAction(R.string.shared_string_show, new View.OnClickListener() { @Override public void onClick(View view) { - openTrack(app, new File(getGpx().path)); + TrackMenuFragment.openTrack(app, new File(getGpx().path), null); } }); UiUtilities.setupSnackbar(snackbar, !lightTheme); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java index 7a19141567..f0b226dd1e 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java @@ -1,7 +1,6 @@ package net.osmand.plus.mapmarkers; import android.app.Dialog; -import android.content.Intent; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Bundle; @@ -29,18 +28,18 @@ import net.osmand.AndroidUtils; import net.osmand.Location; import net.osmand.data.LatLon; import net.osmand.plus.LockableViewPager; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersSortByDef; -import net.osmand.plus.mapmarkers.MapMarkersHelper.OnGroupSyncedListener; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.mapmarkers.CoordinateInputDialogFragment.OnPointsSavedListener; import net.osmand.plus.mapmarkers.DirectionIndicationDialogFragment.DirectionIndicationFragmentListener; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersSortByDef; +import net.osmand.plus.mapmarkers.MapMarkersHelper.OnGroupSyncedListener; import net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.MarkerOptionsFragmentListener; import net.osmand.plus.mapmarkers.OrderByBottomSheetDialogFragment.OrderByFragmentListener; import net.osmand.plus.mapmarkers.SaveAsTrackBottomSheetDialogFragment.MarkerSaveAsTrackFragmentListener; +import net.osmand.plus.track.TrackMenuFragment; import java.io.File; import java.util.ArrayList; @@ -49,7 +48,6 @@ import java.util.List; import static net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.GROUPS_MARKERS_MENU; import static net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.HISTORY_MARKERS_MENU; -import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; public class MapMarkersDialogFragment extends DialogFragment implements OnGroupSyncedListener { @@ -169,7 +167,7 @@ public class MapMarkersDialogFragment extends DialogFragment implements OnGroupS viewPager.setAdapter(adapter); progressBar = (ProgressBar) mainView.findViewById(R.id.progress_bar); - + TextView toolbarTitle = mainView.findViewById(R.id.map_markers_toolbar_title); bottomNav = mainView.findViewById(R.id.map_markers_bottom_navigation); toolbarTitle.setTextColor(ContextCompat.getColor(getContext(), lightTheme ? R.color.active_buttons_and_links_text_light : R.color.text_color_primary_dark)); @@ -488,7 +486,7 @@ public class MapMarkersDialogFragment extends DialogFragment implements OnGroupS .setAction(R.string.shared_string_show, new View.OnClickListener() { @Override public void onClick(View view) { - openTrack(mapActivity, new File(gpxPath)); + TrackMenuFragment.openTrack(mapActivity, new File(gpxPath), null); } }); UiUtilities.setupSnackbar(snackbar, !lightTheme); diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index 01a39ce793..cc17d2ac9f 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -47,7 +47,6 @@ import net.osmand.plus.UiUtilities; import net.osmand.plus.Version; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivityActions; -import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.base.BaseOsmAndFragment; import net.osmand.plus.base.ContextMenuFragment.MenuState; import net.osmand.plus.helpers.AndroidUiHelper; @@ -76,6 +75,7 @@ import net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet.DialogMode; import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.views.layers.MapControlsLayer.MapControlsThemeInfoProvider; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType; @@ -104,7 +104,6 @@ import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCo import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCommandMode.AFTER; import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCommandMode.ALL; import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCommandMode.BEFORE; -import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; public class MeasurementToolFragment extends BaseOsmAndFragment implements RouteBetweenPointsFragmentListener, OptionsFragmentListener, GpxApproximationFragmentListener, SelectedPointFragmentListener, @@ -1915,7 +1914,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route GpxData gpxData = editingCtx.getGpxData(); GPXFile gpx = gpxData != null ? gpxData.getGpxFile() : null; if (gpx != null) { - openTrack(mapActivity, new File(gpx.path)); + TrackMenuFragment.openTrack(mapActivity, new File(gpx.path), null); } } editingCtx.resetRouteSettingsListener(); diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/SavedTrackBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/SavedTrackBottomSheetDialogFragment.java index c7d5eb67da..8a2b558c60 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/SavedTrackBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/SavedTrackBottomSheetDialogFragment.java @@ -1,7 +1,6 @@ package net.osmand.plus.measurementtool; import android.app.Activity; -import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.TextView; @@ -10,22 +9,19 @@ import androidx.annotation.NonNull; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; -import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemButton; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem; import net.osmand.plus.helpers.GpxUiHelper; +import net.osmand.plus.track.TrackMenuFragment; import net.osmand.util.Algorithms; import java.io.File; -import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; - public class SavedTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { public static final String TAG = SavedTrackBottomSheetDialogFragment.class.getSimpleName(); @@ -62,7 +58,7 @@ public class SavedTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFr public void onClick(View v) { FragmentActivity activity = getActivity(); if (activity != null && !Algorithms.isEmpty(fileName)) { - openTrack(activity, new File(fileName)); + TrackMenuFragment.openTrack(activity, new File(fileName), null); } dismiss(); } diff --git a/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java index 7b1a4cb26a..28211e5682 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java @@ -13,16 +13,14 @@ import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; -import net.osmand.IndexConstants; import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; +import net.osmand.IndexConstants; import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; -import net.osmand.plus.settings.backend.OsmAndAppCustomization; 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.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.SavingTrackHelper; @@ -33,6 +31,9 @@ import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; import net.osmand.plus.myplaces.AvailableGPXFragment; import net.osmand.plus.myplaces.FavoritesActivity; +import net.osmand.plus.settings.backend.OsmAndAppCustomization; +import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.plus.track.TrackMenuFragment; import java.io.File; import java.util.ArrayList; @@ -153,7 +154,7 @@ public class DashTrackFragment extends DashBaseFragment { view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - AvailableGPXFragment.openTrack(getActivity(), null); + TrackMenuFragment.openTrack(getActivity(), null, null); } }); view.findViewById(R.id.divider_dash).setVisibility(View.VISIBLE); @@ -172,7 +173,7 @@ public class DashTrackFragment extends DashBaseFragment { v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - AvailableGPXFragment.openTrack(getActivity(), f); + TrackMenuFragment.openTrack(getActivity(), f, null); } }); ImageButton showOnMap = ((ImageButton) v.findViewById(R.id.show_on_map)); diff --git a/OsmAnd/src/net/osmand/plus/monitoring/SaveGPXBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/SaveGPXBottomSheetFragment.java index 0b38cb6853..4bd5e6bcda 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/SaveGPXBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/SaveGPXBottomSheetFragment.java @@ -29,6 +29,7 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; import net.osmand.plus.myplaces.AvailableGPXFragment; +import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.widgets.OsmandTextFieldBoxes; import net.osmand.util.Algorithms; @@ -167,7 +168,7 @@ public class SaveGPXBottomSheetFragment extends MenuBottomSheetDialogFragment { } FragmentActivity activity = getActivity(); if (openTrack && activity != null) { - AvailableGPXFragment.openTrack(activity, file); + TrackMenuFragment.openTrack(activity, file, null); } } } diff --git a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java index e7d04884bc..1bde2f3c61 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java @@ -72,7 +72,6 @@ import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; import net.osmand.plus.activities.SavingTrackHelper; -import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.base.OsmandExpandableListFragment; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType; @@ -104,7 +103,7 @@ import java.util.Set; import static net.osmand.plus.GpxSelectionHelper.CURRENT_TRACK; import static net.osmand.plus.myplaces.FavoritesActivity.GPX_TAB; import static net.osmand.plus.myplaces.FavoritesActivity.TAB_ID; -import static net.osmand.plus.track.TrackMenuFragment.OPEN_TRACK_MENU; +import static net.osmand.plus.track.TrackMenuFragment.openTrack; import static net.osmand.util.Algorithms.capitalizeFirstLetter; import static net.osmand.util.Algorithms.formatDuration; import static net.osmand.util.Algorithms.objectEquals; @@ -345,7 +344,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement public void onClick(View v) { FragmentActivity activity = getActivity(); if (activity != null) { - openTrack(activity, null); + openTrack(activity, null, storeState()); } } }); @@ -414,17 +413,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement updateCurrentTrack(); } - public static void openTrack(Context context, File file) { - Bundle bundle = new Bundle(); - bundle.putBoolean(OPEN_TRACK_MENU, true); - if (file == null) { - bundle.putBoolean(TrackActivity.CURRENT_RECORDING, true); - } else { - bundle.putString(TrackActivity.TRACK_FILE_NAME, file.getAbsolutePath()); - } - MapActivity.launchMapActivityMoveToTop(context, null, null, bundle); - } - public void reloadTracks() { asyncLoader = new LoadGpxTask(); asyncLoader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, getActivity()); @@ -834,7 +822,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement app.showToastMessage(R.string.file_can_not_be_moved); } } - + public void renamedTo(File file) { reloadTracks(); } @@ -1609,7 +1597,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement GpxInfo item = allGpxAdapter.getChild(groupPosition, childPosition); if (!selectionMode) { - openTrack(getActivity(), item.file); + openTrack(getActivity(), item.file, storeState()); } else { if (!selectedItems.contains(item)) { selectedItems.add(item); diff --git a/OsmAnd/src/net/osmand/plus/track/OverviewCard.java b/OsmAnd/src/net/osmand/plus/track/OverviewCard.java index d5d8e44ce4..a13e140916 100644 --- a/OsmAnd/src/net/osmand/plus/track/OverviewCard.java +++ b/OsmAnd/src/net/osmand/plus/track/OverviewCard.java @@ -24,11 +24,13 @@ import androidx.recyclerview.widget.RecyclerView.ItemDecoration; import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.GPXTrackAnalysis; +import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType; import net.osmand.plus.myplaces.SegmentActionsListener; import net.osmand.plus.routepreparationmenu.cards.BaseCard; @@ -93,38 +95,43 @@ public class OverviewCard extends BaseCard { } void initStatBlocks() { - GpxDisplayItem gpxItem = TrackDisplayHelper.flatten(displayHelper.getOriginalGroups(filterTypes)).get(0); - GPXTrackAnalysis analysis = gpxItem.analysis; - boolean joinSegments = displayHelper.isJoinSegments(); - float totalDistance = !joinSegments && gpxItem.isGeneralTrack() ? analysis.totalDistanceWithoutGaps : analysis.totalDistance; - float timeSpan = !joinSegments && gpxItem.isGeneralTrack() ? analysis.timeSpanWithoutGaps : analysis.timeSpan; - String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app); - String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app); - String avg = OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app); - String max = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app); + List groups = displayHelper.getOriginalGroups(filterTypes); + if (!Algorithms.isEmpty(groups)) { + GpxDisplayItem gpxItem = TrackDisplayHelper.flatten(groups).get(0); + GPXTrackAnalysis analysis = gpxItem.analysis; + boolean joinSegments = displayHelper.isJoinSegments(); + float totalDistance = !joinSegments && gpxItem.isGeneralTrack() ? analysis.totalDistanceWithoutGaps : analysis.totalDistance; + float timeSpan = !joinSegments && gpxItem.isGeneralTrack() ? analysis.timeSpanWithoutGaps : analysis.timeSpan; + String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app); + String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app); + String avg = OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app); + String max = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app); - StatBlock sDistance = new StatBlock(app.getString(R.string.distance), OsmAndFormatter.getFormattedDistance(totalDistance, app), - R.drawable.ic_action_track_16, R.color.icon_color_default_light, GPXDataSetType.ALTITUDE, GPXDataSetType.SPEED); - StatBlock sAscent = new StatBlock(app.getString(R.string.altitude_ascent), asc, - R.drawable.ic_action_arrow_up_16, R.color.gpx_chart_red, GPXDataSetType.SLOPE, null); - StatBlock sDescent = new StatBlock(app.getString(R.string.altitude_descent), desc, - R.drawable.ic_action_arrow_down_16, R.color.gpx_pale_green, GPXDataSetType.ALTITUDE, GPXDataSetType.SLOPE); - StatBlock sAvSpeed = new StatBlock(app.getString(R.string.average_speed), avg, - R.drawable.ic_action_speed_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null); - StatBlock sMaxSpeed = new StatBlock(app.getString(R.string.max_speed), max, - R.drawable.ic_action_max_speed_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null); - StatBlock sTimeSpan = new StatBlock(app.getString(R.string.shared_string_time_span), - Algorithms.formatDuration((int) (timeSpan / 1000), app.accessibilityEnabled()), - R.drawable.ic_action_time_span_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null); + StatBlock sDistance = new StatBlock(app.getString(R.string.distance), OsmAndFormatter.getFormattedDistance(totalDistance, app), + R.drawable.ic_action_track_16, R.color.icon_color_default_light, GPXDataSetType.ALTITUDE, GPXDataSetType.SPEED); + StatBlock sAscent = new StatBlock(app.getString(R.string.altitude_ascent), asc, + R.drawable.ic_action_arrow_up_16, R.color.gpx_chart_red, GPXDataSetType.SLOPE, null); + StatBlock sDescent = new StatBlock(app.getString(R.string.altitude_descent), desc, + R.drawable.ic_action_arrow_down_16, R.color.gpx_pale_green, GPXDataSetType.ALTITUDE, GPXDataSetType.SLOPE); + StatBlock sAvSpeed = new StatBlock(app.getString(R.string.average_speed), avg, + R.drawable.ic_action_speed_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null); + StatBlock sMaxSpeed = new StatBlock(app.getString(R.string.max_speed), max, + R.drawable.ic_action_max_speed_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null); + StatBlock sTimeSpan = new StatBlock(app.getString(R.string.shared_string_time_span), + Algorithms.formatDuration((int) (timeSpan / 1000), app.accessibilityEnabled()), + R.drawable.ic_action_time_span_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null); - LinearLayoutManager llManager = new LinearLayoutManager(app); - llManager.setOrientation(LinearLayoutManager.HORIZONTAL); - rvOverview.setLayoutManager(llManager); - rvOverview.setItemAnimator(new DefaultItemAnimator()); - List items = Arrays.asList(sDistance, sAscent, sDescent, sAvSpeed, sMaxSpeed, sTimeSpan); - final StatBlockAdapter siAdapter = new StatBlockAdapter(items); - rvOverview.setAdapter(siAdapter); - rvOverview.addItemDecoration(new HorizontalDividerDecoration(app)); + LinearLayoutManager llManager = new LinearLayoutManager(app); + llManager.setOrientation(LinearLayoutManager.HORIZONTAL); + rvOverview.setLayoutManager(llManager); + rvOverview.setItemAnimator(new DefaultItemAnimator()); + List items = Arrays.asList(sDistance, sAscent, sDescent, sAvSpeed, sMaxSpeed, sTimeSpan); + final StatBlockAdapter siAdapter = new StatBlockAdapter(items); + rvOverview.setAdapter(siAdapter); + rvOverview.addItemDecoration(new HorizontalDividerDecoration(app)); + } else { + AndroidUiHelper.updateVisibility(rvOverview, false); + } } private void initShowButton(final int iconColorDef, final int iconColorPres) { diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index 5d1d64192c..8bcfb411ef 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -2,6 +2,8 @@ package net.osmand.plus.track; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; +import android.app.ProgressDialog; +import android.content.Context; import android.content.DialogInterface; import android.content.res.ColorStateList; import android.os.AsyncTask; @@ -22,6 +24,7 @@ import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.TextView; +import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StringRes; @@ -32,6 +35,7 @@ import androidx.fragment.app.FragmentManager; import com.google.android.material.bottomnavigation.BottomNavigationView; import net.osmand.AndroidUtils; +import net.osmand.CallbackWithObject; import net.osmand.FileUtils; import net.osmand.FileUtils.RenameCallback; import net.osmand.GPXUtilities.GPXFile; @@ -42,10 +46,10 @@ import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.QuadRect; import net.osmand.data.RotatedTileBox; -import net.osmand.plus.GpxDbHelper; import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType; +import net.osmand.plus.GpxSelectionHelper.GpxFileLoaderTask; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; @@ -56,6 +60,7 @@ import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities.UpdateLocationViewCache; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivityActions; +import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.base.ContextMenuFragment; import net.osmand.plus.base.ContextMenuScrollFragment; import net.osmand.plus.helpers.AndroidUiHelper; @@ -86,6 +91,7 @@ import net.osmand.util.MapUtils; import org.apache.commons.logging.Log; import java.io.File; +import java.lang.ref.WeakReference; import java.util.List; import static net.osmand.plus.activities.TrackActivity.CURRENT_RECORDING; @@ -201,36 +207,42 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card } @Override - public void onCreate(Bundle savedInstanceState) {// + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); app = requireMyApplication(); - GpxDbHelper gpxDbHelper = app.getGpxDbHelper(); displayHelper = new TrackDisplayHelper(app); updateLocationViewCache = app.getUIUtilities().getUpdateLocationViewCache(); - Bundle arguments = getArguments(); - if (arguments != null) { - String gpxFilePath = arguments.getString(TRACK_FILE_NAME); - boolean currentRecording = arguments.getBoolean(CURRENT_RECORDING, false); - if (currentRecording) { - selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack(); - } else { - File file = new File(gpxFilePath); - displayHelper.setFile(file); - displayHelper.setGpxDataItem(gpxDbHelper.getItem(file)); - selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(gpxFilePath); - } - displayHelper.setGpx(selectedGpxFile.getGpxFile()); - String fileName = Algorithms.getFileWithoutDirs(getGpx().path); - gpxTitle = GpxUiHelper.getGpxTitle(fileName); + if (!selectedGpxFile.isShowCurrentTrack()) { + File file = new File(selectedGpxFile.getGpxFile().path); + displayHelper.setFile(file); + displayHelper.setGpxDataItem(app.getGpxDbHelper().getItem(file)); } + displayHelper.setGpx(selectedGpxFile.getGpxFile()); + String fileName = Algorithms.getFileWithoutDirs(getGpx().path); + gpxTitle = GpxUiHelper.getGpxTitle(fileName); toolbarHeightPx = getResources().getDimensionPixelSize(R.dimen.dashboard_map_toolbar); + + FragmentActivity activity = requireMyActivity(); + activity.getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) { + public void handleOnBackPressed() { + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + mapActivity.launchPrevActivityIntent(); + } + dismiss(); + } + }); } public GPXFile getGpx() { return displayHelper.getGpx(); } + public void setSelectedGpxFile(SelectedGpxFile selectedGpxFile) { + this.selectedGpxFile = selectedGpxFile; + } + @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); @@ -998,7 +1010,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card @Override public void gpxSavingFinished(Exception errorMessage) { if (selectedGpxFile != null) { - List groups = displayHelper.getDisplayGroups(new GpxDisplayItemType[]{GpxDisplayItemType.TRACK_SEGMENT}); + List groups = displayHelper.getDisplayGroups(new GpxDisplayItemType[] {GpxDisplayItemType.TRACK_SEGMENT}); selectedGpxFile.setDisplayGroups(groups, app); selectedGpxFile.processPoints(app); } @@ -1031,16 +1043,60 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card } } - public static boolean showInstance(@NonNull MapActivity mapActivity, String path, boolean showCurrentTrack) { + public static void openTrack(@NonNull Context context, @Nullable File file, Bundle prevIntentParams) { + Bundle bundle = new Bundle(); + bundle.putBoolean(OPEN_TRACK_MENU, true); + if (file == null) { + bundle.putBoolean(TrackActivity.CURRENT_RECORDING, true); + } else { + bundle.putString(TrackActivity.TRACK_FILE_NAME, file.getAbsolutePath()); + } + MapActivity.launchMapActivityMoveToTop(context, prevIntentParams, null, bundle); + } + + public static void showInstance(@NonNull final MapActivity mapActivity, @Nullable String path, boolean showCurrentTrack) { + OsmandApplication app = mapActivity.getMyApplication(); + SelectedGpxFile selectedGpxFile; + if (showCurrentTrack) { + selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack(); + } else { + selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(path); + } + if (selectedGpxFile != null) { + showInstance(mapActivity, selectedGpxFile); + } else if (!Algorithms.isEmpty(path)) { + String title = app.getString(R.string.loading_smth, ""); + final ProgressDialog progress = ProgressDialog.show(mapActivity, title, app.getString(R.string.loading_data)); + final WeakReference mapActivityRef = new WeakReference<>(mapActivity); + + GpxFileLoaderTask gpxFileLoaderTask = new GpxFileLoaderTask(new File(path), new CallbackWithObject() { + @Override + public boolean processResult(GPXFile result) { + MapActivity mapActivity = mapActivityRef.get(); + if (mapActivity != null) { + OsmandApplication app = mapActivity.getMyApplication(); + SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().selectGpxFile(result, true, false); + showInstance(mapActivity, selectedGpxFile); + } + if (progress != null && AndroidUtils.isActivityNotDestroyed(mapActivity)) { + progress.dismiss(); + } + return true; + } + }); + gpxFileLoaderTask.execute(); + } + } + + public static boolean showInstance(@NonNull MapActivity mapActivity, SelectedGpxFile selectedGpxFile) { try { Bundle args = new Bundle(); - args.putString(TRACK_FILE_NAME, path); - args.putBoolean(CURRENT_RECORDING, showCurrentTrack); args.putInt(ContextMenuFragment.MENU_STATE_KEY, MenuState.HEADER_ONLY); TrackMenuFragment fragment = new TrackMenuFragment(); fragment.setArguments(args); fragment.setRetainInstance(true); + fragment.setSelectedGpxFile(selectedGpxFile); mapActivity.getSupportFragmentManager() .beginTransaction() diff --git a/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java b/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java index c1f20a4ea0..f525c60fbd 100644 --- a/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java +++ b/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java @@ -22,8 +22,6 @@ import net.osmand.plus.views.layers.ContextMenuLayer; import java.io.File; -import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; - public class AddGpxPointBottomSheetHelper implements OnDismissListener { private final View view; private final TextView title; @@ -151,7 +149,7 @@ public class AddGpxPointBottomSheetHelper implements OnDismissListener { if (fragment != null) { fragment.show(); } else { - openTrack(mapActivity, new File(newGpxPoint.getGpx().path)); + TrackMenuFragment.openTrack(mapActivity, new File(newGpxPoint.getGpx().path), null); } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index 5354d90ec9..2f9cfa3587 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -51,7 +51,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; -import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; +import static net.osmand.plus.track.TrackMenuFragment.openTrack; import static net.osmand.plus.wikipedia.WikiArticleShowImages.OFF; @@ -151,7 +151,7 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme } TravelHelper travelHelper = getMyApplication().getTravelHelper(); File file = travelHelper.createGpxFile(article); - openTrack(activity, new File(file.getAbsolutePath())); + openTrack(activity, new File(file.getAbsolutePath()), null); } }); From f64097c28833a59455166b242b03dabadc2977e4 Mon Sep 17 00:00:00 2001 From: Eduardo Addad de Oliveira Date: Tue, 26 Jan 2021 13:58:59 +0000 Subject: [PATCH 036/125] Translated using Weblate (Portuguese (Brazil)) Currently translated at 99.9% (3649 of 3651 strings) --- OsmAnd/res/values-pt-rBR/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/res/values-pt-rBR/strings.xml b/OsmAnd/res/values-pt-rBR/strings.xml index 2d9bc87624..afe7bc99a0 100644 --- a/OsmAnd/res/values-pt-rBR/strings.xml +++ b/OsmAnd/res/values-pt-rBR/strings.xml @@ -3995,4 +3995,8 @@ MTB Erro de servidor: %1$s O nome já existe + Editar descrição + Apagar ponto fixo + Copiar para marcadores de mapa + Copiar para favoritos \ No newline at end of file From 05b892244b220eb91f34c857e83b8ce713d777e7 Mon Sep 17 00:00:00 2001 From: Eduardo Addad de Oliveira Date: Tue, 26 Jan 2021 14:00:43 +0000 Subject: [PATCH 037/125] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (3651 of 3651 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 afe7bc99a0..44ac4e79b6 100644 --- a/OsmAnd/res/values-pt-rBR/strings.xml +++ b/OsmAnd/res/values-pt-rBR/strings.xml @@ -3999,4 +3999,6 @@ Apagar ponto fixo Copiar para marcadores de mapa Copiar para favoritos + Excluir este mecanismo de roteamento online\? + Ler na íntegra \ No newline at end of file From 8378a91f05906f3918653a3c5c0edf0c94a930ea Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 26 Jan 2021 16:37:50 +0200 Subject: [PATCH 038/125] Fix back to travel from gpx menu --- .../wikivoyage/article/WikivoyageArticleDialogFragment.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index 2f9cfa3587..e3964b4c1a 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -44,6 +44,7 @@ import net.osmand.plus.wikivoyage.data.TravelArticle; import net.osmand.plus.wikivoyage.data.TravelArticle.TravelArticleIdentifier; import net.osmand.plus.wikivoyage.data.TravelHelper; import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; +import net.osmand.plus.wikivoyage.explore.WikivoyageExploreActivity; import net.osmand.util.Algorithms; import java.io.File; @@ -149,6 +150,10 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme if (article == null || activity == null || fm == null) { return; } + if (activity instanceof WikivoyageExploreActivity) { + WikivoyageExploreActivity exploreActivity = (WikivoyageExploreActivity) activity; + exploreActivity.setArticle(article); + } TravelHelper travelHelper = getMyApplication().getTravelHelper(); File file = travelHelper.createGpxFile(article); openTrack(activity, new File(file.getAbsolutePath()), null); From a9018f49fdb97c2ff2252c25275202acbfb644e2 Mon Sep 17 00:00:00 2001 From: Skalii Date: Tue, 26 Jan 2021 16:53:54 +0200 Subject: [PATCH 039/125] fix background crops in 360dp width device --- OsmAnd/res/layout/gpx_overview_fragment.xml | 57 +++++++++++---------- OsmAnd/res/layout/item_gpx_action.xml | 10 ++-- 2 files changed, 37 insertions(+), 30 deletions(-) diff --git a/OsmAnd/res/layout/gpx_overview_fragment.xml b/OsmAnd/res/layout/gpx_overview_fragment.xml index 3c5fe507c7..426633eb83 100644 --- a/OsmAnd/res/layout/gpx_overview_fragment.xml +++ b/OsmAnd/res/layout/gpx_overview_fragment.xml @@ -48,55 +48,60 @@ - - - - - - - diff --git a/OsmAnd/res/layout/item_gpx_action.xml b/OsmAnd/res/layout/item_gpx_action.xml index dce94e951b..8b68dd681b 100644 --- a/OsmAnd/res/layout/item_gpx_action.xml +++ b/OsmAnd/res/layout/item_gpx_action.xml @@ -1,13 +1,15 @@ + android:minHeight="@dimen/context_menu_controller_height" + android:minWidth="@dimen/context_menu_top_right_button_min_width" + android:layout_width="@dimen/fab_recycler_view_padding_bottom" + android:layout_height="@dimen/setting_list_item_small_height"> From b249fdbab6a22401b1b00996f8eddf296fb7d07e Mon Sep 17 00:00:00 2001 From: cepprice Date: Tue, 26 Jan 2021 20:09:25 +0500 Subject: [PATCH 040/125] Update UI of Description in Overview Tab in GPX context menu --- .../layout/dialog_edit_gpx_description.xml | 63 +++++--- .../layout/dialog_read_gpx_description.xml | 42 +++-- .../layout/gpx_description_preview_card.xml | 147 ++++++++++++------ .../osmand/plus/track/DescriptionCard.java | 42 ++++- .../GpxEditDescriptionDialogFragment.java | 61 ++++++-- .../GpxReadDescriptionDialogFragment.java | 25 +-- 6 files changed, 262 insertions(+), 118 deletions(-) diff --git a/OsmAnd/res/layout/dialog_edit_gpx_description.xml b/OsmAnd/res/layout/dialog_edit_gpx_description.xml index 52b5f97bdc..1d2428f82b 100644 --- a/OsmAnd/res/layout/dialog_edit_gpx_description.xml +++ b/OsmAnd/res/layout/dialog_edit_gpx_description.xml @@ -42,25 +42,31 @@ android:textSize="@dimen/dialog_header_text_size" osmand:typeface="@string/font_roboto_medium" /> - + android:background="@drawable/btn_border_active"> + + + @@ -69,17 +75,26 @@ android:layout_height="1dp" android:background="?attr/divider_color" /> - + android:layout_height="match_parent"> + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/dialog_read_gpx_description.xml b/OsmAnd/res/layout/dialog_read_gpx_description.xml index f4cf390af5..d065868ab1 100644 --- a/OsmAnd/res/layout/dialog_read_gpx_description.xml +++ b/OsmAnd/res/layout/dialog_read_gpx_description.xml @@ -56,32 +56,40 @@ android:id="@+id/divider" android:layout_width="match_parent" android:layout_height="1dp" - android:background="?attr/divider_color" + android:background="?attr/ctx_menu_info_divider" android:visibility="gone" tools:visibility="visible"/> - + android:background="@drawable/rounded_background_3dp"> + + + + - + android:orientation="vertical"> + + + + + + + + + + + + + + + + + + + + + android:layout_marginStart="@dimen/card_padding" + android:layout_marginLeft="@dimen/card_padding" + android:layout_marginTop="@dimen/content_padding" + android:background="@drawable/rounded_background_3dp" + android:visibility="gone" + tools:visibility="visible"> - - @@ -110,6 +160,7 @@ = 19) { + webView.setLayerType(View.LAYER_TYPE_HARDWARE, null); + } + else { + webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); + } webView.setScrollbarFadingEnabled(true); webView.setVerticalScrollBarEnabled(false); webView.setBackgroundColor(Color.TRANSPARENT); - webView.setLayerType(WebView.LAYER_TYPE_HARDWARE, null); webView.getSettings().setTextZoom((int) (getResources().getConfiguration().fontScale * 100f)); webView.getSettings().setDomStorageEnabled(true); webView.getSettings().setLoadWithOverviewMode(true); From 6bbe104de7ae9f2fa3cd3275ffd6a17c8e559496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuz=20Ersen?= Date: Tue, 26 Jan 2021 15:15:40 +0000 Subject: [PATCH 041/125] Translated using Weblate (Turkish) Currently translated at 99.9% (3648 of 3651 strings) --- OsmAnd/res/values-tr/strings.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/values-tr/strings.xml b/OsmAnd/res/values-tr/strings.xml index 9b7d3c4972..e7322ba264 100644 --- a/OsmAnd/res/values-tr/strings.xml +++ b/OsmAnd/res/values-tr/strings.xml @@ -4001,4 +4001,7 @@ Yarış bisikleti Sunucu hatası: %1$s Ad zaten var + Ara noktaları sil + Harita işaretleyicilerine kopyala + Sık kullanılanlara kopyala \ No newline at end of file From 0d67fb55ba9215d2f9b10917d95d06bf55a3bbd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuz=20Ersen?= Date: Tue, 26 Jan 2021 15:16:22 +0000 Subject: [PATCH 042/125] Translated using Weblate (Turkish) Currently translated at 100.0% (3651 of 3651 strings) --- OsmAnd/res/values-tr/strings.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/values-tr/strings.xml b/OsmAnd/res/values-tr/strings.xml index e7322ba264..02664a0a1e 100644 --- a/OsmAnd/res/values-tr/strings.xml +++ b/OsmAnd/res/values-tr/strings.xml @@ -4004,4 +4004,7 @@ Ara noktaları sil Harita işaretleyicilerine kopyala Sık kullanılanlara kopyala + Bu çevrim içi yönlendirme motoru silinsin mi\? + Tamamını oku + Açıklamayı düzenle \ No newline at end of file From c7f5edca551a6487b35b88d005eaed96ec63f7f9 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 26 Jan 2021 17:59:47 +0200 Subject: [PATCH 043/125] Fix first map position adjusting --- .../osmand/plus/base/ContextMenuFragment.java | 7 ++++--- .../plus/base/ContextMenuScrollFragment.java | 2 +- .../ChooseRouteFragment.java | 2 +- .../osmand/plus/track/TrackMenuFragment.java | 19 +++++++------------ 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java index 4f6097897f..4cc90afd96 100644 --- a/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java @@ -103,7 +103,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment public interface ContextMenuFragmentListener { void onContextMenuYPosChanged(@NonNull ContextMenuFragment fragment, int y, boolean needMapAdjust, boolean animated); - void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState); + void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState, int previousMenuState); void onContextMenuDismiss(@NonNull ContextMenuFragment fragment); } @@ -815,7 +815,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment ContextMenuFragmentListener listener = this.listener; if (listener != null) { - listener.onContextMenuStateChanged(this, newMenuState); + listener.onContextMenuStateChanged(this, newMenuState, currentMenuState); } } @@ -971,7 +971,8 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment ContextMenuFragmentListener listener = ContextMenuFragment.this.listener; if (listener != null) { - listener.onContextMenuStateChanged(ContextMenuFragment.this, getCurrentMenuState()); + int menuState = getCurrentMenuState(); + listener.onContextMenuStateChanged(ContextMenuFragment.this, menuState, menuState); } } } diff --git a/OsmAnd/src/net/osmand/plus/base/ContextMenuScrollFragment.java b/OsmAnd/src/net/osmand/plus/base/ContextMenuScrollFragment.java index 51f4278948..5ba853e147 100644 --- a/OsmAnd/src/net/osmand/plus/base/ContextMenuScrollFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/ContextMenuScrollFragment.java @@ -82,7 +82,7 @@ public abstract class ContextMenuScrollFragment extends ContextMenuFragment impl } @Override - public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState) { + public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState, int previousMenuState) { updateMapControlsVisibility(menuState); } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java index 5c283c670d..99d6a5c0cd 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java @@ -815,7 +815,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe } @Override - public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState) { + public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState, int previousMenuState) { LockableViewPager viewPager = this.viewPager; RouteDetailsFragment current = getCurrentFragment(); if (viewPager != null && fragment == current) { diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index 8bcfb411ef..0e21879f85 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -152,6 +152,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card private int menuTitleHeight; private int toolbarHeightPx; + private boolean mapPositionAdjusted; public enum TrackMenuType { OVERVIEW(R.id.action_overview, R.string.shared_string_overview), @@ -455,9 +456,11 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card } @Override - public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - adjustMapPosition(getHeight()); + public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int currentMenuState, int previousMenuState) { + super.onContextMenuStateChanged(fragment, currentMenuState, previousMenuState); + if (currentMenuState != MenuState.FULL_SCREEN && (currentMenuState != previousMenuState || !mapPositionAdjusted)) { + adjustMapPosition(getViewY()); + } } @Override @@ -760,15 +763,6 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card } } - @Override - protected int applyPosY(int currentY, boolean needCloseMenu, boolean needMapAdjust, int previousMenuState, int newMenuState, int dZoom, boolean animated) { - int y = super.applyPosY(currentY, needCloseMenu, needMapAdjust, previousMenuState, newMenuState, dZoom, animated); - if (needMapAdjust) { - adjustMapPosition(y); - } - return y; - } - public void updateToolbar(int y, boolean animated) { final MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { @@ -821,6 +815,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card if (r.left != 0 && r.right != 0) { mapActivity.getMapView().fitRectToMap(r.left, r.right, r.top, r.bottom, tileBoxWidthPx, tileBoxHeightPx, 0); } + mapPositionAdjusted = true; } } From 93093ea42838fc2bac09b0ff04d791d5e7840b00 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Tue, 26 Jan 2021 19:02:55 +0300 Subject: [PATCH 044/125] Added progress bar while reading travel article gpx --- .../fragment_wikivoyage_article_dialog.xml | 8 + .../TrackActivityFragmentAdapter.java | 2 +- .../WikivoyageArticleDialogFragment.java | 42 ++++- .../WikivoyageArticleNavigationFragment.java | 6 +- .../plus/wikivoyage/data/TravelArticle.java | 1 + .../plus/wikivoyage/data/TravelDbHelper.java | 18 +- .../plus/wikivoyage/data/TravelHelper.java | 21 ++- .../data/TravelLocalDataHelper.java | 2 +- .../plus/wikivoyage/data/TravelObfHelper.java | 162 +++++++++++------- .../menu/WikivoyageWptPtMenuController.java | 6 +- 10 files changed, 181 insertions(+), 87 deletions(-) diff --git a/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml b/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml index 76fe893831..1643d43234 100644 --- a/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml +++ b/OsmAnd/res/layout/fragment_wikivoyage_article_dialog.xml @@ -145,6 +145,14 @@ tools:drawableStart="@drawable/ic_action_markers_dark" android:paddingEnd="@dimen/bottom_sheet_content_padding_small" /> + + 0) { - trackButton.setVisibility(View.VISIBLE); - trackButton.setText(getString(R.string.shared_string_gpx_points) + " (" + gpxFile.getPointsSize() + ")"); - } else { - trackButton.setVisibility(View.GONE); - } TravelLocalDataHelper ldh = getMyApplication().getTravelHelper().getBookmarksHelper(); ldh.addToHistory(article); @@ -327,6 +336,21 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme contentWebView.loadDataWithBaseURL(getBaseUrl(), createHtmlContent(), "text/html", "UTF-8", null); } + private void updateTrackButton(boolean processing, @Nullable GPXFile gpxFile) { + if (processing) { + trackButton.setVisibility(View.GONE); + gpxProgress.setVisibility(View.VISIBLE); + } else { + if (gpxFile != null && gpxFile.getPointsSize() > 0) { + trackButton.setVisibility(View.VISIBLE); + trackButton.setText(getString(R.string.shared_string_gpx_points) + " (" + gpxFile.getPointsSize() + ")"); + } else { + trackButton.setVisibility(View.GONE); + } + gpxProgress.setVisibility(View.GONE); + } + } + @NonNull @Override protected String createHtmlContent() { diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleNavigationFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleNavigationFragment.java index 1018874d26..98500afa01 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleNavigationFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleNavigationFragment.java @@ -20,6 +20,7 @@ import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; +import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; import net.osmand.plus.base.MenuBottomSheetDialogFragment; @@ -75,14 +76,15 @@ public class WikivoyageArticleNavigationFragment extends MenuBottomSheetDialogFr return; } - article = getMyApplication().getTravelHelper().getArticleById(articleId, selectedLang); + OsmandApplication app = requiredMyApplication(); + article = app.getTravelHelper().getArticleById(articleId, selectedLang, false, null); if (article == null) { return; } parentsList = new ArrayList<>(Arrays.asList(article.getAggregatedPartOf().split(","))); Map> navigationMap - = getMyApplication().getTravelHelper().getNavigationMap(article); + = app.getTravelHelper().getNavigationMap(article); items.add(new TitleItem(getString(R.string.shared_string_navigation))); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelArticle.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelArticle.java index cf38b7265f..952b85be4d 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelArticle.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelArticle.java @@ -44,6 +44,7 @@ public class TravelArticle { String aggregatedPartOf; long lastModified; + boolean gpxFileReading; boolean gpxFileRead; @NonNull diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java index 38380015c3..b53605a0bb 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java @@ -549,7 +549,7 @@ public class TravelDbHelper implements TravelHelper { @Override @Nullable - public TravelArticle getArticleById(@NonNull TravelArticleIdentifier articleId, @NonNull String lang) { + public TravelArticle getArticleById(@NonNull TravelArticleIdentifier articleId, @NonNull String lang, boolean readGpx, @Nullable GpxReadCallback callback) { TravelArticle res = null; SQLiteConnection conn = openConnection(); String routeId = articleId.routeId; @@ -566,24 +566,27 @@ public class TravelDbHelper implements TravelHelper { if (res == null) { res = localDataHelper.getSavedArticle(articleId.file, articleId.routeId, lang); } + if (res != null && callback != null) { + callback.onGpxFileRead(res.gpxFile); + } return res; } @Nullable @Override - public TravelArticle getArticleByTitle(@NonNull final String title, @NonNull final String lang) { - return getArticleByTitle(title, new QuadRect(), lang); + public TravelArticle getArticleByTitle(@NonNull final String title, @NonNull final String lang, boolean readGpx, @Nullable GpxReadCallback callback) { + return getArticleByTitle(title, new QuadRect(), lang, readGpx, callback); } @Nullable @Override - public TravelArticle getArticleByTitle(@NonNull final String title, @NonNull LatLon latLon, @NonNull final String lang) { - return getArticleByTitle(title, new QuadRect(), lang); + public TravelArticle getArticleByTitle(@NonNull final String title, @NonNull LatLon latLon, @NonNull final String lang, boolean readGpx, @Nullable GpxReadCallback callback) { + return getArticleByTitle(title, new QuadRect(), lang, readGpx, callback); } @Nullable @Override - public TravelArticle getArticleByTitle(@NonNull final String title, @NonNull QuadRect rect, @NonNull final String lang) { + public TravelArticle getArticleByTitle(@NonNull final String title, @NonNull QuadRect rect, @NonNull final String lang, boolean readGpx, @Nullable GpxReadCallback callback) { TravelArticle res = null; SQLiteConnection conn = openConnection(); if (conn != null) { @@ -596,6 +599,9 @@ public class TravelDbHelper implements TravelHelper { cursor.close(); } } + if (res != null && callback != null) { + callback.onGpxFileRead(res.gpxFile); + } return res; } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java index 87b5bc1e95..967138b0bd 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelHelper.java @@ -3,6 +3,8 @@ package net.osmand.plus.wikivoyage.data; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import net.osmand.GPXUtilities; +import net.osmand.GPXUtilities.GPXFile; import net.osmand.data.LatLon; import net.osmand.data.QuadRect; import net.osmand.plus.wikivoyage.data.TravelArticle.TravelArticleIdentifier; @@ -14,6 +16,11 @@ import java.util.Map; public interface TravelHelper { + interface GpxReadCallback { + void onGpxFileReading(); + void onGpxFileRead(@Nullable GPXFile gpxFile); + } + TravelLocalDataHelper getBookmarksHelper(); void initializeDataOnAppStartup(); @@ -29,19 +36,19 @@ public interface TravelHelper { List getPopularArticles(); @NonNull - Map> getNavigationMap(@NonNull final TravelArticle article); + Map> getNavigationMap(@NonNull TravelArticle article); @Nullable - TravelArticle getArticleById(@NonNull TravelArticleIdentifier articleId, @NonNull String lang); + TravelArticle getArticleById(@NonNull TravelArticleIdentifier articleId, @NonNull String lang, boolean readGpx, @Nullable GpxReadCallback callback); @Nullable - public TravelArticle getArticleByTitle(@NonNull final String title, @NonNull final String lang); + TravelArticle getArticleByTitle(@NonNull String title, @NonNull String lang, boolean readGpx, @Nullable GpxReadCallback callback); @Nullable - public TravelArticle getArticleByTitle(@NonNull final String title, @NonNull LatLon latLon, @NonNull final String lang); + TravelArticle getArticleByTitle(@NonNull String title, @NonNull LatLon latLon, @NonNull String lang, boolean readGpx, @Nullable GpxReadCallback callback); @Nullable - TravelArticle getArticleByTitle(@NonNull String title, @NonNull QuadRect rect, @NonNull String lang); + TravelArticle getArticleByTitle(@NonNull String title, @NonNull QuadRect rect, @NonNull String lang, boolean readGpx, @Nullable GpxReadCallback callback); @Nullable TravelArticleIdentifier getArticleId(@NonNull String title, @NonNull String lang); @@ -50,10 +57,10 @@ public interface TravelHelper { ArrayList getArticleLangs(@NonNull TravelArticleIdentifier articleId); @NonNull - String getGPXName(@NonNull final TravelArticle article); + String getGPXName(@NonNull TravelArticle article); @NonNull - File createGpxFile(@NonNull final TravelArticle article); + File createGpxFile(@NonNull TravelArticle article); // TODO: this method should be deleted once TravelDBHelper is deleted @Nullable diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java index 2c59c16ed2..02ee5a32c8 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java @@ -420,7 +420,7 @@ public class TravelLocalDataHelper { if (cursor.moveToFirst()) { do { TravelArticle dbArticle = readSavedArticle(cursor); - TravelArticle article = context.getTravelHelper().getArticleById(dbArticle.generateIdentifier(), dbArticle.lang); + TravelArticle article = context.getTravelHelper().getArticleById(dbArticle.generateIdentifier(), dbArticle.lang, false, null); if (article != null && article.getLastModified() > dbArticle.getLastModified()) { updateSavedArticle(dbArticle, article); res.add(article); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index 9a2c80940c..9ea963db81 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -1,5 +1,6 @@ package net.osmand.plus.wikivoyage.data; +import android.os.AsyncTask; import android.text.TextUtils; import androidx.annotation.NonNull; @@ -97,9 +98,19 @@ public class TravelObfHelper implements TravelHelper { location, POPULAR_ARTICLES_SEARCH_RADIUS, -1, getSearchFilter(false), null); List amenities = reader.searchPoi(req); if (amenities.size() > 0) { + Collections.sort(amenities, new Comparator() { + @Override + public int compare(Amenity a1, Amenity a2) { + int d1 = (int) (MapUtils.getDistance(a1.getLocation().getLatitude(), a1.getLocation().getLongitude(), + location.getLatitude(), location.getLongitude())); + int d2 = (int) (MapUtils.getDistance(a2.getLocation().getLatitude(), a2.getLocation().getLongitude(), + location.getLatitude(), location.getLongitude())); + return d1 < d2 ? -1 : (d1 == d2 ? 0 : 1); + } + }); for (Amenity amenity : amenities) { if (!Algorithms.isEmpty(amenity.getName(lang))) { - TravelArticle article = cacheTravelArticles(reader.getFile(), amenity, lang, false); + TravelArticle article = cacheTravelArticles(reader.getFile(), amenity, lang, false, null); if (article != null) { popularArticles.add(article); if (popularArticles.size() >= MAX_POPULAR_ARTICLES_COUNT) { @@ -108,16 +119,6 @@ public class TravelObfHelper implements TravelHelper { } } } - Collections.sort(popularArticles, new Comparator() { - @Override - public int compare(TravelArticle article1, TravelArticle article2) { - int d1 = (int) (MapUtils.getDistance(article1.getLat(), article1.getLon(), - location.getLatitude(), location.getLongitude())); - int d2 = (int) (MapUtils.getDistance(article2.getLat(), article2.getLon(), - location.getLatitude(), location.getLongitude())); - return d1 < d2 ? -1 : (d1 == d2 ? 0 : 1); - } - }); } } catch (Exception e) { LOG.error(e.getMessage(), e); @@ -128,13 +129,13 @@ public class TravelObfHelper implements TravelHelper { } @Nullable - private TravelArticle cacheTravelArticles(File file, Amenity amenity, String lang, boolean readPoints) { + private TravelArticle cacheTravelArticles(File file, Amenity amenity, String lang, boolean readPoints, @Nullable GpxReadCallback callback) { TravelArticle article = null; - Map articles = readArticles(file, amenity, false); + Map articles = readArticles(file, amenity); if (!Algorithms.isEmpty(articles)) { TravelArticleIdentifier newArticleId = articles.values().iterator().next().generateIdentifier(); cachedArticles.put(newArticleId, articles); - article = getCachedArticle(newArticleId, lang, readPoints); + article = getCachedArticle(newArticleId, lang, readPoints, callback); } return article; } @@ -155,17 +156,17 @@ public class TravelObfHelper implements TravelHelper { } @NonNull - private Map readArticles(@NonNull File file, @NonNull Amenity amenity, boolean readPoints) { + private Map readArticles(@NonNull File file, @NonNull Amenity amenity) { Map articles = new HashMap<>(); Set langs = getLanguages(amenity); for (String lang : langs) { - articles.put(lang, readArticle(file, amenity, lang, readPoints)); + articles.put(lang, readArticle(file, amenity, lang)); } return articles; } @NonNull - private TravelArticle readArticle(@NonNull File file, @NonNull Amenity amenity, @NonNull String lang, boolean readPoints) { + private TravelArticle readArticle(@NonNull File file, @NonNull Amenity amenity, @NonNull String lang) { TravelArticle res = new TravelArticle(); res.file = file; String title = amenity.getName(lang); @@ -182,29 +183,11 @@ public class TravelObfHelper implements TravelHelper { res.lang = lang; res.contentsJson = Algorithms.emptyIfNull(amenity.getTagContent(Amenity.CONTENT_JSON, lang)); res.aggregatedPartOf = Algorithms.emptyIfNull(amenity.getTagContent(Amenity.IS_AGGR_PART, lang)); - if (readPoints) { - res.gpxFile = buildGpxFile(res); - res.gpxFileRead = true; - } return res; } - private GPXFile buildGpxFile(@NonNull TravelArticle article) { - GPXFile gpxFile = null; - List pointList = getPointList(article); - if (!Algorithms.isEmpty(pointList)) { - gpxFile = new GPXFile(article.getTitle(), article.getLang(), article.getContent()); - gpxFile.metadata.link = TravelArticle.getImageUrl(article.getImageTitle(), false); - for (Amenity amenity : pointList) { - WptPt wptPt = createWptPt(amenity, article.getLang()); - gpxFile.addPoint(wptPt); - } - } - return gpxFile; - } - @NonNull - private List getPointList(@NonNull final TravelArticle article) { + private synchronized List getPointList(@NonNull final TravelArticle article) { final List pointList = new ArrayList<>(); final String lang = article.getLang(); for (BinaryMapIndexReader reader : getReaders()) { @@ -312,7 +295,7 @@ public class TravelObfHelper implements TravelHelper { for (Amenity amenity : entry.getValue()) { Set nameLangs = getLanguages(amenity); if (nameLangs.contains(appLang)) { - TravelArticle article = readArticle(file, amenity, appLang, false); + TravelArticle article = readArticle(file, amenity, appLang); ArrayList langs = new ArrayList<>(nameLangs); Collections.sort(langs, new Comparator() { @Override @@ -481,20 +464,28 @@ public class TravelObfHelper implements TravelHelper { LOG.error(e.getMessage()); } if (!Algorithms.isEmpty(amenities)) { - article = readArticle(reader.getFile(), amenities.get(0), lang, false); + article = readArticle(reader.getFile(), amenities.get(0), lang); } } return article; } @Override - public TravelArticle getArticleById(@NonNull TravelArticleIdentifier articleId, @NonNull String lang) { - TravelArticle article = getCachedArticle(articleId, lang, true); - return article == null ? localDataHelper.getSavedArticle(articleId.file, articleId.routeId, lang) : article; + public TravelArticle getArticleById(@NonNull TravelArticleIdentifier articleId, @NonNull String lang, + boolean readGpx, @Nullable GpxReadCallback callback) { + TravelArticle article = getCachedArticle(articleId, lang, readGpx, callback); + if (article == null) { + article = localDataHelper.getSavedArticle(articleId.file, articleId.routeId, lang); + if (article != null && callback != null && readGpx) { + callback.onGpxFileRead(article.gpxFile); + } + } + return article; } @Nullable - private TravelArticle getCachedArticle(@NonNull TravelArticleIdentifier articleId, @NonNull String lang, boolean forceReadPoints) { + private TravelArticle getCachedArticle(@NonNull TravelArticleIdentifier articleId, @NonNull String lang, + boolean forceReadPoints, @Nullable GpxReadCallback callback) { TravelArticle article = null; Map articles = cachedArticles.get(articleId); if (articles != null) { @@ -511,16 +502,24 @@ public class TravelObfHelper implements TravelHelper { } } if (article == null && articles == null) { - article = findArticleById(articleId, lang); + article = findArticleById(articleId, lang, callback); } - if (article != null && !article.gpxFileRead && forceReadPoints && !Algorithms.isEmpty(lang)) { - article.gpxFile = buildGpxFile(article); - article.gpxFileRead = true; + if (article != null && forceReadPoints && !Algorithms.isEmpty(lang)) { + readGpxFile(article, callback); } return article; } - private TravelArticle findArticleById(@NonNull final TravelArticleIdentifier articleId, final String lang) { + private void readGpxFile(@NonNull TravelArticle article, @Nullable GpxReadCallback callback) { + if (!article.gpxFileRead) { + new GpxFileReader(article, callback).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + } else if (callback != null) { + callback.onGpxFileRead(article.gpxFile); + } + } + + private TravelArticle findArticleById(@NonNull final TravelArticleIdentifier articleId, + final String lang, @Nullable GpxReadCallback callback) { TravelArticle article = null; final boolean isDbArticle = articleId.file != null && articleId.file.getName().endsWith(IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT); final List amenities = new ArrayList<>(); @@ -563,7 +562,7 @@ public class TravelObfHelper implements TravelHelper { LOG.error(e.getMessage()); } if (!Algorithms.isEmpty(amenities)) { - article = cacheTravelArticles(reader.getFile(), amenities.get(0), lang, true); + article = cacheTravelArticles(reader.getFile(), amenities.get(0), lang, true, callback); } } return article; @@ -571,20 +570,23 @@ public class TravelObfHelper implements TravelHelper { @Nullable @Override - public TravelArticle getArticleByTitle(@NonNull final String title, @NonNull final String lang) { - return getArticleByTitle(title, new QuadRect(), lang); + public TravelArticle getArticleByTitle(@NonNull final String title, @NonNull final String lang, + boolean readGpx, @Nullable GpxReadCallback callback) { + return getArticleByTitle(title, new QuadRect(), lang, readGpx, callback); } @Nullable @Override - public TravelArticle getArticleByTitle(@NonNull final String title, @NonNull LatLon latLon, @NonNull final String lang) { - QuadRect rect = latLon != null ? MapUtils.calculateLatLonBbox(latLon.getLatitude(), latLon.getLongitude(), ARTICLE_SEARCH_RADIUS) : new QuadRect(); - return getArticleByTitle(title, rect, lang); + public TravelArticle getArticleByTitle(@NonNull final String title, @NonNull LatLon latLon, + @NonNull final String lang, boolean readGpx, @Nullable GpxReadCallback callback) { + QuadRect rect = MapUtils.calculateLatLonBbox(latLon.getLatitude(), latLon.getLongitude(), ARTICLE_SEARCH_RADIUS); + return getArticleByTitle(title, rect, lang, readGpx, callback); } @Nullable @Override - public TravelArticle getArticleByTitle(@NonNull final String title, @NonNull QuadRect rect, @NonNull final String lang) { + public TravelArticle getArticleByTitle(@NonNull final String title, @NonNull QuadRect rect, + @NonNull final String lang, boolean readGpx, @Nullable GpxReadCallback callback) { TravelArticle article = null; final List amenities = new ArrayList<>(); int x = 0; @@ -627,7 +629,7 @@ public class TravelObfHelper implements TravelHelper { LOG.error(e.getMessage()); } if (!Algorithms.isEmpty(amenities)) { - article = cacheTravelArticles(reader.getFile(), amenities.get(0), lang, true); + article = cacheTravelArticles(reader.getFile(), amenities.get(0), lang, readGpx, callback); } } return article; @@ -654,7 +656,7 @@ public class TravelObfHelper implements TravelHelper { } } if (a == null) { - TravelArticle article = getArticleByTitle(title, lang); + TravelArticle article = getArticleByTitle(title, lang, false, null); if (article != null) { a = article; } @@ -666,7 +668,7 @@ public class TravelObfHelper implements TravelHelper { @Override public ArrayList getArticleLangs(@NonNull TravelArticleIdentifier articleId) { ArrayList res = new ArrayList<>(); - TravelArticle article = getArticleById(articleId, ""); + TravelArticle article = getArticleById(articleId, "", false, null); if (article != null) { Map articles = cachedArticles.get(article.generateIdentifier()); if (articles != null) { @@ -683,14 +685,14 @@ public class TravelObfHelper implements TravelHelper { @NonNull @Override - public String getGPXName(@NonNull final TravelArticle article) { + public String getGPXName(@NonNull TravelArticle article) { return article.getTitle().replace('/', '_').replace('\'', '_') .replace('\"', '_') + IndexConstants.GPX_FILE_EXT; } @NonNull @Override - public File createGpxFile(@NonNull final TravelArticle article) { + public File createGpxFile(@NonNull TravelArticle article) { final GPXFile gpx = article.getGpxFile(); File file = app.getAppPath(IndexConstants.GPX_TRAVEL_DIR + getGPXName(article)); writeGpxFile(file, gpx); @@ -706,4 +708,46 @@ public class TravelObfHelper implements TravelHelper { public String getWikivoyageFileName() { return WORLD_WIKIVOYAGE_FILE_NAME; } + + private class GpxFileReader extends AsyncTask { + + private final TravelArticle article; + private final GpxReadCallback callback; + + public GpxFileReader(@NonNull TravelArticle article, @Nullable GpxReadCallback callback) { + this.article = article; + this.callback = callback; + } + + @Override + protected void onPreExecute() { + if (callback != null) { + callback.onGpxFileReading(); + } + } + + @Override + protected GPXFile doInBackground(Void... voids) { + GPXFile gpxFile = null; + List pointList = getPointList(article); + if (!Algorithms.isEmpty(pointList)) { + gpxFile = new GPXFile(article.getTitle(), article.getLang(), article.getContent()); + gpxFile.metadata.link = TravelArticle.getImageUrl(article.getImageTitle(), false); + for (Amenity amenity : pointList) { + WptPt wptPt = createWptPt(amenity, article.getLang()); + gpxFile.addPoint(wptPt); + } + } + return gpxFile; + } + + @Override + protected void onPostExecute(GPXFile gpxFile) { + article.gpxFileRead = true; + article.gpxFile = gpxFile; + if (callback != null) { + callback.onGpxFileRead(gpxFile); + } + } + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/menu/WikivoyageWptPtMenuController.java b/OsmAnd/src/net/osmand/plus/wikivoyage/menu/WikivoyageWptPtMenuController.java index 6f3ee2fd43..84507da899 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/menu/WikivoyageWptPtMenuController.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/menu/WikivoyageWptPtMenuController.java @@ -10,6 +10,7 @@ import net.osmand.GPXUtilities.WptPt; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; +import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.controllers.WptPtMenuController; @@ -38,13 +39,14 @@ public class WikivoyageWptPtMenuController extends WptPtMenuController { } private static TravelArticle getTravelArticle(@NonNull MapActivity mapActivity, @NonNull WptPt wpt) { - SelectedGpxFile selectedGpxFile = mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedGPXFile(wpt); + OsmandApplication app = mapActivity.getMyApplication(); + SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().getSelectedGPXFile(wpt); GPXFile gpxFile = selectedGpxFile != null ? selectedGpxFile.getGpxFile() : null; Metadata metadata = gpxFile != null ? gpxFile.metadata : null; String title = metadata != null ? metadata.getArticleTitle() : null; String lang = metadata != null ? metadata.getArticleLang() : null; if (!TextUtils.isEmpty(title) && !TextUtils.isEmpty(lang)) { - return mapActivity.getMyApplication().getTravelHelper().getArticleByTitle(title, new LatLon(wpt.lat, wpt.lon), lang); + return app.getTravelHelper().getArticleByTitle(title, new LatLon(wpt.lat, wpt.lon), lang, false, null); } return null; } From effe5c96e3123b39713a658685e49d45250a9676 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 26 Jan 2021 18:47:33 +0200 Subject: [PATCH 045/125] Make widgets visibility in gpx menu same as in context menu --- .../osmand/plus/activities/MapActivity.java | 12 +++++- .../plus/mapcontextmenu/MapContextMenu.java | 32 ++++++++------- .../osmand/plus/track/TrackMenuFragment.java | 40 ++++++++++--------- .../plus/views/layers/MapControlsLayer.java | 12 +++--- .../mapwidgets/MapInfoWidgetsFactory.java | 4 +- .../mapwidgets/MapMarkersWidgetsFactory.java | 2 +- 6 files changed, 60 insertions(+), 42 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 316d5c36b2..0de562fa2b 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -70,7 +70,6 @@ import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.OnDismissDialogFragmentListener; import net.osmand.plus.OsmAndConstants; -import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; import net.osmand.plus.OsmAndLocationSimulation; import net.osmand.plus.OsmandApplication; @@ -1568,6 +1567,17 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven } } + public boolean shouldHideTopControls() { + boolean hideTopControls = !mapContextMenu.shouldShowTopControls(); + + TrackMenuFragment fragment = getTrackMenuFragment(); + if (fragment != null) { + hideTopControls = hideTopControls || !fragment.shouldShowTopControls(); + } + + return hideTopControls; + } + public OsmandMapTileView getMapView() { return mapView; } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index c1a6a6cc0a..cd035da4bb 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -22,18 +22,17 @@ import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.TransportStop; -import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; -import net.osmand.plus.mapmarkers.MapMarker; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkerChangedListener; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.TargetPointsHelper.TargetPointChangedListener; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.GpxUiHelper; +import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment.ContextMenuItemClickListener; import net.osmand.plus.mapcontextmenu.MenuController.ContextMenuToolbarController; import net.osmand.plus.mapcontextmenu.MenuController.MenuState; import net.osmand.plus.mapcontextmenu.MenuController.MenuType; @@ -47,12 +46,14 @@ import net.osmand.plus.mapcontextmenu.editors.RtePtEditor; import net.osmand.plus.mapcontextmenu.editors.WptPtEditor; import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu; import net.osmand.plus.mapcontextmenu.other.ShareMenu; -import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment.ContextMenuItemClickListener; +import net.osmand.plus.mapmarkers.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkerChangedListener; import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.routing.RoutingHelper; +import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.transport.TransportStopRoute; -import net.osmand.plus.views.layers.ContextMenuLayer; import net.osmand.plus.views.OsmandMapLayer; +import net.osmand.plus.views.layers.ContextMenuLayer; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType; import net.osmand.util.Algorithms; @@ -570,18 +571,21 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL public void updateControlsVisibility(boolean menuVisible) { MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { - int topControlsVisibility = shouldShowTopControls(menuVisible) ? View.VISIBLE : View.GONE; - mapActivity.findViewById(R.id.map_center_info).setVisibility(topControlsVisibility); - mapActivity.findViewById(R.id.map_left_widgets_panel).setVisibility(topControlsVisibility); - mapActivity.findViewById(R.id.map_right_widgets_panel).setVisibility(topControlsVisibility); - - int bottomControlsVisibility = shouldShowBottomControls(menuVisible) ? View.VISIBLE : View.GONE; - mapActivity.findViewById(R.id.bottom_controls_container).setVisibility(bottomControlsVisibility); - - mapActivity.refreshMap(); + boolean topControlsVisible = shouldShowTopControls(menuVisible); + boolean bottomControlsVisible = shouldShowBottomControls(menuVisible); + updateControlsVisibility(mapActivity, topControlsVisible, bottomControlsVisible); } } + public static void updateControlsVisibility(@NonNull MapActivity mapActivity, boolean topControlsVisible, boolean bottomControlsVisible) { + AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_center_info), topControlsVisible); + AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_left_widgets_panel), topControlsVisible); + AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_right_widgets_panel), topControlsVisible); + AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.bottom_controls_container), bottomControlsVisible); + + mapActivity.refreshMap(); + } + public boolean shouldShowTopControls() { return shouldShowTopControls(isVisible()); } diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index 0e21879f85..ff7a55180d 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -270,7 +270,6 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card setupToolbar(); updateHeader(); setupButtons(view); - enterTrackAppearanceMode(); runLayoutListener(); } return view; @@ -458,7 +457,12 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card @Override public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int currentMenuState, int previousMenuState) { super.onContextMenuStateChanged(fragment, currentMenuState, previousMenuState); - if (currentMenuState != MenuState.FULL_SCREEN && (currentMenuState != previousMenuState || !mapPositionAdjusted)) { + + boolean changed = currentMenuState != previousMenuState; + if (changed) { + updateControlsVisibility(true); + } + if (currentMenuState != MenuState.FULL_SCREEN && (changed || !mapPositionAdjusted)) { adjustMapPosition(getViewY()); } } @@ -466,7 +470,6 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card @Override public void onDestroyView() { super.onDestroyView(); - exitTrackAppearanceMode(); updateStatusBarColor(); } @@ -477,6 +480,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card if (mapActivity != null && trackChartPoints != null) { mapActivity.getMapLayers().getGpxLayer().setTrackChartPoints(trackChartPoints); } + updateControlsVisibility(true); startLocationUpdate(); } @@ -487,6 +491,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card if (mapActivity != null) { mapActivity.getMapLayers().getGpxLayer().setTrackChartPoints(null); } + updateControlsVisibility(false); stopLocationUpdate(); } @@ -572,26 +577,25 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card updateContent(); } - private void enterTrackAppearanceMode() { + public void updateControlsVisibility(boolean menuVisible) { MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { - boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity); - AndroidUiHelper.setVisibility(mapActivity, portrait ? View.INVISIBLE : View.GONE, - R.id.map_left_widgets_panel, - R.id.map_right_widgets_panel, - R.id.map_center_info); + boolean topControlsVisible = shouldShowTopControls(menuVisible); + boolean bottomControlsVisible = shouldShowBottomControls(menuVisible); + MapContextMenu.updateControlsVisibility(mapActivity, topControlsVisible, bottomControlsVisible); } } - private void exitTrackAppearanceMode() { - MapActivity mapActivity = getMapActivity(); - if (mapActivity != null) { - AndroidUiHelper.setVisibility(mapActivity, View.VISIBLE, - R.id.map_left_widgets_panel, - R.id.map_right_widgets_panel, - R.id.map_center_info, - R.id.map_search_button); - } + public boolean shouldShowTopControls() { + return shouldShowTopControls(isVisible()); + } + + public boolean shouldShowTopControls(boolean menuVisible) { + return !menuVisible || !isPortrait() || getCurrentMenuState() == MenuState.HEADER_ONLY; + } + + public boolean shouldShowBottomControls(boolean menuVisible) { + return !menuVisible || !isPortrait(); } @Override diff --git a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java index e4fe3a484c..22eb448670 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java @@ -859,30 +859,30 @@ public class MapControlsLayer extends OsmandMapLayer { } boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode(); boolean trackDialogOpened = mapActivity.getTrackDetailsMenu().isVisible(); - boolean contextMenuOpened = !mapActivity.getContextMenu().shouldShowTopControls(); + boolean shouldHideTopControls = mapActivity.shouldHideTopControls(); boolean showRouteCalculationControls = routePlanningMode || ((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode); boolean routeDialogOpened = mapRouteInfoMenu.isVisible() || (showRouteCalculationControls && mapRouteInfoMenu.needShowMenu()); - updateMyLocationVisibility(backToLocationControl, rh, routeDialogOpened || contextMenuOpened); + updateMyLocationVisibility(backToLocationControl, rh, routeDialogOpened || shouldHideTopControls); //routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_info_dark : R.drawable.ic_action_gdirections_dark); updateRoutePlaningButton(rh, routePlanningMode); boolean showBottomMenuButtons = (showRouteCalculationControls || !routeFollowingMode) && !isInMovingMarkerMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode() - && !isInPlanRouteMode() && !contextMenuOpened && !isInChoosingRoutesMode() + && !isInPlanRouteMode() && !shouldHideTopControls && !isInChoosingRoutesMode() && !isInWaypointsChoosingMode() && !isInFollowTrackMode() && !isInTrackAppearanceMode(); routePlanningBtn.updateVisibility(showBottomMenuButtons); menuControl.updateVisibility(showBottomMenuButtons); - boolean showZoomButtons = !routeDialogOpened && !contextMenuOpened && !isInTrackAppearanceMode() + boolean showZoomButtons = !routeDialogOpened && !shouldHideTopControls && !isInTrackAppearanceMode() && (!isInGpxApproximationMode() || !isPotrait()) && !isInFollowTrackMode() && (!isInChoosingRoutesMode() || !isInWaypointsChoosingMode() || !portrait); mapZoomIn.updateVisibility(showZoomButtons); mapZoomOut.updateVisibility(showZoomButtons); boolean forceHideCompass = routeDialogOpened || trackDialogOpened || isInMeasurementToolMode() - || isInPlanRouteMode() || contextMenuOpened || isInChoosingRoutesMode() + || isInPlanRouteMode() || shouldHideTopControls || isInChoosingRoutesMode() || isInTrackAppearanceMode() || isInWaypointsChoosingMode() || isInFollowTrackMode(); compassHud.forceHideCompass = forceHideCompass; compassHud.updateVisibility(!forceHideCompass && shouldShowCompass()); @@ -892,7 +892,7 @@ public class MapControlsLayer extends OsmandMapLayer { if (layersHud.setIconResId(appMode.getIconRes())) { layersHud.update(app, isNight); } - boolean showTopButtons = !routeDialogOpened && !trackDialogOpened && !contextMenuOpened + boolean showTopButtons = !routeDialogOpened && !trackDialogOpened && !shouldHideTopControls && !isInMeasurementToolMode() && !isInPlanRouteMode() && !isInChoosingRoutesMode() && !isInTrackAppearanceMode() && !isInWaypointsChoosingMode() && !isInFollowTrackMode(); layersHud.updateVisibility(showTopButtons); diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index fca0ae429e..63c4c93ab9 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -974,7 +974,7 @@ public class MapInfoWidgetsFactory { } } } - if (map.isTopToolbarActive() || !map.getContextMenu().shouldShowTopControls() || MapRouteInfoMenu.chooseRoutesVisible || MapRouteInfoMenu.waypointsVisible) { + if (map.isTopToolbarActive() || map.shouldHideTopControls() || MapRouteInfoMenu.chooseRoutesVisible || MapRouteInfoMenu.waypointsVisible) { updateVisibility(false); } else if (showClosestWaypointFirstInAddress && updateWaypoint()) { updateVisibility(true); @@ -1232,7 +1232,7 @@ public class MapInfoWidgetsFactory { @SuppressLint("SetTextI18n") public boolean updateInfo() { - boolean visible = settings.SHOW_COORDINATES_WIDGET.get() && map.getContextMenu().shouldShowTopControls() + boolean visible = settings.SHOW_COORDINATES_WIDGET.get() && !map.shouldHideTopControls() && map.getMapRouteInfoMenu().shouldShowTopControls() && !map.isTopToolbarActive() && !map.getMapLayers().getGpxLayer().isInTrackAppearanceMode() && !MapRouteInfoMenu.chooseRoutesVisible && !MapRouteInfoMenu.waypointsVisible diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java index f47c0f8bd6..ac0765cee5 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java @@ -191,7 +191,7 @@ public class MapMarkersWidgetsFactory { || map.getMapRouteInfoMenu().isVisible() || addressTopBar.getVisibility() == View.VISIBLE || map.isTopToolbarActive() - || !map.getContextMenu().shouldShowTopControls() + || map.shouldHideTopControls() || map.getMapLayers().getGpxLayer().isInTrackAppearanceMode() || map.getMapLayers().getMapMarkersLayer().isInPlanRouteMode()) { updateVisibility(false); From 81ef3a95b8d4773f0d09ad4028187d49a86fc570 Mon Sep 17 00:00:00 2001 From: Skalii Date: Tue, 26 Jan 2021 18:55:32 +0200 Subject: [PATCH 046/125] fix changing icon show/hide button after clicking; add night colors --- .../src/net/osmand/plus/track/OverviewCard.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/track/OverviewCard.java b/OsmAnd/src/net/osmand/plus/track/OverviewCard.java index 8cca345d5c..dcebdc31da 100644 --- a/OsmAnd/src/net/osmand/plus/track/OverviewCard.java +++ b/OsmAnd/src/net/osmand/plus/track/OverviewCard.java @@ -78,7 +78,7 @@ public class OverviewCard extends BaseCard { @Override protected void updateContent() { - int iconColorDef = R.color.icon_color_active_light; + int iconColorDef = nightMode ? R.color.icon_color_active_dark : R.color.icon_color_active_light; int iconColorPres = R.color.active_buttons_and_links_text_dark; boolean fileAvailable = gpxFile.path != null && !gpxFile.showCurrentTrack; @@ -157,7 +157,7 @@ public class OverviewCard extends BaseCard { @ColorRes int iconColorDef, @ColorRes int iconColorPres, @Nullable final StatBlockCallback callback) { final AppCompatImageView icon = item.findViewById(R.id.image); final AppCompatImageView filled = item.findViewById(R.id.filled); - filled.setImageResource(R.drawable.bg_topbar_shield_exit_ref); + filled.setImageResource(nightMode ? R.drawable.bg_plugin_logo_enabled_dark : R.drawable.bg_topbar_shield_exit_ref); filled.setAlpha(0.1f); if (callback != null) { callback.run(icon); @@ -168,12 +168,12 @@ public class OverviewCard extends BaseCard { item.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (callback != null) { - callback.run(icon); - } CardListener listener = getListener(); if (listener != null) { listener.onCardButtonPressed(OverviewCard.this, buttonIndex); + if (callback != null) { + callback.run(icon); + } } } }); @@ -236,10 +236,13 @@ public class OverviewCard extends BaseCard { @Override public void onBindViewHolder(StatBlockViewHolder holder, int position) { final StatBlock item = statBlocks.get(position); + final int textColor = nightMode ? + app.getResources().getColor(R.color.active_color_primary_dark) + : app.getResources().getColor(R.color.active_color_primary_light); holder.valueText.setText(item.value); holder.titleText.setText(item.title); - holder.valueText.setTextColor(app.getResources().getColor(R.color.active_color_primary_light)); + holder.valueText.setTextColor(textColor); holder.titleText.setTextColor(app.getResources().getColor(R.color.text_color_secondary_light)); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override From 62a8b4dbfe0b9f5bbd6cfdc7dd2b4896bfb28e47 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 26 Jan 2021 19:20:25 +0200 Subject: [PATCH 047/125] Add zoom buttons to gpx menu --- OsmAnd/res/layout/context_menu_controls.xml | 30 +++++++++++++++++++ OsmAnd/res/layout/follow_track_options.xml | 29 +----------------- OsmAnd/res/layout/track_appearance.xml | 29 +----------------- OsmAnd/res/layout/track_menu.xml | 2 ++ .../osmand/plus/track/TrackMenuFragment.java | 1 + .../views/layers/MapQuickActionLayer.java | 1 + 6 files changed, 36 insertions(+), 56 deletions(-) create mode 100644 OsmAnd/res/layout/context_menu_controls.xml diff --git a/OsmAnd/res/layout/context_menu_controls.xml b/OsmAnd/res/layout/context_menu_controls.xml new file mode 100644 index 0000000000..0132153f4f --- /dev/null +++ b/OsmAnd/res/layout/context_menu_controls.xml @@ -0,0 +1,30 @@ + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/follow_track_options.xml b/OsmAnd/res/layout/follow_track_options.xml index 4523599e6c..0ca2466eb2 100644 --- a/OsmAnd/res/layout/follow_track_options.xml +++ b/OsmAnd/res/layout/follow_track_options.xml @@ -99,34 +99,7 @@ - - - - - - - + - - - - - - - + + + Date: Tue, 26 Jan 2021 19:35:22 +0200 Subject: [PATCH 048/125] Fix join gaps visibility --- OsmAnd/src/net/osmand/plus/track/OptionsCard.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/track/OptionsCard.java b/OsmAnd/src/net/osmand/plus/track/OptionsCard.java index e042a6ab6b..fef9f34f0b 100644 --- a/OsmAnd/src/net/osmand/plus/track/OptionsCard.java +++ b/OsmAnd/src/net/osmand/plus/track/OptionsCard.java @@ -74,7 +74,9 @@ public class OptionsCard extends BaseCard { items.add(createDirectionsItem()); } items.add(createDividerItem()); - items.add(createJoinGapsItem()); + if (gpxFile.getGeneralTrack() != null) { + items.add(createJoinGapsItem()); + } items.add(createAnalyzeOnMapItem()); items.add(createAnalyzeByIntervalsItem()); From 878208deee79b55325a91d305993fde0f3f576ba Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Tue, 26 Jan 2021 19:41:49 +0200 Subject: [PATCH 049/125] Review Show track on the map: all lines should be tappable. Slider color = profile color --- ...h_switch_divider_and_additional_button.xml | 16 ++++--- OsmAnd/res/layout/trip_recording_fragment.xml | 5 ++- OsmAnd/src/net/osmand/plus/UiUtilities.java | 2 +- .../monitoring/TripRecordingBottomSheet.java | 42 +++++++++++++++---- 4 files changed, 48 insertions(+), 17 deletions(-) diff --git a/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml b/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml index 681c03e560..8f95b5777b 100644 --- a/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml +++ b/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml @@ -7,15 +7,16 @@ android:baselineAligned="false" android:gravity="center_vertical" android:minHeight="@dimen/bottom_sheet_selected_item_title_height" - android:paddingStart="@dimen/content_padding" - android:paddingEnd="@dimen/content_padding" - android:paddingRight="@dimen/content_padding" - android:paddingLeft="@dimen/content_padding"> + > @@ -46,8 +47,9 @@ android:layout_gravity="center_vertical" android:layout_marginStart="@dimen/bottom_sheet_content_margin" android:layout_marginLeft="@dimen/bottom_sheet_content_margin" - android:layout_marginEnd="@dimen/bottom_sheet_content_margin" - android:layout_marginRight="@dimen/bottom_sheet_content_margin" + android:clickable="false" + android:focusable="false" + android:focusableInTouchMode="false" tools:checked="true" /> @@ -73,6 +75,8 @@ android:layout_gravity="center" android:layout_marginStart="@dimen/content_padding" android:layout_marginLeft="@dimen/content_padding" + android:layout_marginEnd="@dimen/content_padding" + android:layout_marginRight="@dimen/content_padding" app:srcCompat="@drawable/ic_action_track_line_bold_color" /> diff --git a/OsmAnd/res/layout/trip_recording_fragment.xml b/OsmAnd/res/layout/trip_recording_fragment.xml index 8c43e98d5f..d35626a7ce 100644 --- a/OsmAnd/res/layout/trip_recording_fragment.xml +++ b/OsmAnd/res/layout/trip_recording_fragment.xml @@ -32,6 +32,8 @@ android:background="?attr/dashboard_divider" /> @@ -106,8 +109,6 @@ android:id="@+id/second_divider" android:layout_width="match_parent" android:layout_height="1dp" - android:layout_marginTop="@dimen/content_padding" - android:layout_marginBottom="@dimen/bottom_sheet_content_margin_small" android:background="?attr/dashboard_divider" /> diff --git a/OsmAnd/src/net/osmand/plus/UiUtilities.java b/OsmAnd/src/net/osmand/plus/UiUtilities.java index 94bd3c4bcb..8d3a6d35bf 100644 --- a/OsmAnd/src/net/osmand/plus/UiUtilities.java +++ b/OsmAnd/src/net/osmand/plus/UiUtilities.java @@ -636,7 +636,7 @@ public class UiUtilities { int activeDisableColor = getColorWithAlpha(activeColor, 0.25f); ColorStateList activeCsl = new ColorStateList(states, new int[] {activeColor, activeDisableColor}); int inactiveColor = ContextCompat.getColor(ctx, nightMode ? R.color.icon_color_default_dark : R.color.icon_color_secondary_light); - ColorStateList inactiveCsl = new ColorStateList(states, new int[] {inactiveColor, inactiveColor}); + ColorStateList inactiveCsl = new ColorStateList(states, new int[] {activeDisableColor, inactiveColor}); slider.setTrackActiveTintList(activeCsl); slider.setTrackInactiveTintList(inactiveCsl); slider.setHaloTintList(activeCsl); diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java index 54b444ff30..096430f3da 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java @@ -9,6 +9,7 @@ import android.os.Bundle; import android.text.SpannableString; import android.view.LayoutInflater; import android.view.View; +import android.view.ViewGroup; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.ImageView; @@ -18,10 +19,12 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.SwitchCompat; +import androidx.core.content.ContextCompat; import androidx.fragment.app.FragmentManager; import com.google.android.material.slider.RangeSlider; +import net.osmand.AndroidUtils; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.NavigationService; import net.osmand.plus.OsmandApplication; @@ -49,9 +52,10 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment { private ImageView upDownBtn; private SwitchCompat confirmEveryRun; - private RangeSlider intervalSlider; private TextView intervalValueView; private LinearLayout container; + private LinearLayout expandHideIntervalContainer; + private View divider; private boolean infoExpanded; @Override @@ -92,8 +96,10 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment { } }); + divider = itemView.findViewById(R.id.second_divider); + expandHideIntervalContainer = itemView.findViewById(R.id.interval_view_container); upDownBtn = itemView.findViewById(R.id.up_down_button); - upDownBtn.setOnClickListener(new View.OnClickListener() { + expandHideIntervalContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -108,8 +114,11 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment { updateIntervalLegend(); container = itemView.findViewById(R.id.always_ask_and_range_slider_container); - intervalSlider = itemView.findViewById(R.id.interval_slider); + RangeSlider intervalSlider = itemView.findViewById(R.id.interval_slider); intervalSlider.setValueTo(secondsLength + minutesLength - 1); + int currentModeColorRes = app.getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode); + int currentModeColor = ContextCompat.getColor(app, currentModeColorRes); + UiUtilities.setupSlider(intervalSlider, nightMode, currentModeColor, true); container.setVisibility(View.GONE); intervalSlider.addOnChangeListener(new RangeSlider.OnChangeListener() { @@ -126,6 +135,7 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment { updateIntervalLegend(); } }); + for (int i = 0; i < secondsLength + minutesLength; i++) { if (i < secondsLength) { if (settings.SAVE_GLOBAL_TRACK_INTERVAL.get() <= SECONDS[i] * 1000) { @@ -151,13 +161,19 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment { } }); - SwitchCompat showTrackOnMapButton = showTrackOnMapView.findViewById(R.id.switch_button); + final SwitchCompat showTrackOnMapButton = showTrackOnMapView.findViewById(R.id.switch_button); showTrackOnMapButton.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null); - showTrackOnMapButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - + View basicItem = itemView.findViewById(R.id.basic_item_body); + basicItem.setOnClickListener(new View.OnClickListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), isChecked, false); + public void onClick(View v) { + if (showTrackOnMapButton.isChecked()) { + showTrackOnMapButton.setChecked(false); + app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), false, false); + } else { + showTrackOnMapButton.setChecked(true); + app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), true, false); + } } }); UiUtilities.setupCompoundButton(showTrackOnMapButton, nightMode, PROFILE_DEPENDENT); @@ -217,6 +233,16 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment { private void toggleInfoView() { infoExpanded = !infoExpanded; + ViewGroup.MarginLayoutParams marginParams = (ViewGroup.MarginLayoutParams) divider.getLayoutParams(); + if (getMapActivity() != null) { + final int dp8 = AndroidUtils.dpToPx(getMapActivity(), 8f); + final int dp16 = AndroidUtils.dpToPx(getMapActivity(), 16f); + if (infoExpanded) { + AndroidUtils.setMargins(marginParams, 0, dp16, 0, dp8); + } else { + AndroidUtils.setMargins(marginParams, 0, 0, 0, dp8); + } + } AndroidUiHelper.updateVisibility(container, infoExpanded); updateUpDownBtn(); } From 0967630a6bfd9658cc328be2d6e163a94320ae86 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Tue, 26 Jan 2021 21:26:02 +0300 Subject: [PATCH 050/125] Added progress bar to travel navigation --- .../res/layout/bottom_sheet_item_progress.xml | 10 ++ .../simpleitems/ProgressItem.java | 11 ++ .../WikivoyageArticleNavigationFragment.java | 139 ++++++++++++------ .../plus/wikivoyage/data/TravelObfHelper.java | 2 +- 4 files changed, 117 insertions(+), 45 deletions(-) create mode 100644 OsmAnd/res/layout/bottom_sheet_item_progress.xml create mode 100644 OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/ProgressItem.java diff --git a/OsmAnd/res/layout/bottom_sheet_item_progress.xml b/OsmAnd/res/layout/bottom_sheet_item_progress.xml new file mode 100644 index 0000000000..6fcb6e1286 --- /dev/null +++ b/OsmAnd/res/layout/bottom_sheet_item_progress.xml @@ -0,0 +1,10 @@ + + diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/ProgressItem.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/ProgressItem.java new file mode 100644 index 0000000000..ec3724b9d3 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/ProgressItem.java @@ -0,0 +1,11 @@ +package net.osmand.plus.base.bottomsheetmenu.simpleitems; + +import net.osmand.plus.R; +import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; + +public class ProgressItem extends SimpleBottomSheetItem { + + public ProgressItem() { + this.layoutId = R.layout.bottom_sheet_item_progress; + } +} diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleNavigationFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleNavigationFragment.java index 98500afa01..d99937cce8 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleNavigationFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleNavigationFragment.java @@ -1,7 +1,9 @@ package net.osmand.plus.wikivoyage.article; +import android.app.Activity; import android.content.Context; import android.graphics.drawable.Drawable; +import android.os.AsyncTask; import android.os.Bundle; import android.text.TextUtils; import android.view.LayoutInflater; @@ -24,7 +26,9 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; import net.osmand.plus.base.MenuBottomSheetDialogFragment; +import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.ProgressItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; import net.osmand.plus.wikivoyage.data.TravelArticle; import net.osmand.plus.wikivoyage.data.TravelArticle.TravelArticleIdentifier; @@ -53,6 +57,7 @@ public class WikivoyageArticleNavigationFragment extends MenuBottomSheetDialogFr private List parentsList; private ExpandableListView expListView; + private Map> navigationMap; @Override public void createMenuItems(Bundle savedInstanceState) { @@ -83,55 +88,21 @@ public class WikivoyageArticleNavigationFragment extends MenuBottomSheetDialogFr } parentsList = new ArrayList<>(Arrays.asList(article.getAggregatedPartOf().split(","))); - Map> navigationMap - = app.getTravelHelper().getNavigationMap(article); - items.add(new TitleItem(getString(R.string.shared_string_navigation))); - expListView = new ExpandableListView(ctx); - final ExpandableListAdapter listAdapter = new ExpandableListAdapter(ctx, navigationMap); + if (navigationMap == null) { + items.add(new ProgressItem()); + new BuildNavigationTask(app).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + } else { + final ExpandableListAdapter listAdapter = createNavigationListView(navigationMap); + LinearLayout container = new LinearLayout(ctx); + container.addView(expListView); - expListView.setAdapter(listAdapter); - Drawable transparent = AppCompatResources.getDrawable(ctx, R.color.color_transparent); - expListView.setDivider(transparent); - expListView.setGroupIndicator(transparent); - expListView.setSelector(transparent); - expListView.setLayoutParams(new LinearLayout.LayoutParams( - LinearLayout.LayoutParams.MATCH_PARENT, - LinearLayout.LayoutParams.MATCH_PARENT) - ); + items.add(new SimpleBottomSheetItem.Builder().setCustomView(container).create()); - expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { - @Override - public boolean onChildClick(ExpandableListView parent, View v, - int groupPosition, int childPosition, long id) { - WikivoyageSearchResult articleItem = listAdapter.getArticleItem(groupPosition, childPosition); - sendResults(articleItem.getArticleTitle()); - dismiss(); - return true; + if (listAdapter.getGroupCount() > 0) { + expListView.expandGroup(listAdapter.getGroupCount() - 1); } - }); - expListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { - @Override - public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { - WikivoyageSearchResult articleItem = (WikivoyageSearchResult) listAdapter.getGroup(groupPosition); - if (Algorithms.isEmpty(articleItem.getArticleTitle())) { - Toast.makeText(getContext(), R.string.wiki_article_not_found, Toast.LENGTH_LONG).show(); - } else { - sendResults(articleItem.getArticleTitle()); - dismiss(); - } - return true; - } - }); - - LinearLayout container = new LinearLayout(ctx); - container.addView(expListView); - - items.add(new SimpleBottomSheetItem.Builder().setCustomView(container).create()); - - if (listAdapter.getGroupCount() > 0) { - expListView.expandGroup(listAdapter.getGroupCount() - 1); } } @@ -309,4 +280,84 @@ public class WikivoyageArticleNavigationFragment extends MenuBottomSheetDialogFr return true; } } + + public void updateMenu() { + Activity activity = getActivity(); + View mainView = getView(); + if (activity != null && mainView != null) { + LinearLayout itemsContainer = (LinearLayout) mainView.findViewById(useScrollableItemsContainer() + ? R.id.scrollable_items_container : R.id.non_scrollable_items_container); + if (itemsContainer != null) { + itemsContainer.removeAllViews(); + } + items.clear(); + createMenuItems(null); + for (BaseBottomSheetItem item : items) { + item.inflate(activity, itemsContainer, nightMode); + } + setupHeightAndBackground(mainView); + } + } + + private ExpandableListAdapter createNavigationListView(Map> navigationMap) { + final Context ctx = requireContext(); + + expListView = new ExpandableListView(ctx); + final ExpandableListAdapter listAdapter = new ExpandableListAdapter(ctx, navigationMap); + + expListView.setAdapter(listAdapter); + Drawable transparent = AppCompatResources.getDrawable(ctx, R.color.color_transparent); + expListView.setDivider(transparent); + expListView.setGroupIndicator(transparent); + expListView.setSelector(transparent); + expListView.setLayoutParams(new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.MATCH_PARENT) + ); + + expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { + @Override + public boolean onChildClick(ExpandableListView parent, View v, + int groupPosition, int childPosition, long id) { + WikivoyageSearchResult articleItem = listAdapter.getArticleItem(groupPosition, childPosition); + sendResults(articleItem.getArticleTitle()); + dismiss(); + return true; + } + }); + expListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { + @Override + public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { + WikivoyageSearchResult articleItem = (WikivoyageSearchResult) listAdapter.getGroup(groupPosition); + if (Algorithms.isEmpty(articleItem.getArticleTitle())) { + Toast.makeText(ctx, R.string.wiki_article_not_found, Toast.LENGTH_LONG).show(); + } else { + sendResults(articleItem.getArticleTitle()); + dismiss(); + } + return true; + } + }); + return listAdapter; + } + + private class BuildNavigationTask extends AsyncTask>> { + + private final OsmandApplication app; + + public BuildNavigationTask(@NonNull OsmandApplication app) { + this.app = app; + } + + @Override + protected Map> doInBackground(Void... voids) { + return app.getTravelHelper().getNavigationMap(article); + } + + @Override + protected void onPostExecute(Map> navigationMap) { + WikivoyageArticleNavigationFragment.this.navigationMap = navigationMap; + updateMenu(); + } + } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index 9ea963db81..0f14896a94 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -362,7 +362,7 @@ public class TravelObfHelper implements TravelHelper { @NonNull @Override - public Map> getNavigationMap(@NonNull final TravelArticle article) { + public synchronized Map> getNavigationMap(@NonNull final TravelArticle article) { final String lang = article.getLang(); final String title = article.getTitle(); if (TextUtils.isEmpty(lang) || TextUtils.isEmpty(title)) { From 181528de1227749239d8a21366d350b5337aa93a Mon Sep 17 00:00:00 2001 From: Ihor Hordiichuk Date: Tue, 26 Jan 2021 18:18:17 +0000 Subject: [PATCH 051/125] Translated using Weblate (Ukrainian) Currently translated at 100.0% (3651 of 3651 strings) --- OsmAnd/res/values-uk/strings.xml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml index e66ec0fbe9..ee3261419f 100644 --- a/OsmAnd/res/values-uk/strings.xml +++ b/OsmAnd/res/values-uk/strings.xml @@ -57,7 +57,7 @@ Для поточної місцевості відсутні векторні автономні мапи. Завантажте їх у \'Налаштуваннях\' (\'Керування файлами мап\') або перемкніться на втулок \'Мережеві мапи\'. Відправити GPX файли в OSM? Видимість - Теги + Мітки Для вивантаження GPX-файлів вкажіть ваше ім\'я користувача і пароль в OSM. Підтримка Підтримати розробку нових функцій @@ -597,7 +597,7 @@ Оновити мапу Оновити частину мапи Точка - Додати в закладки + Додати до закладок Вибір між місцевими та англійськими назвами. Використовувати англійські назви на мапах Налаштування програми @@ -657,7 +657,7 @@ Застосувати Додати Ні - Введіть ім’я Закладки + Введіть назву Закладки Закладка Точку Закладки \'\'{0}\'\' додано. Редагувати Закладку @@ -1382,7 +1382,7 @@ Завантажте спеціальну безмережеву мапу, щоб відобразити морські подробиці. Редагувати групу Місце для стоянки - ВИЛУЧИТИ ТЕҐ + ВИЛУЧИТИ МІТКУ Стан GPS Завантажити нічні збірки. Збірки @@ -2844,7 +2844,7 @@ Крутість Запустити OsmAnd\? Пішки - Довжина тегу \"%s\" має бути менше 255 символів. + Довжина мітки \"%s\" має бути менше 255 символів. Докладніше про те, як OsmAnd розраховує маршрути, читайте в нашому деннику. Навігація громадським транспортом на даний час проходить тестування, можливі помилки та неточності. Додати проміжну точку @@ -3617,7 +3617,7 @@ Показати чи приховати громадський транспорт Кнопка показу або приховування громадського транспорту на мапі. Створити чи змінити POI - Додати чи змінити вибране + Додати чи змінити закладку Відновити усталене впорядкування Повернутися до редагування Ви можете отримати доступ до цих дій, торкнувшись кнопки “%1$s”. @@ -3999,4 +3999,10 @@ Гірський велосипед Помилка сервера: %1$s Назва вже існує + Видалити цей рушій мережної маршрутизації\? + Читати повністю + Змінити опис + Видалити маршрутні точки + Копіювати до позначок мапи + Копіювати до закладок \ No newline at end of file From d6cf24c99cf58aa451efac471e66848f223c58a6 Mon Sep 17 00:00:00 2001 From: Yaron Shahrabani Date: Tue, 26 Jan 2021 18:19:50 +0000 Subject: [PATCH 052/125] Translated using Weblate (Hebrew) Currently translated at 99.7% (3642 of 3651 strings) --- OsmAnd/res/values-iw/strings.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/OsmAnd/res/values-iw/strings.xml b/OsmAnd/res/values-iw/strings.xml index 5cefe14bd4..4915811995 100644 --- a/OsmAnd/res/values-iw/strings.xml +++ b/OsmAnd/res/values-iw/strings.xml @@ -3993,4 +3993,12 @@ רכיבת הרים רכיבת כביש רכיבה רגילה + טיול שטח + משאית כבדה + למחוק את מנוע הניווט המקוון הזה\? + להציג במלואו + עריכת תיאור + מחיקת נקודות דרך + העתקה לסמני המפה + העתקה למועדפים \ No newline at end of file From 8f9a56e161a7d8e0b07ec1159907c9893e3e22a5 Mon Sep 17 00:00:00 2001 From: Verdulo Date: Tue, 26 Jan 2021 18:59:11 +0000 Subject: [PATCH 053/125] Translated using Weblate (Esperanto) Currently translated at 99.8% (3646 of 3651 strings) --- OsmAnd/res/values-eo/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values-eo/strings.xml b/OsmAnd/res/values-eo/strings.xml index 59164b63aa..e203d58aaf 100644 --- a/OsmAnd/res/values-eo/strings.xml +++ b/OsmAnd/res/values-eo/strings.xml @@ -4000,4 +4000,5 @@ Interspacoj distancaj kaj tempaj Tempo de anonco de diversaj voĉaj sciigoj dependas de ilia specoj, nuna naviga kaj implicita naviga rapido. Tempo de anonco + Kopii al ŝatataj \ No newline at end of file From e4b60c02863c713f50bca819ec97eba680933ed8 Mon Sep 17 00:00:00 2001 From: Verdulo Date: Tue, 26 Jan 2021 19:01:52 +0000 Subject: [PATCH 054/125] Translated using Weblate (Esperanto) Currently translated at 100.0% (3651 of 3651 strings) --- OsmAnd/res/values-eo/strings.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OsmAnd/res/values-eo/strings.xml b/OsmAnd/res/values-eo/strings.xml index e203d58aaf..349175b810 100644 --- a/OsmAnd/res/values-eo/strings.xml +++ b/OsmAnd/res/values-eo/strings.xml @@ -4001,4 +4001,9 @@ Tempo de anonco de diversaj voĉaj sciigoj dependas de ilia specoj, nuna naviga kaj implicita naviga rapido. Tempo de anonco Kopii al ŝatataj + Ĉu forigi tiun ĉi enretan navigilon\? + Legi pli + Redakti priskribon + Forigi navigadpunktojn + Kopii al map‑markoj \ No newline at end of file From 7cb209adb53c2f222ad31aea652bf0a12064a76e Mon Sep 17 00:00:00 2001 From: Ihor Hordiichuk Date: Tue, 26 Jan 2021 19:11:50 +0000 Subject: [PATCH 055/125] Translated using Weblate (Ukrainian) Currently translated at 100.0% (3651 of 3651 strings) --- OsmAnd/res/values-uk/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml index ee3261419f..45b0ce54f6 100644 --- a/OsmAnd/res/values-uk/strings.xml +++ b/OsmAnd/res/values-uk/strings.xml @@ -683,7 +683,7 @@ Відкрити Коментар Зміна POI - Наступні теги POI не можуть бути змінені + Всі інші мітки POI не буде змінено Зберегти Очистити Фільтр From 32b4517c1ca9bd31d0eaac302c8e108f1d407997 Mon Sep 17 00:00:00 2001 From: Ihor Hordiichuk Date: Tue, 26 Jan 2021 19:13:51 +0000 Subject: [PATCH 056/125] Translated using Weblate (Ukrainian) Currently translated at 100.0% (3651 of 3651 strings) --- OsmAnd/res/values-uk/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml index 45b0ce54f6..c0bb7f6e03 100644 --- a/OsmAnd/res/values-uk/strings.xml +++ b/OsmAnd/res/values-uk/strings.xml @@ -3344,8 +3344,8 @@ Точність журналювання Ви можете знайти всі записи в %1$s або в теці OsmAnd за допомогою файлового провідника. Ваші нотатки OSM розміщено в %1$s. - Відеонотатки - Фотонотатки + Відеопримітки + Фотопримітки Перерахунок маршруту Оголошення Ім\'я користувача і пароль From 4eec9ca8c41a8cde3d52fb875ab072e02544ea1b Mon Sep 17 00:00:00 2001 From: Ihor Hordiichuk Date: Tue, 26 Jan 2021 19:14:06 +0000 Subject: [PATCH 057/125] Translated using Weblate (Ukrainian) Currently translated at 100.0% (3651 of 3651 strings) --- OsmAnd/res/values-uk/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml index c0bb7f6e03..7abdd334db 100644 --- a/OsmAnd/res/values-uk/strings.xml +++ b/OsmAnd/res/values-uk/strings.xml @@ -3343,7 +3343,7 @@ Мережеве відстеження Точність журналювання Ви можете знайти всі записи в %1$s або в теці OsmAnd за допомогою файлового провідника. - Ваші нотатки OSM розміщено в %1$s. + Ваші примітки OSM розміщено в %1$s. Відеопримітки Фотопримітки Перерахунок маршруту From fea90fd37e6395feb960ff8e1c30c508ff7f20b4 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Tue, 26 Jan 2021 23:41:44 +0200 Subject: [PATCH 058/125] Add to bookmarks, build gpx track --- .../plus/wikivoyage/data/TravelGpx.java | 6 ++ .../data/TravelLocalDataHelper.java | 33 +++++-- .../plus/wikivoyage/data/TravelObfHelper.java | 82 +++++++++++++++- .../explore/SavedArticlesRvAdapter.java | 93 ++++++++++++++++--- .../explore/travelcards/TravelGpxCard.java | 18 ++-- 5 files changed, 198 insertions(+), 34 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelGpx.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelGpx.java index 8393ec98a6..185fdc922c 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelGpx.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelGpx.java @@ -1,6 +1,12 @@ package net.osmand.plus.wikivoyage.data; public class TravelGpx extends TravelArticle { + + public static final String DISTANCE = "distance"; + public static final String DIFF_ELE_UP = "diff_ele_up"; + public static final String DIFF_ELE_DOWN = "diff_ele_down"; + public static final String USER = "user"; + public String user; public float totalDistance = 0; public double diffElevationUp = 0; diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java index 2c59c16ed2..748800a611 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java @@ -143,6 +143,9 @@ public class TravelLocalDataHelper { @Nullable private TravelArticle getArticle(String title, String lang) { for (TravelArticle article : savedArticles) { + if (article.lang == null && lang == null && article.title != null && article.title.equals(title)) { + return article; + } if (article.title != null && article.title.equals(title) && article.lang != null && article.lang.equals(lang)) { return article; } @@ -477,12 +480,23 @@ public class TravelLocalDataHelper { SQLiteConnection conn = openConnection(false); if (conn != null) { try { - conn.execSQL("DELETE FROM " + BOOKMARKS_TABLE_NAME + - " WHERE " + BOOKMARKS_COL_ARTICLE_TITLE + " = ?" + - " AND " + BOOKMARKS_COL_ROUTE_ID + " = ?" + - " AND " + BOOKMARKS_COL_LANG + " = ?" + - " AND " + BOOKMARKS_COL_TRAVEL_BOOK + " = ?", - new Object[]{article.title, article.routeId, article.lang, travelBook}); + String query; + Object[] parameters; + if (article.lang == null) { + query = "DELETE FROM " + BOOKMARKS_TABLE_NAME + + " WHERE " + BOOKMARKS_COL_ARTICLE_TITLE + " = ?" + + " AND " + BOOKMARKS_COL_ROUTE_ID + " = ?" + + " AND " + BOOKMARKS_COL_TRAVEL_BOOK + " = ?"; + parameters = new Object[]{article.title, article.routeId, travelBook}; + } else { + query = "DELETE FROM " + BOOKMARKS_TABLE_NAME + + " WHERE " + BOOKMARKS_COL_ARTICLE_TITLE + " = ?" + + " AND " + BOOKMARKS_COL_ROUTE_ID + " = ?" + + " AND " + BOOKMARKS_COL_LANG + " = ?" + + " AND " + BOOKMARKS_COL_TRAVEL_BOOK + " = ?"; + parameters = new Object[]{article.title, article.routeId, article.lang, travelBook}; + } + conn.execSQL(query, parameters); } finally { conn.close(); } @@ -537,7 +551,12 @@ public class TravelLocalDataHelper { @NonNull private TravelArticle readSavedArticle(SQLiteCursor cursor) { - TravelArticle res = new TravelArticle(); + TravelArticle res; + if (cursor.getString(cursor.getColumnIndex(BOOKMARKS_COL_LANG)) == null) { + res = new TravelGpx(); + } else { + res = new TravelArticle(); + } res.title = cursor.getString(cursor.getColumnIndex(BOOKMARKS_COL_ARTICLE_TITLE)); res.lang = cursor.getString(cursor.getColumnIndex(BOOKMARKS_COL_LANG)); res.aggregatedPartOf = cursor.getString(cursor.getColumnIndex(BOOKMARKS_COL_IS_PART_OF)); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index 0f76eb775e..13c4fffa49 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -8,11 +8,13 @@ import androidx.annotation.Nullable; import net.osmand.Collator; import net.osmand.CollatorStringMatcher.StringMatcherMode; +import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; import net.osmand.IndexConstants; import net.osmand.OsmAndCollator; import net.osmand.PlatformUtil; import net.osmand.ResultMatcher; +import net.osmand.binary.BinaryMapDataObject; import net.osmand.binary.BinaryMapIndexReader; import net.osmand.binary.BinaryMapIndexReader.SearchRequest; import net.osmand.data.Amenity; @@ -48,6 +50,10 @@ import java.util.concurrent.ConcurrentHashMap; import static net.osmand.GPXUtilities.WptPt; import static net.osmand.GPXUtilities.writeGpxFile; import static net.osmand.plus.helpers.GpxUiHelper.getGpxTitle; +import static net.osmand.plus.wikivoyage.data.TravelGpx.DIFF_ELE_DOWN; +import static net.osmand.plus.wikivoyage.data.TravelGpx.DIFF_ELE_UP; +import static net.osmand.plus.wikivoyage.data.TravelGpx.DISTANCE; +import static net.osmand.plus.wikivoyage.data.TravelGpx.USER; import static net.osmand.util.Algorithms.capitalizeFirstLetter; public class TravelObfHelper implements TravelHelper { @@ -168,25 +174,26 @@ public class TravelObfHelper implements TravelHelper { private Map readRoutePoint(File file, Amenity amenity) { Map articles = new HashMap<>(); TravelGpx res = new TravelGpx(); + res.file = file; String title = amenity.getName("en"); res.title = capitalizeFirstLetter(getGpxTitle(Algorithms.isEmpty(title) ? amenity.getName() : title)); res.routeId = Algorithms.emptyIfNull(amenity.getTagContent(Amenity.ROUTE_ID)); try { - res.totalDistance = Float.parseFloat(Algorithms.emptyIfNull(amenity.getTagContent("distance"))); + res.totalDistance = Float.parseFloat(Algorithms.emptyIfNull(amenity.getTagContent(DISTANCE))); } catch (NumberFormatException e) { LOG.debug(e.getMessage(), e); } try { - res.diffElevationUp = Double.parseDouble(Algorithms.emptyIfNull(amenity.getTagContent("diff_ele_up"))); + res.diffElevationUp = Double.parseDouble(Algorithms.emptyIfNull(amenity.getTagContent(DIFF_ELE_UP))); } catch (NumberFormatException e) { LOG.debug(e.getMessage(), e); } try { - res.diffElevationDown = Double.parseDouble(Algorithms.emptyIfNull(amenity.getTagContent("diff_ele_down"))); + res.diffElevationDown = Double.parseDouble(Algorithms.emptyIfNull(amenity.getTagContent(DIFF_ELE_DOWN))); } catch (NumberFormatException e) { LOG.debug(e.getMessage(), e); } - res.user = Algorithms.emptyIfNull(amenity.getTagContent("user")); + res.user = Algorithms.emptyIfNull(amenity.getTagContent(USER)); articles.put("en", res); return articles; } @@ -255,6 +262,66 @@ public class TravelObfHelper implements TravelHelper { return gpxFile; } + @Nullable + private GPXFile buildTravelGpxFile(@NonNull final TravelGpx article) { + String routeId = article.getRouteId(); + final String ref = routeId.substring(routeId.length() - 3); + final List segmentList = new ArrayList<>(); + + for (BinaryMapIndexReader reader : getReaders()) { + try { + if (article.file != null && !article.file.equals(reader.getFile())) { + continue; + } + BinaryMapIndexReader.SearchRequest sr = BinaryMapIndexReader.buildSearchRequest( + 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, 15, null, + new ResultMatcher() { + @Override + public boolean publish(BinaryMapDataObject object) { + if (object.getPointsLength() > 1) { + if (object.getObjectNames().get(2).equals(ref) + && capitalizeFirstLetter(getGpxTitle(object.getObjectNames().get(1))).equals(article.title)) { + segmentList.add(object); + } + } + return false; + } + + @Override + public boolean isCancelled() { + return false; + } + }); + reader.searchMapIndex(sr); + if (!Algorithms.isEmpty(segmentList)) { + break; + } + } catch (Exception e) { + System.out.println(e.getMessage()); + } + } + GPXFile gpxFile = null; + if (!segmentList.isEmpty()) { + GPXUtilities.Track track = new GPXUtilities.Track(); + for (BinaryMapDataObject segment : segmentList) { + List pointList = new ArrayList<>(); + GPXUtilities.TrkSegment trkSegment = new GPXUtilities.TrkSegment(); + for (int i = 0; i < segment.getPointsLength(); i++) { + WptPt point = new WptPt(); + point.lat = MapUtils.get31LatitudeY(segment.getPoint31YTile(i)); + point.lon = MapUtils.get31LongitudeX(segment.getPoint31XTile(i)); + pointList.add(point); + } + trkSegment.points = pointList; + track.segments.add(trkSegment); + } + gpxFile = new GPXFile(article.getTitle(), article.getLang(), ""); + gpxFile.tracks = new ArrayList<>(); + gpxFile.tracks.add(track); + } + return gpxFile; + } + @NonNull private List getPointList(@NonNull final TravelArticle article) { final List pointList = new ArrayList<>(); @@ -744,7 +811,12 @@ public class TravelObfHelper implements TravelHelper { @NonNull @Override public File createGpxFile(@NonNull final TravelArticle article) { - final GPXFile gpx = article.getGpxFile(); + final GPXFile gpx; + if (article instanceof TravelGpx) { + gpx = buildTravelGpxFile((TravelGpx) article); + } else { + gpx = article.getGpxFile(); + } File file = app.getAppPath(IndexConstants.GPX_TRAVEL_DIR + getGPXName(article)); writeGpxFile(file, gpx); return file; diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java index 8996e4d375..89fc06ed37 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java @@ -7,6 +7,8 @@ import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; +import androidx.annotation.DrawableRes; +import androidx.annotation.LayoutRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.recyclerview.widget.RecyclerView; @@ -16,16 +18,20 @@ import com.squareup.picasso.Callback; import com.squareup.picasso.Picasso; import com.squareup.picasso.RequestCreator; +import net.osmand.AndroidUtils; import net.osmand.PicassoUtils; +import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; +import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.widgets.tools.CropCircleTransformation; import net.osmand.plus.wikipedia.WikiArticleHelper; import net.osmand.plus.wikivoyage.WikivoyageUtils; import net.osmand.plus.wikivoyage.data.TravelArticle; +import net.osmand.plus.wikivoyage.data.TravelGpx; import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; +import net.osmand.plus.wikivoyage.explore.travelcards.TravelGpxCard; import java.util.ArrayList; import java.util.List; @@ -33,7 +39,8 @@ import java.util.List; public class SavedArticlesRvAdapter extends RecyclerView.Adapter { private static final int HEADER_TYPE = 0; - private static final int ITEM_TYPE = 1; + private static final int ARTICLE_TYPE = 1; + private static final int GPX_TYPE = 2; private final OsmandApplication app; private final OsmandSettings settings; @@ -45,6 +52,7 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter Date: Tue, 26 Jan 2021 21:03:01 +0000 Subject: [PATCH 059/125] Translated using Weblate (German) Currently translated at 99.9% (3648 of 3651 strings) --- OsmAnd/res/values-de/strings.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index 30daf76d2f..620e4a10ea 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -4002,4 +4002,10 @@ Abweichung von der Route Ankunft am Ziel Annährung ans Ziel + Vollständig lesen + Dieses Online-Routingmodul löschen\? + Beschreibung bearbeiten + Wegpunkte löschen + In Favoriten kopieren + In Kartenmarkierungen kopieren \ No newline at end of file From 2bdc4fa262ebe4e5890d36aa490fa12c6379143f Mon Sep 17 00:00:00 2001 From: Ihor Hordiichuk Date: Tue, 26 Jan 2021 19:38:41 +0000 Subject: [PATCH 060/125] Translated using Weblate (Ukrainian) Currently translated at 100.0% (3651 of 3651 strings) --- OsmAnd/res/values-uk/strings.xml | 96 ++++++++++++++++---------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml index 7abdd334db..f180654a56 100644 --- a/OsmAnd/res/values-uk/strings.xml +++ b/OsmAnd/res/values-uk/strings.xml @@ -121,13 +121,13 @@ Якщо ввімкнено редагування в автономному режимі, тоді зміни буде збережено спочатку локально та завантажено за запитом, інакше зміни буде завантажено негайно. Зміни POI всередині застосунку не впливають на завантажені файли мап - вони зберігаються в окремий файл на Вашому пристрої. Вивантаження… - {0} POI/нотатки вивантажено + {0} POI/примітки вивантажено Вивантажити усе Вивантажити правки в OSM Видалити редагування Асинхронне редагування OSM: - OSM-POI/Нотатки, збережено на пристрої - Перегляд і керування OSM-POI/нотатками, збереженими у базі даних на пристрої. + OSM-POI/примітки, збережено на пристрої + Перегляд і керування OSM-POI/примітками, збереженими у базі даних пристрою. Вкажіть інтервал надсилання даних. Інтервал надсилання даних Вкажіть веб-адресу з наступними параметрами: lat={0}, lon={1}, timestamp={2}, hdop={3}, altitude={4}, speed={5}, bearing={6}. @@ -435,7 +435,7 @@ Яндекс Пробки Маршрут Закладки - Нотатки OSM (мережеві) + Примітки OSM (мережеві) POI-накладення… Джерело мапи… Шари мапи @@ -776,7 +776,7 @@ Світлина %1$s %2$s Зробити світлину Зробити світлину - Взаємозберігайте треки та звуко/відео-нотатки з Вашим обліковим записом Dropbox. + Синхронізуйте треки та звуко/відеопримітки з вашим обліковим записом Dropbox. Втулок Dropbox Змінити порядок Будь ласка, зверніть увагу на оплату втулка \"Горизонталі\" для підтримки подальшого розвитку. @@ -795,7 +795,7 @@ недоступно Зупинити Почати - Звуко/відео-нотатки + Звуко/відеопримітки Втулок OsmAnd для показу горизонталей в автономному режимі Використовувати програму Камера Налаштування аудіо/відео запису. @@ -805,8 +805,8 @@ Запис За запитом\? Аудіо/відео зараз записується. Для зупинки натисніть на AV-віджет. - Створити аудіо-нотатку - Створити відео-нотатку + Створити аудіопримітку + Створити відеопримітку Вилучити запис Грати Проміжний пункт призначення @@ -820,9 +820,9 @@ \n \nВсесвітні дані (між 70° на півночі і 70° на півдні) базуються на вимірюваннях SRTM (Shuttle Radar Topography Mission) і ASTER (Advanced Spaceborne Thermal Emission and Reflection Radiometer), даних інструменту відмальовуванню Terra, флагманського супутника системи спостереження Землі від NASA. ASTER — це підсумок спільної роботи NASA, міністерства економіки Японії, міністерства торгівлі і промисловості Японії (METI), агенції космічних систем Японії (J-spacesystems). Вимірювання відстаней - Звуко-нотатки - Зробіть звуко/світлино/відео нотатки під час подорожі, використовуючи або кнопку мапи, або контекстне меню розташування. - Звуко/відео-нотатки + Аудіопримітки + Робіть звуко/світлино/відео примітки під час подорожі використовуючи кнопку мапи або контекстне меню розташування. + Звуко/відеопримітки частин Горизонталі Цей втулок показує як шар горизонталей, так і шар рельєфу поверх усталених мап OsmAnd. Ця функціональність стане в пригоді спортсменам, туристам, мандрівникам та будь-кому, хто цікавиться структурою рельєфу місцевості. (Зверніть увагу, що дані про горизонталі є окремими від даних про рельєф; додаткові завантаження доступні після задіювання втулку.) @@ -843,7 +843,7 @@ Запустити програму в безпечному режимі (використовує повільніші Android-функції замість власних). Безпечний режим Програму запущено в безпечному режимі (вимкніть його в \'Налаштуваннях\'). - Виберіть \"Використати місцеперебування...\" для прив\'язки нотатки до поточного розташування. + Виберіть \"Використати місцеперебування...\" для прив\'язки примітки до поточного розташування. Службу OsmAnd у тлі досі запущено. Зупинити її роботу також\? Закрити набір змін Програма \'ZXing Barcode Scanner\' не встановлена. Шукати в Google Play? @@ -1370,8 +1370,8 @@ Північної широти Відхилити Аудіо - Поділитись нотаткою - A/V нотатки + Поділитись приміткою + A/V примітки Мережева мапа Тільки дороги Вільно %1$s @@ -1624,19 +1624,19 @@ Зберегти локально OSM POI відредаговано OSM POI видалено - Відкрити OSM-нотатку - Відкрити заново OSM-нотатку - До OSM-нотатки додано коментар - Створено OSM-нотатку - OSM-нотатка - Створити нотатку + Відкрити примітку OSM + Повторно відкрити примітку OSM + До примітки OSM додано коментар + Створено примітку OSM + Примітка OSM + Створити примітку Додати коментар - Перевідкрити нотатку - Закрити нотатку - Нотатку створено - Не вдалося створити нотатку. - Нотатку закрито - Не вдалося закрити нотатку. + Перевідкрити примітку + Закрити примітку + Примітку створено + Не вдалося створити примітку. + Примітку закрито + Не вдалося закрити примітку. Підтвердити Вилучити GPX точку? Редагувати GPX точку @@ -1947,8 +1947,8 @@ Передплата дозволяє щогодини отримувати оновлення для мап по всьому світу. \nЧастина від передплати переводиться спільноті OSM та виплачується кожному землеписцю за його внесок. \nЯкщо Вам подобається OsmAnd та OSM, і хочете підтримати і бути підтриманими ними, це ідеальний спосіб зробити це. - Надішліть Вашу OSM-нотатку таємно, або скориставшись обліковим записом на OSM.org. - Надіслати нотатку в OSM + Надішліть примітку OSM знеособлено чи скориставшись профілем OpenStreetMap.org. + Надіслати примітку в OSM Неприпустимі знаки в назві файлу Слідкуйте за нами Звукові напрямки @@ -2162,19 +2162,19 @@ Додати підкладку Змінити джерело мапи Довге натискання з перетягуванням кнопки змінює її розташування на екрані. - Додати нотатку OSM + Додати примітку OSM Дуже тонкий Відкритий код розташування (OLC) - Нова аудіонотатка - Нова відеонотатка - Нова фотонотатка + Нова аудіопримітка + Нова відеопримітка + Нова фотопримітка Найменування Кнопка для додавання позначки мапи посередині екрану. Натискання на цю кнопку додасть маршрутну точку GPX посередині екрану. - Натискання цієї кнопки додає аудіонотатку посередині екрану. - Натискання цієї кнопки додає відеонотатку посередині екрану. - Натискання цієї кнопки додає фотонотатку посередині екрану. - Натискання цієї кнопки додає OSM-нотатку посередині екрану. + Натискання цієї кнопки додає аудіопримітку посередині екрана. + Натискання цієї кнопки додає відеопримітку посередині екрана. + Натискання цієї кнопки додає фотопримітку посередині екрана. + Натискання цієї кнопки додає примітку OSM посередині екрану. Натискання цієї кнопки додає POI посередині екрану. Перемикач, щоб вимкнути або увімкнути голосові підказки під час навігації. Кнопка для додавання місця паркування посередині екрана. @@ -2212,10 +2212,10 @@ Нічого не знайдено Місце призначення розташовано в області з приватним доступом. Дозволити доступ до приватних доріг у цій подорожі\? Змініть пошуковий запит або ж розширте пошуковий радіус. - Показати/приховати OSM-нотатки - Показати OSM-нотатки - Приховати OSM-нотатки - Натискання на кнопку дії покаже чи приховає OSM-нотатки на мапі. + Показати/приховати примітки OSM + Показати примітки OSM + Приховати примітки OSM + Натискання на кнопку дії покаже чи приховає примітки OSM на мапі. Відсортоване за відстанню Пошук у закладках Завантажте шар мапи «Пагорби», щоб показати вертикальне затінення. @@ -2526,9 +2526,9 @@ Уникає льодових доріг і бродів. Додати копію початкової точки як місце призначення. Зробити кругову подорож - Не вдалося змінити нотатку. - Змінити нотатку - Змінити OSM-нотатку + Не вдалося змінити примітку. + Змінити примітку + Змінити примітку OSM Неправильний ввід Неправильний формат Дорога @@ -2576,15 +2576,15 @@ Пошук треків з шляховими точками Більше Створити або змінити OSM-об\'єкти - Створюйте або змінюйте цікаві точки в OSM, відкривайте або коментуйте OSM-нотатки, а також надсилайте записані GPX-файли. + Створюйте або змінюйте OSM POI, відкривайте або коментуйте примітки OSM та надсилайте записані GPX-файли. Вилучено Відредаговано Додано Позначку %s задіяно. Натискання на позначку на мапі перемістить її на перше місце в списку задіяних позначок, не відкриваючи контекстне меню. Задіювання одним натисненням - Робіть нотатки! - Додайте аудіо, відео або фотонотатку в будь-яку точку на мапі, використовуючи віджет або контекстне меню. + Робіть примітки! + Додайте аудіо, відео або фотопримітку в будь-яку точку на мапі використовуючи віджет або контекстне меню. Примітки за датою За датою За типом @@ -2620,14 +2620,14 @@ Додає проміжну зупинку Додає першу зупинку Пересунути призначення далі і створити його - Показати закриті нотатки + Показати закриті примітки Показати чи приховати примітки OSM на мапі. GPX — підходить для експорту в JOSM та інші OSM-редактори. OSC — підходить для експорту в OSM. GPX-файл OSC-файл Виберіть тип файлу - Виберіть вид експорту: OSM-нотатки, POI чи і те і те. + Виберіть вид експорту: примітки OSM, POI чи і те і те. Усі дані Примітки OSM Відкриється завтра о From 96fc15a45328ed8bde2a9a30e9862318cc3e1736 Mon Sep 17 00:00:00 2001 From: Manuel Tassi Date: Tue, 26 Jan 2021 21:46:32 +0000 Subject: [PATCH 061/125] Translated using Weblate (Italian) Currently translated at 87.4% (3192 of 3651 strings) --- OsmAnd/res/values-it/strings.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/OsmAnd/res/values-it/strings.xml b/OsmAnd/res/values-it/strings.xml index bbe3202bf0..7a3d6ee245 100644 --- a/OsmAnd/res/values-it/strings.xml +++ b/OsmAnd/res/values-it/strings.xml @@ -543,7 +543,7 @@ Circolazione a sinistra Per i paesi in cui si guida nella parte sinistra della strada. Posizione di partenza non ancora determinata. - Annulla il download del file\? + Annulla il download\? La mappa di base necessaria per il funzionamento è in coda per il download. Abilita il plugin \'Mappe Online\' per scegliere altre sorgenti di mappe Mappe online e a tasselli @@ -929,7 +929,7 @@ Seleziona Preferito Modifiche OSM Non connesso al Wi-Fi. Usare la connessione a Internet attuale per il download\? - Cancellare il percorso\? + Ignora il percorso\? Interrompere la navigazione Cancella la destinazione Altra @@ -1399,7 +1399,7 @@ Ok Annulla - Annulla + Ignora No Acceso @@ -1989,7 +1989,7 @@ Ottieni indicazioni e scopri nuovi luoghi senza una connessione a Internet Scegli un\'altra regione Non hai mappe offline installate. Si può scegliere una mappa dalla lista o scaricarle in seguito andando su \'Menù - %1$s\'. - Il costo della sottoscrizione verrà addebitato ogni mese. Puoi scegliere di annullare la sottoscrizione su Google Play in ogni momento. + La sottoscrizione viene addebitata ogni mese. Puoi annullarla su Google Play in ogni momento. Donazione per la comunità di OpenStreetMap Parte della tua donazione verrà inviata agli utenti che fanno modifiche su OpenStreetMap. Il costo della sottoscrizione rimane inalterato. La sottoscrizione attiva aggiornamenti orari, quotidiani e settimanali e la possibilità di scaricare senza limiti tutte le mappe del mondo. @@ -3134,7 +3134,7 @@ Il formato selezionato sarà applicato per tutta l\'app. Questa impostazione è selezionata di default per i profili: %s Cambia impostazioni - Annulla cambiamenti + Annulla modifiche Applica solo a \"%1$s\" Applica a tutti i profili Messaggio di avvio @@ -3704,7 +3704,7 @@ Abilita per controllare il livello di zoom della mappa con i pulsanti del volume del dispositivo. Pulsanti volume come zoom Per favore indica un nome per il punto - Il punto di destinazione corrente sul percorso verrà eliminato. Se sarà la Destinazione, la navigazione verrà interrotta. + Elimina la destinazione successiva nel percorso. Se questa è la destinazione finale, la navigazione si fermerà. Scarica mappe Wikipedia Ottieni informazioni sui punti di interesse da Wikipedia. È la tua guida tascabile offline - basta abilitare il plugin Wikipedia e goderti gli articoli sugli oggetti intorno a te. Moto da enduro From 41adb3fd47963b1049c0d3b9e2288ca3e593e931 Mon Sep 17 00:00:00 2001 From: Ihor Hordiichuk Date: Tue, 26 Jan 2021 19:27:13 +0000 Subject: [PATCH 062/125] Translated using Weblate (Ukrainian) Currently translated at 100.0% (3881 of 3881 strings) --- OsmAnd/res/values-uk/phrases.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-uk/phrases.xml b/OsmAnd/res/values-uk/phrases.xml index 759b53b5f9..9464312798 100644 --- a/OsmAnd/res/values-uk/phrases.xml +++ b/OsmAnd/res/values-uk/phrases.xml @@ -2790,7 +2790,7 @@ Вирощується культура: рис Вид вибуху: неглибокого закладення Послуги надаються дорослим: так - Різдво: нотатка + Різдво: примітка Крильця Ямайська Місця на відкритому повітрі: пішохідна зона @@ -3019,7 +3019,7 @@ Вино: так Напої і закуски Болото, періодично затоплюване морською водою - Нотатка + Примітка Вирощується культура: квіти Водонагрівач: відсутній Орієнтація майданчика для вільного польоту: схід (E) From 069f526a571156d5be281c003800371b1ab306c1 Mon Sep 17 00:00:00 2001 From: Skalii Date: Wed, 27 Jan 2021 01:31:44 +0200 Subject: [PATCH 063/125] fix re-adding top padding --- .../src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java b/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java index 45eb6a703b..64cae466c4 100644 --- a/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java +++ b/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java @@ -26,8 +26,8 @@ public class OsmandTextFieldBoxes extends TextFieldBoxes { floatingLabel.setVisibility(View.GONE); labelSpace.setVisibility(View.GONE); labelSpaceBelow.setVisibility(View.GONE); - int paddingH = getResources().getDimensionPixelSize(R.dimen.route_info_card_details_margin); - inputLayout.setPadding(0, paddingH, 0, paddingH); + int paddingV = getResources().getDimensionPixelSize(R.dimen.route_info_card_details_margin); + inputLayout.setPadding(0, paddingV, 0, paddingV); } public void setGravityFloatingLabel(int gravity) { @@ -43,7 +43,8 @@ public class OsmandTextFieldBoxes extends TextFieldBoxes { if (floatingLabel.getLineCount() > 1) { inputLayout.setPadding( inputLayout.getPaddingLeft(), - inputLayout.getPaddingTop() + getResources().getDimensionPixelSize(R.dimen.pages_item_padding), + getResources().getDimensionPixelOffset(useDenseSpacing ? R.dimen.dense_editTextLayout_padding_top : R.dimen.editTextLayout_padding_top) + + getResources().getDimensionPixelSize(useDenseSpacing ? R.dimen.context_menu_first_line_top_margin : R.dimen.content_padding_small), inputLayout.getPaddingRight(), inputLayout.getPaddingBottom() ); From 84c879e02db9b123d1a4e7fd8ecff892d9cfd989 Mon Sep 17 00:00:00 2001 From: Skalii Date: Wed, 27 Jan 2021 04:11:06 +0200 Subject: [PATCH 064/125] fix visible dividers between statistic info; rollback gradle.properties --- OsmAnd/res/layout/item_gpx_stat_block.xml | 76 ++++++++++++------- .../net/osmand/plus/track/OverviewCard.java | 23 ++++-- gradle.properties | 18 +++-- 3 files changed, 76 insertions(+), 41 deletions(-) diff --git a/OsmAnd/res/layout/item_gpx_stat_block.xml b/OsmAnd/res/layout/item_gpx_stat_block.xml index 6b94dd4047..18dfa5cdde 100644 --- a/OsmAnd/res/layout/item_gpx_stat_block.xml +++ b/OsmAnd/res/layout/item_gpx_stat_block.xml @@ -3,42 +3,62 @@ xmlns:osmand="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical"> + android:layout_height="@dimen/list_header_height" + android:layout_marginStart="@dimen/content_padding" + android:layout_marginLeft="@dimen/content_padding" + android:gravity="center_vertical" + android:orientation="horizontal"> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginEnd="@dimen/content_padding" + android:layout_marginRight="@dimen/content_padding" + android:orientation="vertical"> - + + + + + + + + - - + tools:text="@string/distance" /> - + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/track/OverviewCard.java b/OsmAnd/src/net/osmand/plus/track/OverviewCard.java index dcebdc31da..f91b45419b 100644 --- a/OsmAnd/src/net/osmand/plus/track/OverviewCard.java +++ b/OsmAnd/src/net/osmand/plus/track/OverviewCard.java @@ -2,9 +2,9 @@ package net.osmand.plus.track; import android.annotation.SuppressLint; import android.content.Context; -import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Rect; +import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -18,10 +18,12 @@ import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.AppCompatImageView; +import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView.ItemDecoration; +import net.osmand.AndroidUtils; import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.GPXTrackAnalysis; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; @@ -30,6 +32,7 @@ import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType; import net.osmand.plus.myplaces.SegmentActionsListener; import net.osmand.plus.routepreparationmenu.cards.BaseCard; @@ -125,8 +128,10 @@ public class OverviewCard extends BaseCard { final StatBlockAdapter sbAdapter = new StatBlockAdapter(items); rvOverview.setLayoutManager(new LinearLayoutManager(app, LinearLayoutManager.HORIZONTAL, false)); - rvOverview.addItemDecoration(new HorizontalDividerDecoration(app)); +// rvOverview.addItemDecoration(new HorizontalDividerDecoration(app, nightMode)); rvOverview.setAdapter(sbAdapter); + } else { + AndroidUiHelper.updateVisibility(rvOverview, false); } } @@ -265,6 +270,10 @@ public class OverviewCard extends BaseCard { } }); setImageDrawable(holder.imageView, item.imageResId, item.imageColorId); + AndroidUtils.setBackgroundColor(view.getContext(), holder.divider, nightMode, R.color.divider_color_light, R.color.divider_color_dark); + if (position == statBlocks.size() - 1) { + AndroidUiHelper.setVisibility(View.GONE, holder.divider); + } } } @@ -273,12 +282,14 @@ public class OverviewCard extends BaseCard { private final TextViewEx valueText; private final TextView titleText; private final AppCompatImageView imageView; + private final View divider; StatBlockViewHolder(View view) { super(view); valueText = view.findViewById(R.id.value); titleText = view.findViewById(R.id.title); imageView = view.findViewById(R.id.image); + divider = view.findViewById(R.id.divider); } } @@ -288,12 +299,8 @@ public class OverviewCard extends BaseCard { private final int marginV; private final int marginH; - public HorizontalDividerDecoration(Context context) { - int[] ATTRS = {android.R.attr.listDivider}; - final TypedArray ta = context.obtainStyledAttributes(ATTRS); - divider = ta.getDrawable(0); -// DrawableCompat.setTint(divider, context.getResources().getColor(R.color.divider_color_light)); //todo change drawable color - ta.recycle(); + public HorizontalDividerDecoration(Context context, boolean nightMode) { + divider = new ColorDrawable(ContextCompat.getColor(context, nightMode ? R.color.divider_color_dark : R.color.divider_color_light)); marginV = context.getResources().getDimensionPixelSize(R.dimen.map_small_button_margin); marginH = context.getResources().getDimensionPixelSize(R.dimen.content_padding); } diff --git a/gradle.properties b/gradle.properties index f565c6e638..dffb2e0a79 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,16 +1,24 @@ -## For more details on how to configure your build environment visit +## Project-wide Gradle settings. +# +# For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html # # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -# Default value: -Xmx1024m -XX:MaxPermSize=256m +# Default value: -Xmx10248m -XX:MaxPermSize=256m # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 # # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -#Mon Dec 28 12:25:02 EET 2020 +#Fri Apr 08 18:47:31 EEST 2016 +# android.useDeprecatedNdk=true + +# for enableD8=true min sdk must be > 22 +# UPDATE: temporairly commented since gradle plugin updated to 3.1.3 and claims INSTALL_FAILED_DEXOPT is fixed +# UPDATE 2: D8 causes problems on arm64 devices with Android 6.0 (API 23) +# UPDATE 3: Turn on D8 to recover builds with new gradle 6.5 and pluigin 4.1.1 +#android.enableD8=false android.enableJetifier=true -android.useAndroidX=true -org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M" +android.useAndroidX=true \ No newline at end of file From 3afd8fc3bd7d62fc17e76e138cee61918429c4d6 Mon Sep 17 00:00:00 2001 From: cepprice Date: Wed, 27 Jan 2021 10:43:34 +0500 Subject: [PATCH 065/125] Fix #10658 --- OsmAnd/res/values/strings.xml | 1 + OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 79d3a211b4..439678fcac 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -12,6 +12,7 @@ --> + Select edits for upload Copy to favorites Copy to map markers Delete waypoints diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java index e61520188d..56c49c4219 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java @@ -295,8 +295,13 @@ public class OsmEditsFragment extends OsmAndListFragment implements ProgressDial item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { - uploadItems(osmEditsSelected.toArray(new OsmPoint[0])); - mode.finish(); + if (Algorithms.isEmpty(osmEditsSelected)) { + Toast.makeText(requireContext(), + R.string.toast_select_edits_for_upload, Toast.LENGTH_LONG).show(); + } else { + uploadItems(osmEditsSelected.toArray(new OsmPoint[0])); + mode.finish(); + } return true; } }); From ea1c439cd12a1a5f23a9493a5bbfaf0b0f884b4e Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Wed, 27 Jan 2021 10:20:55 +0200 Subject: [PATCH 066/125] Open mapActivity --- .../plus/wikivoyage/data/TravelObfHelper.java | 3 +++ .../explore/ExploreTabFragment.java | 2 +- .../explore/travelcards/TravelGpxCard.java | 21 ++++++++++++------- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index 13c4fffa49..a44b131a66 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -177,6 +177,8 @@ public class TravelObfHelper implements TravelHelper { res.file = file; String title = amenity.getName("en"); res.title = capitalizeFirstLetter(getGpxTitle(Algorithms.isEmpty(title) ? amenity.getName() : title)); + res.lat = amenity.getLocation().getLatitude(); + res.lon = amenity.getLocation().getLongitude(); res.routeId = Algorithms.emptyIfNull(amenity.getTagContent(Amenity.ROUTE_ID)); try { res.totalDistance = Float.parseFloat(Algorithms.emptyIfNull(amenity.getTagContent(DISTANCE))); @@ -319,6 +321,7 @@ public class TravelObfHelper implements TravelHelper { gpxFile.tracks = new ArrayList<>(); gpxFile.tracks.add(track); } + article.gpxFile = gpxFile; return gpxFile; } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java index ce6f4475af..9055acd4ed 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java @@ -181,7 +181,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv List popularArticles = app.getTravelHelper().getPopularArticles(); for (TravelArticle article : popularArticles) { if (article instanceof TravelGpx) { - items.add(new TravelGpxCard(app, nightMode, (TravelGpx) article, activity.getSupportFragmentManager())); + items.add(new TravelGpxCard(app, nightMode, (TravelGpx) article, getActivity())); } else { items.add(new ArticleTravelCard(app, nightMode, article, activity.getSupportFragmentManager())); } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java index ded096a260..3cfbc91c04 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java @@ -5,13 +5,15 @@ import android.view.View; import android.widget.TextView; import androidx.annotation.NonNull; -import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentActivity; import androidx.recyclerview.widget.RecyclerView; import net.osmand.AndroidUtils; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.wikipedia.WikiArticleHelper; import net.osmand.plus.wikivoyage.data.TravelGpx; import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; @@ -22,15 +24,15 @@ public class TravelGpxCard extends BaseTravelCard { private final TravelGpx article; private final Drawable readIcon; - private final FragmentManager fragmentManager; + private final FragmentActivity activity; private boolean isLastItem; public TravelGpxCard(@NonNull OsmandApplication app, boolean nightMode, @NonNull TravelGpx article, - @NonNull FragmentManager fragmentManager) { + @NonNull FragmentActivity activity) { super(app, nightMode); this.article = article; readIcon = getActiveIcon(R.drawable.ic_action_read_article); - this.fragmentManager = fragmentManager; + this.activity = activity; } @Override @@ -49,10 +51,15 @@ public class TravelGpxCard extends BaseTravelCard { View.OnClickListener readClickListener = new View.OnClickListener() { @Override public void onClick(View v) { - if (fragmentManager != null) { -// WikivoyageArticleDialogFragment.showInstance(app, fragmentManager, -// article.generateIdentifier(), article.getLang()); + if (activity != null) { app.getTravelHelper().createGpxFile(article); + final OsmandSettings settings = app.getSettings(); + settings.setMapLocationToShow(article.getLat(), article.getLon(), + settings.getLastKnownMapZoom(), + null, + false, + article.getGpxFile()); + MapActivity.launchMapActivityMoveToTop(activity); } } }; From 943eaa6b7d5ccf69b27de8ebcc5422d9ae8591f4 Mon Sep 17 00:00:00 2001 From: cepprice Date: Wed, 27 Jan 2021 14:05:53 +0500 Subject: [PATCH 067/125] Small edit to prevent Exception --- OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java index 56c49c4219..cacc1ed125 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java @@ -296,8 +296,7 @@ public class OsmEditsFragment extends OsmAndListFragment implements ProgressDial @Override public boolean onMenuItemClick(MenuItem item) { if (Algorithms.isEmpty(osmEditsSelected)) { - Toast.makeText(requireContext(), - R.string.toast_select_edits_for_upload, Toast.LENGTH_LONG).show(); + app.showToastMessage(R.string.toast_select_edits_for_upload); } else { uploadItems(osmEditsSelected.toArray(new OsmPoint[0])); mode.finish(); From 048f6035cbf1a00ed8140c68f05f2250b883d547 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Wed, 27 Jan 2021 12:02:57 +0200 Subject: [PATCH 068/125] open TrackMenuFragment --- .../explore/SavedArticlesRvAdapter.java | 9 +++++++-- .../explore/SavedArticlesTabFragment.java | 20 +++++++++++++++---- .../explore/travelcards/TravelGpxCard.java | 15 +++++--------- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java index 89fc06ed37..bbc0cb6da7 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java @@ -11,6 +11,7 @@ import androidx.annotation.DrawableRes; import androidx.annotation.LayoutRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.fragment.app.FragmentActivity; import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.snackbar.Snackbar; @@ -25,6 +26,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.widgets.tools.CropCircleTransformation; import net.osmand.plus.wikipedia.WikiArticleHelper; import net.osmand.plus.wikivoyage.WikivoyageUtils; @@ -33,6 +35,7 @@ import net.osmand.plus.wikivoyage.data.TravelGpx; import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; import net.osmand.plus.wikivoyage.explore.travelcards.TravelGpxCard; +import java.io.File; import java.util.ArrayList; import java.util.List; @@ -58,7 +61,7 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter Date: Wed, 27 Jan 2021 12:28:17 +0200 Subject: [PATCH 069/125] Buttons height Buttons, add a parameter for our button default/large (user needed proper name). Those parameters should control buttons height, default 36dp, large 48 dp. Make bottom buttons 48 --- .../base/MenuBottomSheetDialogFragment.java | 18 ++++++++++++++++++ .../monitoring/TripRecordingBottomSheet.java | 10 ++++++++++ 2 files changed, 28 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java index 2af2d9673b..0afa81a300 100644 --- a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java @@ -268,6 +268,18 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra dismissButtonStringRes = stringRes; } + protected int getDismissButtonHeight(){ + return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height_small); + } + + protected int getRightButtonHeight(){ + return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height_small); + } + + protected int getThirdButtonHeight(){ + return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height_small); + } + protected DialogButtonType getDismissButtonType() { return DialogButtonType.SECONDARY; } @@ -360,6 +372,8 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra private void setupDismissButton() { dismissButton = buttonsContainer.findViewById(R.id.dismiss_button); + android.widget.LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getDismissButtonHeight()); + dismissButton.setLayoutParams(lp); int buttonTextId = getDismissButtonTextId(); if (buttonTextId != DEFAULT_VALUE) { UiUtilities.setupDialogButton(nightMode, dismissButton, getDismissButtonType(), buttonTextId); @@ -376,6 +390,8 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra private void setupRightButton() { rightButton = buttonsContainer.findViewById(R.id.right_bottom_button); + android.widget.LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getRightButtonHeight()); + rightButton.setLayoutParams(lp); int buttonTextId = getRightBottomButtonTextId(); if (buttonTextId != DEFAULT_VALUE) { UiUtilities.setupDialogButton(nightMode, rightButton, getRightBottomButtonType(), buttonTextId); @@ -398,6 +414,8 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra protected void setupThirdButton() { thirdButton = buttonsContainer.findViewById(R.id.third_button); + android.widget.LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getThirdButtonHeight()); + thirdButton.setLayoutParams(lp); int buttonTextId = getThirdBottomButtonTextId(); if (buttonTextId != DEFAULT_VALUE) { UiUtilities.setupDialogButton(nightMode, thirdButton, getThirdBottomButtonType(), buttonTextId); diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java index 096430f3da..1cb23e7ba9 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java @@ -252,6 +252,16 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment { return true; } + @Override + protected int getRightButtonHeight(){ + return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height); + } + + @Override + protected int getDismissButtonHeight(){ + return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height); + } + @Override protected int getRightBottomButtonTextId() { return R.string.start_recording; From 27dd3423754914ca884140b41fbd4cd3e9960645 Mon Sep 17 00:00:00 2001 From: cepprice Date: Wed, 27 Jan 2021 15:48:10 +0500 Subject: [PATCH 070/125] Small edit and fix --- OsmAnd/src/net/osmand/plus/track/DescriptionCard.java | 5 ++++- .../plus/track/GpxEditDescriptionDialogFragment.java | 7 +------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/track/DescriptionCard.java b/OsmAnd/src/net/osmand/plus/track/DescriptionCard.java index 1280a183ef..8195c8d417 100644 --- a/OsmAnd/src/net/osmand/plus/track/DescriptionCard.java +++ b/OsmAnd/src/net/osmand/plus/track/DescriptionCard.java @@ -50,7 +50,7 @@ public class DescriptionCard extends BaseCard { setupImage(imageUrl); - if (descriptionHtml == null || Algorithms.isEmpty(descriptionHtml.trim())) { + if (Algorithms.isBlank(descriptionHtml)) { showAddBtn(); } else { showDescription(title, imageUrl, descriptionHtml); @@ -73,7 +73,10 @@ public class DescriptionCard extends BaseCard { private void showDescription(final String title, final String imageUrl, final String descriptionHtml) { LinearLayout descriptionContainer = view.findViewById(R.id.description_container); + FrameLayout addBtn = view.findViewById(R.id.btn_add); + AndroidUiHelper.updateVisibility(descriptionContainer, true); + AndroidUiHelper.updateVisibility(addBtn, false); TextViewEx tvDescription = view.findViewById(R.id.description); tvDescription.setText(getFirstParagraph(descriptionHtml)); diff --git a/OsmAnd/src/net/osmand/plus/track/GpxEditDescriptionDialogFragment.java b/OsmAnd/src/net/osmand/plus/track/GpxEditDescriptionDialogFragment.java index d17cd91667..a79a392f8e 100644 --- a/OsmAnd/src/net/osmand/plus/track/GpxEditDescriptionDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/GpxEditDescriptionDialogFragment.java @@ -84,17 +84,12 @@ public class GpxEditDescriptionDialogFragment extends BaseOsmAndDialogFragment { return view; } - - private boolean shouldClose() { Editable editable = editableHtml.getText(); if (htmlCode == null || editable == null || editable.toString() == null) { return true; } - if (htmlCode.equals(editable.toString())) { - return true; - } - return false; + return htmlCode.equals(editable.toString()); } private void showDismissDialog() { From 14d00037b2e8481a2e7a26746208bd29d46ee537 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Wed, 27 Jan 2021 13:37:32 +0200 Subject: [PATCH 071/125] Pull request review --- .../base/MenuBottomSheetDialogFragment.java | 9 +++------ .../monitoring/TripRecordingBottomSheet.java | 19 ++++++------------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java index 0afa81a300..9f97a07563 100644 --- a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java @@ -372,8 +372,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra private void setupDismissButton() { dismissButton = buttonsContainer.findViewById(R.id.dismiss_button); - android.widget.LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getDismissButtonHeight()); - dismissButton.setLayoutParams(lp); + dismissButton.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getDismissButtonHeight())); int buttonTextId = getDismissButtonTextId(); if (buttonTextId != DEFAULT_VALUE) { UiUtilities.setupDialogButton(nightMode, dismissButton, getDismissButtonType(), buttonTextId); @@ -390,8 +389,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra private void setupRightButton() { rightButton = buttonsContainer.findViewById(R.id.right_bottom_button); - android.widget.LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getRightButtonHeight()); - rightButton.setLayoutParams(lp); + rightButton.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getRightButtonHeight())); int buttonTextId = getRightBottomButtonTextId(); if (buttonTextId != DEFAULT_VALUE) { UiUtilities.setupDialogButton(nightMode, rightButton, getRightBottomButtonType(), buttonTextId); @@ -414,8 +412,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra protected void setupThirdButton() { thirdButton = buttonsContainer.findViewById(R.id.third_button); - android.widget.LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getThirdButtonHeight()); - thirdButton.setLayoutParams(lp); + thirdButton.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getThirdButtonHeight())); int buttonTextId = getThirdBottomButtonTextId(); if (buttonTextId != DEFAULT_VALUE) { UiUtilities.setupDialogButton(nightMode, thirdButton, getThirdBottomButtonType(), buttonTextId); diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java index 1cb23e7ba9..533d9f151d 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java @@ -54,7 +54,6 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment { private SwitchCompat confirmEveryRun; private TextView intervalValueView; private LinearLayout container; - private LinearLayout expandHideIntervalContainer; private View divider; private boolean infoExpanded; @@ -97,7 +96,7 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment { }); divider = itemView.findViewById(R.id.second_divider); - expandHideIntervalContainer = itemView.findViewById(R.id.interval_view_container); + LinearLayout expandHideIntervalContainer = itemView.findViewById(R.id.interval_view_container); upDownBtn = itemView.findViewById(R.id.up_down_button); expandHideIntervalContainer.setOnClickListener(new View.OnClickListener() { @@ -167,13 +166,9 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment { basicItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (showTrackOnMapButton.isChecked()) { - showTrackOnMapButton.setChecked(false); - app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), false, false); - } else { - showTrackOnMapButton.setChecked(true); - app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), true, false); - } + boolean checked = !showTrackOnMapButton.isChecked(); + showTrackOnMapButton.setChecked(checked); + app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), checked, false); } }); UiUtilities.setupCompoundButton(showTrackOnMapButton, nightMode, PROFILE_DEPENDENT); @@ -234,15 +229,13 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment { private void toggleInfoView() { infoExpanded = !infoExpanded; ViewGroup.MarginLayoutParams marginParams = (ViewGroup.MarginLayoutParams) divider.getLayoutParams(); - if (getMapActivity() != null) { - final int dp8 = AndroidUtils.dpToPx(getMapActivity(), 8f); - final int dp16 = AndroidUtils.dpToPx(getMapActivity(), 16f); + final int dp8 = AndroidUtils.dpToPx(app, 8f); + final int dp16 = AndroidUtils.dpToPx(app, 16f); if (infoExpanded) { AndroidUtils.setMargins(marginParams, 0, dp16, 0, dp8); } else { AndroidUtils.setMargins(marginParams, 0, 0, 0, dp8); } - } AndroidUiHelper.updateVisibility(container, infoExpanded); updateUpDownBtn(); } From 2baf45e76f322e19d4724bf39c406ca21435e7c6 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Wed, 27 Jan 2021 13:46:33 +0200 Subject: [PATCH 072/125] Code styling fix --- ...h_switch_divider_and_additional_button.xml | 139 +++++++++--------- .../monitoring/TripRecordingBottomSheet.java | 14 +- 2 files changed, 76 insertions(+), 77 deletions(-) diff --git a/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml b/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml index 8f95b5777b..6953783885 100644 --- a/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml +++ b/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml @@ -1,84 +1,83 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:baselineAligned="false" + android:gravity="center_vertical" + android:minHeight="@dimen/bottom_sheet_selected_item_title_height"> - + - + - + - + - + - + - + - + - + - + diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java index 533d9f151d..789fc0aeb0 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java @@ -229,13 +229,13 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment { private void toggleInfoView() { infoExpanded = !infoExpanded; ViewGroup.MarginLayoutParams marginParams = (ViewGroup.MarginLayoutParams) divider.getLayoutParams(); - final int dp8 = AndroidUtils.dpToPx(app, 8f); - final int dp16 = AndroidUtils.dpToPx(app, 16f); - if (infoExpanded) { - AndroidUtils.setMargins(marginParams, 0, dp16, 0, dp8); - } else { - AndroidUtils.setMargins(marginParams, 0, 0, 0, dp8); - } + final int dp8 = AndroidUtils.dpToPx(app, 8f); + final int dp16 = AndroidUtils.dpToPx(app, 16f); + if (infoExpanded) { + AndroidUtils.setMargins(marginParams, 0, dp16, 0, dp8); + } else { + AndroidUtils.setMargins(marginParams, 0, 0, 0, dp8); + } AndroidUiHelper.updateVisibility(container, infoExpanded); updateUpDownBtn(); } From cae54bf0efc4f909d0d1c1d0031cd88b882bbea3 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Wed, 27 Jan 2021 13:48:45 +0200 Subject: [PATCH 073/125] Code style 2 --- OsmAnd/res/layout/trip_recording_fragment.xml | 200 +++++++++--------- 1 file changed, 100 insertions(+), 100 deletions(-) diff --git a/OsmAnd/res/layout/trip_recording_fragment.xml b/OsmAnd/res/layout/trip_recording_fragment.xml index d35626a7ce..f69e4eb4c7 100644 --- a/OsmAnd/res/layout/trip_recording_fragment.xml +++ b/OsmAnd/res/layout/trip_recording_fragment.xml @@ -1,115 +1,115 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:osmand="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> - + - + - + - + - + - - + + - + - + - - + + - + From 10ae234c30d32d0a13f505b056a9a98d0908b7ad Mon Sep 17 00:00:00 2001 From: Skalii Date: Wed, 27 Jan 2021 14:04:43 +0200 Subject: [PATCH 074/125] minor fixes --- .../net/osmand/plus/track/OverviewCard.java | 98 +++++-------------- 1 file changed, 22 insertions(+), 76 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/track/OverviewCard.java b/OsmAnd/src/net/osmand/plus/track/OverviewCard.java index f91b45419b..d140e5478e 100644 --- a/OsmAnd/src/net/osmand/plus/track/OverviewCard.java +++ b/OsmAnd/src/net/osmand/plus/track/OverviewCard.java @@ -1,10 +1,6 @@ package net.osmand.plus.track; import android.annotation.SuppressLint; -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Rect; -import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -16,16 +12,14 @@ import android.widget.TextView; import androidx.annotation.ColorRes; import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.appcompat.widget.AppCompatImageView; -import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import androidx.recyclerview.widget.RecyclerView.ItemDecoration; import net.osmand.AndroidUtils; import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.GPXTrackAnalysis; +import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType; import net.osmand.plus.OsmAndFormatter; @@ -71,7 +65,10 @@ public class OverviewCard extends BaseCard { this.listener = listener; gpxFile = displayHelper.getGpx(); gpxFileSelected = isGpxFileSelected(app, gpxFile); - gpxItem = TrackDisplayHelper.flatten(displayHelper.getOriginalGroups(filterTypes)).get(0); + List groups = displayHelper.getOriginalGroups(filterTypes); + if (!Algorithms.isEmpty(groups)) { + gpxItem = TrackDisplayHelper.flatten(displayHelper.getOriginalGroups(filterTypes)).get(0); + } } @Override @@ -101,8 +98,8 @@ public class OverviewCard extends BaseCard { } void initStatBlocks() { - GPXTrackAnalysis analysis = gpxItem.analysis; - if (analysis != null) { + if (gpxItem != null) { + GPXTrackAnalysis analysis = gpxItem.analysis; boolean joinSegments = displayHelper.isJoinSegments(); float totalDistance = !joinSegments && gpxItem.isGeneralTrack() ? analysis.totalDistanceWithoutGaps : analysis.totalDistance; float timeSpan = !joinSegments && gpxItem.isGeneralTrack() ? analysis.timeSpanWithoutGaps : analysis.timeSpan; @@ -128,47 +125,39 @@ public class OverviewCard extends BaseCard { final StatBlockAdapter sbAdapter = new StatBlockAdapter(items); rvOverview.setLayoutManager(new LinearLayoutManager(app, LinearLayoutManager.HORIZONTAL, false)); -// rvOverview.addItemDecoration(new HorizontalDividerDecoration(app, nightMode)); rvOverview.setAdapter(sbAdapter); - } else { - AndroidUiHelper.updateVisibility(rvOverview, false); } } + @DrawableRes + private int getActiveShowHideIcon() { + gpxFileSelected = isGpxFileSelected(app, gpxFile); + return gpxFileSelected ? R.drawable.ic_action_view : R.drawable.ic_action_hide; + } + private void initShowButton(final int iconColorDef, final int iconColorPres) { - initButton(showButton, SHOW_ON_MAP_BUTTON_INDEX, null, iconColorDef, iconColorPres, new StatBlockCallback() { - @Override - public void run(AppCompatImageView image) { - gpxFileSelected = isGpxFileSelected(app, gpxFile); - setImageDrawable(image, gpxFileSelected ? R.drawable.ic_action_view : R.drawable.ic_action_hide, iconColorDef); - image.requestLayout(); - } - }); + initButton(showButton, SHOW_ON_MAP_BUTTON_INDEX, getActiveShowHideIcon(), iconColorDef, iconColorPres); } private void initAppearanceButton(@ColorRes int iconColorDef, @ColorRes int iconColorPres) { - initButton(appearanceButton, APPEARANCE_BUTTON_INDEX, R.drawable.ic_action_appearance, iconColorDef, iconColorPres, null); + initButton(appearanceButton, APPEARANCE_BUTTON_INDEX, R.drawable.ic_action_appearance, iconColorDef, iconColorPres); } private void initEditButton(@ColorRes int iconColorDef, @ColorRes int iconColorPres) { - initButton(editButton, EDIT_BUTTON_INDEX, R.drawable.ic_action_edit_dark, iconColorDef, iconColorPres, null); + initButton(editButton, EDIT_BUTTON_INDEX, R.drawable.ic_action_edit_dark, iconColorDef, iconColorPres); } private void initDirectionsButton(@ColorRes int iconColorDef, @ColorRes int iconColorPres) { - initButton(directionsButton, DIRECTIONS_BUTTON_INDEX, R.drawable.ic_action_gdirections_dark, iconColorDef, iconColorPres, null); + initButton(directionsButton, DIRECTIONS_BUTTON_INDEX, R.drawable.ic_action_gdirections_dark, iconColorDef, iconColorPres); } private void initButton(View item, final int buttonIndex, @DrawableRes Integer iconResId, - @ColorRes int iconColorDef, @ColorRes int iconColorPres, @Nullable final StatBlockCallback callback) { + @ColorRes final int iconColorDef, @ColorRes int iconColorPres) { final AppCompatImageView icon = item.findViewById(R.id.image); final AppCompatImageView filled = item.findViewById(R.id.filled); filled.setImageResource(nightMode ? R.drawable.bg_plugin_logo_enabled_dark : R.drawable.bg_topbar_shield_exit_ref); filled.setAlpha(0.1f); - if (callback != null) { - callback.run(icon); - } else { - setImageDrawable(icon, iconResId, iconColorDef); - } + setImageDrawable(icon, iconResId, iconColorDef); setOnTouchItem(item, icon, filled, iconResId, iconColorDef, iconColorPres); item.setOnClickListener(new View.OnClickListener() { @Override @@ -176,8 +165,8 @@ public class OverviewCard extends BaseCard { CardListener listener = getListener(); if (listener != null) { listener.onCardButtonPressed(OverviewCard.this, buttonIndex); - if (callback != null) { - callback.run(icon); + if (buttonIndex == SHOW_ON_MAP_BUTTON_INDEX) { + setImageDrawable(icon, getActiveShowHideIcon(), iconColorDef); } } } @@ -213,10 +202,6 @@ public class OverviewCard extends BaseCard { }); } - private interface StatBlockCallback { - void run(AppCompatImageView image); - } - private class StatBlockAdapter extends RecyclerView.Adapter { private final List statBlocks; @@ -241,13 +226,9 @@ public class OverviewCard extends BaseCard { @Override public void onBindViewHolder(StatBlockViewHolder holder, int position) { final StatBlock item = statBlocks.get(position); - final int textColor = nightMode ? - app.getResources().getColor(R.color.active_color_primary_dark) - : app.getResources().getColor(R.color.active_color_primary_light); - holder.valueText.setText(item.value); holder.titleText.setText(item.title); - holder.valueText.setTextColor(textColor); + holder.valueText.setTextColor(getActiveColor()); holder.titleText.setTextColor(app.getResources().getColor(R.color.text_color_secondary_light)); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override @@ -293,41 +274,6 @@ public class OverviewCard extends BaseCard { } } - private static class HorizontalDividerDecoration extends ItemDecoration { - - private final Drawable divider; - private final int marginV; - private final int marginH; - - public HorizontalDividerDecoration(Context context, boolean nightMode) { - divider = new ColorDrawable(ContextCompat.getColor(context, nightMode ? R.color.divider_color_dark : R.color.divider_color_light)); - marginV = context.getResources().getDimensionPixelSize(R.dimen.map_small_button_margin); - marginH = context.getResources().getDimensionPixelSize(R.dimen.content_padding); - } - - @Override - public void onDraw(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { - drawHorizontal(c, parent); - } - - public void drawHorizontal(Canvas c, RecyclerView parent) { - for (int i = 0; i < parent.getChildCount() - 1; i++) { - final View child = parent.getChildAt(i); - final int left = child.getRight() - divider.getIntrinsicWidth() + marginH; - final int right = left + divider.getIntrinsicHeight(); - final int top = child.getTop() + marginV; - final int bottom = child.getBottom() - marginV; - divider.setBounds(left, top, right, bottom); - divider.draw(c); - } - } - - @Override - public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { - outRect.set(marginH - divider.getIntrinsicWidth(), 0, marginH + divider.getIntrinsicWidth(), 0); - } - } - protected static class StatBlock { private final String title; From db99e060885ef15656725fd5817b6b96df92268d Mon Sep 17 00:00:00 2001 From: Skalii Date: Wed, 27 Jan 2021 14:49:11 +0200 Subject: [PATCH 075/125] fix hide zero total distance --- .../net/osmand/plus/track/OverviewCard.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/track/OverviewCard.java b/OsmAnd/src/net/osmand/plus/track/OverviewCard.java index d140e5478e..e43b6d139f 100644 --- a/OsmAnd/src/net/osmand/plus/track/OverviewCard.java +++ b/OsmAnd/src/net/osmand/plus/track/OverviewCard.java @@ -123,9 +123,15 @@ public class OverviewCard extends BaseCard { Algorithms.formatDuration((int) (timeSpan / 1000), app.accessibilityEnabled()), R.drawable.ic_action_time_span_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null, ITEM_TIME); - final StatBlockAdapter sbAdapter = new StatBlockAdapter(items); - rvOverview.setLayoutManager(new LinearLayoutManager(app, LinearLayoutManager.HORIZONTAL, false)); - rvOverview.setAdapter(sbAdapter); + if (Algorithms.isEmpty(items)) { + AndroidUiHelper.updateVisibility(rvOverview, false); + } else { + final StatBlockAdapter sbAdapter = new StatBlockAdapter(items); + rvOverview.setLayoutManager(new LinearLayoutManager(app, LinearLayoutManager.HORIZONTAL, false)); + rvOverview.setAdapter(sbAdapter); + } + } else { + AndroidUiHelper.updateVisibility(rvOverview, false); } } @@ -252,9 +258,7 @@ public class OverviewCard extends BaseCard { }); setImageDrawable(holder.imageView, item.imageResId, item.imageColorId); AndroidUtils.setBackgroundColor(view.getContext(), holder.divider, nightMode, R.color.divider_color_light, R.color.divider_color_dark); - if (position == statBlocks.size() - 1) { - AndroidUiHelper.setVisibility(View.GONE, holder.divider); - } + AndroidUiHelper.updateVisibility(holder.divider, position != statBlocks.size() - 1); } } @@ -301,7 +305,9 @@ public class OverviewCard extends BaseCard { StatBlock statBlock = new StatBlock(title, value, imageResId, imageColorId, firstType, secondType, itemType); switch (statBlock.itemType) { case ITEM_DISTANCE: { - listItems.add(statBlock); + if (analysis.totalDistance != 0f) { + listItems.add(statBlock); + } break; } case ITEM_ALTITUDE: { From 7c2abb67a4475b25e54e1d49611d5f1d7ded078c Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 27 Jan 2021 15:56:36 +0200 Subject: [PATCH 076/125] Fix track menu opening --- .../net/osmand/plus/track/TrackMenuFragment.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index 4d09bafbd5..a551ba2330 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -60,7 +60,6 @@ import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities.UpdateLocationViewCache; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivityActions; -import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.base.ContextMenuFragment; import net.osmand.plus.base.ContextMenuScrollFragment; import net.osmand.plus.helpers.AndroidUiHelper; @@ -1044,14 +1043,17 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card } public static void openTrack(@NonNull Context context, @Nullable File file, Bundle prevIntentParams) { - Bundle bundle = new Bundle(); - bundle.putBoolean(OPEN_TRACK_MENU, true); - if (file == null) { - bundle.putBoolean(TrackActivity.CURRENT_RECORDING, true); + boolean currentRecording = file == null; + String path = file != null ? file.getAbsolutePath() : null; + if (context instanceof MapActivity) { + TrackMenuFragment.showInstance((MapActivity) context, path, currentRecording); } else { - bundle.putString(TrackActivity.TRACK_FILE_NAME, file.getAbsolutePath()); + Bundle bundle = new Bundle(); + bundle.putString(TRACK_FILE_NAME, path); + bundle.putBoolean(OPEN_TRACK_MENU, true); + bundle.putBoolean(CURRENT_RECORDING, currentRecording); + MapActivity.launchMapActivityMoveToTop(context, prevIntentParams, null, bundle); } - MapActivity.launchMapActivityMoveToTop(context, prevIntentParams, null, bundle); } public static void showInstance(@NonNull final MapActivity mapActivity, @Nullable String path, boolean showCurrentTrack) { From bc5ad1a03251aad39c0e29e704671b610b5d9537 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Wed, 27 Jan 2021 16:33:49 +0200 Subject: [PATCH 077/125] Minor code cleanup --- .../data/TravelLocalDataHelper.java | 23 +++++-------------- .../plus/wikivoyage/data/TravelObfHelper.java | 23 +++++++++++-------- .../explore/SavedArticlesRvAdapter.java | 5 +--- .../explore/SavedArticlesTabFragment.java | 2 +- 4 files changed, 22 insertions(+), 31 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java index e27b3363b6..ae1c22b587 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java @@ -480,23 +480,12 @@ public class TravelLocalDataHelper { SQLiteConnection conn = openConnection(false); if (conn != null) { try { - String query; - Object[] parameters; - if (article.lang == null) { - query = "DELETE FROM " + BOOKMARKS_TABLE_NAME + - " WHERE " + BOOKMARKS_COL_ARTICLE_TITLE + " = ?" + - " AND " + BOOKMARKS_COL_ROUTE_ID + " = ?" + - " AND " + BOOKMARKS_COL_TRAVEL_BOOK + " = ?"; - parameters = new Object[]{article.title, article.routeId, travelBook}; - } else { - query = "DELETE FROM " + BOOKMARKS_TABLE_NAME + - " WHERE " + BOOKMARKS_COL_ARTICLE_TITLE + " = ?" + - " AND " + BOOKMARKS_COL_ROUTE_ID + " = ?" + - " AND " + BOOKMARKS_COL_LANG + " = ?" + - " AND " + BOOKMARKS_COL_TRAVEL_BOOK + " = ?"; - parameters = new Object[]{article.title, article.routeId, article.lang, travelBook}; - } - conn.execSQL(query, parameters); + String query = "DELETE FROM " + BOOKMARKS_TABLE_NAME + + " WHERE " + BOOKMARKS_COL_ARTICLE_TITLE + " = ?" + + " AND " + BOOKMARKS_COL_ROUTE_ID + " = ?" + + " AND " + BOOKMARKS_COL_LANG + ((article.lang != null) ? " = '" + article.lang + "'" : " IS NULL") + + " AND " + BOOKMARKS_COL_TRAVEL_BOOK + " = ?"; + conn.execSQL(query, new Object[]{article.title, article.routeId, travelBook}); } finally { conn.close(); } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index 17dd2c71c0..69c1506b9b 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -9,7 +9,6 @@ import androidx.annotation.Nullable; import net.osmand.Collator; import net.osmand.CollatorStringMatcher.StringMatcherMode; -import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; import net.osmand.IndexConstants; import net.osmand.OsmAndCollator; @@ -49,6 +48,8 @@ import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import static net.osmand.GPXUtilities.Track; +import static net.osmand.GPXUtilities.TrkSegment; import static net.osmand.GPXUtilities.WptPt; import static net.osmand.GPXUtilities.writeGpxFile; import static net.osmand.plus.helpers.GpxUiHelper.getGpxTitle; @@ -69,6 +70,8 @@ public class TravelObfHelper implements TravelHelper { public static final int ARTICLE_SEARCH_RADIUS = 50000; public static final int GPX_TRACKS_SEARCH_RADIUS = 10000; public static final int MAX_POPULAR_ARTICLES_COUNT = 30; + public static final int REF_KEY = 2; + public static final int NAME_KEY = 1; private final OsmandApplication app; private final Collator collator; @@ -178,7 +181,7 @@ public class TravelObfHelper implements TravelHelper { TravelGpx res = new TravelGpx(); res.file = file; String title = amenity.getName("en"); - res.title = capitalizeFirstLetter(getGpxTitle(Algorithms.isEmpty(title) ? amenity.getName() : title)); + res.title = createTitle(Algorithms.isEmpty(title) ? amenity.getName() : title); res.lat = amenity.getLocation().getLatitude(); res.lon = amenity.getLocation().getLongitude(); res.routeId = Algorithms.emptyIfNull(amenity.getTagContent(Amenity.ROUTE_ID)); @@ -265,8 +268,8 @@ public class TravelObfHelper implements TravelHelper { @Override public boolean publish(BinaryMapDataObject object) { if (object.getPointsLength() > 1) { - if (object.getObjectNames().get(2).equals(ref) - && capitalizeFirstLetter(getGpxTitle(object.getObjectNames().get(1))).equals(article.title)) { + if (object.getObjectNames().get(REF_KEY).equals(ref) + && createTitle(object.getObjectNames().get(NAME_KEY)).equals(article.title)) { segmentList.add(object); } } @@ -288,17 +291,15 @@ public class TravelObfHelper implements TravelHelper { } GPXFile gpxFile = null; if (!segmentList.isEmpty()) { - GPXUtilities.Track track = new GPXUtilities.Track(); + Track track = new Track(); for (BinaryMapDataObject segment : segmentList) { - List pointList = new ArrayList<>(); - GPXUtilities.TrkSegment trkSegment = new GPXUtilities.TrkSegment(); + TrkSegment trkSegment = new TrkSegment(); for (int i = 0; i < segment.getPointsLength(); i++) { WptPt point = new WptPt(); point.lat = MapUtils.get31LatitudeY(segment.getPoint31YTile(i)); point.lon = MapUtils.get31LongitudeX(segment.getPoint31XTile(i)); - pointList.add(point); + trkSegment.points.add(point); } - trkSegment.points = pointList; track.segments.add(trkSegment); } gpxFile = new GPXFile(article.getTitle(), article.getLang(), ""); @@ -309,6 +310,10 @@ public class TravelObfHelper implements TravelHelper { return gpxFile; } + private String createTitle(String name) { + return capitalizeFirstLetter(getGpxTitle(name)); + } + @NonNull private synchronized List getPointList(@NonNull final TravelArticle article) { final List pointList = new ArrayList<>(); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java index bbc0cb6da7..a01de6e6cb 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java @@ -11,7 +11,6 @@ import androidx.annotation.DrawableRes; import androidx.annotation.LayoutRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.fragment.app.FragmentActivity; import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.snackbar.Snackbar; @@ -26,7 +25,6 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.widgets.tools.CropCircleTransformation; import net.osmand.plus.wikipedia.WikiArticleHelper; import net.osmand.plus.wikivoyage.WikivoyageUtils; @@ -35,7 +33,6 @@ import net.osmand.plus.wikivoyage.data.TravelGpx; import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; import net.osmand.plus.wikivoyage.explore.travelcards.TravelGpxCard; -import java.io.File; import java.util.ArrayList; import java.util.List; @@ -61,7 +58,7 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter Date: Wed, 27 Jan 2021 16:53:33 +0200 Subject: [PATCH 078/125] Fix #10682 --- .../net/osmand/plus/base/MenuBottomSheetDialogFragment.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java index 9f97a07563..e4f0c6fa58 100644 --- a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java @@ -372,7 +372,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra private void setupDismissButton() { dismissButton = buttonsContainer.findViewById(R.id.dismiss_button); - dismissButton.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getDismissButtonHeight())); + dismissButton.getLayoutParams().height = getDismissButtonHeight(); int buttonTextId = getDismissButtonTextId(); if (buttonTextId != DEFAULT_VALUE) { UiUtilities.setupDialogButton(nightMode, dismissButton, getDismissButtonType(), buttonTextId); @@ -389,7 +389,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra private void setupRightButton() { rightButton = buttonsContainer.findViewById(R.id.right_bottom_button); - rightButton.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getRightButtonHeight())); + rightButton.getLayoutParams().height = getRightButtonHeight(); int buttonTextId = getRightBottomButtonTextId(); if (buttonTextId != DEFAULT_VALUE) { UiUtilities.setupDialogButton(nightMode, rightButton, getRightBottomButtonType(), buttonTextId); @@ -412,7 +412,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra protected void setupThirdButton() { thirdButton = buttonsContainer.findViewById(R.id.third_button); - thirdButton.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getThirdButtonHeight())); + thirdButton.getLayoutParams().height = getThirdButtonHeight(); int buttonTextId = getThirdBottomButtonTextId(); if (buttonTextId != DEFAULT_VALUE) { UiUtilities.setupDialogButton(nightMode, thirdButton, getThirdBottomButtonType(), buttonTextId); From 830cc1a7d4974575991a249c7bf5e766be4a8114 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 27 Jan 2021 17:29:14 +0200 Subject: [PATCH 079/125] Fix #10621 --- OsmAnd/src/net/osmand/plus/dialogs/RenameFileBottomSheet.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/dialogs/RenameFileBottomSheet.java b/OsmAnd/src/net/osmand/plus/dialogs/RenameFileBottomSheet.java index af26533607..f2bfe0e6e7 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/RenameFileBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/RenameFileBottomSheet.java @@ -99,7 +99,9 @@ public class RenameFileBottomSheet extends MenuBottomSheetDialogFragment { } private void updateFileName(String name) { - if (!Algorithms.isEmpty(name) && ILLEGAL_FILE_NAME_CHARACTERS.matcher(name).find()) { + if (Algorithms.isBlank(name)) { + nameTextBox.setError(getString(R.string.empty_filename)); + } else if (ILLEGAL_FILE_NAME_CHARACTERS.matcher(name).find()) { nameTextBox.setError(getString(R.string.file_name_containes_illegal_char)); } else { selectedFileName = name; From 829c1ae9989f59a49ab49629595e9b45986845f0 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Wed, 27 Jan 2021 18:21:36 +0200 Subject: [PATCH 080/125] Request review --- .../layout/bottom_sheet_with_progress_bar.xml | 1 - OsmAnd/res/values/strings.xml | 4 +- .../UploadPhotoProgressBottomSheet.java | 118 ++++++++++++++++++ ...UploadPhotoWithProgressBarBottomSheet.java | 111 ---------------- .../plus/mapcontextmenu/MenuBuilder.java | 6 - .../mapcontextmenu/UploadPhotosAsyncTask.java | 53 +++++--- 6 files changed, 155 insertions(+), 138 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/dialogs/UploadPhotoProgressBottomSheet.java delete mode 100644 OsmAnd/src/net/osmand/plus/dialogs/UploadPhotoWithProgressBarBottomSheet.java diff --git a/OsmAnd/res/layout/bottom_sheet_with_progress_bar.xml b/OsmAnd/res/layout/bottom_sheet_with_progress_bar.xml index fd1f27bbae..66583734bf 100644 --- a/OsmAnd/res/layout/bottom_sheet_with_progress_bar.xml +++ b/OsmAnd/res/layout/bottom_sheet_with_progress_bar.xml @@ -4,7 +4,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="?attr/selectableItemBackground" android:minHeight="@dimen/bottom_sheet_selected_item_title_height" android:orientation="vertical" android:paddingStart="@dimen/content_padding" diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 4b4b94826e..17f80d6b39 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,8 +11,8 @@ Thx - Hardy --> - Uploaded %1$s of %2$d - Uploading %1$s of %2$d + Uploaded %1$d of %2$d + Uploading %1$d of %2$d Upload completed Uploading Copy to favorites diff --git a/OsmAnd/src/net/osmand/plus/dialogs/UploadPhotoProgressBottomSheet.java b/OsmAnd/src/net/osmand/plus/dialogs/UploadPhotoProgressBottomSheet.java new file mode 100644 index 0000000000..d5b618310b --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/dialogs/UploadPhotoProgressBottomSheet.java @@ -0,0 +1,118 @@ +package net.osmand.plus.dialogs; + +import android.content.Context; +import android.content.DialogInterface; +import android.content.DialogInterface.OnDismissListener; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.ProgressBar; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.FragmentActivity; +import androidx.fragment.app.FragmentManager; + +import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; +import net.osmand.plus.base.MenuBottomSheetDialogFragment; +import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem; +import net.osmand.plus.mapcontextmenu.UploadPhotosAsyncTask.UploadPhotosListener; + +public class UploadPhotoProgressBottomSheet extends MenuBottomSheetDialogFragment implements UploadPhotosListener { + + public static final String TAG = UploadPhotoProgressBottomSheet.class.getSimpleName(); + + private ProgressBar progressBar; + private TextView uploadedPhotosTitle; + private TextView uploadedPhotosCounter; + + private OnDismissListener onDismissListener; + + private int progress; + private int maxProgress; + String descriptionProgress; + + @Override + public void createMenuItems(Bundle savedInstanceState) { + Context context = requireContext(); + LayoutInflater inflater = UiUtilities.getInflater(context, nightMode); + View view = inflater.inflate(R.layout.bottom_sheet_with_progress_bar, null); + + uploadedPhotosTitle = view.findViewById(R.id.title); + uploadedPhotosCounter = view.findViewById(R.id.description); + progressBar = view.findViewById(R.id.progress_bar); + progressBar.setMax(maxProgress); + String titleProgress = getString(progress == maxProgress? R.string.upload_photo_completed: R.string.upload_photo); + if (progress == maxProgress) { + descriptionProgress = getString(R.string.uploaded_count, progress, maxProgress); + } else { + descriptionProgress = getString(R.string.uploading_count, progress, maxProgress); + } + + BaseBottomSheetItem descriptionItem = new BottomSheetItemWithDescription.Builder() + .setDescription(descriptionProgress) + .setTitle(titleProgress) + .setCustomView(view) + .create(); + items.add(descriptionItem); + + updateProgress(progress); + + int padding = getResources().getDimensionPixelSize(R.dimen.content_padding_small); + items.add(new DividerSpaceItem(context, padding)); + } + + public void setMaxProgress(int maxProgress) { + this.maxProgress = maxProgress; + } + + public void setOnDismissListener(OnDismissListener onDismissListener) { + this.onDismissListener = onDismissListener; + } + + private void updateProgress(int progress) { + progressBar.setProgress(progress); + uploadedPhotosCounter.setText((getString(R.string.uploading_count, progress, maxProgress))); + uploadedPhotosTitle.setText(progress == maxProgress ? R.string.upload_photo_completed : R.string.upload_photo); + } + + @Override + public void uploadPhotosProgressUpdate(int progress) { + this.progress = progress; + updateProgress(progress); + } + + @Override + public void uploadPhotosFinished() { + updateProgress(maxProgress); + if (progress == maxProgress) { + uploadedPhotosCounter.setText((getString(R.string.uploaded_count, progress, maxProgress))); + setDismissButtonTextId(R.string.shared_string_close); + UiUtilities.setupDialogButton(nightMode, dismissButton, getDismissButtonType(), getDismissButtonTextId()); + } + } + + @Override + public void onDismiss(@NonNull DialogInterface dialog) { + super.onDismiss(dialog); + FragmentActivity activity = getActivity(); + if (onDismissListener != null && activity != null && !activity.isChangingConfigurations()) { + onDismissListener.onDismiss(dialog); + } + } + + public static UploadPhotosListener showInstance(@NonNull FragmentManager fragmentManager, int maxProgress, OnDismissListener listener) { + UploadPhotoProgressBottomSheet fragment = new UploadPhotoProgressBottomSheet(); + fragment.setRetainInstance(true); + fragment.setMaxProgress(maxProgress); + fragment.setOnDismissListener(listener); + fragmentManager.beginTransaction() + .add(fragment, UploadPhotoProgressBottomSheet.TAG) + .commitAllowingStateLoss(); + + return fragment; + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/dialogs/UploadPhotoWithProgressBarBottomSheet.java b/OsmAnd/src/net/osmand/plus/dialogs/UploadPhotoWithProgressBarBottomSheet.java deleted file mode 100644 index 73e09845a3..0000000000 --- a/OsmAnd/src/net/osmand/plus/dialogs/UploadPhotoWithProgressBarBottomSheet.java +++ /dev/null @@ -1,111 +0,0 @@ -package net.osmand.plus.dialogs; - -import android.app.Activity; -import android.content.Context; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.ProgressBar; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.fragment.app.FragmentManager; - -import net.osmand.plus.R; -import net.osmand.plus.UiUtilities; -import net.osmand.plus.UiUtilities.DialogButtonType; -import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.base.MenuBottomSheetDialogFragment; -import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; -import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription; -import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem; -import net.osmand.plus.widgets.TextViewEx; - -public class UploadPhotoWithProgressBarBottomSheet extends MenuBottomSheetDialogFragment { - - public static final String TAG = UploadPhotoWithProgressBarBottomSheet.class.getSimpleName(); - - private ProgressBar progressBar; - private TextView uploadedPhotosCounter; - private TextViewEx uploadedPhotosTitle; - private int maxProgress; - - @Override - public void createMenuItems(Bundle savedInstanceState) { - Context context = requireContext(); - LayoutInflater inflater = UiUtilities.getInflater(context, nightMode); - View view = inflater.inflate(R.layout.bottom_sheet_with_progress_bar, null); - - progressBar = view.findViewById(R.id.progress_bar); - progressBar.setMax(maxProgress); - uploadedPhotosCounter = view.findViewById(R.id.description); - - uploadedPhotosTitle = view.findViewById(R.id.title); - - BaseBottomSheetItem descriptionItem = new BottomSheetItemWithDescription.Builder() - .setDescription(getString(R.string.uploading_count, progressBar.getProgress(), maxProgress)) - .setTitle(getString(R.string.upload_photo)) - .setCustomView(view) - .create(); - items.add(descriptionItem); - - int padding = getResources().getDimensionPixelSize(R.dimen.content_padding_small); - items.add(new DividerSpaceItem(requireContext(), padding)); - } - - public void onProgressUpdate(int progress) { - progressBar.setProgress(progress); - uploadedPhotosCounter.setText((getString(R.string.uploading_count, progressBar.getProgress(), maxProgress))); - } - - public void onUploadingFinished() { - TextViewEx dismissButtonText = dismissButton.findViewById(R.id.button_text); - setDismissButtonTextId(R.string.shared_string_close); - dismissButtonText.setText(R.string.shared_string_close); - uploadedPhotosTitle.setText(R.string.upload_photo_completed); - uploadedPhotosCounter.setText((getString(R.string.uploaded_count, progressBar.getProgress(), maxProgress))); - } - - @Override - protected boolean useVerticalButtons() { - return true; - } - - @Override - protected int getDismissButtonTextId() { - return R.string.shared_string_cancel; - } - - @Override - protected DialogButtonType getRightBottomButtonType() { - return DialogButtonType.PRIMARY; - } - - @Override - public int getSecondDividerHeight() { - return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_icon_margin); - } - - @Override - protected void onRightBottomButtonClick() { - dismiss(); - } - - @Nullable - public MapActivity getMapActivity() { - Activity activity = getActivity(); - if (activity instanceof MapActivity) { - return (MapActivity) activity; - } - return null; - } - - public static UploadPhotoWithProgressBarBottomSheet showInstance(@NonNull FragmentManager fragmentManager, int maxProgress) { - UploadPhotoWithProgressBarBottomSheet fragment = new UploadPhotoWithProgressBarBottomSheet(); - fragment.maxProgress = maxProgress; - fragment.setRetainInstance(true); - fragmentManager.beginTransaction().add(fragment, TAG).commitAllowingStateLoss(); - return fragment; - } -} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 98198d65f3..183e41a84f 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -36,7 +36,6 @@ import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; import net.osmand.AndroidUtils; -import net.osmand.PlatformUtil; import net.osmand.data.Amenity; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; @@ -76,8 +75,6 @@ import net.osmand.plus.widgets.tools.ClickableSpanTouchListener; import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; -import org.apache.commons.logging.Log; - import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -91,7 +88,6 @@ import static net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCa public class MenuBuilder { private static final int PICK_IMAGE = 1231; - private static final Log LOG = PlatformUtil.getLog(MenuBuilder.class); public static final float SHADOW_HEIGHT_TOP_DP = 17f; public static final int TITLE_LIMIT = 60; protected static final String[] arrowChars = new String[] {"=>", " - "}; @@ -124,7 +120,6 @@ public class MenuBuilder { private String preferredMapLang; private String preferredMapAppLang; private boolean transliterateNames; - private View view; private View photoButton; private final OpenDBAPI openDBAPI = new OpenDBAPI(); @@ -261,7 +256,6 @@ public class MenuBuilder { } public void build(View view) { - this.view = view; firstRow = true; hidden = false; buildTopInternal(view); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/UploadPhotosAsyncTask.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/UploadPhotosAsyncTask.java index ce59999a11..30932e8b42 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/UploadPhotosAsyncTask.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/UploadPhotosAsyncTask.java @@ -1,5 +1,7 @@ package net.osmand.plus.mapcontextmenu; +import android.content.DialogInterface; +import android.content.DialogInterface.OnDismissListener; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Matrix; @@ -7,6 +9,7 @@ import android.net.Uri; import android.os.AsyncTask; import androidx.fragment.app.FragmentActivity; +import androidx.fragment.app.FragmentManager; import net.osmand.AndroidUtils; import net.osmand.PlatformUtil; @@ -15,7 +18,7 @@ import net.osmand.osm.io.NetworkUtils; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.dialogs.UploadPhotoWithProgressBarBottomSheet; +import net.osmand.plus.dialogs.UploadPhotoProgressBottomSheet; import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask; import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask.GetImageCardsListener; import net.osmand.plus.openplacereviews.OPRConstants; @@ -42,7 +45,7 @@ public class UploadPhotosAsyncTask extends AsyncTask { private final OsmandApplication app; private final WeakReference activityRef; - private UploadPhotoWithProgressBarBottomSheet progress; + private UploadPhotosListener listener; private final OpenDBAPI openDBAPI = new OpenDBAPI(); private final LatLon latLon; @@ -66,7 +69,20 @@ public class UploadPhotosAsyncTask extends AsyncTask { protected void onPreExecute() { FragmentActivity activity = activityRef.get(); if (AndroidUtils.isActivityNotDestroyed(activity)) { - progress = UploadPhotoWithProgressBarBottomSheet.showInstance(activity.getSupportFragmentManager(), data.size()); + FragmentManager manager = activity.getSupportFragmentManager(); + listener = UploadPhotoProgressBottomSheet.showInstance(manager, data.size(), new OnDismissListener() { + @Override + public void onDismiss(DialogInterface dialog) { + cancel(false); + } + }); + } + } + + @Override + protected void onProgressUpdate(Integer... values) { + if (listener != null) { + listener.uploadPhotosProgressUpdate(values[0]); } } @@ -77,22 +93,15 @@ public class UploadPhotosAsyncTask extends AsyncTask { } Uri uri = data.get(i); handleSelectedImage(uri); - publishProgress(i); + publishProgress(i + 1); } return null; } - @Override - protected void onProgressUpdate(Integer... values) { - if (progress != null) { - progress.onProgressUpdate(values[0]); - } - } - @Override protected void onPostExecute(Void aVoid) { - if (progress != null) { - progress.onUploadingFinished(); + if (listener != null) { + listener.uploadPhotosFinished(); } } @@ -158,12 +167,11 @@ public class UploadPhotosAsyncTask extends AsyncTask { //This method runs on non main thread private void checkTokenAndShowScreen() { - final String baseUrl = OPRConstants.getBaseUrl(app); - final String name = app.getSettings().OPR_USERNAME.get(); - final String privateKey = app.getSettings().OPR_ACCESS_TOKEN.get(); + String baseUrl = OPRConstants.getBaseUrl(app); + String name = app.getSettings().OPR_USERNAME.get(); + String privateKey = app.getSettings().OPR_ACCESS_TOKEN.get(); if (openDBAPI.checkPrivateKeyValid(baseUrl, name, privateKey)) { - String str = app.getString(R.string.cannot_upload_image); - app.showToastMessage(str); + app.showToastMessage(R.string.cannot_upload_image); } else { app.runInUIThread(new Runnable() { @Override @@ -200,4 +208,13 @@ public class UploadPhotosAsyncTask extends AsyncTask { bmp.compress(Bitmap.CompressFormat.JPEG, 90, os); return os.toByteArray(); } + + + public interface UploadPhotosListener { + + void uploadPhotosProgressUpdate(int progress); + + void uploadPhotosFinished(); + + } } \ No newline at end of file From 7ff2b92dfb6f8c69a245c441a896df3733d1cce0 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Wed, 27 Jan 2021 18:41:50 +0200 Subject: [PATCH 081/125] Global variable, code styling --- .../layout/bottom_sheet_with_progress_bar.xml | 82 +++++++++---------- .../UploadPhotoProgressBottomSheet.java | 2 +- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/OsmAnd/res/layout/bottom_sheet_with_progress_bar.xml b/OsmAnd/res/layout/bottom_sheet_with_progress_bar.xml index 66583734bf..258489706b 100644 --- a/OsmAnd/res/layout/bottom_sheet_with_progress_bar.xml +++ b/OsmAnd/res/layout/bottom_sheet_with_progress_bar.xml @@ -1,48 +1,48 @@ + xmlns:osmand="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:minHeight="@dimen/bottom_sheet_selected_item_title_height" + android:orientation="vertical" + android:paddingStart="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingTop="@dimen/measurement_tool_menu_title_padding_top" + android:paddingEnd="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingBottom="@dimen/content_padding_small"> - + - + - + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/dialogs/UploadPhotoProgressBottomSheet.java b/OsmAnd/src/net/osmand/plus/dialogs/UploadPhotoProgressBottomSheet.java index d5b618310b..f1c37a55ee 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/UploadPhotoProgressBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/UploadPhotoProgressBottomSheet.java @@ -33,7 +33,6 @@ public class UploadPhotoProgressBottomSheet extends MenuBottomSheetDialogFragmen private int progress; private int maxProgress; - String descriptionProgress; @Override public void createMenuItems(Bundle savedInstanceState) { @@ -46,6 +45,7 @@ public class UploadPhotoProgressBottomSheet extends MenuBottomSheetDialogFragmen progressBar = view.findViewById(R.id.progress_bar); progressBar.setMax(maxProgress); String titleProgress = getString(progress == maxProgress? R.string.upload_photo_completed: R.string.upload_photo); + String descriptionProgress; if (progress == maxProgress) { descriptionProgress = getString(R.string.uploaded_count, progress, maxProgress); } else { From 12c3851c5b90867303778f948c6a6da4826cc78d Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 27 Jan 2021 19:27:00 +0200 Subject: [PATCH 082/125] Add default height states for gpx menu tabs --- .../osmand/plus/base/ContextMenuFragment.java | 8 +++++ .../osmand/plus/track/TrackMenuFragment.java | 31 ++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java index 4cc90afd96..4b625e9515 100644 --- a/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/ContextMenuFragment.java @@ -946,6 +946,11 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment @TargetApi(Build.VERSION_CODES.JELLY_BEAN) protected void runLayoutListener() { + runLayoutListener(null); + } + + @TargetApi(Build.VERSION_CODES.JELLY_BEAN) + protected void runLayoutListener(final Runnable runnable) { if (view != null) { ViewTreeObserver vto = view.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @@ -974,6 +979,9 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment int menuState = getCurrentMenuState(); listener.onContextMenuStateChanged(ContextMenuFragment.this, menuState, menuState); } + if (runnable != null) { + runnable.run(); + } } } }); diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index a551ba2330..6c9857e11e 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -270,7 +270,18 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card setupToolbar(); updateHeader(); setupButtons(view); - runLayoutListener(); + runLayoutListener(new Runnable() { + @Override + public void run() { + if (menuType == TrackMenuType.OPTIONS) { + openMenuFullScreen(); + } else if (menuType == TrackMenuType.OVERVIEW) { + openMenuHeaderOnly(); + } else { + openMenuHalfScreen(); + } + } + }); } return view; } @@ -837,6 +848,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card menuType = type; setupCards(); updateHeader(); + updateMenuState(); break; } } @@ -845,6 +857,23 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card }); } + + private void updateMenuState() { + runLayoutListener(new Runnable() { + + @Override + public void run() { + if (menuType == TrackMenuType.OPTIONS) { + openMenuFullScreen(); + } else if (menuType == TrackMenuType.OVERVIEW) { + openMenuHeaderOnly(); + } else { + openMenuHalfScreen(); + } + } + }); + } + @Override public void updateContent() { if (segmentsCard != null) { From 0bc61f85c1d3d387df504e62fdb0f5f1c4f6341d Mon Sep 17 00:00:00 2001 From: Skalii Date: Thu, 28 Jan 2021 01:48:44 +0200 Subject: [PATCH 083/125] fix saving correct icon and background type of waypoints after saving current recording track --- .../plus/activities/SavingTrackHelper.java | 137 ++++++++++-------- 1 file changed, 75 insertions(+), 62 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java index ff7039702e..b06d3bb1a5 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java @@ -38,10 +38,10 @@ import java.util.Locale; import java.util.Map; public class SavingTrackHelper extends SQLiteOpenHelper { - + public final static String DATABASE_NAME = "tracks"; //$NON-NLS-1$ - public final static int DATABASE_VERSION = 6; - + public final static int DATABASE_VERSION = 7; + public final static String TRACK_NAME = "track"; //$NON-NLS-1$ public final static String TRACK_COL_DATE = "date"; //$NON-NLS-1$ public final static String TRACK_COL_LAT = "lat"; //$NON-NLS-1$ @@ -50,7 +50,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper { public final static String TRACK_COL_SPEED = "speed"; //$NON-NLS-1$ public final static String TRACK_COL_HDOP = "hdop"; //$NON-NLS-1$ public final static String TRACK_COL_HEADING = "heading"; //$NON-NLS-1$ - + public final static String POINT_NAME = "point"; //$NON-NLS-1$ public final static String POINT_COL_DATE = "date"; //$NON-NLS-1$ public final static String POINT_COL_LAT = "lat"; //$NON-NLS-1$ @@ -59,7 +59,9 @@ public class SavingTrackHelper extends SQLiteOpenHelper { public final static String POINT_COL_CATEGORY = "category"; //$NON-NLS-1$ public final static String POINT_COL_DESCRIPTION = "description"; //$NON-NLS-1$ public final static String POINT_COL_COLOR = "color"; //$NON-NLS-1$ - + public final static String POINT_COL_ICON = "icon"; //$NON-NLS-1$ + public final static String POINT_COL_BACKGROUND = "background"; //$NON-NLS-1$ + public final static float NO_HEADING = -1.0f; public final static Log log = PlatformUtil.getLog(SavingTrackHelper.class); @@ -76,8 +78,8 @@ public class SavingTrackHelper extends SQLiteOpenHelper { private SelectedGpxFile currentTrack; private int points; private int trkPoints = 0; - - public SavingTrackHelper(OsmandApplication ctx){ + + public SavingTrackHelper(OsmandApplication ctx) { super(ctx, DATABASE_NAME, null, DATABASE_VERSION); this.ctx = ctx; this.currentTrack = new SelectedGpxFile(); @@ -88,11 +90,11 @@ public class SavingTrackHelper extends SQLiteOpenHelper { prepareCurrentTrackForRecording(); updateScript = "INSERT INTO " + TRACK_NAME + " (" + TRACK_COL_LAT + ", " + TRACK_COL_LON + ", " - + TRACK_COL_ALTITUDE + ", " + TRACK_COL_SPEED + ", " + TRACK_COL_HDOP + ", " - + TRACK_COL_DATE + ", " + TRACK_COL_HEADING + ")" + + TRACK_COL_ALTITUDE + ", " + TRACK_COL_SPEED + ", " + TRACK_COL_HDOP + ", " + + TRACK_COL_DATE + ", " + TRACK_COL_HEADING + ")" + " VALUES (?, ?, ?, ?, ?, ?, ?)"; //$NON-NLS-1$ //$NON-NLS-2$ - insertPointsScript = "INSERT INTO " + POINT_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?)"; //$NON-NLS-1$ //$NON-NLS-2$ + insertPointsScript = "INSERT INTO " + POINT_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; //$NON-NLS-1$ //$NON-NLS-2$ } @Override @@ -100,19 +102,19 @@ public class SavingTrackHelper extends SQLiteOpenHelper { createTableForTrack(db); createTableForPoints(db); } - - private void createTableForTrack(SQLiteDatabase db){ + + private void createTableForTrack(SQLiteDatabase db) { db.execSQL("CREATE TABLE " + TRACK_NAME + " (" + TRACK_COL_LAT + " double, " + TRACK_COL_LON + " double, " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + TRACK_COL_ALTITUDE + " double, " + TRACK_COL_SPEED + " double, " //$NON-NLS-1$ //$NON-NLS-2$ + TRACK_COL_HDOP + " double, " + TRACK_COL_DATE + " long, " + TRACK_COL_HEADING + " float )"); //$NON-NLS-1$ //$NON-NLS-2$ } - - private void createTableForPoints(SQLiteDatabase db){ + + private void createTableForPoints(SQLiteDatabase db) { try { db.execSQL("CREATE TABLE " + POINT_NAME + " (" + POINT_COL_LAT + " double, " + POINT_COL_LON + " double, " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + POINT_COL_DATE + " long, " + POINT_COL_DESCRIPTION + " text, " + POINT_COL_NAME + " text, " - + POINT_COL_CATEGORY + " text, " + POINT_COL_COLOR + " long" + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + + POINT_COL_CATEGORY + " text, " + POINT_COL_COLOR + " long, " + POINT_COL_ICON + " text, " + POINT_COL_BACKGROUND + " text )"); //$NON-NLS-1$ //$NON-NLS-2$ } catch (RuntimeException e) { // ignore if already exists } @@ -120,25 +122,29 @@ public class SavingTrackHelper extends SQLiteOpenHelper { @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { - if(oldVersion < 2){ + if (oldVersion < 2) { createTableForPoints(db); } - if(oldVersion < 3){ + if (oldVersion < 3) { db.execSQL("ALTER TABLE " + TRACK_NAME + " ADD " + TRACK_COL_HDOP + " double"); } - if(oldVersion < 4){ - db.execSQL("ALTER TABLE " + POINT_NAME + " ADD " + POINT_COL_NAME + " text"); - db.execSQL("ALTER TABLE " + POINT_NAME + " ADD " + POINT_COL_CATEGORY + " text"); + if (oldVersion < 4) { + db.execSQL("ALTER TABLE " + POINT_NAME + " ADD " + POINT_COL_NAME + " text"); + db.execSQL("ALTER TABLE " + POINT_NAME + " ADD " + POINT_COL_CATEGORY + " text"); } - if(oldVersion < 5){ - db.execSQL("ALTER TABLE " + POINT_NAME + " ADD " + POINT_COL_COLOR + " long"); + if (oldVersion < 5) { + db.execSQL("ALTER TABLE " + POINT_NAME + " ADD " + POINT_COL_COLOR + " long"); } - if(oldVersion < 6){ - db.execSQL("ALTER TABLE " + TRACK_NAME + " ADD " + TRACK_COL_HEADING + " float"); + if (oldVersion < 6) { + db.execSQL("ALTER TABLE " + TRACK_NAME + " ADD " + TRACK_COL_HEADING + " float"); + } + if (oldVersion < 7) { + db.execSQL("ALTER TABLE " + POINT_NAME + " ADD " + POINT_COL_ICON + " text"); + db.execSQL("ALTER TABLE " + POINT_NAME + " ADD " + POINT_COL_BACKGROUND + " text"); } } - - + + public long getLastTrackPointTime() { long res = 0; try { @@ -146,7 +152,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper { if (db != null) { try { Cursor query = db.rawQuery("SELECT " + TRACK_COL_DATE + " FROM " + TRACK_NAME + " ORDER BY " + TRACK_COL_DATE + " DESC", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if(query.moveToFirst()) { + if (query.moveToFirst()) { res = query.getLong(0); } query.close(); @@ -154,11 +160,11 @@ public class SavingTrackHelper extends SQLiteOpenHelper { db.close(); } } - } catch(RuntimeException e) { + } catch (RuntimeException e) { } return res; } - + public synchronized boolean hasDataToSave() { try { SQLiteDatabase db = getWritableDatabase(); @@ -172,11 +178,11 @@ public class SavingTrackHelper extends SQLiteOpenHelper { } q = db.query(false, POINT_NAME, new String[]{POINT_COL_LAT, POINT_COL_LON}, null, null, null, null, null, null); has = q.moveToFirst(); - while(has) { - if(q.getDouble(0) != 0 || q.getDouble(1) != 0) { + while (has) { + if (q.getDouble(0) != 0 || q.getDouble(1) != 0) { break; } - if(!q.moveToNext()) { + if (!q.moveToNext()) { has = false; break; } @@ -189,7 +195,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper { db.close(); } } - } catch(RuntimeException e) { + } catch (RuntimeException e) { return false; } @@ -294,7 +300,8 @@ public class SavingTrackHelper extends SQLiteOpenHelper { private void collectDBPoints(SQLiteDatabase db, Map dataTracks) { Cursor query = db.rawQuery("SELECT " + POINT_COL_LAT + "," + POINT_COL_LON + "," + POINT_COL_DATE + "," //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - + POINT_COL_DESCRIPTION + "," + POINT_COL_NAME + "," + POINT_COL_CATEGORY + "," + POINT_COL_COLOR + " FROM " + POINT_NAME+" ORDER BY " + POINT_COL_DATE +" ASC", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + + POINT_COL_DESCRIPTION + "," + POINT_COL_NAME + "," + POINT_COL_CATEGORY + "," + POINT_COL_COLOR + "," + + POINT_COL_ICON + "," + POINT_COL_BACKGROUND + " FROM " + POINT_NAME + " ORDER BY " + POINT_COL_DATE + " ASC", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if (query.moveToFirst()) { do { WptPt pt = new WptPt(); @@ -309,18 +316,20 @@ public class SavingTrackHelper extends SQLiteOpenHelper { if (color != 0) { pt.setColor(color); } + pt.setIconName(query.getString(7)); + pt.setBackgroundType(query.getString(8)); // check if name is extension (needed for audio/video plugin & josm integration) - if(pt.name != null && pt.name.length() > 4 && pt.name.charAt(pt.name.length() - 4) == '.') { + if (pt.name != null && pt.name.length() > 4 && pt.name.charAt(pt.name.length() - 4) == '.') { pt.link = pt.name; } - + String date = DateFormat.format("yyyy-MM-dd", time).toString(); //$NON-NLS-1$ GPXFile gpx; if (dataTracks.containsKey(date)) { gpx = dataTracks.get(date); } else { - gpx = new GPXFile(Version.getFullVersion(ctx)); + gpx = new GPXFile(Version.getFullVersion(ctx)); dataTracks.put(date, gpx); } ctx.getSelectedGpxHelper().addPoint(pt, gpx); @@ -329,10 +338,10 @@ public class SavingTrackHelper extends SQLiteOpenHelper { } query.close(); } - + private void collectDBTracks(SQLiteDatabase db, Map dataTracks) { Cursor query = db.rawQuery("SELECT " + TRACK_COL_LAT + "," + TRACK_COL_LON + "," + TRACK_COL_ALTITUDE + "," //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - + TRACK_COL_SPEED + "," + TRACK_COL_HDOP + "," + TRACK_COL_DATE + "," + TRACK_COL_HEADING + " FROM " + TRACK_NAME +" ORDER BY " + TRACK_COL_DATE +" ASC", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + + TRACK_COL_SPEED + "," + TRACK_COL_HDOP + "," + TRACK_COL_DATE + "," + TRACK_COL_HEADING + " FROM " + TRACK_NAME + " ORDER BY " + TRACK_COL_DATE + " ASC", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ long previousTime = 0; long previousInterval = 0; TrkSegment segment = null; @@ -351,14 +360,14 @@ public class SavingTrackHelper extends SQLiteOpenHelper { pt.heading = heading == NO_HEADING ? Float.NaN : heading; long currentInterval = Math.abs(time - previousTime); boolean newInterval = pt.lat == 0 && pt.lon == 0; - + if (track != null && !newInterval && (!ctx.getSettings().AUTO_SPLIT_RECORDING.get() || currentInterval < 6 * 60 * 1000 || currentInterval < 10 * previousInterval)) { // 6 minute - same segment segment.points.add(pt); } else if (track != null && (ctx.getSettings().AUTO_SPLIT_RECORDING.get() && currentInterval < 2 * 60 * 60 * 1000)) { // 2 hour - same track segment = new TrkSegment(); - if(!newInterval) { + if (!newInterval) { segment.points.add(pt); } track.segments.add(segment); @@ -367,10 +376,10 @@ public class SavingTrackHelper extends SQLiteOpenHelper { track = new Track(); segment = new TrkSegment(); track.segments.add(segment); - if(!newInterval) { + if (!newInterval) { segment.points.add(pt); } - String date = new SimpleDateFormat("yyyy-MM-dd", Locale.US).format(new Date(time));; //$NON-NLS-1$ + String date = new SimpleDateFormat("yyyy-MM-dd", Locale.US).format(new Date(time)); //$NON-NLS-1$ if (dataTracks.containsKey(date)) { GPXFile gpx = dataTracks.get(date); gpx.tracks.add(track); @@ -411,14 +420,14 @@ public class SavingTrackHelper extends SQLiteOpenHelper { dataTracks.remove(date); } } - + public void startNewSegment() { lastTimeUpdated = 0; lastPoint = null; - execWithClose(updateScript, new Object[] { 0, 0, 0, 0, 0, System.currentTimeMillis(), NO_HEADING}); + execWithClose(updateScript, new Object[]{0, 0, 0, 0, 0, System.currentTimeMillis(), NO_HEADING}); addTrackPoint(null, true, System.currentTimeMillis()); } - + public void updateLocation(net.osmand.Location location, Float heading) { // use because there is a bug on some devices with location.getTime() long locationTime = System.currentTimeMillis(); @@ -459,12 +468,12 @@ public class SavingTrackHelper extends SQLiteOpenHelper { ctx.getNotificationHelper().refreshNotification(NotificationType.GPX); } } - + public void insertData(double lat, double lon, double alt, double speed, double hdop, long time, float heading, - OsmandSettings settings) { + OsmandSettings settings) { // * 1000 in next line seems to be wrong with new IntervalChooseDialog // if (time - lastTimeUpdated > settings.SAVE_TRACK_INTERVAL.get() * 1000) { - execWithClose(updateScript, new Object[] { lat, lon, alt, speed, hdop, time, heading }); + execWithClose(updateScript, new Object[]{lat, lon, alt, speed, hdop, time, heading}); boolean newSegment = false; if (lastPoint == null || (time - lastTimeUpdated) > 180 * 1000) { lastPoint = new LatLon(lat, lon); @@ -485,7 +494,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper { addTrackPoint(pt, newSegment, time); trkPoints++; } - + private void addTrackPoint(WptPt pt, boolean newSegment, long time) { List points = currentTrack.getModifiablePointsToDisplay(); Track track = currentTrack.getModifiableGpxFile().tracks.get(0); @@ -511,12 +520,12 @@ public class SavingTrackHelper extends SQLiteOpenHelper { } public WptPt insertPointData(double lat, double lon, long time, String description, String name, String category, - int color) { + int color) { return insertPointData(lat, lon, time, description, name, category, color, null, null); } public WptPt insertPointData(double lat, double lon, long time, String description, String name, String category, - int color, String iconName, String backgroundName) { + int color, String iconName, String backgroundName) { final WptPt pt = new WptPt(lat, lon, time, Double.NaN, 0, Double.NaN); pt.name = name; pt.category = category; @@ -529,7 +538,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper { ctx.getSelectedGpxHelper().addPoint(pt, currentTrack.getModifiableGpxFile()); currentTrack.getModifiableGpxFile().modifiedTime = time; points++; - execWithClose(insertPointsScript, new Object[] { lat, lon, time, description, name, category, color }); + execWithClose(insertPointsScript, new Object[]{lat, lon, time, description, name, category, color, iconName, backgroundName}); return pt; } @@ -538,7 +547,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper { } public void updatePointData(WptPt pt, double lat, double lon, long time, String description, String name, - String category, int color, String iconName, String iconBackground) { + String category, int color, String iconName, String iconBackground) { currentTrack.getModifiableGpxFile().modifiedTime = time; List params = new ArrayList<>(); @@ -549,6 +558,8 @@ public class SavingTrackHelper extends SQLiteOpenHelper { params.add(name); params.add(category); params.add(color); + params.add(iconName); + params.add(iconBackground); params.add(pt.getLatitude()); params.add(pt.getLongitude()); @@ -563,7 +574,9 @@ public class SavingTrackHelper extends SQLiteOpenHelper { + POINT_COL_DESCRIPTION + "=?, " + POINT_COL_NAME + "=?, " + POINT_COL_CATEGORY + "=?, " - + POINT_COL_COLOR + "=? " + + POINT_COL_COLOR + "=?, " + + POINT_COL_ICON + "=?, " + + POINT_COL_BACKGROUND + "=? " + "WHERE " + POINT_COL_LAT + "=? AND " + POINT_COL_LON + "=? AND " @@ -662,10 +675,10 @@ public class SavingTrackHelper extends SQLiteOpenHelper { } } - public void loadGpxFromDatabase(){ + public void loadGpxFromDatabase() { Map files = collectRecordedData(); currentTrack.getModifiableGpxFile().tracks.clear(); - for (Map.Entry entry : files.entrySet()){ + for (Map.Entry entry : files.entrySet()) { ctx.getSelectedGpxHelper().addPoints(entry.getValue().getPoints(), currentTrack.getModifiableGpxFile()); currentTrack.getModifiableGpxFile().tracks.addAll(entry.getValue().tracks); } @@ -679,10 +692,10 @@ public class SavingTrackHelper extends SQLiteOpenHelper { } private void prepareCurrentTrackForRecording() { - if(currentTrack.getModifiableGpxFile().tracks.size() == 0) { + if (currentTrack.getModifiableGpxFile().tracks.size() == 0) { currentTrack.getModifiableGpxFile().tracks.add(new Track()); } - while(currentTrack.getPointsToDisplay().size() < currentTrack.getModifiableGpxFile().tracks.size()) { + while (currentTrack.getPointsToDisplay().size() < currentTrack.getModifiableGpxFile().tracks.size()) { TrkSegment trkSegment = new TrkSegment(); currentTrack.getModifiablePointsToDisplay().add(trkSegment); } @@ -705,7 +718,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper { public int getPoints() { return points; } - + public int getTrkPoints() { return trkPoints; } @@ -717,11 +730,11 @@ public class SavingTrackHelper extends SQLiteOpenHelper { public GPXFile getCurrentGpx() { return currentTrack.getGpxFile(); } - + public SelectedGpxFile getCurrentTrack() { return currentTrack; } - + public class SaveGpxResult { public SaveGpxResult(List warnings, List filenames) { From 7508dea7cab8c93c53c74cf3aa1ec5f092926158 Mon Sep 17 00:00:00 2001 From: Hardy Date: Thu, 28 Jan 2021 08:18:59 +0100 Subject: [PATCH 084/125] string improvement --- OsmAnd/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 7cd16f7f7e..2c3358dda4 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -2444,7 +2444,7 @@ Average %1$d of %2$d Ascent/Descent - Moving time + Time in motion Max/Min Min/Max Tours From cc7ec8e0d9fc52ecd588ee0ba37ab116a390dd25 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 28 Jan 2021 09:38:00 +0200 Subject: [PATCH 085/125] Add group to markers in gpx menu --- .../EditTrackGroupDialogFragment.java | 68 +++++++++++++++---- .../osmand/plus/track/TrackMenuFragment.java | 30 ++++---- 2 files changed, 68 insertions(+), 30 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java index 19c398685c..fa7bff99ed 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java @@ -30,6 +30,7 @@ import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.WptPt; import net.osmand.data.FavouritePoint; import net.osmand.plus.FavouritesDbHelper; +import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType; @@ -70,19 +71,32 @@ public class EditTrackGroupDialogFragment extends MenuBottomSheetDialogFragment public static final String TAG = EditTrackGroupDialogFragment.class.getSimpleName(); private OsmandApplication app; + private GpxSelectionHelper selectedGpxHelper; + private MapMarkersHelper mapMarkersHelper; private GpxDisplayGroup group; @Override public void createMenuItems(Bundle savedInstanceState) { - app = requiredMyApplication(); if (group == null) { return; } + app = requiredMyApplication(); + selectedGpxHelper = app.getSelectedGpxHelper(); + mapMarkersHelper = app.getMapMarkersHelper(); items.add(new TitleItem(getCategoryName(app, group.getName()))); + GPXFile gpxFile = group.getGpx(); + + boolean currentTrack = group.getGpx().showCurrentTrack; + + SelectedGpxFile selectedGpxFile; + if (currentTrack) { + selectedGpxFile = selectedGpxHelper.getSelectedCurrentRecordingTrack(); + } else { + selectedGpxFile = selectedGpxHelper.getSelectedFileByPath(gpxFile.path); + } boolean trackPoints = group.getType() == GpxDisplayItemType.TRACK_POINTS; - SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(group.getGpx().path); if (trackPoints && selectedGpxFile != null) { items.add(createShowOnMapItem(selectedGpxFile)); } @@ -92,7 +106,9 @@ public class EditTrackGroupDialogFragment extends MenuBottomSheetDialogFragment } items.add(new OptionsDividerItem(app)); -// items.add(createCopyToMarkersItem()); + if (!currentTrack) { + items.add(createCopyToMarkersItem(gpxFile)); + } items.add(createCopyToFavoritesItem()); items.add(new OptionsDividerItem(app)); @@ -175,27 +191,51 @@ public class EditTrackGroupDialogFragment extends MenuBottomSheetDialogFragment .create(); } - private BaseBottomSheetItem createCopyToMarkersItem() { + private BaseBottomSheetItem createCopyToMarkersItem(final GPXFile gpxFile) { + final MapMarkersGroup markersGroup = getOrCreateMarkersGroup(gpxFile); + final Set categories = markersGroup.getWptCategories(); + final boolean synced = categories != null && categories.contains(group.getName()); + return new SimpleBottomSheetItem.Builder() - .setIcon(getContentIcon(R.drawable.ic_action_copy)) - .setTitle(getString(R.string.copy_to_map_markers)) - .setLayoutId(R.layout.bottom_sheet_item_simple) + .setIcon(getContentIcon(synced ? R.drawable.ic_action_delete_dark : R.drawable.ic_action_copy)) + .setTitle(getString(synced ? R.string.remove_from_map_markers : R.string.copy_to_map_markers)) .setLayoutId(R.layout.bottom_sheet_item_simple_pad_32dp) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { -// MapMarkersHelper markersHelper = app.getMapMarkersHelper(); -// MapMarkersGroup markersGroup = markersHelper.getMarkersGroup(group); -// if (markersGroup != null) { -// markersHelper.removeMarkersGroup(markersGroup); -// } else { -// markersHelper.addOrEnableGroup(group); -// } + updateGroupWptCategory(gpxFile, markersGroup, categories, synced); + dismiss(); } }) .create(); } + private void updateGroupWptCategory(GPXFile gpxFile, MapMarkersGroup markersGroup, Set categories, boolean synced) { + SelectedGpxFile selectedGpxFile = selectedGpxHelper.getSelectedFileByPath(gpxFile.path); + if (selectedGpxFile == null) { + selectedGpxHelper.selectGpxFile(gpxFile, true, false, false, false, false); + } + Set selectedCategories = new HashSet<>(); + if (categories != null) { + selectedCategories.addAll(categories); + } + if (synced) { + selectedCategories.remove(group.getName()); + } else { + selectedCategories.add(group.getName()); + } + mapMarkersHelper.updateGroupWptCategories(markersGroup, selectedCategories); + mapMarkersHelper.runSynchronization(markersGroup); + } + + private MapMarkersGroup getOrCreateMarkersGroup(GPXFile gpxFile) { + MapMarkersGroup markersGroup = mapMarkersHelper.getMarkersGroup(gpxFile); + if (markersGroup == null) { + markersGroup = mapMarkersHelper.addOrEnableGroup(gpxFile); + } + return markersGroup; + } + private BaseBottomSheetItem createCopyToFavoritesItem() { return new SimpleBottomSheetItem.Builder() .setIcon(getContentIcon(R.drawable.ic_action_copy)) diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index 6c9857e11e..dd2ca7f465 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -808,7 +808,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card @Override protected void onHeaderClick() { - adjustMapPosition(getViewY()); + updateMenuState(); } private void adjustMapPosition(int y) { @@ -848,7 +848,12 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card menuType = type; setupCards(); updateHeader(); - updateMenuState(); + runLayoutListener(new Runnable() { + @Override + public void run() { + updateMenuState(); + } + }); break; } } @@ -857,21 +862,14 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card }); } - private void updateMenuState() { - runLayoutListener(new Runnable() { - - @Override - public void run() { - if (menuType == TrackMenuType.OPTIONS) { - openMenuFullScreen(); - } else if (menuType == TrackMenuType.OVERVIEW) { - openMenuHeaderOnly(); - } else { - openMenuHalfScreen(); - } - } - }); + if (menuType == TrackMenuType.OPTIONS) { + openMenuFullScreen(); + } else if (menuType == TrackMenuType.OVERVIEW) { + openMenuHeaderOnly(); + } else { + openMenuHalfScreen(); + } } @Override From e28246975000dbeb230209653e6a0e2282182ec9 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 28 Jan 2021 10:49:44 +0200 Subject: [PATCH 086/125] Remove unnecessary code --- OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index dd2ca7f465..cfc6610b5b 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -273,13 +273,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card runLayoutListener(new Runnable() { @Override public void run() { - if (menuType == TrackMenuType.OPTIONS) { - openMenuFullScreen(); - } else if (menuType == TrackMenuType.OVERVIEW) { - openMenuHeaderOnly(); - } else { - openMenuHalfScreen(); - } + updateMenuState(); } }); } From 08621d17fdadcc19ce80aba303b637f66c5b6f53 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 28 Jan 2021 11:35:23 +0200 Subject: [PATCH 087/125] Add new method for updating menu state after layout calculation --- .../osmand/plus/track/TrackMenuFragment.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index cfc6610b5b..7f3fef69ed 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -270,12 +270,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card setupToolbar(); updateHeader(); setupButtons(view); - runLayoutListener(new Runnable() { - @Override - public void run() { - updateMenuState(); - } - }); + calculateLayoutAndUpdateMenuState(); } return view; } @@ -842,12 +837,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card menuType = type; setupCards(); updateHeader(); - runLayoutListener(new Runnable() { - @Override - public void run() { - updateMenuState(); - } - }); + calculateLayoutAndUpdateMenuState(); break; } } @@ -856,6 +846,15 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card }); } + private void calculateLayoutAndUpdateMenuState() { + runLayoutListener(new Runnable() { + @Override + public void run() { + updateMenuState(); + } + }); + } + private void updateMenuState() { if (menuType == TrackMenuType.OPTIONS) { openMenuFullScreen(); From 1b1ed6e02f69a9b8d671ee46fa0f4257af4602a0 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 28 Jan 2021 13:00:51 +0200 Subject: [PATCH 088/125] Show my location button and change header height for overview tab --- OsmAnd/res/layout/track_menu.xml | 7 +++++++ OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/layout/track_menu.xml b/OsmAnd/res/layout/track_menu.xml index 671a9332f1..db0f8a47f9 100644 --- a/OsmAnd/res/layout/track_menu.xml +++ b/OsmAnd/res/layout/track_menu.xml @@ -91,6 +91,13 @@ + + Date: Thu, 28 Jan 2021 14:33:31 +0200 Subject: [PATCH 089/125] Fix back to context menu from gpx menu --- .../controllers/SelectedGpxMenuController.java | 4 +--- .../src/net/osmand/plus/track/TrackMenuFragment.java | 12 ++++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java index 427e0cce35..acdce38b90 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java @@ -42,9 +42,7 @@ public class SelectedGpxMenuController extends MenuController { leftTitleButtonController = new TitleButtonController() { @Override public void buttonPressed() { - SelectedGpxFile selectedGpxFile = selectedGpxPoint.getSelectedGpxFile(); - mapActivity.getContextMenu().hide(false); - TrackMenuFragment.showInstance(mapActivity, selectedGpxFile.getGpxFile().path, selectedGpxFile.isShowCurrentTrack()); + TrackMenuFragment.showInstance(mapActivity, selectedGpxPoint.getSelectedGpxFile()); } }; leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_open_track); diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index 533268fd62..b145fc903d 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -227,11 +227,15 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card FragmentActivity activity = requireMyActivity(); activity.getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) { public void handleOnBackPressed() { - MapActivity mapActivity = getMapActivity(); - if (mapActivity != null) { - mapActivity.launchPrevActivityIntent(); + if (getCurrentMenuState() != MenuState.HEADER_ONLY && isPortrait()) { + openMenuHeaderOnly(); + } else { + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null && mapActivity.getSupportFragmentManager().getBackStackEntryCount() == 1) { + mapActivity.launchPrevActivityIntent(); + } + dismiss(); } - dismiss(); } }); } From c0727f658fc2eeff3e5a37acded82e4bbc27cc7f Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 28 Jan 2021 15:04:41 +0200 Subject: [PATCH 090/125] Fix back from track appearance screen to trip recording dialog --- .../osmand/plus/activities/MapActivity.java | 2 +- .../monitoring/TripRecordingBottomSheet.java | 2 +- .../plus/track/TrackAppearanceFragment.java | 26 ++++++++++--------- .../osmand/plus/track/TrackMenuFragment.java | 2 +- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 0de562fa2b..12f66f8c49 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -1200,7 +1200,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(gpxFile.path); } - TrackAppearanceFragment.showInstance(this, selectedGpxFile); + TrackAppearanceFragment.showInstance(this, selectedGpxFile, null); } else if (toShow instanceof QuadRect) { QuadRect qr = (QuadRect) toShow; mapView.fitRectToMap(qr.left, qr.right, qr.top, qr.bottom, (int) qr.width(), (int) qr.height(), 0); diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java index 789fc0aeb0..178e662176 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java @@ -90,7 +90,7 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment { if (mapActivity != null) { hide(); SelectedGpxFile selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack(); - TrackAppearanceFragment.showInstance(mapActivity, selectedGpxFile); + TrackAppearanceFragment.showInstance(mapActivity, selectedGpxFile, TripRecordingBottomSheet.this); } } }); diff --git a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java index ddc102adc9..522103ac02 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java @@ -19,6 +19,7 @@ import androidx.activity.OnBackPressedCallback; import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; @@ -37,6 +38,7 @@ import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities.DialogButtonType; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.base.ContextMenuFragment; import net.osmand.plus.base.ContextMenuScrollFragment; import net.osmand.plus.dialogs.GpxAppearanceAdapter; import net.osmand.plus.dialogs.GpxAppearanceAdapter.AppearanceListItem; @@ -165,16 +167,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement } requireMyActivity().getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) { public void handleOnBackPressed() { - MapActivity mapActivity = getMapActivity(); - if (mapActivity != null) { - TripRecordingBottomSheet fragment = mapActivity.getTripRecordingBottomSheet(); - if (fragment != null) { - fragment.show(); - } else { - mapActivity.launchPrevActivityIntent(); - } - dismissImmediate(); - } + dismiss(); } }); } @@ -385,6 +378,14 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement return y; } + @Override + public void onContextMenuDismiss(@NonNull ContextMenuFragment fragment) { + Fragment target = getTargetFragment(); + if (target instanceof TripRecordingBottomSheet) { + ((TripRecordingBottomSheet) target).show(); + } + } + private void updateAppearanceIcon() { Drawable icon = getTrackIcon(app, trackDrawInfo.getWidth(), trackDrawInfo.isShowArrows(), trackDrawInfo.getColor()); trackIcon.setImageDrawable(icon); @@ -725,11 +726,12 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement return totalScreenHeight - frameTotalHeight; } - public static boolean showInstance(@NonNull MapActivity mapActivity, @NonNull SelectedGpxFile selectedGpxFile) { + public static boolean showInstance(@NonNull MapActivity mapActivity, @NonNull SelectedGpxFile selectedGpxFile, Fragment target) { try { TrackAppearanceFragment fragment = new TrackAppearanceFragment(); - fragment.setSelectedGpxFile(selectedGpxFile); fragment.setRetainInstance(true); + fragment.setSelectedGpxFile(selectedGpxFile); + fragment.setTargetFragment(target, 0); mapActivity.getSupportFragmentManager() .beginTransaction() diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index b145fc903d..597dc4c485 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -663,7 +663,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card app.getSelectedGpxHelper().selectGpxFile(gpxFile, gpxFileSelected, false); mapActivity.refreshMap(); } else if (buttonIndex == APPEARANCE_BUTTON_INDEX) { - TrackAppearanceFragment.showInstance(mapActivity, selectedGpxFile); + TrackAppearanceFragment.showInstance(mapActivity, selectedGpxFile, this); } else if (buttonIndex == DIRECTIONS_BUTTON_INDEX) { MapActivityActions mapActions = mapActivity.getMapActions(); if (app.getRoutingHelper().isFollowingMode()) { From 65facb4af39b7e41a9e37ed720cc2896ed6e1878 Mon Sep 17 00:00:00 2001 From: cepprice Date: Thu, 28 Jan 2021 18:11:24 +0500 Subject: [PATCH 091/125] Add silent setting --- .../customization/ProfileSettingsParams.java | 13 +++++++++++-- OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java | 4 ++-- OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/OsmAnd-api/src/net/osmand/aidlapi/customization/ProfileSettingsParams.java b/OsmAnd-api/src/net/osmand/aidlapi/customization/ProfileSettingsParams.java index 00c68851e7..afca79aa0e 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/customization/ProfileSettingsParams.java +++ b/OsmAnd-api/src/net/osmand/aidlapi/customization/ProfileSettingsParams.java @@ -15,16 +15,18 @@ public class ProfileSettingsParams extends AidlParams { public static final String VERSION_KEY = "version"; public static final String REPLACE_KEY = "replace"; + public static final String SILENT_IMPORT_KEY = "silent_import"; public static final String LATEST_CHANGES_KEY = "latestChanges"; public static final String PROFILE_SETTINGS_URI_KEY = "profileSettingsUri"; private Uri profileSettingsUri; private String latestChanges; private int version; private ArrayList settingsTypeKeyList = new ArrayList<>(); - boolean replace; + private boolean silent; + private boolean replace; public ProfileSettingsParams(Uri profileSettingsUri, ArrayList settingsTypeList, boolean replace, - String latestChanges, int version) { + boolean silent, String latestChanges, int version) { this.profileSettingsUri = profileSettingsUri; for (AExportSettingsType settingsType : settingsTypeList) { settingsTypeKeyList.add(settingsType.name()); @@ -32,6 +34,7 @@ public class ProfileSettingsParams extends AidlParams { this.replace = replace; this.latestChanges = latestChanges; this.version = version; + this.silent = silent; } public ProfileSettingsParams(Parcel in) { @@ -70,6 +73,10 @@ public class ProfileSettingsParams extends AidlParams { return replace; } + public boolean isSilent() { + return silent; + } + @Override public void writeToBundle(Bundle bundle) { bundle.putInt(VERSION_KEY, version); @@ -77,6 +84,7 @@ public class ProfileSettingsParams extends AidlParams { bundle.putParcelable(PROFILE_SETTINGS_URI_KEY, profileSettingsUri); bundle.putStringArrayList(SETTINGS_TYPE_KEY, settingsTypeKeyList); bundle.putBoolean(REPLACE_KEY, replace); + bundle.putBoolean(SILENT_IMPORT_KEY, silent); } @Override @@ -86,5 +94,6 @@ public class ProfileSettingsParams extends AidlParams { profileSettingsUri = bundle.getParcelable(PROFILE_SETTINGS_URI_KEY); settingsTypeKeyList = bundle.getStringArrayList(SETTINGS_TYPE_KEY); replace = bundle.getBoolean(REPLACE_KEY); + silent = bundle.getBoolean(SILENT_IMPORT_KEY); } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 1dc3e00d98..033fceff1a 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -2297,12 +2297,12 @@ public class OsmandAidlApi { } public boolean importProfileV2(final Uri profileUri, ArrayList settingsTypeKeys, boolean replace, - String latestChanges, int version) { + boolean silent, String latestChanges, int version) { if (profileUri != null) { Bundle bundle = new Bundle(); bundle.putStringArrayList(SettingsHelper.SETTINGS_TYPE_LIST_KEY, settingsTypeKeys); bundle.putBoolean(REPLACE_KEY, replace); - bundle.putBoolean(SILENT_IMPORT_KEY, true); + bundle.putBoolean(SILENT_IMPORT_KEY, silent); bundle.putString(SettingsHelper.SETTINGS_LATEST_CHANGES_KEY, latestChanges); bundle.putInt(SettingsHelper.SETTINGS_VERSION_KEY, version); diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java index ed7ab614f3..fcd5d5159e 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java @@ -1270,7 +1270,7 @@ public class OsmandAidlServiceV2 extends Service implements AidlCallbackListener try { OsmandAidlApi api = getApi("importProfile"); return api != null && api.importProfileV2(params.getProfileSettingsUri(), params.getSettingsTypeKeys(), - params.isReplace(), params.getLatestChanges(), params.getVersion()); + params.isReplace(), params.isSilent(), params.getLatestChanges(), params.getVersion()); } catch (Exception e) { handleException(e); return false; From 2bd2839f495cde38c94748553dad521a4e9c5d05 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 28 Jan 2021 15:32:21 +0200 Subject: [PATCH 092/125] Fix context menu visibility --- .../controllers/SelectedGpxMenuController.java | 1 + .../net/osmand/plus/track/TrackMenuFragment.java | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java index acdce38b90..5ea0766469 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java @@ -42,6 +42,7 @@ public class SelectedGpxMenuController extends MenuController { leftTitleButtonController = new TitleButtonController() { @Override public void buttonPressed() { + mapContextMenu.hide(false); TrackMenuFragment.showInstance(mapActivity, selectedGpxPoint.getSelectedGpxFile()); } }; diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index 597dc4c485..0c7c88b7a3 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -230,11 +230,18 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card if (getCurrentMenuState() != MenuState.HEADER_ONLY && isPortrait()) { openMenuHeaderOnly(); } else { - MapActivity mapActivity = getMapActivity(); - if (mapActivity != null && mapActivity.getSupportFragmentManager().getBackStackEntryCount() == 1) { - mapActivity.launchPrevActivityIntent(); - } dismiss(); + + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + MapContextMenu contextMenu = mapActivity.getContextMenu(); + if (contextMenu.isActive() && contextMenu.getPointDescription() != null + && contextMenu.getPointDescription().isGpxPoint()) { + contextMenu.show(); + } else { + mapActivity.launchPrevActivityIntent(); + } + } } } }); From 593657475a93ac040d97a6454edfebd8d2e240c1 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 28 Jan 2021 16:06:10 +0200 Subject: [PATCH 093/125] Fix menu drag under toolbar --- OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index 0c7c88b7a3..492ac2ff3d 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -193,6 +193,10 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card return 0.5f; } + public int getMinY() { + return getFullScreenTopPosY(); + } + @Override public int getSupportedMenuStatesPortrait() { return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN; From a9761c1a39fa36b34b313e487aed7ed7aeaf9dca Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 28 Jan 2021 16:30:29 +0200 Subject: [PATCH 094/125] UI improvements --- .../net/osmand/plus/track/TrackMenuFragment.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index 492ac2ff3d..9147de6de9 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -186,7 +186,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card @Override public int getToolbarHeight() { - return toolbarHeightPx; + return isPortrait() ? toolbarHeightPx : 0; } public float getMiddleStateKoef() { @@ -286,6 +286,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card setupToolbar(); updateHeader(); setupButtons(view); + updateCardsLayout(); calculateLayoutAndUpdateMenuState(); } return view; @@ -443,6 +444,17 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card } } + private void updateCardsLayout() { + FrameLayout bottomContainer = getBottomContainer(); + if (menuType == TrackMenuType.OPTIONS) { + AndroidUtils.setBackground(app, bottomContainer, isNightMode(), + R.color.list_background_color_light, R.color.list_background_color_dark); + } else { + AndroidUtils.setBackground(app, bottomContainer, isNightMode(), + R.color.activity_background_color_light, R.color.activity_background_color_dark); + } + } + @Override protected void calculateLayout(View view, boolean initLayout) { menuTitleHeight = routeMenuTopShadowAll.getHeight() @@ -852,6 +864,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card menuType = type; setupCards(); updateHeader(); + updateCardsLayout(); calculateLayoutAndUpdateMenuState(); break; } From cbebccb12374ee1ac61ec5a24954e901425da97f Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Thu, 28 Jan 2021 16:42:08 +0200 Subject: [PATCH 095/125] Small refactoring --- .../data/TravelLocalDataHelper.java | 6 ++--- .../plus/wikivoyage/data/TravelObfHelper.java | 25 +++++++++++++++---- .../explore/travelcards/TravelGpxCard.java | 3 +-- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java index ae1c22b587..a95438a77e 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java @@ -143,10 +143,8 @@ public class TravelLocalDataHelper { @Nullable private TravelArticle getArticle(String title, String lang) { for (TravelArticle article : savedArticles) { - if (article.lang == null && lang == null && article.title != null && article.title.equals(title)) { - return article; - } - if (article.title != null && article.title.equals(title) && article.lang != null && article.lang.equals(lang)) { + if (article.title != null && article.title.equals(title) + && (article.lang != null && article.lang.equals(lang) || article.lang == null && lang == null)) { return article; } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index 69c1506b9b..ab9e926c10 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -48,6 +48,8 @@ import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import gnu.trove.iterator.TIntObjectIterator; + import static net.osmand.GPXUtilities.Track; import static net.osmand.GPXUtilities.TrkSegment; import static net.osmand.GPXUtilities.WptPt; @@ -70,8 +72,8 @@ public class TravelObfHelper implements TravelHelper { public static final int ARTICLE_SEARCH_RADIUS = 50000; public static final int GPX_TRACKS_SEARCH_RADIUS = 10000; public static final int MAX_POPULAR_ARTICLES_COUNT = 30; - public static final int REF_KEY = 2; - public static final int NAME_KEY = 1; + public static final String REF_TAG = "ref"; + public static final String NAME_TAG = "name"; private final OsmandApplication app; private final Collator collator; @@ -163,7 +165,7 @@ public class TravelObfHelper implements TravelHelper { private TravelArticle cacheTravelArticles(File file, Amenity amenity, String lang, boolean readPoints, @Nullable GpxReadCallback callback) { TravelArticle article = null; Map articles; - if (amenity.getSubType().equals(ROUTE_TRACK)) { + if (Algorithms.objectEquals(amenity.getSubType(), ROUTE_TRACK)) { articles = readRoutePoint(file, amenity); } else { articles = readArticles(file, amenity); @@ -268,8 +270,8 @@ public class TravelObfHelper implements TravelHelper { @Override public boolean publish(BinaryMapDataObject object) { if (object.getPointsLength() > 1) { - if (object.getObjectNames().get(REF_KEY).equals(ref) - && createTitle(object.getObjectNames().get(NAME_KEY)).equals(article.title)) { + if (getTagValue(object, REF_TAG).equals(ref) + && createTitle(getTagValue(object, NAME_TAG)).equals(article.title)) { segmentList.add(object); } } @@ -310,6 +312,19 @@ public class TravelObfHelper implements TravelHelper { return gpxFile; } + private String getTagValue(BinaryMapDataObject object, String tag) { + BinaryMapIndexReader.MapIndex mi = object.getMapIndex(); + TIntObjectIterator it = object.getObjectNames().iterator(); + while (it.hasNext()) { + it.advance(); + BinaryMapIndexReader.TagValuePair tp = mi.decodeType(it.key()); + if (tp.tag.equals(tag)) { + return it.value(); + } + } + return ""; + } + private String createTitle(String name) { return capitalizeFirstLetter(getGpxTitle(name)); } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java index 515a5f5b06..1bc2409621 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java @@ -13,7 +13,6 @@ import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.track.TrackMenuFragment; -import net.osmand.plus.wikipedia.WikiArticleHelper; import net.osmand.plus.wikivoyage.data.TravelGpx; import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; @@ -43,7 +42,7 @@ public class TravelGpxCard extends BaseTravelCard { holder.title.setText(article.getTitle()); Drawable icon = getActiveIcon(R.drawable.ic_action_user_account_16); holder.user.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); - holder.user.setText(WikiArticleHelper.getPartialContent(article.user)); + holder.user.setText(article.user); AndroidUtils.setBackground(app, holder.user, nightMode, R.drawable.btn_border_bg_light, R.drawable.btn_border_bg_dark); holder.distance.setText(OsmAndFormatter.getFormattedDistance(article.totalDistance, app)); holder.diffElevationUp.setText(OsmAndFormatter.getFormattedAlt(article.diffElevationUp, app)); From 25f7a2a8b309a0bfdbfa1c44a2a90613027ce14a Mon Sep 17 00:00:00 2001 From: vshcherb Date: Thu, 28 Jan 2021 16:00:47 +0100 Subject: [PATCH 096/125] Moved to docs --- GPX.md | 157 --------------------------------------------------------- 1 file changed, 157 deletions(-) delete mode 100644 GPX.md diff --git a/GPX.md b/GPX.md deleted file mode 100644 index b3f1e441e4..0000000000 --- a/GPX.md +++ /dev/null @@ -1,157 +0,0 @@ -The OsmAnd's GPX file format conforms to the GPX 1.1 specification with additional data written as extensions. There are several sections of such data: - -## Track appearance -The following parameters are used to customize the appearance of a track on the map. They are used inside the "gpx" tag and apply to all tracks contained in the gpx. -#### Parameters -* **show_arrows** [*true, false*] - show / hide arrows along the path line. -* **width** [*thin, medium, bold, 1-24*] - width of the track line on the map. The thin, medium, and bold are style depended values (should be defined as currentTrackWidth attribute). -* **color** [*#AARRGGBB, #RRGGBB*] - color of a track line on the map. Hex value. -* **split_type** [*no_split, distance, time*] - split type for a track. -* **split_interval** [*double*] - split interval for a track. Distance (meters), time (seconds). - -#### Example: -```xml - -... - - true - #4e4eff - distance - 2000.0 - bold - - -``` -## Details of a track point (trkpt) -Written to a gpx file while recording a track. -* **speed** (meters per second) -* **heading** (0-359 degrees) - -#### Example: -```xml - - 203 - - 3 - - 273 - 5.02 - - -``` - -## Calculated route(s) -This data contains all details of a route built with **OsmAnd** (route segments, turns, road names, road types, restrictions, etc.). The route can be completely restored as if just built, even in the absence of the respective offline maps. - -A gpx file may contain several routes. Each of them is contained in a specific segment under **trkseg** / **extensions**. A gpx file is saved in this form when exporting a constructed route or when saving a track that consists of several separate segments via the **Plan a route** functionality. -**Plan a route** also adds one (or several, in accordance with the number of contained separate segments / tracks) **rte** blocks to the gpx file, containing route key points (**rtept**). -#### Gpx structure: -```xml - - - - - - - - - - - - - - - - - - - - - - - - - - ... - - ... - - - -``` - -#### Example: -```xml - - - Fri 06 Nov 2020 - - - Fri 06 Nov 2020 - - - 0.801 - - - 0.998 - - - 1 - - - 0.963 - - - 0.899 - - - .... - - - - - - - - ... - - - - - - - - ... - - - - - - - - - pedestrian - 0 - - - - - pedestrian - 24 - - - - - pedestrian - 89 - - - - - pedestrian - 121 - - - - -``` From f4c5685ff5ce15d51ee0ecf0086a9d06a49494e2 Mon Sep 17 00:00:00 2001 From: vshcherb Date: Thu, 28 Jan 2021 16:03:32 +0100 Subject: [PATCH 097/125] Update no_translate.xml --- OsmAnd/no_translate.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/no_translate.xml b/OsmAnd/no_translate.xml index 92d3a4034f..d5ecc7c149 100644 --- a/OsmAnd/no_translate.xml +++ b/OsmAnd/no_translate.xml @@ -40,7 +40,7 @@ items modified OsmAnd Unlimited Markers - https://test.openplacereviews.org/ + https://openplacereviews.org/ https://test.openplacereviews.org/ v8G8r9NLJZGMV4he5lwbQlz620FNVARKjI9Bm5UJ jDvM95Ne1Bq2BDTmIfB6b3ZMxvdK87WGfp6DC07J From 0f994e2da6133d79a12cf8ae43b34e2c0df05421 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Thu, 28 Jan 2021 17:21:32 +0200 Subject: [PATCH 098/125] Small refactoring --- .../osmand/plus/wikivoyage/data/TravelLocalDataHelper.java | 4 ++-- .../src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java index a95438a77e..c2ccc442c3 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java @@ -143,8 +143,8 @@ public class TravelLocalDataHelper { @Nullable private TravelArticle getArticle(String title, String lang) { for (TravelArticle article : savedArticles) { - if (article.title != null && article.title.equals(title) - && (article.lang != null && article.lang.equals(lang) || article.lang == null && lang == null)) { + if (Algorithms.stringsEqual(article.title, title) + && Algorithms.stringsEqual(article.lang, lang)) { return article; } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index ab9e926c10..294cf2cd13 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -165,7 +165,7 @@ public class TravelObfHelper implements TravelHelper { private TravelArticle cacheTravelArticles(File file, Amenity amenity, String lang, boolean readPoints, @Nullable GpxReadCallback callback) { TravelArticle article = null; Map articles; - if (Algorithms.objectEquals(amenity.getSubType(), ROUTE_TRACK)) { + if (ROUTE_TRACK.equals(amenity.getSubType())) { articles = readRoutePoint(file, amenity); } else { articles = readArticles(file, amenity); From 111e2791090ada3346ad0af9c6a208a606e341da Mon Sep 17 00:00:00 2001 From: Damjan Gerl Date: Wed, 27 Jan 2021 16:58:34 +0000 Subject: [PATCH 099/125] Translated using Weblate (Slovenian) Currently translated at 72.9% (2663 of 3651 strings) --- OsmAnd/res/values-sl/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/res/values-sl/strings.xml b/OsmAnd/res/values-sl/strings.xml index 89091ce1d4..0cb17c35f4 100644 --- a/OsmAnd/res/values-sl/strings.xml +++ b/OsmAnd/res/values-sl/strings.xml @@ -3305,4 +3305,8 @@ MTB Napaka strežnika: %1$s To ime že obstaja + Preberi v celoti + Uredi opis + Brisanje točk + Kopiraj na oznake na zemljevidu \ No newline at end of file From fe2e610b0577de8f624be798402dc8eb1978b504 Mon Sep 17 00:00:00 2001 From: solokot Date: Wed, 27 Jan 2021 15:45:19 +0000 Subject: [PATCH 100/125] Translated using Weblate (Russian) Currently translated at 99.5% (3633 of 3651 strings) --- OsmAnd/res/values-ru/strings.xml | 57 +++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index 33236ca153..a0a8f5fdea 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -1185,7 +1185,7 @@ Нет маршрута Включите GPS в настройках Показывать направление к пункту назначения - Включите плагин «Запись поездки» для использования сервисов мониторинга (запись GPX, сопровождение в реальном времени) + Включите плагин «Запись поездки» для использования служб мониторинга (запись GPX, сопровождение в реальном времени) Выберите цветовую схему дорог: Цветовая схема дорог Ш %1$.3f Д %2$.3f @@ -1731,7 +1731,7 @@ выбранные Нет Отменить выбор - Отменить выбор всех + Отменить выбор Поделиться Мои места Избранные @@ -3225,7 +3225,7 @@ \n Контурные линии и затенение рельефа Предпочитать грунтовые дороги - Предпочитать грунтовые дороги. + Предпочитать грунтовые дороги Вы уверены, что хотите обновить все карты (%1$d)\? Вы можете применить это ко всем или только к выбранному профилю. Общий @@ -3713,7 +3713,7 @@ Удалить ближайший пункт Задайте название точки Следующая точка маршрута будет удалена. Если это конечный пункт, навигация завершится. - Информация о достопримечательностях из Википедии. Ваш карманный офлайн-путеводитель — просто включите плагин Википедии и читайте об объектах вокруг вас. + Информация о достопримечательностях из Википедии, карманного автономного путеводителя со статьями о местах и направлениях. Скачать карты Википедии Эндуро мотоцикл Мотороллер @@ -3937,4 +3937,53 @@ Папки Выбор папки Выберите папку или добавьте новую + Время голосовых подсказок + Можно использовать данные о высотах для учёта подъёма/спуска поездки + Предпочитать пешеходные маршруты + Подтип + Введите параметр + Пешеход + Самокат + Анализ по интервалам (по отдельности) + Заблаговременно + Заранее + При прохождении + При приближении + Инвалидная коляска + Пеший туризм + Малый грузовик + Грузовик + Копировать в маркеры + Копировать в избранное + Удалить онлайн-маршрутизатор\? + Предпочитать пешеходные маршруты + Добавить онлайн-маршрутизатор + Редактировать онлайн-маршрутизатор + Ключ API + URL-адрес сервера + Оставить пустым, если не + URL со всеми параметрами будет выглядеть так: + Тест расчёта маршрута + Автомобиль + Онлайн-маршрутизатор + Онлайн-маршрутизаторы + Пусто + Отправить в OpenStreetMap + Редактировать трек + Переименовать трек + Изменить папку + сек. + Вне маршрута + Прибытие в пункт назначения + Поворот + Интервалы времени и расстояния + Время объявления + Время объявления различных голосовых подсказок зависит от типа подсказки, текущей скорости навигации и скорости навигации по умолчанию. + Начать запись + Показать трек на карте + Ошибка сервера: %1$s + Имя уже существует + Читать полностью + Редактировать описание + Удалить путевые точки \ No newline at end of file From 624c2419f4af2e97362a5ffb5a4ee6c3212672ab Mon Sep 17 00:00:00 2001 From: ace shadow Date: Wed, 27 Jan 2021 23:39:53 +0000 Subject: [PATCH 101/125] Translated using Weblate (Slovak) Currently translated at 100.0% (3651 of 3651 strings) --- OsmAnd/res/values-sk/strings.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OsmAnd/res/values-sk/strings.xml b/OsmAnd/res/values-sk/strings.xml index 95f34a3db1..2da9b2324b 100644 --- a/OsmAnd/res/values-sk/strings.xml +++ b/OsmAnd/res/values-sk/strings.xml @@ -3995,4 +3995,10 @@ Chyba servera: %1$s Názov už existuje Odbočiť + Odstrániť túto online navigačnú službu\? + Prečítať celé + Upraviť popis + Odstrániť body trasy + Skopírovať do mapových značiek + Skopírovať do obľúbených \ No newline at end of file From 45357c21397989fa550424d3cf20d0a38c363049 Mon Sep 17 00:00:00 2001 From: Ahmad Alfrhood Date: Wed, 27 Jan 2021 12:59:17 +0000 Subject: [PATCH 102/125] Translated using Weblate (Arabic) Currently translated at 100.0% (3651 of 3651 strings) --- OsmAnd/res/values-ar/strings.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OsmAnd/res/values-ar/strings.xml b/OsmAnd/res/values-ar/strings.xml index 8929bd6f4d..699c82cd8e 100644 --- a/OsmAnd/res/values-ar/strings.xml +++ b/OsmAnd/res/values-ar/strings.xml @@ -4063,4 +4063,10 @@ MTB خطأ في الخادم: %1$s الاسم موجود بالفعل + هل تريد حذف محرك التوجيه عبر الإنترنت؟ + قراءة كاملة + تحرير الوصف + حذف نقاط الطريق + نسخ لعلامات الخريطة + نسخ للمفضلة \ No newline at end of file From 092f990229c4e19cd7fd84a0c8a4ec63661fa53f Mon Sep 17 00:00:00 2001 From: nasr pen Date: Wed, 27 Jan 2021 09:10:59 +0000 Subject: [PATCH 103/125] Translated using Weblate (Arabic) Currently translated at 100.0% (3651 of 3651 strings) --- OsmAnd/res/values-ar/strings.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OsmAnd/res/values-ar/strings.xml b/OsmAnd/res/values-ar/strings.xml index 699c82cd8e..4b91263f2d 100644 --- a/OsmAnd/res/values-ar/strings.xml +++ b/OsmAnd/res/values-ar/strings.xml @@ -3513,7 +3513,7 @@ أنواع نقاط الاهتمام لا شيء محدد زر الإجراء السريع - ملفات التعريف + الأوضاع سيتم استبدال العناصر الحالية بالعناصر التي في الملف استبدل الكل احصل على %1$d %2$s عند %3$s مقابل. @@ -3965,7 +3965,7 @@ مساحة جهازك %1$s الخالية فقط. يرجى تحرير بعض المساحة أو إلغاء تحديد بعض العناصر للتصدير. المصادر حجم الملف التقريبي - حدد البيانات التي سيتم تصديرها إلى الملف. + حدد البيانات التي سيتم تصديرها إلى ملف. مطلوب للاستيراد لا يوجد مساحة كافية أضف إلى مابيلاي @@ -3997,10 +3997,10 @@ \n • دعم ألوان مخصصة للمفضلة ونقاط لمسار الطريق \n \n - ملف تعريف أوسماند + وضع الاستعراض ملف تعريف المستخدم عكس جميع النقاط - حدد ملف التعريف، الذي سيتم استخدامه في بدء التطبيق. + حدد الوضع الذي سيتم استخدامه في بدء التطبيق. آخر استخدام تفضيل طرق التنزه تفضيل طرق التنزه From c53b863bd21a5bfe5b8d5354d4880581584aa53a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Allan=20Nordh=C3=B8y?= Date: Wed, 27 Jan 2021 04:05:25 +0000 Subject: [PATCH 104/125] =?UTF-8?q?Translated=20using=20Weblate=20(Norwegi?= =?UTF-8?q?an=20Bokm=C3=A5l)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently translated at 59.2% (2163 of 3651 strings) --- OsmAnd/res/values-nb/strings.xml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-nb/strings.xml b/OsmAnd/res/values-nb/strings.xml index bff5af5293..7c3e0695ce 100644 --- a/OsmAnd/res/values-nb/strings.xml +++ b/OsmAnd/res/values-nb/strings.xml @@ -1526,7 +1526,7 @@ Taledataversjon som ikke støttes Sporer posisjonen din mens skjermen er slått av. Favoritter delt via OsmAnd - Lagre data som GPX-fil eller importere rutepunkter til Favoritter\? + Lagre data som GPX-fil eller importere rutepunkter til favoritter\? Format for geografiske koordinater. Koordinatformat Søk @@ -3919,4 +3919,18 @@ Vanlig sykling Tjenerfeil: %1$s Navnet finnes allerede + Analyser ved intervaller (delt intervall) + Ruteavvik + Stor lastebil + Slett denne nettbaserte rutingsmotoren\? + Les hele + Slett rutepunkt + Luke + Logg inn på OpenStreetMap + Logg inn + Tidsforbruk + Ankomst + Rediger beskrivelse + Kopier til kartmarkører + Kopier til favoritter \ No newline at end of file From 8694faaba66c3e4d06a9b0611007d8cd78314ab4 Mon Sep 17 00:00:00 2001 From: Franco Date: Wed, 27 Jan 2021 22:34:54 +0000 Subject: [PATCH 105/125] Translated using Weblate (Spanish (Argentina)) Currently translated at 99.8% (3646 of 3651 strings) --- OsmAnd/res/values-es-rAR/strings.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-es-rAR/strings.xml b/OsmAnd/res/values-es-rAR/strings.xml index 1a037e42ff..56f6940aae 100644 --- a/OsmAnd/res/values-es-rAR/strings.xml +++ b/OsmAnd/res/values-es-rAR/strings.xml @@ -3982,7 +3982,7 @@ Preparar Fuera de la ruta Has llegado al destino - Giro + Girar Intervalos de tiempo y distancia El tiempo de anuncio de las diferentes indicaciones por voz depende del tipo de mensaje, la velocidad de navegación actual y la velocidad de navegación predefinida. Tiempo de anuncio @@ -4003,4 +4003,10 @@ Bicicleta de montaña Error de servidor: %1$s El nombre ya existe + ¿Borrar este motor de navegación en línea\? + Leer completo + Editar descripción + Borrar puntos de referencia + Copiar a «Marcadores del mapa» + Copiar a favoritos \ No newline at end of file From c96276556325757ebb18b5d1468b8efa863d6b7a Mon Sep 17 00:00:00 2001 From: Oymate Date: Thu, 28 Jan 2021 08:21:59 +0000 Subject: [PATCH 106/125] Translated using Weblate (Bengali) Currently translated at 0.4% (17 of 3651 strings) --- OsmAnd/res/values-bn/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OsmAnd/res/values-bn/strings.xml b/OsmAnd/res/values-bn/strings.xml index 1dd3435fca..09ae3e8f32 100644 --- a/OsmAnd/res/values-bn/strings.xml +++ b/OsmAnd/res/values-bn/strings.xml @@ -24,4 +24,8 @@ ওএসএমও কেনাকাটা একটি মানচিত্রের প্রতীকের জন্য গাইড ন্যাভিগেশন প্রোফাইল + অবস্থানগুলো + দিক নির্ণয় + মি/সে + নটিকাল মাইল \ No newline at end of file From a591cb14c6cf65a42b57d9e619f56471d26672c9 Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Wed, 27 Jan 2021 01:46:38 +0000 Subject: [PATCH 107/125] Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (3651 of 3651 strings) --- OsmAnd/res/values-zh-rTW/strings.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OsmAnd/res/values-zh-rTW/strings.xml b/OsmAnd/res/values-zh-rTW/strings.xml index 2c86df4178..c092cb961b 100644 --- a/OsmAnd/res/values-zh-rTW/strings.xml +++ b/OsmAnd/res/values-zh-rTW/strings.xml @@ -3993,4 +3993,10 @@ 登山車 伺服器錯誤:%1$s 名稱已存在 + 刪除此線上路線引擎? + 讀取全部 + 編輯描述 + 刪除航點 + 複製到地圖標記 + 複製到收藏 \ No newline at end of file From eabd5037fd802d31fa6db7bc59e2ebf005d9741e Mon Sep 17 00:00:00 2001 From: CJTmmr Date: Wed, 27 Jan 2021 16:29:50 +0000 Subject: [PATCH 108/125] Translated using Weblate (Dutch) Currently translated at 96.1% (3510 of 3651 strings) --- OsmAnd/res/values-nl/strings.xml | 87 +++++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 24 deletions(-) diff --git a/OsmAnd/res/values-nl/strings.xml b/OsmAnd/res/values-nl/strings.xml index 012850fd00..c9d8e87306 100644 --- a/OsmAnd/res/values-nl/strings.xml +++ b/OsmAnd/res/values-nl/strings.xml @@ -2178,8 +2178,8 @@ Tijdsduur Tijd in beweging Rijstijl - Gebruik hoogtegegevens - Factor in hoogtegegevens (van SRTM, ASTER en EU-DEM data). + Hoogtegegevens gebruiken + Gebruik hoogtegegevens (van SRTM, ASTER en EU-DEM data) bij bepalen route. Track Rechts rijdend Automatisch @@ -3320,9 +3320,9 @@ Route herberekening Meld Gebruikersnaam en wachtwoord - Deze instellingen hebben betrekking op alle profielen + Deze plugin-instellingen hebben betrekking op alle profielen OSM Bewerking - U kan al uw niet geüploade bewerkingen of OSM fouten zien in %1$s. Geüploade punten ziet u niet meer. + U kunt alle niet-geüploade bewerkingen of OSM-opmerkingen zien in %1$s. Geüploade wijzigingen ziet u niet meer. OSM Tijdens navigatie of beweging getoond icoon. Bij rust getoond icoon. @@ -3667,8 +3667,8 @@ Volgende segment Alle volgende segmenten Alle volgende segmenten worden opnieuw berekend met het geselecteerde profiel. - De ganse track - De ganse track wordt herberekend volgens het geselecteerde profiel. + De gehele route + De gehele route wordt herberekend volgens het geselecteerde profiel. Punt van de track om te navigeren Bewaar als nieuw trackbestand Bewaar als nieuwe track @@ -3730,8 +3730,8 @@ \nDe grafiek is beschikbaar na herberekening. %1$s — %2$s Kies een trackbestand om te volgen of importeer het, vanaf uw apparaat. - Kloof - Op maat + Onderbreking + Aangepast Voer een OAuth-login uit om osm edit functies te gebruiken "• Bijgewerkte app- en profielinstellingen: instellingen zijn nu gerangschikt op type. Elk profiel kan afzonderlijk worden aangepast. \n @@ -3843,41 +3843,41 @@ Onderhoud Symbolen Sport - Noodtoestand + Noodgevallen Reizen Trackbestanden importeren of opnemen Track waypoint toevoegen Opslaan als trackbestand Rec U moet minimaal twee punten toevoegen - Login op OpenStreetMap - Login op OpenStreetMap.org - Login met OpenStreetMap - U moet inloggen om nieuwe of gewijzigde wijzigingen te uploaden. + Inloggen bij OpenStreetMap + Inloggen bij OpenStreetMap.org + Aanmelden via OpenStreetMap (OAuth) + U moet inloggen om wijzigingen te uploaden. \n -\nU kunt inloggen met de veilige OAuth-methode of uw login en wachtwoord gebruiken. - Gebruik uw login gegevens +\nU kunt inloggen met de veilige OAuth-methode of uw loginnaam en wachtwoord gebruiken. + Inloggen met gebruikersnaam en wachtwoord. Account - Inloggen + Gebruikersnaam Abonnement beheren Er is een probleem met uw abonnement. Klik op de knop om naar de Google Play-abonnementsinstellingen te gaan om uw betalingsmethode te corrigeren. OsmAnd Live-abonnement is verlopen OsmAnd Live-abonnement is gepauzeerd - Het OsmAnd Live-abonnement is op wacht gezet - Markeervlaggen geschiedenis + Het OsmAnd Live-abonnement is opgeschort + Markeervlaggetjes-geschiedenis Stuur het GPX-bestand naar OpenStreetMap Voer tags in, gescheiden door komma\'s. - Openbaar betekent dat de trace openbaar zal worden getoond in Uw GPS-sporen en in openbare GPS-traceerlijsten. Gegevens die via de API worden geleverd, verwijzen niet naar uw traceerpagina. Tijdaanduidingen van de traceerpunten zijn niet beschikbaar via de openbare GPS-API en de punten zijn niet chronologisch gerangschikt. Andere gebruikers kunnen de onbewerkte tracering echter nog steeds downloaden van de openbare traceringslijst en eventuele tijdaanduiding erin. - Privé betekent dat de trace niet in openbare vermeldingen zal verschijnen, maar trackpoints ervan zullen nog steeds beschikbaar zijn via de openbare GPS API zonder tijdaanduiding, maar zullen niet chronologisch worden gerangschikt. - Identificeerbaar betekent dat de trace openbaar wordt getoond in uw GPS-sporen en in openbare GPS-trace-lijsten, dat wil zeggen dat andere gebruikers de onbewerkte trace kunnen downloaden en deze aan uw gebruikersnaam kunnen koppelen. Gegevens die via de trackpoints-API worden aangeboden, verwijzen naar uw oorspronkelijke tracepagina. Tijdaanduidingen van de traceerpunten zijn beschikbaar via de openbare GPS-API. - Trackbaar betekent dat de trace niet in openbare vermeldingen zal verschijnen, maar trackpoints ervan zullen nog steeds beschikbaar zijn via de openbare GPS API met tijdaanduiding. Andere gebruikers kunnen alleen verwerkte trackpoints downloaden van uw trace die niet rechtstreeks aan u kunnen worden gekoppeld. + \"Publiek\" betekent dat de track openbaar wordt getoond in \"Jouw GPS-tracks\" en in openbare GPS-track-lijsten. Trackpoints die d.m.v. de API worden gedownload zullen niet aan je oorspronkelijke trackpagina refereren. Tijden in de tracks zijn niet beschikbaar in de publieke GPS API, maar de punten zullen wel chronologisch geordend zijn. Echter, andere gebruikers kunnen de track van de openbare GPS-track-lijsten downloaden met alle tijdinformatie. + \"Persoonlijk\" betekent dat de track niet wordt getoond in openbare GPS-track-lijsten, maar de trackpunten zijn wel beschikbaar in volgorde van tijd door de publieke GPS API, maar zonder tijdinformatie. + \"Identificeerbaar\" betekent dat de trace openbaar wordt getoond in uw GPS-sporen en in openbare GPS-trace-lijsten. Dat wil zeggen dat andere gebruikers de onbewerkte trace kunnen downloaden en deze aan uw gebruikersnaam kunnen koppelen. Gegevens die via de trackpoints-API worden aangeboden, verwijzen naar uw oorspronkelijke tracepagina. Tijdaanduidingen van de traceerpunten zijn beschikbaar via de openbare GPS-API. + \"Traceerbaar\" betekent dat de track niet wordt getoond in openbare GPS-track-lijsten maar de trackpunten zijn wel beschikbaar door de publieke GPS API met tijdinformatie. Andere gebruikers kunnen alleen bewerkte trackpunten downloaden die niet aan jou herleid kunnen worden. Sluit OSM Note Opmerking maken bij OSM-nota - U kunt inloggen met de veilige OAuth-methode of uw login en wachtwoord gebruiken. + U kunt inloggen met de veilige OAuth-methode, of uw loginnaam en wachtwoord gebruiken. Een foto toevoegen Registreer u op \nOpenPlaceReviews.org - Foto\'s zijn afkomstig van het open data-project OpenPlaceReviews.org. Om uw foto\'s te uploaden, moet u zich aanmelden op deze website. + Foto\'s zijn afkomstig van het open data-project OpenPlaceReviews.org. Om uw foto\'s te uploaden, moet u zich aanmelden op hun website. Maak een nieuw account aan Ik heb al een account %1$s * %2$s @@ -3954,4 +3954,43 @@ Laat regelmatig droogvallende waterwegen toe Geef een parameter Laat leeg indien niet + Analyseren met intervallen + Uploaden naar OpenStreetMap + GPX-track bewerken + GPX-track hernoemen + Map wijzigen + sec + Bij nadering + Bij passeren + Ruime vooraankondiging + Vooraankondiging + Afwijking van de route + Aankomst op bestemming + Bocht + Tijd- en afstandsintervallen + De aankondigingstijd van verschillende aankondigen hangt af van type en huidige snelheid. + Aankondigingstijd + Start opname + Toon GPX-track op de kaart + Rolstoel + Hiken + Wandelen + Elektische Fiets + Mountainbiken + Fietsen + Normaal Fietsen + Vrachtwagen + Kleine Vrachtwagen + Vrachtwagen + Scooter + Racefiets + Mountainbike + Server fout: %1$s + Deze naam bestaat al + Deze Online-routeservice verwijderen\? + Helemaal inlezen + Beschrijving bewerken + Waypoints verwijderen + Kopiëren naar Markeervlaggetjes + Kopiëren naar Favorieten \ No newline at end of file From f87592c4adf0ff4acc883c700cebf7950026edf6 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Thu, 28 Jan 2021 19:04:14 +0300 Subject: [PATCH 109/125] Travel fixes --- .../net/osmand/plus/OsmandApplication.java | 13 ++++++++++ .../plus/activities/MapActivityActions.java | 2 +- .../data/TravelLocalDataHelper.java | 26 +++++++++++++++++++ .../plus/wikivoyage/data/TravelObfHelper.java | 14 +++++----- 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index 842a36237e..6b9aa4d0a4 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -210,6 +210,8 @@ public class OsmandApplication extends MultiDexApplication { File mapillaryVectorTilesPath = new File(tilesPath, TileSourceManager.getMapillaryVectorSource().getName()); Algorithms.removeAllFiles(mapillaryRasterTilesPath); Algorithms.removeAllFiles(mapillaryVectorTilesPath); + // Remove travel sqlite db files + removeSqliteDbTravelFiles(); } checkPreferredLocale(); @@ -234,6 +236,17 @@ public class OsmandApplication extends MultiDexApplication { return externalStorageDirectoryReadOnly; } + private void removeSqliteDbTravelFiles() { + File[] files = getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR).listFiles(); + if (files != null) { + for (File file : files) { + if (file.getName().endsWith(IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT)) { + file.delete(); + } + } + } + } + @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index b5dd0dc3ea..258ed7be38 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -928,7 +928,7 @@ public class MapActivityActions implements DialogProvider { MapActivity.clearPrevActivityIntent(); TravelHelper travelHelper = getMyApplication().getTravelHelper(); travelHelper.initializeDataOnAppStartup(); - if (!travelHelper.isAnyTravelBookPresent()) { + if (!travelHelper.isAnyTravelBookPresent() && !travelHelper.getBookmarksHelper().hasSavedArticles()) { WikivoyageWelcomeDialogFragment.showInstance(mapActivity.getSupportFragmentManager()); } else { Intent intent = new Intent(mapActivity, WikivoyageExploreActivity.class); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java index 02ee5a32c8..151a0ef424 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelLocalDataHelper.java @@ -1,6 +1,9 @@ package net.osmand.plus.wikivoyage.data; +import android.database.DatabaseUtils; +import android.database.sqlite.SQLiteDatabase; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -100,6 +103,10 @@ public class TravelLocalDataHelper { } } + public boolean hasSavedArticles() { + return !savedArticles.isEmpty() || dbHelper.hasSavedArticles(); + } + @NonNull public List getSavedArticles() { return new ArrayList<>(savedArticles); @@ -438,6 +445,25 @@ public class TravelLocalDataHelper { return res; } + boolean hasSavedArticles() { + int count = 0; + SQLiteConnection conn = openConnection(true); + if (conn != null) { + try { + SQLiteCursor cursor = conn.rawQuery("SELECT COUNT(*) FROM " + BOOKMARKS_TABLE_NAME, null); + if (cursor != null) { + if (cursor.moveToFirst()) { + count = cursor.getInt(0); + } + cursor.close(); + } + } finally { + conn.close(); + } + } + return count > 0; + } + void addSavedArticle(@NonNull TravelArticle article) { String travelBook = article.getTravelBook(context); if (travelBook == null) { diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index 0f14896a94..1336dcc2f6 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -485,7 +485,7 @@ public class TravelObfHelper implements TravelHelper { @Nullable private TravelArticle getCachedArticle(@NonNull TravelArticleIdentifier articleId, @NonNull String lang, - boolean forceReadPoints, @Nullable GpxReadCallback callback) { + boolean readGpx, @Nullable GpxReadCallback callback) { TravelArticle article = null; Map articles = cachedArticles.get(articleId); if (articles != null) { @@ -502,9 +502,9 @@ public class TravelObfHelper implements TravelHelper { } } if (article == null && articles == null) { - article = findArticleById(articleId, lang, callback); + article = findArticleById(articleId, lang, readGpx, callback); } - if (article != null && forceReadPoints && !Algorithms.isEmpty(lang)) { + if (article != null && readGpx && !Algorithms.isEmpty(lang)) { readGpxFile(article, callback); } return article; @@ -518,8 +518,8 @@ public class TravelObfHelper implements TravelHelper { } } - private TravelArticle findArticleById(@NonNull final TravelArticleIdentifier articleId, - final String lang, @Nullable GpxReadCallback callback) { + private synchronized TravelArticle findArticleById(@NonNull final TravelArticleIdentifier articleId, + final String lang, boolean readGpx, @Nullable GpxReadCallback callback) { TravelArticle article = null; final boolean isDbArticle = articleId.file != null && articleId.file.getName().endsWith(IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT); final List amenities = new ArrayList<>(); @@ -562,7 +562,7 @@ public class TravelObfHelper implements TravelHelper { LOG.error(e.getMessage()); } if (!Algorithms.isEmpty(amenities)) { - article = cacheTravelArticles(reader.getFile(), amenities.get(0), lang, true, callback); + article = cacheTravelArticles(reader.getFile(), amenities.get(0), lang, readGpx, callback); } } return article; @@ -585,7 +585,7 @@ public class TravelObfHelper implements TravelHelper { @Nullable @Override - public TravelArticle getArticleByTitle(@NonNull final String title, @NonNull QuadRect rect, + public synchronized TravelArticle getArticleByTitle(@NonNull final String title, @NonNull QuadRect rect, @NonNull final String lang, boolean readGpx, @Nullable GpxReadCallback callback) { TravelArticle article = null; final List amenities = new ArrayList<>(); From 8098f5d92c32c4bfcc6f85bdc8304a5bd0fee348 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Thu, 28 Jan 2021 19:17:25 +0300 Subject: [PATCH 110/125] Fix npe --- .../WikivoyageArticleDialogFragment.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index 4ee8099c26..cced9d45ad 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -1,6 +1,7 @@ package net.osmand.plus.wikivoyage.article; import android.annotation.SuppressLint; +import android.content.Context; import android.content.Intent; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; @@ -339,17 +340,20 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme } private void updateTrackButton(boolean processing, @Nullable GPXFile gpxFile) { - if (processing) { - trackButton.setVisibility(View.GONE); - gpxProgress.setVisibility(View.VISIBLE); - } else { - if (gpxFile != null && gpxFile.getPointsSize() > 0) { - trackButton.setVisibility(View.VISIBLE); - trackButton.setText(getString(R.string.shared_string_gpx_points) + " (" + gpxFile.getPointsSize() + ")"); - } else { + Context ctx = getContext(); + if (ctx != null) { + if (processing) { trackButton.setVisibility(View.GONE); + gpxProgress.setVisibility(View.VISIBLE); + } else { + if (gpxFile != null && gpxFile.getPointsSize() > 0) { + trackButton.setVisibility(View.VISIBLE); + trackButton.setText(ctx.getString(R.string.shared_string_gpx_points) + " (" + gpxFile.getPointsSize() + ")"); + } else { + trackButton.setVisibility(View.GONE); + } + gpxProgress.setVisibility(View.GONE); } - gpxProgress.setVisibility(View.GONE); } } From 1b30f1f428b3fbc7ea54693b389e41f5cc02d040 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Thu, 28 Jan 2021 19:53:34 +0300 Subject: [PATCH 111/125] Fix travel cards when no book --- .../explore/ExploreTabFragment.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java index 9055acd4ed..c13c7fb22f 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java @@ -175,10 +175,9 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv if (!Version.isPaidVersion(app) && !OpenBetaTravelCard.isClosed()) { items.add(new OpenBetaTravelCard(activity, nightMode)); } - if (app.getTravelHelper().isAnyTravelBookPresent()) { + List popularArticles = app.getTravelHelper().getPopularArticles(); + if (!popularArticles.isEmpty()) { items.add(new HeaderTravelCard(app, nightMode, getString(R.string.popular_destinations))); - - List popularArticles = app.getTravelHelper().getPopularArticles(); for (TravelArticle article : popularArticles) { if (article instanceof TravelGpx) { items.add(new TravelGpxCard(app, nightMode, (TravelGpx) article, getActivity())); @@ -186,15 +185,15 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv items.add(new ArticleTravelCard(app, nightMode, article, activity.getSupportFragmentManager())); } } - items.add(new StartEditingTravelCard(activity, nightMode)); - adapter.setItems(items); - final DownloadIndexesThread downloadThread = app.getDownloadThread(); - if (!downloadThread.getIndexes().isDownloadedFromInternet) { - waitForIndexes = true; - downloadThread.runReloadIndexFilesSilent(); - } else { - checkDownloadIndexes(); - } + } + items.add(new StartEditingTravelCard(activity, nightMode)); + adapter.setItems(items); + final DownloadIndexesThread downloadThread = app.getDownloadThread(); + if (!downloadThread.getIndexes().isDownloadedFromInternet) { + waitForIndexes = true; + downloadThread.runReloadIndexFilesSilent(); + } else { + checkDownloadIndexes(); } } } From 44bcf483759a72aa40a36761b46e1b166acf53ba Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 28 Jan 2021 18:54:45 +0200 Subject: [PATCH 112/125] Add opr blockchain name --- .../plus/mapcontextmenu/MenuBuilder.java | 2 +- .../mapcontextmenu/UploadPhotosAsyncTask.java | 6 ++-- .../osmand/plus/osmedit/opr/OpenDBAPI.java | 32 ++++++++++++++++--- .../plus/settings/backend/OsmandSettings.java | 3 ++ 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 183e41a84f..93f2bdf6b5 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -421,7 +421,7 @@ public class MenuBuilder { new Thread(new Runnable() { @Override public void run() { - if (openDBAPI.checkPrivateKeyValid(baseUrl, name, privateKey)) { + if (openDBAPI.checkPrivateKeyValid(app, baseUrl, name, privateKey)) { app.runInUIThread(new Runnable() { @Override public void run() { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/UploadPhotosAsyncTask.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/UploadPhotosAsyncTask.java index 30932e8b42..1bb48ff1f0 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/UploadPhotosAsyncTask.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/UploadPhotosAsyncTask.java @@ -131,12 +131,12 @@ public class UploadPhotosAsyncTask extends AsyncTask { try { StringBuilder error = new StringBuilder(); String privateKey = app.getSettings().OPR_ACCESS_TOKEN.get(); - String username = app.getSettings().OPR_USERNAME.get(); + String name = app.getSettings().OPR_BLOCKCHAIN_NAME.get(); res = openDBAPI.uploadImage( placeId, baseUrl, privateKey, - username, + name, response, error); if (res != 200) { app.showToastMessage(error.toString()); @@ -170,7 +170,7 @@ public class UploadPhotosAsyncTask extends AsyncTask { String baseUrl = OPRConstants.getBaseUrl(app); String name = app.getSettings().OPR_USERNAME.get(); String privateKey = app.getSettings().OPR_ACCESS_TOKEN.get(); - if (openDBAPI.checkPrivateKeyValid(baseUrl, name, privateKey)) { + if (openDBAPI.checkPrivateKeyValid(app, baseUrl, name, privateKey)) { app.showToastMessage(R.string.cannot_upload_image); } else { app.runInUIThread(new Runnable() { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/opr/OpenDBAPI.java b/OsmAnd/src/net/osmand/plus/osmedit/opr/OpenDBAPI.java index a16361c8bd..14c0e97672 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/opr/OpenDBAPI.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/opr/OpenDBAPI.java @@ -3,10 +3,15 @@ package net.osmand.plus.osmedit.opr; import android.net.TrafficStats; import android.os.Build; +import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonSyntaxException; +import com.google.gson.reflect.TypeToken; import net.osmand.PlatformUtil; import net.osmand.osm.io.NetworkUtils; +import net.osmand.plus.OsmandApplication; +import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; import org.bouncycastle.jce.provider.BouncyCastleProvider; @@ -27,6 +32,7 @@ import java.security.KeyPair; import java.security.Security; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -40,7 +46,7 @@ public class OpenDBAPI { public static final String PURPOSE = "osmand-android"; private static final Log log = PlatformUtil.getLog(SecUtils.class); private static final String checkLoginEndpoint = "api/auth/user-check-loginkey?"; - private static final String LOGIN_SUCCESS_MESSAGE = "{\"result\":\"OK\"}"; + private static final String LOGIN_SUCCESS_MESSAGE = "\"result\":\"OK\""; private static final int THREAD_ID = 11200; /* @@ -51,7 +57,7 @@ public class OpenDBAPI { * Need to encode key * Do not call on mainThread */ - public boolean checkPrivateKeyValid(String baseUrl, String username, String privateKey) { + public boolean checkPrivateKeyValid(OsmandApplication app, String baseUrl, String username, String privateKey) { String url = null; try { String purposeParam = "purpose=" + PURPOSE; @@ -65,9 +71,27 @@ public class OpenDBAPI { } catch (UnsupportedEncodingException e) { return false; } + StringBuilder response = new StringBuilder(); - return (NetworkUtils.sendGetRequest(url,null,response) == null) && - response.toString().contains(LOGIN_SUCCESS_MESSAGE); + String error = NetworkUtils.sendGetRequest(url, null, response); + if (error == null) { + String responseStr = response.toString(); + try { + Map tagMap = new Gson().fromJson( + responseStr, new TypeToken>() { + }.getType() + ); + if (Algorithms.isEmpty(tagMap) && tagMap.containsKey("blockchain-name")) { + String blockchainName = tagMap.get("blockchain-name"); + app.getSettings().OPR_BLOCKCHAIN_NAME.set(blockchainName); + } + } catch (JsonSyntaxException e) { + return false; + } + return responseStr.contains(LOGIN_SUCCESS_MESSAGE); + } else { + return false; + } } public int uploadImage(String[] placeId, String baseUrl, String privateKey, String username, String image, StringBuilder sb) throws FailedVerificationException { diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index dfaaea9468..0d3cddb136 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -1171,6 +1171,9 @@ public class OsmandSettings { public final OsmandPreference OPR_USERNAME = new StringPreference(this, "opr_username_secret", "").makeGlobal(); + public final OsmandPreference OPR_BLOCKCHAIN_NAME = + new StringPreference(this, "opr_blockchain_name", "").makeGlobal(); + // this value boolean is synchronized with settings_pref.xml preference offline POI/Bugs edition public final OsmandPreference OFFLINE_EDITION = new BooleanPreference(this, "offline_osm_editing", true).makeGlobal().makeShared(); public final OsmandPreference USE_DEV_URL = new BooleanPreference(this, "use_dev_url", false).makeGlobal().makeShared(); From ef899fad821229ecefb27c317d6ac907d90520ec Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 28 Jan 2021 18:58:49 +0200 Subject: [PATCH 113/125] Small fix --- OsmAnd/src/net/osmand/plus/osmedit/opr/OpenDBAPI.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/opr/OpenDBAPI.java b/OsmAnd/src/net/osmand/plus/osmedit/opr/OpenDBAPI.java index 14c0e97672..62612f2ffe 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/opr/OpenDBAPI.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/opr/OpenDBAPI.java @@ -77,13 +77,15 @@ public class OpenDBAPI { if (error == null) { String responseStr = response.toString(); try { - Map tagMap = new Gson().fromJson( + Map map = new Gson().fromJson( responseStr, new TypeToken>() { }.getType() ); - if (Algorithms.isEmpty(tagMap) && tagMap.containsKey("blockchain-name")) { - String blockchainName = tagMap.get("blockchain-name"); + if (Algorithms.isEmpty(map) && map.containsKey("blockchain-name")) { + String blockchainName = map.get("blockchain-name"); app.getSettings().OPR_BLOCKCHAIN_NAME.set(blockchainName); + } else { + return false; } } catch (JsonSyntaxException e) { return false; From b43a4e46f370b1ba4549f538352a5435303c5b93 Mon Sep 17 00:00:00 2001 From: vshcherb Date: Thu, 28 Jan 2021 18:00:25 +0100 Subject: [PATCH 114/125] Update no_translate.xml --- OsmAnd/no_translate.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/no_translate.xml b/OsmAnd/no_translate.xml index d5ecc7c149..92d3a4034f 100644 --- a/OsmAnd/no_translate.xml +++ b/OsmAnd/no_translate.xml @@ -40,7 +40,7 @@ items modified OsmAnd Unlimited Markers - https://openplacereviews.org/ + https://test.openplacereviews.org/ https://test.openplacereviews.org/ v8G8r9NLJZGMV4he5lwbQlz620FNVARKjI9Bm5UJ jDvM95Ne1Bq2BDTmIfB6b3ZMxvdK87WGfp6DC07J From 31dc53203d727fb00be67b5b0654833bdd8d5c7d Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 28 Jan 2021 19:04:23 +0200 Subject: [PATCH 115/125] Fix typo --- OsmAnd/src/net/osmand/plus/osmedit/opr/OpenDBAPI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/opr/OpenDBAPI.java b/OsmAnd/src/net/osmand/plus/osmedit/opr/OpenDBAPI.java index 62612f2ffe..1fdeba64f0 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/opr/OpenDBAPI.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/opr/OpenDBAPI.java @@ -81,7 +81,7 @@ public class OpenDBAPI { responseStr, new TypeToken>() { }.getType() ); - if (Algorithms.isEmpty(map) && map.containsKey("blockchain-name")) { + if (!Algorithms.isEmpty(map) && map.containsKey("blockchain-name")) { String blockchainName = map.get("blockchain-name"); app.getSettings().OPR_BLOCKCHAIN_NAME.set(blockchainName); } else { From 70c7e8a3676111ed088a0ab2d830d4139bbb11b8 Mon Sep 17 00:00:00 2001 From: vshcherb Date: Thu, 28 Jan 2021 20:44:22 +0100 Subject: [PATCH 116/125] Update no_translate.xml --- OsmAnd/no_translate.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/no_translate.xml b/OsmAnd/no_translate.xml index 92d3a4034f..d5ecc7c149 100644 --- a/OsmAnd/no_translate.xml +++ b/OsmAnd/no_translate.xml @@ -40,7 +40,7 @@ items modified OsmAnd Unlimited Markers - https://test.openplacereviews.org/ + https://openplacereviews.org/ https://test.openplacereviews.org/ v8G8r9NLJZGMV4he5lwbQlz620FNVARKjI9Bm5UJ jDvM95Ne1Bq2BDTmIfB6b3ZMxvdK87WGfp6DC07J From e188034530bc0ec591fe944fed8febbd4c1153c7 Mon Sep 17 00:00:00 2001 From: Jurijus Date: Thu, 28 Jan 2021 16:19:56 +0000 Subject: [PATCH 117/125] Translated using Weblate (Lithuanian) Currently translated at 59.1% (2163 of 3656 strings) --- OsmAnd/res/values-lt/strings.xml | 44 +++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/OsmAnd/res/values-lt/strings.xml b/OsmAnd/res/values-lt/strings.xml index 09ee2a83fd..3c683d41cf 100644 --- a/OsmAnd/res/values-lt/strings.xml +++ b/OsmAnd/res/values-lt/strings.xml @@ -18,9 +18,8 @@ po piet ryto Statymo vieta - Šis įskiepis leidžia įsiminti vietą, kurioje palikote savo automobilį ir kiek laiko liko iki parkavimo pabaigos (jei ribojamas laikas). - -Tiek vieta, tiek laikas yra matomi OsmAnd valdymo skydelyje bei skydelyje žemėlapyje rodinyje. Šis įskiepis taip pat gali įrašyti priminimą į kalendorių. + Šis įskiepis leidžia įsiminti vietą, kurioje palikote savo automobilį ir kiek laiko liko iki parkavimo pabaigos . +\nTiek vieta, tiek laikas yra matomi OsmAnd valdymo skydelyje bei skydelyje žemėlapyje rodinyje. Šis įskiepis taip pat gali įrašyti priminimą į Android kalendorių. Statymo vieta Žymėti statymo vietą Naikinti statymo žymę @@ -200,9 +199,8 @@ Tiek vieta, tiek laikas yra matomi OsmAnd valdymo skydelyje bei skydelyje žemė Foninis režimas Reikalinga, jei norite naudoti OsmAnd kai ekranas yra išjungtas. Neužtenka vietos parsiųsti %1$s MB (laisva: %2$s). - Atsiųsti {0} failą(-us)? -Tam prireiks {1} MB pastoviam saugojimui. -(Dabar laisvos vietos yra {2} MB.) + Atsiųsti {0} failą(-us)\? +\nTam prireiks {1} MB pastoviam saugojimui. (Dabar laisvos vietos yra {2} MB.) Permatoma tema Aparatinė biblioteka šiame įrenginyje nepalaikoma. Inicializuojama aparatinė biblioteka… @@ -778,8 +776,28 @@ Tam prireiks {1} MB pastoviam saugojimui. Vengti greitkelių Poziciją rodyti ant kelių kai naviguojama. Rodyti ant kelio - OsmAnd (OSM Automated Navigation Directions) -\nOsmAnd yra atviro kodo programa naudojanti įvairius OpenStreetMap (OSM) duomenis. Visi žemėlapių duomenys (vektoriniai ar lakštiniai) gali būti išsaugoti telefone ir naudojami be interneto prieigos. OsmAnd taip pat gali pasiūlyti maršruto skaičiavimo paslaugas internete ar įrenginyje, bei balso nurodymus kelionei apskaičiuotu maršrutu. Dalis pagrindinių savybių: - Veikia be interneto (išsaugokite parsiųstus žemėlapius ar jų lakštus įrenginyje) - Kompaktiški vektoriniai viso pasaulio žemėlapiai - Parsisųskite šalies ar regiono žemėlapius tiesiai iš pačios propgramos - Galima sulieti kelis žemėlapop sluoksnius, tokius kaip GPX ar judėjimo istoriją, Lankytinas Vietas, mėgiamas vietas, kontūrų linijas, viešojo transporto stoteles, papildomus žemėlapius su pasirinktinai nustatomu permatomumo lygiu - Adresų ir LV paieška nenaudojant interneto - Vidutinio ilgio maršruto apskaičiavimas be interneto paslaugų - Automobilio, dviračio ir pėsčiojo režimai su: - pasirinktiniu dineos/nakties rodinio perjungimu - pasirinktiniu pagal judėjimo greitį automatiškai nustatomu mąsteliu - pasirinktine žemėlapio orientacija pagal kompaso arba judėjimo kryptį - pasirinktinis eismo juostų nurodymas, greičio ribojimų rodymas, įrašyti ar generuojami balsai Šios nemokamos OsmAnd versijos apribojimai: - Ribojamas žemėlapių parsiuntimų skaičius - Nėra prieigos prie iš Wikipedia parsiunčiamų LV OsmAnd yra aktyviai tobulinama ir mūsų projektas bei jo tolesnis progresas priklauso nuo finansinės paramos, kuri įgalina tolesnį vystymą ir naujų funkcijų kūrimą. Norime paskatinti jus nusipirkti OsmAnd+ programą arba finansiškai prisidėti prie specifinių funkcijų kūrimo arba šiaip paremti programą osmand.net svetainėje. + OsmAnd (OSM Automated Navigation Directions) +\n +\nOsmAnd yra atviro kodo programa naudojanti įvairius OpenStreetMap (OSM) duomenis. Visi žemėlapių duomenys (vektoriniai ar lakštiniai) gali būti išsaugoti telefone ir naudojami be interneto prieigos. OsmAnd taip pat gali pasiūlyti maršruto skaičiavimo paslaugas internete ar įrenginyje, bei balso nurodymus kelionei apskaičiuotu maršrutu. +\n +\nDalis pagrindinių savybių: +\n- Veikia be interneto (išsaugokite parsiųstus žemėlapius ar jų lakštus įrenginyje) +\n- Kompaktiški vektoriniai viso pasaulio žemėlapiai +\n- Parsisųskite šalies ar regiono žemėlapius tiesiai iš pačios propgramos +\n- Galima sulieti kelis žemėlapop sluoksnius, tokius kaip GPX ar judėjimo istoriją, Lankytinas Vietas, mėgiamas vietas, kontūrų linijas, viešojo transporto stoteles, papildomus žemėlapius su pasirinktinai nustatomu permatomumo lygiu +\n - Adresų ir LV paieška nenaudojant interneto +\n- Vidutinio ilgio maršruto apskaičiavimas be interneto prieigos +\n- Automobilio, dviračio ir pėsčiojo režimai su: +\n- pasirinktiniu dineos/nakties rodinio perjungimu +\n- pasirinktiniu pagal judėjimo greitį automatiškai nustatomu mąsteliu +\n- pasirinktine žemėlapio orientacija pagal kompaso arba judėjimo kryptį +\n- pasirinktinis eismo juostų nurodymas, greičio ribojimų rodymas, įrašyti ar generuojami balsai +\n +\nNemokamos OsmAnd versijos apribojimai: +\n- Ribojamas žemėlapių parsiuntimų skaičius +\n- Nėra prieigos prie iš Wikipedia parsiunčiamų LV +\n +\n OsmAnd yra aktyviai tobulinama ir mūsų projektas bei jo tolesnis progresas priklauso nuo finansinės paramos, kuri įgalina tolesnį vystymą ir naujų funkcijų kūrimą. Norime paskatinti jus nusipirkti OsmAnd+ programą arba finansiškai prisidėti prie specifinių funkcijų kūrimo arba šiaip paremti programą https://osmand.net svetainėje. OsmAnd - atviro kodo navigacijos programa su žemėlapiais OsmAnd+ (OSM Automated Navigation Directions) \n @@ -1872,9 +1890,9 @@ Failams reikalinga {3} MB laikinam ir {1} MB pastoviam saugojimui. Prenumerata leidžia kas valandą gauti visų pasaulio žemėlapių atnaujinimus. Dalis pajamų grįžta OSM bendruomenei ir apmokamas kiekvienas indėlis į OSM kūrimą. Tai yra puikus būdas paremti OsmAnd ir OSM, jei jie jums patinka. - Ar siųsti {0} failų? - Failams reikalinga {3} MB laikinam ir {1} MB pastoviam saugojimui. - (Šiuo metu prieinama tik {2} MB vietos.) + Ar siųsti {0} failų\? +\nFailams reikalinga {3} MB laikinam ir {1} MB pastoviam saugojimui. +\n(Šiuo metu prieinama tik {2} MB vietos.) Ispanų (Amerikos) Anglų (Junginė Karalystė) Belarusų (Lotynų) @@ -2419,7 +2437,9 @@ Tai yra puikus būdas paremti OsmAnd ir OSM, jei jie jums patinka. Paskutinį kartą naudota: %1$s Taisymų %1$s, suma %2$s mBTC Laosiečių - OsmAnd (OSM Automated Navigation Directions) yra žemėlapio ir navigacijos programa su prieiga prie nemokamų, pasaulinių ir aukštos kokybės OpenStreetMap (OSM) duomenų. Naudokitės balso ir vaizdo navigatoriumi, peržiūrėkite LV (lankytinas vietas), kurkite ir valdytkite GPX kelius, naudojkite kontūro linijos vizualizaciją ir aukščio info (įskiepių pagalba), pasirinkite vairavimo, dviračių, pėsčiųjų režimus, redaguokite OSM duomenis ir daug daugiau. + OsmAnd (OSM Automated Navigation Directions) yra žemėlapio ir navigacijos programa su prieiga prie nemokamų, pasaulinių ir aukštos kokybės OpenStreetMap (OSM) duomenų. +\n +\nNaudokitės balso ir vaizdo navigatoriumi, peržiūrėkite LV (lankytinas vietas), kurkite ir valdytkite GPX kelius, naudojkite kontūro linijos vizualizaciją ir aukščio info (įskiepių pagalba), pasirinkite vairavimo, dviračių, pėsčiųjų režimus, redaguokite OSM duomenis ir daug daugiau. Nuostatos pavadinimas Bakstelėję veiksmo mygtuką pridėsite žemėlapio žymeklį ekrano centre. Bakstelėję veiksmo mygtuką pridėsite garso įrašą ekrano centre. From b5f01a1c7f117a5756b2f6f65c7678ac601c048b Mon Sep 17 00:00:00 2001 From: Skalii Date: Fri, 29 Jan 2021 04:04:33 +0200 Subject: [PATCH 118/125] add the ability to save the global settings of Wikipedia Languages --- .../SelectWikiLanguagesBottomSheet.java | 52 +++++++++++++++++-- .../plus/wikipedia/WikipediaPlugin.java | 31 +++++++++-- 2 files changed, 76 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/SelectWikiLanguagesBottomSheet.java b/OsmAnd/src/net/osmand/plus/wikipedia/SelectWikiLanguagesBottomSheet.java index 873feba53c..da3b6f106d 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/SelectWikiLanguagesBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/SelectWikiLanguagesBottomSheet.java @@ -1,8 +1,12 @@ package net.osmand.plus.wikipedia; +import android.app.Activity; import android.content.res.Resources; +import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.text.SpannableString; +import android.text.style.StyleSpan; import android.view.View; import android.widget.CompoundButton; @@ -12,6 +16,8 @@ import androidx.core.content.ContextCompat; import androidx.core.os.ConfigurationCompat; import androidx.core.os.LocaleListCompat; +import com.google.android.material.snackbar.Snackbar; + import net.osmand.AndroidUtils; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; @@ -124,6 +130,12 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen } } + @Nullable + public MapActivity getMapActivity() { + Activity activity = getActivity(); + return (MapActivity) activity; + } + private void initLanguagesData() { languages = new ArrayList<>(); @@ -188,12 +200,44 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen localesForSaving.add(language.getLocale()); } } - wikiPlugin.setLanguagesToShow(localesForSaving); - wikiPlugin.setShowAllLanguages(isGlobalWikiPoiEnabled); - wikiPlugin.updateWikipediaState(); + applyPreferenceWithSnackBar(localesForSaving, isGlobalWikiPoiEnabled); dismiss(); } + protected final void applyPreference(boolean applyToAllProfiles, List localesForSaving, boolean global) { + if (applyToAllProfiles) { + for (ApplicationMode mode : ApplicationMode.allPossibleValues()) { + wikiPlugin.setLanguagesToShow(mode, localesForSaving); + wikiPlugin.setShowAllLanguages(mode, global); + } + } else { + wikiPlugin.setLanguagesToShow(localesForSaving); + wikiPlugin.setShowAllLanguages(isGlobalWikiPoiEnabled); + } + + wikiPlugin.updateWikipediaState(); + } + + protected void applyPreferenceWithSnackBar(final List localesForSaving, final boolean global) { + applyPreference(false, localesForSaving, global); + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + String modeName = appMode.toHumanString(); + String text = app.getString(R.string.changes_applied_to_profile, modeName); + SpannableString message = UiUtilities.createSpannableString(text, new StyleSpan(Typeface.BOLD), modeName); + Snackbar snackbar = Snackbar.make(mapActivity.getLayout(), message, Snackbar.LENGTH_LONG) + .setAction(R.string.apply_to_all_profiles, new View.OnClickListener() { + @Override + public void onClick(View view) { + applyPreference(true, localesForSaving, global); + } + }); + UiUtilities.setupSnackbarVerticalLayout(snackbar); + UiUtilities.setupSnackbar(snackbar, nightMode); + snackbar.show(); + } + } + private View getCustomButtonView() { OsmandApplication app = getMyApplication(); if (app == null) { @@ -265,7 +309,7 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen } public static void showInstance(@NonNull MapActivity mapActivity, - boolean usedOnMap) { + boolean usedOnMap) { SelectWikiLanguagesBottomSheet fragment = new SelectWikiLanguagesBottomSheet(); fragment.setUsedOnMap(usedOnMap); fragment.show(mapActivity.getSupportFragmentManager(), SelectWikiLanguagesBottomSheet.TAG); diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPlugin.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPlugin.java index 16684fbe25..88b7618185 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPlugin.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPlugin.java @@ -30,6 +30,7 @@ import net.osmand.plus.search.QuickSearchDialogFragment; import net.osmand.plus.search.QuickSearchListAdapter; import net.osmand.plus.search.listitems.QuickSearchBannerListItem; import net.osmand.plus.search.listitems.QuickSearchFreeBannerListItem; +import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.views.layers.DownloadedRegionsLayer; import net.osmand.plus.views.OsmandMapTileView; @@ -97,8 +98,8 @@ public class WikipediaPlugin extends OsmandPlugin { @Override protected void registerLayerContextMenuActions(OsmandMapTileView mapView, - ContextMenuAdapter adapter, - final MapActivity mapActivity) { + ContextMenuAdapter adapter, + final MapActivity mapActivity) { ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.OnRowItemClick() { @Override @@ -113,7 +114,7 @@ public class WikipediaPlugin extends OsmandPlugin { @Override public boolean onContextMenuClick(final ArrayAdapter adapter, int itemId, - final int pos, boolean isChecked, int[] viewCoordinates) { + final int pos, boolean isChecked, int[] viewCoordinates) { if (itemId == R.string.shared_string_wikipedia) { toggleWikipediaPoi(isChecked, new CallbackWithObject() { @Override @@ -189,26 +190,50 @@ public class WikipediaPlugin extends OsmandPlugin { return !isShowAllLanguages() && getLanguagesToShow() != null; } + public boolean hasCustomSettings(ApplicationMode profile) { + return !isShowAllLanguages(profile) && getLanguagesToShow(profile) != null; + } + public boolean hasLanguagesFilter() { return settings.WIKIPEDIA_POI_ENABLED_LANGUAGES.get() != null; } + public boolean hasLanguagesFilter(ApplicationMode profile) { + return settings.WIKIPEDIA_POI_ENABLED_LANGUAGES.getModeValue(profile) != null; + } + public boolean isShowAllLanguages() { return settings.GLOBAL_WIKIPEDIA_POI_ENABLED.get(); } + public boolean isShowAllLanguages(ApplicationMode mode) { + return settings.GLOBAL_WIKIPEDIA_POI_ENABLED.getModeValue(mode); + } + public void setShowAllLanguages(boolean showAllLanguages) { settings.GLOBAL_WIKIPEDIA_POI_ENABLED.set(showAllLanguages); } + public void setShowAllLanguages(ApplicationMode mode, boolean showAllLanguages) { + settings.GLOBAL_WIKIPEDIA_POI_ENABLED.setModeValue(mode, showAllLanguages); + } + public List getLanguagesToShow() { return settings.WIKIPEDIA_POI_ENABLED_LANGUAGES.getStringsList(); } + public List getLanguagesToShow(ApplicationMode mode) { + return settings.WIKIPEDIA_POI_ENABLED_LANGUAGES.getStringsListForProfile(mode); + } + public void setLanguagesToShow(List languagesToShow) { settings.WIKIPEDIA_POI_ENABLED_LANGUAGES.setStringsList(languagesToShow); } + public void setLanguagesToShow(ApplicationMode mode, List languagesToShow) { + settings.WIKIPEDIA_POI_ENABLED_LANGUAGES.setStringsListForProfile(mode, languagesToShow); + } + public void toggleWikipediaPoi(boolean enable, CallbackWithObject callback) { if (enable) { showWikiOnMap(); From 54763fc22d1b73dd3e6f360d53d6ceb5e586e190 Mon Sep 17 00:00:00 2001 From: cepprice Date: Fri, 29 Jan 2021 18:51:28 +0500 Subject: [PATCH 119/125] Small edit --- .../aidlapi/customization/ProfileSettingsParams.java | 9 +++++---- OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/OsmAnd-api/src/net/osmand/aidlapi/customization/ProfileSettingsParams.java b/OsmAnd-api/src/net/osmand/aidlapi/customization/ProfileSettingsParams.java index afca79aa0e..eee80329f7 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/customization/ProfileSettingsParams.java +++ b/OsmAnd-api/src/net/osmand/aidlapi/customization/ProfileSettingsParams.java @@ -8,6 +8,7 @@ import net.osmand.aidlapi.AidlParams; import net.osmand.aidlapi.profile.AExportSettingsType; import java.util.ArrayList; +import java.util.List; import static net.osmand.aidlapi.profile.ExportProfileParams.SETTINGS_TYPE_KEY; @@ -21,11 +22,11 @@ public class ProfileSettingsParams extends AidlParams { private Uri profileSettingsUri; private String latestChanges; private int version; - private ArrayList settingsTypeKeyList = new ArrayList<>(); + private List settingsTypeKeyList = new ArrayList<>(); private boolean silent; private boolean replace; - public ProfileSettingsParams(Uri profileSettingsUri, ArrayList settingsTypeList, boolean replace, + public ProfileSettingsParams(Uri profileSettingsUri, List settingsTypeList, boolean replace, boolean silent, String latestChanges, int version) { this.profileSettingsUri = profileSettingsUri; for (AExportSettingsType settingsType : settingsTypeList) { @@ -65,7 +66,7 @@ public class ProfileSettingsParams extends AidlParams { return profileSettingsUri; } - public ArrayList getSettingsTypeKeys() { + public List getSettingsTypeKeys() { return settingsTypeKeyList; } @@ -82,7 +83,7 @@ public class ProfileSettingsParams extends AidlParams { bundle.putInt(VERSION_KEY, version); bundle.putString(LATEST_CHANGES_KEY, latestChanges); bundle.putParcelable(PROFILE_SETTINGS_URI_KEY, profileSettingsUri); - bundle.putStringArrayList(SETTINGS_TYPE_KEY, settingsTypeKeyList); + bundle.putStringArrayList(SETTINGS_TYPE_KEY, new ArrayList<>(settingsTypeKeyList)); bundle.putBoolean(REPLACE_KEY, replace); bundle.putBoolean(SILENT_IMPORT_KEY, silent); } diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 033fceff1a..3687602716 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -2296,11 +2296,11 @@ public class OsmandAidlApi { return false; } - public boolean importProfileV2(final Uri profileUri, ArrayList settingsTypeKeys, boolean replace, + public boolean importProfileV2(final Uri profileUri, List settingsTypeKeys, boolean replace, boolean silent, String latestChanges, int version) { if (profileUri != null) { Bundle bundle = new Bundle(); - bundle.putStringArrayList(SettingsHelper.SETTINGS_TYPE_LIST_KEY, settingsTypeKeys); + bundle.putStringArrayList(SettingsHelper.SETTINGS_TYPE_LIST_KEY, new ArrayList<>(settingsTypeKeys)); bundle.putBoolean(REPLACE_KEY, replace); bundle.putBoolean(SILENT_IMPORT_KEY, silent); bundle.putString(SettingsHelper.SETTINGS_LATEST_CHANGES_KEY, latestChanges); From f04a181524d781955366d3b3aa8418f33d67a96f Mon Sep 17 00:00:00 2001 From: max-klaus Date: Fri, 29 Jan 2021 18:46:27 +0300 Subject: [PATCH 120/125] Fix travel in free version --- OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java index aaac5e6f9e..298e3fc287 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java @@ -292,10 +292,6 @@ public class DownloadActivityType { public IndexItem parseIndexItem(OsmandApplication ctx, XmlPullParser parser) { - if (TRAVEL_FILE == this && !Version.isDeveloperVersion(ctx)) { - //todo remove "if" when .travel.obf will be used in production - return null; - } String name = parser.getAttributeValue(null, "name"); //$NON-NLS-1$ if (!isAccepted(name)) { return null; From 55a1669afbfcd6d4d68aaf11f75702626c390da3 Mon Sep 17 00:00:00 2001 From: Skalii Date: Fri, 29 Jan 2021 18:12:20 +0200 Subject: [PATCH 121/125] fix max-width in stats block; fix align icon to the right in stats block --- OsmAnd/res/layout/item_gpx_stat_block.xml | 44 +++++++++++++++-------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/OsmAnd/res/layout/item_gpx_stat_block.xml b/OsmAnd/res/layout/item_gpx_stat_block.xml index 18dfa5cdde..dd0ed2a571 100644 --- a/OsmAnd/res/layout/item_gpx_stat_block.xml +++ b/OsmAnd/res/layout/item_gpx_stat_block.xml @@ -10,43 +10,59 @@ android:orientation="horizontal"> + android:gravity="center_vertical" + android:orientation="horizontal" + android:weightSum="2"> - + + + + + From 9d5bd47f4a62f80bdeb17d165cf6bad7a9fde36e Mon Sep 17 00:00:00 2001 From: Skalii Date: Sun, 31 Jan 2021 02:59:28 +0200 Subject: [PATCH 122/125] fix display of distance and direction --- .../SelectedGpxMenuController.java | 4 +++- .../osmand/plus/track/TrackMenuFragment.java | 22 ++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java index 5ea0766469..6e062829a6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java @@ -43,7 +43,9 @@ public class SelectedGpxMenuController extends MenuController { @Override public void buttonPressed() { mapContextMenu.hide(false); - TrackMenuFragment.showInstance(mapActivity, selectedGpxPoint.getSelectedGpxFile()); + WptPt wptPt = selectedGpxPoint.selectedPoint; + LatLon latLon = new LatLon(wptPt.lat, wptPt.lon); + TrackMenuFragment.showInstance(mapActivity, selectedGpxPoint.getSelectedGpxFile(), latLon); } }; leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_open_track); diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index 9147de6de9..4b58c0b9dc 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -149,6 +149,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card private Location lastLocation; private UpdateLocationViewCache updateLocationViewCache; private boolean locationUpdateStarted; + private LatLon latLon; private int menuTitleHeight; private int toolbarHeightPx; @@ -259,6 +260,10 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card this.selectedGpxFile = selectedGpxFile; } + public void setLatLon(LatLon latLon) { + this.latLon = latLon; + } + @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); @@ -556,10 +561,9 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card MapActivity mapActivity = getMapActivity(); View view = overviewCard.getView(); if (mapActivity != null && view != null) { - MapContextMenu menu = mapActivity.getContextMenu(); TextView distanceText = (TextView) view.findViewById(R.id.distance); ImageView direction = (ImageView) view.findViewById(R.id.direction); - app.getUIUtilities().updateLocationView(updateLocationViewCache, direction, distanceText, menu.getLatLon()); + app.getUIUtilities().updateLocationView(updateLocationViewCache, direction, distanceText, latLon); } } @@ -1113,7 +1117,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(path); } if (selectedGpxFile != null) { - showInstance(mapActivity, selectedGpxFile); + showInstance(mapActivity, selectedGpxFile, null); } else if (!Algorithms.isEmpty(path)) { String title = app.getString(R.string.loading_smth, ""); final ProgressDialog progress = ProgressDialog.show(mapActivity, title, app.getString(R.string.loading_data)); @@ -1126,7 +1130,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card if (mapActivity != null) { OsmandApplication app = mapActivity.getMyApplication(); SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().selectGpxFile(result, true, false); - showInstance(mapActivity, selectedGpxFile); + showInstance(mapActivity, selectedGpxFile, null); } if (progress != null && AndroidUtils.isActivityNotDestroyed(mapActivity)) { progress.dismiss(); @@ -1138,7 +1142,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card } } - public static boolean showInstance(@NonNull MapActivity mapActivity, SelectedGpxFile selectedGpxFile) { + public static boolean showInstance(@NonNull MapActivity mapActivity, SelectedGpxFile selectedGpxFile, @Nullable LatLon latLon) { try { Bundle args = new Bundle(); args.putInt(ContextMenuFragment.MENU_STATE_KEY, MenuState.HEADER_ONLY); @@ -1148,6 +1152,14 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card fragment.setRetainInstance(true); fragment.setSelectedGpxFile(selectedGpxFile); + if (latLon != null) { + fragment.setLatLon(latLon); + } else { + QuadRect rect = selectedGpxFile.getGpxFile().getRect(); + LatLon latLonRect = new LatLon(rect.centerY(), rect.centerX()); + fragment.setLatLon(latLonRect); + } + mapActivity.getSupportFragmentManager() .beginTransaction() .replace(R.id.fragmentContainer, fragment, TAG) From bbf341cde2dc6bdc375eb81870bd9cf1e167bf07 Mon Sep 17 00:00:00 2001 From: Skalii Date: Sun, 31 Jan 2021 12:43:14 +0200 Subject: [PATCH 123/125] add column names to the insert script for clarity in which order to insert data --- OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java index b06d3bb1a5..e173a49ad1 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java @@ -94,7 +94,10 @@ public class SavingTrackHelper extends SQLiteOpenHelper { + TRACK_COL_DATE + ", " + TRACK_COL_HEADING + ")" + " VALUES (?, ?, ?, ?, ?, ?, ?)"; //$NON-NLS-1$ //$NON-NLS-2$ - insertPointsScript = "INSERT INTO " + POINT_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; //$NON-NLS-1$ //$NON-NLS-2$ + insertPointsScript = "INSERT INTO " + POINT_NAME + " (" + POINT_COL_LAT + ", " + POINT_COL_LON + ", " + + POINT_COL_DATE + ", " + POINT_COL_DESCRIPTION + ", " + POINT_COL_NAME + ", " + + POINT_COL_CATEGORY + ", " + POINT_COL_COLOR + ", " + POINT_COL_ICON + ", " + + POINT_COL_BACKGROUND + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; //$NON-NLS-1$ //$NON-NLS-2$ } @Override From 29b9d038758e9e537f8b404b7570e1a4904594be Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Sun, 31 Jan 2021 15:34:00 +0200 Subject: [PATCH 124/125] Small fix --- .../osmand/plus/wikipedia/SelectWikiLanguagesBottomSheet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/SelectWikiLanguagesBottomSheet.java b/OsmAnd/src/net/osmand/plus/wikipedia/SelectWikiLanguagesBottomSheet.java index da3b6f106d..2fdf57b9be 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/SelectWikiLanguagesBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/SelectWikiLanguagesBottomSheet.java @@ -212,7 +212,7 @@ public class SelectWikiLanguagesBottomSheet extends MenuBottomSheetDialogFragmen } } else { wikiPlugin.setLanguagesToShow(localesForSaving); - wikiPlugin.setShowAllLanguages(isGlobalWikiPoiEnabled); + wikiPlugin.setShowAllLanguages(global); } wikiPlugin.updateWikipediaState(); From 46559fc3280a4bbb4dd25a4c0e1a4841afdbf5db Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Mon, 1 Feb 2021 01:19:40 +0200 Subject: [PATCH 125/125] Small fix --- .../net/osmand/aidlapi/customization/ProfileSettingsParams.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd-api/src/net/osmand/aidlapi/customization/ProfileSettingsParams.java b/OsmAnd-api/src/net/osmand/aidlapi/customization/ProfileSettingsParams.java index eee80329f7..a22d4e3c91 100644 --- a/OsmAnd-api/src/net/osmand/aidlapi/customization/ProfileSettingsParams.java +++ b/OsmAnd-api/src/net/osmand/aidlapi/customization/ProfileSettingsParams.java @@ -16,7 +16,7 @@ public class ProfileSettingsParams extends AidlParams { public static final String VERSION_KEY = "version"; public static final String REPLACE_KEY = "replace"; - public static final String SILENT_IMPORT_KEY = "silent_import"; + public static final String SILENT_IMPORT_KEY = "silentImport"; public static final String LATEST_CHANGES_KEY = "latestChanges"; public static final String PROFILE_SETTINGS_URI_KEY = "profileSettingsUri"; private Uri profileSettingsUri;