diff --git a/packages/share_plus/share_plus/CHANGELOG.md b/packages/share_plus/share_plus/CHANGELOG.md index d103573cf0..ac6f708106 100644 --- a/packages/share_plus/share_plus/CHANGELOG.md +++ b/packages/share_plus/share_plus/CHANGELOG.md @@ -1,3 +1,10 @@ +## 3.1.0 + +- Android: Migrate to Kotlin +- Android: Update dependencies, build config updates +- Example: Fix project title +- Example: Set min Flutter version to 1.20.0 + ## 3.0.5 - Fix example embedding issue diff --git a/packages/share_plus/share_plus/README.md b/packages/share_plus/share_plus/README.md index 7484d9a596..f9a32ab6b7 100644 --- a/packages/share_plus/share_plus/README.md +++ b/packages/share_plus/share_plus/README.md @@ -1,16 +1,16 @@ +# Share plugin + [](https://github.com/fluttercommunity/community) +[](https://github.com/fluttercommunity/plus_plugins/actions/workflows/share_plus.yaml) [](https://pub.dev/packages/share_plus) -
-

A Flutter plugin to share content from your Flutter app via the platform's
share dialog.
-Wraps the ACTION_SEND Intent on Android and UIActivityViewController
+Wraps the `ACTION_SEND` Intent on Android and `UIActivityViewController`
on iOS.
## Platform Support
@@ -62,6 +62,3 @@ Check out our documentation website to learn more. [Plus plugins documentation](
### Mobile platforms (Android and iOS)
Due to restrictions set up by Facebook this plugin isn't capable of sharing data reliably to Facebook related apps on Android and iOS. This includes eg. sharing text to the Facebook Messenger. If you require this functionality please check the native Facebook Sharing SDK ([https://developers.facebook.com/docs/sharing](https://developers.facebook.com/docs/sharing)) or search for other Flutter plugins implementing this SDK. More information can be found in [this issue](https://github.com/fluttercommunity/plus_plugins/issues/413).
-
-
-**Important:** As of January 2021, the Flutter team is no longer accepting non-critical PRs for the original set of plugins in `flutter/plugins`, and instead they should be submitted in this project. [You can read more about this announcement here.](https://github.com/flutter/plugins/blob/master/CONTRIBUTING.md#important-note) as well as [in the Flutter 2 announcement blog post.](https://medium.com/flutter/whats-new-in-flutter-2-0-fe8e95ecc65)
diff --git a/packages/share_plus/share_plus/android/build.gradle b/packages/share_plus/share_plus/android/build.gradle
index 1ffb74eb60..4f9ee5dee7 100644
--- a/packages/share_plus/share_plus/android/build.gradle
+++ b/packages/share_plus/share_plus/android/build.gradle
@@ -2,38 +2,42 @@ group 'dev.fluttercommunity.plus.share'
version '1.0-SNAPSHOT'
buildscript {
- repositories {
- google()
- mavenCentral()
- }
+ ext.kotlin_version = '1.6.10'
+ repositories {
+ google()
+ mavenCentral()
+ }
- dependencies {
- classpath 'com.android.tools.build:gradle:7.0.2'
- }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:7.1.1'
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ }
}
rootProject.allprojects {
- repositories {
- google()
- mavenCentral()
- }
+ repositories {
+ google()
+ mavenCentral()
+ }
}
apply plugin: 'com.android.library'
+apply plugin: 'kotlin-android'
android {
- compileSdkVersion 31
+ compileSdkVersion 31
- defaultConfig {
- minSdkVersion 16
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
- }
- lintOptions {
- disable 'InvalidPackage'
- }
+ defaultConfig {
+ minSdkVersion 16
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ }
+ lintOptions {
+ disable 'InvalidPackage'
+ }
- dependencies {
- implementation 'androidx.core:core:1.6.0'
- implementation 'androidx.annotation:annotation:1.2.0'
- }
+ dependencies {
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
+ implementation 'androidx.core:core-ktx:1.7.0'
+ implementation 'androidx.annotation:annotation:1.3.0'
+ }
}
diff --git a/packages/share_plus/share_plus/android/gradle/wrapper/gradle-wrapper.properties b/packages/share_plus/share_plus/android/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000000..41dfb87909
--- /dev/null
+++ b/packages/share_plus/share_plus/android/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/packages/share_plus/share_plus/android/settings.gradle b/packages/share_plus/share_plus/android/settings.gradle
index 64350ae697..82e4e954fa 100644
--- a/packages/share_plus/share_plus/android/settings.gradle
+++ b/packages/share_plus/share_plus/android/settings.gradle
@@ -1 +1 @@
-rootProject.name = 'share'
+rootProject.name = 'share_plus'
diff --git a/packages/share_plus/share_plus/android/src/main/java/dev/fluttercommunity/plus/share/MethodCallHandler.java b/packages/share_plus/share_plus/android/src/main/java/dev/fluttercommunity/plus/share/MethodCallHandler.java
deleted file mode 100644
index d06a87f832..0000000000
--- a/packages/share_plus/share_plus/android/src/main/java/dev/fluttercommunity/plus/share/MethodCallHandler.java
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright 2019 The Flutter Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package dev.fluttercommunity.plus.share;
-
-import androidx.annotation.NonNull;
-import io.flutter.plugin.common.MethodCall;
-import io.flutter.plugin.common.MethodChannel;
-import java.io.*;
-import java.util.List;
-import java.util.Map;
-
-/** Handles the method calls for the plugin. */
-class MethodCallHandler implements MethodChannel.MethodCallHandler {
-
- private final Share share;
-
- MethodCallHandler(Share share) {
- this.share = share;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public void onMethodCall(MethodCall call, @NonNull MethodChannel.Result result) {
- switch (call.method) {
- case "share":
- expectMapArguments(call);
- // Android does not support showing the share sheet at a particular point on screen.
- share.share((String) call.argument("text"), (String) call.argument("subject"));
- result.success(null);
- break;
- case "shareFiles":
- expectMapArguments(call);
-
- // Android does not support showing the share sheet at a particular point on screen.
- try {
- share.shareFiles(
- (ListSee https://developer.android.com/guide/topics/manifest/provider-element.html for details.
- */
-public class ShareFileProvider extends FileProvider {}
diff --git a/packages/share_plus/share_plus/android/src/main/java/dev/fluttercommunity/plus/share/SharePlusPlugin.java b/packages/share_plus/share_plus/android/src/main/java/dev/fluttercommunity/plus/share/SharePlusPlugin.java
deleted file mode 100644
index d10509ae47..0000000000
--- a/packages/share_plus/share_plus/android/src/main/java/dev/fluttercommunity/plus/share/SharePlusPlugin.java
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2019 The Flutter Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package dev.fluttercommunity.plus.share;
-
-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.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 Share share;
- private MethodChannel methodChannel;
-
- @Override
- public void onAttachedToEngine(FlutterPluginBinding binding) {
- methodChannel = new MethodChannel(binding.getBinaryMessenger(), CHANNEL);
- share = new Share(binding.getApplicationContext(), null);
- MethodCallHandler handler = new MethodCallHandler(share);
- methodChannel.setMethodCallHandler(handler);
- }
-
- @Override
- public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
- methodChannel.setMethodCallHandler(null);
- methodChannel = null;
- share = null;
- }
-
- @Override
- public void onAttachedToActivity(ActivityPluginBinding binding) {
- share.setActivity(binding.getActivity());
- }
-
- @Override
- public void onDetachedFromActivity() {
- share.setActivity(null);
- }
-
- @Override
- public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) {
- onAttachedToActivity(binding);
- }
-
- @Override
- public void onDetachedFromActivityForConfigChanges() {
- onDetachedFromActivity();
- }
-}
diff --git a/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/MethodCallHandler.kt b/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/MethodCallHandler.kt
new file mode 100644
index 0000000000..331a201b21
--- /dev/null
+++ b/packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/MethodCallHandler.kt
@@ -0,0 +1,45 @@
+package dev.fluttercommunity.plus.share
+
+import io.flutter.plugin.common.MethodCall
+import io.flutter.plugin.common.MethodChannel
+import java.io.IOException
+
+/** Handles the method calls for the plugin. */
+internal class MethodCallHandler(private val share: Share) : MethodChannel.MethodCallHandler {
+
+ override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
+ when (call.method) {
+ "share" -> {
+ expectMapArguments(call)
+ // Android does not support showing the share sheet at a particular point on screen.
+ share.share(
+ call.argument>("paths")!!,
+ call.argument
?>("mimeTypes"),
+ call.argument