Update ImportBookActivity.kt

新增自定义“导入文件名”选项
pull/1048/head
bushixuanqi 3 years ago committed by GitHub
parent da3fb420f2
commit 3a3d0c36be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt

@ -15,8 +15,10 @@ import io.legado.app.R
import io.legado.app.base.VMBaseActivity
import io.legado.app.data.appDb
import io.legado.app.databinding.ActivityImportBookBinding
import io.legado.app.databinding.DialogEditTextBinding
import io.legado.app.help.AppConfig
import io.legado.app.lib.permission.Permissions
import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.permission.PermissionsCompat
import io.legado.app.lib.theme.backgroundColor
import io.legado.app.ui.document.FilePicker
@ -78,6 +80,7 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV
when (item.itemId) {
R.id.menu_select_folder -> selectFolder.launch(null)
R.id.menu_scan_folder -> scanFolder()
R.id.menu_import_file_name -> alertImportFileName()
}
return super.onCompatOptionsItemSelected(item)
}
@ -275,6 +278,19 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV
}
}
private fun alertImportFileName() {
alert(R.string.import_file_name) {
val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
editView.setText(AppConfig.bookImportFileName)
}
customView { alertBinding.root }
okButton {
AppConfig.bookImportFileName = alertBinding.editView.text?.toString()
}
cancelButton()
}.show()
}
private val find: (docItem: DocItem) -> Unit = {
launch {
adapter.addItem(it)

Loading…
Cancel
Save