From ac1168664694563d470739c428b4dbc49347da42 Mon Sep 17 00:00:00 2001 From: cepprice Date: Tue, 2 Feb 2021 15:56:57 +0500 Subject: [PATCH 1/5] Fix #10540 --- .../activities/FavoritesTreeFragment.java | 58 ++++++++++--------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java index 866503f477..06e71c1bfd 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java @@ -10,6 +10,7 @@ import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.text.Html; +import android.text.Spanned; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -606,29 +607,34 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen } } - private StringBuilder generateHtmlPrint(List groups) { + private String generateHtmlPrint(List groups) { StringBuilder html = new StringBuilder(); html.append("

My Favorites

"); + + int MAX_AMOUNT_OF_POINTS = 100; + int addedPoints = 0; for (FavoriteGroup group : groups) { html.append("

" + group.getDisplayName(app) + "

"); for (FavouritePoint fp : group.getPoints()) { - String url = "geo:" + ((float) fp.getLatitude()) + "," + ((float) fp.getLongitude()) + "?m=" + fp.getName(); - html.append("

" + fp.getDisplayName(app) + " - " + "geo:" - + ((float) fp.getLatitude()) + "," + ((float) fp.getLongitude()) + "
"); - if (fp.isAddressSpecified()) { - html.append(": " + fp.getAddress()); - html.append("
"); + if (addedPoints >= MAX_AMOUNT_OF_POINTS) { + break; } - if (!Algorithms.isEmpty(fp.getDescription())) { - html.append(": " + fp.getDescription()); - } - html.append("

"); + + float lat = (float) fp.getLatitude(); + float lon = (float) fp.getLongitude(); + String url = "geo:" + lat + "," + lon + "?m=" + fp.getName(); + html.append("

" + fp.getDisplayName(app) + " - geo:" + + lat + "," + lon + "

"); + addedPoints++; + } + if (addedPoints >= MAX_AMOUNT_OF_POINTS) { + html.append("

...

"); + break; } } - return html; + return html.toString(); } - private void shareFavourites() { if (favouritesAdapter.isEmpty()) { Toast.makeText(getActivity(), R.string.no_fav_to_save, Toast.LENGTH_LONG).show(); @@ -646,6 +652,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen File src = null; File dst = null; + Spanned descriptionOfPoints; @Override protected void onPreExecute() { @@ -662,9 +669,15 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen @Override protected Void doInBackground(Void... params) { + List groups; if (group != null) { helper.saveFile(group.getPoints(), dst); + groups = new ArrayList<>(); + groups.add(group); + } else { + groups = getMyApplication().getFavorites().getFavoriteGroups(); } + descriptionOfPoints = Html.fromHtml(generateHtmlPrint(groups)); return null; } @@ -680,19 +693,12 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen Algorithms.fileCopy(src, dst); } final Intent sendIntent = new Intent(); - sendIntent.setAction(Intent.ACTION_SEND); - List groups; - if (group != null) { - groups = new ArrayList<>(); - groups.add(group); - } else { - groups = getMyApplication().getFavorites().getFavoriteGroups(); - } - sendIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(generateHtmlPrint(groups).toString())); - sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_fav_subject)); - sendIntent.putExtra(Intent.EXTRA_STREAM, AndroidUtils.getUriForFile(getMyApplication(), dst)); - sendIntent.setType("text/plain"); - sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + sendIntent.setAction(Intent.ACTION_SEND) + .putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_fav_subject)) + .putExtra(Intent.EXTRA_TEXT, descriptionOfPoints) + .putExtra(Intent.EXTRA_STREAM, AndroidUtils.getUriForFile(getMyApplication(), dst)) + .setType("text/plain") + .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(sendIntent); } catch (IOException e) { Toast.makeText(getActivity(), "Error sharing favorites: " + e.getMessage(), Toast.LENGTH_SHORT).show(); From bc63b01ad2bd682b399deeba371433022b04651b Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Tue, 2 Feb 2021 14:15:42 +0200 Subject: [PATCH 2/5] toggle hilshade fix --- OsmAnd/res/layout/center_button_container.xml | 2 +- OsmAnd/res/layout/custom_radio_buttons.xml | 5 +++-- OsmAnd/res/layout/left_button_container.xml | 2 +- OsmAnd/res/layout/right_button_container.xml | 2 +- OsmAnd/src/net/osmand/plus/UiUtilities.java | 21 +++++++++++-------- .../plus/myplaces/GPXItemPagerAdapter.java | 6 +++++- 6 files changed, 23 insertions(+), 15 deletions(-) diff --git a/OsmAnd/res/layout/center_button_container.xml b/OsmAnd/res/layout/center_button_container.xml index 99858650dc..05fa83eae0 100644 --- a/OsmAnd/res/layout/center_button_container.xml +++ b/OsmAnd/res/layout/center_button_container.xml @@ -8,7 +8,7 @@ android:layout_weight="1"> @@ -22,7 +22,8 @@ layout="@layout/center_button_container" android:layout_width="0dp" android:layout_height="match_parent" - android:layout_weight="1" /> + android:layout_weight="1" + android:visibility="gone" /> Date: Tue, 2 Feb 2021 14:55:41 +0200 Subject: [PATCH 3/5] fix speed unit setting for "min/km" to show seconds instead of fractional minutes --- OsmAnd/src/net/osmand/plus/OsmAndFormatter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java index 11267b0286..6a52fe9804 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java @@ -344,8 +344,8 @@ public class OsmAndFormatter { if (minperkm >= 10) { return ((int) Math.round(minperkm)) + " " + mc.toShortString(ctx); } else { - int mph10 = (int) Math.round(minperkm * 10f); - return (mph10 / 10f) + " " + mc.toShortString(ctx); + int seconds = Math.round(minperkm * 60); + return Algorithms.formatDuration(seconds, false) + " " + mc.toShortString(ctx); } } else if (mc == SpeedConstants.MINUTES_PER_MILE) { if (metersperseconds < 0.111111111) { From 31d31f10235ea674cccdb8a5ecf1aea76a7af1ce Mon Sep 17 00:00:00 2001 From: cepprice Date: Tue, 2 Feb 2021 18:41:11 +0500 Subject: [PATCH 4/5] Small edit --- .../activities/FavoritesTreeFragment.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java index 06e71c1bfd..823cb4b740 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java @@ -89,6 +89,8 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen public static final int IMPORT_FAVOURITES_ID = 7; public static final String GROUP_EXPANDED_POSTFIX = "_group_expanded"; + private static final int MAX_POINTS_IN_DESCRIPTION = 100; + private FavouritesAdapter favouritesAdapter; private FavouritesDbHelper helper; @@ -611,23 +613,28 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen StringBuilder html = new StringBuilder(); html.append("

My Favorites

"); - int MAX_AMOUNT_OF_POINTS = 100; int addedPoints = 0; for (FavoriteGroup group : groups) { - html.append("

" + group.getDisplayName(app) + "

"); + html.append("

").append(group.getDisplayName(app)).append("

"); for (FavouritePoint fp : group.getPoints()) { - if (addedPoints >= MAX_AMOUNT_OF_POINTS) { + if (addedPoints >= MAX_POINTS_IN_DESCRIPTION) { break; } float lat = (float) fp.getLatitude(); float lon = (float) fp.getLongitude(); String url = "geo:" + lat + "," + lon + "?m=" + fp.getName(); - html.append("

" + fp.getDisplayName(app) + " - geo:" - + lat + "," + lon + "

"); + html.append("

") + .append(fp.getDisplayName(app)) + .append(" - geo:") + .append(lat).append(",").append(lon) + .append("

"); addedPoints++; } - if (addedPoints >= MAX_AMOUNT_OF_POINTS) { + + if (addedPoints >= MAX_POINTS_IN_DESCRIPTION) { html.append("

...

"); break; } From e57404470dde5d2e7106f5dfaa59ad9f192e6258 Mon Sep 17 00:00:00 2001 From: nnngrach Date: Tue, 2 Feb 2021 18:40:12 +0300 Subject: [PATCH 5/5] add default profile name for unnamed or missing improted profiles. --- .../plus/settings/backend/backup/ProfileSettingsItem.java | 2 +- .../plus/settings/fragments/DuplicatesSettingsAdapter.java | 7 ++++++- .../plus/settings/fragments/ExportItemsBottomSheet.java | 7 ++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/ProfileSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/ProfileSettingsItem.java index b0bfd5be61..88405fd010 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/ProfileSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/ProfileSettingsItem.java @@ -124,7 +124,7 @@ public class ProfileSettingsItem extends OsmandSettingsItem { if (Algorithms.isEmpty(modeBean.userProfileName)) { ApplicationMode appMode = ApplicationMode.valueOfStringKey(modeBean.stringKey, null); if (appMode != null) { - modeBean.userProfileName = app.getString(appMode.getNameKeyResource()); + modeBean.userProfileName = appMode.toHumanString(); } } int number = 0; diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java index 5d9e3af28a..078197da4f 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java @@ -34,6 +34,7 @@ import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean; import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; +import org.apache.commons.lang3.StringUtils; import java.io.File; import java.util.List; @@ -91,7 +92,11 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter