mirror of https://github.com/tasks/tasks
Choose maps based on gplay availability
parent
90bc28c91c
commit
856cd04621
@ -1,21 +0,0 @@
|
|||||||
package org.tasks.injection
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import dagger.Module
|
|
||||||
import dagger.Provides
|
|
||||||
import dagger.hilt.InstallIn
|
|
||||||
import dagger.hilt.android.components.ActivityComponent
|
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
|
||||||
import dagger.hilt.android.scopes.ActivityScoped
|
|
||||||
import org.tasks.location.MapFragment
|
|
||||||
import org.tasks.location.OsmMapFragment
|
|
||||||
|
|
||||||
@Module
|
|
||||||
@InstallIn(ActivityComponent::class)
|
|
||||||
class LocationModule {
|
|
||||||
@Provides
|
|
||||||
@ActivityScoped
|
|
||||||
fun getMapFragment(@ApplicationContext context: Context): MapFragment {
|
|
||||||
return OsmMapFragment(context)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +1,23 @@
|
|||||||
package org.tasks.injection
|
package org.tasks.injection
|
||||||
|
|
||||||
|
import dagger.Lazy
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import dagger.hilt.InstallIn
|
import dagger.hilt.InstallIn
|
||||||
import dagger.hilt.components.SingletonComponent
|
import dagger.hilt.components.SingletonComponent
|
||||||
import org.tasks.location.LocationService
|
import org.tasks.gtasks.PlayServices
|
||||||
import org.tasks.location.LocationServiceGooglePlay
|
import org.tasks.location.*
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
@InstallIn(SingletonComponent::class)
|
@InstallIn(SingletonComponent::class)
|
||||||
class FlavorModule {
|
class FlavorModule {
|
||||||
@Provides
|
@Provides
|
||||||
fun getLocationService(service: LocationServiceGooglePlay): LocationService = service
|
fun getLocationService(service: LocationServiceGooglePlay): LocationService = service
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
fun getMapFragment(
|
||||||
|
playServices: PlayServices,
|
||||||
|
osm: Lazy<OsmMapFragment>,
|
||||||
|
google: Lazy<GoogleMapFragment>,
|
||||||
|
): MapFragment = if (playServices.isPlayServicesAvailable) google.get() else osm.get()
|
||||||
}
|
}
|
@ -1,28 +0,0 @@
|
|||||||
package org.tasks.injection
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import dagger.Module
|
|
||||||
import dagger.Provides
|
|
||||||
import dagger.hilt.InstallIn
|
|
||||||
import dagger.hilt.android.components.ActivityComponent
|
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
|
||||||
import dagger.hilt.android.scopes.ActivityScoped
|
|
||||||
import org.tasks.R
|
|
||||||
import org.tasks.location.GoogleMapFragment
|
|
||||||
import org.tasks.location.MapFragment
|
|
||||||
import org.tasks.location.OsmMapFragment
|
|
||||||
import org.tasks.preferences.Preferences
|
|
||||||
|
|
||||||
@Module
|
|
||||||
@InstallIn(ActivityComponent::class)
|
|
||||||
internal class LocationModule {
|
|
||||||
@Provides
|
|
||||||
@ActivityScoped
|
|
||||||
fun getMapFragment(
|
|
||||||
preferences: Preferences,
|
|
||||||
@ApplicationContext context: Context
|
|
||||||
): MapFragment = when (preferences.getIntegerFromString(R.string.p_map_tiles, 0)) {
|
|
||||||
1 -> OsmMapFragment(context)
|
|
||||||
else -> GoogleMapFragment(context)
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue