This commit is contained in:
kunfei 2022-10-09 20:46:25 +08:00
parent 5c530751e0
commit ea7fa4d3b3
14 changed files with 54 additions and 8 deletions

View File

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

View File

@ -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)
}
}

View File

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

View File

@ -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())
}
}
}

View File

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

View File

@ -9,7 +9,6 @@
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:maxLines="12" />
android:inputType="textMultiLine" />
</io.legado.app.ui.widget.text.TextInputLayout>

View File

@ -1023,7 +1023,7 @@
<string name="delete_review_url">删除段评URLdeleteUrl</string>
<string name="tag_explore_enabled">标志:发现已启用</string>
<string name="tag_explore_disabled">标志:发现已禁用</string>
<string name="show_read_title_addition">show read title addition area</string>
<string name="show_read_title_addition">show read title addition área</string>
<string name="read_bar_style_follow_page">read bar style follow page</string>
<string name="rule_image_decode">Decode Image(imageDecode)</string>
<string name="like_source"></string>
@ -1037,4 +1037,5 @@
<string name="local_no_group">本地未分组</string>
<string name="parallel_export_book">多线程导出TXT</string>
<string name="progress_bar_behavior">进度条行为</string>
<string name="source_edit_text_max_line">源编辑框最大行数</string>
</resources>

View File

@ -1040,4 +1040,5 @@
<string name="local_no_group">本地未分组</string>
<string name="parallel_export_book">多线程导出TXT</string>
<string name="progress_bar_behavior">进度条行为</string>
<string name="source_edit_text_max_line">源编辑框最大行数</string>
</resources>

View File

@ -1040,4 +1040,5 @@
<string name="local_no_group">本地未分组</string>
<string name="parallel_export_book">多线程导出TXT</string>
<string name="progress_bar_behavior">进度条行为</string>
<string name="source_edit_text_max_line">源编辑框最大行数</string>
</resources>

View File

@ -1037,4 +1037,5 @@
<string name="local_no_group">本地未分组</string>
<string name="parallel_export_book">多线程导出TXT</string>
<string name="progress_bar_behavior">进度条行为</string>
<string name="source_edit_text_max_line">源编辑框最大行数</string>
</resources>

View File

@ -1039,4 +1039,5 @@
<string name="local_no_group">本地未分组</string>
<string name="parallel_export_book">多线程导出TXT</string>
<string name="progress_bar_behavior">进度条行为</string>
<string name="source_edit_text_max_line">源编辑框最大行数</string>
</resources>

View File

@ -1039,4 +1039,5 @@
<string name="local_no_group">本地未分组</string>
<string name="parallel_export_book">多线程导出TXT</string>
<string name="progress_bar_behavior">进度条行为</string>
<string name="source_edit_text_max_line">源编辑框最大行数</string>
</resources>

View File

@ -1040,4 +1040,5 @@
<string name="local_no_group">本地未分组</string>
<string name="parallel_export_book">多线程导出TXT</string>
<string name="progress_bar_behavior">进度条行为</string>
<string name="source_edit_text_max_line">源编辑框最大行数</string>
</resources>

View File

@ -61,6 +61,10 @@
android:summary="@string/book_tree_uri_s"
android:title="@string/book_tree_uri_t" />
<io.legado.app.lib.prefs.Preference
android:key="sourceEditMaxLine"
android:title="@string/source_edit_text_max_line" />
<io.legado.app.lib.prefs.Preference
android:key="checkSource"
android:title="@string/check_source_config" />