Skip to content

Commit f39af02

Browse files
hamdikahlounEgor
authored andcommitted
[share] Replace deprecated Environment.getExternalStorageDirectory() call on Android. (flutter#3152)
* Android API 29 & 30 * Update Version
1 parent 4f7eb55 commit f39af02

File tree

6 files changed

+12
-13
lines changed

6 files changed

+12
-13
lines changed

packages/share/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.6.5+3
2+
3+
* Replace deprecated `Environment.getExternalStorageDirectory()` call on Android.
4+
* Upgrade to Android Gradle plugin 3.5.0 & target API level 29.
5+
16
## 0.6.5+2
27

38
* Keep handling deprecated Android v1 classes for backward compatibility.

packages/share/android/build.gradle

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
group 'io.flutter.plugins.share'
22
version '1.0-SNAPSHOT'
3-
def args = ["-Xlint:deprecation","-Xlint:unchecked","-Werror"]
43

54
buildscript {
65
repositories {
@@ -9,7 +8,7 @@ buildscript {
98
}
109

1110
dependencies {
12-
classpath 'com.android.tools.build:gradle:3.3.0'
11+
classpath 'com.android.tools.build:gradle:3.5.0'
1312
}
1413
}
1514

@@ -20,14 +19,10 @@ rootProject.allprojects {
2019
}
2120
}
2221

23-
project.getTasks().withType(JavaCompile){
24-
options.compilerArgs.addAll(args)
25-
}
26-
2722
apply plugin: 'com.android.library'
2823

2924
android {
30-
compileSdkVersion 28
25+
compileSdkVersion 29
3126

3227
defaultConfig {
3328
minSdkVersion 16

packages/share/android/src/main/java/io/flutter/plugins/share/Share.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import android.content.pm.PackageManager;
1111
import android.content.pm.ResolveInfo;
1212
import android.net.Uri;
13-
import android.os.Environment;
1413
import androidx.annotation.NonNull;
1514
import androidx.core.content.FileProvider;
1615
import java.io.File;
@@ -166,7 +165,7 @@ private String getMimeTypeBase(String mimeType) {
166165
private boolean fileIsOnExternal(File file) {
167166
try {
168167
String filePath = file.getCanonicalPath();
169-
File externalDir = Environment.getExternalStorageDirectory();
168+
File externalDir = context.getExternalFilesDir(null);
170169
return externalDir != null && filePath.startsWith(externalDir.getCanonicalPath());
171170
} catch (IOException e) {
172171
return false;

packages/share/example/android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ apply plugin: 'com.android.application'
2525
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2626

2727
android {
28-
compileSdkVersion 28
28+
compileSdkVersion 29
2929

3030
lintOptions {
3131
disable 'InvalidPackage'
@@ -34,7 +34,7 @@ android {
3434
defaultConfig {
3535
applicationId "io.flutter.plugins.shareexample"
3636
minSdkVersion 16
37-
targetSdkVersion 28
37+
targetSdkVersion 29
3838
versionCode flutterVersionCode.toInteger()
3939
versionName flutterVersionName
4040
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

packages/share/example/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
}
66

77
dependencies {
8-
classpath 'com.android.tools.build:gradle:3.3.0'
8+
classpath 'com.android.tools.build:gradle:3.5.0'
99
}
1010
}
1111

packages/share/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ homepage: https://github.com/flutter/plugins/tree/master/packages/share
55
# 0.6.y+z is compatible with 1.0.0, if you land a breaking change bump
66
# the version to 2.0.0.
77
# See more details: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0
8-
version: 0.6.5+2
8+
version: 0.6.5+3
99

1010
flutter:
1111
plugin:

0 commit comments

Comments
 (0)