优化
This commit is contained in:
@@ -115,6 +115,7 @@ object PreferKey {
|
||||
const val ignoreAudioFocus = "ignoreAudioFocus"
|
||||
const val parallelExportBook = "parallelExportBook"
|
||||
const val progressBarBehavior = "progressBarBehavior"
|
||||
const val sourceEditMaxLine = "sourceEditMaxLine"
|
||||
|
||||
const val cPrimary = "colorPrimary"
|
||||
const val cAccent = "colorAccent"
|
||||
|
||||
@@ -368,15 +368,27 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
appCtx.putPrefInt(PreferKey.bitmapCacheSize, value)
|
||||
}
|
||||
|
||||
var showReadTitleBarAddition : Boolean
|
||||
var showReadTitleBarAddition: Boolean
|
||||
get() = appCtx.getPrefBoolean(PreferKey.showReadTitleAddition, true)
|
||||
set(value) {
|
||||
appCtx.putPrefBoolean(PreferKey.showReadTitleAddition, value)
|
||||
}
|
||||
var readBarStyleFollowPage : Boolean
|
||||
var readBarStyleFollowPage: Boolean
|
||||
get() = appCtx.getPrefBoolean(PreferKey.readBarStyleFollowPage, false)
|
||||
set(value) {
|
||||
appCtx.putPrefBoolean(PreferKey.readBarStyleFollowPage, value)
|
||||
}
|
||||
|
||||
var sourceEditMaxLine: Int
|
||||
get() {
|
||||
val maxLine = appCtx.getPrefInt(PreferKey.sourceEditMaxLine, Int.MAX_VALUE)
|
||||
if (maxLine < 10) {
|
||||
return 99
|
||||
}
|
||||
return maxLine
|
||||
}
|
||||
set(value) {
|
||||
appCtx.putPrefInt(PreferKey.sourceEditMaxLine, value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,12 +9,15 @@ import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import io.legado.app.R
|
||||
import io.legado.app.databinding.ItemSourceEditBinding
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.ui.widget.code.addJsPattern
|
||||
import io.legado.app.ui.widget.code.addJsonPattern
|
||||
import io.legado.app.ui.widget.code.addLegadoPattern
|
||||
|
||||
class BookSourceEditAdapter : RecyclerView.Adapter<BookSourceEditAdapter.MyViewHolder>() {
|
||||
|
||||
val editEntityMaxLine = AppConfig.sourceEditMaxLine
|
||||
|
||||
var editEntities: ArrayList<EditEntity> = ArrayList()
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
set(value) {
|
||||
@@ -39,10 +42,12 @@ class BookSourceEditAdapter : RecyclerView.Adapter<BookSourceEditAdapter.MyViewH
|
||||
return editEntities.size
|
||||
}
|
||||
|
||||
class MyViewHolder(val binding: ItemSourceEditBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||
inner class MyViewHolder(val binding: ItemSourceEditBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
fun bind(editEntity: EditEntity) = binding.run {
|
||||
editText.setTag(R.id.tag, editEntity.key)
|
||||
editText.maxLines = editEntityMaxLine
|
||||
if (editText.getTag(R.id.tag1) == null) {
|
||||
val listener = object : View.OnAttachStateChangeListener {
|
||||
override fun onViewAttachedToWindow(v: View) {
|
||||
|
||||
@@ -60,6 +60,7 @@ class OtherConfigFragment : PreferenceFragment(),
|
||||
}
|
||||
upPreferenceSummary(PreferKey.checkSource, CheckSource.summary)
|
||||
upPreferenceSummary(PreferKey.bitmapCacheSize, AppConfig.bitmapCacheSize.toString())
|
||||
upPreferenceSummary(PreferKey.sourceEditMaxLine, AppConfig.sourceEditMaxLine.toString())
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
@@ -119,7 +120,16 @@ class OtherConfigFragment : PreferenceFragment(),
|
||||
ImageProvider.bitmapLruCache.resize(ImageProvider.cacheSize)
|
||||
}
|
||||
}
|
||||
|
||||
PreferKey.sourceEditMaxLine -> {
|
||||
NumberPickerDialog(requireContext())
|
||||
.setTitle(getString(R.string.source_edit_text_max_line))
|
||||
.setMaxValue(99)
|
||||
.setMinValue(10)
|
||||
.setValue(AppConfig.sourceEditMaxLine)
|
||||
.show {
|
||||
AppConfig.sourceEditMaxLine = it
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.onPreferenceTreeClick(preference)
|
||||
}
|
||||
@@ -160,6 +170,9 @@ class OtherConfigFragment : PreferenceFragment(),
|
||||
PreferKey.bitmapCacheSize -> {
|
||||
upPreferenceSummary(key, AppConfig.bitmapCacheSize.toString())
|
||||
}
|
||||
PreferKey.sourceEditMaxLine -> {
|
||||
upPreferenceSummary(key, AppConfig.sourceEditMaxLine.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,12 +9,15 @@ import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import io.legado.app.R
|
||||
import io.legado.app.databinding.ItemSourceEditBinding
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.ui.widget.code.addJsPattern
|
||||
import io.legado.app.ui.widget.code.addJsonPattern
|
||||
import io.legado.app.ui.widget.code.addLegadoPattern
|
||||
|
||||
class RssSourceEditAdapter : RecyclerView.Adapter<RssSourceEditAdapter.MyViewHolder>() {
|
||||
|
||||
val editEntityMaxLine = AppConfig.sourceEditMaxLine
|
||||
|
||||
var editEntities: ArrayList<EditEntity> = ArrayList()
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
set(value) {
|
||||
@@ -39,9 +42,11 @@ class RssSourceEditAdapter : RecyclerView.Adapter<RssSourceEditAdapter.MyViewHol
|
||||
return editEntities.size
|
||||
}
|
||||
|
||||
class MyViewHolder(val binding: ItemSourceEditBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||
inner class MyViewHolder(val binding: ItemSourceEditBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
fun bind(editEntity: EditEntity) = binding.run {
|
||||
editText.maxLines = editEntityMaxLine
|
||||
if (editText.getTag(R.id.tag1) == null) {
|
||||
val listener = object : View.OnAttachStateChangeListener {
|
||||
override fun onViewAttachedToWindow(v: View) {
|
||||
|
||||
Reference in New Issue
Block a user