|
|
@ -18,6 +18,7 @@ import io.legado.app.databinding.ActivityBookSourceEditBinding |
|
|
|
import io.legado.app.help.config.LocalConfig |
|
|
|
import io.legado.app.help.config.LocalConfig |
|
|
|
import io.legado.app.lib.dialogs.SelectItem |
|
|
|
import io.legado.app.lib.dialogs.SelectItem |
|
|
|
import io.legado.app.lib.dialogs.alert |
|
|
|
import io.legado.app.lib.dialogs.alert |
|
|
|
|
|
|
|
import io.legado.app.lib.theme.accentColor |
|
|
|
import io.legado.app.lib.theme.backgroundColor |
|
|
|
import io.legado.app.lib.theme.backgroundColor |
|
|
|
import io.legado.app.lib.theme.primaryColor |
|
|
|
import io.legado.app.lib.theme.primaryColor |
|
|
|
import io.legado.app.ui.book.source.debug.BookSourceDebugActivity |
|
|
|
import io.legado.app.ui.book.source.debug.BookSourceDebugActivity |
|
|
@ -47,7 +48,7 @@ class BookSourceEditActivity : |
|
|
|
private val qrCodeResult = registerForActivityResult(QrCodeResult()) { |
|
|
|
private val qrCodeResult = registerForActivityResult(QrCodeResult()) { |
|
|
|
it ?: return@registerForActivityResult |
|
|
|
it ?: return@registerForActivityResult |
|
|
|
viewModel.importSource(it) { source -> |
|
|
|
viewModel.importSource(it) { source -> |
|
|
|
upRecyclerView(source) |
|
|
|
upSourceView(source) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
private val selectDoc = registerForActivityResult(HandleFileContract()) { |
|
|
|
private val selectDoc = registerForActivityResult(HandleFileContract()) { |
|
|
@ -68,7 +69,7 @@ class BookSourceEditActivity : |
|
|
|
softKeyboardTool.attachToWindow(window) |
|
|
|
softKeyboardTool.attachToWindow(window) |
|
|
|
initView() |
|
|
|
initView() |
|
|
|
viewModel.initData(intent) { |
|
|
|
viewModel.initData(intent) { |
|
|
|
upRecyclerView() |
|
|
|
upSourceView() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -109,9 +110,10 @@ class BookSourceEditActivity : |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
R.id.menu_clear_cookie -> viewModel.clearCookie(getSource().bookSourceUrl) |
|
|
|
R.id.menu_auto_complete -> viewModel.autoComplete = !viewModel.autoComplete |
|
|
|
R.id.menu_auto_complete -> viewModel.autoComplete = !viewModel.autoComplete |
|
|
|
R.id.menu_copy_source -> sendToClip(GSON.toJson(getSource())) |
|
|
|
R.id.menu_copy_source -> sendToClip(GSON.toJson(getSource())) |
|
|
|
R.id.menu_paste_source -> viewModel.pasteSource { upRecyclerView(it) } |
|
|
|
R.id.menu_paste_source -> viewModel.pasteSource { upSourceView(it) } |
|
|
|
R.id.menu_qr_code_camera -> qrCodeResult.launch() |
|
|
|
R.id.menu_qr_code_camera -> qrCodeResult.launch() |
|
|
|
R.id.menu_share_str -> share(GSON.toJson(getSource())) |
|
|
|
R.id.menu_share_str -> share(GSON.toJson(getSource())) |
|
|
|
R.id.menu_share_qr -> shareWithQr( |
|
|
|
R.id.menu_share_qr -> shareWithQr( |
|
|
@ -139,6 +141,7 @@ class BookSourceEditActivity : |
|
|
|
binding.recyclerView.layoutManager = LinearLayoutManager(this) |
|
|
|
binding.recyclerView.layoutManager = LinearLayoutManager(this) |
|
|
|
binding.recyclerView.adapter = adapter |
|
|
|
binding.recyclerView.adapter = adapter |
|
|
|
binding.tabLayout.setBackgroundColor(backgroundColor) |
|
|
|
binding.tabLayout.setBackgroundColor(backgroundColor) |
|
|
|
|
|
|
|
binding.tabLayout.setSelectedTabIndicatorColor(accentColor) |
|
|
|
binding.tabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener { |
|
|
|
binding.tabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener { |
|
|
|
override fun onTabReselected(tab: TabLayout.Tab?) { |
|
|
|
override fun onTabReselected(tab: TabLayout.Tab?) { |
|
|
|
|
|
|
|
|
|
|
@ -186,7 +189,7 @@ class BookSourceEditActivity : |
|
|
|
binding.recyclerView.scrollToPosition(0) |
|
|
|
binding.recyclerView.scrollToPosition(0) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun upRecyclerView(source: BookSource? = viewModel.bookSource) { |
|
|
|
private fun upSourceView(source: BookSource? = viewModel.bookSource) { |
|
|
|
source?.let { |
|
|
|
source?.let { |
|
|
|
binding.cbIsEnable.isChecked = it.enabled |
|
|
|
binding.cbIsEnable.isChecked = it.enabled |
|
|
|
binding.cbIsEnableFind.isChecked = it.enabledExplore |
|
|
|
binding.cbIsEnableFind.isChecked = it.enabledExplore |
|
|
|