diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index 4d07a5403..1754a047f 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -207,12 +207,23 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity private fun selectFile() { FileChooserDialog.show( supportFragmentManager, importSource, - allowExtensions = arrayOf("txt", "json") + allowExtensions = arrayOf("txt", "json"), + menus = arrayOf(getString(R.string.sys_file_picker)) ) -// val intent = Intent(Intent.ACTION_GET_CONTENT) -// intent.addCategory(Intent.CATEGORY_OPENABLE) -// intent.type = "text/*"//设置类型 -// startActivityForResult(intent, importSource) + } + + private fun selectFileSys() { + val intent = Intent(Intent.ACTION_GET_CONTENT) + intent.addCategory(Intent.CATEGORY_OPENABLE) + intent.type = "text/*"//设置类型 + startActivityForResult(intent, importSource) + } + + override fun onMenuClick(menu: String) { + super.onMenuClick(menu) + when (menu) { + getString(R.string.sys_file_picker) -> selectFileSys() + } } override fun onFilePicked(requestCode: Int, currentPath: String) { diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt index 600d09fbf..739a5438b 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt @@ -194,12 +194,23 @@ class RssSourceActivity : VMBaseActivity(R.layout.activity_r private fun selectFile() { FileChooserDialog.show( supportFragmentManager, importSource, - allowExtensions = arrayOf("txt", "json") + allowExtensions = arrayOf("txt", "json"), + menus = arrayOf(getString(R.string.sys_file_picker)) ) -// val intent = Intent(Intent.ACTION_GET_CONTENT) -// intent.addCategory(Intent.CATEGORY_OPENABLE) -// intent.type = "text/*"//设置类型 -// startActivityForResult(intent, importSource) + } + + private fun selectFileSys() { + val intent = Intent(Intent.ACTION_GET_CONTENT) + intent.addCategory(Intent.CATEGORY_OPENABLE) + intent.type = "text/*"//设置类型 + startActivityForResult(intent, importSource) + } + + override fun onMenuClick(menu: String) { + super.onMenuClick(menu) + when (menu) { + getString(R.string.sys_file_picker) -> selectFileSys() + } } override fun onFilePicked(requestCode: Int, currentPath: String) {