18
18
import android .content .Intent ;
19
19
import android .os .Bundle ;
20
20
import android .support .annotation .DrawableRes ;
21
+ import android .support .annotation .Nullable ;
21
22
import android .support .annotation .StringRes ;
22
23
import android .support .annotation .StyleRes ;
23
24
import android .support .design .widget .Snackbar ;
@@ -58,96 +59,49 @@ public class AuthUiActivity extends AppCompatActivity {
58
59
59
60
private static final int RC_SIGN_IN = 100 ;
60
61
61
- @ BindView (R .id .default_theme )
62
- RadioButton mUseDefaultTheme ;
62
+ @ BindView (R .id .root ) View mRootView ;
63
+ @ BindView ( R . id . sign_in ) Button mSignIn ;
63
64
64
- @ BindView (R .id .green_theme )
65
- RadioButton mUseGreenTheme ;
65
+ @ BindView (R .id .google_provider ) CheckBox mUseGoogleProvider ;
66
+ @ BindView (R .id .facebook_provider ) CheckBox mUseFacebookProvider ;
67
+ @ BindView (R .id .twitter_provider ) CheckBox mUseTwitterProvider ;
68
+ @ BindView (R .id .email_provider ) CheckBox mUseEmailProvider ;
69
+ @ BindView (R .id .phone_provider ) CheckBox mUsePhoneProvider ;
66
70
67
- @ BindView (R .id .purple_theme )
68
- RadioButton mUsePurpleTheme ;
71
+ @ BindView (R .id .default_theme ) RadioButton mUseDefaultTheme ;
72
+ @ BindView (R .id .green_theme ) RadioButton mUseGreenTheme ;
73
+ @ BindView (R .id .purple_theme ) RadioButton mUsePurpleTheme ;
74
+ @ BindView (R .id .dark_theme ) RadioButton mUseDarkTheme ;
69
75
70
- @ BindView (R .id .dark_theme )
71
- RadioButton mUseDarkTheme ;
76
+ @ BindView (R .id .firebase_logo ) RadioButton mFirebaseLogo ;
77
+ @ BindView (R .id .google_logo ) RadioButton mGoogleLogo ;
78
+ @ BindView (R .id .no_logo ) RadioButton mNoLogo ;
72
79
73
- @ BindView (R .id .email_provider )
74
- CheckBox mUseEmailProvider ;
80
+ @ BindView (R .id .google_tos ) RadioButton mUseGoogleTos ;
81
+ @ BindView ( R . id . firebase_tos ) RadioButton mUseFirebaseTos ;
75
82
76
- @ BindView (R .id .phone_provider )
77
- CheckBox mUsePhoneProvider ;
83
+ @ BindView (R .id .google_privacy ) RadioButton mUseGooglePrivacyPolicy ;
84
+ @ BindView ( R . id . firebase_privacy ) RadioButton mUseFirebasePrivacyPolicy ;
78
85
79
- @ BindView (R .id .google_provider )
80
- CheckBox mUseGoogleProvider ;
86
+ @ BindView (R .id .google_scopes_header ) TextView mGoogleScopesLabel ;
87
+ @ BindView (R .id .google_scope_drive_file ) CheckBox mGoogleScopeDriveFile ;
88
+ @ BindView (R .id .google_scope_youtube_data ) CheckBox mGoogleScopeYoutubeData ;
81
89
82
- @ BindView (R .id .facebook_provider )
83
- CheckBox mUseFacebookProvider ;
90
+ @ BindView (R .id .facebook_permissions_header ) TextView mFacebookScopesLabel ;
91
+ @ BindView (R .id .facebook_permission_friends ) CheckBox mFacebookScopeFriends ;
92
+ @ BindView (R .id .facebook_permission_photos ) CheckBox mFacebookScopePhotos ;
84
93
85
- @ BindView (R .id .twitter_provider )
86
- CheckBox mUseTwitterProvider ;
87
-
88
- @ BindView (R .id .google_tos )
89
- RadioButton mUseGoogleTos ;
90
-
91
- @ BindView (R .id .firebase_tos )
92
- RadioButton mUseFirebaseTos ;
93
-
94
- @ BindView (R .id .google_privacy )
95
- RadioButton mUseGooglePrivacyPolicy ;
96
-
97
- @ BindView (R .id .firebase_privacy )
98
- RadioButton mUseFirebasePrivacyPolicy ;
99
-
100
- @ BindView (R .id .sign_in )
101
- Button mSignIn ;
102
-
103
- @ BindView (R .id .root )
104
- View mRootView ;
105
-
106
- @ BindView (R .id .firebase_logo )
107
- RadioButton mFirebaseLogo ;
108
-
109
- @ BindView (R .id .google_logo )
110
- RadioButton mGoogleLogo ;
111
-
112
- @ BindView (R .id .no_logo )
113
- RadioButton mNoLogo ;
114
-
115
- @ BindView (R .id .credential_selector_enabled )
116
- CheckBox mEnableCredentialSelector ;
117
-
118
- @ BindView (R .id .hint_selector_enabled )
119
- CheckBox mEnableHintSelector ;
120
-
121
- @ BindView (R .id .allow_new_email_accounts )
122
- CheckBox mAllowNewEmailAccounts ;
123
-
124
- @ BindView (R .id .require_name )
125
- CheckBox mRequireName ;
126
-
127
- @ BindView (R .id .facebook_scopes_label )
128
- TextView mFacebookScopesLabel ;
129
-
130
- @ BindView (R .id .facebook_scope_friends )
131
- CheckBox mFacebookScopeFriends ;
132
-
133
- @ BindView (R .id .facebook_scope_photos )
134
- CheckBox mFacebookScopePhotos ;
135
-
136
- @ BindView (R .id .google_scopes_label )
137
- TextView mGoogleScopesLabel ;
138
-
139
- @ BindView (R .id .google_scope_drive_file )
140
- CheckBox mGoogleScopeDriveFile ;
141
-
142
- @ BindView (R .id .google_scope_youtube_data )
143
- CheckBox mGoogleScopeYoutubeData ;
94
+ @ BindView (R .id .credential_selector_enabled ) CheckBox mEnableCredentialSelector ;
95
+ @ BindView (R .id .hint_selector_enabled ) CheckBox mEnableHintSelector ;
96
+ @ BindView (R .id .allow_new_email_accounts ) CheckBox mAllowNewEmailAccounts ;
97
+ @ BindView (R .id .require_name ) CheckBox mRequireName ;
144
98
145
99
public static Intent createIntent (Context context ) {
146
100
return new Intent (context , AuthUiActivity .class );
147
101
}
148
102
149
103
@ Override
150
- public void onCreate (Bundle savedInstanceState ) {
104
+ public void onCreate (@ Nullable Bundle savedInstanceState ) {
151
105
super .onCreate (savedInstanceState );
152
106
setContentView (R .layout .auth_ui_layout );
153
107
ButterKnife .bind (this );
@@ -217,10 +171,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
217
171
super .onActivityResult (requestCode , resultCode , data );
218
172
if (requestCode == RC_SIGN_IN ) {
219
173
handleSignInResponse (resultCode , data );
220
- return ;
221
174
}
222
-
223
- showSnackbar (R .string .unknown_response );
224
175
}
225
176
226
177
@ Override
@@ -259,29 +210,7 @@ private void handleSignInResponse(int resultCode, Intent data) {
259
210
}
260
211
261
212
private void startSignedInActivity (IdpResponse response ) {
262
- startActivity (
263
- SignedInActivity .createIntent (
264
- this ,
265
- response ,
266
- new SignedInActivity .SignedInConfig (
267
- getSelectedLogo (),
268
- getSelectedTheme (),
269
- getSelectedProviders (),
270
- getSelectedTosUrl (),
271
- mEnableCredentialSelector .isChecked (),
272
- mEnableHintSelector .isChecked ())));
273
- }
274
-
275
- private void setGoogleScopesEnabled (boolean enabled ) {
276
- mGoogleScopesLabel .setEnabled (enabled );
277
- mGoogleScopeDriveFile .setEnabled (enabled );
278
- mGoogleScopeYoutubeData .setEnabled (enabled );
279
- }
280
-
281
- private void setFacebookScopesEnabled (boolean enabled ) {
282
- mFacebookScopesLabel .setEnabled (enabled );
283
- mFacebookScopeFriends .setEnabled (enabled );
284
- mFacebookScopePhotos .setEnabled (enabled );
213
+ startActivity (SignedInActivity .createIntent (this , response ));
285
214
}
286
215
287
216
@ OnClick ({R .id .default_theme , R .id .purple_theme , R .id .green_theme , R .id .dark_theme })
@@ -380,19 +309,16 @@ private boolean isTwitterMisconfigured() {
380
309
return twitterConfigs .contains (AuthUI .UNCONFIGURED_CONFIG_VALUE );
381
310
}
382
311
383
- private void showSnackbar (@ StringRes int errorMessageRes ) {
384
- Snackbar .make (mRootView , errorMessageRes , Snackbar .LENGTH_LONG ).show ();
312
+ private void setGoogleScopesEnabled (boolean enabled ) {
313
+ mGoogleScopesLabel .setEnabled (enabled );
314
+ mGoogleScopeDriveFile .setEnabled (enabled );
315
+ mGoogleScopeYoutubeData .setEnabled (enabled );
385
316
}
386
317
387
- private List <String > getFacebookPermissions () {
388
- List <String > result = new ArrayList <>();
389
- if (mFacebookScopeFriends .isChecked ()) {
390
- result .add ("user_friends" );
391
- }
392
- if (mFacebookScopePhotos .isChecked ()) {
393
- result .add ("user_photos" );
394
- }
395
- return result ;
318
+ private void setFacebookScopesEnabled (boolean enabled ) {
319
+ mFacebookScopesLabel .setEnabled (enabled );
320
+ mFacebookScopeFriends .setEnabled (enabled );
321
+ mFacebookScopePhotos .setEnabled (enabled );
396
322
}
397
323
398
324
private List <String > getGoogleScopes () {
@@ -405,4 +331,19 @@ private List<String> getGoogleScopes() {
405
331
}
406
332
return result ;
407
333
}
334
+
335
+ private List <String > getFacebookPermissions () {
336
+ List <String > result = new ArrayList <>();
337
+ if (mFacebookScopeFriends .isChecked ()) {
338
+ result .add ("user_friends" );
339
+ }
340
+ if (mFacebookScopePhotos .isChecked ()) {
341
+ result .add ("user_photos" );
342
+ }
343
+ return result ;
344
+ }
345
+
346
+ private void showSnackbar (@ StringRes int errorMessageRes ) {
347
+ Snackbar .make (mRootView , errorMessageRes , Snackbar .LENGTH_LONG ).show ();
348
+ }
408
349
}
0 commit comments