Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEVISACCESSAPP-6028: Initialize client with context #19

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ import javax.inject.Inject
* Default implementation of [Settings] interface.
*/
class SettingsImpl @Inject constructor(
/**
* The Android [Context].
*/
@ApplicationContext
context: Context
private val context: Context
) : Settings {
override val allowClass2Sensors = context.resources.getBoolean(R.bool.allow_class2_sensors)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,4 @@ class ApplicationModule {
.addConverterFactory(GsonConverterFactory.create())
.build()
//endregion
}
}
13 changes: 7 additions & 6 deletions app/src/main/java/ch/nevis/exampleapp/ui/home/HomeViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

package ch.nevis.exampleapp.ui.home

import android.app.Application
import android.content.Context
import androidx.lifecycle.viewModelScope
import ch.nevis.exampleapp.NavigationGraphDirections
import ch.nevis.exampleapp.common.configuration.ConfigurationProvider
Expand Down Expand Up @@ -37,6 +37,7 @@ import ch.nevis.mobile.sdk.api.operation.userverification.DevicePasscodeUserVeri
import ch.nevis.mobile.sdk.api.operation.userverification.FingerprintUserVerifier
import ch.nevis.mobile.sdk.api.operation.userverification.PinUserVerifier
import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.suspendCancellableCoroutine
Expand All @@ -49,11 +50,11 @@ import kotlin.coroutines.resume
*/
@HiltViewModel
class HomeViewModel @Inject constructor(

/**
* The current Android [Application] instance.
* An Android [Context] object used for initializing [ch.nevis.mobile.sdk.api.MobileAuthenticationClient].
*/
private val application: Application,
@ApplicationContext
private val context: Context,

/**
* An instance of a [ConfigurationProvider] implementation.
Expand Down Expand Up @@ -147,7 +148,7 @@ class HomeViewModel @Inject constructor(
*/
fun initClient() {
MobileAuthenticationClientInitializer.initializer()
.application(application)
.context(context)
.configuration(configurationProvider.configuration)
.onSuccess {
clientProvider.save(it)
Expand Down Expand Up @@ -344,4 +345,4 @@ class HomeViewModel @Inject constructor(
}
}
//endregion
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ android.nonTransitiveRClass=true

VERSION_NAME=3.6.1
VERSION_CODE=1
NEVIS_MOBILE_AUTHENTICATION_SDK_VERSION=3.6.+
NEVIS_MOBILE_AUTHENTICATION_SDK_VERSION=3.7.+
Loading