Skip to content

Commit 4137a21

Browse files
authored
Merge pull request #740 from firebase/phone-auth
Merge phone auth into version-2.0.0
2 parents 6eba74c + f55c73b commit 4137a21

File tree

78 files changed

+5620
-155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+5620
-155
lines changed

app/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ dependencies {
3838
compile "com.google.firebase:firebase-database:$firebaseVersion"
3939
compile "com.google.firebase:firebase-storage:$firebaseVersion"
4040

41+
compile('com.facebook.android:facebook-android-sdk:4.22.1')
42+
compile("com.twitter.sdk.android:twitter-core:3.0.0@aar") { transitive = true }
43+
4144
// The following dependencies are not required to use the Firebase UI library.
4245
// They are used to make some aspects of the demo app implementation simpler for
4346
// demonstrative purposes, and you may find them useful in your own apps; YMMV.

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ public class AuthUiActivity extends AppCompatActivity {
7171
@BindView(R.id.email_provider)
7272
CheckBox mUseEmailProvider;
7373

74+
@BindView(R.id.phone_provider)
75+
CheckBox mUsePhoneProvider;
76+
7477
@BindView(R.id.google_provider)
7578
CheckBox mUseGoogleProvider;
7679

@@ -107,8 +110,11 @@ public class AuthUiActivity extends AppCompatActivity {
107110
@BindView(R.id.no_logo)
108111
RadioButton mNoLogo;
109112

110-
@BindView(R.id.smartlock_enabled)
111-
CheckBox mEnableSmartLock;
113+
@BindView(R.id.credential_selector_enabled)
114+
CheckBox mEnableCredentialSelector;
115+
116+
@BindView(R.id.hint_selector_enabled)
117+
CheckBox mEnableHintSelector;
112118

113119
@BindView(R.id.allow_new_email_accounts)
114120
CheckBox mAllowNewEmailAccounts;
@@ -194,7 +200,8 @@ public void signIn(View view) {
194200
.setAvailableProviders(getSelectedProviders())
195201
.setTosUrl(getSelectedTosUrl())
196202
.setPrivacyPolicyUrl(getSelectedPrivacyPolicyUrl())
197-
.setIsSmartLockEnabled(mEnableSmartLock.isChecked())
203+
.setIsSmartLockEnabled(mEnableCredentialSelector.isChecked(),
204+
mEnableHintSelector.isChecked())
198205
.setAllowNewEmailAccounts(mAllowNewEmailAccounts.isChecked())
199206
.build(),
200207
RC_SIGN_IN);
@@ -252,7 +259,8 @@ private void startSignedInActivity(IdpResponse response) {
252259
getSelectedTheme(),
253260
getSelectedProviders(),
254261
getSelectedTosUrl(),
255-
mEnableSmartLock.isChecked())));
262+
mEnableCredentialSelector.isChecked(),
263+
mEnableHintSelector.isChecked())));
256264
}
257265

258266
@MainThread
@@ -324,6 +332,11 @@ private List<IdpConfig> getSelectedProviders() {
324332
selectedProviders.add(new IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build());
325333
}
326334

335+
if (mUsePhoneProvider.isChecked()) {
336+
selectedProviders.add(
337+
new IdpConfig.Builder(AuthUI.PHONE_VERIFICATION_PROVIDER).build());
338+
}
339+
327340
return selectedProviders;
328341
}
329342

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ public class SignedInActivity extends AppCompatActivity {
6868
@BindView(R.id.user_display_name)
6969
TextView mUserDisplayName;
7070

71+
72+
@BindView(R.id.user_phone_number)
73+
TextView mUserPhoneNumber;
74+
7175
@BindView(R.id.user_enabled_providers)
7276
TextView mEnabledProviders;
7377

@@ -157,6 +161,8 @@ private void populateProfile() {
157161

158162
mUserEmail.setText(
159163
TextUtils.isEmpty(user.getEmail()) ? "No email" : user.getEmail());
164+
mUserPhoneNumber.setText(
165+
TextUtils.isEmpty(user.getPhoneNumber()) ? "No phone number" : user.getPhoneNumber());
160166
mUserDisplayName.setText(
161167
TextUtils.isEmpty(user.getDisplayName()) ? "No display name" : user.getDisplayName());
162168

@@ -223,18 +229,21 @@ static final class SignedInConfig implements Parcelable {
223229
int theme;
224230
List<IdpConfig> providerInfo;
225231
String tosUrl;
226-
boolean isSmartLockEnabled;
232+
boolean isCredentialSelectorEnabled;
233+
boolean isHintSelectorEnabled;
227234

228235
SignedInConfig(int logo,
229236
int theme,
230237
List<IdpConfig> providerInfo,
231238
String tosUrl,
232-
boolean isSmartLockEnabled) {
239+
boolean isCredentialSelectorEnabled,
240+
boolean isHintSelectorEnabled) {
233241
this.logo = logo;
234242
this.theme = theme;
235243
this.providerInfo = providerInfo;
236244
this.tosUrl = tosUrl;
237-
this.isSmartLockEnabled = isSmartLockEnabled;
245+
this.isCredentialSelectorEnabled = isCredentialSelectorEnabled;
246+
this.isHintSelectorEnabled = isHintSelectorEnabled;
238247
}
239248

240249
SignedInConfig(Parcel in) {
@@ -243,7 +252,8 @@ static final class SignedInConfig implements Parcelable {
243252
providerInfo = new ArrayList<>();
244253
in.readList(providerInfo, IdpConfig.class.getClassLoader());
245254
tosUrl = in.readString();
246-
isSmartLockEnabled = in.readInt() != 0;
255+
isCredentialSelectorEnabled = in.readInt() != 0;
256+
isHintSelectorEnabled = in.readInt() != 0;
247257
}
248258

249259
public static final Creator<SignedInConfig> CREATOR = new Creator<SignedInConfig>() {
@@ -269,7 +279,8 @@ public void writeToParcel(Parcel dest, int flags) {
269279
dest.writeInt(theme);
270280
dest.writeList(providerInfo);
271281
dest.writeString(tosUrl);
272-
dest.writeInt(isSmartLockEnabled ? 1 : 0);
282+
dest.writeInt(isCredentialSelectorEnabled ? 1 : 0);
283+
dest.writeInt(isHintSelectorEnabled ? 1 : 0);
273284
}
274285
}
275286

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@
112112
android:checked="true"
113113
android:text="@string/email_label"/>
114114

115+
<CheckBox
116+
android:id="@+id/phone_provider"
117+
android:layout_width="wrap_content"
118+
android:layout_height="wrap_content"
119+
android:checked="true"
120+
android:text="@string/phone_label"/>
121+
115122
<TextView
116123
style="@style/Base.TextAppearance.AppCompat.Subhead"
117124
android:layout_width="wrap_content"
@@ -257,11 +264,18 @@
257264
android:text="@string/other_options_header"/>
258265

259266
<CheckBox
260-
android:id="@+id/smartlock_enabled"
267+
android:id="@+id/credential_selector_enabled"
268+
android:layout_width="wrap_content"
269+
android:layout_height="wrap_content"
270+
android:checked="true"
271+
android:text="@string/enable_credential_selector"/>
272+
273+
<CheckBox
274+
android:id="@+id/hint_selector_enabled"
261275
android:layout_width="wrap_content"
262276
android:layout_height="wrap_content"
263277
android:checked="true"
264-
android:text="@string/enable_smartlock"/>
278+
android:text="@string/enable_hint_selector"/>
265279

266280
<CheckBox
267281
android:id="@+id/allow_new_email_accounts"

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@
8484
android:layout_height="wrap_content"
8585
android:textIsSelectable="true"/>
8686

87+
<TextView
88+
android:id="@+id/user_phone_number"
89+
android:layout_width="wrap_content"
90+
android:layout_height="wrap_content"
91+
android:textIsSelectable="true"/>
92+
8793
<TextView
8894
android:id="@+id/user_display_name"
8995
android:layout_width="wrap_content"

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<string name="no_logo_label">None</string>
2424
<string name="auth_providers_header">Use auth providers:</string>
2525
<string name="email_label">Email</string>
26+
<string name="phone_label">Phone</string>
2627
<string name="facebook_label">Facebook</string>
2728
<string name="facebook_label_missing_config">Facebook - configuration missing</string>
2829
<string name="twitter_label">Twitter</string>
@@ -49,7 +50,6 @@
4950
<string name="default_theme">Default theme</string>
5051
<string name="configuration_required">Configuration is required - see README.md</string>
5152
<string name="other_options_header">Other Options:</string>
52-
<string name="enable_smartlock">Enable SmartLock for Passwords</string>
5353
<string name="rational_image_perm">This sample will read an image from local storage to upload to Cloud Storage.</string>
5454
<string name="anonymous_auth_failed_msg">Anonymous authentication failed, various components of the demo will not work. Make sure your device is online and that Anonymous Auth is configured in your Firebase project(https://console.firebase.google.com/project/_/authentication/providers)</string>
5555
<string name="extra_google_scopes">Example extra Google scopes</string>
@@ -71,4 +71,6 @@
7171
<!-- strings for database demo activities -->
7272
<string name="start_chatting">No messages. Start chatting at the bottom!</string>
7373
<string name="signed_in">Signed In</string>
74+
<string name="enable_credential_selector">Enable Smart Lock\'s credential selector</string>
75+
<string name="enable_hint_selector">Enable Smart Lock\'s hint selector</string>
7476
</resources>

auth/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ Gradle, add the dependency:
4747
dependencies {
4848
// ...
4949
compile 'com.firebaseui:firebase-ui-auth:1.2.0'
50+
51+
// Required only if Facebook login support is required
52+
compile('com.facebook.android:facebook-android-sdk:4.22.1')
53+
54+
// Required only if Twitter login support is required
55+
compile("com.twitter.sdk.android:twitter-core:3.0.0@aar") { transitive = true }
5056
}
5157
```
5258

auth/auth-proguard.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-dontwarn com.twitter.**
2+
-dontwarn com.facebook.**

auth/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
apply plugin: 'com.android.library'
2-
apply plugin: 'io.fabric'
32
apply from: '../library/quality/quality.gradle'
43

54
android {
@@ -18,7 +17,7 @@ android {
1817
manifestPlaceholders = [enableFbLogging: true]
1918

2019
minifyEnabled false
21-
proguardFiles getDefaultProguardFile('proguard-android.txt')
20+
consumerProguardFiles getDefaultProguardFile('proguard-android.txt'), 'auth-proguard.pro'
2221
}
2322

2423
debug {
@@ -44,8 +43,8 @@ dependencies {
4443
compile "com.google.firebase:firebase-auth:$firebaseVersion"
4544
compile "com.google.android.gms:play-services-auth:$firebaseVersion"
4645

47-
compile 'com.facebook.android:facebook-android-sdk:4.23.0'
48-
compile("com.twitter.sdk.android:twitter:2.3.2@aar") { transitive = true }
46+
provided 'com.facebook.android:facebook-android-sdk:4.23.0'
47+
provided("com.twitter.sdk.android:twitter-core:3.0.0@aar") { transitive = true }
4948

5049
// The following libraries are needed to prevent incompatibilities with the facebook
5150
// library when updating com.android.support libraries:
@@ -57,6 +56,7 @@ dependencies {
5756
testCompile 'org.robolectric:robolectric:3.2.2'
5857
// See https://github.com/robolectric/robolectric/issues/1932#issuecomment-219796474
5958
testCompile 'org.khronos:opengl-api:gl1.1-android-2.1_r1'
59+
testCompile 'com.facebook.android:facebook-android-sdk:4.23.0'
6060
}
6161

6262
javadoc.exclude([

auth/src/main/AndroidManifest.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<manifest
22
xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
34
package="com.firebase.ui.auth">
45

56
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
@@ -39,6 +40,12 @@
3940
android:label="@string/sign_in_default"
4041
android:exported="false"/>
4142

43+
<activity
44+
android:name=".ui.phone.PhoneVerificationActivity"
45+
android:label="@string/sign_in_with_phone_number"
46+
android:windowSoftInputMode="stateAlwaysVisible"
47+
android:exported="false"/>
48+
4249
<activity
4350
android:name=".ui.accountlink.WelcomeBackIdpPrompt"
4451
android:label="@string/title_welcome_back_idp_prompt"
@@ -57,11 +64,13 @@
5764
<activity
5865
android:name="com.facebook.FacebookActivity"
5966
android:label="@string/app_name"
60-
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"/>
67+
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
68+
tools:ignore="MissingRegistered" />
6169

6270
<activity
6371
android:name="com.facebook.CustomTabActivity"
64-
android:exported="true">
72+
android:exported="true"
73+
tools:ignore="MissingRegistered">
6574
<intent-filter>
6675
<action android:name="android.intent.action.VIEW"/>
6776

0 commit comments

Comments
 (0)