From 4c78b22614ee2a9f588722073d80daf213ea1c4f Mon Sep 17 00:00:00 2001 From: davidoskky Date: Mon, 22 Aug 2022 19:33:58 +0200 Subject: [PATCH] Use the connectivity-status library from the repository rather than the local copy --- androidApp/build.gradle.kts | 5 +---- .../apps/readerforselfossv2/android/MyApp.kt | 16 ++++++++++------ shared/build.gradle.kts | 4 +--- .../libs/multiplatform-connectivity-status.aar | Bin 5113 -> 0 bytes .../repository/RepositoryImpl.kt | 17 +---------------- 5 files changed, 13 insertions(+), 29 deletions(-) delete mode 100644 shared/libs/multiplatform-connectivity-status.aar diff --git a/androidApp/build.gradle.kts b/androidApp/build.gradle.kts index 527731a..b548d33 100644 --- a/androidApp/build.gradle.kts +++ b/androidApp/build.gradle.kts @@ -207,8 +207,5 @@ dependencies { implementation("android.arch.work:work-runtime-ktx:1.0.1") // Network information - // TODO: When updating this library, check if the todo in RepositoryImpl.startNetwork can be resolved - // TODO: Include this library once this is merged https://github.com/ln-12/multiplatform-connectivity-status/pull/4 - // implementation("com.github.ln-12:multiplatform-connectivity-status:1.1.0") - implementation(files("../shared/libs/multiplatform-connectivity-status.aar")) + implementation("com.github.ln-12:multiplatform-connectivity-status:1.3.0") } \ No newline at end of file diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/MyApp.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/MyApp.kt index dbd036f..be77f62 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/MyApp.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/MyApp.kt @@ -22,7 +22,7 @@ import bou.amine.apps.readerforselfossv2.repository.Repository import com.bumptech.glide.Glide import com.bumptech.glide.request.RequestOptions import com.ftinc.scoop.Scoop -import com.github.`ln-12`.library.ConnectivityStatus +import com.github.ln_12.library.ConnectivityStatus import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader import com.mikepenz.materialdrawer.util.DrawerImageLoader import com.russhwolf.settings.Settings @@ -37,12 +37,14 @@ class MyApp : MultiDexApplication(), DIAware { override val di by DI.lazy { import(networkModule) - bind() with singleton { Repository(instance(), instance(), ConnectivityStatus(applicationContext)) } + bind() with singleton { Repository(instance(), instance(), connectivityStatus) } + bind() with singleton { ConnectivityStatus(applicationContext) } bind() with singleton { AppViewModel(repository = instance()) } } private val repository: Repository by instance() private val viewModel: AppViewModel by instance() + private val connectivityStatus: ConnectivityStatus by instance() private lateinit var config: Config private lateinit var settings : Settings @@ -60,7 +62,7 @@ class MyApp : MultiDexApplication(), DIAware { handleNotificationChannels() - ProcessLifecycleOwner.get().lifecycle.addObserver(AppLifeCycleObserver(repository)) + ProcessLifecycleOwner.get().lifecycle.addObserver(AppLifeCycleObserver(connectivityStatus, repository)) CoroutineScope(Dispatchers.Main).launch { viewModel.toastMessageProvider.collect { toastMessage -> @@ -131,15 +133,17 @@ class MyApp : MultiDexApplication(), DIAware { } } - class AppLifeCycleObserver(val repository: Repository) : DefaultLifecycleObserver { + class AppLifeCycleObserver(val connectivityStatus: ConnectivityStatus, val repository: Repository) : DefaultLifecycleObserver { override fun onResume(owner: LifecycleOwner) { super.onResume(owner) - repository.startNetwork() + repository.connectionMonitored = true + connectivityStatus.start() } override fun onPause(owner: LifecycleOwner) { - repository.stopNetwork() + repository.connectionMonitored = false + connectivityStatus.stop() super.onPause(owner) } } diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts index ad4c8a8..f8242cd 100644 --- a/shared/build.gradle.kts +++ b/shared/build.gradle.kts @@ -38,9 +38,7 @@ kotlin { implementation("io.github.aakira:napier:2.6.1") // Network information - // TODO: Include this library once this is merged https://github.com/ln-12/multiplatform-connectivity-status/pull/4 - //implementation("com.github.ln-12:multiplatform-connectivity-status:1.1.0") - implementation(files("libs/multiplatform-connectivity-status.aar")) + implementation("com.github.ln-12:multiplatform-connectivity-status:1.3.0") } } val commonTest by getting { diff --git a/shared/libs/multiplatform-connectivity-status.aar b/shared/libs/multiplatform-connectivity-status.aar deleted file mode 100644 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Ppl=tJ2io95}y;@(A4HX(Gk$l*5KDrrJb6bfKDL=5EB|?x}&Y) zJ2-cw>K+a??*9$6?(Xxi@iFwD?O%B7?~=dct$zyufRCYff6@O9cKzMp?_lUZ2K;x# o?0;aQzYG7K+<%0scZ})(ouj@MKEXe&@a`t{-3^d;W&prH0RGivlmGw# diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt index 44fc676..287ef1c 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt @@ -5,7 +5,7 @@ import bou.amine.apps.readerforselfossv2.rest.SelfossModel import bou.amine.apps.readerforselfossv2.service.ApiDetailsService import bou.amine.apps.readerforselfossv2.utils.DateUtils import bou.amine.apps.readerforselfossv2.utils.ItemType -import com.github.`ln-12`.library.ConnectivityStatus +import com.github.ln_12.library.ConnectivityStatus import com.russhwolf.settings.Settings import io.github.aakira.napier.Napier import kotlinx.coroutines.CoroutineScope @@ -342,20 +342,5 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails fun isNetworkAvailable() = isConnectionAvailable.value && !offlineOverride - // TODO: Start and stop the monitoring within Android and iOS code - // This should be performed in the architecture specific code - // However it is not possible on android due to the dash contained in the name of the library - // com.github.ln-12:multiplatform-connectivity-status:1.1.0 - // https://github.com/ln-12/multiplatform-connectivity-status/issues/2 - fun startNetwork() { - connectionMonitored = true - connectivityStatus.start() - } - - fun stopNetwork() { - connectionMonitored = false - connectivityStatus.stop() - } - // TODO: Handle offline actions } \ No newline at end of file