aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin/com')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt34
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt33
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt1
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt32
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt7
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/prefs/Prefs.kt53
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/BehaviourPrefs.kt3
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/CorePrefs.kt3
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/FeedPrefs.kt3
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/NotifPrefs.kt3
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ShowcasePrefs.kt3
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ThemePrefs.kt3
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt12
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt26
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/NestedWebView.kt11
17 files changed, 185 insertions, 50 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
index 100aeecb..863d2042 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
@@ -24,7 +24,9 @@ import ca.allanwang.kau.kpref.KPrefFactory
import ca.allanwang.kau.kpref.KPrefFactoryAndroid
import ca.allanwang.kau.logging.KL
import ca.allanwang.kau.utils.buildIsLollipopAndUp
+import com.pitchedapps.frost.db.CookieDao
import com.pitchedapps.frost.db.FrostDatabase
+import com.pitchedapps.frost.db.NotificationDao
import com.pitchedapps.frost.facebook.FbCookie
import com.pitchedapps.frost.injectors.ThemeProvider
import com.pitchedapps.frost.prefs.Prefs
@@ -32,11 +34,12 @@ import com.pitchedapps.frost.services.scheduleNotificationsFromPrefs
import com.pitchedapps.frost.services.setupNotificationChannels
import com.pitchedapps.frost.utils.FrostPglAdBlock
import com.pitchedapps.frost.utils.L
+import dagger.hilt.android.HiltAndroidApp
import java.util.Random
+import javax.inject.Inject
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import org.koin.core.component.KoinComponent
-import org.koin.core.component.get
import org.koin.core.context.startKoin
import org.koin.core.module.Module
import org.koin.dsl.module
@@ -44,10 +47,20 @@ import org.koin.dsl.module
/**
* Created by Allan Wang on 2017-05-28.
*/
+@HiltAndroidApp
class FrostApp : Application(), KoinComponent {
- private lateinit var prefs: Prefs
- private lateinit var themeProvider: ThemeProvider
+ @Inject
+ lateinit var prefs: Prefs
+
+ @Inject
+ lateinit var themeProvider: ThemeProvider
+
+ @Inject
+ lateinit var cookieDao: CookieDao
+
+ @Inject
+ lateinit var notifDao: NotificationDao
override fun onCreate() {
startKoin {
@@ -65,19 +78,18 @@ class FrostApp : Application(), KoinComponent {
)
)
}
- if (!buildIsLollipopAndUp) { // not supported
- super.onCreate()
- return
- }
- prefs = get()
- themeProvider = get()
+
+ super.onCreate()
+
+ if (!buildIsLollipopAndUp) return // not supported
+
+// prefs = get()
+// themeProvider = get()
initPrefs()
L.i { "Begin Frost for Facebook" }
FrostPglAdBlock.init(this)
- super.onCreate()
-
setupNotificationChannels(this, themeProvider)
scheduleNotificationsFromPrefs(prefs)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt
index 3248eb14..9968dd0c 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt
@@ -44,20 +44,31 @@ import com.pitchedapps.frost.utils.EXTRA_COOKIES
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.launchNewTask
import com.pitchedapps.frost.utils.loadAssets
+import dagger.hilt.android.AndroidEntryPoint
import java.util.ArrayList
+import javax.inject.Inject
import kotlinx.coroutines.launch
-import org.koin.android.ext.android.inject
/**
* Created by Allan Wang on 2017-05-28.
*/
+@AndroidEntryPoint
class StartActivity : KauBaseActivity() {
- private val fbCookie: FbCookie by inject()
- private val prefs: Prefs by inject()
- private val themeProvider: ThemeProvider by inject()
- private val cookieDao: CookieDao by inject()
- private val genericDao: GenericDao by inject()
+ @Inject
+ lateinit var fbCookie: FbCookie
+
+ @Inject
+ lateinit var prefs: Prefs
+
+ @Inject
+ lateinit var themeProvider: ThemeProvider
+
+ @Inject
+ lateinit var cookieDao: CookieDao
+
+ @Inject
+ lateinit var genericDao: GenericDao
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -82,10 +93,12 @@ class StartActivity : KauBaseActivity() {
val cookies = ArrayList(cookieDao.selectAll())
L.i { "Cookies loaded at time ${System.currentTimeMillis()}" }
L._d {
- "Cookies: ${cookies.joinToString(
- "\t",
- transform = CookieEntity::toSensitiveString
- )}"
+ "Cookies: ${
+ cookies.joinToString(
+ "\t",
+ transform = CookieEntity::toSensitiveString
+ )
+ }"
}
loadAssets(themeProvider)
authDefer.await()
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt
index 0553086c..505738f3 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt
@@ -26,7 +26,6 @@ import com.pitchedapps.frost.injectors.ThemeProvider
import com.pitchedapps.frost.prefs.Prefs
import com.pitchedapps.frost.utils.setFrostTheme
import org.koin.android.ext.android.inject
-import org.koin.core.component.inject
/**
* Created by Allan Wang on 2017-06-12.
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
index 394969cb..35dd4141 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
@@ -179,6 +179,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
contentBinding = when (prefs.mainActivityLayout) {
MainActivityLayout.TOP_BAR -> {
val binding = ActivityMainBinding.inflate(layoutInflater)
+ @SuppressLint("StaticFieldLeak")
object : ActivityMainContentBinding {
override val root: View = binding.root
override val toolbar: Toolbar = binding.toolbar
@@ -190,6 +191,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
}
MainActivityLayout.BOTTOM_BAR -> {
val binding = ActivityMainBottomTabsBinding.inflate(layoutInflater)
+ @SuppressLint("StaticFieldLeak")
object : ActivityMainContentBinding {
override val root: View = binding.root
override val toolbar: Toolbar = binding.toolbar
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt b/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt
index bd0b4ee0..cdcd2349 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt
@@ -21,6 +21,12 @@ import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import com.pitchedapps.frost.BuildConfig
+import dagger.Module
+import dagger.Provides
+import dagger.hilt.InstallIn
+import dagger.hilt.android.qualifiers.ApplicationContext
+import dagger.hilt.components.SingletonComponent
+import javax.inject.Singleton
import org.koin.dsl.module
interface FrostPrivateDao {
@@ -101,3 +107,29 @@ class FrostDatabase(
}
}
}
+
+@Module
+@InstallIn(SingletonComponent::class)
+object DatabaseModule {
+
+ @Provides
+ @Singleton
+ fun frostDatabase(@ApplicationContext context: Context): FrostDatabase =
+ FrostDatabase.create(context)
+
+ @Provides
+ @Singleton
+ fun cookieDao(frostDatabase: FrostDatabase): CookieDao = frostDatabase.cookieDao()
+
+ @Provides
+ @Singleton
+ fun cacheDao(frostDatabase: FrostDatabase): CacheDao = frostDatabase.cacheDao()
+
+ @Provides
+ @Singleton
+ fun notifDao(frostDatabase: FrostDatabase): NotificationDao = frostDatabase.notifDao()
+
+ @Provides
+ @Singleton
+ fun genericDao(frostDatabase: FrostDatabase): GenericDao = frostDatabase.genericDao()
+}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt
index 4e932d09..96a1d9ca 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt
@@ -28,6 +28,7 @@ import com.pitchedapps.frost.prefs.Prefs
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.cookies
import com.pitchedapps.frost.utils.launchLogin
+import javax.inject.Inject
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine
import kotlinx.coroutines.Dispatchers
@@ -42,7 +43,10 @@ import org.koin.dsl.module
*
* The following component manages all cookie transfers.
*/
-class FbCookie(private val prefs: Prefs, private val cookieDao: CookieDao) {
+class FbCookie @Inject internal constructor(
+ private val prefs: Prefs,
+ private val cookieDao: CookieDao
+) {
companion object {
private const val FB_COOKIE_DOMAIN = HTTPS_FACEBOOK_COM
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt
index 570f3719..f57b3a51 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/ThemeProvider.kt
@@ -30,8 +30,10 @@ import com.pitchedapps.frost.enums.Theme
import com.pitchedapps.frost.enums.ThemeCategory
import com.pitchedapps.frost.prefs.Prefs
import com.pitchedapps.frost.utils.L
+import dagger.hilt.android.qualifiers.ApplicationContext
import java.io.BufferedReader
import java.io.FileNotFoundException
+import javax.inject.Inject
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.koin.core.context.GlobalContext
@@ -40,7 +42,10 @@ import org.koin.core.context.GlobalContext
* Provides [InjectorContract] for each [ThemeCategory].
* Can be reloaded to take in changes from [Prefs]
*/
-class ThemeProvider(private val context: Context, private val prefs: Prefs) {
+class ThemeProvider @Inject internal constructor(
+ @ApplicationContext private val context: Context,
+ private val prefs: Prefs
+) {
private var theme: Theme = Theme.values[prefs.theme]
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/prefs/Prefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/prefs/Prefs.kt
index d31be432..56a7cf9d 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/prefs/Prefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/prefs/Prefs.kt
@@ -16,6 +16,9 @@
*/
package com.pitchedapps.frost.prefs
+import android.content.Context
+import ca.allanwang.kau.kpref.KPrefFactory
+import ca.allanwang.kau.kpref.KPrefFactoryAndroid
import com.pitchedapps.frost.prefs.sections.BehaviourPrefs
import com.pitchedapps.frost.prefs.sections.BehaviourPrefsImpl
import com.pitchedapps.frost.prefs.sections.CorePrefs
@@ -28,6 +31,14 @@ import com.pitchedapps.frost.prefs.sections.ShowcasePrefs
import com.pitchedapps.frost.prefs.sections.ShowcasePrefsImpl
import com.pitchedapps.frost.prefs.sections.ThemePrefs
import com.pitchedapps.frost.prefs.sections.ThemePrefsImpl
+import dagger.Binds
+import dagger.Module
+import dagger.Provides
+import dagger.hilt.InstallIn
+import dagger.hilt.android.qualifiers.ApplicationContext
+import dagger.hilt.components.SingletonComponent
+import javax.inject.Inject
+import javax.inject.Singleton
import org.koin.core.context.GlobalContext
import org.koin.dsl.module
@@ -73,7 +84,7 @@ interface Prefs :
}
}
-class PrefsImpl(
+class PrefsImpl @Inject internal constructor(
private val behaviourPrefs: BehaviourPrefs,
private val corePrefs: CorePrefs,
private val feedPrefs: FeedPrefs,
@@ -106,3 +117,43 @@ class PrefsImpl(
showcasePrefs.deleteKeys()
}
}
+
+@Module
+@InstallIn(SingletonComponent::class)
+interface PrefModule {
+ @Binds
+ @Singleton
+ fun behaviour(to: BehaviourPrefsImpl): BehaviourPrefs
+
+ @Binds
+ @Singleton
+ fun core(to: CorePrefsImpl): CorePrefs
+
+ @Binds
+ @Singleton
+ fun feed(to: FeedPrefsImpl): FeedPrefs
+
+ @Binds
+ @Singleton
+ fun notif(to: NotifPrefsImpl): NotifPrefs
+
+ @Binds
+ @Singleton
+ fun theme(to: ThemePrefsImpl): ThemePrefs
+
+ @Binds
+ @Singleton
+ fun showcase(to: ShowcasePrefsImpl): ShowcasePrefs
+
+ @Binds
+ @Singleton
+ fun prefs(to: PrefsImpl): Prefs
+}
+
+@Module
+@InstallIn(SingletonComponent::class)
+object PrefFactoryModule {
+ @Provides
+ @Singleton
+ fun factory(@ApplicationContext context: Context): KPrefFactory = KPrefFactoryAndroid(context)
+}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/BehaviourPrefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/BehaviourPrefs.kt
index 9d621048..aa40c0d2 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/BehaviourPrefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/BehaviourPrefs.kt
@@ -21,6 +21,7 @@ import ca.allanwang.kau.kpref.KPrefFactory
import com.pitchedapps.frost.BuildConfig
import com.pitchedapps.frost.prefs.OldPrefs
import com.pitchedapps.frost.prefs.PrefsBase
+import javax.inject.Inject
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
@@ -50,7 +51,7 @@ interface BehaviourPrefs : PrefsBase {
var autoExpandTextBox: Boolean
}
-class BehaviourPrefsImpl(
+class BehaviourPrefsImpl @Inject internal constructor(
factory: KPrefFactory
) : KPref("${BuildConfig.APPLICATION_ID}.prefs.behaviour", factory),
BehaviourPrefs, KoinComponent {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/CorePrefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/CorePrefs.kt
index 6d3885cb..13fa5729 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/CorePrefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/CorePrefs.kt
@@ -21,6 +21,7 @@ import ca.allanwang.kau.kpref.KPrefFactory
import com.pitchedapps.frost.BuildConfig
import com.pitchedapps.frost.prefs.OldPrefs
import com.pitchedapps.frost.prefs.PrefsBase
+import javax.inject.Inject
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
@@ -56,7 +57,7 @@ interface CorePrefs : PrefsBase {
var messageScrollToBottom: Boolean
}
-class CorePrefsImpl(
+class CorePrefsImpl @Inject internal constructor(
factory: KPrefFactory
) : KPref("${BuildConfig.APPLICATION_ID}.prefs.core", factory),
CorePrefs, KoinComponent {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/FeedPrefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/FeedPrefs.kt
index 3fe2cfd8..17e3bfac 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/FeedPrefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/FeedPrefs.kt
@@ -22,6 +22,7 @@ import com.pitchedapps.frost.BuildConfig
import com.pitchedapps.frost.enums.MainActivityLayout
import com.pitchedapps.frost.prefs.OldPrefs
import com.pitchedapps.frost.prefs.PrefsBase
+import javax.inject.Inject
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
@@ -51,7 +52,7 @@ interface FeedPrefs : PrefsBase {
var showPostReactions: Boolean
}
-class FeedPrefsImpl(
+class FeedPrefsImpl @Inject internal constructor(
factory: KPrefFactory
) : KPref("${BuildConfig.APPLICATION_ID}.prefs.feed", factory),
FeedPrefs, KoinComponent {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/NotifPrefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/NotifPrefs.kt
index a9a6956f..c33cd92e 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/NotifPrefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/NotifPrefs.kt
@@ -21,6 +21,7 @@ import ca.allanwang.kau.kpref.KPrefFactory
import com.pitchedapps.frost.BuildConfig
import com.pitchedapps.frost.prefs.OldPrefs
import com.pitchedapps.frost.prefs.PrefsBase
+import javax.inject.Inject
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
@@ -48,7 +49,7 @@ interface NotifPrefs : PrefsBase {
var notificationFreq: Long
}
-class NotifPrefsImpl(
+class NotifPrefsImpl @Inject internal constructor(
factory: KPrefFactory
) : KPref("${BuildConfig.APPLICATION_ID}.prefs.notif", factory),
NotifPrefs, KoinComponent {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ShowcasePrefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ShowcasePrefs.kt
index 516a14c5..d8a51e32 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ShowcasePrefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ShowcasePrefs.kt
@@ -20,6 +20,7 @@ import ca.allanwang.kau.kpref.KPref
import ca.allanwang.kau.kpref.KPrefFactory
import com.pitchedapps.frost.BuildConfig
import com.pitchedapps.frost.prefs.PrefsBase
+import javax.inject.Inject
interface ShowcasePrefs : PrefsBase {
/**
@@ -35,7 +36,7 @@ interface ShowcasePrefs : PrefsBase {
*
* Showcase prefs that offer one time helpers to guide new users
*/
-class ShowcasePrefsImpl(
+class ShowcasePrefsImpl @Inject internal constructor(
factory: KPrefFactory
) : KPref("${BuildConfig.APPLICATION_ID}.showcase", factory),
ShowcasePrefs {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ThemePrefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ThemePrefs.kt
index 47496d6d..126c3654 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ThemePrefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/ThemePrefs.kt
@@ -22,6 +22,7 @@ import com.pitchedapps.frost.BuildConfig
import com.pitchedapps.frost.injectors.ThemeProvider
import com.pitchedapps.frost.prefs.OldPrefs
import com.pitchedapps.frost.prefs.PrefsBase
+import javax.inject.Inject
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
@@ -41,7 +42,7 @@ interface ThemePrefs : PrefsBase {
var tintNavBar: Boolean
}
-class ThemePrefsImpl(
+class ThemePrefsImpl @Inject internal constructor(
factory: KPrefFactory
) : KPref("${BuildConfig.APPLICATION_ID}.prefs.theme", factory),
ThemePrefs, KoinComponent {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt
index 89009b56..847874f4 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt
@@ -28,25 +28,25 @@ import com.pitchedapps.frost.contracts.FrostContentCore
import com.pitchedapps.frost.contracts.FrostContentParent
import com.pitchedapps.frost.fragments.RecyclerContentContract
import com.pitchedapps.frost.prefs.Prefs
+import dagger.hilt.android.AndroidEntryPoint
+import javax.inject.Inject
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.launch
-import org.koin.core.component.KoinComponent
-import org.koin.core.component.inject
/**
* Created by Allan Wang on 2017-05-29.
*
*/
@UseExperimental(ExperimentalCoroutinesApi::class)
+@AndroidEntryPoint
class FrostRecyclerView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
-) : RecyclerView(context, attrs, defStyleAttr),
- KoinComponent,
- FrostContentCore {
+) : RecyclerView(context, attrs, defStyleAttr), FrostContentCore {
- private val prefs: Prefs by inject()
+ @Inject
+ lateinit var prefs: Prefs
override fun reload(animate: Boolean) = reloadBase(animate)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt
index ecd8c093..3e3223d6 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt
@@ -43,28 +43,34 @@ import com.pitchedapps.frost.web.FrostChromeClient
import com.pitchedapps.frost.web.FrostJSI
import com.pitchedapps.frost.web.FrostWebViewClient
import com.pitchedapps.frost.web.NestedWebView
+import dagger.hilt.android.AndroidEntryPoint
+import javax.inject.Inject
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
-import org.koin.core.component.KoinComponent
-import org.koin.core.component.inject
/**
* Created by Allan Wang on 2017-05-29.
*
*/
+@AndroidEntryPoint
class FrostWebView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
-) : NestedWebView(context, attrs, defStyleAttr),
- FrostContentCore,
- KoinComponent {
-
- val fbCookie: FbCookie by inject()
- val prefs: Prefs by inject()
- val themeProvider: ThemeProvider by inject()
- val cookieDao: CookieDao by inject()
+) : NestedWebView(context, attrs, defStyleAttr), FrostContentCore {
+
+ @Inject
+ lateinit var fbCookie: FbCookie
+
+ @Inject
+ lateinit var prefs: Prefs
+
+ @Inject
+ lateinit var themeProvider: ThemeProvider
+
+ @Inject
+ lateinit var cookieDao: CookieDao
override fun reload(animate: Boolean) {
if (parent.registerTransition(false, animate))
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/NestedWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/NestedWebView.kt
index da0ebf0d..294c2ac1 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/NestedWebView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/NestedWebView.kt
@@ -30,12 +30,17 @@ import androidx.core.view.ViewCompat
*
* Webview extension that handles nested scrolls
*/
-open class NestedWebView @JvmOverloads constructor(
+open class NestedWebView(
context: Context,
- attrs: AttributeSet? = null,
- defStyleAttr: Int = 0
+ attrs: AttributeSet?,
+ defStyleAttr: Int
) : WebView(context, attrs, defStyleAttr), NestedScrollingChild {
+ // No JvmOverloads due to hilt
+ constructor(context: Context) : this(context, null)
+
+ constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
+
private lateinit var childHelper: NestedScrollingChildHelper
private var lastY: Int = 0
private val scrollOffset = IntArray(2)