Simplify the storage APIs use
* use Java I/O (classic way) on older android versions * use Storage Access Framework on newer android versions (Android Lollipop or later) * both changes have the external SD Card write permission * add option to ask the save path on each download * warn the user if the save paths are not defined, this only happens on the first NewPipe run (Android Lollipop or later)
This commit is contained in:
parent
d9fb7cb420
commit
b92b434e2c
9 changed files with 119 additions and 182 deletions
|
|
@ -10,7 +10,6 @@ import android.os.Build;
|
|||
import android.provider.DocumentsContract;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.support.v4.provider.DocumentFile;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -33,7 +32,6 @@ public class StoredDirectoryHelper {
|
|||
|
||||
private String tag;
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public StoredDirectoryHelper(@NonNull Context context, @NonNull Uri path, String tag) throws IOException {
|
||||
this.tag = tag;
|
||||
|
||||
|
|
@ -50,6 +48,9 @@ public class StoredDirectoryHelper {
|
|||
throw new IOException(e);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
|
||||
throw new IOException("Storage Access Framework with Directory API is not available");
|
||||
|
||||
this.docTree = DocumentFile.fromTreeUri(context, path);
|
||||
|
||||
if (this.docTree == null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue