Skip to content

Commit

Permalink
Try to retain access to the file for enough time to upload it
Browse files Browse the repository at this point in the history
  • Loading branch information
abelgardep committed Sep 21, 2022
1 parent 6c484b7 commit a6b0dd0
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import android.content.Intent
import android.content.IntentFilter
import android.net.Uri
import android.os.Bundle
import android.os.RemoteException
import android.view.Menu
import android.view.MenuItem
import android.view.View
Expand Down Expand Up @@ -568,6 +569,15 @@ class FileDisplayActivity : FileActivity(),
val currentDir = currentDir
val remotePath = currentDir?.remotePath ?: OCFile.ROOT_PATH

// Try to retain access to that file for some time, so we have enough time to upload it
streamsToUpload.forEach { uri ->
try {
contentResolver.takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION)
} catch (remoteException: RemoteException) {
Timber.w(remoteException)
}
}

transfersViewModel.uploadFilesFromContentUri(
accountName = account.name,
listOfContentUris = streamsToUpload,
Expand Down Expand Up @@ -1618,7 +1628,7 @@ class FileDisplayActivity : FileActivity(),
}

override fun uploadFromFileSystem() {
val action = Intent(Intent.ACTION_GET_CONTENT).apply {
val action = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
setType(ALL_FILES_SAF_REGEX).addCategory(Intent.CATEGORY_OPENABLE)
putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
}
Expand Down

0 comments on commit a6b0dd0

Please sign in to comment.