Fix strange behaviour when app loses access to saf download folder
This commit is contained in:
parent
114dc8ffa0
commit
b78ac7d2e9
2 changed files with 14 additions and 2 deletions
|
@ -682,12 +682,15 @@ public class DownloadDialog extends DialogFragment
|
||||||
throw new RuntimeException("No stream selected");
|
throw new RuntimeException("No stream selected");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!askForSavePath && (mainStorage == null || (mainStorage.isDirect()
|
if (!askForSavePath
|
||||||
== NewPipeSettings.useStorageAccessFramework(context)))) {
|
&& (mainStorage == null
|
||||||
|
|| mainStorage.isDirect() == NewPipeSettings.useStorageAccessFramework(context)
|
||||||
|
|| mainStorage.isInvalidSafStorage())) {
|
||||||
// Pick new download folder if one of:
|
// Pick new download folder if one of:
|
||||||
// - Download folder is not set
|
// - Download folder is not set
|
||||||
// - Download folder uses SAF while SAF is disabled
|
// - Download folder uses SAF while SAF is disabled
|
||||||
// - Download folder doesn't use SAF while SAF is enabled
|
// - Download folder doesn't use SAF while SAF is enabled
|
||||||
|
// - Download folder uses SAF but the user manually revoked access to it
|
||||||
Toast.makeText(context, getString(R.string.no_dir_yet),
|
Toast.makeText(context, getString(R.string.no_dir_yet),
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
|
|
|
@ -223,6 +223,15 @@ public class StoredDirectoryHelper {
|
||||||
return docTree == null ? ioTree.canWrite() : docTree.canWrite();
|
return docTree == null ? ioTree.canWrite() : docTree.canWrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@code false} if the storage is direct, or the SAF storage is valid; {@code true} if
|
||||||
|
* SAF access to this SAF storage is denied (e.g. the user clicked on {@code Android settings ->
|
||||||
|
* Apps & notifications -> NewPipe -> Storage & cache -> Clear access});
|
||||||
|
*/
|
||||||
|
public boolean isInvalidSafStorage() {
|
||||||
|
return docTree != null && docTree.getName() == null;
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
Loading…
Reference in a new issue