diff --git a/open_file_android/CHANGELOG.md b/open_file_android/CHANGELOG.md index 9a4b37b..d001d3c 100644 --- a/open_file_android/CHANGELOG.md +++ b/open_file_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.6 +* update `open_file_platform_interface: ^1.0.3`. +## 1.0.5 +* use file.canRead() to check whether the file has permission to open ## 1.0.4 * use canonicalPath instead of path * use checkUriPermission to check whether the file has permission to open diff --git a/open_file_android/android/src/main/java/com/crazecoder/openfile/OpenFilePlugin.java b/open_file_android/android/src/main/java/com/crazecoder/openfile/OpenFilePlugin.java index 777190f..4e5876d 100644 --- a/open_file_android/android/src/main/java/com/crazecoder/openfile/OpenFilePlugin.java +++ b/open_file_android/android/src/main/java/com/crazecoder/openfile/OpenFilePlugin.java @@ -14,7 +14,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; -import androidx.core.content.FileProvider; import androidx.core.content.ContextCompat; import androidx.core.content.PermissionChecker; @@ -31,8 +30,6 @@ import io.flutter.plugin.common.MethodChannel.Result; import io.flutter.plugin.common.PluginRegistry; -import java.io.File; -import java.io.IOException; import java.util.List; import java.util.Map; @@ -87,7 +84,7 @@ private void doOpen() { if (!isFileAvailable()) { return; } - if (!FileUtil.hasUriPermission(context, filePath)) { + if (FileUtil.isNeedPermission(filePath)) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && FileUtil.isExternalStoragePublicMedia(filePath, mimeType)) { if (FileUtil.isImage(mimeType) && !hasPermission(Manifest.permission.READ_MEDIA_IMAGES) && !Environment.isExternalStorageManager()) { @@ -255,7 +252,6 @@ public boolean onActivityResult(int requestCode, int resultCode, @Nullable Inten if (requestCode == REQUEST_CODE_FOR_DIR && (uri = data.getData()) != null) { context.getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); doOpen(); - } } return false; diff --git a/open_file_android/android/src/main/java/com/crazecoder/openfile/utils/FileUtil.java b/open_file_android/android/src/main/java/com/crazecoder/openfile/utils/FileUtil.java index a529ee1..b77c63a 100644 --- a/open_file_android/android/src/main/java/com/crazecoder/openfile/utils/FileUtil.java +++ b/open_file_android/android/src/main/java/com/crazecoder/openfile/utils/FileUtil.java @@ -202,6 +202,11 @@ public static boolean isExternalStoragePublicPath(String filePath) { return isExternalStoragePublicPath; } + public static boolean isNeedPermission(String filePath) { + File file = new File(filePath); + return !file.canRead(); + } + public static String getCanonicalPath(String filePath) { if (filePath == null) { return null; @@ -230,7 +235,14 @@ public static Uri getFileUri(Context context, String filePath) { return uri; } - public static boolean hasUriPermission(Context context, String filePath) { + /*** + * @deprecated use isNeedPermission instead + * @param context + * @param filePath + * @return + */ + @Deprecated + private static boolean hasUriPermission(Context context, String filePath) { Uri uri = getFileUri(context, filePath); int modeFlags = context.checkUriPermission(uri, android.os.Process.myPid(), android.os.Process.myUid(), Intent.FLAG_GRANT_READ_URI_PERMISSION); diff --git a/open_file_android/pubspec.yaml b/open_file_android/pubspec.yaml index 44ff623..3fb2ebe 100644 --- a/open_file_android/pubspec.yaml +++ b/open_file_android/pubspec.yaml @@ -1,7 +1,7 @@ name: open_file_android description: Android implementation of the open_file plugin. repository: https://github.com/crazecoder/open_file/tree/master/open_file_android -version: 1.0.4 +version: 1.0.6 environment: sdk: ">=2.17.0 <4.0.0" @@ -10,7 +10,7 @@ environment: dependencies: flutter: sdk: flutter - open_file_platform_interface: ^1.0.2 + open_file_platform_interface: ^1.0.3 dev_dependencies: flutter_test: diff --git a/open_file_ios/CHANGELOG.md b/open_file_ios/CHANGELOG.md index 7ed77ad..73e600b 100644 --- a/open_file_ios/CHANGELOG.md +++ b/open_file_ios/CHANGELOG.md @@ -1,3 +1,5 @@ +## 1.0.3 +* update `open_file_platform_interface: ^1.0.3`. ## 1.0.2 * add `isIOSAppOpen` Whether to use the app to open. * The objc code is optimized diff --git a/open_file_ios/pubspec.yaml b/open_file_ios/pubspec.yaml index a8e930b..501969c 100644 --- a/open_file_ios/pubspec.yaml +++ b/open_file_ios/pubspec.yaml @@ -1,7 +1,7 @@ name: open_file_ios description: iOS implementation of the open_file plugin. repository: https://github.com/crazecoder/open_file/tree/master/open_file_ios -version: 1.0.2 +version: 1.0.3 environment: sdk: ">=2.17.0 <4.0.0" @@ -10,7 +10,7 @@ environment: dependencies: flutter: sdk: flutter - open_file_platform_interface: ^1.0.2 + open_file_platform_interface: ^1.0.3 dev_dependencies: flutter_test: diff --git a/open_file_linux/CHANGELOG.md b/open_file_linux/CHANGELOG.md index 61a4e28..c7ebe4c 100644 --- a/open_file_linux/CHANGELOG.md +++ b/open_file_linux/CHANGELOG.md @@ -1,5 +1,7 @@ +## 0.0.5 +* fix issue [#303](https://github.com/crazecoder/open_file/issues/303) ## 0.0.4 -* add `isIOSAppOpen` . +* add `isIOSAppOpen`. ## 0.0.3 * fix issue [#291](https://github.com/crazecoder/open_file/issues/291) ## 0.0.2 diff --git a/open_file_linux/pubspec.yaml b/open_file_linux/pubspec.yaml index 476e5b0..d3624d1 100644 --- a/open_file_linux/pubspec.yaml +++ b/open_file_linux/pubspec.yaml @@ -1,7 +1,7 @@ name: open_file_linux description: Linux platform implementation of open_file repository: https://github.com/crazecoder/open_file/tree/master/open_file_linux -version: 0.0.4 +version: 0.0.5 environment: sdk: ">=2.17.0 <4.0.0" @@ -11,7 +11,7 @@ dependencies: flutter: sdk: flutter ffi: ^2.1.3 - open_file_platform_interface: ^1.0.2 + open_file_platform_interface: ^1.0.3 dev_dependencies: flutter_test: @@ -36,4 +36,5 @@ flutter: implements: open_file platforms: linux: + dartPluginClass: OpenFileLinux pluginClass: OpenFileLinuxPlugin \ No newline at end of file diff --git a/open_file_mac/CHANGELOG.md b/open_file_mac/CHANGELOG.md index f6238af..a905591 100644 --- a/open_file_mac/CHANGELOG.md +++ b/open_file_mac/CHANGELOG.md @@ -1,3 +1,5 @@ +## 1.0.2 +* update `open_file_platform_interface: ^1.0.3`. ## 1.0.1 * update `open_file_platform_interface: ^1.0.2`. ## 1.0.0 diff --git a/open_file_mac/pubspec.yaml b/open_file_mac/pubspec.yaml index c0a7b74..6b45d06 100644 --- a/open_file_mac/pubspec.yaml +++ b/open_file_mac/pubspec.yaml @@ -1,7 +1,7 @@ name: open_file_mac description: MacOS implementation of the open_file plugin. repository: https://github.com/crazecoder/open_file/tree/master/open_file_macos -version: 1.0.1 +version: 1.0.2 environment: sdk: ">=2.17.0 <4.0.0" @@ -10,7 +10,7 @@ environment: dependencies: flutter: sdk: flutter - open_file_platform_interface: ^1.0.2 + open_file_platform_interface: ^1.0.3 dev_dependencies: flutter_test: diff --git a/open_file_web/CHANGELOG.md b/open_file_web/CHANGELOG.md index 604f884..616e3cb 100644 --- a/open_file_web/CHANGELOG.md +++ b/open_file_web/CHANGELOG.md @@ -1,7 +1,10 @@ +## 0.0.4 +* update `open_file_platform_interface: ^1.0.3`. +* update `web: ^1.1.0` ## 0.0.3 * fix for wasm. ## 0.0.2 -* update `open_file_platform_interface: ^1.0.2`. +* update `open_file_platform_interface: ^1.0.2`. * remove `web: ^1.0.0` ## 0.0.1 * initial release. diff --git a/open_file_web/pubspec.yaml b/open_file_web/pubspec.yaml index b9e7840..c07f1d2 100644 --- a/open_file_web/pubspec.yaml +++ b/open_file_web/pubspec.yaml @@ -1,7 +1,7 @@ name: open_file_web description: web implementation of the open_file plugin. repository: https://github.com/crazecoder/open_file/tree/master/open_file_macos -version: 0.0.3 +version: 0.0.4 environment: sdk: ">=2.17.0 <4.0.0" @@ -12,8 +12,8 @@ dependencies: sdk: flutter flutter_web_plugins: sdk: flutter - open_file_platform_interface: ^1.0.2 - web: ^1.0.0 + open_file_platform_interface: ^1.0.3 + web: ^1.1.0 dev_dependencies: flutter_lints: ^4.0.0 diff --git a/open_file_windows/CHANGELOG.md b/open_file_windows/CHANGELOG.md index ea02b59..3e1f7cb 100644 --- a/open_file_windows/CHANGELOG.md +++ b/open_file_windows/CHANGELOG.md @@ -1,3 +1,5 @@ +## 0.0.3 +* update `open_file_platform_interface: ^1.0.3`. ## 0.0.2 * update `open_file_platform_interface: ^1.0.2` ## 0.0.1 diff --git a/open_file_windows/pubspec.yaml b/open_file_windows/pubspec.yaml index 50c3c27..570262a 100644 --- a/open_file_windows/pubspec.yaml +++ b/open_file_windows/pubspec.yaml @@ -1,7 +1,7 @@ name: open_file_windows description: Windows platform implementation of open_file repository: https://github.com/crazecoder/open_file/tree/master/open_file_windows -version: 0.0.2 +version: 0.0.3 environment: sdk: ">=2.17.0 <4.0.0" @@ -12,7 +12,7 @@ dependencies: flutter: sdk: flutter ffi: ^2.1.3 - open_file_platform_interface: ^1.0.2 + open_file_platform_interface: ^1.0.3 dev_dependencies: flutter_test: