Merge branch 'r3.9' into opr_plugin

# Conflicts:
#	OsmAnd/src/net/osmand/plus/osmedit/oauth/OsmOAuthAuthorizationAdapter.java
This commit is contained in:
Vitaliy 2021-02-03 14:50:32 +02:00
commit 9efab732f2
11 changed files with 91 additions and 42 deletions

View file

@ -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);

View file

@ -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>

View file

@ -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();

View file

@ -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,8 +149,10 @@ public class DashOsmEditsFragment extends DashBaseFragment
@Override
public void authorizationCompleted() {
if (selectedPoint != null) {
SendPoiBottomSheetFragment.showInstance(getChildFragmentManager(), new OsmPoint[] {selectedPoint});
}
}
@Override
public void showProgressDialog(OsmPoint[] points, boolean closeChangeSet, boolean anonymously) {

View file

@ -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.OSM_USER_NAME.get())
&& !Algorithms.isEmpty(settings.OSM_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});
}
}
}

View file

@ -6,8 +6,6 @@ import android.net.Uri;
import android.os.AsyncTask;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import com.github.scribejava.core.builder.api.DefaultApi10a;
import com.github.scribejava.core.model.OAuth1AccessToken;
import com.github.scribejava.core.model.OAuth1RequestToken;
@ -129,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 {
@ -148,9 +146,11 @@ public class OsmOAuthAuthorizationAdapter {
@Override
protected Void doInBackground(String... oauthVerifier) {
if (client.getRequestToken() != null) {
client.authorize(oauthVerifier[0]);
saveToken();
updateUserName();
}
return null;
}

View file

@ -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;
@ -10,7 +14,7 @@ import java.util.List;
import java.util.Set;
public class ConfigureAppModesBottomSheetDialogFragment extends AppModesBottomSheetDialogFragment<ConfigureProfileMenuAdapter>
implements ConfigureProfileMenuAdapter.ProfileSelectedListener {
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();
}
}
}

View file

@ -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() {
FragmentActivity activity = getMapActivity();
if (activity != null) {
FragmentManager manager = activity.getSupportFragmentManager();
ConfigureAppModesBottomSheetDialogFragment.showInstance(manager, true, new UpdateMapRouteMenuListener() {
@Override
public void updateAppModeMenu() {
updateApplicationModes();
}
});
getMapActivity().getSupportFragmentManager().beginTransaction()
.add(fragment, ConfigureAppModesBottomSheetDialogFragment.TAG).commitAllowingStateLoss();
}
}
private void updateApplicationMode(ApplicationMode mode, ApplicationMode next) {

View file

@ -625,13 +625,16 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
private List<RoutingParameter> getReliefParameters() {
List<RoutingParameter> reliefFactorParameters = new ArrayList<>();
Map<String, RoutingParameter> parameters = app.getRouter(applicationMode).getParameters();
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;
}

View file

@ -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) {

View file

@ -890,8 +890,6 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
private void updateMenuState() {
if (menuType == TrackMenuType.OPTIONS) {
openMenuFullScreen();
} else if (menuType == TrackMenuType.OVERVIEW) {
openMenuHeaderOnly();
} else {
openMenuHalfScreen();
}
@ -1130,8 +1128,10 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
if (mapActivity != null) {
OsmandApplication app = mapActivity.getMyApplication();
SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().selectGpxFile(result, true, false);
if (selectedGpxFile != null) {
showInstance(mapActivity, selectedGpxFile, null);
}
}
if (progress != null && AndroidUtils.isActivityNotDestroyed(mapActivity)) {
progress.dismiss();
}
@ -1142,7 +1142,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
}
}
public static boolean showInstance(@NonNull MapActivity mapActivity, SelectedGpxFile selectedGpxFile, @Nullable LatLon latLon) {
public static boolean showInstance(@NonNull MapActivity mapActivity, @NonNull SelectedGpxFile selectedGpxFile, @Nullable LatLon latLon) {
try {
Bundle args = new Bundle();
args.putInt(ContextMenuFragment.MENU_STATE_KEY, MenuState.HEADER_ONLY);