-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
signout and current logged in user info added
- Loading branch information
Showing
11 changed files
with
134 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
libDriveBackup/src/main/java/media/uqab/libdrivebackup/model/NoUserFoundException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package media.uqab.libdrivebackup.model | ||
|
||
class NoUserFoundException: Exception() |
6 changes: 0 additions & 6 deletions
6
libDriveBackup/src/main/java/media/uqab/libdrivebackup/model/Operation.kt
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
libDriveBackup/src/main/java/media/uqab/libdrivebackup/model/UserInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package media.uqab.libdrivebackup.model | ||
|
||
data class UserInfo( | ||
val email: String?, | ||
val name: String? | ||
) |
18 changes: 18 additions & 0 deletions
18
libDriveBackup/src/main/java/media/uqab/libdrivebackup/useCase/GetSignedInEmail.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package media.uqab.libdrivebackup.useCase | ||
|
||
import androidx.activity.ComponentActivity | ||
import com.google.android.gms.auth.api.signin.GoogleSignIn | ||
import media.uqab.libdrivebackup.model.UserInfo | ||
|
||
object GetSignedInEmail { | ||
/** | ||
* Return already signed in email address if present. | ||
* | ||
* @return Signed in email if present, null otherwise | ||
*/ | ||
fun getSignedInEmail(activity: ComponentActivity): UserInfo? { | ||
return GoogleSignIn.getLastSignedInAccount(activity)?.let { | ||
UserInfo(it.email, it.displayName) | ||
} | ||
} | ||
} |
21 changes: 20 additions & 1 deletion
21
libDriveBackup/src/main/java/media/uqab/libdrivebackup/useCase/SignOutUser.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,24 @@ | ||
package media.uqab.libdrivebackup.useCase | ||
|
||
import androidx.activity.ComponentActivity | ||
import com.google.android.gms.auth.api.signin.GoogleSignIn | ||
import com.google.android.gms.auth.api.signin.GoogleSignInClient | ||
import com.google.android.gms.auth.api.signin.GoogleSignInOptions | ||
import com.google.android.gms.common.api.Scope | ||
import com.google.api.services.drive.DriveScopes | ||
|
||
object SignOutUser { | ||
|
||
/** | ||
* Sign out already logged in user. | ||
*/ | ||
fun signOut(activity: ComponentActivity, credentialID: String) { | ||
val gso: GoogleSignInOptions = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) | ||
.requestIdToken(credentialID) | ||
.requestEmail() | ||
.requestScopes(Scope(DriveScopes.DRIVE_APPDATA)) | ||
.build() | ||
|
||
val googleSignInClient: GoogleSignInClient = GoogleSignIn.getClient(activity, gso) | ||
googleSignInClient.signOut() | ||
} | ||
} |