Skip to content

Commit

Permalink
Restore accidental deletions from Android plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
amake committed Oct 30, 2023
1 parent de0d3e2 commit d8bdd1a
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package codeux.design.filepicker.file_picker_writable

import android.app.Activity
import android.net.Uri
import android.os.Build
import android.util.Log
import androidx.annotation.MainThread
import androidx.annotation.NonNull
Expand Down Expand Up @@ -89,11 +90,44 @@ class FilePickerWritablePlugin : FlutterPlugin, MethodCallHandler,
?: throw FilePickerException("Expected argument 'path'")
impl.openFilePickerForCreate(result, path)
}
"isDirectoryAccessSupported" -> {
result.success(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
}
"openDirectoryPicker" -> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
val initialDirUri = call.argument<String>("initialDirUri")
impl.openDirectoryPicker(result, initialDirUri)
} else {
throw FilePickerException("${call.method} is not supported on Android ${Build.VERSION.RELEASE}")
}
}
"readFileWithIdentifier" -> {
val identifier = call.argument<String>("identifier")
?: throw FilePickerException("Expected argument 'identifier'")
impl.readFileWithIdentifier(result, identifier)
}
"getDirectory" -> {
val rootIdentifier = call.argument<String>("rootIdentifier")
?: throw FilePickerException("Expected argument 'rootIdentifier'")
val fileIdentifier = call.argument<String>("fileIdentifier")
?: throw FilePickerException("Expected argument 'fileIdentifier'")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
impl.getDirectory(result, rootIdentifier, fileIdentifier)
} else {
throw FilePickerException("${call.method} is not supported on Android ${Build.VERSION.RELEASE}")
}
}
"resolveRelativePath" -> {
val directoryIdentifier = call.argument<String>("directoryIdentifier")
?: throw FilePickerException("Expected argument 'directoryIdentifier'")
val relativePath = call.argument<String>("relativePath")
?: throw FilePickerException("Expected argument 'relativePath'")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
impl.resolveRelativePath(result, directoryIdentifier, relativePath)
} else {
throw FilePickerException("${call.method} is not supported on Android ${Build.VERSION.RELEASE}")
}
}
"writeFileWithIdentifier" -> {
val identifier = call.argument<String>("identifier")
?: throw FilePickerException("Expected argument 'identifier'")
Expand Down

0 comments on commit d8bdd1a

Please sign in to comment.