1818import android .content .Intent ;
1919import android .os .Bundle ;
2020import android .support .annotation .DrawableRes ;
21+ import android .support .annotation .Nullable ;
2122import android .support .annotation .StringRes ;
2223import android .support .annotation .StyleRes ;
2324import android .support .design .widget .Snackbar ;
@@ -58,96 +59,49 @@ public class AuthUiActivity extends AppCompatActivity {
5859
5960 private static final int RC_SIGN_IN = 100 ;
6061
61- @ BindView (R .id .default_theme )
62- RadioButton mUseDefaultTheme ;
62+ @ BindView (R .id .root ) View mRootView ;
63+ @ BindView ( R . id . sign_in ) Button mSignIn ;
6364
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 ;
6670
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 ;
6975
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 ;
7279
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 ;
7582
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 ;
7885
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 ;
8189
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 ;
8493
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 ;
14498
14599 public static Intent createIntent (Context context ) {
146100 return new Intent (context , AuthUiActivity .class );
147101 }
148102
149103 @ Override
150- public void onCreate (Bundle savedInstanceState ) {
104+ public void onCreate (@ Nullable Bundle savedInstanceState ) {
151105 super .onCreate (savedInstanceState );
152106 setContentView (R .layout .auth_ui_layout );
153107 ButterKnife .bind (this );
@@ -217,10 +171,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
217171 super .onActivityResult (requestCode , resultCode , data );
218172 if (requestCode == RC_SIGN_IN ) {
219173 handleSignInResponse (resultCode , data );
220- return ;
221174 }
222-
223- showSnackbar (R .string .unknown_response );
224175 }
225176
226177 @ Override
@@ -259,29 +210,7 @@ private void handleSignInResponse(int resultCode, Intent data) {
259210 }
260211
261212 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 ));
285214 }
286215
287216 @ OnClick ({R .id .default_theme , R .id .purple_theme , R .id .green_theme , R .id .dark_theme })
@@ -380,19 +309,16 @@ private boolean isTwitterMisconfigured() {
380309 return twitterConfigs .contains (AuthUI .UNCONFIGURED_CONFIG_VALUE );
381310 }
382311
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 );
385316 }
386317
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 );
396322 }
397323
398324 private List <String > getGoogleScopes () {
@@ -405,4 +331,19 @@ private List<String> getGoogleScopes() {
405331 }
406332 return result ;
407333 }
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+ }
408349}
0 commit comments