1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-01 16:51:16 +00:00

Suggest new folder creation on primary storage (fixes #376) (#379)

if no external sdcard has been found.
This commit is contained in:
Catfriend1 2019-03-23 12:36:50 +01:00 committed by GitHub
parent bde917d244
commit fa030319ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View file

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

View file

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