Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[share] Replace deprecated Environment.getExternalStorageDirectory() call on Android. #3152

Merged
merged 2 commits into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/share/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.6.5+3

* Replace deprecated `Environment.getExternalStorageDirectory()` call on Android.
* Upgrade to Android Gradle plugin 3.5.0 & target API level 29.

## 0.6.5+2

* Keep handling deprecated Android v1 classes for backward compatibility.
Expand Down
9 changes: 2 additions & 7 deletions packages/share/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
group 'io.flutter.plugins.share'
version '1.0-SNAPSHOT'
def args = ["-Xlint:deprecation","-Xlint:unchecked","-Werror"]

buildscript {
repositories {
Expand All @@ -9,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.android.tools.build:gradle:3.5.0'
}
}

Expand All @@ -20,14 +19,10 @@ rootProject.allprojects {
}
}

project.getTasks().withType(JavaCompile){
options.compilerArgs.addAll(args)
}

apply plugin: 'com.android.library'

android {
compileSdkVersion 28
compileSdkVersion 29

defaultConfig {
minSdkVersion 16
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Environment;
import androidx.annotation.NonNull;
import androidx.core.content.FileProvider;
import java.io.File;
Expand Down Expand Up @@ -166,7 +165,7 @@ private String getMimeTypeBase(String mimeType) {
private boolean fileIsOnExternal(File file) {
try {
String filePath = file.getCanonicalPath();
File externalDir = Environment.getExternalStorageDirectory();
File externalDir = context.getExternalFilesDir(null);
return externalDir != null && filePath.startsWith(externalDir.getCanonicalPath());
} catch (IOException e) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions packages/share/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28
compileSdkVersion 29

lintOptions {
disable 'InvalidPackage'
Expand All @@ -34,7 +34,7 @@ android {
defaultConfig {
applicationId "io.flutter.plugins.shareexample"
minSdkVersion 16
targetSdkVersion 28
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
2 changes: 1 addition & 1 deletion packages/share/example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.android.tools.build:gradle:3.5.0'
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/share/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ homepage: https://github.com/flutter/plugins/tree/master/packages/share
# 0.6.y+z is compatible with 1.0.0, if you land a breaking change bump
# the version to 2.0.0.
# See more details: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0
version: 0.6.5+2
version: 0.6.5+3

flutter:
plugin:
Expand Down