18
18
import android .content .Intent ;
19
19
import android .os .Bundle ;
20
20
import android .support .annotation .DrawableRes ;
21
- import android .support .annotation .MainThread ;
22
21
import android .support .annotation .StringRes ;
23
22
import android .support .annotation .StyleRes ;
24
23
import android .support .design .widget .Snackbar ;
25
24
import android .support .v7 .app .AppCompatActivity ;
26
25
import android .support .v7 .app .AppCompatDelegate ;
26
+ import android .util .Log ;
27
27
import android .view .View ;
28
28
import android .widget .Button ;
29
29
import android .widget .CheckBox ;
49
49
import butterknife .OnClick ;
50
50
51
51
public class AuthUiActivity extends AppCompatActivity {
52
+ private static final String TAG = "AuthUiActivity" ;
53
+
52
54
private static final String GOOGLE_TOS_URL = "https://www.google.com/policies/terms/" ;
53
55
private static final String FIREBASE_TOS_URL = "https://firebase.google.com/terms/" ;
54
56
private static final String GOOGLE_PRIVACY_POLICY_URL = "https://www.google.com/policies/privacy/" ;
@@ -231,15 +233,13 @@ protected void onResume() {
231
233
}
232
234
}
233
235
234
- @ MainThread
235
236
private void handleSignInResponse (int resultCode , Intent data ) {
236
237
IdpResponse response = IdpResponse .fromResultIntent (data );
237
238
238
239
// Successfully signed in
239
240
if (resultCode == RESULT_OK ) {
240
241
startSignedInActivity (response );
241
242
finish ();
242
- return ;
243
243
} else {
244
244
// Sign in failed
245
245
if (response == null ) {
@@ -248,18 +248,14 @@ private void handleSignInResponse(int resultCode, Intent data) {
248
248
return ;
249
249
}
250
250
251
- if (response .getErrorCode () == ErrorCodes .NO_NETWORK ) {
251
+ if (response .getError (). getErrorCode () == ErrorCodes .NO_NETWORK ) {
252
252
showSnackbar (R .string .no_internet_connection );
253
253
return ;
254
254
}
255
255
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 ());
260
258
}
261
-
262
- showSnackbar (R .string .unknown_sign_in_response );
263
259
}
264
260
265
261
private void startSignedInActivity (IdpResponse response ) {
@@ -276,14 +272,12 @@ private void startSignedInActivity(IdpResponse response) {
276
272
mEnableHintSelector .isChecked ())));
277
273
}
278
274
279
- @ MainThread
280
275
private void setGoogleScopesEnabled (boolean enabled ) {
281
276
mGoogleScopesLabel .setEnabled (enabled );
282
277
mGoogleScopeDriveFile .setEnabled (enabled );
283
278
mGoogleScopeYoutubeData .setEnabled (enabled );
284
279
}
285
280
286
- @ MainThread
287
281
private void setFacebookScopesEnabled (boolean enabled ) {
288
282
mFacebookScopesLabel .setEnabled (enabled );
289
283
mFacebookScopeFriends .setEnabled (enabled );
@@ -298,7 +292,6 @@ public void toggleDarkTheme() {
298
292
getDelegate ().setLocalNightMode (mode );
299
293
}
300
294
301
- @ MainThread
302
295
@ StyleRes
303
296
private int getSelectedTheme () {
304
297
if (mUseGreenTheme .isChecked ()) {
@@ -312,7 +305,6 @@ private int getSelectedTheme() {
312
305
return AuthUI .getDefaultTheme ();
313
306
}
314
307
315
- @ MainThread
316
308
@ DrawableRes
317
309
private int getSelectedLogo () {
318
310
if (mFirebaseLogo .isChecked ()) {
@@ -323,7 +315,6 @@ private int getSelectedLogo() {
323
315
return AuthUI .NO_LOGO ;
324
316
}
325
317
326
- @ MainThread
327
318
private List <IdpConfig > getSelectedProviders () {
328
319
List <IdpConfig > selectedProviders = new ArrayList <>();
329
320
@@ -356,7 +347,6 @@ private List<IdpConfig> getSelectedProviders() {
356
347
return selectedProviders ;
357
348
}
358
349
359
- @ MainThread
360
350
private String getSelectedTosUrl () {
361
351
if (mUseGoogleTos .isChecked ()) {
362
352
return GOOGLE_TOS_URL ;
@@ -365,7 +355,6 @@ private String getSelectedTosUrl() {
365
355
return FIREBASE_TOS_URL ;
366
356
}
367
357
368
- @ MainThread
369
358
private String getSelectedPrivacyPolicyUrl () {
370
359
if (mUseGooglePrivacyPolicy .isChecked ()) {
371
360
return GOOGLE_PRIVACY_POLICY_URL ;
@@ -374,17 +363,14 @@ private String getSelectedPrivacyPolicyUrl() {
374
363
return FIREBASE_PRIVACY_POLICY_URL ;
375
364
}
376
365
377
- @ MainThread
378
366
private boolean isGoogleMisconfigured () {
379
367
return AuthUI .UNCONFIGURED_CONFIG_VALUE .equals (getString (R .string .default_web_client_id ));
380
368
}
381
369
382
- @ MainThread
383
370
private boolean isFacebookMisconfigured () {
384
371
return AuthUI .UNCONFIGURED_CONFIG_VALUE .equals (getString (R .string .facebook_application_id ));
385
372
}
386
373
387
- @ MainThread
388
374
private boolean isTwitterMisconfigured () {
389
375
List <String > twitterConfigs = Arrays .asList (
390
376
getString (R .string .twitter_consumer_key ),
@@ -394,12 +380,10 @@ private boolean isTwitterMisconfigured() {
394
380
return twitterConfigs .contains (AuthUI .UNCONFIGURED_CONFIG_VALUE );
395
381
}
396
382
397
- @ MainThread
398
383
private void showSnackbar (@ StringRes int errorMessageRes ) {
399
384
Snackbar .make (mRootView , errorMessageRes , Snackbar .LENGTH_LONG ).show ();
400
385
}
401
386
402
- @ MainThread
403
387
private List <String > getFacebookPermissions () {
404
388
List <String > result = new ArrayList <>();
405
389
if (mFacebookScopeFriends .isChecked ()) {
@@ -411,7 +395,6 @@ private List<String> getFacebookPermissions() {
411
395
return result ;
412
396
}
413
397
414
- @ MainThread
415
398
private List <String > getGoogleScopes () {
416
399
List <String > result = new ArrayList <>();
417
400
if (mGoogleScopeYoutubeData .isChecked ()) {
0 commit comments