Google Sign-In and SmartLock Manager
Kotlin Java
Latest commit f0b3f05 Dec 16, 2016 @pavlospt pavlospt committed on GitHub Update README.md
Permalink
Failed to load latest commit information.
app Initial Commit :octocat: Dec 14, 2016
authmanager Initial Commit :octocat: Dec 14, 2016
gradle/wrapper
.gitignore Initial Commit :octocat: Dec 14, 2016
LICENSE
README.md Update README.md Dec 16, 2016
build.gradle
gradle.properties Initial Commit :octocat: Dec 14, 2016
gradlew Initial Commit :octocat: Dec 14, 2016
gradlew.bat Initial Commit :octocat: Dec 14, 2016
settings.gradle

README.md

Android Arsenal

Auth Manager

AuthManager is a library which eliminates the boilerplate of Google SignIn and SmartLock integration.

Usage

compile 'com.github.charbgr:authmanager:1.0'


AuthManager includes all of the managers below.

AuthManager
    .Builder(this)
    .withGoogleApiClient(googleApiClient)
    .withGoogle(this)
    .withHints(this, hintRequest)
    .withSmartLock(this, smartlockRequest)
    .build()

override fun onDestroy() {
    super.onDestroy()
    authManager.destroy()
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    authManager?.handle(requestCode, resultCode, data)
}

Standalone Managers

Google Manager

Functionality included: Google Sign-In, Google Sign-Out, Google Revoke Access

GoogleAuthManager
    .Builder(this)
    .withGoogleApiClient(googleApiClient)
    .withGoogleView(this)
    .build()

override fun onDestroy() {
    super.onDestroy()
    googleAuthManager?.clear()
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    when (requestCode) {
        RC_SIGN_IN -> googleAuthManager?.handle(resultCode, data)
    }
}

API Overview

fun signInWithGoogle()
fun signOutOfGoogle()
fun revokeGoogleAccess()
fun handle(resultCode: Int, data: Intent?)
fun clear()

Smartlock Manager

Functionality included: SmartLock Credentials Request, SmartLock Credentials Save, SmartLock Credentials Delete

SmartLockManager
    .Builder(this)
    .withGoogleApiClient(googleApiClient)
    .withSmartLockView(this)
    .build()


override fun onDestroy() {
    super.onDestroy()
    smartLockManager?.clear()
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    when (requestCode) {
        RC_CREDENTIAL_SAVE -> smartLockManager?.handleCredentialSave(resultCode)
        RC_CREDENTIALS_REQUEST -> smartLockManager?.handleCredentialRequest(resultCode, data)
    }
} 

API Overview

fun requestCredentials()
fun saveCredential(credential: Credential)
fun deleteCredential(credential: Credential?)
fun handleCredentialSave(resultCode: Int)
fun handleCredentialRequest(resultCode: Int, data: Intent?)
fun clear()

Hints Manager

Functionality included: E-mail Addresses Hints

HintsManager
    .Builder(this)
    .withGoogleApiClient(googleApiClient)
    .withHintsView(this)
    .build()


override fun onDestroy() {
    super.onDestroy()
    hintsManager?.clear()
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    when (requestCode) {
        RC_HINT_REQUEST -> hintsManager?.handle(resultCode, data)
    }
}

API Overview

fun requestEmailHints()
fun handle(resultCode: Int, data: Intent?)
fun clear()

You need to call in Activity.onDestroy() to clear view references otherwise you risk having a memory leak.