diff --git a/.bettercodehub.yml b/.bettercodehub.yml index cce850d71..349f7675a 100644 --- a/.bettercodehub.yml +++ b/.bettercodehub.yml @@ -1,5 +1,3 @@ -exclude: -- /app/src/main/java/io/github/wulkanowy/data/db/dao/entities/.* -component_depth: 1 +component_depth: 8 languages: -- java +- kotlin diff --git a/app/src/main/java/io/github/wulkanowy/WulkanowyApp.kt b/app/src/main/java/io/github/wulkanowy/WulkanowyApp.kt index b7d7c4897..238b11246 100644 --- a/app/src/main/java/io/github/wulkanowy/WulkanowyApp.kt +++ b/app/src/main/java/io/github/wulkanowy/WulkanowyApp.kt @@ -1,6 +1,7 @@ package io.github.wulkanowy import android.content.Context +import androidx.appcompat.app.AppCompatDelegate import androidx.multidex.MultiDex import com.akaita.java.rxjava2debug.RxJava2Debug import com.crashlytics.android.Crashlytics @@ -13,13 +14,18 @@ import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.utils.Log import io.fabric.sdk.android.Fabric import io.github.wulkanowy.BuildConfig.DEBUG +import io.github.wulkanowy.data.repositories.PreferencesRepository import io.github.wulkanowy.di.DaggerAppComponent import io.github.wulkanowy.utils.CrashlyticsTree import io.github.wulkanowy.utils.DebugLogTree import timber.log.Timber +import javax.inject.Inject class WulkanowyApp : DaggerApplication() { + @Inject + lateinit var prefRepository: PreferencesRepository + override fun attachBaseContext(base: Context?) { super.attachBaseContext(base) MultiDex.install(this) @@ -31,6 +37,7 @@ class WulkanowyApp : DaggerApplication() { initializeFabric() if (DEBUG) enableDebugLog() RxJava2Debug.enableRxJava2AssemblyTracking(arrayOf(BuildConfig.APPLICATION_ID)) + AppCompatDelegate.setDefaultNightMode(prefRepository.currentTheme) } private fun enableDebugLog() { 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 0b6e86bb0..223d7abe6 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 @@ -1,12 +1,10 @@ package io.github.wulkanowy.ui.modules.splash import android.os.Bundle -import io.github.wulkanowy.services.notification.GradeNotification 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 -import androidx.appcompat.app.AppCompatDelegate class SplashActivity : BaseActivity(), SplashView { @@ -28,10 +26,6 @@ class SplashActivity : BaseActivity(), SplashView { finish() } - override fun setCurrentThemeMode(mode: Int) { - AppCompatDelegate.setDefaultNightMode(mode) - } - override fun onDestroy() { presenter.onDetachView() super.onDestroy() diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashPresenter.kt index d9dd9b9e7..9de0b1ff7 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashPresenter.kt @@ -1,7 +1,6 @@ package io.github.wulkanowy.ui.modules.splash import io.github.wulkanowy.data.ErrorHandler -import io.github.wulkanowy.data.repositories.PreferencesRepository import io.github.wulkanowy.data.repositories.SessionRepository import io.github.wulkanowy.ui.base.BasePresenter import io.github.wulkanowy.utils.logLogin @@ -9,14 +8,12 @@ import javax.inject.Inject class SplashPresenter @Inject constructor( private val sessionRepository: SessionRepository, - private val preferencesRepository: PreferencesRepository, errorHandler: ErrorHandler ) : BasePresenter(errorHandler) { override fun onAttachView(view: SplashView) { super.onAttachView(view) view.run { - setCurrentThemeMode(preferencesRepository.currentTheme) if (sessionRepository.isSessionSaved) { logLogin("Open app") openMainView() diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashView.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashView.kt index 0a68c4e48..9efd8123b 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashView.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashView.kt @@ -7,6 +7,4 @@ interface SplashView : BaseView { fun openLoginView() fun openMainView() - - fun setCurrentThemeMode(mode: Int) } diff --git a/app/src/test/java/io/github/wulkanowy/ui/modules/splash/SplashPresenterTest.kt b/app/src/test/java/io/github/wulkanowy/ui/modules/splash/SplashPresenterTest.kt index 7a87fc826..529c0a2a5 100644 --- a/app/src/test/java/io/github/wulkanowy/ui/modules/splash/SplashPresenterTest.kt +++ b/app/src/test/java/io/github/wulkanowy/ui/modules/splash/SplashPresenterTest.kt @@ -1,7 +1,6 @@ package io.github.wulkanowy.ui.modules.splash import io.github.wulkanowy.data.ErrorHandler -import io.github.wulkanowy.data.repositories.PreferencesRepository import io.github.wulkanowy.data.repositories.SessionRepository import org.junit.Before import org.junit.Test @@ -21,15 +20,12 @@ class SplashPresenterTest { @Mock lateinit var errorHandler: ErrorHandler - @Mock - lateinit var preferencesRepository: PreferencesRepository - private lateinit var presenter: SplashPresenter @Before fun initPresenter() { MockitoAnnotations.initMocks(this) - presenter = SplashPresenter(sessionRepository, preferencesRepository, errorHandler) + presenter = SplashPresenter(sessionRepository, errorHandler) } @Test