From bba9a860e6461ab00cb6b0e6fc42c1cf6983ac6d Mon Sep 17 00:00:00 2001 From: androiddevkkotlin Date: Fri, 6 Nov 2020 13:16:16 +0200 Subject: [PATCH] My places --- .../LoginBottomSheetFragment.java | 5 ----- .../plus/osmedit/EditPOIMenuController.java | 2 +- .../osmand/plus/osmedit/OsmEditsFragment.java | 21 +++++++++++++++---- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/LoginBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/LoginBottomSheetFragment.java index e61813cd93..44547815ce 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/LoginBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/LoginBottomSheetFragment.java @@ -75,11 +75,6 @@ public class LoginBottomSheetFragment extends MenuBottomSheetDialogFragment { return getResources().getDimensionPixelSize(R.dimen.card_content_padding_large); } - @Override - public int getSecondDividerHeight() { - return getResources().getDimensionPixelSize(R.dimen.content_padding_small); - } - @Override protected void onRightBottomButtonClick() { FragmentManager fragmentManager = getFragmentManager(); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java index 60c2ed0b2b..1d8a4e4aa6 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java @@ -54,7 +54,7 @@ public class EditPOIMenuController extends MenuController { SimpleProgressDialogPoiUploader poiDialogUploader = new SimpleProgressDialogPoiUploader(activity); poiDialogUploader.showProgressDialog(new OsmPoint[] {getOsmPoint()}, false, false); } else { - LoginBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), activity.getLoginBottomSheetFragment()); + LoginBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), null); } } } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java index 40f62e55b6..0a4cc5d7ff 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsFragment.java @@ -29,6 +29,7 @@ import androidx.appcompat.app.AlertDialog; import androidx.appcompat.view.ActionMode; import androidx.fragment.app.DialogFragment; import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; import net.osmand.AndroidUtils; @@ -41,6 +42,8 @@ import net.osmand.osm.edit.Entity; import net.osmand.osm.edit.Node; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; +import net.osmand.plus.measurementtool.LoginBottomSheetFragment; +import net.osmand.plus.osmedit.oauth.OsmOAuthAuthorizationAdapter; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.Version; @@ -624,10 +627,20 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo } private void uploadItems(final OsmPoint[] items) { - SendPoiDialogFragment.createInstance(items, PoiUploaderType.FRAGMENT) - .show(getChildFragmentManager(), SendPoiDialogFragment.TAG); -// UploadOsmEditsConfirmDialogFragment.createInstancee(items).show(getChildFragmentManager(), -// UploadOsmEditsConfirmDialogFragment.TAG); + FragmentActivity activity = getActivity(); + if (activity != null) { + OsmandApplication app = getMyApplication(); + OsmandSettings settings = app.getSettings(); + OsmOAuthAuthorizationAdapter authorizationAdapter = new OsmOAuthAuthorizationAdapter(app); + if (authorizationAdapter.isValidToken() + || !Algorithms.isEmpty(settings.USER_NAME.get()) + && !Algorithms.isEmpty(settings.USER_PASSWORD.get())) { + SendPoiDialogFragment.createInstance(items, PoiUploaderType.FRAGMENT) + .show(getChildFragmentManager(), SendPoiDialogFragment.TAG); + } else { + LoginBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), this); + } + } } public void showProgressDialog(OsmPoint[] points, boolean closeChangeSet, boolean anonymously) {