Skip to content

Commit 6918807

Browse files
authored
make open folder follow the directory devs specify (#65)
* this feels hacky but it works * make the change chloe suggested
1 parent 187d3f9 commit 6918807

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

app/src/main/java/com/geode/launcher/utils/GeodeUtils.kt

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -208,24 +208,20 @@ object GeodeUtils {
208208
val context = activity.get()!!
209209

210210
val pathFile = File(path)
211-
val baseDirectory = LaunchUtils.getBaseDirectory(context)
211+
val baseDirectory = LaunchUtils.getBaseDirectory(context, true)
212212
val isInternalPath = pathFile.startsWith(baseDirectory)
213213

214214
val intent = if (isInternalPath) {
215-
// TODO: figure out how to get this to point to the path it should be pointing at
216-
// (the best i got was pointing at a file)
217-
// val relativePath = pathFile.relativeTo(baseDirectory)
215+
val relativePath = pathFile.relativeTo(baseDirectory)
216+
val uri = DocumentsContract.buildDocumentUri(
217+
"com.android.externalstorage.documents",
218+
"primary:Android/media/${context.packageName}/$relativePath"
219+
)
218220

219221
Intent(Intent.ACTION_VIEW).apply {
220-
data = DocumentsContract.buildRootUri(
221-
"${context.packageName}.user", UserDirectoryProvider.ROOT
222-
)
222+
setDataAndType(uri, DocumentsContract.Document.MIME_TYPE_DIR)
223223

224-
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or
225-
Intent.FLAG_GRANT_WRITE_URI_PERMISSION or
226-
Intent.FLAG_GRANT_PREFIX_URI_PERMISSION or
227-
Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION
228-
)
224+
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
229225
}
230226
} else {
231227
Intent(Intent.ACTION_OPEN_DOCUMENT).apply {

0 commit comments

Comments
 (0)