GithubHelp home page GithubHelp logo

bhavnaharitsa / authmanager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from infamous-riddles/authmanager

0.0 1.0 0.0 96 KB

Google Sign-In and SmartLock Manager

License: MIT License

Kotlin 97.39% Java 2.61%

authmanager's Introduction

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.

authmanager's People

Contributors

pavlospt avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.