From d031998123ef69f7b0bc0c048f0f3f120c0dc63e Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Tue, 22 Jun 2021 12:11:16 -0400 Subject: [PATCH] show proper error for download category --- .../instagrabber/activities/DirectorySelectActivity.java | 4 ++++ .../fragments/settings/DownloadsPreferencesFragment.java | 4 +++- app/src/main/java/awais/instagrabber/utils/DownloadUtils.java | 2 +- app/src/main/res/values/strings.xml | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/activities/DirectorySelectActivity.java b/app/src/main/java/awais/instagrabber/activities/DirectorySelectActivity.java index 7fffbfec..e0c72194 100644 --- a/app/src/main/java/awais/instagrabber/activities/DirectorySelectActivity.java +++ b/app/src/main/java/awais/instagrabber/activities/DirectorySelectActivity.java @@ -81,6 +81,10 @@ public class DirectorySelectActivity extends BaseLanguageActivity { showErrorDialog(getString(R.string.select_a_folder)); return; } + if (!"com.android.externalstorage.documents".equals(data.getData().getAuthority())) { + showErrorDialog(getString(R.string.dir_select_no_download_folder)); + return; + } AppExecutors.INSTANCE.getMainThread().execute(() -> { try { viewModel.setupSelectedDir(data); diff --git a/app/src/main/java/awais/instagrabber/fragments/settings/DownloadsPreferencesFragment.java b/app/src/main/java/awais/instagrabber/fragments/settings/DownloadsPreferencesFragment.java index 305e42c5..5842f401 100644 --- a/app/src/main/java/awais/instagrabber/fragments/settings/DownloadsPreferencesFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/settings/DownloadsPreferencesFragment.java @@ -102,7 +102,9 @@ public class DownloadsPreferencesFragment extends BasePreferencesFragment { final ConfirmDialogFragment dialogFragment = ConfirmDialogFragment.newInstance( 123, R.string.error, - "Please report this error to the developers:\n\n" + sw.toString(), + "com.android.externalstorage.documents".equals(data.getData().getAuthority()) + ? "Please report this error to the developers:\n\n" + sw.toString() + : getString(R.string.dir_select_no_download_folder), R.string.ok, 0, 0 diff --git a/app/src/main/java/awais/instagrabber/utils/DownloadUtils.java b/app/src/main/java/awais/instagrabber/utils/DownloadUtils.java index ad1382f8..d690d64d 100644 --- a/app/src/main/java/awais/instagrabber/utils/DownloadUtils.java +++ b/app/src/main/java/awais/instagrabber/utils/DownloadUtils.java @@ -68,7 +68,7 @@ public final class DownloadUtils { if (TextUtils.isEmpty(barinstaDirUri)) { throw new ReselectDocumentTreeException("folder path is null or empty"); } - if (!barinstaDirUri.startsWith("content")) { + if (!barinstaDirUri.startsWith("content://com.android.externalstorage.documents")) { // reselect the folder in selector view throw new ReselectDocumentTreeException(Uri.parse(barinstaDirUri)); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1abda3cd..41bdfa11 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -512,6 +512,7 @@ The previously selected folder does not exist now: Re-select the directory or select a new directory by clicking the button below. No folder selected! + Please choose a directory from your storage, not a category on the sidebar. Success! Please wait. Starting app… Barinsta folder Top