diff --git a/android/src/com/mapswithme/maps/auth/Authorizer.java b/android/src/com/mapswithme/maps/auth/Authorizer.java index a63431ef2a..d3191649bc 100644 --- a/android/src/com/mapswithme/maps/auth/Authorizer.java +++ b/android/src/com/mapswithme/maps/auth/Authorizer.java @@ -102,13 +102,15 @@ public class Authorizer implements AuthorizationListener { @Framework.AuthTokenType int type = data.getIntExtra(Constants.EXTRA_TOKEN_TYPE, Framework.SOCIAL_TOKEN_INVALID); + boolean privacyAccepted = data.getBooleanExtra(Constants.EXTRA_PRIVACY_POLICY_ACCEPTED, false); + boolean termsOfUseAccepted = data.getBooleanExtra(Constants.EXTRA_TERMS_OF_USE_ACCEPTED, false); + boolean promoAccepted = data.getBooleanExtra(Constants.EXTRA_PROMO_ACCEPTED, false); mIsAuthorizationInProgress = true; if (mCallback != null) mCallback.onAuthorizationStart(); - //TODO: support privacy policy, terms of use and promo offers. - Framework.nativeAuthenticateUser(socialToken, type, false /* privacyAccepted */, - false /* termsAccepted */, false /* promoAccepted */, this); + Framework.nativeAuthenticateUser(socialToken, type, privacyAccepted, termsOfUseAccepted, + promoAccepted, this); } } diff --git a/android/src/com/mapswithme/maps/auth/Constants.java b/android/src/com/mapswithme/maps/auth/Constants.java index 5a7f974df5..3670f3a01e 100644 --- a/android/src/com/mapswithme/maps/auth/Constants.java +++ b/android/src/com/mapswithme/maps/auth/Constants.java @@ -13,6 +13,9 @@ class Constants static final String EXTRA_TOKEN_TYPE = "extra_token_type"; static final String EXTRA_AUTH_ERROR = "extra_auth_error"; static final String EXTRA_IS_CANCEL = "extra_is_cancel"; + static final String EXTRA_PRIVACY_POLICY_ACCEPTED = "extra_privacy_policy_accepted"; + static final String EXTRA_TERMS_OF_USE_ACCEPTED = "extra_terms_of_use_accepted"; + static final String EXTRA_PROMO_ACCEPTED = "extra_promo_accepted"; static final List FACEBOOK_PERMISSIONS = Arrays.asList("email", "user_friends"); } diff --git a/android/src/com/mapswithme/maps/auth/SocialAuthDialogFragment.java b/android/src/com/mapswithme/maps/auth/SocialAuthDialogFragment.java index 8114be5611..a4c3f73671 100644 --- a/android/src/com/mapswithme/maps/auth/SocialAuthDialogFragment.java +++ b/android/src/com/mapswithme/maps/auth/SocialAuthDialogFragment.java @@ -74,6 +74,9 @@ public class SocialAuthDialogFragment extends BaseMwmDialogFragment @SuppressWarnings("NullableProblems") @NonNull private CheckBox mTermOfUseCheck; + @SuppressWarnings("NullableProblems") + @NonNull + private CheckBox mPromoCheck; @NonNull @Override @@ -113,6 +116,7 @@ public class SocialAuthDialogFragment extends BaseMwmDialogFragment View phoneButton = view.findViewById(R.id.phone_button); phoneButton.setOnClickListener(mPhoneClickListener); + mPromoCheck = view.findViewById(R.id.newsCheck); mPrivacyPolicyCheck = view.findViewById(R.id.privacyPolicyCheck); mPrivacyPolicyCheck.setOnCheckedChangeListener((buttonView, isChecked) -> { setButtonAvailability(view, isChecked && mTermOfUseCheck.isChecked(), @@ -133,7 +137,7 @@ public class SocialAuthDialogFragment extends BaseMwmDialogFragment private static void linkifyPolicyViews(@NonNull View root, @IdRes int... ids) { - for(int id: ids) + for (int id : ids) { TextView policyView = root.findViewById(id); policyView.setMovementMethod(LinkMovementMethod.getInstance()); @@ -142,11 +146,11 @@ public class SocialAuthDialogFragment extends BaseMwmDialogFragment private static void setButtonAvailability(@NonNull View root, boolean available, @IdRes int... ids) { - for(int id: ids) - { - View button = root.findViewById(id); - button.setEnabled(available); - } + for (int id : ids) + { + View button = root.findViewById(id); + button.setEnabled(available); + } } @Override @@ -169,6 +173,9 @@ public class SocialAuthDialogFragment extends BaseMwmDialogFragment data.putExtra(Constants.EXTRA_TOKEN_TYPE, type); data.putExtra(Constants.EXTRA_AUTH_ERROR, error); data.putExtra(Constants.EXTRA_IS_CANCEL, isCancel); + data.putExtra(Constants.EXTRA_PRIVACY_POLICY_ACCEPTED, mPrivacyPolicyCheck.isChecked()); + data.putExtra(Constants.EXTRA_TERMS_OF_USE_ACCEPTED, mTermOfUseCheck.isChecked()); + data.putExtra(Constants.EXTRA_PROMO_ACCEPTED, mPromoCheck.isChecked()); caller.onActivityResult(Constants.REQ_CODE_GET_SOCIAL_TOKEN, resultCode, data); }