mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-19 04:18:53 +01:00
Use @Inject constructors instead of providing deps in Module
This commit is contained in:
@@ -2,18 +2,12 @@ package com.moez.QKSMS.common.di
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import com.moez.QKSMS.common.util.DateFormatter
|
||||
import com.moez.QKSMS.common.util.NotificationManager
|
||||
import com.moez.QKSMS.common.util.ThemeManager
|
||||
import com.moez.QKSMS.data.repository.ContactRepository
|
||||
import com.moez.QKSMS.data.repository.MessageRepository
|
||||
import com.moez.QKSMS.data.sync.SyncManager
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Module
|
||||
class AppModule(var application: Application) {
|
||||
class AppModule(private var application: Application) {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@@ -21,40 +15,4 @@ class AppModule(var application: Application) {
|
||||
return application
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideDateFormatter(context: Context): DateFormatter {
|
||||
return DateFormatter(context)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideSyncManager(context: Context, contacts: ContactRepository): SyncManager {
|
||||
return SyncManager(context, contacts)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideThemeMaager(): ThemeManager {
|
||||
return ThemeManager()
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideNotificationHelper(context: Context, themeManager: ThemeManager): NotificationManager {
|
||||
return NotificationManager(context, themeManager)
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
fun provideMessageRepository(context: Context, notificationManager: NotificationManager): MessageRepository {
|
||||
return MessageRepository(context, notificationManager)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideContactRepository(context: Context): ContactRepository {
|
||||
return ContactRepository(context)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,8 +7,11 @@ import com.moez.QKSMS.common.util.extensions.isSameWeek
|
||||
import com.moez.QKSMS.common.util.extensions.isSameYear
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
class DateFormatter(val context: Context) {
|
||||
@Singleton
|
||||
class DateFormatter @Inject constructor(val context: Context) {
|
||||
|
||||
/**
|
||||
* Replace 12 hour format with 24 hour format if necessary
|
||||
|
||||
@@ -16,9 +16,13 @@ import com.moez.QKSMS.receiver.MarkReadReceiver
|
||||
import com.moez.QKSMS.receiver.MarkSeenReceiver
|
||||
import com.moez.QKSMS.receiver.RemoteMessagingReceiver
|
||||
import com.moez.QKSMS.presentation.conversations.ConversationListActivity
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
||||
class NotificationManager(private val context: Context, private val themeManager: ThemeManager) {
|
||||
@Singleton
|
||||
class NotificationManager @Inject constructor(
|
||||
private val context: Context,
|
||||
private val themeManager: ThemeManager) {
|
||||
|
||||
private val notificationManager = NotificationManagerCompat.from(context)
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.moez.QKSMS.common.util
|
||||
|
||||
class ThemeManager {
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class ThemeManager @Inject constructor() {
|
||||
|
||||
val color = 0xFF008389.toInt()
|
||||
val bubbleColor = 0xFFF4F4F4.toInt()
|
||||
|
||||
Reference in New Issue
Block a user