diff --git a/app/src/main/java/io/legado/app/data/entities/RuleSub.kt b/app/src/main/java/io/legado/app/data/entities/RuleSub.kt index 08aa579c6..2b43787fe 100644 --- a/app/src/main/java/io/legado/app/data/entities/RuleSub.kt +++ b/app/src/main/java/io/legado/app/data/entities/RuleSub.kt @@ -13,13 +13,4 @@ data class RuleSub( var customOrder: Int = 0, var autoUpdate: Boolean = false, var update: Long = System.currentTimeMillis() -) { - - fun setType(type: Type) { - this.type = type.ordinal - } - - enum class Type { - BookSource, RssSource, ReplaceRule - } -} +) diff --git a/app/src/main/java/io/legado/app/ui/rss/subscription/RuleSubActivity.kt b/app/src/main/java/io/legado/app/ui/rss/subscription/RuleSubActivity.kt index 9c3e4d3f6..576774bcd 100644 --- a/app/src/main/java/io/legado/app/ui/rss/subscription/RuleSubActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/subscription/RuleSubActivity.kt @@ -11,7 +11,7 @@ import io.legado.app.R import io.legado.app.base.BaseActivity import io.legado.app.data.entities.RuleSub import io.legado.app.databinding.ActivityRuleSubBinding -import io.legado.app.databinding.DialogSourceSubEditBinding +import io.legado.app.databinding.DialogRuleSubEditBinding import io.legado.app.lib.dialogs.alert import io.legado.app.ui.association.ImportBookSourceActivity import io.legado.app.ui.association.ImportRssSourceActivity @@ -20,6 +20,9 @@ import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.launch import org.jetbrains.anko.startActivity +/** + * 规则订阅界面 + */ class RuleSubActivity : BaseActivity(), RuleSubAdapter.Callback { @@ -69,7 +72,7 @@ class RuleSubActivity : BaseActivity(), override fun openSubscription(ruleSub: RuleSub) { when (ruleSub.type) { - RuleSub.Type.RssSource.ordinal -> { + 1 -> { startActivity("source" to ruleSub.url) } else -> { @@ -80,20 +83,14 @@ class RuleSubActivity : BaseActivity(), override fun editSubscription(ruleSub: RuleSub) { alert(R.string.rule_subscription) { - val alertBinding = DialogSourceSubEditBinding.inflate(layoutInflater).apply { - when (ruleSub.type) { - RuleSub.Type.RssSource.ordinal -> rgType.check(R.id.rb_rss_source) - else -> rgType.check(R.id.rb_book_source) - } + val alertBinding = DialogRuleSubEditBinding.inflate(layoutInflater).apply { + spType.setSelection(ruleSub.type) etName.setText(ruleSub.name) etUrl.setText(ruleSub.url) } customView = alertBinding.root okButton { - when (alertBinding.rgType.checkedRadioButtonId) { - R.id.rb_rss_source -> ruleSub.setType(RuleSub.Type.RssSource) - else -> ruleSub.setType(RuleSub.Type.BookSource) - } + ruleSub.type = alertBinding.spType.selectedItemPosition ruleSub.name = alertBinding.etName.text?.toString() ?: "" ruleSub.url = alertBinding.etUrl.text?.toString() ?: "" launch(IO) { diff --git a/app/src/main/java/io/legado/app/ui/rss/subscription/RuleSubAdapter.kt b/app/src/main/java/io/legado/app/ui/rss/subscription/RuleSubAdapter.kt index e8bbd2b6d..2269e4756 100644 --- a/app/src/main/java/io/legado/app/ui/rss/subscription/RuleSubAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/rss/subscription/RuleSubAdapter.kt @@ -9,27 +9,29 @@ import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.RuleSub -import io.legado.app.databinding.ItemSourceSubBinding +import io.legado.app.databinding.ItemRuleSubBinding import io.legado.app.ui.widget.recycler.ItemTouchCallback import org.jetbrains.anko.sdk27.listeners.onClick import java.util.* class RuleSubAdapter(context: Context, val callBack: Callback) : - SimpleRecyclerAdapter(context), + SimpleRecyclerAdapter(context), ItemTouchCallback.Callback { + private val typeArray = context.resources.getStringArray(R.array.rule_type) + override fun convert( holder: ItemViewHolder, - binding: ItemSourceSubBinding, + binding: ItemRuleSubBinding, item: RuleSub, payloads: MutableList ) { - binding.tvType.text = RuleSub.Type.values()[item.type].name + binding.tvType.text = typeArray[item.type] binding.tvName.text = item.name binding.tvUrl.text = item.url } - override fun registerListener(holder: ItemViewHolder, binding: ItemSourceSubBinding) { + override fun registerListener(holder: ItemViewHolder, binding: ItemRuleSubBinding) { binding.root.onClick { callBack.openSubscription(getItem(holder.layoutPosition)!!) } @@ -54,8 +56,8 @@ class RuleSubAdapter(context: Context, val callBack: Callback) : popupMenu.show() } - override fun getViewBinding(parent: ViewGroup): ItemSourceSubBinding { - return ItemSourceSubBinding.inflate(inflater, parent, false) + override fun getViewBinding(parent: ViewGroup): ItemRuleSubBinding { + return ItemRuleSubBinding.inflate(inflater, parent, false) } override fun onMove(srcPosition: Int, targetPosition: Int): Boolean { diff --git a/app/src/main/res/layout/activity_rule_sub.xml b/app/src/main/res/layout/activity_rule_sub.xml index 1fdf1049b..b4704f5eb 100644 --- a/app/src/main/res/layout/activity_rule_sub.xml +++ b/app/src/main/res/layout/activity_rule_sub.xml @@ -21,7 +21,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" - tools:listitem="@layout/item_source_sub" /> + tools:listitem="@layout/item_rule_sub" /> - - + android:text="@string/book_type" + android:padding="3dp" + tools:ignore="RtlHardcoded" /> - + android:entries="@array/rule_type" + app:theme="@style/Spinner" /> - + + + 文本 + 音頻 + + 跟隨系統 亮色主題 @@ -60,4 +65,9 @@ 英文 + + 書源 + 訂閲源 + + \ No newline at end of file diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index b42d6e2a3..771d3fa6a 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -592,8 +592,6 @@ 封面換源 選擇本地圖片 類型: - 文本 - 音頻 後台 正在導入 正在導出 diff --git a/app/src/main/res/values-zh-rTW/arrays.xml b/app/src/main/res/values-zh-rTW/arrays.xml index af03a5205..0597ef775 100644 --- a/app/src/main/res/values-zh-rTW/arrays.xml +++ b/app/src/main/res/values-zh-rTW/arrays.xml @@ -1,8 +1,8 @@ - @string/book_type_text - @string/book_type_audio + 文字 + 音訊 @@ -101,4 +101,9 @@ 英文 + + 書源 + 訂閲源 + + diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 4c36af612..09fef5660 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -594,8 +594,6 @@ 封面換源 選擇本機圖片 類型: - 文字 - 音訊 後台 正在匯入 正在匯出 diff --git a/app/src/main/res/values-zh/arrays.xml b/app/src/main/res/values-zh/arrays.xml index 0046aba58..2f8b4273f 100644 --- a/app/src/main/res/values-zh/arrays.xml +++ b/app/src/main/res/values-zh/arrays.xml @@ -1,8 +1,8 @@ - @string/book_type_text - @string/book_type_audio + 文本 + 音频 @@ -101,4 +101,9 @@ 英文 + + 书源 + 订阅源 + + \ No newline at end of file diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 0b5f52339..604c05b2c 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -602,8 +602,6 @@ 封面换源 选择本地图片 类型: - 文本 - 音频 后台 正在导入 正在导出 diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 6ca480b12..751bba619 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -1,8 +1,8 @@ - @string/book_type_text - @string/book_type_audio + Text + Audio @@ -101,4 +101,9 @@ English + + BookSource + RssSource + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f674135aa..df57c00ab 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -603,8 +603,6 @@ Change origin Local image Type: - Text - Audio Background Importing Exporting