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/activities/AboutActivity.kt12
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt8
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt15
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt39
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/widgets/NotificationWidget.kt35
6 files changed, 74 insertions, 39 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt
index 30116fcb..bbf8f812 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt
@@ -50,16 +50,20 @@ import com.pitchedapps.frost.R
import com.pitchedapps.frost.injectors.ThemeProvider
import com.pitchedapps.frost.prefs.Prefs
import com.pitchedapps.frost.utils.L
-import org.koin.android.ext.android.inject
-import org.koin.core.component.inject
+import dagger.hilt.android.AndroidEntryPoint
+import javax.inject.Inject
/**
* Created by Allan Wang on 2017-06-26.
*/
+@AndroidEntryPoint
class AboutActivity : AboutActivityBase(null) {
- private val prefs: Prefs by inject()
- private val themeProvider: ThemeProvider by inject()
+ @Inject
+ lateinit var prefs: Prefs
+
+ @Inject
+ lateinit var themeProvider: ThemeProvider
override fun Configs.buildConfigs() {
textColor = themeProvider.textColor
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt
index 4b5180d7..4d2af123 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/DebugActivity.kt
@@ -36,7 +36,6 @@ import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.createFreshDir
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.CoroutineExceptionHandler
-import org.koin.android.ext.android.inject
import java.io.File
import javax.inject.Inject
import kotlin.coroutines.resume
@@ -58,7 +57,8 @@ class DebugActivity : KauBaseActivity() {
@Inject
lateinit var activityThemer: ActivityThemer
- private val themeProvider: ThemeProvider by inject()
+ @Inject
+ lateinit var themeProvider: ThemeProvider
lateinit var binding: ActivityDebugBinding
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt
index 8fd45ab8..817eebe1 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt
@@ -56,7 +56,6 @@ import com.pitchedapps.frost.widgets.NotificationWidget
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.NonCancellable
import kotlinx.coroutines.launch
-import org.koin.android.ext.android.inject
import javax.inject.Inject
/**
@@ -71,8 +70,11 @@ class IntroActivity :
ViewPager.PageTransformer,
ViewPager.OnPageChangeListener {
- private val prefs: Prefs by inject()
- private val themeProvider: ThemeProvider by inject()
+ @Inject
+ lateinit var prefs: Prefs
+
+ @Inject
+ lateinit var themeProvider: ThemeProvider
@Inject
lateinit var activityThemer: ActivityThemer
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
index 55dad065..01f52caa 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
@@ -29,12 +29,13 @@ import com.pitchedapps.frost.prefs.Prefs
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.frostEvent
import com.pitchedapps.frost.widgets.NotificationWidget
+import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import kotlinx.coroutines.yield
-import org.koin.android.ext.android.inject
+import javax.inject.Inject
/**
* Created by Allan Wang on 2017-06-14.
@@ -44,11 +45,17 @@ import org.koin.android.ext.android.inject
*
* All fetching is done through parsers
*/
+@AndroidEntryPoint
class NotificationService : BaseJobService() {
- private val prefs: Prefs by inject()
- private val notifDao: NotificationDao by inject()
- private val cookieDao: CookieDao by inject()
+ @Inject
+ lateinit var prefs: Prefs
+
+ @Inject
+ lateinit var notifDao: NotificationDao
+
+ @Inject
+ lateinit var cookieDao: CookieDao
override fun onStopJob(params: JobParameters?): Boolean {
super.onStopJob(params)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt
index c3d5a90e..a0a7e5b1 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/Keywords.kt
@@ -39,20 +39,25 @@ import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial
import com.pitchedapps.frost.R
import com.pitchedapps.frost.injectors.ThemeProvider
import com.pitchedapps.frost.prefs.Prefs
-import org.koin.core.component.KoinComponent
-import org.koin.core.component.inject
+import dagger.hilt.android.AndroidEntryPoint
+import javax.inject.Inject
/**
* Created by Allan Wang on 2017-06-19.
*/
+@AndroidEntryPoint
class Keywords @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
-) : ConstraintLayout(context, attrs, defStyleAttr), KoinComponent {
+) : ConstraintLayout(context, attrs, defStyleAttr) {
+
+ @Inject
+ lateinit var prefs: Prefs
+
+ @Inject
+ lateinit var themeProvider: ThemeProvider
- private val prefs: Prefs by inject()
- private val themeProvider: ThemeProvider by inject()
val editText: AppCompatEditText by bindView(R.id.edit_text)
val addIcon: ImageView by bindView(R.id.add_icon)
val recycler: RecyclerView by bindView(R.id.recycler)
@@ -61,16 +66,21 @@ class Keywords @JvmOverloads constructor(
init {
inflate(context, R.layout.view_keywords, this)
editText.tint(themeProvider.textColor)
- addIcon.setImageDrawable(GoogleMaterial.Icon.gmd_add.keywordDrawable(context, themeProvider))
+ addIcon.setImageDrawable(
+ GoogleMaterial.Icon.gmd_add.keywordDrawable(
+ context,
+ themeProvider
+ )
+ )
addIcon.setOnClickListener {
if (editText.text.isNullOrEmpty()) editText.error =
context.string(R.string.empty_keyword)
else {
- adapter.add(0, KeywordItem(editText.text.toString()))
+ adapter.add(0, KeywordItem(editText.text.toString(), themeProvider))
editText.text?.clear()
}
}
- adapter.add(prefs.notificationKeywords.map { KeywordItem(it) })
+ adapter.add(prefs.notificationKeywords.map { KeywordItem(it, themeProvider) })
recycler.layoutManager = LinearLayoutManager(context)
recycler.adapter = adapter
adapter.addEventHook(object : ClickEventHook<KeywordItem>() {
@@ -96,9 +106,12 @@ class Keywords @JvmOverloads constructor(
private fun IIcon.keywordDrawable(context: Context, themeProvider: ThemeProvider): Drawable =
toDrawable(context, 20, themeProvider.textColor)
-class KeywordItem(val keyword: String) : AbstractItem<KeywordItem.ViewHolder>() {
+class KeywordItem(
+ val keyword: String,
+ private val themeProvider: ThemeProvider
+) : AbstractItem<KeywordItem.ViewHolder>() {
- override fun getViewHolder(v: View): ViewHolder = ViewHolder(v)
+ override fun getViewHolder(v: View): ViewHolder = ViewHolder(v, themeProvider)
override val layoutRes: Int
get() = R.layout.item_keyword
@@ -116,9 +129,11 @@ class KeywordItem(val keyword: String) : AbstractItem<KeywordItem.ViewHolder>()
holder.text.text = null
}
- class ViewHolder(v: View) : RecyclerView.ViewHolder(v), KoinComponent {
+ class ViewHolder(
+ v: View,
+ themeProvider: ThemeProvider
+ ) : RecyclerView.ViewHolder(v) {
- private val themeProvider: ThemeProvider by inject()
val text: AppCompatTextView by bindView(R.id.keyword_text)
val delete: ImageView by bindView(R.id.keyword_delete)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/widgets/NotificationWidget.kt b/app/src/main/kotlin/com/pitchedapps/frost/widgets/NotificationWidget.kt
index 3bf37f7d..d4176ece 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/widgets/NotificationWidget.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/widgets/NotificationWidget.kt
@@ -48,13 +48,17 @@ import com.pitchedapps.frost.prefs.Prefs
import com.pitchedapps.frost.services.NotificationContent
import com.pitchedapps.frost.services.NotificationType
import com.pitchedapps.frost.utils.toReadableTime
-import org.koin.core.component.KoinComponent
-import org.koin.core.component.inject
+import dagger.hilt.android.AndroidEntryPoint
+import javax.inject.Inject
-class NotificationWidget : AppWidgetProvider(), KoinComponent {
+@AndroidEntryPoint
+class NotificationWidget : AppWidgetProvider() {
- private val prefs: Prefs by inject()
- private val themeProvider: ThemeProvider by inject()
+ @Inject
+ lateinit var prefs: Prefs
+
+ @Inject
+ lateinit var themeProvider: ThemeProvider
override fun onUpdate(
context: Context,
@@ -142,9 +146,13 @@ private fun RemoteViews.setIcon(
}
}
-class NotificationWidgetService : RemoteViewsService() {
+@AndroidEntryPoint
+class NotificationWidgetService @Inject internal constructor(
+ private val themeProvider: ThemeProvider,
+ private val notifDao: NotificationDao
+) : RemoteViewsService() {
override fun onGetViewFactory(intent: Intent): RemoteViewsFactory =
- NotificationWidgetDataProvider(this, intent)
+ NotificationWidgetDataProvider(this, intent, themeProvider, notifDao)
companion object {
fun createIntent(context: Context, type: NotificationType, userId: Long): Intent =
@@ -154,13 +162,12 @@ class NotificationWidgetService : RemoteViewsService() {
}
}
-class NotificationWidgetDataProvider(val context: Context, val intent: Intent) :
- RemoteViewsService.RemoteViewsFactory,
- KoinComponent {
-
- private val themeProvider: ThemeProvider by inject()
-
- private val notifDao: NotificationDao by inject()
+class NotificationWidgetDataProvider(
+ private val context: Context,
+ private val intent: Intent,
+ private val themeProvider: ThemeProvider,
+ private val notifDao: NotificationDao
+) : RemoteViewsService.RemoteViewsFactory {
@Volatile
private var content: List<NotificationContent> = emptyList()