diff --git a/android/res/drawable-hdpi/img_permission_explanation.png b/android/res/drawable-hdpi/img_permission_explanation.png deleted file mode 100755 index cf7a3815ce..0000000000 Binary files a/android/res/drawable-hdpi/img_permission_explanation.png and /dev/null differ diff --git a/android/res/drawable-hdpi/img_welcome.png b/android/res/drawable-hdpi/img_welcome.png old mode 100644 new mode 100755 index ca21ca19da..cf7a3815ce Binary files a/android/res/drawable-hdpi/img_welcome.png and b/android/res/drawable-hdpi/img_welcome.png differ diff --git a/android/res/drawable-mdpi/img_permission_explanation.png b/android/res/drawable-mdpi/img_permission_explanation.png deleted file mode 100755 index e085ec0f48..0000000000 Binary files a/android/res/drawable-mdpi/img_permission_explanation.png and /dev/null differ diff --git a/android/res/drawable-mdpi/img_welcome.png b/android/res/drawable-mdpi/img_welcome.png old mode 100644 new mode 100755 index 8a40f24232..e085ec0f48 Binary files a/android/res/drawable-mdpi/img_welcome.png and b/android/res/drawable-mdpi/img_welcome.png differ diff --git a/android/res/drawable-sw600dp-hdpi/img_welcome.png b/android/res/drawable-sw600dp-hdpi/img_welcome.png deleted file mode 100644 index 21c07eb221..0000000000 Binary files a/android/res/drawable-sw600dp-hdpi/img_welcome.png and /dev/null differ diff --git a/android/res/drawable-sw600dp-mdpi/img_welcome.png b/android/res/drawable-sw600dp-mdpi/img_welcome.png deleted file mode 100644 index 26bdd1a820..0000000000 Binary files a/android/res/drawable-sw600dp-mdpi/img_welcome.png and /dev/null differ diff --git a/android/res/drawable-sw600dp-xhdpi/img_welcome.png b/android/res/drawable-sw600dp-xhdpi/img_welcome.png deleted file mode 100644 index 7b484b92b4..0000000000 Binary files a/android/res/drawable-sw600dp-xhdpi/img_welcome.png and /dev/null differ diff --git a/android/res/drawable-sw600dp-xxhdpi/img_welcome.png b/android/res/drawable-sw600dp-xxhdpi/img_welcome.png deleted file mode 100644 index 956cf2cd39..0000000000 Binary files a/android/res/drawable-sw600dp-xxhdpi/img_welcome.png and /dev/null differ diff --git a/android/res/drawable-sw600dp-xxxhdpi/img_welcome.png b/android/res/drawable-sw600dp-xxxhdpi/img_welcome.png deleted file mode 100644 index fcfa06c8ae..0000000000 Binary files a/android/res/drawable-sw600dp-xxxhdpi/img_welcome.png and /dev/null differ diff --git a/android/res/drawable-xhdpi/img_permission_explanation.png b/android/res/drawable-xhdpi/img_permission_explanation.png deleted file mode 100755 index a8439577a9..0000000000 Binary files a/android/res/drawable-xhdpi/img_permission_explanation.png and /dev/null differ diff --git a/android/res/drawable-xhdpi/img_welcome.png b/android/res/drawable-xhdpi/img_welcome.png old mode 100644 new mode 100755 index 00a8d20db7..a8439577a9 Binary files a/android/res/drawable-xhdpi/img_welcome.png and b/android/res/drawable-xhdpi/img_welcome.png differ diff --git a/android/res/drawable-xxhdpi/img_permission_explanation.png b/android/res/drawable-xxhdpi/img_permission_explanation.png deleted file mode 100755 index 96a17e6803..0000000000 Binary files a/android/res/drawable-xxhdpi/img_permission_explanation.png and /dev/null differ diff --git a/android/res/drawable-xxhdpi/img_welcome.png b/android/res/drawable-xxhdpi/img_welcome.png old mode 100644 new mode 100755 index 95b6da8812..96a17e6803 Binary files a/android/res/drawable-xxhdpi/img_welcome.png and b/android/res/drawable-xxhdpi/img_welcome.png differ diff --git a/android/res/drawable-xxxhdpi/img_permission_explanation.png b/android/res/drawable-xxxhdpi/img_permission_explanation.png deleted file mode 100755 index 3e2f70d700..0000000000 Binary files a/android/res/drawable-xxxhdpi/img_permission_explanation.png and /dev/null differ diff --git a/android/res/drawable-xxxhdpi/img_welcome.png b/android/res/drawable-xxxhdpi/img_welcome.png old mode 100644 new mode 100755 index c675387da3..3e2f70d700 Binary files a/android/res/drawable-xxxhdpi/img_welcome.png and b/android/res/drawable-xxxhdpi/img_welcome.png differ diff --git a/android/res/layout-land/fragment_welcome.xml b/android/res/layout-land/fragment_welcome.xml new file mode 100644 index 0000000000..8b3509b207 --- /dev/null +++ b/android/res/layout-land/fragment_welcome.xml @@ -0,0 +1,10 @@ + + + + diff --git a/android/res/layout-land/info_page.xml b/android/res/layout-land/info_page.xml index 7fe6a89541..d7275ed533 100644 --- a/android/res/layout-land/info_page.xml +++ b/android/res/layout-land/info_page.xml @@ -25,16 +25,17 @@ android:gravity="center_horizontal" android:orientation="vertical"> + android:layout_height="wrap_content"> + @@ -50,6 +52,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="@dimen/margin_base" + android:textSize="@dimen/text_size_body_3" android:textAppearance="@style/MwmTextAppearance.Body1.Secondary" tools:text="@string/onboarding_welcome_first_subtitle" /> diff --git a/android/res/layout-sw600dp-land/info_page.xml b/android/res/layout-sw600dp-land/info_page.xml index 3c1bc51bf4..ab47a52a1f 100644 --- a/android/res/layout-sw600dp-land/info_page.xml +++ b/android/res/layout-sw600dp-land/info_page.xml @@ -25,13 +25,14 @@ android:layout_margin="@dimen/margin_base_plus" android:layout_weight="1"> + android:layout_width="match_parent" + android:layout_height="wrap_content"> + @@ -40,6 +41,7 @@ android:layout_marginTop="@dimen/margin_half_double_plus" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:textSize="@dimen/text_size_toolbar" android:textAppearance="@style/MwmTextAppearance.Title" android:fontFamily="@string/robotoMedium" tools:text="@string/onboarding_welcome_title" @@ -49,6 +51,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="@dimen/margin_base" + android:textSize="@dimen/text_size_body_3" android:textAppearance="@style/MwmTextAppearance.Body1.Secondary" tools:text="@string/onboarding_welcome_first_subtitle"/> diff --git a/android/res/layout-sw600dp/info_page.xml b/android/res/layout-sw600dp/info_page.xml index aea759ff16..bc5fb1f4dc 100644 --- a/android/res/layout-sw600dp/info_page.xml +++ b/android/res/layout-sw600dp/info_page.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"> @@ -27,6 +27,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="@dimen/margin_base" + android:textSize="@dimen/text_size_toolbar" android:textAppearance="@style/MwmTextAppearance.Title" android:layout_gravity="center_horizontal" android:gravity="center_horizontal" @@ -39,13 +40,14 @@ android:layout_height="wrap_content" android:layout_marginBottom="@dimen/margin_base" android:textAppearance="@style/MwmTextAppearance.Body1.Secondary" + android:textSize="@dimen/text_size_body_3" android:layout_gravity="center_horizontal" android:gravity="center_horizontal" tools:text="@string/onboarding_welcome_first_subtitle"/> + android:layout_height="match_parent" + android:layout_alignWithParentIfMissing="true" + android:layout_above="@id/user_agreement_block" /> + diff --git a/android/res/layout/info_page.xml b/android/res/layout/info_page.xml index be9d101af8..dcd29bbbfb 100644 --- a/android/res/layout/info_page.xml +++ b/android/res/layout/info_page.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"> @@ -29,6 +29,7 @@ android:layout_marginLeft="@dimen/margin_double" android:layout_marginRight="@dimen/margin_double" android:layout_marginBottom="@dimen/margin_base" + android:textSize="@dimen/text_size_toolbar" android:textAppearance="@style/MwmTextAppearance.Title" android:layout_gravity="center_horizontal" android:gravity="center_horizontal" @@ -42,6 +43,7 @@ android:layout_marginLeft="@dimen/margin_double" android:layout_marginRight="@dimen/margin_double" android:layout_marginBottom="@dimen/margin_base" + android:textSize="@dimen/text_size_body_3" android:textAppearance="@style/MwmTextAppearance.Body1.Secondary" android:layout_gravity="center_horizontal" android:gravity="center_horizontal" @@ -49,7 +51,7 @@ + + + + diff --git a/android/res/layout/user_agreement_block.xml b/android/res/layout/user_agreement_block.xml new file mode 100644 index 0000000000..16e2251f3b --- /dev/null +++ b/android/res/layout/user_agreement_block.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + diff --git a/android/src/com/mapswithme/maps/auth/SocialAuthDialogFragment.java b/android/src/com/mapswithme/maps/auth/SocialAuthDialogFragment.java index 40cf9f8c76..86094e56b6 100644 --- a/android/src/com/mapswithme/maps/auth/SocialAuthDialogFragment.java +++ b/android/src/com/mapswithme/maps/auth/SocialAuthDialogFragment.java @@ -4,21 +4,17 @@ import android.app.Activity; import android.app.Dialog; import android.content.DialogInterface; import android.content.Intent; -import android.content.res.Resources; import android.os.Bundle; import androidx.annotation.IdRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.annotation.StringRes; -import android.text.Html; + import android.text.TextUtils; -import android.text.method.LinkMovementMethod; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.widget.CheckBox; -import android.widget.TextView; import com.facebook.CallbackManager; import com.facebook.FacebookCallback; @@ -32,6 +28,7 @@ import com.mapswithme.maps.Framework; import com.mapswithme.maps.PrivateVariables; import com.mapswithme.maps.R; import com.mapswithme.maps.base.BaseMwmDialogFragment; +import com.mapswithme.util.UiUtils; import com.mapswithme.util.log.Logger; import com.mapswithme.util.log.LoggerFactory; import com.mapswithme.util.statistics.Statistics; @@ -145,11 +142,11 @@ public class SocialAuthDialogFragment extends BaseMwmDialogFragment R.id.google_button, R.id.facebook_button, R.id.phone_button); }); - linkifyPolicyView(view, R.id.privacyPolicyLink, R.string.sign_agree_pp_gdpr, - Framework.nativeGetPrivacyPolicyLink()); + UiUtils.linkifyPolicyView(view, R.id.privacyPolicyLink, R.string.sign_agree_pp_gdpr, + Framework.nativeGetPrivacyPolicyLink()); - linkifyPolicyView(view, R.id.termOfUseLink, R.string.sign_agree_tof_gdpr, - Framework.nativeGetTermsOfUseLink()); + UiUtils.linkifyPolicyView(view, R.id.termOfUseLink, R.string.sign_agree_tof_gdpr, + Framework.nativeGetTermsOfUseLink()); setButtonAvailability(view, false, R.id.google_button, R.id.facebook_button, R.id.phone_button); @@ -163,15 +160,6 @@ public class SocialAuthDialogFragment extends BaseMwmDialogFragment button.setOnClickListener(clickListener); } - private static void linkifyPolicyView(@NonNull View root, @IdRes int id, @StringRes int stringId, - @NonNull String link) - { - TextView policyView = root.findViewById(id); - Resources rs = policyView.getResources(); - policyView.setText(Html.fromHtml(rs.getString(stringId, link))); - policyView.setMovementMethod(LinkMovementMethod.getInstance()); - } - private static void setButtonAvailability(@NonNull View root, boolean available, @IdRes int... ids) { for (int id : ids) diff --git a/android/src/com/mapswithme/maps/news/WelcomeScreenBindingType.java b/android/src/com/mapswithme/maps/news/WelcomeScreenBindingType.java index 97066f2c42..8a54ad4c16 100644 --- a/android/src/com/mapswithme/maps/news/WelcomeScreenBindingType.java +++ b/android/src/com/mapswithme/maps/news/WelcomeScreenBindingType.java @@ -51,7 +51,7 @@ public enum WelcomeScreenBindingType R.string.visible, R.string.view_campaign_button, R.string.visible, - R.drawable.img_permission_explanation); + R.drawable.img_welcome); @StringRes private final int mAcceptButtonResId; diff --git a/android/src/com/mapswithme/maps/onboarding/WelcomeDialogFragment.java b/android/src/com/mapswithme/maps/onboarding/WelcomeDialogFragment.java index a3a5dead88..30a75660db 100644 --- a/android/src/com/mapswithme/maps/onboarding/WelcomeDialogFragment.java +++ b/android/src/com/mapswithme/maps/onboarding/WelcomeDialogFragment.java @@ -2,10 +2,13 @@ package com.mapswithme.maps.onboarding; import android.app.Activity; import android.app.Dialog; +import android.content.Context; import android.content.DialogInterface; +import android.content.SharedPreferences; import android.os.Bundle; import android.view.View; import android.view.Window; +import android.widget.CheckBox; import android.widget.ImageView; import android.widget.TextView; @@ -15,10 +18,13 @@ import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; import com.mapswithme.maps.BuildConfig; +import com.mapswithme.maps.Framework; +import com.mapswithme.maps.MwmApplication; import com.mapswithme.maps.R; import com.mapswithme.maps.base.BaseMwmDialogFragment; import com.mapswithme.maps.news.WelcomeScreenBindingType; import com.mapswithme.util.Counters; +import com.mapswithme.util.SharedPropertiesUtils; import com.mapswithme.util.ThemeUtils; import com.mapswithme.util.UiUtils; @@ -52,6 +58,14 @@ public class WelcomeDialogFragment extends BaseMwmDialogFragment implements View @NonNull private TextView mAcceptBtn; + @SuppressWarnings("NullableProblems") + @NonNull + private CheckBox mTermOfUseCheckbox; + + @SuppressWarnings("NullableProblems") + @NonNull + private CheckBox mPrivacyPolicyCheckbox; + public static void show(@NonNull FragmentActivity activity) { create(activity); @@ -63,6 +77,9 @@ public class WelcomeDialogFragment extends BaseMwmDialogFragment implements View if (Counters.getFirstInstallVersion() < BuildConfig.VERSION_CODE) return false; + if (isAgreementDenied(activity)) + return true; + FragmentManager fm = activity.getSupportFragmentManager(); if (fm.isDestroyed()) return false; @@ -139,22 +156,80 @@ public class WelcomeDialogFragment extends BaseMwmDialogFragment implements View mTitle.setText(R.string.onboarding_welcome_title); mSubtitle = mContentView.findViewById(R.id.tv__subtitle1); mSubtitle.setText(R.string.onboarding_welcome_first_subtitle); + mContentView.findViewById(R.id.privacy_policy_welcome); + initUserAgreementViews(); bindWelcomeScreenType(); return res; } + private void initUserAgreementViews() + { + SharedPreferences prefs = MwmApplication.prefs(requireContext()); + + mTermOfUseCheckbox = mContentView.findViewById(R.id.term_of_use_welcome_checkbox); + mTermOfUseCheckbox.setChecked(prefs.getBoolean(SharedPropertiesUtils.USER_AGREEMENT_TERM_OF_USE, false)); + + mPrivacyPolicyCheckbox = mContentView.findViewById(R.id.privacy_policy_welcome_checkbox); + mPrivacyPolicyCheckbox.setChecked(prefs.getBoolean(SharedPropertiesUtils.USER_AGREEMENT_PRIVACY_POLICY, false)); + + mTermOfUseCheckbox.setOnCheckedChangeListener( + (buttonView, isChecked) -> onTermsOfUseViewChanged(isChecked)); + mPrivacyPolicyCheckbox.setOnCheckedChangeListener( + (buttonView, isChecked) -> onPrivacyPolicyViewChanged(isChecked)); + + UiUtils.linkifyPolicyView(mContentView, R.id.privacy_policy_welcome, + R.string.sign_agree_pp_gdpr, Framework.nativeGetPrivacyPolicyLink()); + + UiUtils.linkifyPolicyView(mContentView, R.id.term_of_use_welcome, + R.string.sign_agree_tof_gdpr, Framework.nativeGetTermsOfUseLink()); + } + + private void onPrivacyPolicyViewChanged(boolean isChecked) + { + onCheckedValueChanged(isChecked, mTermOfUseCheckbox.isChecked(), + SharedPropertiesUtils.USER_AGREEMENT_PRIVACY_POLICY); + } + + private void onTermsOfUseViewChanged(boolean isChecked) + { + onCheckedValueChanged(isChecked, mPrivacyPolicyCheckbox.isChecked(), + SharedPropertiesUtils.USER_AGREEMENT_TERM_OF_USE); + } + + private void onCheckedValueChanged(boolean isChecked, + boolean isAnotherConditionChecked, + @NonNull String key) + + { + applyPreferenceChanges(key, isChecked); + boolean isAgreementGranted = isChecked && isAnotherConditionChecked; + if (!isAgreementGranted) + return; + + if (mListener != null) + mListener.onPolicyAgreementApplied(); + dismiss(); + } + private void bindWelcomeScreenType() { - boolean hasDeclineBtn = mWelcomeScreenBindingType != null + boolean hasBindingType = mWelcomeScreenBindingType != null; + UiUtils.showIf(hasBindingType, mContentView, R.id.button_container); + + boolean hasDeclineBtn = hasBindingType && mWelcomeScreenBindingType.hasDeclinedButton(); TextView declineBtn = mContentView.findViewById(R.id.decline_btn); UiUtils.showIf(hasDeclineBtn, declineBtn); + + View userAgreementBlock = mContentView.findViewById(R.id.user_agreement_block); + UiUtils.hideIf(hasBindingType, userAgreementBlock); + if (hasDeclineBtn) declineBtn.setText(mWelcomeScreenBindingType.getDeclinedButtonResId()); - if (mWelcomeScreenBindingType == null) + if (!hasBindingType) return; mTitle.setText(mWelcomeScreenBindingType.getTitle()); @@ -188,6 +263,20 @@ public class WelcomeDialogFragment extends BaseMwmDialogFragment implements View requireActivity().finish(); } + private void applyPreferenceChanges(@NonNull String key, boolean value) + { + SharedPreferences.Editor editor = MwmApplication.prefs(requireContext()).edit(); + editor.putBoolean(key, value).apply(); + } + + private static boolean isAgreementDenied(@NonNull Context context) + { + SharedPreferences prefs = MwmApplication.prefs(context); + return !prefs.getBoolean(SharedPropertiesUtils.USER_AGREEMENT_TERM_OF_USE, false) + || !prefs.getBoolean(SharedPropertiesUtils.USER_AGREEMENT_PRIVACY_POLICY, false); + + } + public interface PolicyAgreementListener { void onPolicyAgreementApplied(); diff --git a/android/src/com/mapswithme/maps/permissions/PermissionsDialogFragment.java b/android/src/com/mapswithme/maps/permissions/PermissionsDialogFragment.java index ee4a130edf..f238647eae 100644 --- a/android/src/com/mapswithme/maps/permissions/PermissionsDialogFragment.java +++ b/android/src/com/mapswithme/maps/permissions/PermissionsDialogFragment.java @@ -36,7 +36,7 @@ public class PermissionsDialogFragment extends BasePermissionsDialogFragment @Override protected int getImageRes() { - return R.drawable.img_permission_explanation; + return R.drawable.img_welcome; } @StringRes diff --git a/android/src/com/mapswithme/util/SharedPropertiesUtils.java b/android/src/com/mapswithme/util/SharedPropertiesUtils.java index 73ebe1130b..1462e3d4b0 100644 --- a/android/src/com/mapswithme/util/SharedPropertiesUtils.java +++ b/android/src/com/mapswithme/util/SharedPropertiesUtils.java @@ -14,6 +14,8 @@ import static com.mapswithme.util.Config.KEY_PREF_STATISTICS; public final class SharedPropertiesUtils { + public static final String USER_AGREEMENT_TERM_OF_USE = "user_agreement_term_of_use"; + public static final String USER_AGREEMENT_PRIVACY_POLICY = "user_agreement_privacy_policy"; private static final String PREFS_SHOW_EMULATE_BAD_STORAGE_SETTING = "ShowEmulateBadStorageSetting"; private static final String PREFS_BACKUP_WIDGET_EXPANDED = "BackupWidgetExpanded"; private static final String PREFS_WHATS_NEW_TITLE_CONCATENATION = "WhatsNewTitleConcatenation"; diff --git a/android/src/com/mapswithme/util/UiUtils.java b/android/src/com/mapswithme/util/UiUtils.java index 473acc2b08..ef6bb48780 100644 --- a/android/src/com/mapswithme/util/UiUtils.java +++ b/android/src/com/mapswithme/util/UiUtils.java @@ -11,7 +11,9 @@ import android.graphics.Color; import android.graphics.Rect; import android.net.Uri; import android.os.Build; +import android.text.Html; import android.text.TextUtils; +import android.text.method.LinkMovementMethod; import android.view.Gravity; import android.view.MotionEvent; import android.view.Surface; @@ -63,6 +65,15 @@ public final class UiUtils frontView.bringToFront(); } + public static void linkifyPolicyView(@NonNull View root, @IdRes int id, @StringRes int stringId, + @NonNull String link) + { + TextView policyView = root.findViewById(id); + Resources rs = policyView.getResources(); + policyView.setText(Html.fromHtml(rs.getString(stringId, link))); + policyView.setMovementMethod(LinkMovementMethod.getInstance()); + } + public static class SimpleAnimationListener implements AnimationListener { @Override