|
@@ -20,7 +20,7 @@
|
|
|
*
|
|
|
*/
|
|
|
|
|
|
-package com.owncloud.android.files;
|
|
|
+package com.owncloud.android.ui.helpers;
|
|
|
|
|
|
import android.accounts.Account;
|
|
|
import android.content.ActivityNotFoundException;
|
|
@@ -40,7 +40,6 @@ import com.owncloud.android.authentication.AccountUtils;
|
|
|
import com.owncloud.android.datamodel.OCFile;
|
|
|
import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
|
|
|
import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
|
|
|
-import com.owncloud.android.lib.common.network.WebdavUtils;
|
|
|
import com.owncloud.android.lib.common.utils.Log_OC;
|
|
|
import com.owncloud.android.lib.resources.shares.OCShare;
|
|
|
import com.owncloud.android.lib.resources.shares.ShareType;
|
|
@@ -100,7 +99,6 @@ public class FileOperationsHelper {
|
|
|
}
|
|
|
} catch (IOException e) {
|
|
|
Log_OC.d(TAG, e.getMessage());
|
|
|
- return null;
|
|
|
} finally {
|
|
|
if (br != null) {
|
|
|
try {
|
|
@@ -145,8 +143,6 @@ public class FileOperationsHelper {
|
|
|
public void openFile(OCFile file) {
|
|
|
if (file != null) {
|
|
|
String storagePath = file.getStoragePath();
|
|
|
- String encodedStoragePath = WebdavUtils.encodePath(storagePath);
|
|
|
- Uri uri = Uri.parse("file://" + encodedStoragePath);
|
|
|
|
|
|
Intent openFileWithIntent = null;
|
|
|
int lastIndexOfDot = storagePath.lastIndexOf('.');
|
|
@@ -155,7 +151,10 @@ public class FileOperationsHelper {
|
|
|
String guessedMimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExt);
|
|
|
if (guessedMimeType != null) {
|
|
|
openFileWithIntent = new Intent(Intent.ACTION_VIEW);
|
|
|
- openFileWithIntent.setDataAndType(uri, guessedMimeType);
|
|
|
+ openFileWithIntent.setDataAndType(
|
|
|
+ file.getExposedFileUri(mFileActivity),
|
|
|
+ guessedMimeType
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -165,13 +164,13 @@ public class FileOperationsHelper {
|
|
|
|
|
|
if (openFileWithIntent == null) {
|
|
|
openFileWithIntent = new Intent(Intent.ACTION_VIEW);
|
|
|
- openFileWithIntent.setDataAndType(uri, file.getMimetype());
|
|
|
+ openFileWithIntent.setDataAndType(
|
|
|
+ file.getExposedFileUri(mFileActivity),
|
|
|
+ file.getMimetype()
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
- openFileWithIntent.setFlags(
|
|
|
- Intent.FLAG_GRANT_READ_URI_PERMISSION |
|
|
|
- Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
|
|
- );
|
|
|
+ openFileWithIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
|
|
|
|
|
List<ResolveInfo> launchables = mFileActivity.getPackageManager().
|
|
|
queryIntentActivities(openFileWithIntent, PackageManager.GET_INTENT_FILTERS);
|
|
@@ -495,11 +494,13 @@ public class FileOperationsHelper {
|
|
|
public void sendDownloadedFile(OCFile file) {
|
|
|
if (file != null) {
|
|
|
String storagePath = file.getStoragePath();
|
|
|
- String encodedStoragePath = WebdavUtils.encodePath(storagePath);
|
|
|
Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
|
|
|
// set MimeType
|
|
|
sendIntent.setType(file.getMimetype());
|
|
|
- sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + encodedStoragePath));
|
|
|
+ sendIntent.putExtra(
|
|
|
+ Intent.EXTRA_STREAM,
|
|
|
+ file.getExposedFileUri(mFileActivity)
|
|
|
+ );
|
|
|
sendIntent.putExtra(Intent.ACTION_SEND, true); // Send Action
|
|
|
|
|
|
// Show dialog, without the own app
|