diff --git a/app/build.gradle b/app/build.gradle index fe316e863..e0a7551c6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,6 +1,7 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' +apply plugin: 'dagger.hilt.android.plugin' apply plugin: 'com.google.firebase.crashlytics' apply plugin: 'com.github.triplet.play' apply plugin: 'com.mikepenz.aboutlibraries.plugin' @@ -28,7 +29,7 @@ android { ] javaCompileOptions { annotationProcessorOptions { - arguments = [ + arguments += [ "room.schemaLocation": "$projectDir/schemas".toString(), "room.incremental" : "true" ] @@ -114,9 +115,8 @@ play { } ext { - work_manager = "2.3.4" + work_manager = "2.4.0" room = "2.2.5" - dagger = "2.28.3" chucker = "3.2.0" mockk = "1.10.0" } @@ -128,13 +128,13 @@ configurations.all { dependencies { implementation "io.github.wulkanowy:sdk:02486b9" - coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.9' + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.10' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.8' - implementation "androidx.core:core-ktx:1.3.0" + implementation "androidx.core:core-ktx:1.3.1" implementation "androidx.activity:activity-ktx:1.1.0" implementation "androidx.appcompat:appcompat:1.2.0-rc02" implementation "androidx.appcompat:appcompat-resources:1.1.0" @@ -162,11 +162,10 @@ dependencies { implementation "androidx.room:room-ktx:$room" kapt "androidx.room:room-compiler:$room" - implementation "com.google.dagger:dagger-android-support:$dagger" - kapt "com.google.dagger:dagger-compiler:$dagger" - kapt "com.google.dagger:dagger-android-processor:$dagger" - implementation "com.squareup.inject:assisted-inject-annotations-dagger2:0.5.2" - kapt "com.squareup.inject:assisted-inject-processor-dagger2:0.5.2" + implementation "com.google.dagger:hilt-android:$hilt_version" + kapt "com.google.dagger:hilt-android-compiler:$hilt_version" + implementation 'androidx.hilt:hilt-work:1.0.0-alpha02' + kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha02' implementation "com.aurelhubert:ahbottomnavigation:2.3.4" implementation "com.ncapdevi:frag-nav:3.3.0" diff --git a/app/src/main/java/io/github/wulkanowy/WulkanowyApp.kt b/app/src/main/java/io/github/wulkanowy/WulkanowyApp.kt index 9b1944c3f..649958582 100644 --- a/app/src/main/java/io/github/wulkanowy/WulkanowyApp.kt +++ b/app/src/main/java/io/github/wulkanowy/WulkanowyApp.kt @@ -1,17 +1,16 @@ package io.github.wulkanowy +import android.app.Application import android.content.Context import android.util.Log.DEBUG import android.util.Log.INFO import android.util.Log.VERBOSE +import androidx.hilt.work.HiltWorkerFactory import androidx.multidex.MultiDex import androidx.work.Configuration import com.yariksoffice.lingver.Lingver -import dagger.android.AndroidInjector -import dagger.android.support.DaggerApplication +import dagger.hilt.android.HiltAndroidApp import fr.bipi.tressence.file.FileLoggerTree -import io.github.wulkanowy.di.DaggerAppComponent -import io.github.wulkanowy.services.sync.SyncWorkerFactory import io.github.wulkanowy.ui.base.ThemeManager import io.github.wulkanowy.utils.ActivityLifecycleLogger import io.github.wulkanowy.utils.AppInfo @@ -21,10 +20,11 @@ import io.github.wulkanowy.utils.DebugLogTree import timber.log.Timber import javax.inject.Inject -class WulkanowyApp : DaggerApplication(), Configuration.Provider { +@HiltAndroidApp +class WulkanowyApp : Application(), Configuration.Provider { @Inject - lateinit var workerFactory: SyncWorkerFactory + lateinit var workerFactory: HiltWorkerFactory @Inject lateinit var themeManager: ThemeManager @@ -62,10 +62,6 @@ class WulkanowyApp : DaggerApplication(), Configuration.Provider { registerActivityLifecycleCallbacks(ActivityLifecycleLogger()) } - override fun applicationInjector(): AndroidInjector { - return DaggerAppComponent.factory().create(this) - } - override fun getWorkManagerConfiguration() = Configuration.Builder() .setWorkerFactory(workerFactory) .setMinimumLoggingLevel(if (appInfo.isDebug) VERBOSE else INFO) diff --git a/app/src/main/java/io/github/wulkanowy/data/RepositoryModule.kt b/app/src/main/java/io/github/wulkanowy/data/RepositoryModule.kt index 6ece2d978..3370d0ac3 100644 --- a/app/src/main/java/io/github/wulkanowy/data/RepositoryModule.kt +++ b/app/src/main/java/io/github/wulkanowy/data/RepositoryModule.kt @@ -10,6 +10,9 @@ import com.chuckerteam.chucker.api.ChuckerInterceptor import com.chuckerteam.chucker.api.RetentionManager import dagger.Module import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.android.components.ApplicationComponent +import dagger.hilt.android.qualifiers.ApplicationContext import io.github.wulkanowy.data.db.AppDatabase import io.github.wulkanowy.data.db.SharedPrefProvider import io.github.wulkanowy.data.repositories.preferences.PreferencesRepository @@ -18,11 +21,12 @@ import timber.log.Timber import javax.inject.Singleton @Module +@InstallIn(ApplicationComponent::class) internal class RepositoryModule { @Singleton @Provides - fun provideSdk(chuckerCollector: ChuckerCollector, context: Context): Sdk { + fun provideSdk(chuckerCollector: ChuckerCollector, @ApplicationContext context: Context): Sdk { return Sdk().apply { androidVersion = android.os.Build.VERSION.RELEASE buildTag = android.os.Build.MODEL @@ -35,7 +39,7 @@ internal class RepositoryModule { @Singleton @Provides - fun provideChuckerCollector(context: Context, prefRepository: PreferencesRepository): ChuckerCollector { + fun provideChuckerCollector(@ApplicationContext context: Context, prefRepository: PreferencesRepository): ChuckerCollector { return ChuckerCollector( context = context, showNotification = prefRepository.isDebugNotificationEnable, @@ -45,19 +49,19 @@ internal class RepositoryModule { @Singleton @Provides - fun provideDatabase(context: Context, sharedPrefProvider: SharedPrefProvider) = AppDatabase.newInstance(context, sharedPrefProvider) + fun provideDatabase(@ApplicationContext context: Context, sharedPrefProvider: SharedPrefProvider) = AppDatabase.newInstance(context, sharedPrefProvider) @Singleton @Provides - fun provideResources(context: Context): Resources = context.resources + fun provideResources(@ApplicationContext context: Context): Resources = context.resources @Singleton @Provides - fun provideAssets(context: Context): AssetManager = context.assets + fun provideAssets(@ApplicationContext context: Context): AssetManager = context.assets @Singleton @Provides - fun provideSharedPref(context: Context): SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) + fun provideSharedPref(@ApplicationContext context: Context): SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) @Singleton @Provides diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/logger/LoggerRepository.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/logger/LoggerRepository.kt index e50955e2c..85168fee5 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/logger/LoggerRepository.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/logger/LoggerRepository.kt @@ -1,6 +1,7 @@ package io.github.wulkanowy.data.repositories.logger import android.content.Context +import dagger.hilt.android.qualifiers.ApplicationContext import io.github.wulkanowy.utils.DispatchersProvider import kotlinx.coroutines.withContext import java.io.File @@ -8,7 +9,7 @@ import java.io.FileNotFoundException import javax.inject.Inject class LoggerRepository @Inject constructor( - private val context: Context, + @ApplicationContext private val context: Context, private val dispatchers: DispatchersProvider ) { diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/preferences/PreferencesRepository.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/preferences/PreferencesRepository.kt index 7715cde0d..1d5e57f8a 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/preferences/PreferencesRepository.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/preferences/PreferencesRepository.kt @@ -2,6 +2,7 @@ package io.github.wulkanowy.data.repositories.preferences import android.content.Context import android.content.SharedPreferences +import dagger.hilt.android.qualifiers.ApplicationContext import io.github.wulkanowy.R import io.github.wulkanowy.ui.modules.grade.GradeAverageMode import javax.inject.Inject @@ -10,7 +11,7 @@ import javax.inject.Singleton @Singleton class PreferencesRepository @Inject constructor( private val sharedPref: SharedPreferences, - val context: Context + @ApplicationContext val context: Context ) { val startMenuIndex: Int get() = getString(R.string.pref_key_start_menu, R.string.pref_default_startup).toInt() diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/student/StudentLocal.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/student/StudentLocal.kt index 3a964aae5..5aff8f869 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/student/StudentLocal.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/student/StudentLocal.kt @@ -1,6 +1,7 @@ package io.github.wulkanowy.data.repositories.student import android.content.Context +import dagger.hilt.android.qualifiers.ApplicationContext import io.github.wulkanowy.data.db.dao.StudentDao import io.github.wulkanowy.data.db.entities.Student import io.github.wulkanowy.sdk.Sdk @@ -15,7 +16,7 @@ import javax.inject.Singleton class StudentLocal @Inject constructor( private val studentDb: StudentDao, private val dispatchers: DispatchersProvider, - private val context: Context + @ApplicationContext private val context: Context ) { suspend fun saveStudents(students: List) = withContext(dispatchers.backgroundThread) { diff --git a/app/src/main/java/io/github/wulkanowy/di/AppComponent.kt b/app/src/main/java/io/github/wulkanowy/di/AppComponent.kt deleted file mode 100644 index c0329f7d7..000000000 --- a/app/src/main/java/io/github/wulkanowy/di/AppComponent.kt +++ /dev/null @@ -1,22 +0,0 @@ -package io.github.wulkanowy.di - -import dagger.Component -import dagger.android.AndroidInjector -import dagger.android.support.AndroidSupportInjectionModule -import io.github.wulkanowy.WulkanowyApp -import io.github.wulkanowy.data.RepositoryModule -import io.github.wulkanowy.services.ServicesModule -import javax.inject.Singleton - -@Singleton -@Component(modules = [ - AndroidSupportInjectionModule::class, - AppModule::class, - RepositoryModule::class, - ServicesModule::class, - BindingModule::class]) -interface AppComponent : AndroidInjector { - - @Component.Factory - interface Factory : AndroidInjector.Factory -} diff --git a/app/src/main/java/io/github/wulkanowy/di/AppModule.kt b/app/src/main/java/io/github/wulkanowy/di/AppModule.kt index d791f0a35..9133c34ed 100644 --- a/app/src/main/java/io/github/wulkanowy/di/AppModule.kt +++ b/app/src/main/java/io/github/wulkanowy/di/AppModule.kt @@ -5,29 +5,23 @@ import android.content.Context import com.yariksoffice.lingver.Lingver import dagger.Module import dagger.Provides -import io.github.wulkanowy.WulkanowyApp -import io.github.wulkanowy.utils.AppInfo +import dagger.hilt.InstallIn +import dagger.hilt.android.components.ApplicationComponent +import dagger.hilt.android.qualifiers.ApplicationContext import io.github.wulkanowy.utils.DispatchersProvider import javax.inject.Singleton @Module +@InstallIn(ApplicationComponent::class) internal class AppModule { - @Singleton - @Provides - fun provideContext(app: WulkanowyApp): Context = app - @Singleton @Provides fun provideDispatchersProvider() = DispatchersProvider() @Singleton @Provides - fun provideAppWidgetManager(context: Context): AppWidgetManager = AppWidgetManager.getInstance(context) - - @Singleton - @Provides - fun provideAppInfo() = AppInfo() + fun provideAppWidgetManager(@ApplicationContext context: Context): AppWidgetManager = AppWidgetManager.getInstance(context) @Singleton @Provides diff --git a/app/src/main/java/io/github/wulkanowy/di/BindingModule.kt b/app/src/main/java/io/github/wulkanowy/di/BindingModule.kt deleted file mode 100644 index 246e8c706..000000000 --- a/app/src/main/java/io/github/wulkanowy/di/BindingModule.kt +++ /dev/null @@ -1,55 +0,0 @@ -package io.github.wulkanowy.di - -import dagger.Module -import dagger.android.ContributesAndroidInjector -import io.github.wulkanowy.di.scopes.PerActivity -import io.github.wulkanowy.services.alarm.TimetableNotificationReceiver -import io.github.wulkanowy.ui.base.ErrorDialog -import io.github.wulkanowy.ui.modules.login.LoginActivity -import io.github.wulkanowy.ui.modules.login.LoginModule -import io.github.wulkanowy.ui.modules.luckynumberwidget.LuckyNumberWidgetConfigureActivity -import io.github.wulkanowy.ui.modules.luckynumberwidget.LuckyNumberWidgetProvider -import io.github.wulkanowy.ui.modules.main.MainActivity -import io.github.wulkanowy.ui.modules.main.MainModule -import io.github.wulkanowy.ui.modules.message.send.SendMessageActivity -import io.github.wulkanowy.ui.modules.splash.SplashActivity -import io.github.wulkanowy.ui.modules.timetablewidget.TimetableWidgetConfigureActivity -import io.github.wulkanowy.ui.modules.timetablewidget.TimetableWidgetProvider - -@Suppress("unused") -@Module -internal abstract class BindingModule { - - @ContributesAndroidInjector - abstract fun bindErrorDialog(): ErrorDialog - - @PerActivity - @ContributesAndroidInjector - abstract fun bindSplashActivity(): SplashActivity - - @PerActivity - @ContributesAndroidInjector(modules = [LoginModule::class]) - abstract fun bindLoginActivity(): LoginActivity - - @PerActivity - @ContributesAndroidInjector(modules = [MainModule::class]) - abstract fun bindMainActivity(): MainActivity - - @ContributesAndroidInjector - abstract fun bindMessageSendActivity(): SendMessageActivity - - @ContributesAndroidInjector - abstract fun bindTimetableWidgetAccountActivity(): TimetableWidgetConfigureActivity - - @ContributesAndroidInjector - abstract fun bindTimetableWidgetProvider(): TimetableWidgetProvider - - @ContributesAndroidInjector - abstract fun bindLuckyNumberWidgetAccountActivity(): LuckyNumberWidgetConfigureActivity - - @ContributesAndroidInjector - abstract fun bindLuckyNumberWidgetProvider(): LuckyNumberWidgetProvider - - @ContributesAndroidInjector - abstract fun bindTimetableNotificationReceiver(): TimetableNotificationReceiver -} diff --git a/app/src/main/java/io/github/wulkanowy/di/scopes/PerActivity.kt b/app/src/main/java/io/github/wulkanowy/di/scopes/PerActivity.kt deleted file mode 100644 index c1b4352a4..000000000 --- a/app/src/main/java/io/github/wulkanowy/di/scopes/PerActivity.kt +++ /dev/null @@ -1,7 +0,0 @@ -package io.github.wulkanowy.di.scopes - -import javax.inject.Scope - -@Scope -@Retention(AnnotationRetention.RUNTIME) -annotation class PerActivity diff --git a/app/src/main/java/io/github/wulkanowy/di/scopes/PerChildFragment.kt b/app/src/main/java/io/github/wulkanowy/di/scopes/PerChildFragment.kt deleted file mode 100644 index 08884dac5..000000000 --- a/app/src/main/java/io/github/wulkanowy/di/scopes/PerChildFragment.kt +++ /dev/null @@ -1,7 +0,0 @@ -package io.github.wulkanowy.di.scopes - -import javax.inject.Scope - -@Scope -@Retention(AnnotationRetention.RUNTIME) -annotation class PerChildFragment diff --git a/app/src/main/java/io/github/wulkanowy/di/scopes/PerFragment.kt b/app/src/main/java/io/github/wulkanowy/di/scopes/PerFragment.kt deleted file mode 100644 index 1203d7d88..000000000 --- a/app/src/main/java/io/github/wulkanowy/di/scopes/PerFragment.kt +++ /dev/null @@ -1,7 +0,0 @@ -package io.github.wulkanowy.di.scopes - -import javax.inject.Scope - -@Scope -@Retention(AnnotationRetention.RUNTIME) -annotation class PerFragment diff --git a/app/src/main/java/io/github/wulkanowy/services/HiltBroadcastReceiver.kt b/app/src/main/java/io/github/wulkanowy/services/HiltBroadcastReceiver.kt new file mode 100644 index 000000000..1e795d439 --- /dev/null +++ b/app/src/main/java/io/github/wulkanowy/services/HiltBroadcastReceiver.kt @@ -0,0 +1,9 @@ +package io.github.wulkanowy.services + +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent + +abstract class HiltBroadcastReceiver : BroadcastReceiver() { + override fun onReceive(context: Context, intent: Intent) {} +} diff --git a/app/src/main/java/io/github/wulkanowy/services/ServicesModule.kt b/app/src/main/java/io/github/wulkanowy/services/ServicesModule.kt index facba9cb1..ac5a84e8f 100644 --- a/app/src/main/java/io/github/wulkanowy/services/ServicesModule.kt +++ b/app/src/main/java/io/github/wulkanowy/services/ServicesModule.kt @@ -5,11 +5,12 @@ import android.content.Context import androidx.core.app.NotificationManagerCompat import androidx.core.content.getSystemService import androidx.work.WorkManager -import com.squareup.inject.assisted.dagger2.AssistedModule import dagger.Binds import dagger.Module import dagger.Provides -import dagger.android.ContributesAndroidInjector +import dagger.hilt.InstallIn +import dagger.hilt.android.components.ApplicationComponent +import dagger.hilt.android.qualifiers.ApplicationContext import dagger.multibindings.IntoSet import io.github.wulkanowy.services.sync.channels.Channel import io.github.wulkanowy.services.sync.channels.DebugChannel @@ -33,31 +34,27 @@ import io.github.wulkanowy.services.sync.works.RecipientWork import io.github.wulkanowy.services.sync.works.TeacherWork import io.github.wulkanowy.services.sync.works.TimetableWork import io.github.wulkanowy.services.sync.works.Work -import io.github.wulkanowy.services.widgets.TimetableWidgetService import javax.inject.Singleton @Suppress("unused") -@AssistedModule -@Module(includes = [AssistedInject_ServicesModule::class]) +@Module +@InstallIn(ApplicationComponent::class) abstract class ServicesModule { companion object { @Provides - fun provideWorkManager(context: Context) = WorkManager.getInstance(context) + fun provideWorkManager(@ApplicationContext context: Context) = WorkManager.getInstance(context) @Singleton @Provides - fun provideNotificationManager(context: Context) = NotificationManagerCompat.from(context) + fun provideNotificationManager(@ApplicationContext context: Context) = NotificationManagerCompat.from(context) @Singleton @Provides - fun provideAlarmManager(context: Context): AlarmManager = context.getSystemService()!! + fun provideAlarmManager(@ApplicationContext context: Context): AlarmManager = context.getSystemService()!! } - @ContributesAndroidInjector - abstract fun bindTimetableWidgetService(): TimetableWidgetService - @Binds @IntoSet abstract fun provideGradeWork(work: GradeWork): Work diff --git a/app/src/main/java/io/github/wulkanowy/services/alarm/TimetableNotificationReceiver.kt b/app/src/main/java/io/github/wulkanowy/services/alarm/TimetableNotificationReceiver.kt index 1e68685f7..592d0919e 100644 --- a/app/src/main/java/io/github/wulkanowy/services/alarm/TimetableNotificationReceiver.kt +++ b/app/src/main/java/io/github/wulkanowy/services/alarm/TimetableNotificationReceiver.kt @@ -3,17 +3,17 @@ package io.github.wulkanowy.services.alarm import android.annotation.SuppressLint import android.app.PendingIntent import android.app.PendingIntent.FLAG_UPDATE_CURRENT -import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.os.Build import android.os.Build.VERSION_CODES.N import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat -import dagger.android.AndroidInjection +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.Status import io.github.wulkanowy.data.repositories.student.StudentRepository +import io.github.wulkanowy.services.HiltBroadcastReceiver import io.github.wulkanowy.services.sync.channels.UpcomingLessonsChannel.Companion.CHANNEL_ID import io.github.wulkanowy.ui.modules.main.MainActivity import io.github.wulkanowy.ui.modules.main.MainView @@ -26,7 +26,8 @@ import kotlinx.coroutines.flow.onEach import timber.log.Timber import javax.inject.Inject -class TimetableNotificationReceiver : BroadcastReceiver() { +@AndroidEntryPoint +class TimetableNotificationReceiver : HiltBroadcastReceiver() { @Inject lateinit var studentRepository: StudentRepository @@ -51,8 +52,8 @@ class TimetableNotificationReceiver : BroadcastReceiver() { @SuppressLint("CheckResult") override fun onReceive(context: Context, intent: Intent) { + super.onReceive(context, intent) Timber.d("Receiving intent... ${intent.toUri(0)}") - AndroidInjection.inject(this, context) flowWithResource { val student = studentRepository.getCurrentStudent(false) diff --git a/app/src/main/java/io/github/wulkanowy/services/alarm/TimetableNotificationSchedulerHelper.kt b/app/src/main/java/io/github/wulkanowy/services/alarm/TimetableNotificationSchedulerHelper.kt index 9922a2753..8f8782a2f 100644 --- a/app/src/main/java/io/github/wulkanowy/services/alarm/TimetableNotificationSchedulerHelper.kt +++ b/app/src/main/java/io/github/wulkanowy/services/alarm/TimetableNotificationSchedulerHelper.kt @@ -8,6 +8,7 @@ import android.content.Context import android.content.Intent import androidx.core.app.AlarmManagerCompat import androidx.core.app.NotificationManagerCompat +import dagger.hilt.android.qualifiers.ApplicationContext import io.github.wulkanowy.data.db.entities.Student import io.github.wulkanowy.data.db.entities.Timetable import io.github.wulkanowy.data.repositories.preferences.PreferencesRepository @@ -32,7 +33,7 @@ import java.time.LocalDateTime.now import javax.inject.Inject class TimetableNotificationSchedulerHelper @Inject constructor( - private val context: Context, + @ApplicationContext private val context: Context, private val alarmManager: AlarmManager, private val preferencesRepository: PreferencesRepository ) { diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/SyncWorker.kt b/app/src/main/java/io/github/wulkanowy/services/sync/SyncWorker.kt index 75711f0eb..2ba0435b4 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/SyncWorker.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/SyncWorker.kt @@ -5,12 +5,11 @@ import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat.BigTextStyle import androidx.core.app.NotificationCompat.PRIORITY_DEFAULT import androidx.core.app.NotificationManagerCompat +import androidx.hilt.Assisted +import androidx.hilt.work.WorkerInject import androidx.work.CoroutineWorker import androidx.work.Data -import androidx.work.ListenableWorker import androidx.work.WorkerParameters -import com.squareup.inject.assisted.Assisted -import com.squareup.inject.assisted.AssistedInject import io.github.wulkanowy.R import io.github.wulkanowy.data.repositories.preferences.PreferencesRepository import io.github.wulkanowy.data.repositories.semester.SemesterRepository @@ -24,7 +23,7 @@ import kotlinx.coroutines.coroutineScope import timber.log.Timber import kotlin.random.Random -class SyncWorker @AssistedInject constructor( +class SyncWorker @WorkerInject constructor( @Assisted appContext: Context, @Assisted workerParameters: WorkerParameters, private val studentRepository: StudentRepository, @@ -81,10 +80,4 @@ class SyncWorker @AssistedInject constructor( .setPriority(PRIORITY_DEFAULT) .build()) } - - @AssistedInject.Factory - interface Factory { - - fun create(appContext: Context, workerParameters: WorkerParameters): ListenableWorker - } } diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/SyncWorkerFactory.kt b/app/src/main/java/io/github/wulkanowy/services/sync/SyncWorkerFactory.kt deleted file mode 100644 index aadfc27f4..000000000 --- a/app/src/main/java/io/github/wulkanowy/services/sync/SyncWorkerFactory.kt +++ /dev/null @@ -1,20 +0,0 @@ -package io.github.wulkanowy.services.sync - -import android.content.Context -import androidx.work.ListenableWorker -import androidx.work.WorkerFactory -import androidx.work.WorkerParameters -import timber.log.Timber -import javax.inject.Inject - -class SyncWorkerFactory @Inject constructor(private val syncWorkerFactory: SyncWorker.Factory) : WorkerFactory() { - - override fun createWorker(appContext: Context, workerClassName: String, workerParameters: WorkerParameters): ListenableWorker? { - return if (workerClassName == SyncWorker::class.java.name) { - syncWorkerFactory.create(appContext, workerParameters) - } else { - Timber.e(IllegalArgumentException("Unknown worker class name: $workerClassName")) - null - } - } -} diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/channels/DebugChannel.kt b/app/src/main/java/io/github/wulkanowy/services/sync/channels/DebugChannel.kt index a67350550..2c7565195 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/channels/DebugChannel.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/channels/DebugChannel.kt @@ -6,6 +6,7 @@ import android.app.NotificationChannel import android.app.NotificationManager.IMPORTANCE_DEFAULT import android.content.Context import androidx.core.app.NotificationManagerCompat +import dagger.hilt.android.qualifiers.ApplicationContext import io.github.wulkanowy.R import io.github.wulkanowy.utils.AppInfo import javax.inject.Inject @@ -13,7 +14,7 @@ import javax.inject.Inject @TargetApi(26) class DebugChannel @Inject constructor( private val notificationManager: NotificationManagerCompat, - private val context: Context, + @ApplicationContext private val context: Context, private val appInfo: AppInfo ) : Channel { diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/channels/LuckyNumberChannel.kt b/app/src/main/java/io/github/wulkanowy/services/sync/channels/LuckyNumberChannel.kt index ae228edd7..8025bd76c 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/channels/LuckyNumberChannel.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/channels/LuckyNumberChannel.kt @@ -6,13 +6,14 @@ import android.app.NotificationChannel import android.app.NotificationManager import android.content.Context import androidx.core.app.NotificationManagerCompat +import dagger.hilt.android.qualifiers.ApplicationContext import io.github.wulkanowy.R import javax.inject.Inject @TargetApi(26) class LuckyNumberChannel @Inject constructor( private val notificationManager: NotificationManagerCompat, - private val context: Context + @ApplicationContext private val context: Context ) : Channel { companion object { diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/channels/NewGradesChannel.kt b/app/src/main/java/io/github/wulkanowy/services/sync/channels/NewGradesChannel.kt index 7d6f275d9..5d5727d35 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/channels/NewGradesChannel.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/channels/NewGradesChannel.kt @@ -6,13 +6,14 @@ import android.app.NotificationChannel import android.app.NotificationManager import android.content.Context import androidx.core.app.NotificationManagerCompat +import dagger.hilt.android.qualifiers.ApplicationContext import io.github.wulkanowy.R import javax.inject.Inject @TargetApi(26) class NewGradesChannel @Inject constructor( private val notificationManager: NotificationManagerCompat, - private val context: Context + @ApplicationContext private val context: Context ) : Channel { companion object { diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/channels/NewMessagesChannel.kt b/app/src/main/java/io/github/wulkanowy/services/sync/channels/NewMessagesChannel.kt index 49f39c6be..962fbfa24 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/channels/NewMessagesChannel.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/channels/NewMessagesChannel.kt @@ -6,13 +6,14 @@ import android.app.NotificationChannel import android.app.NotificationManager import android.content.Context import androidx.core.app.NotificationManagerCompat +import dagger.hilt.android.qualifiers.ApplicationContext import io.github.wulkanowy.R import javax.inject.Inject @TargetApi(26) class NewMessagesChannel @Inject constructor( private val notificationManager: NotificationManagerCompat, - private val context: Context + @ApplicationContext private val context: Context ) : Channel { companion object { diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/channels/NewNotesChannel.kt b/app/src/main/java/io/github/wulkanowy/services/sync/channels/NewNotesChannel.kt index d80d43dc5..c6e79b393 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/channels/NewNotesChannel.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/channels/NewNotesChannel.kt @@ -6,13 +6,14 @@ import android.app.NotificationChannel import android.app.NotificationManager import android.content.Context import androidx.core.app.NotificationManagerCompat +import dagger.hilt.android.qualifiers.ApplicationContext import io.github.wulkanowy.R import javax.inject.Inject @TargetApi(26) class NewNotesChannel @Inject constructor( private val notificationManager: NotificationManagerCompat, - private val context: Context + @ApplicationContext private val context: Context ) : Channel { companion object { diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/channels/PushChannel.kt b/app/src/main/java/io/github/wulkanowy/services/sync/channels/PushChannel.kt index a0e24ab45..1d7376b92 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/channels/PushChannel.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/channels/PushChannel.kt @@ -6,13 +6,14 @@ import android.app.NotificationChannel import android.app.NotificationManager import android.content.Context import androidx.core.app.NotificationManagerCompat +import dagger.hilt.android.qualifiers.ApplicationContext import io.github.wulkanowy.R import javax.inject.Inject @TargetApi(26) class PushChannel @Inject constructor( private val notificationManager: NotificationManagerCompat, - private val context: Context + @ApplicationContext private val context: Context ) : Channel { companion object { diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/channels/UpcomingLessonsChannel.kt b/app/src/main/java/io/github/wulkanowy/services/sync/channels/UpcomingLessonsChannel.kt index a292c8b53..cd25eea67 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/channels/UpcomingLessonsChannel.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/channels/UpcomingLessonsChannel.kt @@ -6,13 +6,14 @@ import android.app.NotificationChannel import android.app.NotificationManager.IMPORTANCE_DEFAULT import android.content.Context import androidx.core.app.NotificationManagerCompat +import dagger.hilt.android.qualifiers.ApplicationContext import io.github.wulkanowy.R import javax.inject.Inject @TargetApi(26) class UpcomingLessonsChannel @Inject constructor( private val notificationManager: NotificationManagerCompat, - private val context: Context + @ApplicationContext private val context: Context ) : Channel { companion object { diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/works/GradeWork.kt b/app/src/main/java/io/github/wulkanowy/services/sync/works/GradeWork.kt index 9d4df201d..00bce109e 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/works/GradeWork.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/works/GradeWork.kt @@ -7,6 +7,7 @@ import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat.DEFAULT_ALL import androidx.core.app.NotificationCompat.PRIORITY_HIGH import androidx.core.app.NotificationManagerCompat +import dagger.hilt.android.qualifiers.ApplicationContext import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.Grade import io.github.wulkanowy.data.db.entities.GradeSummary @@ -24,7 +25,7 @@ import javax.inject.Inject import kotlin.random.Random class GradeWork @Inject constructor( - private val context: Context, + @ApplicationContext private val context: Context, private val notificationManager: NotificationManagerCompat, private val gradeRepository: GradeRepository, private val preferencesRepository: PreferencesRepository diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/works/LuckyNumberWork.kt b/app/src/main/java/io/github/wulkanowy/services/sync/works/LuckyNumberWork.kt index 0024d9038..9cb765ec4 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/works/LuckyNumberWork.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/works/LuckyNumberWork.kt @@ -7,6 +7,7 @@ import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat.DEFAULT_ALL import androidx.core.app.NotificationCompat.PRIORITY_HIGH import androidx.core.app.NotificationManagerCompat +import dagger.hilt.android.qualifiers.ApplicationContext import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.LuckyNumber import io.github.wulkanowy.data.db.entities.Semester @@ -23,7 +24,7 @@ import javax.inject.Inject import kotlin.random.Random class LuckyNumberWork @Inject constructor( - private val context: Context, + @ApplicationContext private val context: Context, private val notificationManager: NotificationManagerCompat, private val luckyNumberRepository: LuckyNumberRepository, private val preferencesRepository: PreferencesRepository diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/works/MessageWork.kt b/app/src/main/java/io/github/wulkanowy/services/sync/works/MessageWork.kt index ba026a0e9..7b32f13bb 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/works/MessageWork.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/works/MessageWork.kt @@ -7,6 +7,7 @@ import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat.DEFAULT_ALL import androidx.core.app.NotificationCompat.PRIORITY_HIGH import androidx.core.app.NotificationManagerCompat +import dagger.hilt.android.qualifiers.ApplicationContext import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.Message import io.github.wulkanowy.data.db.entities.Semester @@ -24,7 +25,7 @@ import javax.inject.Inject import kotlin.random.Random class MessageWork @Inject constructor( - private val context: Context, + @ApplicationContext private val context: Context, private val notificationManager: NotificationManagerCompat, private val messageRepository: MessageRepository, private val preferencesRepository: PreferencesRepository diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/works/NoteWork.kt b/app/src/main/java/io/github/wulkanowy/services/sync/works/NoteWork.kt index 2cd9d549a..84b806795 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/works/NoteWork.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/works/NoteWork.kt @@ -7,6 +7,7 @@ import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat.DEFAULT_ALL import androidx.core.app.NotificationCompat.PRIORITY_HIGH import androidx.core.app.NotificationManagerCompat +import dagger.hilt.android.qualifiers.ApplicationContext import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.Note import io.github.wulkanowy.data.db.entities.Semester @@ -23,7 +24,7 @@ import javax.inject.Inject import kotlin.random.Random class NoteWork @Inject constructor( - private val context: Context, + @ApplicationContext private val context: Context, private val notificationManager: NotificationManagerCompat, private val noteRepository: NoteRepository, private val preferencesRepository: PreferencesRepository diff --git a/app/src/main/java/io/github/wulkanowy/services/widgets/TimetableWidgetService.kt b/app/src/main/java/io/github/wulkanowy/services/widgets/TimetableWidgetService.kt index a3b9da95e..42c6d3bfd 100644 --- a/app/src/main/java/io/github/wulkanowy/services/widgets/TimetableWidgetService.kt +++ b/app/src/main/java/io/github/wulkanowy/services/widgets/TimetableWidgetService.kt @@ -2,7 +2,7 @@ package io.github.wulkanowy.services.widgets import android.content.Intent import android.widget.RemoteViewsService -import dagger.android.AndroidInjection +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.data.db.SharedPrefProvider import io.github.wulkanowy.data.repositories.preferences.PreferencesRepository import io.github.wulkanowy.data.repositories.semester.SemesterRepository @@ -12,6 +12,7 @@ import io.github.wulkanowy.ui.modules.timetablewidget.TimetableWidgetFactory import timber.log.Timber import javax.inject.Inject +@AndroidEntryPoint class TimetableWidgetService : RemoteViewsService() { @Inject @@ -30,7 +31,6 @@ class TimetableWidgetService : RemoteViewsService() { lateinit var sharedPref: SharedPrefProvider override fun onGetViewFactory(intent: Intent?): RemoteViewsFactory { - AndroidInjection.inject(this) Timber.d("TimetableWidgetFactory created") return TimetableWidgetFactory(timetableRepo, studentRepo, semesterRepo, prefRepository, sharedPref, applicationContext, intent) } diff --git a/app/src/main/java/io/github/wulkanowy/ui/base/BaseActivity.kt b/app/src/main/java/io/github/wulkanowy/ui/base/BaseActivity.kt index f20fb22f3..86b6701b3 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/base/BaseActivity.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/base/BaseActivity.kt @@ -14,9 +14,6 @@ import androidx.appcompat.app.AppCompatDelegate import androidx.viewbinding.ViewBinding import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar.LENGTH_LONG -import dagger.android.AndroidInjection -import dagger.android.DispatchingAndroidInjector -import dagger.android.HasAndroidInjector import io.github.wulkanowy.R import io.github.wulkanowy.ui.modules.login.LoginActivity import io.github.wulkanowy.utils.FragmentLifecycleLogger @@ -25,13 +22,10 @@ import io.github.wulkanowy.utils.lifecycleAwareVariable import javax.inject.Inject abstract class BaseActivity, VB : ViewBinding> : - AppCompatActivity(), BaseView, HasAndroidInjector { + AppCompatActivity(), BaseView { protected var binding: VB by lifecycleAwareVariable() - @Inject - lateinit var androidInjector: DispatchingAndroidInjector - @Inject lateinit var fragmentLifecycleLogger: FragmentLifecycleLogger @@ -42,8 +36,7 @@ abstract class BaseActivity, VB : ViewBinding> : abstract var presenter: T - public override fun onCreate(savedInstanceState: Bundle?) { - AndroidInjection.inject(this) + override fun onCreate(savedInstanceState: Bundle?) { themeManager.applyActivityTheme(this) super.onCreate(savedInstanceState) supportFragmentManager.registerFragmentLifecycleCallbacks(fragmentLifecycleLogger, true) @@ -91,6 +84,4 @@ abstract class BaseActivity, VB : ViewBinding> : invalidateOptionsMenu() presenter.onDetachView() } - - override fun androidInjector() = androidInjector } diff --git a/app/src/main/java/io/github/wulkanowy/ui/base/BaseDialogFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/base/BaseDialogFragment.kt index 0279dccf4..18cd58b41 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/base/BaseDialogFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/base/BaseDialogFragment.kt @@ -1,11 +1,11 @@ package io.github.wulkanowy.ui.base import android.widget.Toast +import androidx.fragment.app.DialogFragment import androidx.viewbinding.ViewBinding -import dagger.android.support.DaggerAppCompatDialogFragment import io.github.wulkanowy.utils.lifecycleAwareVariable -abstract class BaseDialogFragment : DaggerAppCompatDialogFragment(), BaseView { +abstract class BaseDialogFragment : DialogFragment(), BaseView { protected var binding: VB by lifecycleAwareVariable() diff --git a/app/src/main/java/io/github/wulkanowy/ui/base/BaseFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/base/BaseFragment.kt index 83f787654..c6a2e1d1c 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/base/BaseFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/base/BaseFragment.kt @@ -2,14 +2,14 @@ package io.github.wulkanowy.ui.base import android.view.View import androidx.annotation.LayoutRes +import androidx.fragment.app.Fragment import androidx.viewbinding.ViewBinding import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar.LENGTH_LONG -import dagger.android.support.DaggerFragment import io.github.wulkanowy.R import io.github.wulkanowy.utils.lifecycleAwareVariable -abstract class BaseFragment(@LayoutRes layoutId: Int) : DaggerFragment(layoutId), +abstract class BaseFragment(@LayoutRes layoutId: Int) : Fragment(layoutId), BaseView { protected var binding: VB by lifecycleAwareVariable() diff --git a/app/src/main/java/io/github/wulkanowy/ui/base/ErrorDialog.kt b/app/src/main/java/io/github/wulkanowy/ui/base/ErrorDialog.kt index 627e0a5f5..8d6739a15 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/base/ErrorDialog.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/base/ErrorDialog.kt @@ -11,6 +11,7 @@ import android.widget.Toast import android.widget.Toast.LENGTH_LONG import androidx.appcompat.app.AlertDialog import androidx.core.content.getSystemService +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.databinding.DialogErrorBinding import io.github.wulkanowy.sdk.exception.FeatureNotAvailableException @@ -28,6 +29,7 @@ import java.net.SocketTimeoutException import java.net.UnknownHostException import javax.inject.Inject +@AndroidEntryPoint class ErrorDialog : BaseDialogFragment() { private lateinit var error: Throwable diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/about/AboutFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/about/AboutFragment.kt index d85d01e9e..5ec1a66e3 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/about/AboutFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/about/AboutFragment.kt @@ -4,6 +4,7 @@ import android.graphics.drawable.Drawable import android.os.Bundle import android.view.View import androidx.recyclerview.widget.LinearLayoutManager +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.databinding.FragmentAboutBinding import io.github.wulkanowy.ui.base.BaseFragment @@ -19,6 +20,7 @@ import io.github.wulkanowy.utils.openEmailClient import io.github.wulkanowy.utils.openInternetBrowser import javax.inject.Inject +@AndroidEntryPoint class AboutFragment : BaseFragment(R.layout.fragment_about), AboutView, MainView.TitledView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/about/contributor/ContributorFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/about/contributor/ContributorFragment.kt index 42eebd347..5d7e076c7 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/about/contributor/ContributorFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/about/contributor/ContributorFragment.kt @@ -5,6 +5,7 @@ import android.view.View import android.view.View.GONE import android.view.View.VISIBLE import androidx.recyclerview.widget.LinearLayoutManager +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.pojos.Contributor import io.github.wulkanowy.databinding.FragmentContributorBinding @@ -14,6 +15,7 @@ import io.github.wulkanowy.ui.widgets.DividerItemDecoration import io.github.wulkanowy.utils.openInternetBrowser import javax.inject.Inject +@AndroidEntryPoint class ContributorFragment : BaseFragment(R.layout.fragment_contributor), ContributorView, MainView.TitledView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/about/license/LicenseFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/about/license/LicenseFragment.kt index f6c3b5698..cdd29b41b 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/about/license/LicenseFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/about/license/LicenseFragment.kt @@ -9,13 +9,14 @@ import androidx.core.text.parseAsHtml import androidx.recyclerview.widget.LinearLayoutManager import com.mikepenz.aboutlibraries.Libs import com.mikepenz.aboutlibraries.entity.Library -import dagger.Lazy +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.databinding.FragmentLicenseBinding import io.github.wulkanowy.ui.base.BaseFragment import io.github.wulkanowy.ui.modules.main.MainView import javax.inject.Inject +@AndroidEntryPoint class LicenseFragment : BaseFragment(R.layout.fragment_license), LicenseView, MainView.TitledView { @@ -25,14 +26,13 @@ class LicenseFragment : BaseFragment(R.layout.fragment_l @Inject lateinit var licenseAdapter: LicenseAdapter - @Inject - lateinit var libs: Lazy + private val libs by lazy { Libs(requireContext()) } override val titleStringId get() = R.string.license_title override val appLibraries: ArrayList? get() = context?.let { - libs.get().prepareLibraries(it, emptyArray(), emptyArray(), autoDetect = true, checkCachedDetection = true, sort = true) + libs.prepareLibraries(it, emptyArray(), emptyArray(), autoDetect = true, checkCachedDetection = true, sort = true) } companion object { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/about/license/LicenseModule.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/about/license/LicenseModule.kt deleted file mode 100644 index 0ffc3d90e..000000000 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/about/license/LicenseModule.kt +++ /dev/null @@ -1,15 +0,0 @@ -package io.github.wulkanowy.ui.modules.about.license - -import android.content.Context -import com.mikepenz.aboutlibraries.Libs -import dagger.Module -import dagger.Provides -import io.github.wulkanowy.di.scopes.PerFragment - -@Module -class LicenseModule { - - @PerFragment - @Provides - fun provideLibs(context: Context) = Libs(context) -} diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/about/logviewer/LogViewerFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/about/logviewer/LogViewerFragment.kt index 08f91aff1..cf40975e7 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/about/logviewer/LogViewerFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/about/logviewer/LogViewerFragment.kt @@ -14,6 +14,7 @@ import android.view.MenuItem import android.view.View import androidx.core.content.FileProvider import androidx.recyclerview.widget.LinearLayoutManager +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.BuildConfig.APPLICATION_ID import io.github.wulkanowy.R import io.github.wulkanowy.databinding.FragmentLogviewerBinding @@ -22,6 +23,7 @@ import io.github.wulkanowy.ui.modules.main.MainView import java.io.File import javax.inject.Inject +@AndroidEntryPoint class LogViewerFragment : BaseFragment(R.layout.fragment_logviewer), LogViewerView, MainView.TitledView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/account/AccountDialog.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/account/AccountDialog.kt index 320613745..1fa87268b 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/account/AccountDialog.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/account/AccountDialog.kt @@ -8,12 +8,14 @@ import android.widget.Toast import android.widget.Toast.LENGTH_LONG import androidx.appcompat.app.AlertDialog import androidx.recyclerview.widget.LinearLayoutManager +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.databinding.DialogAccountBinding import io.github.wulkanowy.ui.base.BaseDialogFragment import io.github.wulkanowy.ui.modules.login.LoginActivity import javax.inject.Inject +@AndroidEntryPoint class AccountDialog : BaseDialogFragment(), AccountView { @Inject diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/AttendanceFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/AttendanceFragment.kt index 51f9cb7b5..c7caef069 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/AttendanceFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/AttendanceFragment.kt @@ -14,6 +14,7 @@ import androidx.appcompat.app.AlertDialog import androidx.appcompat.view.ActionMode import androidx.recyclerview.widget.LinearLayoutManager import com.wdullaer.materialdatetimepicker.date.DatePickerDialog +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.Attendance import io.github.wulkanowy.databinding.DialogExcuseBinding @@ -28,6 +29,7 @@ import io.github.wulkanowy.utils.dpToPx import java.time.LocalDate import javax.inject.Inject +@AndroidEntryPoint class AttendanceFragment : BaseFragment(R.layout.fragment_attendance), AttendanceView, MainView.MainChildView, MainView.TitledView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/summary/AttendanceSummaryFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/summary/AttendanceSummaryFragment.kt index 1b9fe08ef..2f8622374 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/summary/AttendanceSummaryFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/summary/AttendanceSummaryFragment.kt @@ -8,6 +8,7 @@ import android.view.View.VISIBLE import android.widget.ArrayAdapter import android.widget.TextView import androidx.recyclerview.widget.LinearLayoutManager +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.AttendanceSummary import io.github.wulkanowy.databinding.FragmentAttendanceSummaryBinding @@ -17,6 +18,7 @@ import io.github.wulkanowy.utils.dpToPx import io.github.wulkanowy.utils.setOnItemSelectedListener import javax.inject.Inject +@AndroidEntryPoint class AttendanceSummaryFragment : BaseFragment(R.layout.fragment_attendance_summary), AttendanceSummaryView, MainView.TitledView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/exam/ExamFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/exam/ExamFragment.kt index eeab30c15..000da00f8 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/exam/ExamFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/exam/ExamFragment.kt @@ -6,6 +6,7 @@ import android.view.View.GONE import android.view.View.INVISIBLE import android.view.View.VISIBLE import androidx.recyclerview.widget.LinearLayoutManager +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.Exam import io.github.wulkanowy.databinding.FragmentExamBinding @@ -16,6 +17,7 @@ import io.github.wulkanowy.ui.widgets.DividerItemDecoration import io.github.wulkanowy.utils.dpToPx import javax.inject.Inject +@AndroidEntryPoint class ExamFragment : BaseFragment(R.layout.fragment_exam), ExamView, MainView.MainChildView, MainView.TitledView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/GradeFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/GradeFragment.kt index 59b83c4b0..0678e13ef 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/GradeFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/GradeFragment.kt @@ -8,6 +8,7 @@ import android.view.View import android.view.View.INVISIBLE import android.view.View.VISIBLE import androidx.appcompat.app.AlertDialog +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.databinding.FragmentGradeBinding import io.github.wulkanowy.ui.base.BaseFragment @@ -20,13 +21,14 @@ import io.github.wulkanowy.utils.dpToPx import io.github.wulkanowy.utils.setOnSelectPageListener import javax.inject.Inject -class GradeFragment : BaseFragment(R.layout.fragment_grade), GradeView, MainView.MainChildView, MainView.TitledView { +@AndroidEntryPoint +class GradeFragment : BaseFragment(R.layout.fragment_grade), GradeView, + MainView.MainChildView, MainView.TitledView { @Inject lateinit var presenter: GradePresenter - @Inject - lateinit var pagerAdapter: BaseFragmentPagerAdapter + private val pagerAdapter by lazy { BaseFragmentPagerAdapter(childFragmentManager) } private var semesterSwitchMenu: MenuItem? = null diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/GradeModule.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/GradeModule.kt deleted file mode 100644 index 342f356cb..000000000 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/GradeModule.kt +++ /dev/null @@ -1,35 +0,0 @@ -package io.github.wulkanowy.ui.modules.grade - -import dagger.Module -import dagger.Provides -import dagger.android.ContributesAndroidInjector -import io.github.wulkanowy.di.scopes.PerChildFragment -import io.github.wulkanowy.di.scopes.PerFragment -import io.github.wulkanowy.ui.base.BaseFragmentPagerAdapter -import io.github.wulkanowy.ui.modules.grade.details.GradeDetailsFragment -import io.github.wulkanowy.ui.modules.grade.statistics.GradeStatisticsFragment -import io.github.wulkanowy.ui.modules.grade.summary.GradeSummaryFragment - -@Suppress("unused") -@Module -abstract class GradeModule { - - companion object { - - @PerFragment - @Provides - fun provideGradeAdapter(fragment: GradeFragment) = BaseFragmentPagerAdapter(fragment.childFragmentManager) - } - - @PerChildFragment - @ContributesAndroidInjector - abstract fun bindGradeDetailsFragment(): GradeDetailsFragment - - @PerChildFragment - @ContributesAndroidInjector - abstract fun binGradeSummaryFragment(): GradeSummaryFragment - - @PerChildFragment - @ContributesAndroidInjector - abstract fun binGradeStatisticsFragment(): GradeStatisticsFragment -} diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsFragment.kt index ac50b9f53..ef9a932e1 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsFragment.kt @@ -9,6 +9,7 @@ import android.view.View.GONE import android.view.View.INVISIBLE import android.view.View.VISIBLE import androidx.recyclerview.widget.LinearLayoutManager +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.Grade import io.github.wulkanowy.databinding.FragmentGradeDetailsBinding @@ -18,6 +19,7 @@ import io.github.wulkanowy.ui.modules.grade.GradeView import io.github.wulkanowy.ui.modules.main.MainActivity import javax.inject.Inject +@AndroidEntryPoint class GradeDetailsFragment : BaseFragment(R.layout.fragment_grade_details), GradeDetailsView, GradeView.GradeChildView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsFragment.kt index 3a8f40073..75050249a 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsFragment.kt @@ -5,6 +5,7 @@ import android.view.View import android.widget.ArrayAdapter import android.widget.TextView import androidx.recyclerview.widget.LinearLayoutManager +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.pojos.GradeStatisticsItem import io.github.wulkanowy.databinding.FragmentGradeStatisticsBinding @@ -15,6 +16,7 @@ import io.github.wulkanowy.utils.dpToPx import io.github.wulkanowy.utils.setOnItemSelectedListener import javax.inject.Inject +@AndroidEntryPoint class GradeStatisticsFragment : BaseFragment(R.layout.fragment_grade_statistics), GradeStatisticsView, GradeView.GradeChildView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/summary/GradeSummaryFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/summary/GradeSummaryFragment.kt index d169f7c62..4d12dcd50 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/summary/GradeSummaryFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/summary/GradeSummaryFragment.kt @@ -6,6 +6,7 @@ import android.view.View.GONE import android.view.View.INVISIBLE import android.view.View.VISIBLE import androidx.recyclerview.widget.LinearLayoutManager +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.GradeSummary import io.github.wulkanowy.databinding.FragmentGradeSummaryBinding @@ -14,6 +15,7 @@ import io.github.wulkanowy.ui.modules.grade.GradeFragment import io.github.wulkanowy.ui.modules.grade.GradeView import javax.inject.Inject +@AndroidEntryPoint class GradeSummaryFragment : BaseFragment(R.layout.fragment_grade_summary), GradeSummaryView, GradeView.GradeChildView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/homework/HomeworkFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/homework/HomeworkFragment.kt index ee2751d71..e1d7ac52f 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/homework/HomeworkFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/homework/HomeworkFragment.kt @@ -5,6 +5,7 @@ import android.view.View import android.view.View.GONE import android.view.View.VISIBLE import androidx.recyclerview.widget.LinearLayoutManager +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.Homework import io.github.wulkanowy.databinding.FragmentHomeworkBinding @@ -16,6 +17,7 @@ import io.github.wulkanowy.ui.widgets.DividerItemDecoration import io.github.wulkanowy.utils.dpToPx import javax.inject.Inject +@AndroidEntryPoint class HomeworkFragment : BaseFragment(R.layout.fragment_homework), HomeworkView, MainView.TitledView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/homework/details/HomeworkDetailsDialog.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/homework/details/HomeworkDetailsDialog.kt index 82938a47d..78abfffd0 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/homework/details/HomeworkDetailsDialog.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/homework/details/HomeworkDetailsDialog.kt @@ -8,6 +8,7 @@ import android.view.ViewGroup import android.view.ViewGroup.LayoutParams.MATCH_PARENT import android.view.ViewGroup.LayoutParams.WRAP_CONTENT import androidx.recyclerview.widget.LinearLayoutManager +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.Homework import io.github.wulkanowy.databinding.DialogHomeworkBinding @@ -15,6 +16,7 @@ import io.github.wulkanowy.ui.base.BaseDialogFragment import io.github.wulkanowy.utils.openInternetBrowser import javax.inject.Inject +@AndroidEntryPoint class HomeworkDetailsDialog : BaseDialogFragment(), HomeworkDetailsView { @Inject diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/LoginActivity.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/LoginActivity.kt index ffb36fe6e..c568b33c2 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/LoginActivity.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/LoginActivity.kt @@ -4,6 +4,7 @@ import android.content.Context import android.content.Intent import android.os.Bundle import android.view.MenuItem +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.data.db.entities.Student import io.github.wulkanowy.databinding.ActivityLoginBinding import io.github.wulkanowy.ui.base.BaseActivity @@ -16,13 +17,13 @@ import io.github.wulkanowy.ui.modules.login.symbol.LoginSymbolFragment import io.github.wulkanowy.utils.setOnSelectPageListener import javax.inject.Inject +@AndroidEntryPoint class LoginActivity : BaseActivity(), LoginView { @Inject override lateinit var presenter: LoginPresenter - @Inject - lateinit var loginAdapter: BaseFragmentPagerAdapter + private val loginAdapter = BaseFragmentPagerAdapter(supportFragmentManager) companion object { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/LoginModule.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/LoginModule.kt deleted file mode 100644 index 26a243dcd..000000000 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/LoginModule.kt +++ /dev/null @@ -1,45 +0,0 @@ -package io.github.wulkanowy.ui.modules.login - -import dagger.Module -import dagger.Provides -import dagger.android.ContributesAndroidInjector -import io.github.wulkanowy.di.scopes.PerActivity -import io.github.wulkanowy.di.scopes.PerFragment -import io.github.wulkanowy.ui.base.BaseFragmentPagerAdapter -import io.github.wulkanowy.ui.modules.login.advanced.LoginAdvancedFragment -import io.github.wulkanowy.ui.modules.login.form.LoginFormFragment -import io.github.wulkanowy.ui.modules.login.recover.LoginRecoverFragment -import io.github.wulkanowy.ui.modules.login.studentselect.LoginStudentSelectFragment -import io.github.wulkanowy.ui.modules.login.symbol.LoginSymbolFragment - -@Suppress("unused") -@Module -internal abstract class LoginModule { - - companion object { - - @PerActivity - @Provides - fun provideLoginAdapter(activity: LoginActivity) = BaseFragmentPagerAdapter(activity.supportFragmentManager) - } - - @PerFragment - @ContributesAndroidInjector - abstract fun bindLoginFormFragment(): LoginFormFragment - - @PerFragment - @ContributesAndroidInjector - abstract fun bindLoginAdvancedFragment(): LoginAdvancedFragment - - @PerFragment - @ContributesAndroidInjector - abstract fun bindLoginSymbolFragment(): LoginSymbolFragment - - @PerFragment - @ContributesAndroidInjector - abstract fun bindLoginSelectStudentFragment(): LoginStudentSelectFragment - - @PerFragment - @ContributesAndroidInjector - abstract fun bindLoginRecoverFragment(): LoginRecoverFragment -} diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/advanced/LoginAdvancedFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/advanced/LoginAdvancedFragment.kt index 3b6a985be..389517912 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/advanced/LoginAdvancedFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/advanced/LoginAdvancedFragment.kt @@ -6,6 +6,7 @@ import android.view.View.GONE import android.view.View.VISIBLE import android.widget.ArrayAdapter import androidx.core.widget.doOnTextChanged +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.Student import io.github.wulkanowy.databinding.FragmentLoginAdvancedBinding @@ -18,6 +19,7 @@ import io.github.wulkanowy.utils.setOnEditorDoneSignIn import io.github.wulkanowy.utils.showSoftInput import javax.inject.Inject +@AndroidEntryPoint class LoginAdvancedFragment : BaseFragment(R.layout.fragment_login_advanced), LoginAdvancedView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormFragment.kt index a2a083c00..2dd5abc3a 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormFragment.kt @@ -6,6 +6,7 @@ import android.view.View import android.view.View.GONE import android.view.View.VISIBLE import androidx.core.widget.doOnTextChanged +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.Student import io.github.wulkanowy.databinding.FragmentLoginFormBinding @@ -19,6 +20,7 @@ import io.github.wulkanowy.utils.setOnEditorDoneSignIn import io.github.wulkanowy.utils.showSoftInput import javax.inject.Inject +@AndroidEntryPoint class LoginFormFragment : BaseFragment(R.layout.fragment_login_form), LoginFormView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/recover/LoginRecoverFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/recover/LoginRecoverFragment.kt index e27c845a6..f0c9652fb 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/recover/LoginRecoverFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/recover/LoginRecoverFragment.kt @@ -10,6 +10,7 @@ import android.webkit.JavascriptInterface import android.webkit.WebView import android.webkit.WebViewClient import androidx.core.widget.doOnTextChanged +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.databinding.FragmentLoginRecoverBinding import io.github.wulkanowy.ui.base.BaseFragment @@ -19,6 +20,7 @@ import io.github.wulkanowy.utils.hideSoftInput import io.github.wulkanowy.utils.showSoftInput import javax.inject.Inject +@AndroidEntryPoint class LoginRecoverFragment : BaseFragment(R.layout.fragment_login_recover), LoginRecoverView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/studentselect/LoginStudentSelectFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/studentselect/LoginStudentSelectFragment.kt index b0df51991..d2884c21e 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/studentselect/LoginStudentSelectFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/studentselect/LoginStudentSelectFragment.kt @@ -5,6 +5,7 @@ import android.view.View import android.view.View.GONE import android.view.View.VISIBLE import androidx.recyclerview.widget.LinearLayoutManager +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.Student import io.github.wulkanowy.databinding.FragmentLoginStudentSelectBinding @@ -16,6 +17,7 @@ import io.github.wulkanowy.utils.openInternetBrowser import java.io.Serializable import javax.inject.Inject +@AndroidEntryPoint class LoginStudentSelectFragment : BaseFragment(R.layout.fragment_login_student_select), LoginStudentSelectView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/symbol/LoginSymbolFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/symbol/LoginSymbolFragment.kt index befbffd50..005fcb7fa 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/symbol/LoginSymbolFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/symbol/LoginSymbolFragment.kt @@ -8,6 +8,7 @@ import android.view.inputmethod.EditorInfo.IME_ACTION_DONE import android.view.inputmethod.EditorInfo.IME_NULL import android.widget.ArrayAdapter import androidx.core.widget.doOnTextChanged +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.Student import io.github.wulkanowy.databinding.FragmentLoginSymbolBinding @@ -20,6 +21,7 @@ import io.github.wulkanowy.utils.openInternetBrowser import io.github.wulkanowy.utils.showSoftInput import javax.inject.Inject +@AndroidEntryPoint class LoginSymbolFragment : BaseFragment(R.layout.fragment_login_symbol), LoginSymbolView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/luckynumber/LuckyNumberFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/luckynumber/LuckyNumberFragment.kt index 0775ce189..0f1d836d0 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/luckynumber/LuckyNumberFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/luckynumber/LuckyNumberFragment.kt @@ -4,6 +4,7 @@ import android.os.Bundle import android.view.View import android.view.View.GONE import android.view.View.VISIBLE +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.LuckyNumber import io.github.wulkanowy.databinding.FragmentLuckyNumberBinding @@ -11,6 +12,7 @@ import io.github.wulkanowy.ui.base.BaseFragment import io.github.wulkanowy.ui.modules.main.MainView import javax.inject.Inject +@AndroidEntryPoint class LuckyNumberFragment : BaseFragment(R.layout.fragment_lucky_number), LuckyNumberView, MainView.TitledView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/luckynumberwidget/LuckyNumberWidgetConfigureActivity.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/luckynumberwidget/LuckyNumberWidgetConfigureActivity.kt index 961ac6338..692615d98 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/luckynumberwidget/LuckyNumberWidgetConfigureActivity.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/luckynumberwidget/LuckyNumberWidgetConfigureActivity.kt @@ -9,6 +9,7 @@ import android.os.Bundle import android.widget.Toast import androidx.appcompat.app.AlertDialog import androidx.recyclerview.widget.LinearLayoutManager +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.Student import io.github.wulkanowy.databinding.ActivityWidgetConfigureBinding @@ -18,6 +19,7 @@ import io.github.wulkanowy.ui.modules.login.LoginActivity import io.github.wulkanowy.utils.AppInfo import javax.inject.Inject +@AndroidEntryPoint class LuckyNumberWidgetConfigureActivity : BaseActivity(), LuckyNumberWidgetConfigureView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/luckynumberwidget/LuckyNumberWidgetProvider.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/luckynumberwidget/LuckyNumberWidgetProvider.kt index 3daaaaf66..4d42b355a 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/luckynumberwidget/LuckyNumberWidgetProvider.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/luckynumberwidget/LuckyNumberWidgetProvider.kt @@ -7,13 +7,12 @@ import android.appwidget.AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT import android.appwidget.AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH import android.appwidget.AppWidgetProvider import android.content.Context -import android.content.Intent import android.content.res.Configuration import android.os.Bundle import android.view.View.GONE import android.view.View.VISIBLE import android.widget.RemoteViews -import dagger.android.AndroidInjection +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.SharedPrefProvider import io.github.wulkanowy.data.exceptions.NoCurrentStudentException @@ -26,6 +25,7 @@ import kotlinx.coroutines.runBlocking import timber.log.Timber import javax.inject.Inject +@AndroidEntryPoint class LuckyNumberWidgetProvider : AppWidgetProvider() { @Inject @@ -48,11 +48,6 @@ class LuckyNumberWidgetProvider : AppWidgetProvider() { fun getWidthWidgetKey(appWidgetId: Int) = "lucky_number_widget_width_$appWidgetId" } - override fun onReceive(context: Context, intent: Intent) { - AndroidInjection.inject(this, context) - super.onReceive(context, intent) - } - override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray?) { super.onUpdate(context, appWidgetManager, appWidgetIds) appWidgetIds?.forEach { appWidgetId -> diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt index f5b7c47c8..035608893 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt @@ -17,7 +17,7 @@ import com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem import com.google.android.material.elevation.ElevationOverlayProvider import com.ncapdevi.fragnav.FragNavController import com.ncapdevi.fragnav.FragNavController.Companion.HIDE -import dagger.Lazy +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.databinding.ActivityMainBinding import io.github.wulkanowy.ui.base.BaseActivity @@ -39,19 +39,18 @@ import io.github.wulkanowy.utils.setOnViewChangeListener import timber.log.Timber import javax.inject.Inject +@AndroidEntryPoint class MainActivity : BaseActivity(), MainView { @Inject override lateinit var presenter: MainPresenter - @Inject - lateinit var navController: FragNavController - @Inject lateinit var analytics: FirebaseAnalyticsHelper - @Inject - lateinit var overlayProvider: Lazy + private val overlayProvider by lazy { ElevationOverlayProvider(this) } + + private val navController = FragNavController(supportFragmentManager, R.id.mainFragmentContainer) companion object { const val EXTRA_START_MENU = "extraStartMenu" @@ -106,7 +105,7 @@ class MainActivity : BaseActivity(), MainVie override fun initView() { with(binding.mainToolbar) { if (SDK_INT >= LOLLIPOP) stateListAnimator = null - setBackgroundColor(overlayProvider.get().compositeOverlayWithThemeSurfaceColorIfNeeded(dpToPx(4f))) + setBackgroundColor(overlayProvider.compositeOverlayWithThemeSurfaceColorIfNeeded(dpToPx(4f))) } with(binding.mainBottomNav) { @@ -119,7 +118,7 @@ class MainActivity : BaseActivity(), MainVie )) accentColor = getThemeAttrColor(R.attr.colorPrimary) inactiveColor = getThemeAttrColor(R.attr.colorOnSurface, 153) - defaultBackgroundColor = overlayProvider.get().compositeOverlayWithThemeSurfaceColorIfNeeded(dpToPx(8f)) + defaultBackgroundColor = overlayProvider.compositeOverlayWithThemeSurfaceColorIfNeeded(dpToPx(8f)) titleState = ALWAYS_SHOW currentItem = startMenuIndex isBehaviorTranslationEnabled = false diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainModule.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainModule.kt deleted file mode 100644 index 03f6ac382..000000000 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainModule.kt +++ /dev/null @@ -1,139 +0,0 @@ -package io.github.wulkanowy.ui.modules.main - -import com.google.android.material.elevation.ElevationOverlayProvider -import com.ncapdevi.fragnav.FragNavController -import dagger.Module -import dagger.Provides -import dagger.android.ContributesAndroidInjector -import io.github.wulkanowy.R -import io.github.wulkanowy.di.scopes.PerFragment -import io.github.wulkanowy.ui.modules.about.AboutFragment -import io.github.wulkanowy.ui.modules.about.contributor.ContributorFragment -import io.github.wulkanowy.ui.modules.about.license.LicenseFragment -import io.github.wulkanowy.ui.modules.about.license.LicenseModule -import io.github.wulkanowy.ui.modules.about.logviewer.LogViewerFragment -import io.github.wulkanowy.ui.modules.account.AccountDialog -import io.github.wulkanowy.ui.modules.attendance.AttendanceFragment -import io.github.wulkanowy.ui.modules.attendance.summary.AttendanceSummaryFragment -import io.github.wulkanowy.ui.modules.exam.ExamFragment -import io.github.wulkanowy.ui.modules.grade.GradeFragment -import io.github.wulkanowy.ui.modules.grade.GradeModule -import io.github.wulkanowy.ui.modules.homework.HomeworkFragment -import io.github.wulkanowy.ui.modules.homework.details.HomeworkDetailsDialog -import io.github.wulkanowy.ui.modules.luckynumber.LuckyNumberFragment -import io.github.wulkanowy.ui.modules.message.MessageFragment -import io.github.wulkanowy.ui.modules.message.MessageModule -import io.github.wulkanowy.ui.modules.message.preview.MessagePreviewFragment -import io.github.wulkanowy.ui.modules.mobiledevice.MobileDeviceFragment -import io.github.wulkanowy.ui.modules.mobiledevice.token.MobileDeviceTokenDialog -import io.github.wulkanowy.ui.modules.more.MoreFragment -import io.github.wulkanowy.ui.modules.note.NoteFragment -import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersFragment -import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersModule -import io.github.wulkanowy.ui.modules.settings.SettingsFragment -import io.github.wulkanowy.ui.modules.timetable.TimetableFragment -import io.github.wulkanowy.ui.modules.timetable.completed.CompletedLessonsFragment - -@Suppress("unused") -@Module -abstract class MainModule { - - companion object { - - @Provides - fun provideFragNavController(activity: MainActivity) = - FragNavController(activity.supportFragmentManager, R.id.mainFragmentContainer) - - //In activities must be injected as Lazy - @Provides - fun provideElevationOverlayProvider(activity: MainActivity) = ElevationOverlayProvider(activity) - } - - @PerFragment - @ContributesAndroidInjector - abstract fun bindAttendanceFragment(): AttendanceFragment - - @PerFragment - @ContributesAndroidInjector - abstract fun bindAttendanceSummaryFragment(): AttendanceSummaryFragment - - @PerFragment - @ContributesAndroidInjector - abstract fun bindExamFragment(): ExamFragment - - @PerFragment - @ContributesAndroidInjector(modules = [GradeModule::class]) - abstract fun bindGradeFragment(): GradeFragment - - @PerFragment - @ContributesAndroidInjector(modules = [MessageModule::class]) - abstract fun bindMessagesFragment(): MessageFragment - - @PerFragment - @ContributesAndroidInjector - abstract fun bindMessagePreviewFragment(): MessagePreviewFragment - - @PerFragment - @ContributesAndroidInjector - abstract fun bindMoreFragment(): MoreFragment - - @PerFragment - @ContributesAndroidInjector - abstract fun bindTimetableFragment(): TimetableFragment - - @PerFragment - @ContributesAndroidInjector - abstract fun bindAboutFragment(): AboutFragment - - @PerFragment - @ContributesAndroidInjector - abstract fun bindSettingsFragment(): SettingsFragment - - @PerFragment - @ContributesAndroidInjector - abstract fun bindNoteFragment(): NoteFragment - - @PerFragment - @ContributesAndroidInjector - abstract fun bindHomeworkFragment(): HomeworkFragment - - @PerFragment - @ContributesAndroidInjector - abstract fun bindHomeworkDetailsDialog(): HomeworkDetailsDialog - - @PerFragment - @ContributesAndroidInjector - abstract fun bindLuckyNumberFragment(): LuckyNumberFragment - - @PerFragment - @ContributesAndroidInjector - abstract fun bindCompletedLessonsFragment(): CompletedLessonsFragment - - @PerFragment - @ContributesAndroidInjector - abstract fun bindAccountDialog(): AccountDialog - - @PerFragment - @ContributesAndroidInjector - abstract fun bindMobileDevices(): MobileDeviceFragment - - @PerFragment - @ContributesAndroidInjector - abstract fun bindMobileDeviceDialog(): MobileDeviceTokenDialog - - @PerFragment - @ContributesAndroidInjector(modules = [LicenseModule::class]) - abstract fun bindLicenseFragment(): LicenseFragment - - @PerFragment - @ContributesAndroidInjector - abstract fun bindLogViewerFragment(): LogViewerFragment - - @PerFragment - @ContributesAndroidInjector - abstract fun bindContributorFragment(): ContributorFragment - - @PerFragment - @ContributesAndroidInjector(modules = [SchoolAndTeachersModule::class]) - abstract fun bindSchoolAndTeachersFragment(): SchoolAndTeachersFragment -} diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/message/MessageFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/message/MessageFragment.kt index 1e48f71b5..16e0184a0 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/message/MessageFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/message/MessageFragment.kt @@ -4,6 +4,7 @@ import android.os.Bundle import android.view.View import android.view.View.INVISIBLE import android.view.View.VISIBLE +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.repositories.message.MessageFolder.RECEIVED import io.github.wulkanowy.data.repositories.message.MessageFolder.SENT @@ -18,14 +19,14 @@ import io.github.wulkanowy.utils.dpToPx import io.github.wulkanowy.utils.setOnSelectPageListener import javax.inject.Inject +@AndroidEntryPoint class MessageFragment : BaseFragment(R.layout.fragment_message), MessageView, MainView.TitledView { @Inject lateinit var presenter: MessagePresenter - @Inject - lateinit var pagerAdapter: BaseFragmentPagerAdapter + private val pagerAdapter by lazy { BaseFragmentPagerAdapter(childFragmentManager) } companion object { fun newInstance() = MessageFragment() diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/message/MessageModule.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/message/MessageModule.kt deleted file mode 100644 index bf7950209..000000000 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/message/MessageModule.kt +++ /dev/null @@ -1,25 +0,0 @@ -package io.github.wulkanowy.ui.modules.message - -import dagger.Module -import dagger.Provides -import dagger.android.ContributesAndroidInjector -import io.github.wulkanowy.di.scopes.PerChildFragment -import io.github.wulkanowy.di.scopes.PerFragment -import io.github.wulkanowy.ui.base.BaseFragmentPagerAdapter -import io.github.wulkanowy.ui.modules.message.tab.MessageTabFragment - -@Suppress("unused") -@Module -abstract class MessageModule { - - companion object { - - @PerFragment - @Provides - fun provideMessageAdapter(fragment: MessageFragment) = BaseFragmentPagerAdapter(fragment.childFragmentManager) - } - - @PerChildFragment - @ContributesAndroidInjector - abstract fun bindMessageTabFragment(): MessageTabFragment -} diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/message/preview/MessagePreviewFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/message/preview/MessagePreviewFragment.kt index e218d759c..740f4927c 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/message/preview/MessagePreviewFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/message/preview/MessagePreviewFragment.kt @@ -16,6 +16,7 @@ import android.webkit.WebViewClient import androidx.annotation.RequiresApi import androidx.core.content.getSystemService import androidx.recyclerview.widget.LinearLayoutManager +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.Message import io.github.wulkanowy.data.db.entities.MessageWithAttachment @@ -28,6 +29,7 @@ import io.github.wulkanowy.utils.AppInfo import io.github.wulkanowy.utils.shareText import javax.inject.Inject +@AndroidEntryPoint class MessagePreviewFragment : BaseFragment(R.layout.fragment_message_preview), MessagePreviewView, MainView.TitledView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/message/send/SendMessageActivity.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/message/send/SendMessageActivity.kt index 7b7503433..2267279c2 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/message/send/SendMessageActivity.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/message/send/SendMessageActivity.kt @@ -11,6 +11,7 @@ import android.view.View.GONE import android.view.View.VISIBLE import android.widget.Toast import android.widget.Toast.LENGTH_LONG +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.Message import io.github.wulkanowy.data.db.entities.ReportingUnit @@ -21,6 +22,7 @@ import io.github.wulkanowy.utils.hideSoftInput import io.github.wulkanowy.utils.showSoftInput import javax.inject.Inject +@AndroidEntryPoint class SendMessageActivity : BaseActivity(), SendMessageView { @Inject @@ -62,7 +64,7 @@ class SendMessageActivity : BaseActivity(R.layout.fragment_message_tab), MessageTabView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/mobiledevice/MobileDeviceFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/mobiledevice/MobileDeviceFragment.kt index 6a3e5a441..8065e9b60 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/mobiledevice/MobileDeviceFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/mobiledevice/MobileDeviceFragment.kt @@ -7,6 +7,7 @@ import android.view.View.VISIBLE import androidx.core.view.postDelayed import androidx.recyclerview.widget.LinearLayoutManager import com.google.android.material.snackbar.Snackbar +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.MobileDevice import io.github.wulkanowy.databinding.FragmentMobileDeviceBinding @@ -17,6 +18,7 @@ import io.github.wulkanowy.ui.modules.mobiledevice.token.MobileDeviceTokenDialog import io.github.wulkanowy.ui.widgets.DividerItemDecoration import javax.inject.Inject +@AndroidEntryPoint class MobileDeviceFragment : BaseFragment(R.layout.fragment_mobile_device), MobileDeviceView, MainView.TitledView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/mobiledevice/token/MobileDeviceTokenDialog.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/mobiledevice/token/MobileDeviceTokenDialog.kt index 9ac6049e9..48150d8de 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/mobiledevice/token/MobileDeviceTokenDialog.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/mobiledevice/token/MobileDeviceTokenDialog.kt @@ -12,12 +12,14 @@ import android.view.View.VISIBLE import android.view.ViewGroup import android.widget.Toast import androidx.core.content.getSystemService +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.pojos.MobileDeviceToken import io.github.wulkanowy.databinding.DialogMobileDeviceBinding import io.github.wulkanowy.ui.base.BaseDialogFragment import javax.inject.Inject +@AndroidEntryPoint class MobileDeviceTokenDialog : BaseDialogFragment(), MobileDeviceTokenVIew { @Inject diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/more/MoreFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/more/MoreFragment.kt index a79087de2..1bdcc26fa 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/more/MoreFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/more/MoreFragment.kt @@ -4,6 +4,7 @@ import android.graphics.drawable.Drawable import android.os.Bundle import android.view.View import androidx.recyclerview.widget.LinearLayoutManager +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.databinding.FragmentMoreBinding import io.github.wulkanowy.ui.base.BaseFragment @@ -20,6 +21,7 @@ import io.github.wulkanowy.ui.modules.settings.SettingsFragment import io.github.wulkanowy.utils.getCompatDrawable import javax.inject.Inject +@AndroidEntryPoint class MoreFragment : BaseFragment(R.layout.fragment_more), MoreView, MainView.TitledView, MainView.MainChildView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/note/NoteFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/note/NoteFragment.kt index 473381659..079285a80 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/note/NoteFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/note/NoteFragment.kt @@ -5,6 +5,7 @@ import android.view.View import android.view.View.GONE import android.view.View.VISIBLE import androidx.recyclerview.widget.LinearLayoutManager +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.Note import io.github.wulkanowy.databinding.FragmentNoteBinding @@ -14,6 +15,7 @@ import io.github.wulkanowy.ui.modules.main.MainView import io.github.wulkanowy.ui.widgets.DividerItemDecoration import javax.inject.Inject +@AndroidEntryPoint class NoteFragment : BaseFragment(R.layout.fragment_note), NoteView, MainView.TitledView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/schoolandteachers/SchoolAndTeachersFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/schoolandteachers/SchoolAndTeachersFragment.kt index 0245aa076..c1c569611 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/schoolandteachers/SchoolAndTeachersFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/schoolandteachers/SchoolAndTeachersFragment.kt @@ -4,6 +4,7 @@ import android.os.Bundle import android.view.View import android.view.View.INVISIBLE import android.view.View.VISIBLE +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.databinding.FragmentSchoolandteachersBinding import io.github.wulkanowy.ui.base.BaseFragment @@ -15,6 +16,7 @@ import io.github.wulkanowy.utils.dpToPx import io.github.wulkanowy.utils.setOnSelectPageListener import javax.inject.Inject +@AndroidEntryPoint class SchoolAndTeachersFragment : BaseFragment(R.layout.fragment_schoolandteachers), SchoolAndTeachersView, MainView.TitledView { @@ -22,8 +24,7 @@ class SchoolAndTeachersFragment : @Inject lateinit var presenter: SchoolAndTeachersPresenter - @Inject - lateinit var pagerAdapter: BaseFragmentPagerAdapter + private val pagerAdapter by lazy { BaseFragmentPagerAdapter(childFragmentManager) } companion object { fun newInstance() = SchoolAndTeachersFragment() diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/schoolandteachers/SchoolAndTeachersModule.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/schoolandteachers/SchoolAndTeachersModule.kt deleted file mode 100644 index 2087b0b42..000000000 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/schoolandteachers/SchoolAndTeachersModule.kt +++ /dev/null @@ -1,30 +0,0 @@ -package io.github.wulkanowy.ui.modules.schoolandteachers - -import dagger.Module -import dagger.Provides -import dagger.android.ContributesAndroidInjector -import io.github.wulkanowy.di.scopes.PerChildFragment -import io.github.wulkanowy.di.scopes.PerFragment -import io.github.wulkanowy.ui.base.BaseFragmentPagerAdapter -import io.github.wulkanowy.ui.modules.schoolandteachers.school.SchoolFragment -import io.github.wulkanowy.ui.modules.schoolandteachers.teacher.TeacherFragment - -@Suppress("unused") -@Module -abstract class SchoolAndTeachersModule { - - companion object { - - @PerFragment - @Provides - fun provideSchoolAndTeachersAdapter(fragment: SchoolAndTeachersFragment) = BaseFragmentPagerAdapter(fragment.childFragmentManager) - } - - @PerChildFragment - @ContributesAndroidInjector - abstract fun provideSchoolFragment(): SchoolFragment - - @PerChildFragment - @ContributesAndroidInjector - abstract fun provideTeacherFragment(): TeacherFragment -} diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/schoolandteachers/school/SchoolFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/schoolandteachers/school/SchoolFragment.kt index 722999f86..d3f110073 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/schoolandteachers/school/SchoolFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/schoolandteachers/school/SchoolFragment.kt @@ -4,6 +4,7 @@ import android.os.Bundle import android.view.View import android.view.View.GONE import android.view.View.VISIBLE +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.School import io.github.wulkanowy.databinding.FragmentSchoolBinding @@ -15,6 +16,7 @@ import io.github.wulkanowy.utils.openDialer import io.github.wulkanowy.utils.openNavigation import javax.inject.Inject +@AndroidEntryPoint class SchoolFragment : BaseFragment(R.layout.fragment_school), SchoolView, MainView.TitledView, SchoolAndTeachersChildView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/schoolandteachers/teacher/TeacherFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/schoolandteachers/teacher/TeacherFragment.kt index aa50339c1..5914945b9 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/schoolandteachers/teacher/TeacherFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/schoolandteachers/teacher/TeacherFragment.kt @@ -5,6 +5,7 @@ import android.view.View import android.view.View.GONE import android.view.View.VISIBLE import androidx.recyclerview.widget.LinearLayoutManager +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.Teacher import io.github.wulkanowy.databinding.FragmentTeacherBinding @@ -15,6 +16,7 @@ import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersFragmen import io.github.wulkanowy.ui.widgets.DividerItemDecoration import javax.inject.Inject +@AndroidEntryPoint class TeacherFragment : BaseFragment(R.layout.fragment_teacher), TeacherView, MainView.TitledView, SchoolAndTeachersChildView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/settings/SettingsFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/settings/SettingsFragment.kt index 248417fd1..a8a15cec5 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/settings/SettingsFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/settings/SettingsFragment.kt @@ -9,7 +9,7 @@ import androidx.preference.PreferenceFragmentCompat import com.thelittlefireman.appkillermanager.AppKillerManager import com.thelittlefireman.appkillermanager.exceptions.NoActionFoundException import com.yariksoffice.lingver.Lingver -import dagger.android.support.AndroidSupportInjection +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.ui.base.BaseActivity import io.github.wulkanowy.ui.base.ErrorDialog @@ -18,6 +18,7 @@ import io.github.wulkanowy.utils.AppInfo import io.github.wulkanowy.utils.openInternetBrowser import javax.inject.Inject +@AndroidEntryPoint class SettingsFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedPreferenceChangeListener, MainView.TitledView, SettingsView { @@ -42,7 +43,6 @@ class SettingsFragment : PreferenceFragmentCompat(), override val syncFailedString get() = getString(R.string.pref_services_message_sync_failed) override fun onAttach(context: Context) { - AndroidSupportInjection.inject(this) super.onAttach(context) } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashActivity.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashActivity.kt index 23a437506..7fc20d238 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashActivity.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashActivity.kt @@ -4,11 +4,13 @@ import android.os.Bundle import android.widget.Toast import android.widget.Toast.LENGTH_LONG import androidx.viewbinding.ViewBinding +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.ui.base.BaseActivity import io.github.wulkanowy.ui.modules.login.LoginActivity import io.github.wulkanowy.ui.modules.main.MainActivity import javax.inject.Inject +@AndroidEntryPoint class SplashActivity : BaseActivity(), SplashView { @Inject diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetableFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetableFragment.kt index c2be76ea7..2c5e136dd 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetableFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetableFragment.kt @@ -9,6 +9,7 @@ import android.view.View.GONE import android.view.View.VISIBLE import androidx.recyclerview.widget.LinearLayoutManager import com.wdullaer.materialdatetimepicker.date.DatePickerDialog +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.Timetable import io.github.wulkanowy.databinding.FragmentTimetableBinding @@ -22,6 +23,7 @@ import io.github.wulkanowy.utils.dpToPx import java.time.LocalDate import javax.inject.Inject +@AndroidEntryPoint class TimetableFragment : BaseFragment(R.layout.fragment_timetable), TimetableView, MainView.MainChildView, MainView.TitledView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/completed/CompletedLessonsFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/completed/CompletedLessonsFragment.kt index 5a41f96c5..5b77fc1f3 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/completed/CompletedLessonsFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/completed/CompletedLessonsFragment.kt @@ -7,6 +7,7 @@ import android.view.View.INVISIBLE import android.view.View.VISIBLE import androidx.recyclerview.widget.LinearLayoutManager import com.wdullaer.materialdatetimepicker.date.DatePickerDialog +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.CompletedLesson import io.github.wulkanowy.databinding.FragmentTimetableCompletedBinding @@ -20,6 +21,7 @@ import io.github.wulkanowy.utils.getCompatDrawable import java.time.LocalDate import javax.inject.Inject +@AndroidEntryPoint class CompletedLessonsFragment : BaseFragment(R.layout.fragment_timetable_completed), CompletedLessonsView, MainView.TitledView { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/timetablewidget/TimetableWidgetConfigureActivity.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/timetablewidget/TimetableWidgetConfigureActivity.kt index 3dc7a3a8c..23d1f27ab 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/timetablewidget/TimetableWidgetConfigureActivity.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/timetablewidget/TimetableWidgetConfigureActivity.kt @@ -10,6 +10,7 @@ import android.widget.Toast import android.widget.Toast.LENGTH_LONG import androidx.appcompat.app.AlertDialog import androidx.recyclerview.widget.LinearLayoutManager +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.Student import io.github.wulkanowy.databinding.ActivityWidgetConfigureBinding @@ -20,6 +21,7 @@ import io.github.wulkanowy.ui.modules.timetablewidget.TimetableWidgetProvider.Co import io.github.wulkanowy.utils.AppInfo import javax.inject.Inject +@AndroidEntryPoint class TimetableWidgetConfigureActivity : BaseActivity(), TimetableWidgetConfigureView { @@ -35,7 +37,7 @@ class TimetableWidgetConfigureActivity : private var dialog: AlertDialog? = null - override fun onCreate(savedInstanceState: Bundle?) { + override public fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setResult(RESULT_CANCELED) setContentView(ActivityWidgetConfigureBinding.inflate(layoutInflater).apply { binding = this }.root) diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/timetablewidget/TimetableWidgetProvider.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/timetablewidget/TimetableWidgetProvider.kt index 426f6cdd7..8b3709a8e 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/timetablewidget/TimetableWidgetProvider.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/timetablewidget/TimetableWidgetProvider.kt @@ -8,19 +8,19 @@ import android.appwidget.AppWidgetManager.ACTION_APPWIDGET_DELETED import android.appwidget.AppWidgetManager.ACTION_APPWIDGET_UPDATE import android.appwidget.AppWidgetManager.EXTRA_APPWIDGET_ID import android.appwidget.AppWidgetManager.EXTRA_APPWIDGET_IDS -import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK import android.content.Intent.FLAG_ACTIVITY_NEW_TASK import android.content.res.Configuration import android.widget.RemoteViews -import dagger.android.AndroidInjection +import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.R import io.github.wulkanowy.data.db.SharedPrefProvider import io.github.wulkanowy.data.db.entities.Student import io.github.wulkanowy.data.exceptions.NoCurrentStudentException import io.github.wulkanowy.data.repositories.student.StudentRepository +import io.github.wulkanowy.services.HiltBroadcastReceiver import io.github.wulkanowy.services.widgets.TimetableWidgetService import io.github.wulkanowy.ui.modules.main.MainActivity import io.github.wulkanowy.ui.modules.main.MainView @@ -36,7 +36,8 @@ import java.time.LocalDate import java.time.LocalDate.now import javax.inject.Inject -class TimetableWidgetProvider : BroadcastReceiver() { +@AndroidEntryPoint +class TimetableWidgetProvider : HiltBroadcastReceiver() { @Inject lateinit var appWidgetManager: AppWidgetManager @@ -74,7 +75,7 @@ class TimetableWidgetProvider : BroadcastReceiver() { } override fun onReceive(context: Context, intent: Intent) { - AndroidInjection.inject(this, context) + super.onReceive(context, intent) GlobalScope.launch { when (intent.action) { ACTION_APPWIDGET_UPDATE -> onUpdate(context, intent) diff --git a/app/src/main/java/io/github/wulkanowy/utils/AppInfo.kt b/app/src/main/java/io/github/wulkanowy/utils/AppInfo.kt index 6912baa36..1098a9a06 100644 --- a/app/src/main/java/io/github/wulkanowy/utils/AppInfo.kt +++ b/app/src/main/java/io/github/wulkanowy/utils/AppInfo.kt @@ -7,10 +7,11 @@ import android.os.Build.VERSION.SDK_INT import io.github.wulkanowy.BuildConfig.DEBUG import io.github.wulkanowy.BuildConfig.VERSION_CODE import io.github.wulkanowy.BuildConfig.VERSION_NAME +import javax.inject.Inject import javax.inject.Singleton @Singleton -open class AppInfo { +open class AppInfo @Inject constructor() { open val isDebug get() = DEBUG diff --git a/app/src/play/java/io/github/wulkanowy/utils/FirebaseAnalyticsHelper.kt b/app/src/play/java/io/github/wulkanowy/utils/FirebaseAnalyticsHelper.kt index b0b2fda4d..f7e4a0fc0 100644 --- a/app/src/play/java/io/github/wulkanowy/utils/FirebaseAnalyticsHelper.kt +++ b/app/src/play/java/io/github/wulkanowy/utils/FirebaseAnalyticsHelper.kt @@ -4,11 +4,14 @@ import android.app.Activity import android.content.Context import android.os.Bundle import com.google.firebase.analytics.FirebaseAnalytics +import dagger.hilt.android.qualifiers.ApplicationContext import javax.inject.Inject import javax.inject.Singleton @Singleton -class FirebaseAnalyticsHelper @Inject constructor(private val context: Context) { +class FirebaseAnalyticsHelper @Inject constructor( + @ApplicationContext private val context: Context +) { private val analytics by lazy { FirebaseAnalytics.getInstance(context) } diff --git a/build.gradle b/build.gradle index 164e258af..cc66780fd 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,9 @@ buildscript { - ext.kotlin_version = '1.3.72' - ext.about_libraries = '8.3.0' + ext { + kotlin_version = '1.3.72' + about_libraries = '8.3.0' + hilt_version = "2.28.3-alpha" + } repositories { mavenCentral() google() @@ -10,12 +13,13 @@ buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.android.tools.build:gradle:4.0.1' + classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version" classpath 'com.google.gms:google-services:4.3.3' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0' classpath "com.github.triplet.gradle:play-publisher:2.7.5" classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.0" classpath "gradle.plugin.com.star-zero.gradle:githook:1.2.0" - classpath "com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:${about_libraries}" + classpath "com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:$about_libraries" } }