diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml
index 4e5395a04a..d762e0a261 100644
--- a/OsmAnd/AndroidManifest.xml
+++ b/OsmAnd/AndroidManifest.xml
@@ -53,7 +53,8 @@
android:icon="@mipmap/icon" android:label="@string/app_name"
android:name="net.osmand.plus.OsmandApplication" android:configChanges="locale"
android:theme="@style/OsmandDarkTheme" android:restoreAnyVersion="true" android:largeHeap="true"
- android:supportsRtl="true" android:usesCleartextTraffic="true">
+ android:supportsRtl="true" android:usesCleartextTraffic="true"
+ android:hasFragileUserData="true" android:requestLegacyExternalStorage="true">
diff --git a/OsmAnd/build.gradle b/OsmAnd/build.gradle
index c2361dd165..3638a103ca 100644
--- a/OsmAnd/build.gradle
+++ b/OsmAnd/build.gradle
@@ -53,7 +53,7 @@ android {
defaultConfig {
minSdkVersion System.getenv("MIN_SDK_VERSION") ? System.getenv("MIN_SDK_VERSION").toInteger() : 15
- targetSdkVersion 28
+ targetSdkVersion 29
versionCode 390
versionCode System.getenv("APK_NUMBER_VERSION") ? System.getenv("APK_NUMBER_VERSION").toInteger() : versionCode
multiDexEnabled true
diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml
index 616ee0c58c..4cbbedc326 100644
--- a/OsmAnd/res/values-ru/strings.xml
+++ b/OsmAnd/res/values-ru/strings.xml
@@ -3882,7 +3882,7 @@
Остановка записи GPX при принудительном закрытии (через последние приложения). (Из панели уведомлений Android исчезнет значок фонового режима.)
сохранен
Добавьте хотя бы две точки.
- ПОВТОРИТЬ
+ Повторить
• Обновлённая функция планирования маршрута позволяет применять к сегментам разные режимы навигации и настраивать привязку к дорогам
\n
\n • Новые настройки вида треков: выбор цвета и толщины линии, указатели направления, метки начала и конца маршрута
@@ -3920,6 +3920,6 @@
Войти через OAuth
Очистить токен OAuth OpenStreetMap
Выход выполнен
- »в 997777777:66666776666
+ График
Файл уже импортирован
-
\ No newline at end of file
+
diff --git a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java
index 4e9ca3d420..e86b64df43 100644
--- a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java
@@ -46,7 +46,6 @@ import net.osmand.plus.quickaction.QuickActionType;
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
import net.osmand.plus.search.QuickSearchDialogFragment;
import net.osmand.plus.settings.backend.ApplicationMode;
-import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.settings.fragments.BaseSettingsFragment;
@@ -499,6 +498,9 @@ public abstract class OsmandPlugin {
public void mapActivityResume(MapActivity activity) {
}
+ public void mapActivityResumeOnTop(MapActivity activity) {
+ }
+
public void mapActivityPause(MapActivity activity) {
}
@@ -752,6 +754,12 @@ public abstract class OsmandPlugin {
}
}
+ public static void onMapActivityResumeOnTop(MapActivity activity) {
+ for (OsmandPlugin plugin : getEnabledPlugins()) {
+ plugin.mapActivityResumeOnTop(activity);
+ }
+ }
+
public static void onMapActivityPause(MapActivity activity) {
for (OsmandPlugin plugin : getEnabledPlugins()) {
plugin.mapActivityPause(activity);
diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
index 77acb11bf0..53d3fcf473 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
@@ -74,10 +74,6 @@ import net.osmand.plus.OsmAndConstants;
import net.osmand.plus.OsmAndLocationSimulation;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
-import net.osmand.plus.dashboard.DashBaseFragment;
-import net.osmand.plus.helpers.DayNightHelper;
-import net.osmand.plus.settings.backend.CommonPreference;
-import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
@@ -88,6 +84,7 @@ import net.osmand.plus.base.ContextMenuFragment;
import net.osmand.plus.base.FailSafeFuntions;
import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.chooseplan.OsmLiveCancelledDialog;
+import net.osmand.plus.dashboard.DashBaseFragment;
import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.dialogs.CrashBottomSheetDialogFragment;
import net.osmand.plus.dialogs.ImportGpxBottomSheetDialogFragment;
@@ -101,13 +98,14 @@ import net.osmand.plus.download.ui.DataStoragePlaceDialogFragment;
import net.osmand.plus.firstusage.FirstUsageWelcomeFragment;
import net.osmand.plus.firstusage.FirstUsageWizardFragment;
import net.osmand.plus.helpers.AndroidUiHelper;
+import net.osmand.plus.helpers.DayNightHelper;
import net.osmand.plus.helpers.DiscountHelper;
-import net.osmand.plus.importfiles.ImportHelper;
import net.osmand.plus.helpers.IntentHelper;
import net.osmand.plus.helpers.LockHelper;
import net.osmand.plus.helpers.LockHelper.LockUIAdapter;
import net.osmand.plus.helpers.ScrollHelper;
import net.osmand.plus.helpers.ScrollHelper.OnScrollEventListener;
+import net.osmand.plus.importfiles.ImportHelper;
import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.MenuController;
@@ -133,7 +131,9 @@ import net.osmand.plus.search.QuickSearchDialogFragment;
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchTab;
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType;
import net.osmand.plus.settings.backend.ApplicationMode;
+import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.settings.backend.OsmAndAppCustomization.OsmAndAppCustomizationListener;
+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.settings.fragments.ConfigureProfileFragment;
@@ -886,6 +886,13 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
settings.USE_SYSTEM_SCREEN_TIMEOUT.addListener(useSystemScreenTimeoutListener);
}
+ @Override
+ public void onTopResumedActivityChanged(boolean isTopResumedActivity) {
+ if (isTopResumedActivity) {
+ OsmandPlugin.onMapActivityResumeOnTop(this);
+ }
+ }
+
public void applyScreenOrientation() {
if (settings.MAP_SCREEN_ORIENTATION.get() != getRequestedOrientation()) {
setRequestedOrientation(settings.MAP_SCREEN_ORIENTATION.get());
diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java
index a68a8bc749..0a99d15b03 100644
--- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java
+++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java
@@ -893,7 +893,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
}
@Override
- public void mapActivityResume(MapActivity activity) {
+ public void mapActivityResumeOnTop(MapActivity activity) {
this.mapActivity = activity;
// ((AudioManager) activity.getSystemService(Context.AUDIO_SERVICE)).registerMediaButtonEventReceiver(
// new ComponentName(activity, MediaRemoteControlReceiver.class));
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java
index 0bc215c366..c487b7acc6 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java
@@ -632,7 +632,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
iconCategoriesRecyclerView.setAdapter(horizontalSelectionAdapter);
iconCategoriesRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false));
horizontalSelectionAdapter.notifyDataSetChanged();
- iconCategoriesRecyclerView.smoothScrollToPosition(horizontalSelectionAdapter.getItemPosition(selectedIconCategory));
+ iconCategoriesRecyclerView.smoothScrollToPosition(horizontalSelectionAdapter.getItemPositionByTitle(selectedIconCategory));
for (String name : iconNameList) {
selectIcon.addView(createIconItemView(name, selectIcon), new FlowLayout.LayoutParams(0, 0));
}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/HorizontalSelectionAdapter.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/HorizontalSelectionAdapter.java
index 0eb3c3b21e..06783d6f50 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/HorizontalSelectionAdapter.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/HorizontalSelectionAdapter.java
@@ -110,13 +110,16 @@ public class HorizontalSelectionAdapter extends RecyclerView.Adapter getAllRouteSegments() {
- // prepare data for sorting
- List fullList = new ArrayList<>();
- for (Map.Entry, RoadSegmentData> entry : roadSegmentData.entrySet()) {
- fullList.add(new TmpRouteSegmentData(
- entry.getKey().first,
- entry.getKey().second,
- entry.getValue().getSegments()));
- }
- // sorting data by connecting together
- while (fullList.size() > 1) {
- TmpRouteSegmentData firstInList = fullList.get(0);
- for (int i = 1; i < fullList.size(); i++) {
- TmpRouteSegmentData other = fullList.get(i);
- boolean isMatched = false;
-
- if (firstInList.isAfterOf(other)) {
- isMatched = true;
- firstInList.joinBefore(other);
- } else if (firstInList.isBeforeOf(other)) {
- isMatched = true;
- firstInList.joinAfter(other);
- }
-
- if (isMatched) {
- fullList.remove(other);
- break;
+ List allSegments = new ArrayList<>();
+ for (Pair key : getOrderedRoadSegmentDataKeys()) {
+ RoadSegmentData data = roadSegmentData.get(key);
+ if (data != null) {
+ List segments = data.getSegments();
+ if (segments != null) {
+ allSegments.addAll(segments);
}
}
}
- return fullList.size() > 0 ? fullList.get(0).getRouteSegments() : null;
- }
-
- private static class TmpRouteSegmentData {
- private WptPt start;
- private WptPt end;
- private List routeSegments;
-
- public TmpRouteSegmentData(WptPt start, WptPt end,
- List routeSegments) {
- this.start = start;
- this.end = end;
- this.routeSegments = new ArrayList<>(routeSegments);
- }
-
- boolean isAfterOf(TmpRouteSegmentData other) {
- return Algorithms.objectEquals(this.start, other.end);
- }
-
- boolean isBeforeOf(TmpRouteSegmentData other) {
- return Algorithms.objectEquals(this.end, other.start);
- }
-
- void joinAfter(TmpRouteSegmentData other) {
- end = other.end;
- routeSegments.addAll(other.routeSegments);
- }
-
- void joinBefore(TmpRouteSegmentData other) {
- start = other.start;
- routeSegments.addAll(0, other.routeSegments);
- }
-
- public List getRouteSegments() {
- return routeSegments;
- }
+ return allSegments.size() > 0 ? allSegments : null;
}
void splitSegments(int position) {
@@ -501,6 +447,16 @@ public class MeasurementEditingContext {
return res;
}
+ private List> getOrderedRoadSegmentDataKeys() {
+ List> keys = new ArrayList<>();
+ for (List points : Arrays.asList(before.points, after.points)) {
+ for (int i = 0; i < points.size() - 1; i++) {
+ keys.add(new Pair<>(points.get(i), points.get(i + 1)));
+ }
+ }
+ return keys;
+ }
+
private void recreateCacheForSnap(TrkSegment cache, TrkSegment original, boolean calculateIfNeeded) {
boolean hasDefaultModeOnly = true;
if (original.points.size() > 1) {
diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java
index 393dd7d965..b90a22c0b9 100644
--- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java
+++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java
@@ -18,6 +18,7 @@ import net.osmand.osm.edit.Entity.EntityType;
import net.osmand.osm.edit.EntityInfo;
import net.osmand.osm.edit.Node;
import net.osmand.osm.edit.Way;
+import net.osmand.osm.io.Base64;
import net.osmand.osm.io.NetworkUtils;
import net.osmand.osm.io.OsmBaseStorage;
import net.osmand.plus.OsmandApplication;
@@ -30,10 +31,8 @@ import org.apache.commons.logging.Log;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.StringWriter;
+import java.io.*;
+import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.text.MessageFormat;
import java.util.HashMap;
@@ -108,14 +107,16 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
boolean doAuthenticate) {
log.info("Sending request " + url); //$NON-NLS-1$
try {
- if (doAuthenticate){
- OsmOAuthAuthorizationAdapter client = new OsmOAuthAuthorizationAdapter(ctx);
- Response response = client.performRequest(url,requestMethod,requestBody);
- return response.getBody();
- }
- else {
- OsmOAuthAuthorizationAdapter client = new OsmOAuthAuthorizationAdapter(ctx);
- Response response = client.performRequestWithoutAuth(url,requestMethod,requestBody);
+ OsmOAuthAuthorizationAdapter client = new OsmOAuthAuthorizationAdapter(ctx);
+ if (doAuthenticate) {
+ if (client.isValidToken()) {
+ Response response = client.performRequest(url, requestMethod, requestBody);
+ return response.getBody();
+ } else {
+ return performBasicAuthRequest(url, requestMethod, requestBody, userOperation);
+ }
+ } else {
+ Response response = client.performRequestWithoutAuth(url, requestMethod, requestBody);
return response.getBody();
}
} catch (NullPointerException e) {
@@ -135,7 +136,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
log.error(userOperation + " " + ctx.getString(R.string.failed_op), e); //$NON-NLS-1$
showWarning(MessageFormat.format(ctx.getResources().getString(R.string.shared_string_action_template)
+ ": " + ctx.getResources().getString(R.string.shared_string_unexpected_error), userOperation));
- } catch (ExecutionException e) {
+ } catch (Exception e) {
log.error(userOperation + " " + ctx.getString(R.string.failed_op), e); //$NON-NLS-1$
showWarning(MessageFormat.format(ctx.getResources().getString(R.string.shared_string_action_template)
+ ": " + ctx.getResources().getString(R.string.shared_string_unexpected_error), userOperation));
@@ -144,6 +145,55 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
return null;
}
+ private String performBasicAuthRequest(String url, String requestMethod, String requestBody, String userOperation) throws IOException {
+ HttpURLConnection connection = NetworkUtils.getHttpURLConnection(url);
+ connection.setConnectTimeout(15000);
+ connection.setRequestMethod(requestMethod);
+ connection.setRequestProperty("User-Agent", Version.getFullVersion(ctx)); //$NON-NLS-1$
+ StringBuilder responseBody = new StringBuilder();
+ String token = settings.USER_NAME.get() + ":" + settings.USER_PASSWORD.get(); //$NON-NLS-1$
+ connection.addRequestProperty("Authorization", "Basic " + Base64.encode(token.getBytes("UTF-8"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ connection.setDoInput(true);
+ if (requestMethod.equals("PUT") || requestMethod.equals("POST") || requestMethod.equals("DELETE")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ connection.setDoOutput(true);
+ connection.setRequestProperty("Content-type", "text/xml"); //$NON-NLS-1$ //$NON-NLS-2$
+ OutputStream out = connection.getOutputStream();
+ if (requestBody != null) {
+ BufferedWriter bwr = new BufferedWriter(new OutputStreamWriter(out, "UTF-8"), 1024); //$NON-NLS-1$
+ bwr.write(requestBody);
+ bwr.flush();
+ }
+ out.close();
+ }
+ connection.connect();
+ if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
+ String msg = userOperation
+ + " " + ctx.getString(R.string.failed_op) + " : " + connection.getResponseMessage(); //$NON-NLS-1$//$NON-NLS-2$
+ log.error(msg);
+ showWarning(msg);
+ } else {
+ log.info("Response : " + connection.getResponseMessage()); //$NON-NLS-1$
+ // populate return fields.
+ responseBody.setLength(0);
+ InputStream i = connection.getInputStream();
+ if (i != null) {
+ BufferedReader in = new BufferedReader(new InputStreamReader(i, "UTF-8"), 256); //$NON-NLS-1$
+ String s;
+ boolean f = true;
+ while ((s = in.readLine()) != null) {
+ if (!f) {
+ responseBody.append("\n"); //$NON-NLS-1$
+ } else {
+ f = false;
+ }
+ responseBody.append(s);
+ }
+ }
+ return responseBody.toString();
+ }
+ return null;
+ }
+
public long openChangeSet(String comment) {
long id = -1;
StringWriter writer = new StringWriter(256);
diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/VehicleParametersBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/VehicleParametersBottomSheet.java
index 9d3275e8fd..b3f160f910 100644
--- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/VehicleParametersBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/VehicleParametersBottomSheet.java
@@ -122,7 +122,7 @@ public class VehicleParametersBottomSheet extends BasePreferenceBottomSheet {
}
selectedItem = preference.getEntryFromValue(String.valueOf(currentValue));
adapter.setSelectedItemByTitle(selectedItem);
- int itemPosition = adapter.getItemPosition(selectedItem);
+ int itemPosition = adapter.getItemPositionByTitle(selectedItem);
if (itemPosition >= 0) {
recyclerView.smoothScrollToPosition(itemPosition);
}