diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseThemedActivity.kt similarity index 76% rename from app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseThemedActivity.kt index fabb20102d..afd4d10285 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseThemedActivity.kt @@ -4,25 +4,15 @@ import android.content.res.Configuration import android.os.Build import android.os.Bundle import androidx.appcompat.app.AppCompatActivity -import androidx.lifecycle.lifecycleScope -import androidx.viewbinding.ViewBinding import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferencesHelper -import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate -import eu.kanade.tachiyomi.util.system.LocaleHelper import uy.kohesive.injekt.injectLazy import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values -abstract class BaseActivity : AppCompatActivity() { +abstract class BaseThemedActivity : AppCompatActivity() { val preferences: PreferencesHelper by injectLazy() - val scope = lifecycleScope - lateinit var binding: VB - - @Suppress("LeakingThis") - private val secureActivityDelegate = SecureActivityDelegate(this) - private val isDarkMode: Boolean by lazy { val themeMode = preferences.themeMode().get() (themeMode == Values.ThemeMode.dark) || @@ -62,11 +52,6 @@ abstract class BaseActivity : AppCompatActivity() { } } - init { - @Suppress("LeakingThis") - LocaleHelper.updateConfiguration(this) - } - override fun onCreate(savedInstanceState: Bundle?) { setTheme( when { @@ -76,13 +61,5 @@ abstract class BaseActivity : AppCompatActivity() { ) super.onCreate(savedInstanceState) - - secureActivityDelegate.onCreate() - } - - override fun onResume() { - super.onResume() - - secureActivityDelegate.onResume() } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseViewBindingActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseViewBindingActivity.kt new file mode 100644 index 0000000000..aa34eaea96 --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseViewBindingActivity.kt @@ -0,0 +1,33 @@ +package eu.kanade.tachiyomi.ui.base.activity + +import android.os.Bundle +import androidx.lifecycle.lifecycleScope +import androidx.viewbinding.ViewBinding +import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate +import eu.kanade.tachiyomi.util.system.LocaleHelper + +abstract class BaseViewBindingActivity : BaseThemedActivity() { + + val scope = lifecycleScope + lateinit var binding: VB + + @Suppress("LeakingThis") + private val secureActivityDelegate = SecureActivityDelegate(this) + + init { + @Suppress("LeakingThis") + LocaleHelper.updateConfiguration(this) + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + secureActivityDelegate.onCreate() + } + + override fun onResume() { + super.onResume() + + secureActivityDelegate.onResume() + } +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index 2976879dfd..e9f96b40c1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -24,7 +24,7 @@ import eu.kanade.tachiyomi.data.notification.NotificationReceiver import eu.kanade.tachiyomi.data.preference.asImmediateFlow import eu.kanade.tachiyomi.databinding.MainActivityBinding import eu.kanade.tachiyomi.extension.api.ExtensionGithubApi -import eu.kanade.tachiyomi.ui.base.activity.BaseActivity +import eu.kanade.tachiyomi.ui.base.activity.BaseViewBindingActivity import eu.kanade.tachiyomi.ui.base.controller.DialogController import eu.kanade.tachiyomi.ui.base.controller.FabController import eu.kanade.tachiyomi.ui.base.controller.NoToolbarElevationController @@ -48,7 +48,7 @@ import timber.log.Timber import java.util.Date import java.util.concurrent.TimeUnit -class MainActivity : BaseActivity() { +class MainActivity : BaseViewBindingActivity() { private lateinit var router: Router diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/BaseOAuthLoginActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/BaseOAuthLoginActivity.kt index eb5fdec53e..06cee4de7e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/BaseOAuthLoginActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/track/BaseOAuthLoginActivity.kt @@ -7,19 +7,19 @@ import android.view.Gravity import android.view.ViewGroup import android.widget.FrameLayout import android.widget.ProgressBar -import androidx.appcompat.app.AppCompatActivity import eu.kanade.tachiyomi.data.track.TrackManager +import eu.kanade.tachiyomi.ui.base.activity.BaseThemedActivity import eu.kanade.tachiyomi.ui.main.MainActivity import uy.kohesive.injekt.injectLazy -abstract class BaseOAuthLoginActivity : AppCompatActivity() { +abstract class BaseOAuthLoginActivity : BaseThemedActivity() { internal val trackManager: TrackManager by injectLazy() abstract fun handleResult(data: Uri?) - override fun onCreate(savedState: Bundle?) { - super.onCreate(savedState) + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) val view = ProgressBar(this) setContentView( diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/BaseWebViewActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/webview/BaseWebViewActivity.kt index c8bbdceeb6..5068cdd1da 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/BaseWebViewActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/webview/BaseWebViewActivity.kt @@ -10,7 +10,7 @@ import androidx.core.view.isVisible import eu.kanade.tachiyomi.BuildConfig import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.databinding.WebviewActivityBinding -import eu.kanade.tachiyomi.ui.base.activity.BaseActivity +import eu.kanade.tachiyomi.ui.base.activity.BaseViewBindingActivity import eu.kanade.tachiyomi.util.system.WebViewUtil import eu.kanade.tachiyomi.util.system.setDefaultSettings import eu.kanade.tachiyomi.util.system.toast @@ -19,7 +19,7 @@ import kotlinx.coroutines.flow.onEach import reactivecircus.flowbinding.appcompat.navigationClicks import reactivecircus.flowbinding.swiperefreshlayout.refreshes -open class BaseWebViewActivity : BaseActivity() { +open class BaseWebViewActivity : BaseViewBindingActivity() { internal var bundle: Bundle? = null