Replace Dagger with Kodein

This commit is contained in:
ligi 2017-04-11 23:27:56 +02:00
parent b3c29e2b8a
commit 923545fd06
No known key found for this signature in database
GPG key ID: 8E81894010ABF23D
46 changed files with 236 additions and 463 deletions

View file

@ -114,16 +114,12 @@ configurations {
}
dependencies {
compile "com.google.dagger:dagger:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$dagger_version"
compile 'com.github.hotchemi:permissionsdispatcher:2.3.2'
kapt 'com.github.hotchemi:permissionsdispatcher-processor:2.3.2'
provided 'org.glassfish:javax.annotation:10.0-b28'
compile 'com.github.salomonbrys.kodein:kodein:3.3.0'
kaptAndroidTest "com.google.dagger:dagger-compiler:$dagger_version"
androidTestCompile "com.android.support:support-annotations:$support_version"
provided 'org.glassfish:javax.annotation:10.0-b28'
androidTestCompile 'com.github.ligi:trulesk:0.19'
@ -194,7 +190,6 @@ spoon {
debug = true
grantAllPermissions = true
// TODO - http://stackoverflow.com/questions/43308368/app-had-used-a-different-appcomponent-during-pre-verification
skipDevices = ['3200d5cd47677000']
}
play {

View file

@ -1,19 +1,69 @@
package org.ligi.passandroid
import com.github.salomonbrys.kodein.Kodein
import com.github.salomonbrys.kodein.bind
import com.github.salomonbrys.kodein.instance
import com.github.salomonbrys.kodein.singleton
import org.greenrobot.eventbus.EventBus
import org.ligi.passandroid.injections.FixedPassListPassStore
import org.ligi.passandroid.model.PassStore
import org.ligi.passandroid.model.Settings
import org.ligi.passandroid.model.comparator.PassSortOrder
import org.ligi.passandroid.model.pass.BarCode
import org.ligi.passandroid.model.pass.Pass
import org.ligi.passandroid.model.pass.PassBarCodeFormat
import org.ligi.passandroid.model.pass.PassImpl
import org.mockito.Mockito.`when`
import org.mockito.Mockito.mock
import java.io.File
import java.util.*
class TestApp : App() {
override fun createComponent() = DaggerTestComponent.builder().testModule(TestModule()).build()
override fun createKodein(): Kodein.Module {
return Kodein.Module {
bind<PassStore>() with singleton {
FixedPassListPassStore(emptyList())
}
bind<Settings>() with singleton {
mock(Settings::class.java).apply {
`when`(getSortOrder()).thenReturn(PassSortOrder.DATE_ASC)
`when`(getPassesDir()).thenReturn(File(""))
`when`(doTraceDroidEmailSend()).thenReturn(false)
}
}
bind<Tracker>(overrides = true) with singleton { mock(Tracker::class.java) }
bind<EventBus>() with singleton { mock(EventBus::class.java) }
}
}
override fun installLeakCanary() = Unit
companion object {
val component by lazy { App.component as TestComponent }
val passStore by lazy { component.passStore() }
fun passStore(): PassStore = kodein.instance()
fun settings(): Settings = kodein.instance()
fun reset() {
App.Companion.component = DaggerTestComponent.builder().testModule(TestModule()).build()
fun populatePassStoreWithSinglePass() {
val passList = ArrayList<Pass>()
val pass = PassImpl(UUID.randomUUID().toString())
pass.description = "description"
pass.barCode = BarCode(PassBarCodeFormat.AZTEC, "messageprobe")
passList.add(pass)
fixedPassListPassStore().setList(passList)
passStore().classifier.moveToTopic(pass, "test")
}
fun emptyPassStore() {
fixedPassListPassStore().setList(emptyList())
}
fun fixedPassListPassStore() = passStore() as FixedPassListPassStore
}
}

View file

@ -1,23 +0,0 @@
package org.ligi.passandroid
import dagger.Component
import javax.inject.Singleton
@Singleton
@Component(modules = arrayOf(TestModule::class))
interface TestComponent : AppComponent {
fun inject(theFullscreenBarcodeActivity: TheFullscreenBarcodeActivity)
fun inject(thePassEditActivity: ThePassEditActivity)
fun inject(thePassViewActivity: ThePassViewActivity)
fun inject(thePastLocationsStore: ThePastLocationsStore)
fun inject(theBarCodeEditing: TheBarCodeEditing)
fun inject(thePassListSwiping: ThePassListSwiping)
fun inject(theFieldListEditFragment: TheFieldListEditFragment)
}

View file

@ -1,77 +0,0 @@
package org.ligi.passandroid
import dagger.Module
import dagger.Provides
import org.greenrobot.eventbus.EventBus
import org.ligi.passandroid.injections.FixedPassListPassStore
import org.ligi.passandroid.model.PassStore
import org.ligi.passandroid.model.Settings
import org.ligi.passandroid.model.comparator.PassSortOrder
import org.ligi.passandroid.model.pass.BarCode
import org.ligi.passandroid.model.pass.Pass
import org.ligi.passandroid.model.pass.PassBarCodeFormat
import org.ligi.passandroid.model.pass.PassImpl
import org.mockito.Mockito.`when`
import org.mockito.Mockito.mock
import java.io.File
import java.util.*
import javax.inject.Singleton
@Module
class TestModule {
private val passList: MutableList<Pass>
constructor() {
passList = ArrayList<Pass>()
val pass = PassImpl(UUID.randomUUID().toString())
pass.description = "description"
pass.barCode = BarCode(PassBarCodeFormat.AZTEC, "messageprobe")
passList.add(pass)
}
constructor(passList: MutableList<Pass>) {
this.passList = passList
}
@Singleton
@Provides
fun providePassStore(): PassStore {
val fixedPassListPassStore = FixedPassListPassStore(passList)
if (!passList.isEmpty()) {
fixedPassListPassStore.currentPass = passList[0]
}
for (pass in passList) {
fixedPassListPassStore.classifier.moveToTopic(pass, "test")
}
return fixedPassListPassStore
}
@Singleton
@Provides
fun provideSettings(): Settings {
val mock = mock(Settings::class.java)
`when`(mock.getSortOrder()).thenReturn(PassSortOrder.DATE_ASC)
`when`(mock.getPassesDir()).thenReturn(File(""))
`when`(mock.doTraceDroidEmailSend()).thenReturn(false)
return mock
}
@Singleton
@Provides
fun provideBus(): EventBus {
return mock(EventBus::class.java)
}
@Singleton
@Provides
fun provideTracker(): Tracker {
return mock(Tracker::class.java)
}
}

View file

@ -31,9 +31,9 @@ class TheAddToCalendar {
@Test
fun testIfWeOnlyHaveCalendarStartDate() {
TestApp.reset()
TestApp.populatePassStoreWithSinglePass()
TestApp.passStore.currentPass!!.calendarTimespan = PassImpl.TimeSpan(time)
TestApp.passStore().currentPass!!.calendarTimespan = PassImpl.TimeSpan(time)
rule.launchActivity()
intending(hasType("vnd.android.cursor.item/event")).respondWith(Instrumentation.ActivityResult(RESULT_CANCELED, null))
@ -44,15 +44,15 @@ class TheAddToCalendar {
hasType("vnd.android.cursor.item/event"),
hasExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, time.toEpochSecond() * 1000),
hasExtra(CalendarContract.EXTRA_EVENT_END_TIME, time.plusHours(DEFAULT_EVENT_LENGTH_IN_HOURS).toEpochSecond() * 1000),
hasExtra("title", TestApp.passStore.currentPass!!.description)
hasExtra("title", TestApp.passStore().currentPass!!.description)
))
}
@Test
fun testIfWeOnlyHaveCalendarEndDate() {
TestApp.reset()
TestApp.populatePassStoreWithSinglePass()
TestApp.passStore.currentPass!!.calendarTimespan = PassImpl.TimeSpan(to = time)
TestApp.passStore().currentPass!!.calendarTimespan = PassImpl.TimeSpan(to = time)
rule.launchActivity()
intending(hasType("vnd.android.cursor.item/event")).respondWith(Instrumentation.ActivityResult(RESULT_CANCELED, null))
@ -63,15 +63,15 @@ class TheAddToCalendar {
hasType("vnd.android.cursor.item/event"),
hasExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, time.minusHours(DEFAULT_EVENT_LENGTH_IN_HOURS).toEpochSecond() * 1000),
hasExtra(CalendarContract.EXTRA_EVENT_END_TIME, time.toEpochSecond() * 1000),
hasExtra("title", TestApp.passStore.currentPass!!.description)
hasExtra("title", TestApp.passStore().currentPass!!.description)
))
}
@Test
fun testIfWeOnlyHaveCalendarStartAndEndDate() {
TestApp.reset()
TestApp.populatePassStoreWithSinglePass()
TestApp.passStore.currentPass!!.calendarTimespan = PassImpl.TimeSpan(time, time2)
TestApp.passStore().currentPass!!.calendarTimespan = PassImpl.TimeSpan(time, time2)
rule.launchActivity()
intending(hasType("vnd.android.cursor.item/event")).respondWith(Instrumentation.ActivityResult(RESULT_CANCELED, null))
@ -82,16 +82,16 @@ class TheAddToCalendar {
hasType("vnd.android.cursor.item/event"),
hasExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, time.toEpochSecond() * 1000),
hasExtra(CalendarContract.EXTRA_EVENT_END_TIME, time2.toEpochSecond() * 1000),
hasExtra("title", TestApp.passStore.currentPass!!.description)
hasExtra("title", TestApp.passStore().currentPass!!.description)
))
}
@Test
fun testIfWeOnlyHaveExpirationDate() {
TestApp.reset()
TestApp.populatePassStoreWithSinglePass()
(TestApp.passStore.currentPass as PassImpl).validTimespans = listOf(PassImpl.TimeSpan(time))
(TestApp.passStore().currentPass as PassImpl).validTimespans = listOf(PassImpl.TimeSpan(time))
rule.launchActivity()
intending(hasType("vnd.android.cursor.item/event")).respondWith(Instrumentation.ActivityResult(RESULT_CANCELED, null))
@ -105,15 +105,15 @@ class TheAddToCalendar {
hasType("vnd.android.cursor.item/event"),
hasExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, time.toEpochSecond() * 1000),
hasExtra(CalendarContract.EXTRA_EVENT_END_TIME, time.plusHours(DEFAULT_EVENT_LENGTH_IN_HOURS).toEpochSecond() * 1000),
hasExtra("title", TestApp.passStore.currentPass!!.description)
hasExtra("title", TestApp.passStore().currentPass!!.description)
))
}
@Test
fun testIfWeOnlyHaveExpirationEndDate() {
TestApp.reset()
TestApp.populatePassStoreWithSinglePass()
(TestApp.passStore.currentPass as PassImpl).validTimespans = listOf(PassImpl.TimeSpan(to = time))
(TestApp.passStore().currentPass as PassImpl).validTimespans = listOf(PassImpl.TimeSpan(to = time))
rule.launchActivity()
intending(hasType("vnd.android.cursor.item/event")).respondWith(Instrumentation.ActivityResult(RESULT_CANCELED, null))
@ -127,15 +127,15 @@ class TheAddToCalendar {
hasType("vnd.android.cursor.item/event"),
hasExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, time.minusHours(DEFAULT_EVENT_LENGTH_IN_HOURS).toEpochSecond() * 1000),
hasExtra(CalendarContract.EXTRA_EVENT_END_TIME, time.toEpochSecond() * 1000),
hasExtra("title", TestApp.passStore.currentPass!!.description)
hasExtra("title", TestApp.passStore().currentPass!!.description)
))
}
@Test
fun testIfWeOnlyHaveExpirationStartAndEndDate() {
TestApp.reset()
TestApp.populatePassStoreWithSinglePass()
(TestApp.passStore.currentPass as PassImpl).validTimespans = listOf(PassImpl.TimeSpan(time, time2))
(TestApp.passStore().currentPass as PassImpl).validTimespans = listOf(PassImpl.TimeSpan(time, time2))
rule.launchActivity()
intending(hasType("vnd.android.cursor.item/event")).respondWith(Instrumentation.ActivityResult(RESULT_CANCELED, null))
@ -149,13 +149,13 @@ class TheAddToCalendar {
hasType("vnd.android.cursor.item/event"),
hasExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, time.toEpochSecond() * 1000),
hasExtra(CalendarContract.EXTRA_EVENT_END_TIME, time2.toEpochSecond() * 1000),
hasExtra("title", TestApp.passStore.currentPass!!.description)
hasExtra("title", TestApp.passStore().currentPass!!.description)
))
}
@Test
fun testThereIsNoButtonWithNoDate() {
TestApp.reset()
TestApp.populatePassStoreWithSinglePass()
rule.launchActivity()
onView(withId(R.id.timeButton)).check(matches(not(isDisplayed())))
}

View file

@ -8,6 +8,7 @@ import android.support.test.espresso.assertion.ViewAssertions.matches
import android.support.test.espresso.matcher.ViewMatchers.*
import android.support.test.filters.SdkSuppress
import android.support.test.runner.AndroidJUnit4
import com.github.salomonbrys.kodein.instance
import org.assertj.core.api.Assertions.assertThat
import org.junit.Rule
import org.junit.Test
@ -17,7 +18,6 @@ import org.ligi.passandroid.model.pass.PassBarCodeFormat
import org.ligi.passandroid.model.pass.PassImpl
import org.ligi.passandroid.ui.PassEditActivity
import org.ligi.trulesk.TruleskActivityRule
import javax.inject.Inject
@RunWith(AndroidJUnit4::class)
class TheBarCodeEditing {
@ -25,15 +25,12 @@ class TheBarCodeEditing {
@get:Rule
val rule = TruleskActivityRule(PassEditActivity::class.java, false)
@Inject
lateinit var passStore: PassStore
val passStore: PassStore = App.kodein.instance()
lateinit var currentPass: PassImpl
fun start(setupPass: (pass: PassImpl) -> Unit = {}) {
TestApp.component.inject(this)
currentPass = passStore.currentPass as PassImpl
setupPass(currentPass)

View file

@ -19,14 +19,15 @@ class TheCondensedPassViewMode {
@get:Rule
var rule = TruleskActivityRule(PassListActivity::class.java, false) {
val currentPass = TestApp.component.passStore().currentPass as PassImpl
TestApp.populatePassStoreWithSinglePass()
val currentPass = TestApp.passStore().currentPass as PassImpl
currentPass.calendarTimespan = PassImpl.TimeSpan(ZonedDateTime.of(2016, 11, 23, 20, 42, 42, 5, ZoneId.systemDefault()))
currentPass.fields = mutableListOf(PassField("textprobe", "bar", "yo", false))
}
@Test
fun testDateShowsForCondensedOff() {
`when`(TestApp.component.settings().isCondensedModeEnabled()).thenReturn(false)
`when`(TestApp.settings().isCondensedModeEnabled()).thenReturn(false)
rule.launchActivity()
@ -40,7 +41,7 @@ class TheCondensedPassViewMode {
@Test
fun testFieldShowsForCondensedOn() {
`when`(TestApp.component.settings().isCondensedModeEnabled()).thenReturn(true)
`when`(TestApp.settings().isCondensedModeEnabled()).thenReturn(true)
rule.launchActivity()

View file

@ -5,26 +5,19 @@ import android.support.test.espresso.action.ViewActions.click
import android.support.test.espresso.assertion.ViewAssertions.matches
import android.support.test.espresso.matcher.ViewMatchers.isDisplayed
import android.support.test.espresso.matcher.ViewMatchers.withId
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.ligi.passandroid.R.id.emptyView
import org.ligi.passandroid.functions.checkThatHelpIsThere
import org.ligi.passandroid.model.pass.Pass
import org.ligi.passandroid.ui.PassListActivity
import org.ligi.trulesk.TruleskIntentRule
import java.util.*
class TheEmptyPassList {
@get:Rule
var rule = TruleskIntentRule(PassListActivity::class.java, false)
@Before
fun setUp() {
App.component = DaggerTestComponent.builder().testModule(TestModule(ArrayList<Pass>())).build()
rule.launchActivity(null)
var rule = TruleskIntentRule(PassListActivity::class.java) {
TestApp.emptyPassStore()
}
@Test

View file

@ -18,7 +18,7 @@ class TheFieldListEditFragment {
@get:Rule
val rule = TruleskIntentRule(PassEditActivity::class.java) {
TestApp.passStore.currentPass = PassImpl(UUID.randomUUID().toString()).apply {
TestApp.passStore().currentPass = PassImpl(UUID.randomUUID().toString()).apply {
fields = arrayListOf(field)
}
}

View file

@ -68,7 +68,7 @@ class TheFullscreenBarcodeActivity {
val pass = PassImpl(UUID.randomUUID().toString())
pass.barCode = BarCode(format, BARCODE_MESSAGE)
TestApp.passStore.currentPass = pass
TestApp.passStore().currentPass = pass
rule.launchActivity(null)
onView(withId(R.id.fullscreen_barcode)).check(matches(isDisplayed()))

View file

@ -16,23 +16,18 @@ import org.junit.Rule
import org.junit.Test
import org.ligi.passandroid.R.id.*
import org.ligi.passandroid.R.string.*
import org.ligi.passandroid.model.PassStore
import org.ligi.passandroid.model.pass.PassType.COUPON
import org.ligi.passandroid.model.pass.PassType.EVENT
import org.ligi.passandroid.ui.PassEditActivity
import org.ligi.trulesk.TruleskIntentRule
import javax.inject.Inject
@TargetApi(14)
class ThePassEditActivity {
@Inject
lateinit var passStore: PassStore
val passStore = TestApp.passStore()
@get:Rule
var rule = TruleskIntentRule(PassEditActivity::class.java) {
TestApp.component.inject(this)
}
var rule = TruleskIntentRule(PassEditActivity::class.java)
@Test
fun testSetToEventWorks() {

View file

@ -21,7 +21,7 @@ class ThePassListActivity {
@get:Rule
var rule = TruleskActivityRule(PassListActivity::class.java) {
TestApp.reset()
TestApp.populatePassStoreWithSinglePass()
}
@Test

View file

@ -9,6 +9,7 @@ import android.support.v7.widget.helper.ItemTouchHelper
import org.assertj.core.api.Assertions.assertThat
import org.junit.Rule
import org.junit.Test
import org.ligi.passandroid.App.Companion.passStore
import org.ligi.passandroid.ui.PassListActivity
import org.ligi.passandroid.ui.PassListFragment
import org.ligi.trulesk.TruleskIntentRule
@ -17,11 +18,9 @@ class ThePassListSwiping {
@get:Rule
val rule = TruleskIntentRule(PassListActivity::class.java) {
TestApp.reset()
TestApp.populatePassStoreWithSinglePass()
}
val passStore by lazy { TestApp.passStore }
@Test
fun testWeCanMoveToTrash() {
fakeSwipeLeft()

View file

@ -21,7 +21,7 @@ import java.util.*
@TargetApi(14)
class ThePassViewActivity {
internal fun getActPass() = TestApp.passStore.currentPass as PassImpl
internal fun getActPass() = TestApp.passStore().currentPass as PassImpl
@get:Rule
var rule = TruleskActivityRule(PassViewActivity::class.java, false)

View file

@ -16,7 +16,7 @@ import org.threeten.bp.ZonedDateTime
class ThePassViewHolder {
val currentPass by lazy { TestApp.component.passStore().currentPass as PassImpl }
val currentPass by lazy { App.passStore.currentPass as PassImpl }
@get:Rule
var rule = TruleskActivityRule(PassListActivity::class.java, false)

View file

@ -4,25 +4,41 @@ import org.ligi.passandroid.model.PassClassifier
import org.ligi.passandroid.model.PassStore
import org.ligi.passandroid.model.pass.Pass
import java.io.File
import java.util.*
class FixedPassListPassStore(private val passes: List<Pass>) : PassStore {
class FixedPassListPassStore(private var passes: List<Pass>) : PassStore {
override lateinit var classifier: PassClassifier
init {
classifier = PassClassifier(HashMap<String, String>(), this)
}
fun setList(newPasses: List<Pass>, newCurrentPass: Pass? = newPasses.firstOrNull()) {
currentPass = newCurrentPass
passes = newPasses
passMap.clear()
passMap.putAll(createHashMap())
classifier = PassClassifier(HashMap<String, String>(), this)
}
override var currentPass: Pass? = null
override val passMap: Map<String, Pass> by lazy {
override val passMap: HashMap<String, Pass> by lazy {
return@lazy createHashMap()
}
private fun createHashMap(): HashMap<String, Pass> {
val hashMap = HashMap<String, Pass>()
passes.forEach { hashMap.put(it.id, it) }
return@lazy hashMap
return hashMap
}
override fun getPassbookForId(id: String): Pass? {
return passMap[id]
}
override val classifier: PassClassifier by lazy {
PassClassifier(HashMap<String, String>(), this)
}
override fun deletePassWithId(id: String): Boolean {
return false

View file

@ -2,8 +2,20 @@ package org.ligi.passandroid
import android.app.Application
import android.support.v7.app.AppCompatDelegate
import com.github.salomonbrys.kodein.Kodein
import com.github.salomonbrys.kodein.bind
import com.github.salomonbrys.kodein.instance
import com.github.salomonbrys.kodein.singleton
import com.jakewharton.threetenabp.AndroidThreeTen
import com.squareup.leakcanary.LeakCanary
import com.squareup.moshi.Moshi
import org.greenrobot.eventbus.EventBus
import org.ligi.passandroid.json_adapter.ColorAdapter
import org.ligi.passandroid.json_adapter.ZonedTimeAdapter
import org.ligi.passandroid.model.AndroidFileSystemPassStore
import org.ligi.passandroid.model.AndroidSettings
import org.ligi.passandroid.model.PassStore
import org.ligi.passandroid.model.Settings
import org.ligi.tracedroid.TraceDroid
import org.ligi.tracedroid.logging.Log
@ -12,32 +24,45 @@ open class App : Application() {
override fun onCreate() {
super.onCreate()
component = createComponent()
kodein = Kodein {
import(createTrackerKodeinModule(this@App))
import(createKodein(), allowOverride = true)
}
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
installLeakCanary()
AndroidThreeTen.init(this)
initTraceDroid()
AppCompatDelegate.setDefaultNightMode(component.settings().getNightMode())
val settings: Settings = kodein.instance()
AppCompatDelegate.setDefaultNightMode(settings.getNightMode())
}
open fun createKodein() = Kodein.Module {
val build = Moshi.Builder()
.add(ZonedTimeAdapter())
.add(ColorAdapter())
.build()
bind<PassStore>() with singleton { AndroidFileSystemPassStore(this@App, instance(), build, instance()) }
bind<Settings>() with singleton { AndroidSettings(this@App) }
bind<EventBus>() with singleton { EventBus.getDefault() }
}
open fun installLeakCanary() {
LeakCanary.install(this)
}
open fun createComponent(): AppComponent {
return DaggerAppComponent.builder().appModule(AppModule(this)).trackerModule(TrackerModule(this)).build()
}
private fun initTraceDroid() {
TraceDroid.init(this)
Log.setTAG("PassAndroid")
}
companion object {
lateinit var component: AppComponent
lateinit var kodein: Kodein
val tracker by lazy { kodein.typed.instance(Tracker::class.java) }
val passStore by lazy { kodein.typed.instance(PassStore::class.java) }
val settings by lazy { kodein.typed.instance(Settings::class.java) }
}
}

View file

@ -1,47 +0,0 @@
package org.ligi.passandroid
import dagger.Component
import org.ligi.passandroid.model.PassStore
import org.ligi.passandroid.model.Settings
import org.ligi.passandroid.ui.*
import org.ligi.passandroid.ui.edit.FieldsEditFragment
import org.ligi.passandroid.ui.quirk_fix.USAirwaysLoadActivity
import javax.inject.Singleton
@Singleton
@Component(modules = arrayOf(AppModule::class, TrackerModule::class))
interface AppComponent {
fun inject(passViewActivityBase: PassViewActivityBase)
fun inject(passListActivity: PassListActivity)
fun inject(passEditActivity: PassEditActivity)
fun inject(passAdapter: PassAdapter)
fun inject(passImportActivity: PassImportActivity)
fun inject(passMenuOptions: PassMenuOptions)
fun inject(searchPassesIntentService: SearchPassesIntentService)
fun inject(usAirwaysLoadActivity: USAirwaysLoadActivity)
fun inject(passAndroidActivity: PassAndroidActivity)
fun inject(passListFragment: PassListFragment)
fun inject(passNavigationView: PassNavigationView)
fun inject(touchImageActivity: TouchImageActivity)
fun inject(fieldsEditFragment: FieldsEditFragment)
fun passStore(): PassStore
fun tracker(): Tracker
fun settings(): Settings
}

View file

@ -1,53 +0,0 @@
package org.ligi.passandroid
import android.content.SharedPreferences
import android.preference.PreferenceManager
import com.squareup.moshi.Moshi
import dagger.Module
import dagger.Provides
import org.greenrobot.eventbus.EventBus
import org.ligi.passandroid.json_adapter.ColorAdapter
import org.ligi.passandroid.json_adapter.ZonedTimeAdapter
import org.ligi.passandroid.model.AndroidFileSystemPassStore
import org.ligi.passandroid.model.AndroidSettings
import org.ligi.passandroid.model.PassStore
import org.ligi.passandroid.model.Settings
import javax.inject.Singleton
@Module
class AppModule(private val app: App) {
@Singleton
@Provides
internal fun providePassStore(settings: Settings, moshi: Moshi, bus: EventBus): PassStore {
return AndroidFileSystemPassStore(app, settings, moshi, bus)
}
@Singleton
@Provides
internal fun provideMoshi(): Moshi {
return Moshi.Builder()
.add(ZonedTimeAdapter())
.add(ColorAdapter())
.build()
}
@Singleton
@Provides
internal fun provideSettings(): Settings {
return AndroidSettings(app)
}
@Singleton
@Provides
internal fun provideSharedPreferences(): SharedPreferences {
return PreferenceManager.getDefaultSharedPreferences(app)
}
@Singleton
@Provides
internal fun provideBus(): EventBus {
return EventBus.getDefault()
}
}

View file

@ -15,7 +15,7 @@ import java.net.URL
val IPHONE_USER_AGENT = "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53"
fun fromURI(context: Context, uri: Uri): InputStreamWithSource? {
App.component.tracker().trackEvent("protocol", "to_inputstream", uri.scheme, null)
App.tracker.trackEvent("protocol", "to_inputstream", uri.scheme, null)
when (uri.scheme) {
"content" ->
@ -27,7 +27,7 @@ fun fromURI(context: Context, uri: Uri): InputStreamWithSource? {
"file" -> return getDefaultInputStreamForUri(uri)
else -> {
App.component.tracker().trackException("unknown scheme in ImportAsyncTask" + uri.scheme, false)
App.tracker.trackException("unknown scheme in ImportAsyncTask" + uri.scheme, false)
return getDefaultInputStreamForUri(uri)
}
@ -54,7 +54,7 @@ private fun fromOKHttp(uri: Uri): InputStreamWithSource? {
for ((key, value) in iPhoneFakeMap) {
if (uri.toString().contains(value)) {
App.component.tracker().trackEvent("quirk_fix", "ua_fake", key, null)
App.tracker.trackEvent("quirk_fix", "ua_fake", key, null)
requestBuilder.header("User-Agent", IPHONE_USER_AGENT)
}
}
@ -65,9 +65,9 @@ private fun fromOKHttp(uri: Uri): InputStreamWithSource? {
return InputStreamWithSource(uri.toString(), response.body().byteStream())
} catch (e: MalformedURLException) {
App.component.tracker().trackException("MalformedURLException in ImportAsyncTask", e, false)
App.tracker.trackException("MalformedURLException in ImportAsyncTask", e, false)
} catch (e: IOException) {
App.component.tracker().trackException("IOException in ImportAsyncTask", e, false)
App.tracker.trackException("IOException in ImportAsyncTask", e, false)
}
return null
@ -77,7 +77,7 @@ private fun fromContent(ctx: Context, uri: Uri): InputStreamWithSource? {
try {
return InputStreamWithSource(uri.toString(), ctx.contentResolver.openInputStream(uri)!!)
} catch (e: FileNotFoundException) {
App.component.tracker().trackException("FileNotFoundException in passImportActivity/ImportAsyncTask", e, false)
App.tracker.trackException("FileNotFoundException in passImportActivity/ImportAsyncTask", e, false)
return null
}
@ -88,7 +88,7 @@ private fun getDefaultInputStreamForUri(uri: Uri): InputStreamWithSource? {
try {
return InputStreamWithSource(uri.toString(), BufferedInputStream(URL(uri.toString()).openStream(), 4096))
} catch (e: IOException) {
App.component.tracker().trackException("IOException in passImportActivity/ImportAsyncTask", e, false)
App.tracker.trackException("IOException in passImportActivity/ImportAsyncTask", e, false)
return null
}

View file

@ -69,7 +69,7 @@ class AndroidFileSystemPassStore(private val context: Context, settings: Setting
try {
result = jsonAdapter.fromJson(Okio.buffer(Okio.source(file)))
} catch (ignored: JsonDataException) {
App.component.tracker().trackException("invalid main.json", false)
App.tracker.trackException("invalid main.json", false)
}
}

View file

@ -74,7 +74,7 @@ public class AppleStylePassTranslation extends HashMap<String, String> {
}
return new String(fileData);
} catch (Throwable e) {
App.Companion.getComponent().tracker().trackException("problem_reading_translation", e, false);
App.Companion.getTracker().trackException("problem_reading_translation", e, false);
e.printStackTrace();
return null;
}

View file

@ -5,13 +5,9 @@ import android.content.SharedPreferences
import android.os.Build
import org.ligi.passandroid.Tracker
import java.util.*
import javax.inject.Inject
class PastLocationsStore
@Inject
constructor(private val sharedPreferences: SharedPreferences, private val tracker: Tracker) {
class PastLocationsStore constructor(private val sharedPreferences: SharedPreferences, private val tracker: Tracker) {
@TargetApi(11)
fun putLocation(path: String) {
if (Build.VERSION.SDK_INT < 11) {
// feature not available for these versions

View file

@ -2,7 +2,9 @@ package org.ligi.passandroid.model.pass
import android.content.res.Resources
import android.graphics.drawable.BitmapDrawable
import com.github.salomonbrys.kodein.instance
import org.ligi.passandroid.App
import org.ligi.passandroid.Tracker
import org.ligi.passandroid.functions.generateBitmapDrawable
import org.ligi.tracedroid.logging.Log
import java.util.*
@ -12,15 +14,16 @@ class BarCode(val format: PassBarCodeFormat?, val message: String? = UUID.random
var alternativeText: String? = null
fun getBitmap(resources: Resources): BitmapDrawable? {
val tracker: Tracker = App.kodein.instance()
if (message == null) {
// no message -> no barcode
App.component.tracker().trackException("No Barcode in pass - strange", false)
tracker.trackException("No Barcode in pass - strange", false)
return null
}
if (format == null) {
Log.w("Barcode format is null - fallback to QR")
App.component.tracker().trackException("Barcode format is null - fallback to QR", false)
tracker.trackException("Barcode format is null - fallback to QR", false)
return generateBitmapDrawable(resources, message, PassBarCodeFormat.QR_CODE)
}

View file

@ -77,7 +77,7 @@ object AppleStylePassReader {
if (pass_json == null) {
Log.w("could not load pass.json from passcode ")
App.component.tracker().trackEvent("problem_event", "pass", "without_pass_json", null)
App.tracker.trackEvent("problem_event", "pass", "without_pass_json", null)
return null
}
@ -86,7 +86,7 @@ object AppleStylePassReader {
if (barcode_json != null) {
val barcodeFormatString = barcode_json.getString("format")
App.component.tracker().trackEvent("measure_event", "barcode_format", barcodeFormatString, 0L)
App.tracker.trackEvent("measure_event", "barcode_format", barcodeFormatString, 0L)
val barcodeFormat = BarCode.getFormatFromString(barcodeFormatString)
val barCode = BarCode(barcodeFormat, barcode_json.getString("message"))
pass.barCode = barCode
@ -105,9 +105,9 @@ object AppleStylePassReader {
} catch (e: JSONException) {
// be robust when it comes to bad dates - had a RL crash with "2013-12-25T00:00-57:00" here
// OK then we just have no date here
App.component.tracker().trackException("problem parsing relevant date", e, false)
App.tracker.trackException("problem parsing relevant date", e, false)
} catch (e: DateTimeException) {
App.component.tracker().trackException("problem parsing relevant date", e, false)
App.tracker.trackException("problem parsing relevant date", e, false)
}
}
@ -118,9 +118,9 @@ object AppleStylePassReader {
} catch (e: JSONException) {
// be robust when it comes to bad dates - had a RL crash with "2013-12-25T00:00-57:00" here
// OK then we just have no date here
App.component.tracker().trackException("problem parsing expiration date", e, false)
App.tracker.trackException("problem parsing expiration date", e, false)
} catch (e: DateTimeException) {
App.component.tracker().trackException("problem parsing expiration date", e, false)
App.tracker.trackException("problem parsing expiration date", e, false)
}
}
@ -196,12 +196,12 @@ object AppleStylePassReader {
try {
pass.creator = pass_json.getString("organizationName")
App.component.tracker().trackEvent("measure_event", "organisation_parse", pass.creator, 1L)
App.tracker.trackEvent("measure_event", "organisation_parse", pass.creator, 1L)
} catch (ignored: JSONException) {
// ok - we have no organisation - big deal ..-)
}
ApplePassbookQuirkCorrector(App.component.tracker()).correctQuirks(pass)
ApplePassbookQuirkCorrector(App.tracker).correctQuirks(pass)
return pass
}
@ -245,14 +245,14 @@ object AppleStylePassReader {
val localized = File(path, language + ".lproj")
if (localized.exists() && localized.isDirectory) {
App.component.tracker().trackEvent("measure_event", "pass", language + "_native_lproj", null)
App.tracker.trackEvent("measure_event", "pass", language + "_native_lproj", null)
return localized.path
}
val fallback = File(path, "en.lproj")
if (fallback.exists() && fallback.isDirectory) {
App.component.tracker().trackEvent("measure_event", "pass", "en_lproj", null)
App.tracker.trackEvent("measure_event", "pass", "en_lproj", null)
return fallback.path
}

View file

@ -6,29 +6,21 @@ import android.support.v7.widget.CardView
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.ViewGroup
import com.github.salomonbrys.kodein.instance
import org.ligi.kaxt.startActivityFromClass
import org.ligi.passandroid.App
import org.ligi.passandroid.R
import org.ligi.passandroid.model.PassStore
import org.ligi.passandroid.model.PassStoreProjection
import org.ligi.passandroid.model.Settings
import org.ligi.passandroid.model.pass.Pass
import org.ligi.passandroid.ui.pass_view_holder.CondensedPassViewHolder
import org.ligi.passandroid.ui.pass_view_holder.PassViewHolder
import org.ligi.passandroid.ui.pass_view_holder.VerbosePassViewHolder
import javax.inject.Inject
class PassAdapter(private val passListActivity: AppCompatActivity, private val passStoreProjection: PassStoreProjection) : RecyclerView.Adapter<PassViewHolder>() {
@Inject
lateinit var passStore: PassStore
@Inject
lateinit var settings: Settings
init {
App.component.inject(this)
}
val passStore: PassStore = App.kodein.instance()
val settings: Settings = App.kodein.instance()
override fun onCreateViewHolder(viewGroup: ViewGroup, i: Int): PassViewHolder {
val inflater = LayoutInflater.from(viewGroup.context)
@ -60,15 +52,8 @@ class PassAdapter(private val passListActivity: AppCompatActivity, private val p
}
}
override fun getItemId(position: Int): Long {
return position.toLong()
}
private val list: List<Pass>
get() = passStoreProjection.passList
override fun getItemCount(): Int {
return list.size
}
override fun getItemId(position: Int) = position.toLong()
private val list = passStoreProjection.passList
override fun getItemCount() = list.size
}

View file

@ -1,37 +1,23 @@
package org.ligi.passandroid.ui
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.github.salomonbrys.kodein.instance
import org.greenrobot.eventbus.EventBus
import org.ligi.kaxt.recreateWhenPossible
import org.ligi.passandroid.App
import org.ligi.passandroid.Tracker
import org.ligi.passandroid.model.PassStore
import org.ligi.passandroid.model.Settings
import javax.inject.Inject
open class PassAndroidActivity : AppCompatActivity() {
@Inject
lateinit var passStore: PassStore
@Inject
lateinit var settings: Settings
@Inject
lateinit var bus: EventBus
@Inject
lateinit var tracker: Tracker
val passStore: PassStore = App.kodein.instance()
val settings: Settings = App.kodein.instance()
val bus: EventBus = App.kodein.instance()
val tracker: Tracker = App.kodein.instance()
private var lastSetNightMode: Int? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
App.component.inject(this)
}
override fun onResume() {
super.onResume()

View file

@ -9,6 +9,7 @@ import android.support.v7.app.AppCompatActivity
import android.view.MenuItem
import android.view.View
import android.widget.ImageView
import com.github.salomonbrys.kodein.instance
import kotlinx.android.synthetic.main.edit.*
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
@ -30,7 +31,6 @@ import org.ligi.passandroid.ui.pass_view_holder.EditViewHolder
import permissions.dispatcher.NeedsPermission
import permissions.dispatcher.RuntimePermissions
import java.util.*
import javax.inject.Inject
@RuntimePermissions
class PassEditActivity : AppCompatActivity() {
@ -38,11 +38,8 @@ class PassEditActivity : AppCompatActivity() {
private lateinit var currentPass: PassImpl
private val imageEditHelper by lazy { ImageEditHelper(this, passStore) }
@Inject
lateinit internal var passStore: PassStore
@Inject
lateinit internal var bus: EventBus
internal val passStore: PassStore = App.kodein.instance()
internal val bus: EventBus = App.kodein.instance()
private val passViewHelper: PassViewHelper by lazy { PassViewHelper(this) }
@ -54,7 +51,6 @@ class PassEditActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
App.component.inject(this)
setContentView(R.layout.edit)
categoryView.setOnClickListener {

View file

@ -31,7 +31,7 @@ internal open class PassExportTaskAndShare(protected val activity: Activity, val
}
if (passExporter.exception != null) {
App.component.tracker().trackException("passExporterException", passExporter.exception, false)
App.tracker.trackException("passExporterException", passExporter.exception, false)
Toast.makeText(activity, "could not export pass " + passExporter.exception, Toast.LENGTH_LONG).show()
} else {
val uriForFile = FileProvider.getUriForFile(activity, activity.getString(R.string.authority_fileprovider), file)

View file

@ -27,7 +27,7 @@ class PassExporter(private val inputPath: File, val file: File) {
} catch (exception: Exception) {
exception.printStackTrace()
App.component.tracker().trackException("when exporting pass to zip", exception, false)
App.tracker.trackException("when exporting pass to zip", exception, false)
this.exception = exception // we need to take action on the main thread later
file.delete() // prevent zombies from taking over
}

View file

@ -2,24 +2,19 @@ package org.ligi.passandroid.ui
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.github.salomonbrys.kodein.instance
import org.ligi.passandroid.App
import org.ligi.passandroid.Tracker
import org.ligi.passandroid.model.PassStore
import javax.inject.Inject
class PassImportActivity : AppCompatActivity() {
@Inject
lateinit var tracker: Tracker
@Inject
lateinit var passStore: PassStore
val tracker: Tracker = App.kodein.instance()
val passStore: PassStore = App.kodein.instance()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
App.component.inject(this)
if (intent.data == null || intent.data.scheme == null) {
tracker.trackException("invalid_import_uri", false)
finish()

View file

@ -24,7 +24,6 @@ import org.greenrobot.eventbus.ThreadMode
import org.ligi.kaxt.setButton
import org.ligi.kaxt.startActivityFromClass
import org.ligi.kaxt.startActivityFromURL
import org.ligi.passandroid.App
import org.ligi.passandroid.R
import org.ligi.passandroid.events.PassStoreChangeEvent
import org.ligi.passandroid.events.ScanFinishedEvent
@ -131,8 +130,6 @@ class PassListActivity : PassAndroidActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
App.component.inject(this)
setContentView(R.layout.pass_list)
setSupportActionBar(toolbar)

View file

@ -11,6 +11,7 @@ import android.support.v7.widget.helper.ItemTouchHelper.*
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.github.salomonbrys.kodein.instance
import kotlinx.android.synthetic.main.pass_recycler.view.*
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
@ -23,7 +24,6 @@ import org.ligi.passandroid.functions.moveWithUndoSnackbar
import org.ligi.passandroid.model.PassStore
import org.ligi.passandroid.model.PassStoreProjection
import org.ligi.passandroid.model.Settings
import javax.inject.Inject
class PassListFragment : Fragment() {
@ -31,20 +31,13 @@ class PassListFragment : Fragment() {
private lateinit var passStoreProjection: PassStoreProjection
private lateinit var adapter: PassAdapter
@Inject
lateinit var passStore: PassStore
@Inject
lateinit var settings: Settings
@Inject
lateinit var bus: EventBus
val passStore: PassStore = App.kodein.instance()
val settings: Settings = App.kodein.instance()
val bus: EventBus = App.kodein.instance()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val inflate = inflater.inflate(R.layout.pass_recycler, container, false)
App.component.inject(this)
passStoreProjection = PassStoreProjection(passStore, arguments.getString(BUNDLE_KEY_TOPIC)!!, settings.getSortOrder())
adapter = PassAdapter(activity as AppCompatActivity, passStoreProjection)

View file

@ -6,6 +6,7 @@ import android.support.v4.app.NavUtils
import android.support.v7.app.AlertDialog
import android.view.LayoutInflater
import android.view.MenuItem
import com.github.salomonbrys.kodein.instance
import kotlinx.android.synthetic.main.delete_dialog_layout.view.*
import org.ligi.kaxt.startActivityFromClass
import org.ligi.passandroid.App
@ -17,22 +18,12 @@ import org.ligi.passandroid.model.Settings
import org.ligi.passandroid.model.pass.Pass
import org.ligi.passandroid.printing.doPrint
import java.io.File
import javax.inject.Inject
class PassMenuOptions(val activity: Activity, val pass: Pass) {
@Inject
lateinit var passStore: PassStore
@Inject
lateinit var tracker: Tracker
@Inject
lateinit var settings: Settings
init {
App.component.inject(this)
}
var passStore: PassStore = App.kodein.instance()
var tracker: Tracker = App.kodein.instance()
var settings: Settings = App.kodein.instance()
fun process(item: MenuItem): Boolean {
when (item.itemId) {

View file

@ -5,6 +5,7 @@ import android.content.Intent
import android.net.Uri
import android.support.design.widget.NavigationView
import android.util.AttributeSet
import com.github.salomonbrys.kodein.instance
import kotlinx.android.synthetic.main.navigation_drawer_header.view.*
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
@ -13,15 +14,11 @@ import org.ligi.passandroid.App
import org.ligi.passandroid.R
import org.ligi.passandroid.events.PassStoreChangeEvent
import org.ligi.passandroid.model.PassStore
import javax.inject.Inject
class PassNavigationView(context: Context, attrs: AttributeSet) : NavigationView(context, attrs) {
@Inject
lateinit internal var passStore: PassStore
@Inject
lateinit internal var bus: EventBus
val passStore: PassStore = App.kodein.instance()
val bus: EventBus = App.kodein.instance()
fun getIntent(id: Int) = when (id) {
R.id.menu_settings -> Intent(context, PreferenceActivity::class.java)
@ -41,8 +38,6 @@ class PassNavigationView(context: Context, attrs: AttributeSet) : NavigationView
override fun onAttachedToWindow() {
super.onAttachedToWindow()
App.component.inject(this)
bus.register(this)
setNavigationItemSelectedListener { item ->

View file

@ -28,7 +28,7 @@ class PrefsFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedPref
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
if (key == getString(R.string.preference_key_nightmode)) {
@AppCompatDelegate.NightMode val nightMode = App.component.settings().getNightMode()
@AppCompatDelegate.NightMode val nightMode = App.settings.getNightMode()
if (nightMode == MODE_NIGHT_AUTO) {
PrefsFragmentPermissionsDispatcher.ensureDayNightWithCheck(this)

View file

@ -9,6 +9,7 @@ import android.net.Uri
import android.os.Environment
import android.preference.PreferenceManager
import android.support.v4.app.NotificationCompat
import com.github.salomonbrys.kodein.instance
import org.greenrobot.eventbus.EventBus
import org.ligi.passandroid.App
import org.ligi.passandroid.R
@ -23,7 +24,6 @@ import org.ligi.passandroid.ui.UnzipPassController.InputStreamUnzipControllerSpe
import org.ligi.tracedroid.logging.Log
import java.io.File
import java.util.*
import javax.inject.Inject
class SearchPassesIntentService : IntentService("SearchPassesIntentService") {
@ -36,20 +36,12 @@ class SearchPassesIntentService : IntentService("SearchPassesIntentService") {
private var lastProgressUpdate: Long = 0
@Inject
lateinit var passStore: PassStore
@Inject
lateinit var bus: EventBus
@Inject
lateinit var tracker: Tracker
val passStore: PassStore = App.kodein.instance()
val bus: EventBus = App.kodein.instance()
val tracker: Tracker = App.kodein.instance()
override fun onHandleIntent(intent: Intent?) {
App.component.inject(this)
foundList = ArrayList<Pass>()
notifyManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager

View file

@ -3,20 +3,18 @@ package org.ligi.passandroid.ui
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.MenuItem
import com.github.salomonbrys.kodein.instance
import com.ortiz.touch.TouchImageView
import org.ligi.passandroid.App
import org.ligi.passandroid.model.PassStore
import javax.inject.Inject
class TouchImageActivity : AppCompatActivity() {
@Inject
lateinit var passStore: PassStore
val passStore: PassStore = App.kodein.instance()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
App.component.inject(this)
val webView = TouchImageView(this)
setContentView(webView)

View file

@ -15,6 +15,6 @@ open class UnzipControllerSpec(var targetPath: File,
var overwrite = false
constructor(context: Context, passStore: PassStore, onSuccessCallback: SuccessCallback?, failCallback: FailCallback?)
: this(App.component.settings().getPassesDir(), context, passStore, onSuccessCallback, failCallback)
: this(App.settings.getPassesDir(), context, passStore, onSuccessCallback, failCallback)
}

View file

@ -38,7 +38,7 @@ object UnzipPassController {
processFile(FileUnzipControllerSpec(tempFile.absolutePath, spec))
tempFile.delete()
} catch (e: Exception) {
App.component.tracker().trackException("problem processing InputStream", e, false)
App.tracker.trackException("problem processing InputStream", e, false)
spec.failCallback?.fail("problem with temp file" + e)
}

View file

@ -16,7 +16,7 @@ import org.ligi.passandroid.model.pass.PassImpl
class FieldsEditFragment : Fragment() {
fun getPass(): PassImpl = App.component.passStore().currentPass as PassImpl
fun getPass(): PassImpl = App.passStore.currentPass as PassImpl
private var isEditingHiddenFields: Boolean = false

View file

@ -0,0 +1,10 @@
package org.ligi.passandroid
import android.content.Context
import com.github.salomonbrys.kodein.Kodein
import com.github.salomonbrys.kodein.bind
import com.github.salomonbrys.kodein.singleton
fun createTrackerKodeinModule(context: Context) = Kodein.Module {
bind<Tracker>() with singleton { NotTracker() }
}

View file

@ -1,22 +0,0 @@
package org.ligi.passandroid;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
@Module
public class TrackerModule {
private final App app;
public TrackerModule(App app) {
this.app = app;
}
@Singleton
@Provides
public Tracker provideTracker() {
return new NotTracker();
}
}

View file

@ -0,0 +1,10 @@
package org.ligi.passandroid
import android.content.Context
import com.github.salomonbrys.kodein.Kodein
import com.github.salomonbrys.kodein.bind
import com.github.salomonbrys.kodein.singleton
fun createTrackerKodeinModule(context: Context) = Kodein.Module {
bind<Tracker>() with singleton { AnalyticsTracker(context) }
}

View file

@ -1,23 +0,0 @@
package org.ligi.passandroid;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
@Module
public class TrackerModule {
private final App app;
public TrackerModule(App app) {
this.app = app;
}
@Singleton
@Provides
Tracker provideTracker() {
return new AnalyticsTracker(app);
}
}

View file

@ -33,7 +33,7 @@ class LocationsMapFragment : SupportMapFragment() {
map.setOnMapLoadedCallback {
if (click_to_fullscreen)
map.setOnMapClickListener {
App.component.passStore().currentPass = base_activity!!.currentPass
App.passStore.currentPass = base_activity!!.currentPass
activity.startActivityFromClass(FullscreenMapActivity::class.java)
}