WIP: Move to KMP
This commit is contained in:
parent
414ac50234
commit
0b336610df
5 changed files with 11 additions and 6 deletions
|
@ -20,7 +20,7 @@ const val IP_MAX = 255
|
|||
|
||||
class AddPiHelperViewModel(
|
||||
private val sharedPreferences: SharedPreferences,
|
||||
private val apiService: PiHoleApiService = KtorPiHoleApiService()
|
||||
private val apiService: PiHoleApiService
|
||||
) : ViewModel() {
|
||||
|
||||
@Volatile
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.wbrawner.pihelper
|
|||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import com.wbrawner.piholeclient.piHoleClientModule
|
||||
import org.koin.android.ext.koin.androidContext
|
||||
import org.koin.android.ext.koin.androidLogger
|
||||
import org.koin.core.context.startKoin
|
||||
|
@ -15,7 +14,6 @@ class PiHelperApplication: Application() {
|
|||
androidLogger()
|
||||
androidContext(this@PiHelperApplication)
|
||||
modules(listOf(
|
||||
piHoleClientModule,
|
||||
piHelperModule
|
||||
))
|
||||
}
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
package com.wbrawner.pihelper
|
||||
|
||||
import androidx.security.crypto.EncryptedSharedPreferences
|
||||
import com.wbrawner.piholeclient.NAME_BASE_URL
|
||||
import com.wbrawner.pihelper.shared.KtorPiHoleApiService
|
||||
import com.wbrawner.pihelper.shared.PiHoleApiService
|
||||
import com.wbrawner.pihelper.shared.httpClient
|
||||
import org.koin.androidx.viewmodel.dsl.viewModel
|
||||
import org.koin.core.qualifier.named
|
||||
import org.koin.dsl.module
|
||||
|
||||
const val ENCRYPTED_SHARED_PREFS_FILE_NAME = "pihelper.prefs"
|
||||
const val NAME_BASE_URL = "baseUrl"
|
||||
|
||||
val piHelperModule = module {
|
||||
single {
|
||||
|
@ -30,4 +33,8 @@ val piHelperModule = module {
|
|||
single(named(NAME_BASE_URL)) {
|
||||
get<EncryptedSharedPreferences>().getString(KEY_BASE_URL, "")
|
||||
}
|
||||
|
||||
single<PiHoleApiService> {
|
||||
KtorPiHoleApiService(httpClient())
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@ package com.wbrawner.pihelper
|
|||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.wbrawner.piholeclient.PiHoleApiService
|
||||
import com.wbrawner.pihelper.shared.PiHoleApiService
|
||||
import com.wbrawner.pihelper.shared.Status
|
||||
import com.wbrawner.pihelper.shared.StatusProvider
|
||||
import kotlinx.coroutines.delay
|
||||
|
|
|
@ -41,7 +41,7 @@ kotlin {
|
|||
val androidMain by getting {
|
||||
dependencies {
|
||||
implementation("com.google.android.material:material:1.2.0")
|
||||
implementation("io.ktor:ktor-client-android:$ktor_version")
|
||||
api("io.ktor:ktor-client-android:$ktor_version")
|
||||
}
|
||||
}
|
||||
val androidTest by getting {
|
||||
|
|
Loading…
Reference in a new issue