Skip to content

Commit

Permalink
Merge branch 'main' into fix/permission-android-23
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 authored Jul 15, 2024
2 parents b7bc318 + fe4fa9c commit 823af5c
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 70 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ that can be found in the LICENSE file. -->

To know more about breaking changes, see the [Migration Guide][].

## 3.2.1

### Improvements

* Declare `NSPrivacyAccessedAPICategoryFileTimestamp` for iOS privacy policies.

### Fixes

* Fixes compile exceptions with Xcode versions that are not compatible with iOS 17.0.
* Modified the way to read the Java version in `build.gradle`.

## 3.2.0

### Improvements
Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @CaiJingLong @AlexV525
84 changes: 17 additions & 67 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,82 +30,32 @@ void log(Object msg) {
logger.log(LogLevel.INFO, "[PhotoManager] $msg")
}

class ExecResult {
int exitValue
String output

ExecResult(int exitValue, String output) {
this.exitValue = exitValue
this.output = output
}
}

static ExecResult executeCommand(String... args) {

int exitValue;
String output;

try {
Process process = new ProcessBuilder(args).start()

def stream = new ByteArrayOutputStream()
stream.withStream { bos ->
process.inputStream.withStream { ins ->
bos << ins
}
process.errorStream.withStream { ins ->
bos << ins
}
output = bos.toString("UTF-8")
}
exitValue = process.waitFor()
} catch (Exception e) {
e.printStackTrace()
exitValue = -1
output = e.toString()
}

return new ExecResult(exitValue, output)
}

/**
* Get java version from JAVA_HOME
* @param path JAVA_HOME path
* @return java version
*/
JavaVersion getJavaFromHome(String path) {
log("Reading java version from JAVA_HOME: ${path}")
def javaExe = path + "/bin/java"

def version = executeCommand(javaExe, "-version")

if (version.exitValue != 0) {
return null
}

def versionText = version.output
log("versionText: ${versionText}")

String regex = "\"(.+)\""
Pattern pattern = Pattern.compile(regex)

// 创建 Matcher 对象
Matcher matcher = pattern.matcher(versionText)

if (matcher.find()) {
String v = matcher.group(1)

if (v.startsWith("1.")) {
// just save the major and minor version
v = v.substring(0, 3)
def releaseFile = new File(path, "release")

if (releaseFile.exists()) {
def pattern = Pattern.compile("JAVA_VERSION=\"(\\d+)\"")
def matcher = pattern.matcher(releaseFile.text)
if (matcher.find()) {
def version = matcher.group(1)
log("Get java version from release file: $version")
return JavaVersion.toVersion(version)
}
} else {
def javaBin = new File("${path}/bin/java")
if (javaBin.exists()) {
return JavaVersion.VERSION_1_8
} else if (new File("${path}/bin/java.exe").exists()) {
return JavaVersion.VERSION_1_8
}

log("java version string: ${v}")

return JavaVersion.toVersion(v)
return null
}

return null
}

JavaVersion getJavaVersion() {
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: photo_manager_example
description: Demonstrates how to use the photo_manager plugin.
version: 3.2.0+27
version: 3.2.1+28
publish_to: none

environment:
Expand Down
4 changes: 4 additions & 0 deletions ios/Classes/core/PHAssetResource+PM_COMMON.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ - (bool)isImageOrVideo{

- (bool)isValid {
bool isResource = self.type != PHAssetResourceTypeAdjustmentData;

#if __IPHONE_17_0
if (@available(iOS 17.0, *)) {
isResource = isResource && self.type != PHAssetResourceTypePhotoProxy;
}
#endif

return isResource;
}

Expand Down
11 changes: 10 additions & 1 deletion ios/Resources/PrivacyInfo.xcprivacy
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@
<key>NSPrivacyTrackingDomains</key>
<array/>
<key>NSPrivacyAccessedAPITypes</key>
<array/>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>C617.1</string>
</array>
</dict>
</array>
<key>NSPrivacyTracking</key>
<false/>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: photo_manager
description: A Flutter plugin that provides album assets abstraction management APIs on Android, iOS, macOS, and OpenHarmony.
repository: https://github.com/fluttercandies/flutter_photo_manager
version: 3.2.0
version: 3.2.1

environment:
sdk: ">=2.13.0 <4.0.0"
Expand Down

0 comments on commit 823af5c

Please sign in to comment.