mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Modularize messaging code (#3435)
This commit is contained in:
parent
cd1a54f506
commit
886e9cfede
37 changed files with 297 additions and 143 deletions
|
|
@ -17,39 +17,40 @@
|
|||
|
||||
package com.geeksville.mesh
|
||||
|
||||
import android.app.Application
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.ProcessLifecycleOwner
|
||||
import com.geeksville.mesh.service.MeshServiceNotifications
|
||||
import com.geeksville.mesh.service.MeshServiceNotificationsImpl
|
||||
import dagger.Binds
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import org.meshtastic.core.common.BuildConfigProvider
|
||||
import org.meshtastic.core.service.MeshServiceNotifications
|
||||
import javax.inject.Singleton
|
||||
|
||||
@InstallIn(SingletonComponent::class)
|
||||
@Module
|
||||
object ApplicationModule {
|
||||
interface ApplicationModule {
|
||||
|
||||
@Provides fun provideProcessLifecycleOwner(): LifecycleOwner = ProcessLifecycleOwner.get()
|
||||
@Binds fun bindMeshServiceNotifications(impl: MeshServiceNotificationsImpl): MeshServiceNotifications
|
||||
|
||||
@Provides
|
||||
fun provideProcessLifecycle(processLifecycleOwner: LifecycleOwner): Lifecycle = processLifecycleOwner.lifecycle
|
||||
companion object {
|
||||
@Provides fun provideProcessLifecycleOwner(): LifecycleOwner = ProcessLifecycleOwner.get()
|
||||
|
||||
@Provides
|
||||
fun providesMeshServiceNotifications(application: Application): MeshServiceNotifications =
|
||||
MeshServiceNotifications(application)
|
||||
@Provides
|
||||
fun provideProcessLifecycle(processLifecycleOwner: LifecycleOwner): Lifecycle = processLifecycleOwner.lifecycle
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
fun provideBuildConfigProvider(): BuildConfigProvider = object : BuildConfigProvider {
|
||||
override val isDebug: Boolean = BuildConfig.DEBUG
|
||||
override val applicationId: String = BuildConfig.APPLICATION_ID
|
||||
override val versionCode: Int = BuildConfig.VERSION_CODE
|
||||
override val versionName: String = BuildConfig.VERSION_NAME
|
||||
override val absoluteMinFwVersion: String = BuildConfig.ABS_MIN_FW_VERSION
|
||||
override val minFwVersion: String = BuildConfig.MIN_FW_VERSION
|
||||
@Singleton
|
||||
@Provides
|
||||
fun provideBuildConfigProvider(): BuildConfigProvider = object : BuildConfigProvider {
|
||||
override val isDebug: Boolean = BuildConfig.DEBUG
|
||||
override val applicationId: String = BuildConfig.APPLICATION_ID
|
||||
override val versionCode: Int = BuildConfig.VERSION_CODE
|
||||
override val versionName: String = BuildConfig.VERSION_NAME
|
||||
override val absoluteMinFwVersion: String = BuildConfig.ABS_MIN_FW_VERSION
|
||||
override val minFwVersion: String = BuildConfig.MIN_FW_VERSION
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue