Przeglądaj źródła

Apply theme to OAuth login redirect activities

arkon 4 lat temu
rodzic
commit
6d403851cf

+ 1 - 24
app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt → 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<VB : ViewBinding> : 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<VB : ViewBinding> : AppCompatActivity() {
         }
     }
 
-    init {
-        @Suppress("LeakingThis")
-        LocaleHelper.updateConfiguration(this)
-    }
-
     override fun onCreate(savedInstanceState: Bundle?) {
         setTheme(
             when {
@@ -76,13 +61,5 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
         )
 
         super.onCreate(savedInstanceState)
-
-        secureActivityDelegate.onCreate()
-    }
-
-    override fun onResume() {
-        super.onResume()
-
-        secureActivityDelegate.onResume()
     }
 }

+ 33 - 0
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<VB : ViewBinding> : 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()
+    }
+}

+ 2 - 2
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<MainActivityBinding>() {
+class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
 
     private lateinit var router: Router
 

+ 4 - 4
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(

+ 2 - 2
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<WebviewActivityBinding>() {
+open class BaseWebViewActivity : BaseViewBindingActivity<WebviewActivityBinding>() {
 
     internal var bundle: Bundle? = null