|
|
|
|
@ -13,9 +13,14 @@ import org.koitharu.kotatsu.R
|
|
|
|
|
import org.koitharu.kotatsu.core.ui.AlertDialogFragment
|
|
|
|
|
import org.koitharu.kotatsu.core.util.ext.tryLaunch
|
|
|
|
|
import org.koitharu.kotatsu.databinding.DialogImportBinding
|
|
|
|
|
import org.koitharu.kotatsu.local.data.LocalStorageManager
|
|
|
|
|
import javax.inject.Inject
|
|
|
|
|
|
|
|
|
|
class ImportDialogFragment : AlertDialogFragment<DialogImportBinding>(), View.OnClickListener {
|
|
|
|
|
|
|
|
|
|
@Inject
|
|
|
|
|
lateinit var storageManager: LocalStorageManager
|
|
|
|
|
|
|
|
|
|
private val importFileCall = registerForActivityResult(ActivityResultContracts.OpenMultipleDocuments()) {
|
|
|
|
|
startImport(it)
|
|
|
|
|
}
|
|
|
|
|
@ -55,6 +60,9 @@ class ImportDialogFragment : AlertDialogFragment<DialogImportBinding>(), View.On
|
|
|
|
|
if (uris.isEmpty()) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
uris.forEach {
|
|
|
|
|
storageManager.takePermissions(it)
|
|
|
|
|
}
|
|
|
|
|
val ctx = requireContext()
|
|
|
|
|
ImportWorker.start(ctx, uris)
|
|
|
|
|
Toast.makeText(ctx, R.string.import_will_start_soon, Toast.LENGTH_LONG).show()
|
|
|
|
|
|