forked from organicmaps/organicmaps
[android] Added policy checkboxes on the social auth dialog
This commit is contained in:
parent
a67c4b04dd
commit
63433c9f37
17 changed files with 204 additions and 26 deletions
6
android/res/color-v21/button_text_ghost_night.xml
Normal file
6
android/res/color-v21/button_text_ghost_night.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="@color/white_primary"
|
||||
android:state_enabled="true"/>
|
||||
<item android:color="@color/white_38"/>
|
||||
</selector>
|
6
android/res/color/button_text_accent.xml
Normal file
6
android/res/color/button_text_accent.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="@color/button_accent_text"
|
||||
android:state_enabled="true"/>
|
||||
<item android:color="@color/black_38"/>
|
||||
</selector>
|
6
android/res/color/button_text_accent_night.xml
Normal file
6
android/res/color/button_text_accent_night.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="@color/button_accent_text_night"
|
||||
android:state_enabled="true"/>
|
||||
<item android:color="@color/white_38"/>
|
||||
</selector>
|
6
android/res/color/button_text_ghost.xml
Normal file
6
android/res/color/button_text_ghost.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="@color/black_primary"
|
||||
android:state_enabled="true"/>
|
||||
<item android:color="@color/black_38"/>
|
||||
</selector>
|
6
android/res/drawable/button_ghost.xml
Normal file
6
android/res/drawable/button_ghost.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/button_ghost_background"
|
||||
android:state_enabled="true"/>
|
||||
<item android:drawable="@drawable/button_ghost_background_disabled"/>
|
||||
</selector>
|
|
@ -1,6 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="@dimen/button_small_corner_radius"/>
|
||||
<solid android:color="@android:color/transparent"/>
|
||||
<stroke android:color="@color/divider" android:width="@dimen/divider_width"/>
|
||||
<stroke
|
||||
android:color="@color/divider"
|
||||
android:width="@dimen/divider_width"/>
|
||||
</shape>
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="@dimen/button_small_corner_radius"/>
|
||||
<solid android:color="@color/black_12"/>
|
||||
<stroke
|
||||
android:color="@color/divider"
|
||||
android:width="@dimen/divider_width"/>
|
||||
</shape>
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="@dimen/button_small_corner_radius"/>
|
||||
<solid android:color="@color/white_12"/>
|
||||
<stroke
|
||||
android:color="@color/divider"
|
||||
android:width="@dimen/divider_width"/>
|
||||
</shape>
|
6
android/res/drawable/button_ghost_night.xml
Normal file
6
android/res/drawable/button_ghost_night.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/button_ghost_background"
|
||||
android:state_enabled="true"/>
|
||||
<item android:drawable="@drawable/button_ghost_background_disabled_night"/>
|
||||
</selector>
|
|
@ -4,5 +4,5 @@
|
|||
<size android:width="4dp"
|
||||
android:height="4dp"/>
|
||||
|
||||
<solid android:color="@color/black_lightest"/>
|
||||
<solid android:color="@color/black_38"/>
|
||||
</shape>
|
||||
|
|
6
android/res/drawable/img_google.xml
Normal file
6
android/res/drawable/img_google.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="false"
|
||||
android:drawable="@drawable/ic_google_disabled"/>
|
||||
<item android:drawable="@drawable/ic_google"/>
|
||||
</selector>
|
|
@ -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">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/MwmTextAppearance.Headline"
|
||||
style="@style/MwmTheme.DialogTitleBase"
|
||||
android:text="@string/profile_authorization_title"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/margin_half_plus_eight"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body3"
|
||||
android:text="@string/profile_authorization_message"/>
|
||||
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"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="@dimen/margin_half"
|
||||
android:paddingBottom="@dimen/margin_half">
|
||||
<CheckBox
|
||||
android:id="@+id/privacyPolicyCheck"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
<TextView
|
||||
android:id="@+id/privacyPolicyLink"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/margin_base"
|
||||
android:layout_marginStart="@dimen/margin_base"
|
||||
android:linksClickable="true"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body3.Primary"
|
||||
android:text="@string/sign_agree_pp_gdpr"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="@dimen/margin_half"
|
||||
android:paddingBottom="@dimen/margin_half">
|
||||
<CheckBox
|
||||
android:id="@+id/termOfUseCheck"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
<TextView
|
||||
android:id="@+id/termOfUseLink"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/margin_base"
|
||||
android:layout_marginStart="@dimen/margin_base"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body3.Primary"
|
||||
android:text="@string/sign_agree_tof_gdpr"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="@dimen/margin_half"
|
||||
android:paddingBottom="@dimen/margin_half">
|
||||
<CheckBox
|
||||
android:id="@+id/newsCheck"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/margin_base"
|
||||
android:layout_marginStart="@dimen/margin_base"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body3.Primary"
|
||||
android:text="@string/sign_agree_news_gdpr"/>
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/google_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:foreground="?clickableBackground"
|
||||
android:background="@drawable/button_transparent_with_border"
|
||||
android:drawableStart="@drawable/ic_google"
|
||||
android:drawableLeft="@drawable/ic_google"
|
||||
android:background="?ghostButtonBackground"
|
||||
android:textColor="?ghostButtonTextColor"
|
||||
android:drawableStart="@drawable/img_google"
|
||||
android:drawableLeft="@drawable/img_google"
|
||||
android:paddingLeft="@dimen/margin_half_plus"
|
||||
android:paddingStart="@dimen/margin_half_plus"
|
||||
android:paddingRight="@dimen/margin_base_plus"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<!-- Text colors -->
|
||||
<color name="text_dark">@color/black_primary</color>
|
||||
<color name="text_dark_subtitle">@color/black_secondary</color>
|
||||
<color name="text_dark_hint">@color/black_lightest</color>
|
||||
<color name="text_dark_hint">@color/black_38</color>
|
||||
<color name="text_light">@color/white_primary</color>
|
||||
<color name="text_light_subtitle">@color/white_secondary</color>
|
||||
<color name="text_light_hint">@color/white_lightest</color>
|
||||
|
@ -19,13 +19,13 @@
|
|||
|
||||
<color name="black_primary">#DE000000</color> <!-- 87% black -->
|
||||
<color name="black_secondary">#8A000000</color> <!-- 54% black -->
|
||||
<color name="black_lightest">#61000000</color> <!-- 38% black -->
|
||||
<color name="black_4">#0A000000</color> <!-- 4% black -->
|
||||
<color name="black_8">#14000000</color> <!-- 8% black -->
|
||||
<color name="black_11">#1C000000</color> <!-- 11% black -->
|
||||
<color name="black_12">#1E000000</color> <!-- 12% black -->
|
||||
<color name="black_24">#3D000000</color> <!-- 24% black -->
|
||||
<color name="black_60">#99000000</color> <!-- 24% black -->
|
||||
<color name="black_38">#61000000</color> <!-- 38% black -->
|
||||
<color name="black_60">#99000000</color> <!-- 60% black -->
|
||||
<color name="white_primary">#FFFFFFFF</color> <!-- 100% white -->
|
||||
<color name="white_secondary">#B3FFFFFF</color> <!-- 70% white -->
|
||||
<color name="white_lightest">#4CFFFFFF</color> <!-- 50% white -->
|
||||
|
@ -33,8 +33,9 @@
|
|||
<color name="white_8">#14FFFFFF</color> <!-- 8% white -->
|
||||
<color name="white_11">#1CFFFFFF</color> <!-- 11% white -->
|
||||
<color name="white_12">#1EFFFFFF</color> <!-- 12% white -->
|
||||
<color name="white_24">#3DFFFFFF</color> <!-- 24% black -->
|
||||
<color name="white_60">#99FFFFFF</color> <!-- 24% black -->
|
||||
<color name="white_24">#3DFFFFFF</color> <!-- 24% white -->
|
||||
<color name="white_38">#61FFFFFF</color> <!-- 38% white -->
|
||||
<color name="white_60">#99FFFFFF</color> <!-- 60% white -->
|
||||
<color name="warm_gray">#FF999691</color>
|
||||
<color name="warm_gray_night">#FF999691</color>
|
||||
|
||||
|
@ -95,7 +96,7 @@
|
|||
<color name="button_pressed">#66999999</color>
|
||||
<color name="button_pressed_night">#40CCCCCC</color>
|
||||
<color name="button_disabled">#00000000</color>
|
||||
<color name="button_disabled_night">#00000000</color>
|
||||
<color name="button_disabled_night">@color/white_12</color>
|
||||
<color name="button_text">#FF000000</color>
|
||||
<color name="button_text_night">#FFFFFFFF</color>
|
||||
<color name="button_text_disabled">#42000000</color>
|
||||
|
@ -107,7 +108,7 @@
|
|||
<color name="button_accent_normal_night">@color/base_accent_night</color>
|
||||
<color name="button_accent_pressed">#FF1C85D6</color>
|
||||
<color name="button_accent_pressed_night">#FF3C9BBE</color>
|
||||
<color name="button_accent_disabled">#FFEFEFEF</color>
|
||||
<color name="button_accent_disabled">@color/black_12</color>
|
||||
<color name="button_accent_disabled_night">#FF505050</color>
|
||||
<color name="button_accent_text">#FFFFFFFF</color>
|
||||
<color name="button_accent_text_night">#FF000000</color>
|
||||
|
|
|
@ -44,6 +44,10 @@
|
|||
<item name="android:textColor">?android:textColorSecondary</item>
|
||||
</style>
|
||||
|
||||
<style name="MwmTextAppearance.Body2.Primary">
|
||||
<item name="android:textColor">?android:textColorPrimary</item>
|
||||
</style>
|
||||
|
||||
<style name="MwmTextAppearance.Body2.Light">
|
||||
<item name="android:textColor">?android:textColorPrimaryInverse</item>
|
||||
</style>
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
<attr name="accentButtonRoundBackground" format="reference"/>
|
||||
<attr name="accentButtonTextColor" format="color"/>
|
||||
<attr name="accentButtonTextColorDisabled" format="color"/>
|
||||
<attr name="ghostButtonBackground" format="reference"/>
|
||||
<attr name="ghostButtonTextColor" format="color"/>
|
||||
|
||||
<attr name="redButtonBackground" format="reference"/>
|
||||
<attr name="redButtonTextColor" format="color"/>
|
||||
|
|
|
@ -49,8 +49,12 @@
|
|||
|
||||
<item name="accentButtonBackground">@drawable/button_accent</item>
|
||||
<item name="accentButtonRoundBackground">@drawable/button_accent_round</item>
|
||||
<item name="accentButtonTextColor">@color/button_accent_text</item>
|
||||
<item name="accentButtonTextColor">@color/button_text_accent</item>
|
||||
<!-- TODO: remove accentButtonTextColorDisabled attribute and use everywhere
|
||||
accentButtonTextColor selector -->
|
||||
<item name="accentButtonTextColorDisabled">@color/button_accent_text_disabled</item>
|
||||
<item name="ghostButtonBackground">@drawable/button_ghost</item>
|
||||
<item name="ghostButtonTextColor">@color/button_text_ghost</item>
|
||||
|
||||
<item name="redButtonBackground">@drawable/button_red</item>
|
||||
<item name="redButtonTextColor">@color/button_red_text</item>
|
||||
|
@ -171,7 +175,11 @@
|
|||
<item name="accentButtonBackground">@drawable/button_accent_night</item>
|
||||
<item name="accentButtonRoundBackground">@drawable/button_accent_round_night</item>
|
||||
<item name="accentButtonTextColor">@color/button_accent_text_night</item>
|
||||
<!-- TODO: remove accentButtonTextColorDisabled attribute and use everywhere
|
||||
accentButtonTextColor selector -->
|
||||
<item name="accentButtonTextColorDisabled">@color/button_accent_text_disabled_night</item>
|
||||
<item name="ghostButtonBackground">@drawable/button_ghost_night</item>
|
||||
<item name="ghostButtonTextColor">@color/button_text_ghost_night</item>
|
||||
|
||||
<item name="redButtonBackground">@drawable/button_red</item>
|
||||
<item name="redButtonTextColor">@color/button_red_text</item>
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue