From 63433c9f378ea542d7a9de007772190fa443d51d Mon Sep 17 00:00:00 2001 From: Alexander Zatsepin Date: Tue, 15 May 2018 16:31:41 +0300 Subject: [PATCH] [android] Added policy checkboxes on the social auth dialog --- .../res/color-v21/button_text_ghost_night.xml | 6 ++ android/res/color/button_text_accent.xml | 6 ++ .../res/color/button_text_accent_night.xml | 6 ++ android/res/color/button_text_ghost.xml | 6 ++ android/res/drawable/button_ghost.xml | 6 ++ ...border.xml => button_ghost_background.xml} | 7 +- .../button_ghost_background_disabled.xml | 9 ++ ...button_ghost_background_disabled_night.xml | 9 ++ android/res/drawable/button_ghost_night.xml | 6 ++ android/res/drawable/dot_divider.xml | 2 +- android/res/drawable/img_google.xml | 6 ++ .../layout/fragment_auth_passport_dialog.xml | 85 ++++++++++++++++--- android/res/values/colors.xml | 15 ++-- android/res/values/styles-text.xml | 4 + android/res/values/themes-attrs.xml | 2 + android/res/values/themes-base.xml | 10 ++- .../maps/auth/SocialAuthDialogFragment.java | 45 +++++++++- 17 files changed, 204 insertions(+), 26 deletions(-) create mode 100644 android/res/color-v21/button_text_ghost_night.xml create mode 100644 android/res/color/button_text_accent.xml create mode 100644 android/res/color/button_text_accent_night.xml create mode 100644 android/res/color/button_text_ghost.xml create mode 100644 android/res/drawable/button_ghost.xml rename android/res/drawable/{button_transparent_with_border.xml => button_ghost_background.xml} (51%) create mode 100644 android/res/drawable/button_ghost_background_disabled.xml create mode 100644 android/res/drawable/button_ghost_background_disabled_night.xml create mode 100644 android/res/drawable/button_ghost_night.xml create mode 100644 android/res/drawable/img_google.xml diff --git a/android/res/color-v21/button_text_ghost_night.xml b/android/res/color-v21/button_text_ghost_night.xml new file mode 100644 index 0000000000..7be887c7d4 --- /dev/null +++ b/android/res/color-v21/button_text_ghost_night.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/android/res/color/button_text_accent.xml b/android/res/color/button_text_accent.xml new file mode 100644 index 0000000000..ecb8ab482b --- /dev/null +++ b/android/res/color/button_text_accent.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/android/res/color/button_text_accent_night.xml b/android/res/color/button_text_accent_night.xml new file mode 100644 index 0000000000..708b2f13a6 --- /dev/null +++ b/android/res/color/button_text_accent_night.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/android/res/color/button_text_ghost.xml b/android/res/color/button_text_ghost.xml new file mode 100644 index 0000000000..3a913171da --- /dev/null +++ b/android/res/color/button_text_ghost.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/android/res/drawable/button_ghost.xml b/android/res/drawable/button_ghost.xml new file mode 100644 index 0000000000..c031483506 --- /dev/null +++ b/android/res/drawable/button_ghost.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/android/res/drawable/button_transparent_with_border.xml b/android/res/drawable/button_ghost_background.xml similarity index 51% rename from android/res/drawable/button_transparent_with_border.xml rename to android/res/drawable/button_ghost_background.xml index 863460dc93..df056581fa 100644 --- a/android/res/drawable/button_transparent_with_border.xml +++ b/android/res/drawable/button_ghost_background.xml @@ -1,6 +1,9 @@ - + - + diff --git a/android/res/drawable/button_ghost_background_disabled.xml b/android/res/drawable/button_ghost_background_disabled.xml new file mode 100644 index 0000000000..853565b77e --- /dev/null +++ b/android/res/drawable/button_ghost_background_disabled.xml @@ -0,0 +1,9 @@ + + + + + + diff --git a/android/res/drawable/button_ghost_background_disabled_night.xml b/android/res/drawable/button_ghost_background_disabled_night.xml new file mode 100644 index 0000000000..985c0c086d --- /dev/null +++ b/android/res/drawable/button_ghost_background_disabled_night.xml @@ -0,0 +1,9 @@ + + + + + + diff --git a/android/res/drawable/button_ghost_night.xml b/android/res/drawable/button_ghost_night.xml new file mode 100644 index 0000000000..94e5d588b3 --- /dev/null +++ b/android/res/drawable/button_ghost_night.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/android/res/drawable/dot_divider.xml b/android/res/drawable/dot_divider.xml index 2b8cb7e184..292482be7e 100644 --- a/android/res/drawable/dot_divider.xml +++ b/android/res/drawable/dot_divider.xml @@ -4,5 +4,5 @@ - + diff --git a/android/res/drawable/img_google.xml b/android/res/drawable/img_google.xml new file mode 100644 index 0000000000..9f012aff9b --- /dev/null +++ b/android/res/drawable/img_google.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/android/res/layout/fragment_auth_passport_dialog.xml b/android/res/layout/fragment_auth_passport_dialog.xml index 9d0bb18c15..857342329e 100644 --- a/android/res/layout/fragment_auth_passport_dialog.xml +++ b/android/res/layout/fragment_auth_passport_dialog.xml @@ -8,31 +8,88 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" - android:paddingStart="@dimen/margin_base_plus" - android:paddingLeft="@dimen/margin_base_plus" - android:paddingEnd="@dimen/margin_base_plus" - android:paddingRight="@dimen/margin_base_plus" - android:paddingBottom="@dimen/auth_dialog_padding_bottom" - android:paddingTop="@dimen/auth_dialog_padding_top"> + android:padding="@dimen/margin_base_plus"> + android:layout_marginTop="@dimen/margin_half_plus" + android:textAppearance="@style/MwmTextAppearance.Body3.Primary" + android:layout_marginBottom="@dimen/margin_half" + android:text="@string/sign_message_gdpr"/> + + + + + + + + + + + + @color/black_primary @color/black_secondary - @color/black_lightest + @color/black_38 @color/white_primary @color/white_secondary @color/white_lightest @@ -19,13 +19,13 @@ #DE000000 #8A000000 - #61000000 #0A000000 #14000000 #1C000000 #1E000000 #3D000000 - #99000000 + #61000000 + #99000000 #FFFFFFFF #B3FFFFFF #4CFFFFFF @@ -33,8 +33,9 @@ #14FFFFFF #1CFFFFFF #1EFFFFFF - #3DFFFFFF - #99FFFFFF + #3DFFFFFF + #61FFFFFF + #99FFFFFF #FF999691 #FF999691 @@ -95,7 +96,7 @@ #66999999 #40CCCCCC #00000000 - #00000000 + @color/white_12 #FF000000 #FFFFFFFF #42000000 @@ -107,7 +108,7 @@ @color/base_accent_night #FF1C85D6 #FF3C9BBE - #FFEFEFEF + @color/black_12 #FF505050 #FFFFFFFF #FF000000 diff --git a/android/res/values/styles-text.xml b/android/res/values/styles-text.xml index 737a4d83f5..2b19bab468 100644 --- a/android/res/values/styles-text.xml +++ b/android/res/values/styles-text.xml @@ -44,6 +44,10 @@ ?android:textColorSecondary + + diff --git a/android/res/values/themes-attrs.xml b/android/res/values/themes-attrs.xml index b76405fd01..8086b87076 100644 --- a/android/res/values/themes-attrs.xml +++ b/android/res/values/themes-attrs.xml @@ -40,6 +40,8 @@ + + diff --git a/android/res/values/themes-base.xml b/android/res/values/themes-base.xml index 73d9dcc111..d4883ac2f2 100644 --- a/android/res/values/themes-base.xml +++ b/android/res/values/themes-base.xml @@ -49,8 +49,12 @@ @drawable/button_accent @drawable/button_accent_round - @color/button_accent_text + @color/button_text_accent + @color/button_accent_text_disabled + @drawable/button_ghost + @color/button_text_ghost @drawable/button_red @color/button_red_text @@ -171,7 +175,11 @@ @drawable/button_accent_night @drawable/button_accent_round_night @color/button_accent_text_night + @color/button_accent_text_disabled_night + @drawable/button_ghost_night + @color/button_text_ghost_night @drawable/button_red @color/button_red_text diff --git a/android/src/com/mapswithme/maps/auth/SocialAuthDialogFragment.java b/android/src/com/mapswithme/maps/auth/SocialAuthDialogFragment.java index 50578efd75..17ee8945d7 100644 --- a/android/src/com/mapswithme/maps/auth/SocialAuthDialogFragment.java +++ b/android/src/com/mapswithme/maps/auth/SocialAuthDialogFragment.java @@ -5,14 +5,18 @@ import android.app.Dialog; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; +import android.support.annotation.IdRes; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; 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; @@ -77,7 +81,6 @@ public class SocialAuthDialogFragment extends BaseMwmDialogFragment { PhoneAuthActivity.startForResult(this); }; - @NonNull private final View.OnClickListener mGoogleClickListener = new View.OnClickListener() { @@ -88,6 +91,12 @@ public class SocialAuthDialogFragment extends BaseMwmDialogFragment startActivity(intent); } }; + @SuppressWarnings("NullableProblems") + @NonNull + private CheckBox mPrivacyPolicyCheck; + @SuppressWarnings("NullableProblems") + @NonNull + private CheckBox mTermOfUseCheck; @NonNull @Override @@ -126,9 +135,43 @@ public class SocialAuthDialogFragment extends BaseMwmDialogFragment View phoneButton = view.findViewById(R.id.phone_button); phoneButton.setOnClickListener(mPhoneClickListener); + + mPrivacyPolicyCheck = view.findViewById(R.id.privacyPolicyCheck); + mPrivacyPolicyCheck.setOnCheckedChangeListener((buttonView, isChecked) -> { + setButtonAvailability(view, isChecked && mTermOfUseCheck.isChecked(), + R.id.google_button, R.id.facebook_button, R.id.phone_button); + }); + + mTermOfUseCheck = view.findViewById(R.id.termOfUseCheck); + mTermOfUseCheck.setOnCheckedChangeListener((buttonView, isChecked) -> { + setButtonAvailability(view, isChecked && mPrivacyPolicyCheck.isChecked(), + R.id.google_button, R.id.facebook_button, R.id.phone_button); + }); + + linkifyPolicyViews(view, R.id.privacyPolicyLink, R.id.termOfUseLink); + setButtonAvailability(view, false, R.id.google_button, R.id.facebook_button, + R.id.phone_button); return view; } + private static void linkifyPolicyViews(@NonNull View root, @IdRes int... ids) + { + for(int id: ids) + { + TextView policyView = root.findViewById(id); + policyView.setMovementMethod(LinkMovementMethod.getInstance()); + } + } + + private static void setButtonAvailability(@NonNull View root, boolean available, @IdRes int... ids) + { + for(int id: ids) + { + View button = root.findViewById(id); + button.setEnabled(available); + } + } + @Override public void onResume() {