From 72d15f341d34e614d61cb4dae87fce6b75c9ac1a Mon Sep 17 00:00:00 2001 From: Conny Duck Date: Fri, 22 Feb 2019 16:58:13 +0100 Subject: [PATCH] fix crash on Android 5 --- .../java/com/keylesspalace/tusky/di/ServicesModule.kt | 3 --- .../keylesspalace/tusky/service/AccountChooserService.kt | 9 +++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/di/ServicesModule.kt b/app/src/main/java/com/keylesspalace/tusky/di/ServicesModule.kt index 327ef284..9015b5f2 100644 --- a/app/src/main/java/com/keylesspalace/tusky/di/ServicesModule.kt +++ b/app/src/main/java/com/keylesspalace/tusky/di/ServicesModule.kt @@ -15,7 +15,6 @@ package com.keylesspalace.tusky.di -import com.keylesspalace.tusky.service.AccountChooserService import com.keylesspalace.tusky.service.SendTootService import dagger.Module import dagger.android.ContributesAndroidInjector @@ -24,6 +23,4 @@ import dagger.android.ContributesAndroidInjector abstract class ServicesModule { @ContributesAndroidInjector abstract fun contributesSendTootService(): SendTootService - @ContributesAndroidInjector - abstract fun contributesAccountChooserService(): AccountChooserService } \ No newline at end of file diff --git a/app/src/main/java/com/keylesspalace/tusky/service/AccountChooserService.kt b/app/src/main/java/com/keylesspalace/tusky/service/AccountChooserService.kt index dd39160d..3463d43c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/service/AccountChooserService.kt +++ b/app/src/main/java/com/keylesspalace/tusky/service/AccountChooserService.kt @@ -24,21 +24,22 @@ import android.service.chooser.ChooserTarget import android.service.chooser.ChooserTargetService import android.text.TextUtils import com.keylesspalace.tusky.R +import com.keylesspalace.tusky.TuskyApplication import com.keylesspalace.tusky.db.AccountManager import com.keylesspalace.tusky.di.Injectable import com.keylesspalace.tusky.util.NotificationHelper import com.squareup.picasso.Picasso -import dagger.android.AndroidInjection -import javax.inject.Inject + @TargetApi(23) class AccountChooserService : ChooserTargetService(), Injectable { - @Inject + + // cannot inject here, it crashes on APIs < 23 lateinit var accountManager: AccountManager override fun onCreate() { super.onCreate() - AndroidInjection.inject(this) + accountManager = (application as TuskyApplication).serviceLocator.get(AccountManager::class.java) } override fun onGetChooserTargets(targetActivityName: ComponentName?, intentFilter: IntentFilter?): MutableList {