Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
60 changes: 33 additions & 27 deletions app/src/main/java/com/firebase/uidemo/auth/AuthUiActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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(),
Expand All @@ -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<IdpConfig> 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())
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/drawable/custom_bg_gradient.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#7986cb"
android:endColor="#7e57c2"
android:angle="270"/>
</shape>
190 changes: 190 additions & 0 deletions app/src/main/res/layout-land/auth_method_picker_custom_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/custom_bg_gradient">

<android.support.constraint.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.4" />

<ImageView
android:id="@+id/custom_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="8dp"
android:src="@mipmap/ic_launcher_foreground"
app:layout_constraintBottom_toTopOf="@+id/custom_subheader"
app:layout_constraintEnd_toStartOf="@+id/guideline"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/header_idp_choice"
app:layout_constraintVertical_bias="0.0"
app:layout_constraintVertical_chainStyle="packed"
tools:ignore="ContentDescription" />

<TextView
android:id="@+id/custom_subheader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="8dp"
android:text="@string/custom_layout_subheader"
android:textColor="#FFFFFF"
app:layout_constraintTop_toBottomOf="@+id/custom_logo"
app:layout_constraintBottom_toTopOf="@+id/custom_tos_pp"
app:layout_constraintEnd_toEndOf="@+id/guideline"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" />


<!-- Horiz line, left of provider header -->
<FrameLayout
android:id="@+id/header_idp_wing_left"
style="@style/CustomWingOuter"
app:layout_constraintBottom_toBottomOf="@+id/header_idp_choice"
app:layout_constraintEnd_toStartOf="@+id/header_idp_choice"
app:layout_constraintStart_toEndOf="@+id/guideline"
app:layout_constraintTop_toTopOf="@+id/header_idp_choice">

<View style="@style/CustomWingInner" />

</FrameLayout>

<TextView
android:id="@+id/header_idp_choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/custom_layout_idp_header"
android:textAllCaps="true"
android:textColor="#FFFFFF"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintBottom_toTopOf="@+id/custom_google_signin_button"
app:layout_constraintEnd_toStartOf="@+id/header_idp_wing_right"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/header_idp_wing_left"
app:layout_constraintTop_toTopOf="parent" />

<!-- Horiz line, right of provider header -->
<FrameLayout
android:id="@+id/header_idp_wing_right"
style="@style/CustomWingOuter"
app:layout_constraintBottom_toBottomOf="@+id/header_idp_choice"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/header_idp_choice"
app:layout_constraintTop_toTopOf="@+id/header_idp_choice">

<View style="@style/CustomWingInner" />

</FrameLayout>

<!--
NOTE: This sample app uses this class from the FirebaseUI library to show the Google Sign
in button. However this button is NOT considered part of the public API and you should not
use it in your own app.
-->
<com.firebase.ui.auth.util.ui.SupportVectorDrawablesButton xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/custom_google_signin_button"
style="@style/FirebaseUI.Button.AccountChooser.GoogleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/fui_sign_in_with_google"
app:layout_constraintBottom_toTopOf="@+id/header_email"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="@+id/guideline"
app:layout_constraintTop_toBottomOf="@+id/header_idp_choice" />

<!-- Horiz line, left of email header -->
<FrameLayout
android:id="@+id/header_email_wing_left"
style="@style/CustomWingOuter"
app:layout_constraintBottom_toBottomOf="@+id/header_email"
app:layout_constraintEnd_toStartOf="@+id/header_email"
app:layout_constraintStart_toEndOf="@+id/guideline"
app:layout_constraintTop_toTopOf="@+id/header_email">

<View style="@style/CustomWingInner" />

</FrameLayout>

<TextView
android:id="@+id/header_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/custom_layout_email_header"
android:textAllCaps="true"
android:textColor="#FFFFFF"
app:layout_constraintBottom_toTopOf="@+id/custom_email_signin_clickable_text"
app:layout_constraintEnd_toStartOf="@+id/header_email_wing_right"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/header_email_wing_left"
app:layout_constraintTop_toBottomOf="@+id/custom_google_signin_button" />

<!-- Horiz line, right of email header -->
<FrameLayout
android:id="@+id/header_email_wing_right"
style="@style/CustomWingOuter"
app:layout_constraintBottom_toBottomOf="@+id/header_email"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/header_email"
app:layout_constraintTop_toTopOf="@+id/header_email">

<View style="@style/CustomWingInner" />

</FrameLayout>

<TextView
android:id="@+id/custom_email_signin_clickable_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="8dp"
android:clickable="true"
android:focusable="true"
android:text="@string/custom_layout_email_click_text"
android:textColor="#FFFFFF"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/guideline"
app:layout_constraintTop_toBottomOf="@+id/header_email" />

<TextView
android:id="@+id/custom_tos_pp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:gravity="center_horizontal"
android:textColor="#FFFFFF"
app:layout_constraintTop_toBottomOf="@+id/custom_subheader"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/guideline"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
tools:text="Terms of Service and Privacy Policy" />

</android.support.constraint.ConstraintLayout>
Loading