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/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"/>
+
+
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
index 7977a9ddc6..a3026eda83 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
@@ -58,6 +58,7 @@ import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.LockableScrollView;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.settings.backend.MainContextMenuItemsSettings;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
@@ -1674,6 +1675,12 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
line2MeasuredHeight = line2.getMeasuredHeight();
}
+ int customAddressLineHeight = 0;
+ View customAddressLine = view.findViewById(R.id.context_menu_custom_address_line);
+ if (customAddressLine.getVisibility() == View.VISIBLE) {
+ customAddressLineHeight = customAddressLine.getMeasuredHeight();
+ }
+
int line3Height = 0;
View line3Container = view.findViewById(R.id.additional_info_row_container);
if (line3Container.getVisibility() == View.VISIBLE) {
@@ -1717,12 +1724,12 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
titleHeight = line1.getMeasuredHeight() + line2MeasuredHeight;
}
newMenuTopViewHeight = menuTopViewHeightExcludingTitle + titleHeight
- + titleButtonHeight + downloadButtonsHeight
+ + titleButtonHeight + customAddressLineHeight + downloadButtonsHeight
+ titleBottomButtonHeight + additionalButtonsHeight + titleProgressHeight + line3Height;
dy = Math.max(0, newMenuTopViewHeight - menuTopViewHeight
- (newMenuTopShadowAllHeight - menuTopShadowAllHeight));
} else {
- menuTopViewHeightExcludingTitle = newMenuTopViewHeight - line1.getMeasuredHeight() - line2MeasuredHeight
+ menuTopViewHeightExcludingTitle = newMenuTopViewHeight - line1.getMeasuredHeight() - line2MeasuredHeight - customAddressLineHeight
- titleButtonHeight - downloadButtonsHeight - titleBottomButtonHeight - additionalButtonsHeight - titleProgressHeight - line3Height;
menuTitleTopBottomPadding = (line1.getMeasuredHeight() - line1.getLineCount() * line1.getLineHeight())
+ (line2MeasuredHeight - line2LineCount * line2LineHeight);
@@ -1818,12 +1825,16 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
line1.setText(menu.getTitleStr());
toolbarTextView.setText(menu.getTitleStr());
// Text line 2
- LinearLayout line2layout = view.findViewById(R.id.context_menu_line2_layout);
TextView line2 = view.findViewById(R.id.context_menu_line2);
+ LinearLayout customAddressLine = view.findViewById(R.id.context_menu_custom_address_line);
+ customAddressLine.removeAllViews();
if (menu.hasCustomAddressLine()) {
- line2layout.removeAllViews();
- menu.buildCustomAddressLine(line2layout);
+ menu.buildCustomAddressLine(customAddressLine);
+ AndroidUiHelper.updateVisibility(line2, false);
+ AndroidUiHelper.updateVisibility(customAddressLine, true);
} else {
+ AndroidUiHelper.updateVisibility(line2, true);
+ AndroidUiHelper.updateVisibility(customAddressLine, false);
String typeStr = menu.getTypeStr();
String streetStr = menu.getStreetStr();
StringBuilder line2Str = new StringBuilder();
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});
}
}
}
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;
}
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) {
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java
index 9916813c5e..8ba86dfe35 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java
@@ -625,11 +625,14 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
private List getReliefParameters() {
List reliefFactorParameters = new ArrayList<>();
- Map parameters = app.getRouter(applicationMode).getParameters();
- for (Map.Entry entry : parameters.entrySet()) {
- RoutingParameter routingParameter = entry.getValue();
- if (RELIEF_SMOOTHNESS_FACTOR.equals(routingParameter.getGroup())) {
- reliefFactorParameters.add(routingParameter);
+ GeneralRouter router = app.getRouter(applicationMode);
+ if (router != null) {
+ Map parameters = router.getParameters();
+ for (Map.Entry entry : parameters.entrySet()) {
+ RoutingParameter routingParameter = entry.getValue();
+ if (RELIEF_SMOOTHNESS_FACTOR.equals(routingParameter.getGroup())) {
+ reliefFactorParameters.add(routingParameter);
+ }
}
}
return reliefFactorParameters;
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) {