mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
优化
This commit is contained in:
parent
b30e266d6e
commit
5216e36fbf
@ -80,6 +80,7 @@ object PreferKey {
|
|||||||
const val autoClearExpired = "autoClearExpired"
|
const val autoClearExpired = "autoClearExpired"
|
||||||
const val autoChangeSource = "autoChangeSource"
|
const val autoChangeSource = "autoChangeSource"
|
||||||
const val importKeepName = "importKeepName"
|
const val importKeepName = "importKeepName"
|
||||||
|
const val importKeepGroup = "importKeepGroup"
|
||||||
const val screenOrientation = "screenOrientation"
|
const val screenOrientation = "screenOrientation"
|
||||||
const val syncBookProgress = "syncBookProgress"
|
const val syncBookProgress = "syncBookProgress"
|
||||||
const val cronet = "Cronet"
|
const val cronet = "Cronet"
|
||||||
|
@ -331,6 +331,7 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val importKeepName get() = appCtx.getPrefBoolean(PreferKey.importKeepName)
|
val importKeepName get() = appCtx.getPrefBoolean(PreferKey.importKeepName)
|
||||||
|
val importKeepGroup get() = appCtx.getPrefBoolean(PreferKey.importKeepGroup)
|
||||||
|
|
||||||
var preDownloadNum
|
var preDownloadNum
|
||||||
get() = appCtx.getPrefInt(PreferKey.preDownloadNum, 10)
|
get() = appCtx.getPrefInt(PreferKey.preDownloadNum, 10)
|
||||||
|
@ -138,18 +138,24 @@ class ImportBookSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_vie
|
|||||||
private fun initMenu() {
|
private fun initMenu() {
|
||||||
binding.toolBar.setOnMenuItemClickListener(this)
|
binding.toolBar.setOnMenuItemClickListener(this)
|
||||||
binding.toolBar.inflateMenu(R.menu.import_source)
|
binding.toolBar.inflateMenu(R.menu.import_source)
|
||||||
binding.toolBar.menu.findItem(R.id.menu_Keep_original_name)
|
binding.toolBar.menu.findItem(R.id.menu_keep_original_name)
|
||||||
?.isChecked = AppConfig.importKeepName
|
?.isChecked = AppConfig.importKeepName
|
||||||
|
binding.toolBar.menu.findItem(R.id.menu_keep_group)
|
||||||
|
?.isChecked = AppConfig.importKeepGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
override fun onMenuItemClick(item: MenuItem): Boolean {
|
override fun onMenuItemClick(item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.menu_new_group -> alertCustomGroup(item)
|
R.id.menu_new_group -> alertCustomGroup(item)
|
||||||
R.id.menu_Keep_original_name -> {
|
R.id.menu_keep_original_name -> {
|
||||||
item.isChecked = !item.isChecked
|
item.isChecked = !item.isChecked
|
||||||
putPrefBoolean(PreferKey.importKeepName, item.isChecked)
|
putPrefBoolean(PreferKey.importKeepName, item.isChecked)
|
||||||
}
|
}
|
||||||
|
R.id.menu_keep_group -> {
|
||||||
|
item.isChecked = !item.isChecked
|
||||||
|
putPrefBoolean(PreferKey.importKeepGroup, item.isChecked)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -54,16 +54,19 @@ class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
|
|||||||
execute {
|
execute {
|
||||||
val group = groupName?.trim()
|
val group = groupName?.trim()
|
||||||
val keepName = AppConfig.importKeepName
|
val keepName = AppConfig.importKeepName
|
||||||
|
val keepGroup = AppConfig.importKeepGroup
|
||||||
val selectSource = arrayListOf<BookSource>()
|
val selectSource = arrayListOf<BookSource>()
|
||||||
selectStatus.forEachIndexed { index, b ->
|
selectStatus.forEachIndexed { index, b ->
|
||||||
if (b) {
|
if (b) {
|
||||||
val source = allSources[index]
|
val source = allSources[index]
|
||||||
if (keepName) {
|
checkSources[index]?.let {
|
||||||
checkSources[index]?.let {
|
if (keepName) {
|
||||||
source.bookSourceName = it.bookSourceName
|
source.bookSourceName = it.bookSourceName
|
||||||
source.bookSourceGroup = it.bookSourceGroup
|
|
||||||
source.customOrder = it.customOrder
|
|
||||||
}
|
}
|
||||||
|
if (keepGroup) {
|
||||||
|
source.bookSourceGroup = it.bookSourceGroup
|
||||||
|
}
|
||||||
|
source.customOrder = it.customOrder
|
||||||
}
|
}
|
||||||
if (!group.isNullOrEmpty()) {
|
if (!group.isNullOrEmpty()) {
|
||||||
if (isAddGroup) {
|
if (isAddGroup) {
|
||||||
|
@ -122,7 +122,7 @@ class ImportReplaceRuleDialog() : BaseDialogFragment(R.layout.dialog_recycler_vi
|
|||||||
override fun onMenuItemClick(item: MenuItem?): Boolean {
|
override fun onMenuItemClick(item: MenuItem?): Boolean {
|
||||||
when (item?.itemId) {
|
when (item?.itemId) {
|
||||||
R.id.menu_new_group -> alertCustomGroup(item)
|
R.id.menu_new_group -> alertCustomGroup(item)
|
||||||
R.id.menu_Keep_original_name -> {
|
R.id.menu_keep_original_name -> {
|
||||||
item.isChecked = !item.isChecked
|
item.isChecked = !item.isChecked
|
||||||
putPrefBoolean(PreferKey.importKeepName, item.isChecked)
|
putPrefBoolean(PreferKey.importKeepName, item.isChecked)
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import io.legado.app.data.appDb
|
|||||||
import io.legado.app.data.entities.ReplaceRule
|
import io.legado.app.data.entities.ReplaceRule
|
||||||
import io.legado.app.exception.NoStackTraceException
|
import io.legado.app.exception.NoStackTraceException
|
||||||
import io.legado.app.help.ReplaceAnalyzer
|
import io.legado.app.help.ReplaceAnalyzer
|
||||||
import io.legado.app.help.config.AppConfig
|
|
||||||
import io.legado.app.help.http.newCallResponseBody
|
import io.legado.app.help.http.newCallResponseBody
|
||||||
import io.legado.app.help.http.okHttpClient
|
import io.legado.app.help.http.okHttpClient
|
||||||
import io.legado.app.help.http.text
|
import io.legado.app.help.http.text
|
||||||
@ -52,18 +51,10 @@ class ImportReplaceRuleViewModel(app: Application) : BaseViewModel(app) {
|
|||||||
fun importSelect(finally: () -> Unit) {
|
fun importSelect(finally: () -> Unit) {
|
||||||
execute {
|
execute {
|
||||||
val group = groupName?.trim()
|
val group = groupName?.trim()
|
||||||
val keepName = AppConfig.importKeepName
|
|
||||||
val selectRules = arrayListOf<ReplaceRule>()
|
val selectRules = arrayListOf<ReplaceRule>()
|
||||||
selectStatus.forEachIndexed { index, b ->
|
selectStatus.forEachIndexed { index, b ->
|
||||||
if (b) {
|
if (b) {
|
||||||
val rule = allRules[index]
|
val rule = allRules[index]
|
||||||
if (keepName) {
|
|
||||||
checkRules[index]?.let {
|
|
||||||
rule.name = it.name
|
|
||||||
rule.group = it.group
|
|
||||||
rule.order = it.order
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!group.isNullOrEmpty()) {
|
if (!group.isNullOrEmpty()) {
|
||||||
if (isAddGroup) {
|
if (isAddGroup) {
|
||||||
val groups = linkedSetOf<String>()
|
val groups = linkedSetOf<String>()
|
||||||
|
@ -137,18 +137,24 @@ class ImportRssSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_view
|
|||||||
private fun initMenu() {
|
private fun initMenu() {
|
||||||
binding.toolBar.setOnMenuItemClickListener(this)
|
binding.toolBar.setOnMenuItemClickListener(this)
|
||||||
binding.toolBar.inflateMenu(R.menu.import_source)
|
binding.toolBar.inflateMenu(R.menu.import_source)
|
||||||
binding.toolBar.menu.findItem(R.id.menu_Keep_original_name)?.isChecked =
|
binding.toolBar.menu.findItem(R.id.menu_keep_original_name)?.isChecked =
|
||||||
AppConfig.importKeepName
|
AppConfig.importKeepName
|
||||||
|
binding.toolBar.menu.findItem(R.id.menu_keep_group)?.isChecked =
|
||||||
|
AppConfig.importKeepGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
override fun onMenuItemClick(item: MenuItem): Boolean {
|
override fun onMenuItemClick(item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.menu_new_group -> alertCustomGroup(item)
|
R.id.menu_new_group -> alertCustomGroup(item)
|
||||||
R.id.menu_Keep_original_name -> {
|
R.id.menu_keep_original_name -> {
|
||||||
item.isChecked = !item.isChecked
|
item.isChecked = !item.isChecked
|
||||||
putPrefBoolean(PreferKey.importKeepName, item.isChecked)
|
putPrefBoolean(PreferKey.importKeepName, item.isChecked)
|
||||||
}
|
}
|
||||||
|
R.id.menu_keep_group -> {
|
||||||
|
item.isChecked = !item.isChecked
|
||||||
|
putPrefBoolean(PreferKey.importKeepGroup, item.isChecked)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -51,16 +51,19 @@ class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) {
|
|||||||
execute {
|
execute {
|
||||||
val group = groupName?.trim()
|
val group = groupName?.trim()
|
||||||
val keepName = AppConfig.importKeepName
|
val keepName = AppConfig.importKeepName
|
||||||
|
val keepGroup = AppConfig.importKeepGroup
|
||||||
val selectSource = arrayListOf<RssSource>()
|
val selectSource = arrayListOf<RssSource>()
|
||||||
selectStatus.forEachIndexed { index, b ->
|
selectStatus.forEachIndexed { index, b ->
|
||||||
if (b) {
|
if (b) {
|
||||||
val source = allSources[index]
|
val source = allSources[index]
|
||||||
if (keepName) {
|
checkSources[index]?.let {
|
||||||
checkSources[index]?.let {
|
if (keepName) {
|
||||||
source.sourceName = it.sourceName
|
source.sourceName = it.sourceName
|
||||||
source.sourceGroup = it.sourceGroup
|
|
||||||
source.customOrder = it.customOrder
|
|
||||||
}
|
}
|
||||||
|
if (keepGroup) {
|
||||||
|
source.sourceGroup = it.sourceGroup
|
||||||
|
}
|
||||||
|
source.customOrder = it.customOrder
|
||||||
}
|
}
|
||||||
if (!group.isNullOrEmpty()) {
|
if (!group.isNullOrEmpty()) {
|
||||||
if (isAddGroup) {
|
if (isAddGroup) {
|
||||||
|
@ -9,10 +9,4 @@
|
|||||||
app:showAsAction="always"
|
app:showAsAction="always"
|
||||||
tools:ignore="AlwaysShowAction" />
|
tools:ignore="AlwaysShowAction" />
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_Keep_original_name"
|
|
||||||
android:title="@string/keep_original_name"
|
|
||||||
android:checkable="true"
|
|
||||||
app:showAsAction="never" />
|
|
||||||
|
|
||||||
</menu>
|
</menu>
|
@ -10,9 +10,15 @@
|
|||||||
tools:ignore="AlwaysShowAction" />
|
tools:ignore="AlwaysShowAction" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_Keep_original_name"
|
android:id="@+id/menu_keep_original_name"
|
||||||
android:title="@string/keep_original_name"
|
android:title="@string/keep_original_name"
|
||||||
android:checkable="true"
|
android:checkable="true"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_keep_group"
|
||||||
|
android:title="@string/keep_group"
|
||||||
|
android:checkable="true"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
</menu>
|
</menu>
|
@ -1079,4 +1079,5 @@
|
|||||||
<string name="show_rule">显示规则(showRule)</string>
|
<string name="show_rule">显示规则(showRule)</string>
|
||||||
<string name="config_txt_toc_rule">配置 TXT 目录规则</string>
|
<string name="config_txt_toc_rule">配置 TXT 目录规则</string>
|
||||||
<string name="import_dict_rule">导入字典规则</string>
|
<string name="import_dict_rule">导入字典规则</string>
|
||||||
|
<string name="keep_group">保留分组</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1082,4 +1082,5 @@
|
|||||||
<string name="show_rule">显示规则(showRule)</string>
|
<string name="show_rule">显示规则(showRule)</string>
|
||||||
<string name="config_txt_toc_rule">配置 TXT 目录规则</string>
|
<string name="config_txt_toc_rule">配置 TXT 目录规则</string>
|
||||||
<string name="import_dict_rule">导入字典规则</string>
|
<string name="import_dict_rule">导入字典规则</string>
|
||||||
|
<string name="keep_group">保留分组</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1082,4 +1082,5 @@
|
|||||||
<string name="show_rule">显示规则(showRule)</string>
|
<string name="show_rule">显示规则(showRule)</string>
|
||||||
<string name="config_txt_toc_rule">配置 TXT 目录规则</string>
|
<string name="config_txt_toc_rule">配置 TXT 目录规则</string>
|
||||||
<string name="import_dict_rule">导入字典规则</string>
|
<string name="import_dict_rule">导入字典规则</string>
|
||||||
|
<string name="keep_group">保留分组</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1079,4 +1079,5 @@
|
|||||||
<string name="show_rule">显示规则(showRule)</string>
|
<string name="show_rule">显示规则(showRule)</string>
|
||||||
<string name="config_txt_toc_rule">配置 TXT 目录规则</string>
|
<string name="config_txt_toc_rule">配置 TXT 目录规则</string>
|
||||||
<string name="import_dict_rule">导入字典规则</string>
|
<string name="import_dict_rule">导入字典规则</string>
|
||||||
|
<string name="keep_group">保留分组</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1081,4 +1081,5 @@
|
|||||||
<string name="show_rule">显示规则(showRule)</string>
|
<string name="show_rule">显示规则(showRule)</string>
|
||||||
<string name="config_txt_toc_rule">配置 TXT 目录规则</string>
|
<string name="config_txt_toc_rule">配置 TXT 目录规则</string>
|
||||||
<string name="import_dict_rule">导入字典规则</string>
|
<string name="import_dict_rule">导入字典规则</string>
|
||||||
|
<string name="keep_group">保留分组</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1081,4 +1081,5 @@
|
|||||||
<string name="show_rule">显示规则(showRule)</string>
|
<string name="show_rule">显示规则(showRule)</string>
|
||||||
<string name="config_txt_toc_rule">配置 TXT 目录规则</string>
|
<string name="config_txt_toc_rule">配置 TXT 目录规则</string>
|
||||||
<string name="import_dict_rule">导入字典规则</string>
|
<string name="import_dict_rule">导入字典规则</string>
|
||||||
|
<string name="keep_group">保留分组</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1077,9 +1077,10 @@
|
|||||||
<string name="source_tab_list">List</string>
|
<string name="source_tab_list">List</string>
|
||||||
<string name="dict_rule">Dict rule</string>
|
<string name="dict_rule">Dict rule</string>
|
||||||
<string name="config_dict_rule">Config dict rule</string>
|
<string name="config_dict_rule">Config dict rule</string>
|
||||||
<string name="create">新建</string>
|
<string name="create">Create</string>
|
||||||
<string name="url_rule">url规则(urlRule)</string>
|
<string name="url_rule">url规则(urlRule)</string>
|
||||||
<string name="show_rule">显示规则(showRule)</string>
|
<string name="show_rule">显示规则(showRule)</string>
|
||||||
<string name="config_txt_toc_rule">配置 TXT 目录规则</string>
|
<string name="config_txt_toc_rule">配置 TXT 目录规则</string>
|
||||||
<string name="import_dict_rule">导入字典规则</string>
|
<string name="import_dict_rule">Import dict rule</string>
|
||||||
|
<string name="keep_group">Keep group</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user