|
|
|
@ -122,12 +122,14 @@ class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity |
|
|
|
|
val lastPath = AppConfig.importBookPath |
|
|
|
|
when { |
|
|
|
|
lastPath.isNullOrEmpty() -> { |
|
|
|
|
tv_empty_msg.visible() |
|
|
|
|
FilePicker.selectFolder(this, requestCodeSelectFolder) |
|
|
|
|
} |
|
|
|
|
lastPath.isContentPath() -> { |
|
|
|
|
val rootUri = Uri.parse(lastPath) |
|
|
|
|
rootDoc = DocumentFile.fromTreeUri(this, rootUri) |
|
|
|
|
if (rootDoc == null) { |
|
|
|
|
tv_empty_msg.visible() |
|
|
|
|
FilePicker.selectFolder(this, requestCodeSelectFolder) |
|
|
|
|
} else { |
|
|
|
|
subDocs.clear() |
|
|
|
@ -135,9 +137,12 @@ class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Build.VERSION.SDK_INT > Build.VERSION_CODES.Q -> { |
|
|
|
|
tv_empty_msg.visible() |
|
|
|
|
FilePicker.selectFolder(this, requestCodeSelectFolder) |
|
|
|
|
} |
|
|
|
|
else -> PermissionsCompat.Builder(this) |
|
|
|
|
else -> { |
|
|
|
|
tv_empty_msg.visible() |
|
|
|
|
PermissionsCompat.Builder(this) |
|
|
|
|
.addPermissions(*Permissions.Group.STORAGE) |
|
|
|
|
.rationale(R.string.tip_perm_request_storage) |
|
|
|
|
.onGranted { |
|
|
|
@ -149,11 +154,13 @@ class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity |
|
|
|
|
.request() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@SuppressLint("SetTextI18n") |
|
|
|
|
@Synchronized |
|
|
|
|
private fun upPath() { |
|
|
|
|
rootDoc?.let { rootDoc -> |
|
|
|
|
tv_empty_msg.gone() |
|
|
|
|
var path = rootDoc.name.toString() + File.separator |
|
|
|
|
var lastDoc = rootDoc |
|
|
|
|
for (doc in subDocs) { |
|
|
|
@ -183,6 +190,7 @@ class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity |
|
|
|
|
} |
|
|
|
|
} ?: let { |
|
|
|
|
if (path.isBlank()) return |
|
|
|
|
tv_empty_msg.gone() |
|
|
|
|
tv_path.text = path.replace(sdPath, "SD") |
|
|
|
|
val docList = arrayListOf<DocItem>() |
|
|
|
|
File(path).listFiles()?.forEach { |
|
|
|
|