From c175f6d140463ce8857f96651a0dba8c6849da5b Mon Sep 17 00:00:00 2001 From: Pierrot Date: Fri, 22 Feb 2019 10:55:02 +0100 Subject: [PATCH] Fix sharing of backup files --- .../pierrox/lightning_launcher/activities/BackupRestore.java | 5 ++++- .../net/pierrox/lightning_launcher/util/FileProvider.java | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/BackupRestore.java b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/BackupRestore.java index f2d36fa..a35190e 100644 --- a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/BackupRestore.java +++ b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/activities/BackupRestore.java @@ -22,6 +22,7 @@ import net.pierrox.lightning_launcher.data.Item; import net.pierrox.lightning_launcher.data.Page; import net.pierrox.lightning_launcher.engine.LightningEngine; import net.pierrox.lightning_launcher.data.Utils; +import net.pierrox.lightning_launcher.util.FileProvider; import net.pierrox.lightning_launcher_extreme.R; import org.json.JSONObject; @@ -297,8 +298,10 @@ public class BackupRestore extends ResourceWrapperActivity implements View.OnCli case 3: Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); - shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(FileUtils.LL_EXT_DIR +"/"+mArchiveName))); + Uri uri = FileProvider.getUriForFile(new File(FileUtils.LL_EXT_DIR +"/"+mArchiveName)); + shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.setType("application/zip"); + shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.br_s))); break; case 4: diff --git a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/util/FileProvider.java b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/util/FileProvider.java index a1d285e..b70f3dd 100644 --- a/app/llx/app/src/main/java/net/pierrox/lightning_launcher/util/FileProvider.java +++ b/app/llx/app/src/main/java/net/pierrox/lightning_launcher/util/FileProvider.java @@ -50,7 +50,7 @@ public class FileProvider extends ContentProvider { @Override public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException { String path = uri.getPath().substring(1); - if(!path.startsWith(FileUtils.LL_TMP_DIR.getAbsolutePath())) { + if(!path.startsWith(FileUtils.LL_TMP_DIR.getAbsolutePath()) && !path.startsWith(FileUtils.LL_EXT_DIR.getAbsolutePath())) { throw new IllegalArgumentException(); }