Skip to content

Commit 2e2daad

Browse files
committed
Merge branch 'master' into updates
2 parents dfb724e + 79f0c7e commit 2e2daad

7 files changed

Lines changed: 54 additions & 12 deletions

File tree

.github/workflows/build.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Build source
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
types: [ opened, synchronize, reopened ]
7+
paths:
8+
- "dfc/**"
9+
push:
10+
branches: [ master ]
11+
paths:
12+
- "dfc/**"
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Set up JDK
22+
uses: actions/setup-java@v4
23+
with:
24+
distribution: "temurin"
25+
java-version: "17"
26+
cache: "gradle"
27+
28+
- name: Build DFC
29+
run: ./gradlew :dfc:assemble

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@
55

66
.idea
77
build
8-
gradle
98
.gradle
109
local.properties

dfc/src/main/java/com/lazygeniouz/dfc/file/DocumentFileCompat.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,5 +240,13 @@ abstract class DocumentFileCompat constructor(
240240
fun isDocument(context: Context, uri: Uri): Boolean {
241241
return isDocumentUri(context, uri)
242242
}
243+
244+
/**
245+
* Return whether the given [uri] is a tree uri.
246+
*/
247+
internal fun isTreeUri(uri: Uri): Boolean {
248+
val paths = uri.pathSegments
249+
return paths.size >= 2 && "tree" == paths[0]
250+
}
243251
}
244252
}

dfc/src/main/java/com/lazygeniouz/dfc/file/internals/SingleDocumentFileCompat.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.lazygeniouz.dfc.file.internals
22

33
import android.content.Context
44
import android.net.Uri
5+
import android.provider.DocumentsContract
56
import com.lazygeniouz.dfc.file.DocumentFileCompat
67
import com.lazygeniouz.dfc.resolver.ResolverCompat
78

@@ -96,6 +97,9 @@ internal class SingleDocumentFileCompat(
9697
* Build a [SingleDocumentFileCompat] from a given [uri].
9798
*/
9899
internal fun make(context: Context, self: Uri): SingleDocumentFileCompat? {
100+
if (isTreeUri(self)) return null
101+
if (!DocumentsContract.isDocumentUri(context, self)) return null
102+
99103
ResolverCompat.getCursor(context, self, ResolverCompat.fullProjection)
100104
?.use { cursor ->
101105
if (cursor.moveToFirst()) {

dfc/src/main/java/com/lazygeniouz/dfc/file/internals/TreeDocumentFileCompat.kt

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,6 @@ internal class TreeDocumentFileCompat constructor(
103103

104104
internal companion object {
105105

106-
/**
107-
* Return whether the given [uri] is a tree uri.
108-
*/
109-
private fun isTreeUri(uri: Uri): Boolean {
110-
val paths = uri.pathSegments
111-
return paths.size >= 2 && "tree" == paths[0]
112-
}
113-
114106
/**
115107
* Build the initial [TreeDocumentFileCompat] from a given [uri].
116108
*/
@@ -120,9 +112,12 @@ internal class TreeDocumentFileCompat constructor(
120112
}
121113

122114
// build a new tree uri if this is a first tree doc creation...
123-
val treeUri = if (isInitial) DocumentsContract.buildDocumentUriUsingTree(
124-
uri, DocumentsContract.getTreeDocumentId(uri)
125-
) else uri
115+
// but only if the uri is not already a document uri to preserve subdir info.
116+
val treeUri = if (isInitial && !DocumentsContract.isDocumentUri(context, uri)) {
117+
DocumentsContract.buildDocumentUriUsingTree(
118+
uri, DocumentsContract.getTreeDocumentId(uri)
119+
)
120+
} else uri
126121

127122
ResolverCompat.getCursor(context, treeUri, ResolverCompat.fullProjection)
128123
?.use { cursor ->

gradle/wrapper/gradle-wrapper.jar

42.7 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)