Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/google_sign_in/google_sign_in_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 7.2.9

* Simplifies internal code for Kotlin/Java interoperability.

## 7.2.8

* Bumps kotlin_version to 2.3.0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void getCredential(
try {
String serverClientId = params.getServerClientId();
if (serverClientId == null || serverClientId.isEmpty()) {
ResultUtilsKt.completeWithGetCredentialFailure(
ResultUtilsKt.completeWithValue(
callback,
new GetCredentialFailure(
GetCredentialFailureType.MISSING_SERVER_CLIENT_ID,
Expand All @@ -228,7 +228,7 @@ public void getCredential(
// the API docs.
Activity activity = getActivity();
if (activity == null) {
ResultUtilsKt.completeWithGetCredentialFailure(
ResultUtilsKt.completeWithValue(
callback,
new GetCredentialFailure(
GetCredentialFailureType.NO_ACTIVITY, "No activity available", null));
Expand Down Expand Up @@ -280,7 +280,7 @@ public void onResult(GetCredentialResponse response) {
GoogleIdTokenCredential googleIdTokenCredential =
credentialConverter.createFrom(credential);
Uri profilePictureUri = googleIdTokenCredential.getProfilePictureUri();
ResultUtilsKt.completeWithGetGetCredentialResult(
ResultUtilsKt.completeWithValue(
callback,
new GetCredentialSuccess(
new PlatformGoogleIdTokenCredential(
Expand All @@ -291,7 +291,7 @@ public void onResult(GetCredentialResponse response) {
googleIdTokenCredential.getIdToken(),
profilePictureUri == null ? null : profilePictureUri.toString())));
} else {
ResultUtilsKt.completeWithGetCredentialFailure(
ResultUtilsKt.completeWithValue(
callback,
new GetCredentialFailure(
GetCredentialFailureType.UNEXPECTED_CREDENTIAL_TYPE,
Expand All @@ -318,12 +318,12 @@ public void onError(@NonNull GetCredentialException e) {
}
// Errors are reported through the return value as structured data, rather than
// a Result error's PlatformException.
ResultUtilsKt.completeWithGetCredentialFailure(
ResultUtilsKt.completeWithValue(
callback, new GetCredentialFailure(type, e.getMessage(), null));
}
});
} catch (RuntimeException e) {
ResultUtilsKt.completeWithGetCredentialFailure(
ResultUtilsKt.completeWithValue(
callback,
new GetCredentialFailure(
GetCredentialFailureType.UNKNOWN,
Expand Down Expand Up @@ -400,7 +400,7 @@ public void authorize(
if (promptIfUnauthorized) {
Activity activity = getActivity();
if (activity == null) {
ResultUtilsKt.completeWithAuthorizeFailure(
ResultUtilsKt.completeWithValue(
callback,
new AuthorizeFailure(
AuthorizeFailureType.NO_ACTIVITY, "No activity available", null));
Expand All @@ -422,20 +422,20 @@ public void authorize(
/* options */ null);
} catch (IntentSender.SendIntentException e) {
pendingAuthorizationCallback = null;
ResultUtilsKt.completeWithAuthorizeFailure(
ResultUtilsKt.completeWithValue(
callback,
new AuthorizeFailure(
AuthorizeFailureType.PENDING_INTENT_EXCEPTION,
e.getMessage(),
null));
}
} else {
ResultUtilsKt.completeWithAuthorizeFailure(
ResultUtilsKt.completeWithValue(
callback,
new AuthorizeFailure(AuthorizeFailureType.UNAUTHORIZED, null, null));
}
} else {
ResultUtilsKt.completeWithAuthorizationResult(
ResultUtilsKt.completeWithValue(
callback,
new PlatformAuthorizationResult(
authorizationResult.getAccessToken(),
Expand All @@ -445,12 +445,12 @@ public void authorize(
})
.addOnFailureListener(
e ->
ResultUtilsKt.completeWithAuthorizeFailure(
ResultUtilsKt.completeWithValue(
callback,
new AuthorizeFailure(
AuthorizeFailureType.AUTHORIZE_FAILURE, e.getMessage(), null)));
} catch (RuntimeException e) {
ResultUtilsKt.completeWithAuthorizeFailure(
ResultUtilsKt.completeWithValue(
callback,
new AuthorizeFailure(
AuthorizeFailureType.API_EXCEPTION,
Expand Down Expand Up @@ -488,15 +488,15 @@ public boolean onActivityResult(int requestCode, int resultCode, @Nullable Inten
try {
AuthorizationResult authorizationResult =
authorizationClientFactory.create(context).getAuthorizationResultFromIntent(data);
ResultUtilsKt.completeWithAuthorizationResult(
ResultUtilsKt.completeWithValue(
pendingAuthorizationCallback,
new PlatformAuthorizationResult(
authorizationResult.getAccessToken(),
authorizationResult.getServerAuthCode(),
authorizationResult.getGrantedScopes()));
return true;
} catch (ApiException e) {
ResultUtilsKt.completeWithAuthorizeFailure(
ResultUtilsKt.completeWithValue(
pendingAuthorizationCallback,
new AuthorizeFailure(AuthorizeFailureType.API_EXCEPTION, e.getMessage(), null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,6 @@

package io.flutter.plugins.googlesignin

fun completeWithGetGetCredentialResult(
callback: (Result<GetCredentialResult>) -> Unit,
result: GetCredentialResult
) {
callback(Result.success(result))
}

fun completeWithGetCredentialFailure(
callback: (Result<GetCredentialFailure>) -> Unit,
failure: GetCredentialFailure
) {
callback(Result.success(failure))
}

fun completeWithUnitSuccess(callback: (Result<Unit>) -> Unit) {
callback(Result.success(Unit))
}
Expand All @@ -26,16 +12,6 @@ fun completeWithUnitError(callback: (Result<Unit>) -> Unit, failure: FlutterErro
callback(Result.failure(failure))
}

fun completeWithAuthorizationResult(
callback: (Result<AuthorizeResult>) -> Unit,
result: PlatformAuthorizationResult
) {
callback(Result.success(result))
}

fun completeWithAuthorizeFailure(
callback: (Result<AuthorizeResult>) -> Unit,
failure: AuthorizeFailure
) {
callback(Result.success(failure))
fun <T> completeWithValue(callback: (Result<T>) -> Unit, value: T) {
callback(Result.success(value))
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: google_sign_in_android
description: Android implementation of the google_sign_in plugin.
repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22
version: 7.2.8
version: 7.2.9

environment:
sdk: ^3.9.0
Expand Down
Loading