pull/371/head
gedoor 4 years ago
parent 4090fe4435
commit 3a5ef948c4
  1. 6
      app/src/main/java/io/legado/app/help/ThemeConfig.kt
  2. 6
      app/src/main/java/io/legado/app/ui/config/ThemeListDialog.kt

@ -41,10 +41,12 @@ object ThemeConfig {
} }
} }
fun addConfig(json: String) { fun addConfig(json: String): Boolean {
GSON.fromJsonObject<Config>(json)?.let { GSON.fromJsonObject<Config>(json.trim { it < ' ' })?.let {
addConfig(it) addConfig(it)
return true
} }
return false
} }
private fun addConfig(newConfig: Config) { private fun addConfig(newConfig: Config) {

@ -21,6 +21,7 @@ import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.GSON import io.legado.app.utils.GSON
import io.legado.app.utils.applyTint import io.legado.app.utils.applyTint
import io.legado.app.utils.getClipText import io.legado.app.utils.getClipText
import io.legado.app.utils.toast
import kotlinx.android.synthetic.main.dialog_recycler_view.* import kotlinx.android.synthetic.main.dialog_recycler_view.*
import kotlinx.android.synthetic.main.item_theme_config.view.* import kotlinx.android.synthetic.main.item_theme_config.view.*
import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.sdk27.listeners.onClick
@ -74,8 +75,11 @@ class ThemeListDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
when (item?.itemId) { when (item?.itemId) {
R.id.menu_import -> { R.id.menu_import -> {
requireContext().getClipText()?.let { requireContext().getClipText()?.let {
ThemeConfig.addConfig(it) if (ThemeConfig.addConfig(it)) {
initData() initData()
} else {
toast("格式不对,添加失败")
}
} }
} }
} }

Loading…
Cancel
Save