From cde044f1f5adc47fa2af10263bf634a52ec38fac Mon Sep 17 00:00:00 2001 From: Willie Chalmers III Date: Thu, 25 May 2017 18:35:24 -0500 Subject: [PATCH 1/6] Add sign-in intent builder support for privacy policy URLS. --- .../java/com/firebase/ui/auth/AuthUI.java | 11 ++++++ .../firebase/ui/auth/ui/FlowParameters.java | 8 +++++ .../auth/ui/email/RegisterEmailFragment.java | 36 +++++++++++++++++++ auth/src/main/res/values/strings.xml | 1 + 4 files changed, 56 insertions(+) diff --git a/auth/src/main/java/com/firebase/ui/auth/AuthUI.java b/auth/src/main/java/com/firebase/ui/auth/AuthUI.java index 465e3e5ad..ad244468b 100644 --- a/auth/src/main/java/com/firebase/ui/auth/AuthUI.java +++ b/auth/src/main/java/com/firebase/ui/auth/AuthUI.java @@ -449,6 +449,7 @@ private abstract class AuthIntentBuilder { int mTheme = getDefaultTheme(); List mProviders = new ArrayList<>(); String mTosUrl; + String mPrivacyPolicyUrl; boolean mIsSmartLockEnabled = true; private AuthIntentBuilder() {} @@ -483,6 +484,14 @@ public T setTosUrl(@Nullable String tosUrl) { return (T) this; } + /** + * Specifies the privacy policy URL for the application. + */ + public T setPrivacyPolicyUrl(@Nullable String privacyPolicyUrl) { + mPrivacyPolicyUrl = privacyPolicyUrl; + return (T) this; + } + /** * Specified the set of supported authentication providers. At least one provider must * be specified. There may only be one instance of each provider. @@ -631,6 +640,7 @@ protected FlowParameters getFlowParams() { mTheme, mLogo, mTosUrl, + mPrivacyPolicyUrl, mIsSmartLockEnabled, false, true, @@ -666,6 +676,7 @@ protected FlowParameters getFlowParams() { mTheme, mLogo, mTosUrl, + mPrivacyPolicyUrl, mIsSmartLockEnabled, mAllowNewEmailAccounts, false, diff --git a/auth/src/main/java/com/firebase/ui/auth/ui/FlowParameters.java b/auth/src/main/java/com/firebase/ui/auth/ui/FlowParameters.java index 8df2c034a..457c7dc05 100644 --- a/auth/src/main/java/com/firebase/ui/auth/ui/FlowParameters.java +++ b/auth/src/main/java/com/firebase/ui/auth/ui/FlowParameters.java @@ -48,6 +48,9 @@ public class FlowParameters implements Parcelable { @Nullable public final String termsOfServiceUrl; + @Nullable + public final String privacyPolicyUrl; + public final boolean smartLockEnabled; public final boolean allowNewEmailAccounts; @@ -62,6 +65,7 @@ public FlowParameters( @StyleRes int themeId, @DrawableRes int logoId, @Nullable String termsOfServiceUrl, + @Nullable String privacyPolicyUrl, boolean smartLockEnabled, boolean allowNewEmailAccounts, boolean isReauth, @@ -72,6 +76,7 @@ public FlowParameters( this.themeId = themeId; this.logoId = logoId; this.termsOfServiceUrl = termsOfServiceUrl; + this.privacyPolicyUrl = privacyPolicyUrl; this.smartLockEnabled = smartLockEnabled; this.allowNewEmailAccounts = allowNewEmailAccounts; this.isReauth = isReauth; @@ -85,6 +90,7 @@ public void writeToParcel(Parcel dest, int flags) { dest.writeInt(themeId); dest.writeInt(logoId); dest.writeString(termsOfServiceUrl); + dest.writeString(privacyPolicyUrl); dest.writeInt(smartLockEnabled ? 1 : 0); dest.writeInt(allowNewEmailAccounts ? 1 : 0); dest.writeInt(isReauth ? 1 : 0); @@ -104,6 +110,7 @@ public FlowParameters createFromParcel(Parcel in) { int themeId = in.readInt(); int logoId = in.readInt(); String termsOfServiceUrl = in.readString(); + String privacyPolicyUrl = in.readString(); boolean smartLockEnabled = in.readInt() != 0; boolean allowNewEmailAccounts = in.readInt() != 0; boolean isReauth = in.readInt() != 0; @@ -115,6 +122,7 @@ public FlowParameters createFromParcel(Parcel in) { themeId, logoId, termsOfServiceUrl, + privacyPolicyUrl, smartLockEnabled, allowNewEmailAccounts, isReauth, diff --git a/auth/src/main/java/com/firebase/ui/auth/ui/email/RegisterEmailFragment.java b/auth/src/main/java/com/firebase/ui/auth/ui/email/RegisterEmailFragment.java index 04b0e2ef5..a7b8d2b86 100644 --- a/auth/src/main/java/com/firebase/ui/auth/ui/email/RegisterEmailFragment.java +++ b/auth/src/main/java/com/firebase/ui/auth/ui/email/RegisterEmailFragment.java @@ -9,8 +9,10 @@ import android.support.customtabs.CustomTabsIntent; import android.support.design.widget.TextInputLayout; import android.support.v4.content.ContextCompat; +import android.text.SpannableString; import android.text.SpannableStringBuilder; import android.text.TextUtils; +import android.text.style.ClickableSpan; import android.text.style.ForegroundColorSpan; import android.util.TypedValue; import android.view.LayoutInflater; @@ -165,6 +167,7 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { mSaveSmartLock = mHelper.getSaveSmartLockInstance(getActivity()); setUpTermsOfService(); + setUpPrivacyPolicy(); } @Override @@ -210,6 +213,39 @@ public void onClick(View view) { }); } + private void setUpPrivacyPolicy() { + if (TextUtils.isEmpty(mHelper.getFlowParams().privacyPolicyUrl)) { + return; + } + + ForegroundColorSpan foregroundColorSpan = + new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.linkColor)); + + String link = getString(R.string.privacy_policy); + SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(link); + int start = mAgreementText.length(); + spannableStringBuilder.setSpan(foregroundColorSpan, start, start + link.length(), 0); + + mAgreementText.append(" and the "); + mAgreementText.append(spannableStringBuilder); + mAgreementText.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + // Getting default color + TypedValue typedValue = new TypedValue(); + getActivity().getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, true); + @ColorInt int color = typedValue.data; + + new CustomTabsIntent.Builder() + .setToolbarColor(color) + .build() + .launchUrl( + getActivity(), + Uri.parse(mHelper.getFlowParams().privacyPolicyUrl)); + } + }); + } + @Override public void onFocusChange(View view, boolean hasFocus) { if (hasFocus) return; // Only consider fields losing focus diff --git a/auth/src/main/res/values/strings.xml b/auth/src/main/res/values/strings.xml index d478de8bd..82bb2bd63 100644 --- a/auth/src/main/res/values/strings.xml +++ b/auth/src/main/res/values/strings.xml @@ -44,6 +44,7 @@ An account already exists with that email address. "By tapping SAVE you are indicating that you agree to the " Terms of Service + Privacy Policy @string/sign_in_default From cb92c8f9cb57d76a639f7283403a7e4422ec0c76 Mon Sep 17 00:00:00 2001 From: Willie Chalmers III Date: Thu, 25 May 2017 18:47:40 -0500 Subject: [PATCH 2/6] Update app sample to include privacy policy URL option --- .../firebase/uidemo/auth/AuthUiActivity.java | 14 ++++++++++++ app/src/main/res/layout/auth_ui_layout.xml | 22 +++++++++++++++++++ app/src/main/res/values/strings.xml | 2 ++ 3 files changed, 38 insertions(+) diff --git a/app/src/main/java/com/firebase/uidemo/auth/AuthUiActivity.java b/app/src/main/java/com/firebase/uidemo/auth/AuthUiActivity.java index 28ef0c772..5d9965dfd 100644 --- a/app/src/main/java/com/firebase/uidemo/auth/AuthUiActivity.java +++ b/app/src/main/java/com/firebase/uidemo/auth/AuthUiActivity.java @@ -52,6 +52,7 @@ public class AuthUiActivity extends AppCompatActivity { private static final String UNCHANGED_CONFIG_VALUE = "CHANGE-ME"; private static final String GOOGLE_TOS_URL = "https://www.google.com/policies/terms/"; private static final String FIREBASE_TOS_URL = "https://firebase.google.com/terms/"; + private static final String GOOGLE_PRIVACY_POLICY_URL = "https://www.google.com/policies/privacy/"; private static final int RC_SIGN_IN = 100; @BindView(R.id.default_theme) @@ -84,6 +85,9 @@ public class AuthUiActivity extends AppCompatActivity { @BindView(R.id.firebase_tos) RadioButton mUseFirebaseTos; + @BindView(R.id.google_privacy) + RadioButton mUseGooglePrivacyPolicy; + @BindView(R.id.sign_in) Button mSignIn; @@ -185,6 +189,7 @@ public void signIn(View view) { .setLogo(getSelectedLogo()) .setAvailableProviders(getSelectedProviders()) .setTosUrl(getSelectedTosUrl()) + .setPrivacyPolicyUrl(getSelectedPrivacyPolicyUrl()) .setIsSmartLockEnabled(mEnableSmartLock.isChecked()) .setAllowNewEmailAccounts(mAllowNewEmailAccounts.isChecked()) .build(), @@ -327,6 +332,15 @@ private String getSelectedTosUrl() { return FIREBASE_TOS_URL; } + @MainThread + private String getSelectedPrivacyPolicyUrl() { + if (mUseGooglePrivacyPolicy.isChecked()) { + return GOOGLE_PRIVACY_POLICY_URL; + } + + return GOOGLE_PRIVACY_POLICY_URL; + } + @MainThread private boolean isGoogleConfigured() { return !UNCHANGED_CONFIG_VALUE.equals( diff --git a/app/src/main/res/layout/auth_ui_layout.xml b/app/src/main/res/layout/auth_ui_layout.xml index 211b5803c..5148b6b36 100644 --- a/app/src/main/res/layout/auth_ui_layout.xml +++ b/app/src/main/res/layout/auth_ui_layout.xml @@ -140,6 +140,28 @@ + + + + + + + + Google - configuration missing Google TOS Firebase TOS + Google Privacy Policy Terms of Service URL: + Privacy Policy URL: Unexpected onActivityResult response code Unknown response from AuthUI sign-in Sign in cancelled From 97c1df273cc59d9248bc5e03cfafa095f05094f5 Mon Sep 17 00:00:00 2001 From: Willie Chalmers III Date: Thu, 25 May 2017 19:56:34 -0500 Subject: [PATCH 3/6] Fix auth library tests --- auth/src/test/java/com/firebase/ui/auth/AuthUITest.java | 2 ++ .../java/com/firebase/ui/auth/testhelpers/TestConstants.java | 1 + .../test/java/com/firebase/ui/auth/testhelpers/TestHelper.java | 1 + 3 files changed, 4 insertions(+) diff --git a/auth/src/test/java/com/firebase/ui/auth/AuthUITest.java b/auth/src/test/java/com/firebase/ui/auth/AuthUITest.java index 092e38237..0624d7859 100644 --- a/auth/src/test/java/com/firebase/ui/auth/AuthUITest.java +++ b/auth/src/test/java/com/firebase/ui/auth/AuthUITest.java @@ -83,12 +83,14 @@ public void testCreatingStartIntent() { new IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build(), new IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER).build())) .setTosUrl(TestConstants.TOS_URL) + .setPrivacyPolicyUrl(TestConstants.PRIVACY_URL) .build() .getParcelableExtra(ExtraConstants.EXTRA_FLOW_PARAMS); assertEquals(3, flowParameters.providerInfo.size()); assertEquals(mFirebaseApp.getName(), flowParameters.appName); assertEquals(TestConstants.TOS_URL, flowParameters.termsOfServiceUrl); + assertEquals(TestConstants.PRIVACY_URL, flowParameters.privacyPolicyUrl); assertEquals(AuthUI.getDefaultTheme(), flowParameters.themeId); } } diff --git a/auth/src/test/java/com/firebase/ui/auth/testhelpers/TestConstants.java b/auth/src/test/java/com/firebase/ui/auth/testhelpers/TestConstants.java index cf505fceb..0aa5ff89b 100644 --- a/auth/src/test/java/com/firebase/ui/auth/testhelpers/TestConstants.java +++ b/auth/src/test/java/com/firebase/ui/auth/testhelpers/TestConstants.java @@ -22,5 +22,6 @@ public class TestConstants { public static final String NAME = "Test Testerson"; public static final String TOKEN = "token"; public static final String TOS_URL = "http://www.google.com"; + public static final String PRIVACY_URL = "https://www.google.com/policies/privacy/"; public static final Uri PHOTO_URI = Uri.parse("http://example.com/profile.png"); } diff --git a/auth/src/test/java/com/firebase/ui/auth/testhelpers/TestHelper.java b/auth/src/test/java/com/firebase/ui/auth/testhelpers/TestHelper.java index e7a25c812..44be52f26 100644 --- a/auth/src/test/java/com/firebase/ui/auth/testhelpers/TestHelper.java +++ b/auth/src/test/java/com/firebase/ui/auth/testhelpers/TestHelper.java @@ -62,6 +62,7 @@ public static FlowParameters getFlowParameters(List providerIds) { AuthUI.getDefaultTheme(), AuthUI.NO_LOGO, null /* tosUrl */, + null /* privacyPolicyUrl */, true /* smartLockEnabled */, true /* allowNewEmailAccounts */, false /* isReauth */, From 2e9daf67565e8aec5d7453bb850d059daeb84b3f Mon Sep 17 00:00:00 2001 From: Willie Chalmers III Date: Thu, 25 May 2017 22:37:12 -0500 Subject: [PATCH 4/6] Add additional privacy policy URL to demo app --- .../main/java/com/firebase/uidemo/auth/AuthUiActivity.java | 6 +++++- app/src/main/res/layout/auth_ui_layout.xml | 6 ++++++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/firebase/uidemo/auth/AuthUiActivity.java b/app/src/main/java/com/firebase/uidemo/auth/AuthUiActivity.java index 5d9965dfd..b431a376b 100644 --- a/app/src/main/java/com/firebase/uidemo/auth/AuthUiActivity.java +++ b/app/src/main/java/com/firebase/uidemo/auth/AuthUiActivity.java @@ -53,6 +53,7 @@ public class AuthUiActivity extends AppCompatActivity { private static final String GOOGLE_TOS_URL = "https://www.google.com/policies/terms/"; private static final String FIREBASE_TOS_URL = "https://firebase.google.com/terms/"; private static final String GOOGLE_PRIVACY_POLICY_URL = "https://www.google.com/policies/privacy/"; + private static final String FIREBASE_PRIVACY_POLICY_URL = "https://firebase.google.com/terms/analytics/#7_privacy"; private static final int RC_SIGN_IN = 100; @BindView(R.id.default_theme) @@ -88,6 +89,9 @@ public class AuthUiActivity extends AppCompatActivity { @BindView(R.id.google_privacy) RadioButton mUseGooglePrivacyPolicy; + @BindView(R.id.firebase_privacy) + RadioButton mUseFirebasePrivacyPolicy; + @BindView(R.id.sign_in) Button mSignIn; @@ -338,7 +342,7 @@ private String getSelectedPrivacyPolicyUrl() { return GOOGLE_PRIVACY_POLICY_URL; } - return GOOGLE_PRIVACY_POLICY_URL; + return FIREBASE_PRIVACY_POLICY_URL; } @MainThread diff --git a/app/src/main/res/layout/auth_ui_layout.xml b/app/src/main/res/layout/auth_ui_layout.xml index 5148b6b36..36f4bc3ee 100644 --- a/app/src/main/res/layout/auth_ui_layout.xml +++ b/app/src/main/res/layout/auth_ui_layout.xml @@ -160,6 +160,12 @@ android:checked="true" android:text="@string/google_privacy_label"/> + + Google TOS Firebase TOS Google Privacy Policy + Firebase Privacy Policy Terms of Service URL: Privacy Policy URL: Unexpected onActivityResult response code From 3d4a798cc1c07268ab17d006f6b29f994c00fb6f Mon Sep 17 00:00:00 2001 From: Willie Chalmers III Date: Thu, 25 May 2017 22:37:52 -0500 Subject: [PATCH 5/6] Fix text span link bugs --- .../ui/auth/ui/email/PreambleHandler.java | 122 ++++++++++++++++++ .../auth/ui/email/RegisterEmailFragment.java | 78 +---------- auth/src/main/res/values/strings.xml | 6 +- 3 files changed, 128 insertions(+), 78 deletions(-) create mode 100644 auth/src/main/java/com/firebase/ui/auth/ui/email/PreambleHandler.java diff --git a/auth/src/main/java/com/firebase/ui/auth/ui/email/PreambleHandler.java b/auth/src/main/java/com/firebase/ui/auth/ui/email/PreambleHandler.java new file mode 100644 index 000000000..82becb643 --- /dev/null +++ b/auth/src/main/java/com/firebase/ui/auth/ui/email/PreambleHandler.java @@ -0,0 +1,122 @@ +package com.firebase.ui.auth.ui.email; + +import android.content.Context; +import android.net.Uri; +import android.support.annotation.ColorInt; +import android.support.annotation.StringRes; +import android.support.customtabs.CustomTabsIntent; +import android.support.v4.content.ContextCompat; +import android.text.SpannableStringBuilder; +import android.text.TextUtils; +import android.text.method.LinkMovementMethod; +import android.text.style.ClickableSpan; +import android.text.style.ForegroundColorSpan; +import android.util.TypedValue; +import android.view.View; +import android.widget.TextView; + +import com.firebase.ui.auth.R; +import com.firebase.ui.auth.ui.FlowParameters; + +public class PreambleHandler { + private static final String TOS_TARGET = "%TOS%"; + private static final String PP_TARGET = "%PP%"; + + private final Context mContext; + private final FlowParameters mFlowParameters; + private final ForegroundColorSpan mLinkSpan; + + private SpannableStringBuilder mBuilder; + + public PreambleHandler(Context context, FlowParameters parameters) { + mContext = context; + mFlowParameters = parameters; + mLinkSpan = new ForegroundColorSpan(ContextCompat.getColor(mContext, R.color.linkColor)); + + setupCreateAccountPreamble(); + } + + public void setPreamble(TextView textView) { + textView.setMovementMethod(LinkMovementMethod.getInstance()); + textView.setText(mBuilder); + } + + private void setupCreateAccountPreamble() { + int preambleType = getPreambleType(); + if (preambleType == -1) { + return; + } + + String[] preambles = + mContext.getResources().getStringArray(R.array.create_account_preamble); + mBuilder = new SpannableStringBuilder(preambles[preambleType]); + + replaceTarget(TOS_TARGET, R.string.terms_of_service, mFlowParameters.termsOfServiceUrl); + replaceTarget(PP_TARGET, R.string.privacy_policy, mFlowParameters.privacyPolicyUrl); + } + + private void replaceTarget(String target, @StringRes int replacementRes, String url) { + char[] currentPreambleChars = new char[mBuilder.length()]; + mBuilder.getChars(0, mBuilder.length(), currentPreambleChars, 0); + String currentPreamble = String.valueOf(currentPreambleChars); + + int targetIndex = currentPreamble.indexOf(target); + if (targetIndex != -1) { + String replacement = mContext.getString(replacementRes); + mBuilder.replace(targetIndex, targetIndex + target.length(), replacement); + + int end = targetIndex + replacement.length(); + mBuilder.setSpan(mLinkSpan, targetIndex, end, 0); + mBuilder.setSpan(new CustomTabsSpan(url), targetIndex, end, 0); + } + } + + /** + * 0 means we have both a TOS and a PP + *

1 means we only have a TOS + *

2 means we only have a PP + *

-1 means we have neither + */ + private int getPreambleType() { + int preambleType; + + boolean hasTos = !TextUtils.isEmpty(mFlowParameters.termsOfServiceUrl); + boolean hasPp = !TextUtils.isEmpty(mFlowParameters.privacyPolicyUrl); + + if (hasTos && hasPp) { + preambleType = 0; + } else if (hasTos) { + preambleType = 1; + } else if (hasPp) { + preambleType = 2; + } else { + preambleType = -1; + } + + return preambleType; + } + + private class CustomTabsSpan extends ClickableSpan { + private final String mUrl; + private final CustomTabsIntent mCustomTabsIntent; + + public CustomTabsSpan(String url) { + mUrl = url; + + // Getting default color + TypedValue typedValue = new TypedValue(); + mContext.getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, true); + @ColorInt int color = typedValue.data; + + mCustomTabsIntent = new CustomTabsIntent.Builder() + .setToolbarColor(color) + .setShowTitle(true) + .build(); + } + + @Override + public void onClick(View widget) { + mCustomTabsIntent.launchUrl(mContext, Uri.parse(mUrl)); + } + } +} diff --git a/auth/src/main/java/com/firebase/ui/auth/ui/email/RegisterEmailFragment.java b/auth/src/main/java/com/firebase/ui/auth/ui/email/RegisterEmailFragment.java index a7b8d2b86..dc9c8cce5 100644 --- a/auth/src/main/java/com/firebase/ui/auth/ui/email/RegisterEmailFragment.java +++ b/auth/src/main/java/com/firebase/ui/auth/ui/email/RegisterEmailFragment.java @@ -1,20 +1,11 @@ package com.firebase.ui.auth.ui.email; -import android.net.Uri; import android.os.Bundle; -import android.support.annotation.ColorInt; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.RestrictTo; -import android.support.customtabs.CustomTabsIntent; import android.support.design.widget.TextInputLayout; -import android.support.v4.content.ContextCompat; -import android.text.SpannableString; -import android.text.SpannableStringBuilder; import android.text.TextUtils; -import android.text.style.ClickableSpan; -import android.text.style.ForegroundColorSpan; -import android.util.TypedValue; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -166,8 +157,7 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { getActivity().setTitle(R.string.title_register_email); mSaveSmartLock = mHelper.getSaveSmartLockInstance(getActivity()); - setUpTermsOfService(); - setUpPrivacyPolicy(); + new PreambleHandler(getContext(), mHelper.getFlowParams()).setPreamble(mAgreementText); } @Override @@ -180,72 +170,6 @@ public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); } - private void setUpTermsOfService() { - if (TextUtils.isEmpty(mHelper.getFlowParams().termsOfServiceUrl)) { - return; - } - - ForegroundColorSpan foregroundColorSpan = - new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.linkColor)); - - String preamble = getString(R.string.create_account_preamble); - String link = getString(R.string.terms_of_service); - SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(preamble + link); - int start = preamble.length(); - spannableStringBuilder.setSpan(foregroundColorSpan, start, start + link.length(), 0); - - mAgreementText.setText(spannableStringBuilder); - mAgreementText.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - // Getting default color - TypedValue typedValue = new TypedValue(); - getActivity().getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, true); - @ColorInt int color = typedValue.data; - - new CustomTabsIntent.Builder() - .setToolbarColor(color) - .build() - .launchUrl( - getActivity(), - Uri.parse(mHelper.getFlowParams().termsOfServiceUrl)); - } - }); - } - - private void setUpPrivacyPolicy() { - if (TextUtils.isEmpty(mHelper.getFlowParams().privacyPolicyUrl)) { - return; - } - - ForegroundColorSpan foregroundColorSpan = - new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.linkColor)); - - String link = getString(R.string.privacy_policy); - SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(link); - int start = mAgreementText.length(); - spannableStringBuilder.setSpan(foregroundColorSpan, start, start + link.length(), 0); - - mAgreementText.append(" and the "); - mAgreementText.append(spannableStringBuilder); - mAgreementText.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - // Getting default color - TypedValue typedValue = new TypedValue(); - getActivity().getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, true); - @ColorInt int color = typedValue.data; - - new CustomTabsIntent.Builder() - .setToolbarColor(color) - .build() - .launchUrl( - getActivity(), - Uri.parse(mHelper.getFlowParams().privacyPolicyUrl)); - } - }); - } - @Override public void onFocusChange(View view, boolean hasFocus) { if (hasFocus) return; // Only consider fields losing focus diff --git a/auth/src/main/res/values/strings.xml b/auth/src/main/res/values/strings.xml index 82bb2bd63..a022ae08a 100644 --- a/auth/src/main/res/values/strings.xml +++ b/auth/src/main/res/values/strings.xml @@ -42,7 +42,11 @@ Email account registration unsuccessful An account already exists with that email address. - "By tapping SAVE you are indicating that you agree to the " + + By tapping SAVE you are indicating that you agree to the %TOS% and the %PP%. + By tapping SAVE you are indicating that you agree to the %TOS%. + By tapping SAVE you are indicating that you agree to the %PP%. + Terms of Service Privacy Policy From b48cba9eb8c33046b841d0b57fbf25ea8d469ad8 Mon Sep 17 00:00:00 2001 From: Willie Chalmers III Date: Sat, 27 May 2017 21:06:19 -0500 Subject: [PATCH 6/6] Simplify method replaceTarget --- .../java/com/firebase/ui/auth/ui/email/PreambleHandler.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/auth/src/main/java/com/firebase/ui/auth/ui/email/PreambleHandler.java b/auth/src/main/java/com/firebase/ui/auth/ui/email/PreambleHandler.java index 82becb643..1b621709b 100644 --- a/auth/src/main/java/com/firebase/ui/auth/ui/email/PreambleHandler.java +++ b/auth/src/main/java/com/firebase/ui/auth/ui/email/PreambleHandler.java @@ -56,11 +56,7 @@ private void setupCreateAccountPreamble() { } private void replaceTarget(String target, @StringRes int replacementRes, String url) { - char[] currentPreambleChars = new char[mBuilder.length()]; - mBuilder.getChars(0, mBuilder.length(), currentPreambleChars, 0); - String currentPreamble = String.valueOf(currentPreambleChars); - - int targetIndex = currentPreamble.indexOf(target); + int targetIndex = mBuilder.toString().indexOf(target); if (targetIndex != -1) { String replacement = mContext.getString(replacementRes); mBuilder.replace(targetIndex, targetIndex + target.length(), replacement);