mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-12-01 16:51:16 +00:00
if no external sdcard has been found.
This commit is contained in:
parent
bde917d244
commit
fa030319ff
2 changed files with 14 additions and 0 deletions
|
@ -327,6 +327,11 @@ public class FolderActivity extends SyncthingActivity {
|
||||||
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
||||||
if (externalFilesDirUri != null) {
|
if (externalFilesDirUri != null) {
|
||||||
intent.putExtra("android.provider.extra.INITIAL_URI", externalFilesDirUri);
|
intent.putExtra("android.provider.extra.INITIAL_URI", externalFilesDirUri);
|
||||||
|
} else {
|
||||||
|
android.net.Uri internalFilesDirUri = FileUtils.getInternalStorageRootUri();
|
||||||
|
if (internalFilesDirUri != null) {
|
||||||
|
intent.putExtra("android.provider.extra.INITIAL_URI", internalFilesDirUri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
|
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
|
||||||
intent.putExtra("android.content.extra.SHOW_ADVANCED", true);
|
intent.putExtra("android.content.extra.SHOW_ADVANCED", true);
|
||||||
|
|
|
@ -217,6 +217,15 @@ public class FileUtils {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FileProvider does not support converting absolute paths
|
||||||
|
* to a "content://" Uri. As "file://" Uri has been blocked
|
||||||
|
* since Android 7+, we need to build the Uri manually.
|
||||||
|
*/
|
||||||
|
public static android.net.Uri getInternalStorageRootUri() {
|
||||||
|
return android.net.Uri.parse("content://com.android.externalstorage.documents/document/primary%3A");
|
||||||
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
private static String getVolumeIdFromTreeUri(final Uri treeUri) {
|
private static String getVolumeIdFromTreeUri(final Uri treeUri) {
|
||||||
final String docId = DocumentsContract.getTreeDocumentId(treeUri);
|
final String docId = DocumentsContract.getTreeDocumentId(treeUri);
|
||||||
|
|
Loading…
Reference in a new issue