Skip to content

Commit 696aa44

Browse files
committed
Merge branch 'version-2.0.0-dev' into phone-auth
Change-Id: I57574ae9e376e3c576218b4e18e16ad914a6c496
2 parents b61c950 + f528a22 commit 696aa44

File tree

19 files changed

+49
-224
lines changed

19 files changed

+49
-224
lines changed

app/src/main/java/com/firebase/uidemo/auth/SignedInActivity.java

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@
5353
import butterknife.OnClick;
5454

5555
public class SignedInActivity extends AppCompatActivity {
56-
private static final String EXTRA_SIGNED_IN_CONFIG = "extra_signed_in_config";
5756

58-
private static final int RC_REAUTH = 100;
57+
private static final String EXTRA_SIGNED_IN_CONFIG = "extra_signed_in_config";
5958

6059
@BindView(android.R.id.content)
6160
View mRootView;
@@ -117,22 +116,6 @@ public void onComplete(@NonNull Task<Void> task) {
117116
});
118117
}
119118

120-
@OnClick(R.id.reauthenticate)
121-
public void reauthenticate() {
122-
Intent reauthIntent = AuthUI.getInstance()
123-
.createReauthIntentBuilder()
124-
.setAvailableProviders(mSignedInConfig.providerInfo)
125-
.setIsSmartLockEnabled(mSignedInConfig.isCredentialSelectorEnabled,
126-
mSignedInConfig.isHintSelectorEnabled)
127-
.setLogo(mSignedInConfig.logo)
128-
.setTheme(mSignedInConfig.theme)
129-
.setTosUrl(mSignedInConfig.tosUrl)
130-
.setReauthReason(getString(R.string.reauthentication_reason))
131-
.build();
132-
133-
startActivityForResult(reauthIntent, RC_REAUTH);
134-
}
135-
136119
@OnClick(R.id.delete_account)
137120
public void deleteAccountClicked() {
138121

@@ -310,14 +293,4 @@ public static Intent createIntent(
310293
return startIntent.setClass(context, SignedInActivity.class)
311294
.putExtra(EXTRA_SIGNED_IN_CONFIG, signedInConfig);
312295
}
313-
314-
@Override
315-
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
316-
super.onActivityResult(requestCode, resultCode, data);
317-
if (requestCode == RC_REAUTH) {
318-
mIdpResponse = IdpResponse.fromResultIntent(data);
319-
populateIdpToken();
320-
populateProfile();
321-
}
322-
}
323296
}

app/src/main/res/layout/signed_in_layout.xml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,6 @@
4040
android:layout_margin="16dp"
4141
android:text="@string/sign_out"/>
4242

43-
<Button
44-
android:id="@+id/reauthenticate"
45-
style="@style/Widget.AppCompat.Button.Colored"
46-
android:layout_width="wrap_content"
47-
android:layout_height="wrap_content"
48-
android:layout_gravity="center"
49-
android:layout_margin="16dp"
50-
android:text="@string/reauthenticate"/>
51-
5243
<Button
5344
android:id="@+id/delete_account"
5445
android:layout_width="wrap_content"

app/src/main/res/values/strings.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@
6767
<string name="choose_image">Choose Image</string>
6868
<string name="accessibility_downloaded_image">Downloaded image</string>
6969
<string name="allow_new_email_acccount">Allow account creation if email does not exist.</string>
70-
<string name="reauthenticate">Reauth</string>
71-
<string name="reauthentication_reason">Reauth was requested from the test app. Please login to continue.</string>
7270

7371
<!-- strings for database demo activities -->
7472
<string name="start_chatting">No messages. Start chatting at the bottom!</string>

auth/src/main/java/com/firebase/ui/auth/AuthUI.java

Lines changed: 15 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import android.support.annotation.DrawableRes;
2323
import android.support.annotation.NonNull;
2424
import android.support.annotation.Nullable;
25+
import android.support.annotation.StringDef;
2526
import android.support.annotation.StyleRes;
2627
import android.support.v4.app.FragmentActivity;
2728

@@ -71,6 +72,14 @@
7172
* for examples on how to get started with FirebaseUI Auth.
7273
*/
7374
public class AuthUI {
75+
@StringDef({
76+
EmailAuthProvider.PROVIDER_ID, EMAIL_PROVIDER,
77+
PhoneAuthProvider.PROVIDER_ID, PHONE_VERIFICATION_PROVIDER,
78+
GoogleAuthProvider.PROVIDER_ID, GOOGLE_PROVIDER,
79+
FacebookAuthProvider.PROVIDER_ID, FACEBOOK_PROVIDER,
80+
TwitterAuthProvider.PROVIDER_ID, TWITTER_PROVIDER,
81+
})
82+
public @interface SupportedProvider {}
7483

7584
/**
7685
* Provider identifier for email and password credentials, for use with
@@ -319,13 +328,6 @@ public SignInIntentBuilder createSignInIntentBuilder() {
319328
return new SignInIntentBuilder();
320329
}
321330

322-
/**
323-
* Starts the reauthentication flow.
324-
*/
325-
public ReauthIntentBuilder createReauthIntentBuilder() {
326-
return new ReauthIntentBuilder();
327-
}
328-
329331
/**
330332
* Configuration for an identity provider.
331333
* <p>
@@ -336,7 +338,7 @@ public static class IdpConfig implements Parcelable {
336338
private final String mProviderId;
337339
private final List<String> mScopes;
338340

339-
private IdpConfig(@NonNull String providerId, List<String> scopes) {
341+
private IdpConfig(@SupportedProvider @NonNull String providerId, List<String> scopes) {
340342
mProviderId = providerId;
341343
mScopes = Collections.unmodifiableList(scopes);
342344
}
@@ -346,6 +348,7 @@ private IdpConfig(Parcel in) {
346348
mScopes = Collections.unmodifiableList(in.createStringArrayList());
347349
}
348350

351+
@SupportedProvider
349352
public String getProviderId() {
350353
return mProviderId;
351354
}
@@ -401,7 +404,7 @@ public String toString() {
401404
}
402405

403406
public static class Builder {
404-
private String mProviderId;
407+
@SupportedProvider private String mProviderId;
405408
private List<String> mScopes = new ArrayList<>();
406409

407410
/**
@@ -411,7 +414,7 @@ public static class Builder {
411414
* AuthUI#GOOGLE_PROVIDER}. See {@link AuthUI#SUPPORTED_PROVIDERS} for
412415
* the complete list of supported Identity providers
413416
*/
414-
public Builder(@NonNull String providerId) {
417+
public Builder(@SupportedProvider @NonNull String providerId) {
415418
if (!SUPPORTED_PROVIDERS.contains(providerId)) {
416419
throw new IllegalArgumentException("Unkown provider: " + providerId);
417420
}
@@ -444,7 +447,7 @@ public IdpConfig build() {
444447
}
445448

446449
/**
447-
* Base builder for both {@link SignInIntentBuilder} and {@link ReauthIntentBuilder}
450+
* Base builder for both {@link SignInIntentBuilder}.
448451
*/
449452
@SuppressWarnings(value = "unchecked")
450453
private abstract class AuthIntentBuilder<T extends AuthIntentBuilder> {
@@ -626,53 +629,6 @@ public Intent build() {
626629
protected abstract FlowParameters getFlowParams();
627630
}
628631

629-
/**
630-
* Builder for the intent to start the reauthentication flow.
631-
*/
632-
public final class ReauthIntentBuilder extends AuthIntentBuilder<ReauthIntentBuilder> {
633-
private String mReauthReason;
634-
635-
private ReauthIntentBuilder() {
636-
super();
637-
}
638-
639-
/**
640-
* Set an explanation for why reauth was requested e.g. "To delete your account you must
641-
* reauthenticate."
642-
*
643-
* @param reauthReason A string explaining why reauthentication was requested.
644-
*/
645-
public ReauthIntentBuilder setReauthReason(String reauthReason) {
646-
mReauthReason = reauthReason;
647-
return this;
648-
}
649-
650-
@Override
651-
public Intent build() {
652-
if (FirebaseAuth.getInstance(mApp).getCurrentUser() == null) {
653-
throw new IllegalStateException("User must be currently logged in to reauthenticate");
654-
}
655-
656-
return super.build();
657-
}
658-
659-
@Override
660-
protected FlowParameters getFlowParams() {
661-
return new FlowParameters(
662-
mApp.getName(),
663-
mProviders,
664-
mTheme,
665-
mLogo,
666-
mTosUrl,
667-
mPrivacyPolicyUrl,
668-
mEnableCredentials,
669-
mEnableHints,
670-
false,
671-
true,
672-
mReauthReason);
673-
}
674-
}
675-
676632
/**
677633
* Builder for the intent to start the user authentication flow.
678634
*/
@@ -704,9 +660,7 @@ protected FlowParameters getFlowParams() {
704660
mPrivacyPolicyUrl,
705661
mEnableCredentials,
706662
mEnableHints,
707-
mAllowNewEmailAccounts,
708-
false,
709-
null);
663+
mAllowNewEmailAccounts);
710664
}
711665
}
712666
}

auth/src/main/java/com/firebase/ui/auth/IdpResponse.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public Intent toIntent() {
8787
* Get the type of provider. e.g. {@link AuthUI#GOOGLE_PROVIDER}
8888
*/
8989
@NonNull
90+
@AuthUI.SupportedProvider
9091
public String getProviderType() {
9192
return mProviderId;
9293
}
@@ -164,7 +165,7 @@ public static class Builder {
164165
private String mToken;
165166
private String mSecret;
166167

167-
public Builder(@NonNull String providerId, @Nullable String email) {
168+
public Builder(@AuthUI.SupportedProvider @NonNull String providerId, @Nullable String email) {
168169
mProviderId = providerId;
169170
mEmail = email;
170171
}

auth/src/main/java/com/firebase/ui/auth/KickoffActivity.java

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
import android.content.Context;
44
import android.content.DialogInterface;
5-
import android.content.DialogInterface.OnClickListener;
65
import android.content.Intent;
76
import android.net.ConnectivityManager;
87
import android.os.Bundle;
98
import android.support.annotation.RestrictTo;
10-
import android.support.v7.app.AlertDialog;
11-
import android.text.TextUtils;
129
import android.util.Log;
10+
1311
import com.firebase.ui.auth.ui.ActivityHelper;
1412
import com.firebase.ui.auth.ui.ExtraConstants;
1513
import com.firebase.ui.auth.ui.FlowParameters;
@@ -87,41 +85,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
8785

8886
private void start() {
8987
FlowParameters flowParams = mActivityHelper.getFlowParams();
90-
if (flowParams.isReauth) {
91-
showReauthDialog();
92-
} else {
93-
SignInDelegate.delegate(this, flowParams);
94-
}
95-
}
96-
97-
private void showReauthDialog() {
98-
final FlowParameters flowParams = mActivityHelper.getFlowParams();
99-
AlertDialog.Builder builder = new AlertDialog.Builder(this)
100-
.setTitle(R.string.reauth_dialog_title)
101-
.setOnCancelListener(new DialogInterface.OnCancelListener() {
102-
@Override
103-
public void onCancel(DialogInterface dialog) {
104-
finish(ResultCodes.CANCELED, new Intent());
105-
}
106-
})
107-
.setPositiveButton(R.string.sign_in_default, new OnClickListener() {
108-
@Override
109-
public void onClick(DialogInterface dialog, int which) {
110-
SignInDelegate.delegate(KickoffActivity.this, flowParams);
111-
}
112-
})
113-
.setNegativeButton(android.R.string.cancel, new OnClickListener() {
114-
@Override
115-
public void onClick(DialogInterface dialog, int which) {
116-
finish(ResultCodes.CANCELED, new Intent());
117-
}
118-
});
119-
120-
if (!TextUtils.isEmpty(flowParams.reauthReason)) {
121-
builder.setMessage(flowParams.reauthReason);
122-
}
123-
124-
builder.create().show();
88+
SignInDelegate.delegate(this, flowParams);
12589
}
12690

12791
/**

auth/src/main/java/com/firebase/ui/auth/provider/FacebookProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public String getName(Context context) {
8989
}
9090

9191
@Override
92+
@AuthUI.SupportedProvider
9293
public String getProviderId() {
9394
return FacebookAuthProvider.PROVIDER_ID;
9495
}

auth/src/main/java/com/firebase/ui/auth/provider/GoogleProvider.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import android.util.Log;
2727
import android.widget.Toast;
2828

29+
import com.firebase.ui.auth.AuthUI;
2930
import com.firebase.ui.auth.AuthUI.IdpConfig;
3031
import com.firebase.ui.auth.IdpResponse;
3132
import com.firebase.ui.auth.R;
@@ -104,6 +105,7 @@ public String getName(Context context) {
104105
}
105106

106107
@Override
108+
@AuthUI.SupportedProvider
107109
public String getProviderId() {
108110
return GoogleAuthProvider.PROVIDER_ID;
109111
}

auth/src/main/java/com/firebase/ui/auth/provider/TwitterProvider.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.support.annotation.LayoutRes;
88
import android.util.Log;
99

10+
import com.firebase.ui.auth.AuthUI;
1011
import com.firebase.ui.auth.IdpResponse;
1112
import com.firebase.ui.auth.R;
1213
import com.google.firebase.auth.AuthCredential;
@@ -67,6 +68,7 @@ public String getName(Context context) {
6768
}
6869

6970
@Override
71+
@AuthUI.SupportedProvider
7072
public String getProviderId() {
7173
return TwitterAuthProvider.PROVIDER_ID;
7274
}

auth/src/main/java/com/firebase/ui/auth/ui/FlowParameters.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ public class FlowParameters implements Parcelable {
5353

5454
public final boolean allowNewEmailAccounts;
5555

56-
@Nullable
57-
public final String reauthReason;
58-
public final boolean isReauth;
59-
6056
public final boolean enableCredentials;
6157
public final boolean enableHints;
6258

@@ -69,9 +65,7 @@ public FlowParameters(
6965
@Nullable String privacyPolicyUrl,
7066
boolean enableCredentials,
7167
boolean enableHints,
72-
boolean allowNewEmailAccounts,
73-
boolean isReauth,
74-
String reauthReason) {
68+
boolean allowNewEmailAccounts) {
7569
this.appName = Preconditions.checkNotNull(appName, "appName cannot be null");
7670
this.providerInfo = Collections.unmodifiableList(
7771
Preconditions.checkNotNull(providerInfo, "providerInfo cannot be null"));
@@ -82,8 +76,6 @@ public FlowParameters(
8276
this.enableCredentials = enableCredentials;
8377
this.enableHints = enableHints;
8478
this.allowNewEmailAccounts = allowNewEmailAccounts;
85-
this.isReauth = isReauth;
86-
this.reauthReason = reauthReason;
8779
}
8880

8981
@Override
@@ -97,8 +89,6 @@ public void writeToParcel(Parcel dest, int flags) {
9789
dest.writeInt(enableCredentials ? 1 : 0);
9890
dest.writeInt(enableHints ? 1 : 0);
9991
dest.writeInt(allowNewEmailAccounts ? 1 : 0);
100-
dest.writeInt(isReauth ? 1 : 0);
101-
dest.writeString(reauthReason);
10292
}
10393

10494
@Override
@@ -118,8 +108,6 @@ public FlowParameters createFromParcel(Parcel in) {
118108
boolean enableCredentials = in.readInt() != 0;
119109
boolean enableHints = in.readInt() != 0;
120110
boolean allowNewEmailAccounts = in.readInt() != 0;
121-
boolean isReauth = in.readInt() != 0;
122-
String reauthReason = in.readString();
123111

124112
return new FlowParameters(
125113
appName,
@@ -130,9 +118,7 @@ public FlowParameters createFromParcel(Parcel in) {
130118
privacyPolicyUrl,
131119
enableCredentials,
132120
enableHints,
133-
allowNewEmailAccounts,
134-
isReauth,
135-
reauthReason);
121+
allowNewEmailAccounts);
136122
}
137123

138124
@Override

0 commit comments

Comments
 (0)