1515import com .flowcrypt .email .R ;
1616import com .flowcrypt .email .ui .activity .AddNewAccountManuallyActivity ;
1717import com .flowcrypt .email .util .GeneralUtil ;
18- import com .flowcrypt .email .util .UIUtil ;
1918import com .flowcrypt .email .util .google .GoogleApiClientHelper ;
2019import com .google .android .gms .auth .api .Auth ;
2120import com .google .android .gms .common .ConnectionResult ;
@@ -52,12 +51,15 @@ public void onClick(View v) {
5251 switch (v .getId ()) {
5352 case R .id .buttonSignInWithGmail :
5453 if (GeneralUtil .isInternetConnectionAvailable (this )) {
55- googleApiClient .clearDefaultAccountAndReconnect ();
56- Intent signInIntent = Auth .GoogleSignInApi .getSignInIntent (googleApiClient );
57- startActivityForResult (signInIntent , REQUEST_CODE_SIGN_IN );
54+ if (googleApiClient != null && googleApiClient .isConnected ()) {
55+ googleApiClient .clearDefaultAccountAndReconnect ();
56+ Intent signInIntent = Auth .GoogleSignInApi .getSignInIntent (googleApiClient );
57+ startActivityForResult (signInIntent , REQUEST_CODE_SIGN_IN );
58+ } else {
59+ showInfoSnackbar (getRootView (), getString (R .string .google_api_is_not_available ));
60+ }
5861 } else {
59- UIUtil .showInfoSnackbar (getRootView (),
60- getString (R .string .internet_connection_is_not_available ));
62+ showInfoSnackbar (getRootView (), getString (R .string .internet_connection_is_not_available ));
6163 }
6264 break ;
6365
@@ -66,7 +68,7 @@ public void onClick(View v) {
6668 startActivityForResult (new Intent (this , AddNewAccountManuallyActivity .class ),
6769 REQUEST_CODE_ADD_OTHER_ACCOUNT );
6870 } else {
69- UIUtil . showInfoSnackbar (getRootView (), getString (R .string .internet_connection_is_not_available ));
71+ showInfoSnackbar (getRootView (), getString (R .string .internet_connection_is_not_available ));
7072 }
7173 break ;
7274 }
@@ -84,7 +86,7 @@ public void onConnectionSuspended(int i) {
8486
8587 @ Override
8688 public void onConnectionFailed (@ NonNull ConnectionResult connectionResult ) {
87- UIUtil . showInfoSnackbar (getRootView (), connectionResult .getErrorMessage ());
89+ showInfoSnackbar (getRootView (), connectionResult .getErrorMessage ());
8890 }
8991
9092 protected void initGoogleApiClient () {
0 commit comments