Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Fix login and logout
Browse files Browse the repository at this point in the history
  • Loading branch information
Klagarge committed Feb 9, 2022
1 parent 5f7a76e commit 26c5e22
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ android {

minSdkVersion 21
targetSdkVersion 31
versionCode 27
versionName "1.4.2"
versionCode 28
versionName "1.4.3"
signingConfig signingConfigs.release
}

Expand Down
Binary file modified app/release/app-release.aab
Binary file not shown.
41 changes: 21 additions & 20 deletions app/src/main/java/dickclock/team/snake/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,18 @@ private void switchToFragment(Fragment newFrag) {

private void signInSilently() {
Log.d(TAG, "signInSilently()");

mGoogleSignInClient.silentSignIn().addOnCompleteListener(this,
task -> {
if (task.isSuccessful()) {
Log.d(TAG, "signInSilently(): success");
onConnected(task.getResult());
} else {
Log.d(TAG, "signInSilently(): failure"/*, task.getException()*/);
onDisconnected();
}
});
try {
mGoogleSignInClient.silentSignIn().addOnCompleteListener(this,
task -> {
if (task.isSuccessful()) {
Log.d(TAG, "signInSilently(): success");
onConnected(task.getResult());
} else {
Log.d(TAG, "signInSilently(): failure"/*, task.getException()*/);
onDisconnected();
}
});
} catch (Exception ignored) {}
}

private void startSignInIntent() { try { startActivityForResult(mGoogleSignInClient.getSignInIntent(), RC_SIGN_IN); } catch (Exception ignored) {} }
Expand All @@ -189,7 +190,6 @@ protected void onResume() {

// Since the state of the signed in user can change when the activity is not active
// it is recommended to try and sign in silently from when the app resumes.
//TODO for release:
try { signInSilently(); } catch (Exception ignored) {}


Expand All @@ -208,14 +208,15 @@ private void signOut() {
Log.w(TAG, "signOut() called, but was not signed in!");
return;
}
try {
mGoogleSignInClient.signOut().addOnCompleteListener(this,
task -> {
boolean successful = task.isSuccessful();
Log.d(TAG, "signOut(): " + (successful ? "success" : "failed"));

mGoogleSignInClient.signOut().addOnCompleteListener(this,
task -> {
boolean successful = task.isSuccessful();
Log.d(TAG, "signOut(): " + (successful ? "success" : "failed"));

onDisconnected();
});
onDisconnected();
});
} catch (Exception ignored) {}
}

@Override
Expand Down Expand Up @@ -633,7 +634,7 @@ private void onDisconnected() {
public void onSignInButtonClicked() { try { startSignInIntent(); } catch (Exception ignored) {} }

@Override
public void onSignOutButtonClicked() { signOut(); }
public void onSignOutButtonClicked() { try { signOut(); } catch (Exception ignored) {} }

@Override
public void onShowFriendsButtonClicked() { switchToFragment(mFriendsFragment); }
Expand Down

0 comments on commit 26c5e22

Please sign in to comment.