Merge pull request #10751 from osmandapp/minor_fixes

Minor fixes
This commit is contained in:
vshcherb 2021-02-03 12:42:22 +01:00 committed by GitHub
commit f56f0d971a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 87 additions and 46 deletions

View file

@ -94,6 +94,10 @@ public class OsmOAuthAuthorizationClient {
return accessToken; return accessToken;
} }
public OAuth1RequestToken getRequestToken() {
return requestToken;
}
public Response performRequestWithoutAuth(String url, String requestMethod, String requestBody) public Response performRequestWithoutAuth(String url, String requestMethod, String requestBody)
throws InterruptedException, ExecutionException, IOException { throws InterruptedException, ExecutionException, IOException {
Verb verb = parseRequestMethod(requestMethod); Verb verb = parseRequestMethod(requestMethod);

View file

@ -61,6 +61,13 @@
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:text="@string/amenity_type_finance"/> 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>
</LinearLayout> </LinearLayout>

View file

@ -58,6 +58,7 @@ import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.LockableScrollView; import net.osmand.plus.LockableScrollView;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.settings.backend.MainContextMenuItemsSettings; import net.osmand.plus.settings.backend.MainContextMenuItemsSettings;
import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -1674,6 +1675,12 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
line2MeasuredHeight = line2.getMeasuredHeight(); 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; int line3Height = 0;
View line3Container = view.findViewById(R.id.additional_info_row_container); View line3Container = view.findViewById(R.id.additional_info_row_container);
if (line3Container.getVisibility() == View.VISIBLE) { if (line3Container.getVisibility() == View.VISIBLE) {
@ -1717,12 +1724,12 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
titleHeight = line1.getMeasuredHeight() + line2MeasuredHeight; titleHeight = line1.getMeasuredHeight() + line2MeasuredHeight;
} }
newMenuTopViewHeight = menuTopViewHeightExcludingTitle + titleHeight newMenuTopViewHeight = menuTopViewHeightExcludingTitle + titleHeight
+ titleButtonHeight + downloadButtonsHeight + titleButtonHeight + customAddressLineHeight + downloadButtonsHeight
+ titleBottomButtonHeight + additionalButtonsHeight + titleProgressHeight + line3Height; + titleBottomButtonHeight + additionalButtonsHeight + titleProgressHeight + line3Height;
dy = Math.max(0, newMenuTopViewHeight - menuTopViewHeight dy = Math.max(0, newMenuTopViewHeight - menuTopViewHeight
- (newMenuTopShadowAllHeight - menuTopShadowAllHeight)); - (newMenuTopShadowAllHeight - menuTopShadowAllHeight));
} else { } else {
menuTopViewHeightExcludingTitle = newMenuTopViewHeight - line1.getMeasuredHeight() - line2MeasuredHeight menuTopViewHeightExcludingTitle = newMenuTopViewHeight - line1.getMeasuredHeight() - line2MeasuredHeight - customAddressLineHeight
- titleButtonHeight - downloadButtonsHeight - titleBottomButtonHeight - additionalButtonsHeight - titleProgressHeight - line3Height; - titleButtonHeight - downloadButtonsHeight - titleBottomButtonHeight - additionalButtonsHeight - titleProgressHeight - line3Height;
menuTitleTopBottomPadding = (line1.getMeasuredHeight() - line1.getLineCount() * line1.getLineHeight()) menuTitleTopBottomPadding = (line1.getMeasuredHeight() - line1.getLineCount() * line1.getLineHeight())
+ (line2MeasuredHeight - line2LineCount * line2LineHeight); + (line2MeasuredHeight - line2LineCount * line2LineHeight);
@ -1818,12 +1825,16 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
line1.setText(menu.getTitleStr()); line1.setText(menu.getTitleStr());
toolbarTextView.setText(menu.getTitleStr()); toolbarTextView.setText(menu.getTitleStr());
// Text line 2 // Text line 2
LinearLayout line2layout = view.findViewById(R.id.context_menu_line2_layout);
TextView line2 = view.findViewById(R.id.context_menu_line2); 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()) { if (menu.hasCustomAddressLine()) {
line2layout.removeAllViews(); menu.buildCustomAddressLine(customAddressLine);
menu.buildCustomAddressLine(line2layout); AndroidUiHelper.updateVisibility(line2, false);
AndroidUiHelper.updateVisibility(customAddressLine, true);
} else { } else {
AndroidUiHelper.updateVisibility(line2, true);
AndroidUiHelper.updateVisibility(customAddressLine, false);
String typeStr = menu.getTypeStr(); String typeStr = menu.getTypeStr();
String streetStr = menu.getStreetStr(); String streetStr = menu.getStreetStr();
StringBuilder line2Str = new StringBuilder(); StringBuilder line2Str = new StringBuilder();

View file

@ -28,7 +28,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static net.osmand.plus.osmedit.oauth.OsmOAuthHelper.*; import static net.osmand.plus.osmedit.oauth.OsmOAuthHelper.OsmAuthorizationListener;
/** /**
* Created by Denis * Created by Denis
@ -149,7 +149,9 @@ public class DashOsmEditsFragment extends DashBaseFragment
@Override @Override
public void authorizationCompleted() { public void authorizationCompleted() {
SendPoiBottomSheetFragment.showInstance(getChildFragmentManager(), new OsmPoint[]{selectedPoint}); if (selectedPoint != null) {
SendPoiBottomSheetFragment.showInstance(getChildFragmentManager(), new OsmPoint[] {selectedPoint});
}
} }
@Override @Override

View file

@ -5,6 +5,7 @@ import android.graphics.drawable.Drawable;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentManager;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.osm.PoiType; import net.osmand.osm.PoiType;
@ -54,16 +55,15 @@ public class EditPOIMenuController extends MenuController {
|| !Algorithms.isEmpty(settings.USER_NAME.get()) || !Algorithms.isEmpty(settings.USER_NAME.get())
&& !Algorithms.isEmpty(settings.USER_PASSWORD.get()); && !Algorithms.isEmpty(settings.USER_PASSWORD.get());
FragmentManager fragmentManager = activity.getSupportFragmentManager();
if (point instanceof OpenstreetmapPoint) { if (point instanceof OpenstreetmapPoint) {
if (isLogged) { if (isLogged) {
SendPoiBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), SendPoiBottomSheetFragment.showInstance(fragmentManager, new OsmPoint[] {point});
new OsmPoint[]{getOsmPoint()});
} else { } else {
LoginBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), null); LoginBottomSheetFragment.showInstance(fragmentManager, null);
} }
} else if (point instanceof OsmNotesPoint) { } else if (point instanceof OsmNotesPoint) {
SendOsmNoteBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), SendOsmNoteBottomSheetFragment.showInstance(fragmentManager, new OsmPoint[] {point});
new OsmPoint[]{getOsmPoint()});
} }
} }
} }

View file

@ -1,19 +1,10 @@
package net.osmand.plus.osmedit.oauth; package net.osmand.plus.osmedit.oauth;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.net.TrafficStats; import android.net.TrafficStats;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build;
import android.view.View;
import android.view.ViewGroup; 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.builder.api.DefaultApi10a;
import com.github.scribejava.core.model.OAuth1AccessToken; 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.PlatformUtil;
import net.osmand.osm.oauth.OsmOAuthAuthorizationClient; import net.osmand.osm.oauth.OsmOAuthAuthorizationClient;
import net.osmand.plus.OsmAndConstants;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.wikipedia.WikipediaDialogFragment; import net.osmand.plus.wikipedia.WikipediaDialogFragment;
@ -137,7 +127,7 @@ public class OsmOAuthAuthorizationAdapter {
} }
@Override @Override
protected void onPostExecute(@NonNull OAuth1RequestToken requestToken) { protected void onPostExecute(OAuth1RequestToken requestToken) {
if (requestToken != null) { if (requestToken != null) {
loadWebView(rootLayout, nightMode, client.getService().getAuthorizationUrl(requestToken)); loadWebView(rootLayout, nightMode, client.getService().getAuthorizationUrl(requestToken));
} else { } else {
@ -156,9 +146,11 @@ public class OsmOAuthAuthorizationAdapter {
@Override @Override
protected Void doInBackground(String... oauthVerifier) { protected Void doInBackground(String... oauthVerifier) {
client.authorize(oauthVerifier[0]); if (client.getRequestToken() != null) {
saveToken(); client.authorize(oauthVerifier[0]);
updateUserName(); saveToken();
updateUserName();
}
return null; return null;
} }

View file

@ -1,7 +1,11 @@
package net.osmand.plus.profiles; 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.R;
import net.osmand.plus.profiles.ConfigureProfileMenuAdapter.ProfileSelectedListener;
import net.osmand.plus.settings.backend.ApplicationMode;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
@ -10,7 +14,7 @@ import java.util.List;
import java.util.Set; import java.util.Set;
public class ConfigureAppModesBottomSheetDialogFragment extends AppModesBottomSheetDialogFragment<ConfigureProfileMenuAdapter> public class ConfigureAppModesBottomSheetDialogFragment extends AppModesBottomSheetDialogFragment<ConfigureProfileMenuAdapter>
implements ConfigureProfileMenuAdapter.ProfileSelectedListener { implements ProfileSelectedListener {
public static final String TAG = "ConfigureAppModesBottomSheetDialogFragment"; public static final String TAG = "ConfigureAppModesBottomSheetDialogFragment";
@ -56,4 +60,15 @@ public class ConfigureAppModesBottomSheetDialogFragment extends AppModesBottomSh
} }
ApplicationMode.changeProfileAvailability(item, isChecked, getMyApplication()); 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();
}
}
} }

View file

@ -29,6 +29,8 @@ import androidx.appcompat.content.res.AppCompatResources;
import androidx.appcompat.widget.AppCompatImageView; import androidx.appcompat.widget.AppCompatImageView;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.transition.AutoTransition; import androidx.transition.AutoTransition;
import androidx.transition.Scene; import androidx.transition.Scene;
import androidx.transition.Transition; 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.MapMarker;
import net.osmand.plus.mapmarkers.MapMarkerSelectionFragment; import net.osmand.plus.mapmarkers.MapMarkerSelectionFragment;
import net.osmand.plus.poi.PoiUIFilter; 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.profiles.ConfigureAppModesBottomSheetDialogFragment;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidPTTypesRoutingParameter; import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidPTTypesRoutingParameter;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidRoadsRoutingParameter; import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidRoadsRoutingParameter;
@ -870,16 +872,16 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
} }
private void showProfileBottomSheetDialog() { private void showProfileBottomSheetDialog() {
final AppModesBottomSheetDialogFragment fragment = new ConfigureAppModesBottomSheetDialogFragment(); FragmentActivity activity = getMapActivity();
fragment.setUsedOnMap(true); if (activity != null) {
fragment.setUpdateMapRouteMenuListener(new AppModesBottomSheetDialogFragment.UpdateMapRouteMenuListener() { FragmentManager manager = activity.getSupportFragmentManager();
@Override ConfigureAppModesBottomSheetDialogFragment.showInstance(manager, true, new UpdateMapRouteMenuListener() {
public void updateAppModeMenu() { @Override
updateApplicationModes(); public void updateAppModeMenu() {
} updateApplicationModes();
}); }
getMapActivity().getSupportFragmentManager().beginTransaction() });
.add(fragment, ConfigureAppModesBottomSheetDialogFragment.TAG).commitAllowingStateLoss(); }
} }
private void updateApplicationMode(ApplicationMode mode, ApplicationMode next) { private void updateApplicationMode(ApplicationMode mode, ApplicationMode next) {

View file

@ -625,11 +625,14 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
private List<RoutingParameter> getReliefParameters() { private List<RoutingParameter> getReliefParameters() {
List<RoutingParameter> reliefFactorParameters = new ArrayList<>(); List<RoutingParameter> reliefFactorParameters = new ArrayList<>();
Map<String, RoutingParameter> parameters = app.getRouter(applicationMode).getParameters(); GeneralRouter router = app.getRouter(applicationMode);
for (Map.Entry<String, RoutingParameter> entry : parameters.entrySet()) { if (router != null) {
RoutingParameter routingParameter = entry.getValue(); Map<String, RoutingParameter> parameters = router.getParameters();
if (RELIEF_SMOOTHNESS_FACTOR.equals(routingParameter.getGroup())) { for (Map.Entry<String, RoutingParameter> entry : parameters.entrySet()) {
reliefFactorParameters.add(routingParameter); RoutingParameter routingParameter = entry.getValue();
if (RELIEF_SMOOTHNESS_FACTOR.equals(routingParameter.getGroup())) {
reliefFactorParameters.add(routingParameter);
}
} }
} }
return reliefFactorParameters; return reliefFactorParameters;

View file

@ -301,7 +301,12 @@ public class ApplicationMode {
} }
public boolean isCustomProfile() { 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) { public boolean isDerivedRoutingFrom(ApplicationMode mode) {