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 23/65] 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 13:43:45 +0100
Subject: [PATCH 24/65] clean up setup files
---
.gitignore | 3 ++-
plugins/Osmand-Nautical/.classpath | 9 -------
plugins/Osmand-Nautical/.project | 33 -------------------------
plugins/Osmand-ParkingPlugin/.classpath | 9 -------
plugins/Osmand-ParkingPlugin/.project | 33 -------------------------
plugins/Osmand-SRTMPlugin/.classpath | 9 -------
plugins/Osmand-SRTMPlugin/.project | 33 -------------------------
plugins/Osmand-Skimaps/.classpath | 9 -------
plugins/Osmand-Skimaps/.project | 33 -------------------------
9 files changed, 2 insertions(+), 169 deletions(-)
delete mode 100644 plugins/Osmand-Nautical/.classpath
delete mode 100644 plugins/Osmand-Nautical/.project
delete mode 100644 plugins/Osmand-ParkingPlugin/.classpath
delete mode 100644 plugins/Osmand-ParkingPlugin/.project
delete mode 100644 plugins/Osmand-SRTMPlugin/.classpath
delete mode 100644 plugins/Osmand-SRTMPlugin/.project
delete mode 100644 plugins/Osmand-Skimaps/.classpath
delete mode 100644 plugins/Osmand-Skimaps/.project
diff --git a/.gitignore b/.gitignore
index 33e746a3d6..7386d5e61e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,7 +16,8 @@ OsmAndCore_*.aar
*.iml
.settings
.idea
-.project
+**/.project
+**/.classpath
out/
# Huawei
diff --git a/plugins/Osmand-Nautical/.classpath b/plugins/Osmand-Nautical/.classpath
deleted file mode 100644
index 7bc01d9a9c..0000000000
--- a/plugins/Osmand-Nautical/.classpath
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/plugins/Osmand-Nautical/.project b/plugins/Osmand-Nautical/.project
deleted file mode 100644
index 69d5b60769..0000000000
--- a/plugins/Osmand-Nautical/.project
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
- Osmand-Nautical
-
-
-
-
-
- com.android.ide.eclipse.adt.ResourceManagerBuilder
-
-
-
-
- com.android.ide.eclipse.adt.PreCompilerBuilder
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- com.android.ide.eclipse.adt.ApkBuilder
-
-
-
-
-
- com.android.ide.eclipse.adt.AndroidNature
- org.eclipse.jdt.core.javanature
-
-
diff --git a/plugins/Osmand-ParkingPlugin/.classpath b/plugins/Osmand-ParkingPlugin/.classpath
deleted file mode 100644
index 7bc01d9a9c..0000000000
--- a/plugins/Osmand-ParkingPlugin/.classpath
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/plugins/Osmand-ParkingPlugin/.project b/plugins/Osmand-ParkingPlugin/.project
deleted file mode 100644
index 1c708327e5..0000000000
--- a/plugins/Osmand-ParkingPlugin/.project
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
- Osmand-ParkingPlugin
-
-
-
-
-
- com.android.ide.eclipse.adt.ResourceManagerBuilder
-
-
-
-
- com.android.ide.eclipse.adt.PreCompilerBuilder
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- com.android.ide.eclipse.adt.ApkBuilder
-
-
-
-
-
- com.android.ide.eclipse.adt.AndroidNature
- org.eclipse.jdt.core.javanature
-
-
diff --git a/plugins/Osmand-SRTMPlugin/.classpath b/plugins/Osmand-SRTMPlugin/.classpath
deleted file mode 100644
index 7bc01d9a9c..0000000000
--- a/plugins/Osmand-SRTMPlugin/.classpath
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/plugins/Osmand-SRTMPlugin/.project b/plugins/Osmand-SRTMPlugin/.project
deleted file mode 100644
index 6c3b83059d..0000000000
--- a/plugins/Osmand-SRTMPlugin/.project
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
- Osmand-SRTMPlugin
-
-
-
-
-
- com.android.ide.eclipse.adt.ResourceManagerBuilder
-
-
-
-
- com.android.ide.eclipse.adt.PreCompilerBuilder
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- com.android.ide.eclipse.adt.ApkBuilder
-
-
-
-
-
- com.android.ide.eclipse.adt.AndroidNature
- org.eclipse.jdt.core.javanature
-
-
diff --git a/plugins/Osmand-Skimaps/.classpath b/plugins/Osmand-Skimaps/.classpath
deleted file mode 100644
index 7bc01d9a9c..0000000000
--- a/plugins/Osmand-Skimaps/.classpath
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/plugins/Osmand-Skimaps/.project b/plugins/Osmand-Skimaps/.project
deleted file mode 100644
index 852dfb35a5..0000000000
--- a/plugins/Osmand-Skimaps/.project
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
- Osmand-SkiMaps
-
-
-
-
-
- com.android.ide.eclipse.adt.ResourceManagerBuilder
-
-
-
-
- com.android.ide.eclipse.adt.PreCompilerBuilder
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- com.android.ide.eclipse.adt.ApkBuilder
-
-
-
-
-
- com.android.ide.eclipse.adt.AndroidNature
- org.eclipse.jdt.core.javanature
-
-
From 9c08af0ecb4b4e59bb36de9a60b0a7d906b743ca Mon Sep 17 00:00:00 2001
From: Skalii
Date: Tue, 2 Feb 2021 14:55:41 +0200
Subject: [PATCH 25/65] 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 26/65] 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 bb9a05766593a4f05f702801944be496ed7ba484 Mon Sep 17 00:00:00 2001
From: Victor Shcherb
Date: Tue, 2 Feb 2021 15:40:48 +0100
Subject: [PATCH 27/65] Add route activity type class
---
.../net/osmand/osm/RouteActivityType.java | 218 ++++++++++++++++++
1 file changed, 218 insertions(+)
create mode 100644 OsmAnd-java/src/main/java/net/osmand/osm/RouteActivityType.java
diff --git a/OsmAnd-java/src/main/java/net/osmand/osm/RouteActivityType.java b/OsmAnd-java/src/main/java/net/osmand/osm/RouteActivityType.java
new file mode 100644
index 0000000000..28c9b11551
--- /dev/null
+++ b/OsmAnd-java/src/main/java/net/osmand/osm/RouteActivityType.java
@@ -0,0 +1,218 @@
+package net.osmand.osm;
+
+public enum RouteActivityType {
+ WATER("Water", "yellow"), WINTER("Winter", "yellow"), SNOWMOBILE("Snowmobile", "yellow"), RIDING("Riding", "yellow"), RACING("Racing", "yellow"),
+ MOUNTAINBIKE("Mountainbike", "blue"), CYCLING("Cycling", "blue"),
+ HIKING("Hiking", "orange"), RUNNING("Running", "orange"), WALKING("Walking", "orange"),
+ OFFROAD("Off-road", "yellow"),
+ MOTORBIKE("Motorbike", "green"), CAR("Car", "green");
+ // less specific bottom order
+
+ String name;
+ String color;
+
+ private RouteActivityType(String nm, String clr) {
+ this.name = nm;
+ this.color = clr;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getColor() {
+ return color;
+ }
+
+ public static RouteActivityType getTypeFromTags(String[] tags) {
+ RouteActivityType activityType = null;
+ for (String tg : tags) {
+ RouteActivityType rat = RouteActivityType.convertFromOsmGPXTag(tg);
+ if (rat != null) {
+ if (activityType == null || activityType.ordinal() > rat.ordinal()) {
+ activityType = rat;
+ }
+ }
+ }
+ return activityType;
+ }
+
+ public static RouteActivityType convertFromOsmGPXTag(String tg) {
+ String t = tg.toLowerCase();
+ if ("mountain hiking".equalsIgnoreCase(t)) {
+ return HIKING;
+ }
+ if ("motorcar".equalsIgnoreCase(t)) {
+ return CAR;
+ }
+ if ("laufen".equalsIgnoreCase(t)) {
+ return RUNNING;
+ }
+ if ("pedestrian".equalsIgnoreCase(t)) {
+ return WALKING;
+ }
+ switch (t) {
+ case "mountainbiking":
+ case "mtb":
+ case "mountainbike":
+ case "mountain bike":
+ case "mountain biking":
+ case "mountbarker":
+ case "mtb-tour":
+ case "ciclismo-mtb-gravel":
+ case "vtt":
+ case "btt":
+ case "vth":
+ case "mtb ride":
+ return MOUNTAINBIKE;
+ case "hiking":
+ case "route=hiking":
+ case "mountain hiking":
+ case "hiking trail":
+ case "wandern":
+ case "hike":
+ case "randonnée":
+ case "trekking":
+ case "climbing":
+ return HIKING;
+ case "bike":
+ case "biking":
+ case "bicycling":
+ case "bicycle":
+ case "cycling":
+ case "cycle":
+ case "cycleway":
+ case "cykel":
+ case "handcycle":
+ case "cyclotourisme":
+ case "route=bicycle":
+ case "cyclotourism":
+ case "fietsen":
+ case "вело":
+ case "велосипед":
+ case "rower":
+ case "trasa rowerem":
+ case "vélo":
+ case "velo":
+ case "radtour":
+ case "bici":
+ case "fiets":
+ case "fahrrad":
+ case "ncn":
+ case "icn":
+ case "lcn":
+ case "network=ncn":
+ case "network=icn":
+ case "network=lcn":
+ return CYCLING;
+ case "car":
+ case "motorcar":
+ case "by car":
+ case "auto":
+ case "автомобиль":
+ case "automobile":
+ case "autós":
+ case "driving":
+ case "drive":
+ case "van":
+ case "авто":
+ case "на автомобиле":
+ case "bus":
+ case "truck":
+ case "taxi":
+ return CAR;
+ case "running":
+ case "run":
+ case "rungis":
+ case "trail running":
+ case "trailrunning":
+ case "бег":
+ case "laufen":
+ case "langlauf":
+ case "lauf":
+ case "course":
+ case "jogging":
+ case "fitotrack":
+ return RUNNING;
+ case "wanderung":
+ case "walking":
+ case "walk":
+ case "nightwalk":
+ case "walkway":
+ case "пешком":
+ case "пеший":
+ case "pěšky":
+ case "marche":
+ case "pedestrian":
+ case "foot":
+ case "footing":
+ case "on_foot":
+ case "byfoot":
+ case "onfoot":
+ case "sightseeing":
+ case "geocaching":
+ case "etnanatura":
+ case "etna":
+ case "iwn":
+ case "lwn":
+ case "rwn":
+ case "network=iwn":
+ case "network=lwn":
+ case "network=rwn":
+ return WALKING;
+ case "ling-moto":
+ case "motorbiking":
+ case "motorcycle":
+ case "motorrad":
+ case "motorbike":
+ case "motor bike":
+ case "FVbike":
+ case "Motorrad":
+ return MOTORBIKE;
+ case "offroad":
+ case "off-road":
+ case "off road":
+ case "4x4":
+ case "terrain":
+ case "quad":
+ case "enduro":
+ case "feldwege":
+ case "feldweg":
+ return OFFROAD;
+ case "boat":
+ case "water":
+ case "boating":
+ case "kayak":
+ case "river":
+ case "lake":
+ case "lakes":
+ case "canal":
+ return WATER;
+ case "ski":
+ case "skiing":
+ case "skating":
+ case "skitour":
+ case "winter":
+ case "wintersports":
+ case "snowboard":
+ case "лыжи":
+ case "лыжня":
+ case "nordic":
+ case "piste":
+ return WINTER;
+ case "snowmobile=designated":
+ case "snowmobile=permissive":
+ case "snowmobile=yes":
+ case "snowmobile":
+ return SNOWMOBILE;
+ case "ride":
+ case "horse":
+ case "horse trail":
+ return RIDING;
+ case "racing":
+ return RACING;
+ }
+ return null;
+ }
+
+}
\ No newline at end of file
From e57404470dde5d2e7106f5dfaa59ad9f192e6258 Mon Sep 17 00:00:00 2001
From: nnngrach
Date: Tue, 2 Feb 2021 18:40:12 +0300
Subject: [PATCH 28/65] 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
Date: Tue, 2 Feb 2021 22:25:17 +0200
Subject: [PATCH 29/65] Fix possible npe
---
...gureAppModesBottomSheetDialogFragment.java | 21 +++++++++++++---
.../MapRouteInfoMenu.java | 24 ++++++++++---------
2 files changed, 31 insertions(+), 14 deletions(-)
diff --git a/OsmAnd/src/net/osmand/plus/profiles/ConfigureAppModesBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/profiles/ConfigureAppModesBottomSheetDialogFragment.java
index ab59432b01..687cd342bf 100644
--- a/OsmAnd/src/net/osmand/plus/profiles/ConfigureAppModesBottomSheetDialogFragment.java
+++ b/OsmAnd/src/net/osmand/plus/profiles/ConfigureAppModesBottomSheetDialogFragment.java
@@ -1,7 +1,11 @@
package net.osmand.plus.profiles;
-import net.osmand.plus.settings.backend.ApplicationMode;
+import androidx.annotation.NonNull;
+import androidx.fragment.app.FragmentManager;
+
import net.osmand.plus.R;
+import net.osmand.plus.profiles.ConfigureProfileMenuAdapter.ProfileSelectedListener;
+import net.osmand.plus.settings.backend.ApplicationMode;
import java.util.ArrayList;
import java.util.HashSet;
@@ -9,8 +13,8 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
-public class ConfigureAppModesBottomSheetDialogFragment extends AppModesBottomSheetDialogFragment
- implements ConfigureProfileMenuAdapter.ProfileSelectedListener {
+public class ConfigureAppModesBottomSheetDialogFragment extends AppModesBottomSheetDialogFragment
+ implements ProfileSelectedListener {
public static final String TAG = "ConfigureAppModesBottomSheetDialogFragment";
@@ -56,4 +60,15 @@ public class ConfigureAppModesBottomSheetDialogFragment extends AppModesBottomSh
}
ApplicationMode.changeProfileAvailability(item, isChecked, getMyApplication());
}
+
+ public static void showInstance(@NonNull FragmentManager fragmentManager, boolean usedOnMap, UpdateMapRouteMenuListener listener) {
+ if (fragmentManager.findFragmentByTag(TAG) == null) {
+ ConfigureAppModesBottomSheetDialogFragment fragment = new ConfigureAppModesBottomSheetDialogFragment();
+ fragment.setUsedOnMap(usedOnMap);
+ fragment.setUpdateMapRouteMenuListener(listener);
+ fragmentManager.beginTransaction()
+ .add(fragment, TAG)
+ .commitAllowingStateLoss();
+ }
+ }
}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
index a6b69ba124..83a866c49e 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java
@@ -29,6 +29,8 @@ import androidx.appcompat.content.res.AppCompatResources;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentActivity;
+import androidx.fragment.app.FragmentManager;
import androidx.transition.AutoTransition;
import androidx.transition.Scene;
import androidx.transition.Transition;
@@ -71,7 +73,7 @@ import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenuFragment;
import net.osmand.plus.mapmarkers.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkerSelectionFragment;
import net.osmand.plus.poi.PoiUIFilter;
-import net.osmand.plus.profiles.AppModesBottomSheetDialogFragment;
+import net.osmand.plus.profiles.AppModesBottomSheetDialogFragment.UpdateMapRouteMenuListener;
import net.osmand.plus.profiles.ConfigureAppModesBottomSheetDialogFragment;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidPTTypesRoutingParameter;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidRoadsRoutingParameter;
@@ -870,16 +872,16 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
}
private void showProfileBottomSheetDialog() {
- final AppModesBottomSheetDialogFragment fragment = new ConfigureAppModesBottomSheetDialogFragment();
- fragment.setUsedOnMap(true);
- fragment.setUpdateMapRouteMenuListener(new AppModesBottomSheetDialogFragment.UpdateMapRouteMenuListener() {
- @Override
- public void updateAppModeMenu() {
- updateApplicationModes();
- }
- });
- getMapActivity().getSupportFragmentManager().beginTransaction()
- .add(fragment, ConfigureAppModesBottomSheetDialogFragment.TAG).commitAllowingStateLoss();
+ FragmentActivity activity = getMapActivity();
+ if (activity != null) {
+ FragmentManager manager = activity.getSupportFragmentManager();
+ ConfigureAppModesBottomSheetDialogFragment.showInstance(manager, true, new UpdateMapRouteMenuListener() {
+ @Override
+ public void updateAppModeMenu() {
+ updateApplicationModes();
+ }
+ });
+ }
}
private void updateApplicationMode(ApplicationMode mode, ApplicationMode next) {
From 6a38b44e5fff8dd8de62e9e40c84fcd67c5f42f9 Mon Sep 17 00:00:00 2001
From: Vitaliy
Date: Tue, 2 Feb 2021 23:25:45 +0200
Subject: [PATCH 30/65] Fix possible npe
---
.../net/osmand/plus/osmedit/DashOsmEditsFragment.java | 6 ++++--
.../net/osmand/plus/osmedit/EditPOIMenuController.java | 10 +++++-----
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java
index de5e538554..ddd601731a 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java
@@ -28,7 +28,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import static net.osmand.plus.osmedit.oauth.OsmOAuthHelper.*;
+import static net.osmand.plus.osmedit.oauth.OsmOAuthHelper.OsmAuthorizationListener;
/**
* Created by Denis
@@ -149,7 +149,9 @@ public class DashOsmEditsFragment extends DashBaseFragment
@Override
public void authorizationCompleted() {
- SendPoiBottomSheetFragment.showInstance(getChildFragmentManager(), new OsmPoint[]{selectedPoint});
+ if (selectedPoint != null) {
+ SendPoiBottomSheetFragment.showInstance(getChildFragmentManager(), new OsmPoint[] {selectedPoint});
+ }
}
@Override
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java
index 3c64fb12d7..877ebae773 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java
@@ -5,6 +5,7 @@ import android.graphics.drawable.Drawable;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.FragmentManager;
import net.osmand.data.PointDescription;
import net.osmand.osm.PoiType;
@@ -54,16 +55,15 @@ public class EditPOIMenuController extends MenuController {
|| !Algorithms.isEmpty(settings.USER_NAME.get())
&& !Algorithms.isEmpty(settings.USER_PASSWORD.get());
+ FragmentManager fragmentManager = activity.getSupportFragmentManager();
if (point instanceof OpenstreetmapPoint) {
if (isLogged) {
- SendPoiBottomSheetFragment.showInstance(activity.getSupportFragmentManager(),
- new OsmPoint[]{getOsmPoint()});
+ SendPoiBottomSheetFragment.showInstance(fragmentManager, new OsmPoint[] {point});
} else {
- LoginBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), null);
+ LoginBottomSheetFragment.showInstance(fragmentManager, null);
}
} else if (point instanceof OsmNotesPoint) {
- SendOsmNoteBottomSheetFragment.showInstance(activity.getSupportFragmentManager(),
- new OsmPoint[]{getOsmPoint()});
+ SendOsmNoteBottomSheetFragment.showInstance(fragmentManager, new OsmPoint[] {point});
}
}
}
From 6dcde54ace36f6668fd8e43f8f4b2b2267932355 Mon Sep 17 00:00:00 2001
From: Vitaliy
Date: Wed, 3 Feb 2021 11:41:56 +0200
Subject: [PATCH 31/65] Fix check for default profile
---
.../net/osmand/plus/settings/backend/ApplicationMode.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java b/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java
index 59d8172bb1..efb02fefc0 100644
--- a/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java
+++ b/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java
@@ -301,7 +301,12 @@ public class ApplicationMode {
}
public boolean isCustomProfile() {
- return !defaultValues.contains(this);
+ for (ApplicationMode mode : defaultValues) {
+ if (Algorithms.stringsEqual(mode.getStringKey(), getStringKey())) {
+ return false;
+ }
+ }
+ return true;
}
public boolean isDerivedRoutingFrom(ApplicationMode mode) {
From 95cc20b022bc7fe2374d8bd361ebcd9342a90030 Mon Sep 17 00:00:00 2001
From: Vitaliy
Date: Wed, 3 Feb 2021 11:52:51 +0200
Subject: [PATCH 32/65] Add check for available oauth request token
---
.../oauth/OsmOAuthAuthorizationClient.java | 4 ++++
.../oauth/OsmOAuthAuthorizationAdapter.java | 20 ++++++-------------
2 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/OsmAnd-java/src/main/java/net/osmand/osm/oauth/OsmOAuthAuthorizationClient.java b/OsmAnd-java/src/main/java/net/osmand/osm/oauth/OsmOAuthAuthorizationClient.java
index cf2f5a5acc..02a576db5a 100644
--- a/OsmAnd-java/src/main/java/net/osmand/osm/oauth/OsmOAuthAuthorizationClient.java
+++ b/OsmAnd-java/src/main/java/net/osmand/osm/oauth/OsmOAuthAuthorizationClient.java
@@ -94,6 +94,10 @@ public class OsmOAuthAuthorizationClient {
return accessToken;
}
+ public OAuth1RequestToken getRequestToken() {
+ return requestToken;
+ }
+
public Response performRequestWithoutAuth(String url, String requestMethod, String requestBody)
throws InterruptedException, ExecutionException, IOException {
Verb verb = parseRequestMethod(requestMethod);
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthAuthorizationAdapter.java b/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthAuthorizationAdapter.java
index abc5d1f407..c45ebaaf5e 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthAuthorizationAdapter.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthAuthorizationAdapter.java
@@ -1,19 +1,10 @@
package net.osmand.plus.osmedit.oauth;
import android.content.Context;
-import android.content.Intent;
import android.net.TrafficStats;
import android.net.Uri;
import android.os.AsyncTask;
-import android.os.Build;
-import android.view.View;
import android.view.ViewGroup;
-import android.webkit.WebView;
-import android.webkit.WebViewClient;
-
-import androidx.annotation.NonNull;
-import androidx.browser.customtabs.CustomTabsIntent;
-import androidx.core.content.ContextCompat;
import com.github.scribejava.core.builder.api.DefaultApi10a;
import com.github.scribejava.core.model.OAuth1AccessToken;
@@ -24,7 +15,6 @@ import com.github.scribejava.core.model.Verb;
import net.osmand.PlatformUtil;
import net.osmand.osm.oauth.OsmOAuthAuthorizationClient;
-import net.osmand.plus.OsmAndConstants;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.wikipedia.WikipediaDialogFragment;
@@ -137,7 +127,7 @@ public class OsmOAuthAuthorizationAdapter {
}
@Override
- protected void onPostExecute(@NonNull OAuth1RequestToken requestToken) {
+ protected void onPostExecute(OAuth1RequestToken requestToken) {
if (requestToken != null) {
loadWebView(rootLayout, nightMode, client.getService().getAuthorizationUrl(requestToken));
} else {
@@ -156,9 +146,11 @@ public class OsmOAuthAuthorizationAdapter {
@Override
protected Void doInBackground(String... oauthVerifier) {
- client.authorize(oauthVerifier[0]);
- saveToken();
- updateUserName();
+ if (client.getRequestToken() != null) {
+ client.authorize(oauthVerifier[0]);
+ saveToken();
+ updateUserName();
+ }
return null;
}
From 638489fcdf60e42c8949f5caee71f3e932c09239 Mon Sep 17 00:00:00 2001
From: Vitaliy
Date: Wed, 3 Feb 2021 12:30:54 +0200
Subject: [PATCH 33/65] Fix possible npe after new wpt point was added
---
.../res/layout/map_context_menu_fragment.xml | 7 +++++++
.../MapContextMenuFragment.java | 21 ++++++++++++++-----
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml
index 7a57679825..998123115d 100644
--- a/OsmAnd/res/layout/map_context_menu_fragment.xml
+++ b/OsmAnd/res/layout/map_context_menu_fragment.xml
@@ -61,6 +61,13 @@
android:layout_gravity="center_vertical"
android:text="@string/amenity_type_finance"/>
+
+