Browse Source

show proper error for download category

renovate/org.robolectric-robolectric-4.x
Austin Huang 4 years ago
parent
commit
d031998123
No known key found for this signature in database GPG Key ID: 84C23AA04587A91F
  1. 4
      app/src/main/java/awais/instagrabber/activities/DirectorySelectActivity.java
  2. 4
      app/src/main/java/awais/instagrabber/fragments/settings/DownloadsPreferencesFragment.java
  3. 2
      app/src/main/java/awais/instagrabber/utils/DownloadUtils.java
  4. 1
      app/src/main/res/values/strings.xml

4
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);

4
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

2
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));
}

1
app/src/main/res/values/strings.xml

@ -512,6 +512,7 @@
<string name="dir_select_folder_not_exist">The previously selected folder does not exist now:</string>
<string name="dir_select_message2">Re-select the directory or select a new directory by clicking the button below.</string>
<string name="select_a_folder">No folder selected!</string>
<string name="dir_select_no_download_folder">Please choose a directory from your storage, not a category on the sidebar.</string>
<string name="dir_select_success_message">Success! Please wait. Starting app…</string>
<string name="barinsta_folder">Barinsta folder</string>
<string name="top">Top</string>

Loading…
Cancel
Save