forked from geode-sdk/android-launcher
make open folder follow the directory devs specify (#65)
* this feels hacky but it works * make the change chloe suggested
This commit is contained in:
1 parent
187d3f9819
commit
69188075a3
1 file changed
+8
-12
@@ -208,24 +208,20 @@ object GeodeUtils {
|
|||||||
val context = activity.get()!!
|
val context = activity.get()!!
|
||||||
|
|
||||||
val pathFile = File(path)
|
val pathFile = File(path)
|
||||||
val baseDirectory = LaunchUtils.getBaseDirectory(context)
|
val baseDirectory = LaunchUtils.getBaseDirectory(context, true)
|
||||||
val isInternalPath = pathFile.startsWith(baseDirectory)
|
val isInternalPath = pathFile.startsWith(baseDirectory)
|
||||||
|
|
||||||
val intent = if (isInternalPath) {
|
val intent = if (isInternalPath) {
|
||||||
// TODO: figure out how to get this to point to the path it should be pointing at
|
val relativePath = pathFile.relativeTo(baseDirectory)
|
||||||
// (the best i got was pointing at a file)
|
val uri = DocumentsContract.buildDocumentUri(
|
||||||
// val relativePath = pathFile.relativeTo(baseDirectory)
|
"com.android.externalstorage.documents",
|
||||||
|
"primary:Android/media/${context.packageName}/$relativePath"
|
||||||
|
)
|
||||||
|
|
||||||
Intent(Intent.ACTION_VIEW).apply {
|
Intent(Intent.ACTION_VIEW).apply {
|
||||||
data = DocumentsContract.buildRootUri(
|
setDataAndType(uri, DocumentsContract.Document.MIME_TYPE_DIR)
|
||||||
"${context.packageName}.user", UserDirectoryProvider.ROOT
|
|
||||||
)
|
|
||||||
|
|
||||||
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or
|
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||||
Intent.FLAG_GRANT_WRITE_URI_PERMISSION or
|
|
||||||
Intent.FLAG_GRANT_PREFIX_URI_PERMISSION or
|
|
||||||
Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
|
Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
|
||||||
|
|||||||
Reference in new issue
Block a user