更新界面
This commit is contained in:
@@ -69,6 +69,7 @@ class App : Application() {
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
DynamicColors.applyToActivitiesIfAvailable(this)
|
||||
CrashHandler(this)
|
||||
if (isDebuggable) {
|
||||
ThreadUtils.setThreadAssertsDisabledForTesting(true)
|
||||
|
||||
@@ -14,6 +14,7 @@ import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import androidx.activity.addCallback
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.viewbinding.ViewBinding
|
||||
@@ -78,7 +79,7 @@ abstract class BaseActivity<VB : ViewBinding>(
|
||||
window.decorView.disableAutoFill()
|
||||
AppContextWrapper.applyLocaleAndFont(this)
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
enableEdgeToEdge()
|
||||
//setupSystemBar()
|
||||
setContentView(binding.root)
|
||||
upBackgroundImage()
|
||||
@@ -90,9 +91,9 @@ abstract class BaseActivity<VB : ViewBinding>(
|
||||
onActivityCreated(savedInstanceState)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
override fun onMultiWindowModeChanged(isInMultiWindowMode: Boolean, newConfig: Configuration) {
|
||||
super.onMultiWindowModeChanged(isInMultiWindowMode, newConfig)
|
||||
|
||||
// findViewById<TitleBar>(R.id.title_bar)
|
||||
// ?.onMultiWindowModeChanged(isInMultiWindowMode, fullScreen)
|
||||
//setupSystemBar()
|
||||
|
||||
@@ -37,10 +37,10 @@ abstract class BaseFragment(@LayoutRes layoutID: Int) : Fragment(layoutID) {
|
||||
onMultiWindowModeChanged()
|
||||
}
|
||||
|
||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
onMultiWindowModeChanged()
|
||||
}
|
||||
// override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
// super.onConfigurationChanged(newConfig)
|
||||
// onMultiWindowModeChanged()
|
||||
// }
|
||||
|
||||
private fun onMultiWindowModeChanged() {
|
||||
// (activity as? BaseActivity<*>)?.let {
|
||||
|
||||
@@ -37,6 +37,8 @@ object PreferKey {
|
||||
const val enableReview = "enableReview"
|
||||
const val showRss = "showRss"
|
||||
const val bookshelfLayout = "bookshelfLayout"
|
||||
const val bookshelfLayoutPortrait = "bookshelfLayoutPortrait"
|
||||
const val bookshelfLayoutLandscape = "bookshelf_layout_landscape"
|
||||
const val bookshelfSort = "bookshelfSort"
|
||||
const val bookExportFileName = "bookExportFileName"
|
||||
const val bookImportFileName = "bookImportFileName"
|
||||
|
||||
@@ -159,12 +159,19 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
appCtx.putPrefInt(PreferKey.bookGroupStyle, value)
|
||||
}
|
||||
|
||||
var bookshelfLayout: Int
|
||||
get() = appCtx.getPrefInt(PreferKey.bookshelfLayout, 0)
|
||||
var bookshelfLayoutPortrait: Int
|
||||
get() = appCtx.getPrefInt(PreferKey.bookshelfLayoutPortrait, 3)
|
||||
set(value) {
|
||||
appCtx.putPrefInt(PreferKey.bookshelfLayout, value)
|
||||
appCtx.putPrefInt(PreferKey.bookshelfLayoutPortrait, value)
|
||||
}
|
||||
|
||||
var bookshelfLayoutLandscape: Int
|
||||
get() = appCtx.getPrefInt(PreferKey.bookshelfLayoutLandscape, 5)
|
||||
set(value) {
|
||||
appCtx.putPrefInt(PreferKey.bookshelfLayoutLandscape, value)
|
||||
}
|
||||
|
||||
|
||||
var saveTabPosition: Int
|
||||
get() = appCtx.getPrefInt(PreferKey.saveTabPosition, 0)
|
||||
set(value) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import io.legato.kazusa.utils.isContentScheme
|
||||
import io.legato.kazusa.utils.isDataUrl
|
||||
import io.legato.kazusa.utils.lifecycle
|
||||
import java.io.File
|
||||
import androidx.core.net.toUri
|
||||
|
||||
//https://bumptech.github.io/glide/doc/generatedapi.html
|
||||
//Instead of GlideApp, use com.bumptech.Glide
|
||||
@@ -28,7 +29,7 @@ object ImageLoader {
|
||||
path.isNullOrEmpty() -> Glide.with(context).load(path)
|
||||
path.isDataUrl() -> Glide.with(context).load(path)
|
||||
path.isAbsUrl() -> Glide.with(context).load(path)
|
||||
path.isContentScheme() -> Glide.with(context).load(Uri.parse(path))
|
||||
path.isContentScheme() -> Glide.with(context).load(path.toUri())
|
||||
else -> kotlin.runCatching {
|
||||
Glide.with(context).load(File(path))
|
||||
}.getOrElse {
|
||||
|
||||
@@ -12,6 +12,7 @@ import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import io.legato.kazusa.R
|
||||
import io.legato.kazusa.constant.AppLog
|
||||
import io.legato.kazusa.exception.NoStackTraceException
|
||||
@@ -195,7 +196,7 @@ class PermissionActivity : AppCompatActivity() {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
rationaleDialog = AlertDialog.Builder(this)
|
||||
rationaleDialog = MaterialAlertDialogBuilder(this)
|
||||
.setTitle(R.string.dialog_title)
|
||||
.setMessage(rationale)
|
||||
.setPositiveButton(R.string.dialog_setting) { _, _ ->
|
||||
|
||||
@@ -22,18 +22,6 @@ private constructor(private val mContext: Context) : ThemeStoreInterface {
|
||||
|
||||
private val mEditor = prefs(mContext).edit()
|
||||
|
||||
// override fun enableDynamicColors(context: Context, enable: Boolean): ThemeStore {
|
||||
// mEditor.putBoolean(ThemeStorePrefKeys.KEY_DYNAMIC_COLORS_ENABLED, enable)
|
||||
// if (enable && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
// // 使用系统动态颜色
|
||||
// val dynamicColors = DynamicColorsOptions.Builder()
|
||||
// .setThemeOverlay(R.style.Theme_App_Dynamic)
|
||||
// .build()
|
||||
// DynamicColors.applyToActivitiesIfAvailable(context.applicationContext, dynamicColors)
|
||||
// }
|
||||
// return this
|
||||
// }
|
||||
|
||||
override fun primaryColor(@ColorInt color: Int): ThemeStore {
|
||||
mEditor.putInt(ThemeStorePrefKeys.KEY_PRIMARY_COLOR, color)
|
||||
if (autoGeneratePrimaryDark(mContext))
|
||||
|
||||
@@ -18,22 +18,6 @@ class ThemeBottomNavigationVIew(context: Context, attrs: AttributeSet) :
|
||||
BottomNavigationView(context, attrs) {
|
||||
|
||||
init {
|
||||
// val bgColor = context.bottomBackground
|
||||
// setBackgroundColor(bgColor)
|
||||
// val textIsDark = ColorUtils.isColorLight(bgColor)
|
||||
// val textColor = context.getSecondaryTextColor(textIsDark)
|
||||
//
|
||||
// val colorStateList = Selector.colorBuild()
|
||||
// .setDefaultColor(textColor)
|
||||
// .setSelectedColor(ThemeStore.accentColor(context)).create()
|
||||
// itemIconTintList = colorStateList
|
||||
// itemTextColor = colorStateList
|
||||
|
||||
if (AppConfig.isEInkMode) {
|
||||
isItemHorizontalTranslationEnabled = false
|
||||
itemBackground = Color.TRANSPARENT.toDrawable()
|
||||
}
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(this, null)
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ object BookCover {
|
||||
}.getOrDefault(appCtx.resources.getDrawable(R.drawable.image_cover_default, null))
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 加载封面
|
||||
*/
|
||||
@@ -127,6 +128,8 @@ object BookCover {
|
||||
.centerCrop()
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 加载漫画图片
|
||||
*/
|
||||
|
||||
@@ -63,7 +63,7 @@ class OpenUrlConfirmDialog() : BaseDialogFragment(R.layout.dialog_open_url_confi
|
||||
private fun initMenu() {
|
||||
binding.toolBar.setOnMenuItemClickListener(this)
|
||||
binding.toolBar.inflateMenu(R.menu.open_url_confirm)
|
||||
binding.toolBar.menu.applyTint(requireContext())
|
||||
//binding.toolBar.menu.applyTint(requireContext())
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
|
||||
@@ -79,7 +79,7 @@ class VerificationCodeDialog() : BaseDialogFragment(R.layout.dialog_verification
|
||||
private fun initMenu() {
|
||||
binding.toolBar.setOnMenuItemClickListener(this)
|
||||
binding.toolBar.inflateMenu(R.menu.verification_code)
|
||||
binding.toolBar.menu.applyTint(requireContext())
|
||||
//binding.toolBar.menu.applyTint(requireContext())
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
|
||||
@@ -40,14 +40,14 @@ class BookmarkDialog() : BaseBottomSheetDialogFragment(R.layout.dialog_bookmark)
|
||||
return
|
||||
}
|
||||
|
||||
//@Suppress("DEPRECATION")
|
||||
@Suppress("DEPRECATION")
|
||||
val bookmark = arguments.getParcelable<Bookmark>("bookmark")
|
||||
bookmark ?: let {
|
||||
dismiss()
|
||||
return
|
||||
}
|
||||
val editPos = arguments.getInt("editPos", -1)
|
||||
binding.btnDelete.visible(editPos >= 0) // 替换 tvFooterLeft
|
||||
binding.btnDelete.visible(editPos >= 0)
|
||||
|
||||
binding.run {
|
||||
tvChapterName.text = bookmark.chapterName
|
||||
|
||||
@@ -59,7 +59,7 @@ class ChangeCoverDialog() : BaseDialogFragment(R.layout.dialog_change_cover),
|
||||
|
||||
private fun initMenu() {
|
||||
binding.toolBar.inflateMenu(R.menu.change_cover)
|
||||
binding.toolBar.menu.applyTint(requireContext())
|
||||
//binding.toolBar.menu.applyTint(requireContext())
|
||||
binding.toolBar.setOnMenuItemClickListener(this)
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ class ChangeCoverDialog() : BaseDialogFragment(R.layout.dialog_change_cover),
|
||||
item.setTitle(R.string.refresh)
|
||||
}
|
||||
}
|
||||
binding.toolBar.menu.applyTint(requireContext())
|
||||
//binding.toolBar.menu.applyTint(requireContext())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -140,7 +140,7 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
|
||||
|
||||
private fun initMenu() {
|
||||
binding.toolBar.inflateMenu(R.menu.change_source)
|
||||
binding.toolBar.menu.applyTint(requireContext())
|
||||
//binding.toolBar.menu.applyTint(requireContext())
|
||||
binding.toolBar.setOnMenuItemClickListener(this)
|
||||
binding.toolBar.menu.findItem(R.id.menu_check_author)
|
||||
?.isChecked = AppConfig.changeSourceCheckAuthor
|
||||
|
||||
@@ -86,7 +86,7 @@ class GroupManageDialog : BaseBottomSheetDialogFragment(R.layout.dialog_recycler
|
||||
private fun initMenu() {
|
||||
binding.toolBar.setOnMenuItemClickListener(this)
|
||||
binding.toolBar.inflateMenu(R.menu.book_group_manage)
|
||||
binding.toolBar.menu.applyTint(requireContext())
|
||||
//binding.toolBar.menu.applyTint(requireContext())
|
||||
}
|
||||
|
||||
override fun onMenuItemClick(item: MenuItem?): Boolean {
|
||||
|
||||
@@ -66,7 +66,7 @@ class GroupSelectDialog() : BaseBottomSheetDialogFragment(R.layout.dialog_book_g
|
||||
private fun initView() {
|
||||
binding.toolBar.title = getString(R.string.group_select)
|
||||
binding.toolBar.inflateMenu(R.menu.book_group_manage)
|
||||
binding.toolBar.menu.applyTint(requireContext())
|
||||
//binding.toolBar.menu.applyTint(requireContext())
|
||||
binding.toolBar.setOnMenuItemClickListener(this)
|
||||
binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
|
||||
binding.recyclerView.addItemDecoration(VerticalDivider(requireContext()))
|
||||
|
||||
@@ -46,7 +46,7 @@ class ServerConfigDialog() : BaseDialogFragment(R.layout.dialog_webdav_server, t
|
||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
||||
//inding.toolBar.setBackgroundColor(primaryColor)
|
||||
binding.toolBar.inflateMenu(R.menu.server_config)
|
||||
binding.toolBar.menu.applyTint(requireContext())
|
||||
//binding.toolBar.menu.applyTint(requireContext())
|
||||
binding.toolBar.setOnMenuItemClickListener(this)
|
||||
viewModel.init(arguments?.getLong("id")) {
|
||||
upConfigView(viewModel.mServer)
|
||||
|
||||
@@ -2,19 +2,28 @@ package io.legato.kazusa.ui.book.info
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
import android.graphics.RenderEffect
|
||||
import android.graphics.Shader
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.widget.CheckBox
|
||||
import android.widget.LinearLayout
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.activity.viewModels
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.palette.graphics.Palette
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import com.google.android.material.color.utilities.Hct
|
||||
import com.google.android.material.color.utilities.SchemeTonalSpot
|
||||
import io.legato.kazusa.R
|
||||
import io.legato.kazusa.base.VMBaseActivity
|
||||
import io.legato.kazusa.constant.BookType
|
||||
@@ -75,6 +84,7 @@ import io.legato.kazusa.utils.startActivity
|
||||
import io.legato.kazusa.utils.toastOnUi
|
||||
import io.legato.kazusa.utils.viewbindingdelegate.viewBinding
|
||||
import io.legato.kazusa.utils.visible
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
@@ -161,12 +171,10 @@ class BookInfoActivity :
|
||||
// binding.llInfo.setBackgroundColor(backgroundColor)
|
||||
// binding.flAction.setBackgroundColor(bottomBackground)
|
||||
//binding.flAction.applyNavigationBarPadding()
|
||||
binding.btnShelf?.text = getString(R.string.remove_from_bookshelf)
|
||||
binding.btnShelf.text = getString(R.string.remove_from_bookshelf)
|
||||
binding.tvToc.text = getString(R.string.toc_s, getString(R.string.loading))
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
||||
binding.tvDetail?.let { it.revealOnFocusHint = false }
|
||||
}
|
||||
binding.tvDetail.revealOnFocusHint = false
|
||||
|
||||
viewModel.bookData.observe(this) { showBook(it) }
|
||||
viewModel.chapterListData.observe(this) { upLoading(false, it) }
|
||||
@@ -340,8 +348,8 @@ class BookInfoActivity :
|
||||
tvAuthor.text = getString(R.string.author_show, book.getRealAuthor())
|
||||
tvOrigin.text = getString(R.string.origin_show, book.originName)
|
||||
tvLasted.text = getString(R.string.lasted_show, book.latestChapterTitle)
|
||||
tvDetail?.let { it.text = book.getDisplayIntro() }
|
||||
llToc?.visible(!book.isWebFile)
|
||||
tvDetail.let { it.text = book.getDisplayIntro() }
|
||||
llToc.visible(!book.isWebFile)
|
||||
upTvBookshelf()
|
||||
upKinds(book)
|
||||
upGroup(book.group)
|
||||
@@ -412,10 +420,10 @@ class BookInfoActivity :
|
||||
}
|
||||
|
||||
private fun upTvBookshelf() {
|
||||
binding.btnShelf?.apply {
|
||||
binding.btnShelf.apply {
|
||||
if (viewModel.inBookshelf) {
|
||||
text = getString(R.string.remove_from_bookshelf)
|
||||
icon = ContextCompat.getDrawable(context, R.drawable.ic_clear_all)
|
||||
icon = ContextCompat.getDrawable(context, R.drawable.ic_star_fill)
|
||||
} else {
|
||||
text = getString(R.string.add_to_bookshelf)
|
||||
icon = ContextCompat.getDrawable(context, R.drawable.ic_star)
|
||||
@@ -427,13 +435,15 @@ class BookInfoActivity :
|
||||
private fun upGroup(groupId: Long) {
|
||||
viewModel.loadGroup(groupId) {
|
||||
if (it.isNullOrEmpty()) {
|
||||
binding.tvGroup.text = if (book?.isLocal == true) {
|
||||
getString(R.string.group_s, getString(R.string.local_no_group))
|
||||
binding.tvChangeGroup.text = if (book?.isLocal == true) {
|
||||
getString(R.string.local_no_group)
|
||||
} else {
|
||||
getString(R.string.group_s, getString(R.string.no_group))
|
||||
getString(R.string.no_group)
|
||||
}
|
||||
binding.tvChangeGroup.setIconResource(R.drawable.ic_groups)
|
||||
} else {
|
||||
binding.tvGroup.text = getString(R.string.group_s, it)
|
||||
binding.tvChangeGroup.text = getString(R.string.group_s, it)
|
||||
binding.tvChangeGroup.setIconResource(R.drawable.ic_groups_fill)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -452,7 +462,7 @@ class BookInfoActivity :
|
||||
}
|
||||
true
|
||||
}
|
||||
btnRead?.setOnClickListener {
|
||||
btnRead.setOnClickListener {
|
||||
viewModel.getBook()?.let { book ->
|
||||
if (book.isWebFile) {
|
||||
showWebFileDownloadAlert {
|
||||
@@ -463,7 +473,7 @@ class BookInfoActivity :
|
||||
}
|
||||
}
|
||||
}
|
||||
btnShelf?.setOnClickListener {
|
||||
btnShelf.setOnClickListener {
|
||||
viewModel.getBook()?.let { book ->
|
||||
if (viewModel.inBookshelf) {
|
||||
deleteBook()
|
||||
@@ -490,7 +500,7 @@ class BookInfoActivity :
|
||||
}
|
||||
}
|
||||
}
|
||||
btnChangeSource?.setOnClickListener {
|
||||
btnChangeSource.setOnClickListener {
|
||||
viewModel.getBook()?.let { book ->
|
||||
showDialogFragment(ChangeBookSourceDialog(book.name, book.author))
|
||||
}
|
||||
@@ -533,7 +543,7 @@ class BookInfoActivity :
|
||||
}
|
||||
}
|
||||
}
|
||||
refreshLayout?.setOnRefreshListener {
|
||||
refreshLayout.setOnRefreshListener {
|
||||
refreshLayout.isRefreshing = false
|
||||
refreshBook()
|
||||
}
|
||||
@@ -784,4 +794,16 @@ class BookInfoActivity :
|
||||
}
|
||||
}
|
||||
|
||||
// 扩展函数:从Drawable中提取主色调
|
||||
suspend fun Drawable.extractDominantColor(): Int = withContext(Dispatchers.Default) {
|
||||
// 将Drawable转换为Bitmap
|
||||
val bitmap = (this@extractDominantColor as? BitmapDrawable)?.bitmap ?: return@withContext Color.TRANSPARENT
|
||||
|
||||
// 生成Palette
|
||||
val palette = Palette.from(bitmap).generate()
|
||||
|
||||
// 返回主色调,若未找到则使用默认值
|
||||
palette.getDominantColor(Color.WHITE)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -101,7 +101,7 @@ class SourcePickerDialog : BaseDialogFragment(R.layout.dialog_source_picker),
|
||||
private fun initMenu() {
|
||||
toolBar.setOnMenuItemClickListener(this)
|
||||
toolBar.inflateMenu(R.menu.source_picker)
|
||||
toolBar.menu.applyTint(requireContext())
|
||||
//toolBar.menu.applyTint(requireContext())
|
||||
}
|
||||
|
||||
override fun onMenuItemClick(item: MenuItem?): Boolean {
|
||||
|
||||
@@ -121,9 +121,9 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, ReadMangaViewMode
|
||||
|
||||
private val loadMoreView by lazy {
|
||||
LoadMoreView(this).apply {
|
||||
setBackgroundColor(getCompatColor(R.color.book_ant_10))
|
||||
setLoadingColor(R.color.white)
|
||||
setLoadingTextColor(R.color.white)
|
||||
// setBackgroundColor(getCompatColor(R.color.book_ant_10))
|
||||
// setLoadingColor(R.color.white)
|
||||
// setLoadingTextColor(R.color.white)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ class ContentEditDialog : BaseDialogFragment(R.layout.dialog_content_edit) {
|
||||
|
||||
private fun initMenu() {
|
||||
binding.toolBar.inflateMenu(R.menu.content_edit)
|
||||
binding.toolBar.menu.applyTint(requireContext())
|
||||
//binding.toolBar.menu.applyTint(requireContext())
|
||||
binding.toolBar.setOnMenuItemClickListener {
|
||||
when (it.itemId) {
|
||||
R.id.menu_save -> {
|
||||
|
||||
@@ -34,6 +34,7 @@ import io.legato.kazusa.data.entities.Book
|
||||
import io.legato.kazusa.data.entities.BookChapter
|
||||
import io.legato.kazusa.data.entities.BookProgress
|
||||
import io.legato.kazusa.data.entities.BookSource
|
||||
import io.legato.kazusa.data.entities.ReplaceRule
|
||||
import io.legato.kazusa.exception.NoStackTraceException
|
||||
import io.legato.kazusa.help.AppWebDav
|
||||
import io.legato.kazusa.help.IntentData
|
||||
@@ -508,6 +509,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
}
|
||||
}
|
||||
|
||||
R.id.menu_setting_replace -> openReplaceRule()
|
||||
R.id.menu_download -> showDownloadDialog()
|
||||
R.id.menu_add_bookmark -> addBookmark()
|
||||
R.id.menu_simulated_reading -> showSimulatedReading()
|
||||
@@ -1203,19 +1205,23 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
/**
|
||||
* 显示阅读样式配置
|
||||
*/
|
||||
override fun showReadStyle() {
|
||||
// override fun showReadStyle() {
|
||||
// showDialogFragment<ReadStyleDialog>()
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 显示更多设置
|
||||
// */
|
||||
// override fun showMoreSetting() {
|
||||
// showDialogFragment<MoreConfigDialog>()
|
||||
// }
|
||||
//
|
||||
override fun showSearchSetting() {
|
||||
showDialogFragment<ReadStyleDialog>()
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示更多设置
|
||||
*/
|
||||
override fun showMoreSetting() {
|
||||
showDialogFragment<MoreConfigDialog>()
|
||||
}
|
||||
|
||||
override fun showSearchSetting() {
|
||||
showDialogFragment<MoreConfigDialog>()
|
||||
override fun showReadStyle() {
|
||||
showDialogFragment<ReadStyleDialog>()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,6 +31,7 @@ import io.legato.kazusa.lib.dialogs.alert
|
||||
//import io.legado.app.lib.theme.primaryColor
|
||||
//import io.legado.app.lib.theme.primaryTextColor
|
||||
import io.legato.kazusa.model.ReadBook
|
||||
import io.legato.kazusa.ui.book.read.config.MoreConfigDialog
|
||||
import io.legato.kazusa.ui.browser.WebViewActivity
|
||||
import io.legato.kazusa.ui.widget.seekbar.SeekBarChangeListener
|
||||
import io.legato.kazusa.utils.ConstraintModify
|
||||
@@ -44,6 +45,7 @@ import io.legato.kazusa.utils.loadAnimation
|
||||
import io.legato.kazusa.utils.modifyBegin
|
||||
import io.legato.kazusa.utils.openUrl
|
||||
import io.legato.kazusa.utils.putPrefBoolean
|
||||
import io.legato.kazusa.utils.showDialogFragment
|
||||
import io.legato.kazusa.utils.startActivity
|
||||
import io.legato.kazusa.utils.visible
|
||||
import splitties.views.onClick
|
||||
@@ -159,11 +161,11 @@ class ReadMenu @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun initView(reset: Boolean = false) = binding.run {
|
||||
if (AppConfig.isNightTheme) {
|
||||
fabNightTheme.setImageResource(R.drawable.ic_daytime)
|
||||
} else {
|
||||
fabNightTheme.setImageResource(R.drawable.ic_brightness)
|
||||
}
|
||||
// if (AppConfig.isNightTheme) {
|
||||
// fabNightTheme.setIconResource(R.drawable.ic_daytime)
|
||||
// } else {
|
||||
// fabNightTheme.setIconResource(R.drawable.ic_brightness)
|
||||
// }
|
||||
initAnimation()
|
||||
if (immersiveMenu) {
|
||||
// val lightTextColor = ColorUtils.withAlpha(ColorUtils.lightenColor(textColor), 0.75f)
|
||||
@@ -223,7 +225,7 @@ class ReadMenu @JvmOverloads constructor(
|
||||
/**
|
||||
* 确保视图不被导航栏遮挡
|
||||
*/
|
||||
applyNavigationBarPadding()
|
||||
binding.bottomView.applyNavigationBarPadding()
|
||||
}
|
||||
|
||||
fun reset() {
|
||||
@@ -361,8 +363,6 @@ class ReadMenu @JvmOverloads constructor(
|
||||
}
|
||||
tvChapterName.setOnClickListener(chapterViewClickListener)
|
||||
tvChapterName.setOnLongClickListener(chapterViewLongClickListener)
|
||||
tvChapterUrl.setOnClickListener(chapterViewClickListener)
|
||||
tvChapterUrl.setOnLongClickListener(chapterViewLongClickListener)
|
||||
//书源操作
|
||||
tvSourceAction.onClick {
|
||||
sourceMenu.menu.findItem(R.id.menu_login).isVisible =
|
||||
@@ -446,13 +446,13 @@ class ReadMenu @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
//替换
|
||||
fabReplaceRule.setOnClickListener { callBack.openReplaceRule() }
|
||||
//fabReplaceRule.setOnClickListener { callBack.openReplaceRule() }
|
||||
|
||||
//夜间模式
|
||||
fabNightTheme.setOnClickListener {
|
||||
AppConfig.isNightTheme = !AppConfig.isNightTheme
|
||||
ThemeConfig.applyDayNight(context)
|
||||
}
|
||||
// fabNightTheme.setOnClickListener {
|
||||
// AppConfig.isNightTheme = !AppConfig.isNightTheme
|
||||
// ThemeConfig.applyDayNight(context)
|
||||
// }
|
||||
|
||||
//上一章
|
||||
tvPre.setOnClickListener { ReadBook.moveToPrevChapter(upContent = true, toLast = false) }
|
||||
@@ -461,37 +461,31 @@ class ReadMenu @JvmOverloads constructor(
|
||||
tvNext.setOnClickListener { ReadBook.moveToNextChapter(true) }
|
||||
|
||||
//目录
|
||||
llCatalog.setOnClickListener {
|
||||
ivCatalog.setOnClickListener {
|
||||
runMenuOut {
|
||||
callBack.openChapterList()
|
||||
}
|
||||
}
|
||||
|
||||
//朗读
|
||||
llReadAloud.setOnClickListener {
|
||||
ivReadAloud.setOnClickListener {
|
||||
runMenuOut {
|
||||
callBack.onClickReadAloud()
|
||||
}
|
||||
}
|
||||
llReadAloud.onLongClick {
|
||||
|
||||
ivReadAloud.onLongClick {
|
||||
runMenuOut {
|
||||
callBack.showReadAloudDialog()
|
||||
}
|
||||
}
|
||||
|
||||
//界面
|
||||
llFont.setOnClickListener {
|
||||
//设置
|
||||
ivSetting.setOnClickListener {
|
||||
runMenuOut {
|
||||
callBack.showReadStyle()
|
||||
}
|
||||
}
|
||||
|
||||
//设置
|
||||
llSetting.setOnClickListener {
|
||||
runMenuOut {
|
||||
callBack.showMoreSetting()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initAnimation() {
|
||||
@@ -500,13 +494,13 @@ class ReadMenu @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
fun upBookView() {
|
||||
binding.titleBar.title = ReadBook.book?.name
|
||||
binding.titleBar.title = " "
|
||||
binding.tvBookName.text = ReadBook.book?.name
|
||||
ReadBook.curTextChapter?.let {
|
||||
binding.tvChapterName.text = it.title
|
||||
binding.tvChapterName.visible()
|
||||
if (!ReadBook.isLocalBook) {
|
||||
binding.tvChapterUrl.text = it.chapter.getAbsoluteURL()
|
||||
binding.tvChapterUrl.visible()
|
||||
//binding.tvChapterUrl.visible()
|
||||
} else {
|
||||
binding.tvChapterUrl.gone()
|
||||
}
|
||||
@@ -514,7 +508,6 @@ class ReadMenu @JvmOverloads constructor(
|
||||
binding.tvPre.isEnabled = ReadBook.durChapterIndex != 0
|
||||
binding.tvNext.isEnabled = ReadBook.durChapterIndex != ReadBook.simulatedChapterSize - 1
|
||||
} ?: let {
|
||||
binding.tvChapterName.gone()
|
||||
binding.tvChapterUrl.gone()
|
||||
}
|
||||
}
|
||||
@@ -526,20 +519,16 @@ class ReadMenu @JvmOverloads constructor(
|
||||
when (AppConfig.progressBarBehavior) {
|
||||
"page" -> {
|
||||
ReadBook.curTextChapter?.let { chapter ->
|
||||
if (chapter.pageSize > 0 && ReadBook.durPageIndex > 0) {
|
||||
if (chapter.pageSize >= 0 && ReadBook.durPageIndex >= 0) {
|
||||
valueFrom = 1f
|
||||
valueTo = chapter.pageSize.toFloat().coerceAtLeast(2f)
|
||||
value = (ReadBook.durPageIndex).coerceIn(1, chapter.pageSize).toFloat()
|
||||
stepSize = 1f
|
||||
value = (ReadBook.durPageIndex).coerceIn(1, chapter.pageSize).toFloat()
|
||||
} else {
|
||||
valueFrom = 1f
|
||||
valueTo = 2f
|
||||
value = 1f
|
||||
value = 0f
|
||||
valueFrom = 0f
|
||||
valueTo = 1000f
|
||||
}
|
||||
}?: run {
|
||||
valueFrom = 1f
|
||||
valueTo = 2f
|
||||
value = 1f
|
||||
}
|
||||
}
|
||||
|
||||
@@ -548,12 +537,12 @@ class ReadMenu @JvmOverloads constructor(
|
||||
{
|
||||
valueFrom = 1f
|
||||
valueTo = ReadBook.simulatedChapterSize.toFloat().coerceAtLeast(2f)
|
||||
value = (ReadBook.durChapterIndex).coerceIn(1, ReadBook.simulatedChapterSize).toFloat()
|
||||
stepSize = 1f
|
||||
value = (ReadBook.durChapterIndex).coerceIn(1, ReadBook.simulatedChapterSize).toFloat()
|
||||
} else {
|
||||
valueFrom = 1f
|
||||
valueTo = 2f
|
||||
value = 1f
|
||||
valueFrom = 0f
|
||||
value = 0f
|
||||
valueTo = 1000f
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -579,15 +568,15 @@ class ReadMenu @JvmOverloads constructor(
|
||||
// }
|
||||
|
||||
fun setSeekPage(seek: Int) {
|
||||
binding.seekReadPage.value = 1f
|
||||
binding.seekReadPage.value = seek.toFloat() + 1
|
||||
}
|
||||
|
||||
fun setAutoPage(autoPage: Boolean) = binding.run {
|
||||
if (autoPage) {
|
||||
fabAutoPage.setImageResource(R.drawable.ic_auto_page_stop)
|
||||
fabAutoPage.setIconResource(R.drawable.ic_auto_page_stop)
|
||||
fabAutoPage.contentDescription = context.getString(R.string.auto_next_page_stop)
|
||||
} else {
|
||||
fabAutoPage.setImageResource(R.drawable.ic_auto_page)
|
||||
fabAutoPage.setIconResource(R.drawable.ic_auto_page)
|
||||
fabAutoPage.contentDescription = context.getString(R.string.auto_next_page)
|
||||
}
|
||||
//fabAutoPage.setColorFilter(textColor)
|
||||
@@ -615,7 +604,6 @@ class ReadMenu @JvmOverloads constructor(
|
||||
fun openSourceEditActivity()
|
||||
fun openBookInfoActivity()
|
||||
fun showReadStyle()
|
||||
fun showMoreSetting()
|
||||
fun showReadAloudDialog()
|
||||
fun upSystemUiVisibility()
|
||||
fun onClickReadAloud()
|
||||
|
||||
@@ -71,7 +71,7 @@ class HttpTtsEditDialog() : BaseBottomSheetDialogFragment(R.layout.dialog_http_t
|
||||
|
||||
fun initMenu() {
|
||||
binding.toolBar.inflateMenu(R.menu.speak_engine_edit)
|
||||
binding.toolBar.menu.applyTint(requireContext())
|
||||
//binding.toolBar.menu.applyTint(requireContext())
|
||||
binding.toolBar.setOnMenuItemClickListener(this)
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import android.view.ViewConfiguration
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import io.legato.kazusa.R
|
||||
import io.legato.kazusa.base.BasePrefDialogFragment
|
||||
import io.legato.kazusa.constant.EventBus
|
||||
@@ -31,20 +32,6 @@ import io.legato.kazusa.utils.removePref
|
||||
class MoreConfigDialog : BasePrefDialogFragment() {
|
||||
private val readPreferTag = "readPreferenceFragment"
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
// dialog?.window?.run {
|
||||
// clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
|
||||
// setBackgroundDrawableResource(R.color.background)
|
||||
// decorView.setPadding(0, 0, 0, 0)
|
||||
// val attr = attributes
|
||||
// attr.dimAmount = 0.0f
|
||||
// attr.gravity = Gravity.BOTTOM
|
||||
// attributes = attr
|
||||
// setLayout(ViewGroup.LayoutParams.MATCH_PARENT, 360.dpToPx())
|
||||
// }
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
@@ -67,12 +54,7 @@ class MoreConfigDialog : BasePrefDialogFragment() {
|
||||
.commit()
|
||||
}
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface) {
|
||||
super.onDismiss(dialog)
|
||||
(activity as ReadBookActivity).bottomDialog--
|
||||
}
|
||||
|
||||
class ReadPreferenceFragment : PreferenceFragment(),
|
||||
class ReadPreferenceFragment : PreferenceFragmentCompat(),
|
||||
SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
private val slopSquare by lazy { ViewConfiguration.get(requireContext()).scaledTouchSlop }
|
||||
@@ -198,6 +180,5 @@ class MoreConfigDialog : BasePrefDialogFragment() {
|
||||
getString(R.string.page_touch_slop_summary, value)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import splitties.views.onLongClick
|
||||
import androidx.core.graphics.drawable.toDrawable
|
||||
import androidx.transition.TransitionManager
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import io.legato.kazusa.help.config.ThemeConfig
|
||||
|
||||
class ReadStyleDialog : BaseBottomSheetDialogFragment(R.layout.dialog_read_book_style),
|
||||
FontSelectDialog.CallBack {
|
||||
@@ -39,21 +40,6 @@ class ReadStyleDialog : BaseBottomSheetDialogFragment(R.layout.dialog_read_book_
|
||||
|
||||
private lateinit var allSliders: List<DetailSeekBar>
|
||||
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
// dialog?.window?.run {
|
||||
// clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
|
||||
// setBackgroundDrawableResource(R.color.background)
|
||||
// decorView.setPadding(0, 0, 0, 0)
|
||||
// val attr = attributes
|
||||
// attr.dimAmount = 0.0f
|
||||
// attr.gravity = Gravity.BOTTOM
|
||||
// attributes = attr
|
||||
// setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
// }
|
||||
}
|
||||
|
||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
||||
(activity as ReadBookActivity).bottomDialog++
|
||||
initView()
|
||||
@@ -75,6 +61,11 @@ class ReadStyleDialog : BaseBottomSheetDialogFragment(R.layout.dialog_read_book_
|
||||
// tvPageAnim.setTextColor(textColor)
|
||||
// tvBgTs.setTextColor(textColor)
|
||||
// tvShareLayout.setTextColor(textColor)
|
||||
if (AppConfig.isNightTheme) {
|
||||
tvDayNight.setIconResource(R.drawable.ic_daytime)
|
||||
} else {
|
||||
tvDayNight.setIconResource(R.drawable.ic_brightness)
|
||||
}
|
||||
dsbTextSize.valueFormat = {
|
||||
(it + 5).toString()
|
||||
}
|
||||
@@ -133,6 +124,13 @@ class ReadStyleDialog : BaseBottomSheetDialogFragment(R.layout.dialog_read_book_
|
||||
tvTip.setOnClickListener {
|
||||
TipConfigDialog().show(childFragmentManager, "tipConfigDialog")
|
||||
}
|
||||
tvMore.setOnClickListener {
|
||||
showDialogFragment<MoreConfigDialog>()
|
||||
}
|
||||
tvDayNight.setOnClickListener {
|
||||
AppConfig.isNightTheme = !AppConfig.isNightTheme
|
||||
ThemeConfig.applyDayNight(requireContext())
|
||||
}
|
||||
// rgPageAnim.setOnCheckedChangeListener { _, checkedId ->
|
||||
// ReadBook.book?.setPageAnim(-1)
|
||||
// ReadBookConfig.pageAnim = binding.rgPageAnim.getIndexById(checkedId)
|
||||
@@ -299,6 +297,5 @@ class ReadStyleDialog : BaseBottomSheetDialogFragment(R.layout.dialog_read_book_
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -161,7 +161,7 @@ class SpeakEngineDialog() : BaseBottomSheetDialogFragment(R.layout.dialog_recycl
|
||||
|
||||
private fun initMenu() = binding.run {
|
||||
toolBar.inflateMenu(R.menu.speak_engine)
|
||||
toolBar.menu.applyTint(requireContext())
|
||||
//toolBar.menu.applyTint(requireContext())
|
||||
toolBar.setOnMenuItemClickListener(this@SpeakEngineDialog)
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import io.legato.kazusa.utils.applyStatusBarPadding
|
||||
import io.legato.kazusa.utils.dpToPx
|
||||
import io.legato.kazusa.utils.gone
|
||||
import io.legato.kazusa.utils.setTextIfNotEqual
|
||||
import io.legato.kazusa.utils.statusBarHeight
|
||||
import splitties.views.backgroundColor
|
||||
import java.util.Date
|
||||
|
||||
@@ -59,11 +60,9 @@ class PageView(context: Context) : FrameLayout(context) {
|
||||
}
|
||||
|
||||
init {
|
||||
if (!isInEditMode) {
|
||||
upStyle()
|
||||
binding.vwStatusBar.applyStatusBarPadding()
|
||||
binding.vwNavigationBar.applyNavigationBarPadding()
|
||||
}
|
||||
upStyle()
|
||||
binding.vwStatusBar.applyStatusBarPadding()
|
||||
binding.vwNavigationBar.applyNavigationBarPadding()
|
||||
}
|
||||
|
||||
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
||||
@@ -118,8 +117,8 @@ class PageView(context: Context) : FrameLayout(context) {
|
||||
* 显示状态栏时隐藏header
|
||||
*/
|
||||
fun upStatusBar() = with(binding.vwStatusBar) {
|
||||
// setPadding(paddingLeft, context.statusBarHeight, paddingRight, paddingBottom)
|
||||
isGone = ReadBookConfig.hideStatusBar || readBookActivity?.isInMultiWindow == true
|
||||
setPadding(paddingLeft, context.statusBarHeight, paddingRight, paddingBottom)
|
||||
isGone = ReadBookConfig.hideStatusBar
|
||||
}
|
||||
|
||||
fun upNavigationBar() {
|
||||
|
||||
@@ -60,7 +60,7 @@ class SearchScopeDialog : BaseDialogFragment(R.layout.dialog_search_scope) {
|
||||
|
||||
private fun initMenu() {
|
||||
binding.toolBar.inflateMenu(R.menu.book_search_scope)
|
||||
binding.toolBar.menu.applyTint(requireContext())
|
||||
//binding.toolBar.menu.applyTint(requireContext())
|
||||
}
|
||||
|
||||
private fun initSearchView() {
|
||||
|
||||
@@ -46,7 +46,7 @@ class GroupManageDialog : BaseDialogFragment(R.layout.dialog_recycler_view),
|
||||
// binding.toolBar.setBackgroundColor(primaryColor)
|
||||
binding.toolBar.title = getString(R.string.group_manage)
|
||||
binding.toolBar.inflateMenu(R.menu.group_manage)
|
||||
binding.toolBar.menu.applyTint(requireContext())
|
||||
//binding.toolBar.menu.applyTint(requireContext())
|
||||
binding.toolBar.setOnMenuItemClickListener(this)
|
||||
binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
|
||||
binding.recyclerView.addItemDecoration(VerticalDivider(requireContext()))
|
||||
|
||||
@@ -90,7 +90,7 @@ class TxtTocRuleDialog() : BaseDialogFragment(R.layout.dialog_toc_regex),
|
||||
durRegex = arguments?.getString("tocRegex")
|
||||
binding.toolBar.setTitle(R.string.txt_toc_rule)
|
||||
binding.toolBar.inflateMenu(R.menu.txt_toc_rule)
|
||||
binding.toolBar.menu.applyTint(requireContext())
|
||||
//binding.toolBar.menu.applyTint(requireContext())
|
||||
binding.toolBar.setOnMenuItemClickListener(this)
|
||||
initView()
|
||||
initData()
|
||||
|
||||
@@ -51,7 +51,7 @@ class TxtTocRuleEditDialog() : BaseBottomSheetDialogFragment(R.layout.dialog_toc
|
||||
|
||||
private fun initMenu() {
|
||||
binding.toolBar.inflateMenu(R.menu.txt_toc_rule_edit)
|
||||
binding.toolBar.menu.applyTint(requireContext())
|
||||
//binding.toolBar.menu.applyTint(requireContext())
|
||||
binding.toolBar.setOnMenuItemClickListener(this)
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class DictRuleEditDialog() : BaseBottomSheetDialogFragment(R.layout.dialog_dict_
|
||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
||||
//binding.toolBar.setBackgroundColor(primaryColor)
|
||||
binding.toolBar.inflateMenu(R.menu.dict_rule_edit)
|
||||
binding.toolBar.menu.applyTint(requireContext())
|
||||
//binding.toolBar.menu.applyTint(requireContext())
|
||||
binding.toolBar.setOnMenuItemClickListener(this)
|
||||
viewModel.initData(arguments?.getString("name")) {
|
||||
upRuleView(viewModel.dictRule)
|
||||
|
||||
@@ -9,6 +9,7 @@ import androidx.documentfile.provider.DocumentFile
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import io.legato.kazusa.R
|
||||
import io.legato.kazusa.base.BaseBottomSheetDialogFragment
|
||||
import io.legato.kazusa.base.BaseDialogFragment
|
||||
import io.legato.kazusa.constant.AppLog
|
||||
import io.legato.kazusa.constant.PreferKey
|
||||
@@ -36,11 +37,12 @@ import io.legato.kazusa.utils.toastOnUi
|
||||
import io.legato.kazusa.utils.viewbindingdelegate.viewBinding
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
import androidx.core.net.toUri
|
||||
|
||||
/**
|
||||
* 字体选择对话框
|
||||
*/
|
||||
class FontSelectDialog : BaseDialogFragment(R.layout.dialog_font_select),
|
||||
class FontSelectDialog : BaseBottomSheetDialogFragment(R.layout.dialog_font_select),
|
||||
Toolbar.OnMenuItemClickListener,
|
||||
FontAdapter.CallBack {
|
||||
private val fontRegex = Regex("(?i).*\\.[ot]tf")
|
||||
@@ -70,11 +72,6 @@ class FontSelectDialog : BaseDialogFragment(R.layout.dialog_font_select),
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
setLayout(0.9f, 0.9f)
|
||||
}
|
||||
|
||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
||||
//binding.toolBar.setBackgroundColor(primaryColor)
|
||||
binding.toolBar.setTitle(R.string.select_font)
|
||||
@@ -89,7 +86,7 @@ class FontSelectDialog : BaseDialogFragment(R.layout.dialog_font_select),
|
||||
openFolder()
|
||||
} else {
|
||||
if (fontPath.isContentScheme()) {
|
||||
val doc = DocumentFile.fromTreeUri(requireContext(), Uri.parse(fontPath))
|
||||
val doc = DocumentFile.fromTreeUri(requireContext(), fontPath.toUri())
|
||||
if (doc?.canRead() == true) {
|
||||
loadFontFiles(FileDoc.fromDocumentFile(doc))
|
||||
} else {
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
|
||||
package io.legato.kazusa.ui.main
|
||||
|
||||
import android.content.res.Configuration
|
||||
import android.os.Bundle
|
||||
import android.text.format.DateUtils
|
||||
import android.view.MenuItem
|
||||
import android.view.MotionEvent
|
||||
import android.view.ViewGroup
|
||||
import androidx.activity.addCallback
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.activity.viewModels
|
||||
import androidx.core.view.postDelayed
|
||||
import androidx.fragment.app.Fragment
|
||||
@@ -57,7 +59,10 @@ import splitties.views.bottomPadding
|
||||
import kotlin.coroutines.resume
|
||||
import kotlin.coroutines.suspendCoroutine
|
||||
import androidx.core.view.get
|
||||
import com.google.android.material.navigation.NavigationBarView
|
||||
import io.legato.kazusa.ui.welcome.WelcomeActivity
|
||||
import io.legato.kazusa.utils.applyNavigationBarPadding
|
||||
import io.legato.kazusa.utils.applyStatusBarPadding
|
||||
|
||||
/**
|
||||
* 主界面
|
||||
@@ -84,10 +89,12 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
|
||||
private val adapter by lazy {
|
||||
TabFragmentPageAdapter(supportFragmentManager)
|
||||
}
|
||||
private val onUpBooksBadgeView by lazy {
|
||||
binding.bottomNavigationView.addBadgeView(0)
|
||||
|
||||
private val badge by lazy {
|
||||
getNavigationBarView().getOrCreateBadge(R.id.menu_bookshelf)
|
||||
}
|
||||
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
upBottomMenu()
|
||||
initView()
|
||||
@@ -197,13 +204,18 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
|
||||
viewPagerMain.adapter = adapter
|
||||
viewPagerMain.addOnPageChangeListener(PageChangeCallback())
|
||||
//bottomNavigationView.elevation = elevation
|
||||
bottomNavigationView.setOnNavigationItemSelectedListener(this@MainActivity)
|
||||
bottomNavigationView.setOnNavigationItemReselectedListener(this@MainActivity)
|
||||
bottomNavigationView.setOnApplyWindowInsetsListenerCompat { view, windowInsets ->
|
||||
val height = windowInsets.navigationBarHeight
|
||||
view.bottomPadding = height
|
||||
windowInsets.inset(0, 0, 0, height)
|
||||
getNavigationBarView().apply {
|
||||
setOnItemSelectedListener { onNavigationItemSelected(it) }
|
||||
setOnItemReselectedListener { onNavigationItemReselected(it) }
|
||||
}
|
||||
|
||||
//getNavigationBarView().applyNavigationBarPadding()
|
||||
|
||||
// bottomNavigationView.setOnApplyWindowInsetsListenerCompat { view, windowInsets ->
|
||||
// val height = windowInsets.navigationBarHeight
|
||||
// view.bottomPadding = height
|
||||
// windowInsets.inset(0, 0, 0, height)
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -344,8 +356,10 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
|
||||
override fun observeLiveBus() {
|
||||
super.observeLiveBus()
|
||||
viewModel.onUpBooksLiveData.observe(this) {
|
||||
onUpBooksBadgeView.setBadgeCount(it)
|
||||
badge.isVisible = it > 0
|
||||
badge.number = it
|
||||
}
|
||||
|
||||
observeEvent<Boolean>(EventBus.NOTIFY_MAIN) {
|
||||
binding.apply {
|
||||
upBottomMenu()
|
||||
@@ -359,13 +373,24 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
|
||||
}
|
||||
}
|
||||
|
||||
private fun getNavigationBarView(): NavigationBarView {
|
||||
return findViewById(
|
||||
if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT)
|
||||
R.id.bottom_navigation_view
|
||||
else
|
||||
R.id.navigation_rail_view
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
private fun upBottomMenu() {
|
||||
|
||||
val showDiscovery = AppConfig.showDiscovery
|
||||
val showRss = AppConfig.showRSS
|
||||
binding.bottomNavigationView.menu.let { menu ->
|
||||
menu.findItem(R.id.menu_discovery).isVisible = showDiscovery
|
||||
menu.findItem(R.id.menu_rss).isVisible = showRss
|
||||
}
|
||||
val menu = getNavigationBarView().menu
|
||||
menu.findItem(R.id.menu_discovery).isVisible = showDiscovery
|
||||
menu.findItem(R.id.menu_rss).isVisible = showRss
|
||||
|
||||
var index = 0
|
||||
if (showDiscovery) {
|
||||
index++
|
||||
@@ -408,8 +433,9 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
|
||||
|
||||
override fun onPageSelected(position: Int) {
|
||||
pagePosition = position
|
||||
binding.bottomNavigationView.menu[realPositions[position]].isChecked = true
|
||||
getNavigationBarView().menu[realPositions[position]].isChecked = true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package io.legato.kazusa.ui.main.bookshelf
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.res.Configuration
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.LiveData
|
||||
@@ -28,6 +30,7 @@ import io.legato.kazusa.ui.file.HandleFileContract
|
||||
import io.legato.kazusa.ui.main.MainFragmentInterface
|
||||
import io.legato.kazusa.ui.main.MainViewModel
|
||||
import io.legato.kazusa.ui.widget.dialog.WaitDialog
|
||||
import io.legato.kazusa.utils.bookshelfLayout
|
||||
import io.legato.kazusa.utils.checkByIndex
|
||||
import io.legato.kazusa.utils.getCheckedIndex
|
||||
import io.legato.kazusa.utils.isAbsUrl
|
||||
@@ -164,7 +167,17 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment<BookshelfVi
|
||||
@SuppressLint("InflateParams")
|
||||
fun configBookshelf() {
|
||||
alert(titleResource = R.string.bookshelf_layout) {
|
||||
val bookshelfLayout = AppConfig.bookshelfLayout
|
||||
|
||||
val orientation = requireContext().resources.configuration.orientation
|
||||
val bookshelfLayout = if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
AppConfig.bookshelfLayoutLandscape
|
||||
} else {
|
||||
AppConfig.bookshelfLayoutPortrait
|
||||
}
|
||||
|
||||
val isGrid = bookshelfLayout > 0
|
||||
val columnCount = (bookshelfLayout.takeIf { it > 0 } ?: 1)
|
||||
|
||||
val bookshelfSort = AppConfig.bookshelfSort
|
||||
val alertBinding =
|
||||
DialogBookshelfConfigBinding.inflate(layoutInflater)
|
||||
@@ -174,10 +187,20 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment<BookshelfVi
|
||||
swShowLastUpdateTime.isChecked = AppConfig.showLastUpdateTime
|
||||
swShowWaitUpBooks.isChecked = AppConfig.showWaitUpCount
|
||||
swShowBookshelfFastScroller.isChecked = AppConfig.showBookshelfFastScroller
|
||||
rgLayout.checkByIndex(bookshelfLayout)
|
||||
rgSort.checkByIndex(bookshelfSort)
|
||||
|
||||
chipList.isChecked = !isGrid
|
||||
chipGrid.isChecked = isGrid
|
||||
llGridSlider.isVisible = isGrid
|
||||
sliderGridCount.value = columnCount.toFloat()
|
||||
|
||||
chipGroupLayout.setOnCheckedChangeListener { _, checkedId ->
|
||||
llGridSlider.isVisible = checkedId == R.id.chip_grid
|
||||
}
|
||||
|
||||
}
|
||||
customView { alertBinding.root }
|
||||
|
||||
okButton {
|
||||
alertBinding.apply {
|
||||
var notifyMain = false
|
||||
@@ -206,15 +229,30 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment<BookshelfVi
|
||||
AppConfig.bookshelfSort = rgSort.getCheckedIndex()
|
||||
upSort()
|
||||
}
|
||||
if (bookshelfLayout != rgLayout.getCheckedIndex()) {
|
||||
AppConfig.bookshelfLayout = rgLayout.getCheckedIndex()
|
||||
if (AppConfig.bookshelfLayout == 0) {
|
||||
activityViewModel.booksGridRecycledViewPool.clear()
|
||||
|
||||
val isNowGrid = alertBinding.chipGrid.isChecked
|
||||
val selectedColumn = alertBinding.sliderGridCount.value.toInt()
|
||||
val newLayout = if (isNowGrid) selectedColumn else 0
|
||||
|
||||
if (bookshelfLayout != newLayout) {
|
||||
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
AppConfig.bookshelfLayoutLandscape = newLayout
|
||||
if (newLayout == 0) {
|
||||
activityViewModel.booksGridRecycledViewPool.clear()
|
||||
} else {
|
||||
activityViewModel.booksListRecycledViewPool.clear()
|
||||
}
|
||||
} else {
|
||||
activityViewModel.booksListRecycledViewPool.clear()
|
||||
AppConfig.bookshelfLayoutPortrait = newLayout
|
||||
if (newLayout == 0) {
|
||||
activityViewModel.booksGridRecycledViewPool.clear()
|
||||
} else {
|
||||
activityViewModel.booksListRecycledViewPool.clear()
|
||||
}
|
||||
}
|
||||
recreate = true
|
||||
}
|
||||
|
||||
if (recreate) {
|
||||
postEvent(EventBus.RECREATE, "")
|
||||
} else if (notifyMain) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.legato.kazusa.ui.main.bookshelf.style1.books
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.res.Configuration
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewConfiguration
|
||||
@@ -27,6 +28,7 @@ import io.legato.kazusa.help.config.AppConfig
|
||||
//import io.legado.app.lib.theme.primaryColor
|
||||
import io.legato.kazusa.ui.book.info.BookInfoActivity
|
||||
import io.legato.kazusa.ui.main.MainViewModel
|
||||
import io.legato.kazusa.utils.bookshelfLayout
|
||||
import io.legato.kazusa.utils.cnCompare
|
||||
import io.legato.kazusa.utils.flowWithLifecycleAndDatabaseChangeFirst
|
||||
import io.legato.kazusa.utils.observeEvent
|
||||
@@ -61,7 +63,10 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
||||
|
||||
private val binding by viewBinding(FragmentBooksBinding::bind)
|
||||
private val activityViewModel by activityViewModels<MainViewModel>()
|
||||
private val bookshelfLayout by lazy { AppConfig.bookshelfLayout }
|
||||
|
||||
private val bookshelfLayout by lazy { requireContext().bookshelfLayout }
|
||||
|
||||
|
||||
private val booksAdapter: BaseBooksAdapter<*> by lazy {
|
||||
if (bookshelfLayout == 0) {
|
||||
BooksAdapterList(requireContext(), this, this, viewLifecycleOwner.lifecycle)
|
||||
@@ -102,7 +107,7 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
||||
if (bookshelfLayout == 0) {
|
||||
binding.rvBookshelf.layoutManager = LinearLayoutManager(context)
|
||||
} else {
|
||||
binding.rvBookshelf.layoutManager = GridLayoutManager(context, bookshelfLayout + 2)
|
||||
binding.rvBookshelf.layoutManager = GridLayoutManager(context, bookshelfLayout)
|
||||
}
|
||||
if (bookshelfLayout == 0) {
|
||||
binding.rvBookshelf.setRecycledViewPool(activityViewModel.booksListRecycledViewPool)
|
||||
|
||||
@@ -25,6 +25,7 @@ import io.legato.kazusa.ui.book.group.GroupEditDialog
|
||||
import io.legato.kazusa.ui.book.info.BookInfoActivity
|
||||
import io.legato.kazusa.ui.book.search.SearchActivity
|
||||
import io.legato.kazusa.ui.main.bookshelf.BaseBookshelfFragment
|
||||
import io.legato.kazusa.utils.bookshelfLayout
|
||||
import io.legato.kazusa.utils.cnCompare
|
||||
import io.legato.kazusa.utils.flowWithLifecycleAndDatabaseChangeFirst
|
||||
import io.legato.kazusa.utils.observeEvent
|
||||
@@ -56,7 +57,9 @@ class BookshelfFragment2() : BaseBookshelfFragment(R.layout.fragment_bookshelf2)
|
||||
}
|
||||
|
||||
private val binding by viewBinding(FragmentBookshelf2Binding::bind)
|
||||
private val bookshelfLayout by lazy { AppConfig.bookshelfLayout }
|
||||
|
||||
private val bookshelfLayout by lazy { requireContext().bookshelfLayout }
|
||||
|
||||
private val booksAdapter: BaseBooksAdapter<*> by lazy {
|
||||
if (bookshelfLayout == 0) {
|
||||
BooksAdapterList(requireContext(), this)
|
||||
@@ -87,7 +90,7 @@ class BookshelfFragment2() : BaseBookshelfFragment(R.layout.fragment_bookshelf2)
|
||||
if (bookshelfLayout == 0) {
|
||||
binding.rvBookshelf.layoutManager = LinearLayoutManager(context)
|
||||
} else {
|
||||
binding.rvBookshelf.layoutManager = GridLayoutManager(context, bookshelfLayout + 2)
|
||||
binding.rvBookshelf.layoutManager = GridLayoutManager(context, bookshelfLayout)
|
||||
}
|
||||
binding.rvBookshelf.itemAnimator = null
|
||||
binding.rvBookshelf.adapter = booksAdapter
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.children
|
||||
import com.google.android.flexbox.FlexboxLayout
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
import io.legato.kazusa.R
|
||||
import io.legato.kazusa.base.adapter.ItemViewHolder
|
||||
import io.legato.kazusa.base.adapter.RecyclerAdapter
|
||||
@@ -85,14 +86,17 @@ class ExploreAdapter(context: Context, val callBack: CallBack) :
|
||||
recyclerFlexbox(flexbox)
|
||||
flexbox.visible()
|
||||
kinds.forEach { kind ->
|
||||
val tv = getFlexboxChild(flexbox)
|
||||
flexbox.addView(tv)
|
||||
tv.text = kind.title
|
||||
kind.style().apply(tv)
|
||||
val cardView = getFlexboxChild(flexbox)
|
||||
val textView = cardView.findViewById<TextView>(R.id.text_view)
|
||||
flexbox.addView(cardView)
|
||||
|
||||
textView.text = kind.title
|
||||
//kind.style().apply(textView)
|
||||
|
||||
if (kind.url.isNullOrBlank()) {
|
||||
tv.setOnClickListener(null)
|
||||
cardView.setOnClickListener(null)
|
||||
} else {
|
||||
tv.setOnClickListener {
|
||||
cardView.setOnClickListener {
|
||||
if (kind.title.startsWith("ERROR:")) {
|
||||
it.activity?.showDialogFragment(TextDialog("ERROR", kind.url))
|
||||
} else {
|
||||
@@ -104,12 +108,13 @@ class ExploreAdapter(context: Context, val callBack: CallBack) :
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Synchronized
|
||||
private fun getFlexboxChild(flexbox: FlexboxLayout): TextView {
|
||||
private fun getFlexboxChild(flexbox: FlexboxLayout): MaterialCardView {
|
||||
return if (recycler.isEmpty()) {
|
||||
ItemFilletTextBinding.inflate(inflater, flexbox, false).root
|
||||
} else {
|
||||
recycler.removeLastElement() as TextView
|
||||
recycler.removeLastElement() as MaterialCardView
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class GroupManageDialog : BaseBottomSheetDialogFragment(R.layout.dialog_recycler
|
||||
//toolBar.setBackgroundColor(primaryColor)
|
||||
toolBar.title = getString(R.string.group_manage)
|
||||
toolBar.inflateMenu(R.menu.group_manage)
|
||||
toolBar.menu.applyTint(requireContext())
|
||||
//toolBar.menu.applyTint(requireContext())
|
||||
toolBar.setOnMenuItemClickListener(this@GroupManageDialog)
|
||||
recyclerView.layoutManager = LinearLayoutManager(requireContext())
|
||||
recyclerView.addItemDecoration(VerticalDivider(requireContext()))
|
||||
|
||||
@@ -167,12 +167,6 @@ class TitleBar @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
if (AppConfig.isEInkMode) {
|
||||
setBackgroundResource(R.drawable.bg_eink_border_bottom)
|
||||
} else {
|
||||
//setBackgroundColor(context.primaryColor)
|
||||
}
|
||||
|
||||
stateListAnimator = null
|
||||
//elevation = context.elevation
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import androidx.annotation.ColorRes
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
import io.legato.kazusa.R
|
||||
import io.legato.kazusa.databinding.ViewLoadMoreBinding
|
||||
import io.legato.kazusa.lib.dialogs.alert
|
||||
@@ -51,7 +53,7 @@ class LoadMoreView(context: Context, attrs: AttributeSet? = null) : FrameLayout(
|
||||
|
||||
fun stopLoad() {
|
||||
isLoading = false
|
||||
binding.rotateLoading.inVisible()
|
||||
binding.rotateLoading.invisible()
|
||||
}
|
||||
|
||||
fun hasMore() {
|
||||
@@ -81,14 +83,6 @@ class LoadMoreView(context: Context, attrs: AttributeSet? = null) : FrameLayout(
|
||||
binding.tvText.visible()
|
||||
}
|
||||
|
||||
fun setLoadingColor(@ColorRes color: Int) {
|
||||
binding.rotateLoading.loadingColor = context.getCompatColor(color)
|
||||
}
|
||||
|
||||
fun setLoadingTextColor(@ColorRes color: Int) {
|
||||
binding.tvText.setTextColor(context.getCompatColor(color))
|
||||
}
|
||||
|
||||
private fun showErrorDialog(): Boolean {
|
||||
if (errorMsg.isBlank()) {
|
||||
return false
|
||||
|
||||
@@ -290,7 +290,7 @@ class FastScroller : LinearLayout {
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||
when (event.action) {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
if (event.x < mHandleView.x - ViewCompat.getPaddingStart(mHandleView)) {
|
||||
if (event.x < mHandleView.x - mHandleView.paddingStart) {
|
||||
return false
|
||||
}
|
||||
if (!mScrollbar.isVisible) {
|
||||
|
||||
@@ -418,6 +418,13 @@ val Context.isDebuggable: Boolean
|
||||
|
||||
val Context.dataStore by preferencesDataStore(name = "settings")
|
||||
|
||||
val Context.bookshelfLayout: Int
|
||||
get() = if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
AppConfig.bookshelfLayoutLandscape
|
||||
} else {
|
||||
AppConfig.bookshelfLayoutPortrait
|
||||
}
|
||||
|
||||
fun Context.themeColor(attr: Int): Int {
|
||||
val typedValue = TypedValue()
|
||||
theme.resolveAttribute(attr, typedValue, true)
|
||||
|
||||
@@ -24,6 +24,7 @@ object DataStoreUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend fun <T> read(context: Context, key: String, defaultValue: T): T {
|
||||
return context.dataStore.data.map { preferences ->
|
||||
when (defaultValue) {
|
||||
|
||||
@@ -26,7 +26,7 @@ import io.legato.kazusa.ui.widget.dialog.TextDialog
|
||||
inline fun <reified T : DialogFragment> Fragment.showDialogFragment(
|
||||
arguments: Bundle.() -> Unit = {}
|
||||
) {
|
||||
val dialog = T::class.java.newInstance()
|
||||
val dialog = T::class.java.getDeclaredConstructor().newInstance()
|
||||
val bundle = Bundle()
|
||||
bundle.apply(arguments)
|
||||
dialog.arguments = bundle
|
||||
|
||||
@@ -69,9 +69,7 @@ fun EditText.showSoftInput() = run {
|
||||
}
|
||||
|
||||
fun View.disableAutoFill() = run {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
this.importantForAutofill = IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS
|
||||
}
|
||||
this.importantForAutofill = IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS
|
||||
}
|
||||
|
||||
fun View.applyTint(
|
||||
|
||||
Reference in New Issue
Block a user