Skip to content
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
6 changes: 6 additions & 0 deletions packages/share_plus/share_plus/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 3.0.2

- Apply code improvements
- Update gradle for plugin
- Update flutter dependencies

## 3.0.1

- Update Android dependencies for plugin and example, bump compileSDK to 31
Expand Down
8 changes: 4 additions & 4 deletions packages/share_plus/share_plus/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

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

Expand All @@ -22,7 +22,7 @@ rootProject.allprojects {
apply plugin: 'com.android.library'

android {
compileSdkVersion 28
compileSdkVersion 31

defaultConfig {
minSdkVersion 16
Expand All @@ -33,7 +33,7 @@ android {
}

dependencies {
implementation 'androidx.core:core:1.3.1'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.core:core:1.6.0'
implementation 'androidx.annotation:annotation:1.2.0'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package dev.fluttercommunity.plus.share;

import androidx.annotation.NonNull;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import java.io.*;
Expand All @@ -13,15 +14,15 @@
/** Handles the method calls for the plugin. */
class MethodCallHandler implements MethodChannel.MethodCallHandler {

private Share share;
private final Share share;

MethodCallHandler(Share share) {
this.share = share;
}

@Override
@SuppressWarnings("unchecked")
public void onMethodCall(MethodCall call, MethodChannel.Result result) {
public void onMethodCall(MethodCall call, @NonNull MethodChannel.Result result) {
switch (call.method) {
case "share":
expectMapArguments(call);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
/** Handles share intent. */
class Share {

private Context context;
private final Context context;
private Activity activity;

private String providerAuthority;
private final String providerAuthority;

/**
* Constructs a Share object. The {@code context} and {@code activity} are used to start the share
Expand Down Expand Up @@ -183,8 +183,9 @@ private boolean fileIsInShareCache(File file) {
@SuppressWarnings("ResultOfMethodCallIgnored")
private void clearShareCacheFolder() {
File folder = getShareCacheFolder();
if (folder.exists()) {
for (File file : folder.listFiles()) {
final File[] files = folder.listFiles();
if (folder.exists() && files != null) {
for (File file : files) {
file.delete();
}
folder.delete();
Expand Down Expand Up @@ -220,21 +221,15 @@ private Context getContext() {
}

private static void copy(File src, File dst) throws IOException {
InputStream in = new FileInputStream(src);
try {
OutputStream out = new FileOutputStream(dst);
try {
try (InputStream in = new FileInputStream(src)) {
try (OutputStream out = new FileOutputStream(dst)) {
// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
} finally {
out.close();
}
} finally {
in.close();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@

package dev.fluttercommunity.plus.share;

import android.app.Activity;
import android.content.Context;
import androidx.annotation.NonNull;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodChannel;

/** Plugin method host for presenting a share sheet via Intent */
public class SharePlusPlugin implements FlutterPlugin, ActivityAware {

private static final String CHANNEL = "dev.fluttercommunity.plus/share";
private MethodCallHandler handler;
private Share share;
private MethodChannel methodChannel;

@Override
public void onAttachedToEngine(FlutterPluginBinding binding) {
setUpChannel(binding.getApplicationContext(), null, binding.getBinaryMessenger());
methodChannel = new MethodChannel(binding.getBinaryMessenger(), CHANNEL);
share = new Share(binding.getApplicationContext(), null);
MethodCallHandler handler = new MethodCallHandler(share);
methodChannel.setMethodCallHandler(handler);
}

@Override
public void onDetachedFromEngine(FlutterPluginBinding binding) {
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
methodChannel.setMethodCallHandler(null);
methodChannel = null;
share = null;
Expand All @@ -43,19 +43,12 @@ public void onDetachedFromActivity() {
}

@Override
public void onReattachedToActivityForConfigChanges(ActivityPluginBinding binding) {
public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) {
onAttachedToActivity(binding);
}

@Override
public void onDetachedFromActivityForConfigChanges() {
onDetachedFromActivity();
}

private void setUpChannel(Context context, Activity activity, BinaryMessenger messenger) {
methodChannel = new MethodChannel(messenger, CHANNEL);
share = new Share(context, activity);
handler = new MethodCallHandler(share);
methodChannel.setMethodCallHandler(handler);
}
}
2 changes: 1 addition & 1 deletion packages/share_plus/share_plus/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies:
sdk: flutter
share_plus:
path: ../
image_picker: ^0.8.4
image_picker: ^0.8.4+2

dev_dependencies:
flutter_driver:
Expand Down
4 changes: 2 additions & 2 deletions packages/share_plus/share_plus/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: share_plus
description: Flutter plugin for sharing content via the platform share UI, using the ACTION_SEND intent on Android and UIActivityViewController on iOS.
version: 3.0.1
version: 3.0.2
homepage: https://plus.fluttercommunity.dev/
repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/

Expand All @@ -22,7 +22,7 @@ flutter:
default_package: share_plus_windows

dependencies:
meta: ^1.3.0
meta: ^1.7.0
mime: ^1.0.0
flutter:
sdk: flutter
Expand Down