Address overridePendingTransition deprecation (#410)

This function is deprecated starting with API 34 "UpsideDownCake" and
should be replaced with `overrideActivityTransition`.
This commit is contained in:
MajorTanya
2024-02-17 16:26:47 +01:00
committed by GitHub
parent 1b0bbb8440
commit 840b647b4b
3 changed files with 51 additions and 5 deletions
@@ -1,8 +1,10 @@
package eu.kanade.tachiyomi.ui.webview
import android.app.Activity
import android.app.assist.AssistContent
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.widget.Toast
import androidx.core.net.toUri
@@ -35,7 +37,16 @@ class WebViewActivity : BaseActivity() {
}
override fun onCreate(savedInstanceState: Bundle?) {
overridePendingTransition(R.anim.shared_axis_x_push_enter, R.anim.shared_axis_x_push_exit)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
overrideActivityTransition(
Activity.OVERRIDE_TRANSITION_OPEN,
R.anim.shared_axis_x_push_enter,
R.anim.shared_axis_x_push_exit,
)
} else {
@Suppress("DEPRECATION")
overridePendingTransition(R.anim.shared_axis_x_push_enter, R.anim.shared_axis_x_push_exit)
}
super.onCreate(savedInstanceState)
if (!WebViewUtil.supportsWebView(this)) {
@@ -77,7 +88,16 @@ class WebViewActivity : BaseActivity() {
override fun finish() {
super.finish()
overridePendingTransition(R.anim.shared_axis_x_pop_enter, R.anim.shared_axis_x_pop_exit)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
overrideActivityTransition(
Activity.OVERRIDE_TRANSITION_CLOSE,
R.anim.shared_axis_x_pop_enter,
R.anim.shared_axis_x_pop_exit,
)
} else {
@Suppress("DEPRECATION")
overridePendingTransition(R.anim.shared_axis_x_pop_enter, R.anim.shared_axis_x_pop_exit)
}
}
private fun shareWebpage(url: String) {