1818import android .content .Intent ;
1919import android .os .Bundle ;
2020import android .support .annotation .DrawableRes ;
21- import android .support .annotation .MainThread ;
2221import android .support .annotation .StringRes ;
2322import android .support .annotation .StyleRes ;
2423import android .support .design .widget .Snackbar ;
2524import android .support .v7 .app .AppCompatActivity ;
2625import android .support .v7 .app .AppCompatDelegate ;
26+ import android .util .Log ;
2727import android .view .View ;
2828import android .widget .Button ;
2929import android .widget .CheckBox ;
4949import butterknife .OnClick ;
5050
5151public class AuthUiActivity extends AppCompatActivity {
52+ private static final String TAG = "AuthUiActivity" ;
53+
5254 private static final String GOOGLE_TOS_URL = "https://www.google.com/policies/terms/" ;
5355 private static final String FIREBASE_TOS_URL = "https://firebase.google.com/terms/" ;
5456 private static final String GOOGLE_PRIVACY_POLICY_URL = "https://www.google.com/policies/privacy/" ;
@@ -231,15 +233,13 @@ protected void onResume() {
231233 }
232234 }
233235
234- @ MainThread
235236 private void handleSignInResponse (int resultCode , Intent data ) {
236237 IdpResponse response = IdpResponse .fromResultIntent (data );
237238
238239 // Successfully signed in
239240 if (resultCode == RESULT_OK ) {
240241 startSignedInActivity (response );
241242 finish ();
242- return ;
243243 } else {
244244 // Sign in failed
245245 if (response == null ) {
@@ -248,18 +248,14 @@ private void handleSignInResponse(int resultCode, Intent data) {
248248 return ;
249249 }
250250
251- if (response .getErrorCode () == ErrorCodes .NO_NETWORK ) {
251+ if (response .getError (). getErrorCode () == ErrorCodes .NO_NETWORK ) {
252252 showSnackbar (R .string .no_internet_connection );
253253 return ;
254254 }
255255
256- if (response .getErrorCode () == ErrorCodes .UNKNOWN_ERROR ) {
257- showSnackbar (R .string .unknown_error );
258- return ;
259- }
256+ showSnackbar (R .string .unknown_error );
257+ Log .e (TAG , "Sign-in error: " , response .getError ());
260258 }
261-
262- showSnackbar (R .string .unknown_sign_in_response );
263259 }
264260
265261 private void startSignedInActivity (IdpResponse response ) {
@@ -276,14 +272,12 @@ private void startSignedInActivity(IdpResponse response) {
276272 mEnableHintSelector .isChecked ())));
277273 }
278274
279- @ MainThread
280275 private void setGoogleScopesEnabled (boolean enabled ) {
281276 mGoogleScopesLabel .setEnabled (enabled );
282277 mGoogleScopeDriveFile .setEnabled (enabled );
283278 mGoogleScopeYoutubeData .setEnabled (enabled );
284279 }
285280
286- @ MainThread
287281 private void setFacebookScopesEnabled (boolean enabled ) {
288282 mFacebookScopesLabel .setEnabled (enabled );
289283 mFacebookScopeFriends .setEnabled (enabled );
@@ -298,7 +292,6 @@ public void toggleDarkTheme() {
298292 getDelegate ().setLocalNightMode (mode );
299293 }
300294
301- @ MainThread
302295 @ StyleRes
303296 private int getSelectedTheme () {
304297 if (mUseGreenTheme .isChecked ()) {
@@ -312,7 +305,6 @@ private int getSelectedTheme() {
312305 return AuthUI .getDefaultTheme ();
313306 }
314307
315- @ MainThread
316308 @ DrawableRes
317309 private int getSelectedLogo () {
318310 if (mFirebaseLogo .isChecked ()) {
@@ -323,7 +315,6 @@ private int getSelectedLogo() {
323315 return AuthUI .NO_LOGO ;
324316 }
325317
326- @ MainThread
327318 private List <IdpConfig > getSelectedProviders () {
328319 List <IdpConfig > selectedProviders = new ArrayList <>();
329320
@@ -356,7 +347,6 @@ private List<IdpConfig> getSelectedProviders() {
356347 return selectedProviders ;
357348 }
358349
359- @ MainThread
360350 private String getSelectedTosUrl () {
361351 if (mUseGoogleTos .isChecked ()) {
362352 return GOOGLE_TOS_URL ;
@@ -365,7 +355,6 @@ private String getSelectedTosUrl() {
365355 return FIREBASE_TOS_URL ;
366356 }
367357
368- @ MainThread
369358 private String getSelectedPrivacyPolicyUrl () {
370359 if (mUseGooglePrivacyPolicy .isChecked ()) {
371360 return GOOGLE_PRIVACY_POLICY_URL ;
@@ -374,17 +363,14 @@ private String getSelectedPrivacyPolicyUrl() {
374363 return FIREBASE_PRIVACY_POLICY_URL ;
375364 }
376365
377- @ MainThread
378366 private boolean isGoogleMisconfigured () {
379367 return AuthUI .UNCONFIGURED_CONFIG_VALUE .equals (getString (R .string .default_web_client_id ));
380368 }
381369
382- @ MainThread
383370 private boolean isFacebookMisconfigured () {
384371 return AuthUI .UNCONFIGURED_CONFIG_VALUE .equals (getString (R .string .facebook_application_id ));
385372 }
386373
387- @ MainThread
388374 private boolean isTwitterMisconfigured () {
389375 List <String > twitterConfigs = Arrays .asList (
390376 getString (R .string .twitter_consumer_key ),
@@ -394,12 +380,10 @@ private boolean isTwitterMisconfigured() {
394380 return twitterConfigs .contains (AuthUI .UNCONFIGURED_CONFIG_VALUE );
395381 }
396382
397- @ MainThread
398383 private void showSnackbar (@ StringRes int errorMessageRes ) {
399384 Snackbar .make (mRootView , errorMessageRes , Snackbar .LENGTH_LONG ).show ();
400385 }
401386
402- @ MainThread
403387 private List <String > getFacebookPermissions () {
404388 List <String > result = new ArrayList <>();
405389 if (mFacebookScopeFriends .isChecked ()) {
@@ -411,7 +395,6 @@ private List<String> getFacebookPermissions() {
411395 return result ;
412396 }
413397
414- @ MainThread
415398 private List <String > getGoogleScopes () {
416399 List <String > result = new ArrayList <>();
417400 if (mGoogleScopeYoutubeData .isChecked ()) {
0 commit comments