diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 697e455a8..27db59419 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -54,6 +54,7 @@ dependencies { // demonstrative purposes, and you may find them useful in your own apps; YMMV. implementation(Config.Libs.Misc.permissions) implementation(Config.Libs.Misc.butterKnife) + implementation(Config.Libs.Support.constraint) annotationProcessor(Config.Libs.Misc.butterKnifeCompiler) debugImplementation(Config.Libs.Misc.leakCanary) debugImplementation(Config.Libs.Misc.leakCanaryFragments) 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 7dd027952..7b0d45f71 100644 --- a/app/src/main/java/com/firebase/uidemo/auth/AuthUiActivity.java +++ b/app/src/main/java/com/firebase/uidemo/auth/AuthUiActivity.java @@ -49,7 +49,6 @@ import com.google.firebase.auth.FirebaseAuth; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import butterknife.BindView; @@ -79,6 +78,9 @@ public class AuthUiActivity extends AppCompatActivity { @BindView(R.id.phone_provider) CheckBox mUsePhoneProvider; @BindView(R.id.anonymous_provider) CheckBox mUseAnonymousProvider; + @BindView(R.id.default_layout) RadioButton mDefaultLayout; + @BindView(R.id.custom_layout) RadioButton mCustomLayout; + @BindView(R.id.default_theme) RadioButton mDefaultTheme; @BindView(R.id.green_theme) RadioButton mGreenTheme; @BindView(R.id.purple_theme) RadioButton mPurpleTheme; @@ -187,6 +189,24 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mUseEmailLinkProvider.setChecked(false); mUseEmailProvider.setChecked(true); + // The custom layout in this app only supports Email and Google providers. + mCustomLayout.setOnCheckedChangeListener(new OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + if (checked) { + mUseGoogleProvider.setChecked(true); + mUseEmailProvider.setChecked(true); + + mUseFacebookProvider.setChecked(false); + mUseTwitterProvider.setChecked(false); + mUseGitHubProvider.setChecked(false); + mUseEmailLinkProvider.setChecked(false); + mUsePhoneProvider.setChecked(false); + mUseAnonymousProvider.setChecked(false); + } + } + }); + if (ConfigurationUtils.isGoogleMisconfigured(this) || ConfigurationUtils.isFacebookMisconfigured(this) || ConfigurationUtils.isTwitterMisconfigured(this) @@ -241,6 +261,18 @@ public Intent buildSignInIntent(@Nullable String link) { .setIsSmartLockEnabled(mEnableCredentialSelector.isChecked(), mEnableHintSelector.isChecked()); + if (mCustomLayout.isChecked()) { + AuthMethodPickerLayout customLayout = new AuthMethodPickerLayout + .Builder(R.layout.auth_method_picker_custom_layout) + .setGoogleButtonId(R.id.custom_google_signin_button) + .setEmailButtonId(R.id.custom_email_signin_clickable_text) + .setTosAndPrivacyPolicyId(R.id.custom_tos_pp) + .build(); + + builder.setTheme(R.style.CustomTheme); + builder.setAuthMethodPickerLayout(customLayout); + } + if (getSelectedTosUrl() != null && getSelectedPrivacyPolicyUrl() != null) { builder.setTosAndPrivacyPolicyUrls( getSelectedTosUrl(), @@ -260,32 +292,6 @@ public Intent buildSignInIntent(@Nullable String link) { return builder.build(); } - @OnClick(R.id.customised_sign_in) - public void signInCustomLayout() { - AuthMethodPickerLayout customLayout = new AuthMethodPickerLayout - .Builder(R.layout.auth_method_picker_custom_layout) - .setupGoogleButtonId(R.id.custom_google_signin_button) - .setupEmailButtonId(R.id.custom_email_signin_clickable_text) - .build(); - - //For now we only test Google and Email - List availableProviders = Arrays.asList( - new AuthUI.IdpConfig.GoogleBuilder() - .setScopes(getGoogleScopes()) - .build(), - new IdpConfig.EmailBuilder() - .setRequireName(mRequireName.isChecked()) - .setAllowNewAccounts(mAllowNewEmailAccounts.isChecked()) - .build()); - - startActivityForResult( - AuthUI.getInstance().createSignInIntentBuilder() - .setAvailableProviders(availableProviders) - .setAuthMethodPickerLayout(customLayout) - .build(), - RC_SIGN_IN); - } - @OnClick(R.id.sign_in_silent) public void silentSignIn() { AuthUI.getInstance().silentSignIn(this, getSelectedProviders()) diff --git a/app/src/main/res/drawable/custom_bg_gradient.xml b/app/src/main/res/drawable/custom_bg_gradient.xml new file mode 100644 index 000000000..58479ea3c --- /dev/null +++ b/app/src/main/res/drawable/custom_bg_gradient.xml @@ -0,0 +1,7 @@ + + + + diff --git a/app/src/main/res/layout-land/auth_method_picker_custom_layout.xml b/app/src/main/res/layout-land/auth_method_picker_custom_layout.xml new file mode 100644 index 000000000..4a4c98863 --- /dev/null +++ b/app/src/main/res/layout-land/auth_method_picker_custom_layout.xml @@ -0,0 +1,190 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/auth_method_picker_custom_layout.xml b/app/src/main/res/layout/auth_method_picker_custom_layout.xml index 6e3ac625a..430f79318 100644 --- a/app/src/main/res/layout/auth_method_picker_custom_layout.xml +++ b/app/src/main/res/layout/auth_method_picker_custom_layout.xml @@ -1,57 +1,160 @@ - + + + + + + + + + + + + - - - - - -