From c55ab01992c088f2e56caacadd6ad0fcac25d81e Mon Sep 17 00:00:00 2001 From: Arsentiy Milchakov Date: Thu, 5 Apr 2018 17:26:47 +0300 Subject: [PATCH] [android] auth fix --- android/src/com/mapswithme/maps/auth/Authorizer.java | 3 +-- .../mapswithme/maps/auth/PassportAuthDialogFragment.java | 7 ++++++- .../maps/bookmarks/data/BookmarkBackupController.java | 2 ++ .../src/com/mapswithme/maps/ugc/UGCEditorFragment.java | 8 +++++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/android/src/com/mapswithme/maps/auth/Authorizer.java b/android/src/com/mapswithme/maps/auth/Authorizer.java index c1d81a936a..026794def7 100644 --- a/android/src/com/mapswithme/maps/auth/Authorizer.java +++ b/android/src/com/mapswithme/maps/auth/Authorizer.java @@ -9,7 +9,6 @@ import android.support.v4.app.Fragment; import android.text.TextUtils; import com.mapswithme.maps.Framework; -import com.mapswithme.util.ConnectionState; /** * An authorizer is responsible for an authorization for the Mapsme server, @@ -55,7 +54,7 @@ public class Authorizer implements AuthorizationListener public final void authorize() { - if (isAuthorized() || !ConnectionState.isConnected()) + if (isAuthorized()) { if (mCallback != null) mCallback.onAuthorizationFinish(true); diff --git a/android/src/com/mapswithme/maps/auth/PassportAuthDialogFragment.java b/android/src/com/mapswithme/maps/auth/PassportAuthDialogFragment.java index f46e7a1b94..82998f9792 100644 --- a/android/src/com/mapswithme/maps/auth/PassportAuthDialogFragment.java +++ b/android/src/com/mapswithme/maps/auth/PassportAuthDialogFragment.java @@ -10,6 +10,7 @@ import android.view.View; import android.view.ViewGroup; import com.mapswithme.maps.Framework; +import com.mapswithme.maps.background.Notifier; import com.mapswithme.maps.base.BaseMwmDialogFragment; import com.mapswithme.util.statistics.Statistics; @@ -56,11 +57,15 @@ public class PassportAuthDialogFragment extends BaseMwmDialogFragment mAuthorizer.detach(); } - private static class AuthCallback implements Authorizer.Callback + private class AuthCallback implements Authorizer.Callback { @Override public void onAuthorizationFinish(boolean success) { + dismiss(); + + if (success) + Notifier.cancelNotification(Notifier.ID_IS_NOT_AUTHENTICATED); } @Override diff --git a/android/src/com/mapswithme/maps/bookmarks/data/BookmarkBackupController.java b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkBackupController.java index 7aa7cd12e3..ab80f52d0d 100644 --- a/android/src/com/mapswithme/maps/bookmarks/data/BookmarkBackupController.java +++ b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkBackupController.java @@ -9,6 +9,7 @@ import android.view.View; import com.mapswithme.maps.Framework; import com.mapswithme.maps.R; import com.mapswithme.maps.auth.Authorizer; +import com.mapswithme.maps.background.Notifier; import com.mapswithme.maps.widget.BookmarkBackupView; import com.mapswithme.util.DateUtils; import com.mapswithme.util.statistics.Statistics; @@ -127,6 +128,7 @@ public class BookmarkBackupController implements Authorizer.Callback { if (success) { + Notifier.cancelNotification(Notifier.ID_IS_NOT_AUTHENTICATED); BookmarkManager.INSTANCE.setCloudEnabled(true); Statistics.INSTANCE.trackEvent(Statistics.EventName.BMK_SYNC_PROPOSAL_ENABLED); } diff --git a/android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java b/android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java index 216fd44dac..030503dc3a 100644 --- a/android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java +++ b/android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java @@ -13,8 +13,10 @@ import android.widget.EditText; import com.mapswithme.maps.Framework; import com.mapswithme.maps.R; import com.mapswithme.maps.auth.BaseMwmAuthorizationFragment; +import com.mapswithme.maps.background.Notifier; import com.mapswithme.maps.bookmarks.data.FeatureId; import com.mapswithme.maps.widget.ToolbarController; +import com.mapswithme.util.ConnectionState; import com.mapswithme.util.Language; import com.mapswithme.util.UiUtils; import com.mapswithme.util.statistics.Statistics; @@ -79,7 +81,8 @@ public class UGCEditorFragment extends BaseMwmAuthorizationFragment submitButton.setOnClickListener(v -> { onSubmitButtonClick(); - authorize(); + if (ConnectionState.isConnected()) + authorize(); }); } @@ -100,6 +103,9 @@ public class UGCEditorFragment extends BaseMwmAuthorizationFragment @Override public void onAuthorizationFinish(boolean success) { + if (success) + Notifier.cancelNotification(Notifier.ID_IS_NOT_AUTHENTICATED); + if (isAdded()) getActivity().finish(); }