|
|
|
@@ -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 {
|
|
|
|
|