I created this small module with the purpose of managing, in a simple but secure way, the sessions in Android applications, allowing the integration of external authentication systems, adding more flexibility to the module.
Add below codes to your root (project) build.gradle file:
allprojects {
repositories {
maven { url = uri("https://jitpack.io") }
}
}
Then add the dependency to the builde.gralde of your module:
dependencies {
implementation("com.github.crisacm:android-session-manager:<latest-release>")
}
To obtain the instance of SessionManager
, use the getInstance
method of SessionManagerProvider
, where we must pass by parameter the implementation of AuthenticationManager together with the context of the application:
val sessionManager = SessionManagerProvider.getInstance(authenticationManager, context)
To register a new session, use the registerSession
method:
suspend fun registerSession(sessionInfo: SessionInfo)
To clear the current session, use the clearSession
method:
suspend fun clearSession()
To get the current session information, use the getSessionInfo
method:
fun getSessionInfo(): Flow<SessionInfo?>
To check if the session is active, use the isSessionActive
method:
fun isSessionActive(): Flow<Boolean>
To configure options in the SessionManager
, use the configure
method:
fun configure(options: Map<String, Any>)
To get a specific option, use the getOption
method:
fun getOption(key: String): Any?
To validate the session, use the validateSession
method:
suspend fun validateSession(key: ValidateSessionKeys, value: String): SessionValidationResult
This application demonstrates in a very basic way how the module works by performing a login through the Firebase Authentication tool in order to demonstrate in a flexible way how to use the library in a basic scenario.
This application implements many of the most popular libraries in the Android ecosystem.
- 100% Kotlin
- Coroutines - perform background operations
- Kotlin Flow - data flow across all app layers, including views
- Kotlin Serialization - parse JSON
- Lifecycle - perform an action when lifecycle state changes
- ViewModel - store and manage UI-related data in a lifecycle-aware way
- Jetpack
- Navigation - in-app navigation
- Splash Screen API
- Firebase
- Koin - dependency injection (dependency retrieval)
- Coil - image loading library
- Clean Architecture
- MVI Architecture
- Android Architecture components
- UI
- Jetpack Compose - modern, native UI kit (used for Fragments)
- Material Design 3 - application design system providing UI components
- Theme selection
- Dark Theme - dark theme for the app (Android 10+)
- Dynamic Theming - use generated, wallpaper-based theme (Android 12+)
- Gradle
Please fork this repository and contribute back using pull requests.
Any contributions, large or small, major features, bug fixes, are welcomed and appreciated but will be thoroughly reviewed