Skip to content

Commit

Permalink
Completes #5.
Browse files Browse the repository at this point in the history
  • Loading branch information
ItzNotABug committed Oct 14, 2023
1 parent 3c69792 commit 69e83ca
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ allprojects {

plugins.withId("com.vanniktech.maven.publish.base") {
group "com.lazygeniouz"
version "1.0.6"
version "1.0.8"

mavenPublishing {
signAllPublications()
pomFromGradleProperties()
publishToMavenCentral("S01", true)
publishToMavenCentral(SonatypeHost.S01, true)
configure(new AndroidSingleVariantLibrary("release"))
}
}
}

task clean(type: Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal class DocumentController(
internal fun listFiles(): List<DocumentFileCompat> {
return if (!isDirectory())
throw UnsupportedOperationException("Selected document is not a Directory.")
else ResolverCompat.listFiles(context, fileUri)
else ResolverCompat.listFiles(context, fileCompat)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ abstract class DocumentFileCompat constructor(
var uri: Uri = uri
internal set

/**
* Return the parent file of this document.
*
* This will be null if called inside the selected directory.\
* Should return the correct parent file for child items inside the selected directory.
*/
var parentFile: DocumentFileCompat? = null
internal set

/**
* Get the extension of the Document **File**.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ internal object ResolverCompat {
/**
* Queries the ContentResolver & builds a list of [DocumentFileCompat] with all the required fields.
*/
internal fun listFiles(context: Context, uri: Uri): List<DocumentFileCompat> {
internal fun listFiles(context: Context, file: DocumentFileCompat): List<DocumentFileCompat> {
val uri = file.uri
val childrenUri = createChildrenUri(uri)
// empty list
val listOfDocuments = arrayListOf<DocumentFileCompat>()

getCursor(context, childrenUri, fullProjection)?.use { cursor ->
Expand All @@ -116,7 +116,10 @@ internal object ResolverCompat {
context, documentUri, documentName,
documentSize, documentLastModified,
documentMimeType, documentFlags
).also { childFile -> listOfDocuments.add(childFile) }
).also { childFile ->
childFile.parentFile = file
listOfDocuments.add(childFile)
}
}
}

Expand Down

0 comments on commit 69e83ca

Please sign in to comment.