diff --git a/app/src/main/java/io/legado/app/lib/permission/PermissionActivity.kt b/app/src/main/java/io/legado/app/lib/permission/PermissionActivity.kt index a054fe8be480..f010b30c8167 100644 --- a/app/src/main/java/io/legado/app/lib/permission/PermissionActivity.kt +++ b/app/src/main/java/io/legado/app/lib/permission/PermissionActivity.kt @@ -103,11 +103,13 @@ class PermissionActivity : AppCompatActivity() { override fun startActivity(intent: Intent) { super.startActivity(intent) + @Suppress("DEPRECATION") overridePendingTransition(0, 0) } override fun finish() { super.finish() + @Suppress("DEPRECATION") overridePendingTransition(0, 0) } diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceDialog.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceDialog.kt index 5c1d38f39261..a910d47477aa 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceDialog.kt @@ -5,6 +5,7 @@ import android.view.Menu import android.view.MenuItem import android.view.View import android.view.ViewGroup +import android.widget.ImageButton import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.Toolbar import androidx.core.os.bundleOf @@ -26,16 +27,19 @@ import io.legado.app.data.entities.SearchBook import io.legado.app.databinding.DialogBookChangeSourceBinding import io.legado.app.help.config.AppConfig import io.legado.app.lib.dialogs.alert +import io.legado.app.lib.theme.getPrimaryTextColor import io.legado.app.lib.theme.primaryColor import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.ui.book.source.edit.BookSourceEditActivity import io.legado.app.ui.book.source.manage.BookSourceActivity import io.legado.app.ui.widget.dialog.WaitDialog import io.legado.app.ui.widget.recycler.VerticalDivider +import io.legado.app.utils.ColorUtils import io.legado.app.utils.StartActivityContract import io.legado.app.utils.applyTint import io.legado.app.utils.cnCompare import io.legado.app.utils.dpToPx +import io.legado.app.utils.getCompatDrawable import io.legado.app.utils.observeEvent import io.legado.app.utils.setLayout import io.legado.app.utils.startActivity @@ -95,18 +99,12 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_ } override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { - context?.obtainStyledAttributes(intArrayOf(android.R.attr.homeAsUpIndicator))?.use { - binding.toolBar.navigationIcon = it.getDrawable(0) - binding.toolBar.setNavigationContentDescription(androidx.appcompat.R.string.abc_action_bar_up_description) - binding.toolBar.setNavigationOnClickListener { - dismissAllowingStateLoss() - } - } binding.toolBar.setBackgroundColor(primaryColor) viewModel.initData(arguments, callBack?.oldBook, activity is ReadBookActivity) showTitle() initMenu() initRecyclerView() + initNavigationView() initSearchView() initBottomBar() initLiveData() @@ -116,9 +114,8 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_ private fun showTitle() { binding.toolBar.title = viewModel.name binding.toolBar.subtitle = viewModel.author - context?.obtainStyledAttributes(intArrayOf(android.R.attr.homeAsUpIndicator))?.use { - binding.toolBar.navigationIcon = it.getDrawable(0) - } + binding.toolBar.navigationIcon = + getCompatDrawable(androidx.appcompat.R.drawable.abc_ic_ab_back_material) } private fun initMenu() { @@ -177,6 +174,23 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_ }) } + private fun initNavigationView() { + binding.toolBar.navigationIcon = + getCompatDrawable(androidx.appcompat.R.drawable.abc_ic_ab_back_material) + binding.toolBar.setNavigationContentDescription(androidx.appcompat.R.string.abc_action_bar_up_description) + binding.toolBar.setNavigationOnClickListener { + dismissAllowingStateLoss() + } + kotlin.runCatching { + val mNavButtonViewField = Toolbar::class.java.getDeclaredField("mNavButtonView") + mNavButtonViewField.isAccessible = true + val navigationView = mNavButtonViewField.get(binding.toolBar) as ImageButton + val isLight = ColorUtils.isColorLight(primaryColor) + val textColor = requireContext().getPrimaryTextColor(isLight) + navigationView.setColorFilter(textColor) + } + } + private fun initBottomBar() { binding.tvDur.text = callBack?.oldBook?.originName binding.tvDur.setOnClickListener { diff --git a/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt b/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt index a81a7b3bfedc..231cb3a9ad2d 100644 --- a/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt +++ b/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt @@ -33,6 +33,7 @@ class ConfigActivity : VMBaseActivity() inline fun replaceFragment(configTag: String) { intent.putExtra("configTag", configTag) + @Suppress("DEPRECATION") val configFragment = supportFragmentManager.findFragmentByTag(configTag) ?: T::class.java.newInstance() supportFragmentManager.beginTransaction() diff --git a/app/src/main/java/io/legado/app/utils/ActivityExtensions.kt b/app/src/main/java/io/legado/app/utils/ActivityExtensions.kt index cb43c35494fb..b0bf24be9117 100644 --- a/app/src/main/java/io/legado/app/utils/ActivityExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ActivityExtensions.kt @@ -16,6 +16,7 @@ import io.legado.app.R inline fun AppCompatActivity.showDialogFragment( arguments: Bundle.() -> Unit = {} ) { + @Suppress("DEPRECATION") val dialog = T::class.java.newInstance() val bundle = Bundle() bundle.apply(arguments) diff --git a/app/src/main/java/io/legado/app/utils/FragmentExtensions.kt b/app/src/main/java/io/legado/app/utils/FragmentExtensions.kt index 691fa833dc65..994a80c408e0 100644 --- a/app/src/main/java/io/legado/app/utils/FragmentExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/FragmentExtensions.kt @@ -16,6 +16,7 @@ import androidx.fragment.app.Fragment inline fun Fragment.showDialogFragment( arguments: Bundle.() -> Unit = {} ) { + @Suppress("DEPRECATION") val dialog = T::class.java.newInstance() val bundle = Bundle() bundle.apply(arguments)