Merge remote-tracking branch 'origin/r3.9' into r3.9
This commit is contained in:
commit
d614922a00
10 changed files with 87 additions and 46 deletions
|
@ -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);
|
||||
|
|
|
@ -61,6 +61,13 @@
|
|||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/amenity_type_finance"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/context_menu_custom_address_line"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<ConfigureProfileMenuAdapter>
|
||||
implements ConfigureProfileMenuAdapter.ProfileSelectedListener {
|
||||
public class ConfigureAppModesBottomSheetDialogFragment extends AppModesBottomSheetDialogFragment<ConfigureProfileMenuAdapter>
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
|
|
|
@ -625,11 +625,14 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
|
||||
private List<RoutingParameter> getReliefParameters() {
|
||||
List<RoutingParameter> reliefFactorParameters = new ArrayList<>();
|
||||
Map<String, RoutingParameter> parameters = app.getRouter(applicationMode).getParameters();
|
||||
for (Map.Entry<String, RoutingParameter> 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<String, RoutingParameter> parameters = router.getParameters();
|
||||
for (Map.Entry<String, RoutingParameter> entry : parameters.entrySet()) {
|
||||
RoutingParameter routingParameter = entry.getValue();
|
||||
if (RELIEF_SMOOTHNESS_FACTOR.equals(routingParameter.getGroup())) {
|
||||
reliefFactorParameters.add(routingParameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
return reliefFactorParameters;
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue