Skip to content

Commit d8bdd1a

Browse files
committed
Restore accidental deletions from Android plugin
1 parent de0d3e2 commit d8bdd1a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

android/src/main/kotlin/codeux/design/filepicker/file_picker_writable/FilePickerWritablePlugin.kt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package codeux.design.filepicker.file_picker_writable
22

33
import android.app.Activity
44
import android.net.Uri
5+
import android.os.Build
56
import android.util.Log
67
import androidx.annotation.MainThread
78
import androidx.annotation.NonNull
@@ -89,11 +90,44 @@ class FilePickerWritablePlugin : FlutterPlugin, MethodCallHandler,
8990
?: throw FilePickerException("Expected argument 'path'")
9091
impl.openFilePickerForCreate(result, path)
9192
}
93+
"isDirectoryAccessSupported" -> {
94+
result.success(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
95+
}
96+
"openDirectoryPicker" -> {
97+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
98+
val initialDirUri = call.argument<String>("initialDirUri")
99+
impl.openDirectoryPicker(result, initialDirUri)
100+
} else {
101+
throw FilePickerException("${call.method} is not supported on Android ${Build.VERSION.RELEASE}")
102+
}
103+
}
92104
"readFileWithIdentifier" -> {
93105
val identifier = call.argument<String>("identifier")
94106
?: throw FilePickerException("Expected argument 'identifier'")
95107
impl.readFileWithIdentifier(result, identifier)
96108
}
109+
"getDirectory" -> {
110+
val rootIdentifier = call.argument<String>("rootIdentifier")
111+
?: throw FilePickerException("Expected argument 'rootIdentifier'")
112+
val fileIdentifier = call.argument<String>("fileIdentifier")
113+
?: throw FilePickerException("Expected argument 'fileIdentifier'")
114+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
115+
impl.getDirectory(result, rootIdentifier, fileIdentifier)
116+
} else {
117+
throw FilePickerException("${call.method} is not supported on Android ${Build.VERSION.RELEASE}")
118+
}
119+
}
120+
"resolveRelativePath" -> {
121+
val directoryIdentifier = call.argument<String>("directoryIdentifier")
122+
?: throw FilePickerException("Expected argument 'directoryIdentifier'")
123+
val relativePath = call.argument<String>("relativePath")
124+
?: throw FilePickerException("Expected argument 'relativePath'")
125+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
126+
impl.resolveRelativePath(result, directoryIdentifier, relativePath)
127+
} else {
128+
throw FilePickerException("${call.method} is not supported on Android ${Build.VERSION.RELEASE}")
129+
}
130+
}
97131
"writeFileWithIdentifier" -> {
98132
val identifier = call.argument<String>("identifier")
99133
?: throw FilePickerException("Expected argument 'identifier'")

0 commit comments

Comments
 (0)