Skip to content

Commit

Permalink
update open_file_platform_interface: ^1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
crazecoder committed Oct 13, 2024
1 parent 5efe967 commit 4d3286c
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 21 deletions.
4 changes: 4 additions & 0 deletions open_file_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions open_file_android/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions open_file_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions open_file_ios/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion open_file_linux/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 3 additions & 2 deletions open_file_linux/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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:
Expand All @@ -36,4 +36,5 @@ flutter:
implements: open_file
platforms:
linux:
dartPluginClass: OpenFileLinux
pluginClass: OpenFileLinuxPlugin
2 changes: 2 additions & 0 deletions open_file_mac/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions open_file_mac/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion open_file_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 3 additions & 3 deletions open_file_web/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions open_file_windows/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions open_file_windows/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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:
Expand Down

0 comments on commit 4d3286c

Please sign in to comment.