Fix the FolderProvider findDocumentPath implementation to make paths actually visible

This commit is contained in:
artdeell 2023-01-28 07:57:11 +03:00
parent 2293664bd4
commit 1f28b3a6a7
2 changed files with 11 additions and 2 deletions

View File

@ -1 +1 @@
1665886806915
1674881685730

View File

@ -313,6 +313,15 @@ public class FolderProvider extends DocumentsProvider {
public DocumentsContract.Path findDocumentPath(@Nullable String parentDocumentId, String childDocumentId) throws FileNotFoundException {
File source = BASE_DIR;
if(parentDocumentId != null) source = getFileForDocId(parentDocumentId);
return new DocumentsContract.Path(getDocIdForFile(source), Collections.singletonList(childDocumentId));
File destination = getFileForDocId(childDocumentId);
List<String> pathIds = new ArrayList<>();
while(!source.equals(destination) && destination != null) {
pathIds.add(getDocIdForFile(destination));
destination = destination.getParentFile();
}
pathIds.add(getDocIdForFile(source));
Collections.reverse(pathIds);
Log.i("FolderProvider", pathIds.toString());
return new DocumentsContract.Path(getDocIdForFile(source), pathIds);
}
}