react-native-share 8.2.1 → 8.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,6 +27,17 @@ public class InstagramShare extends SingleShareIntent {
27
27
  public void open(ReadableMap options) throws ActivityNotFoundException {
28
28
  super.open(options);
29
29
 
30
+ if (!ShareIntent.hasValidKey("type", options)) {
31
+ Log.e("RNShare", "No type provided");
32
+ return;
33
+ }
34
+ String type = options.getString("type");
35
+
36
+ if (type.startsWith("text")) {
37
+ this.openInstagramIntentChooserForText(chooserTitle);
38
+ return;
39
+ }
40
+
30
41
  if (!ShareIntent.hasValidKey("url", options)) {
31
42
  Log.e("RNShare", "No url provided");
32
43
  return;
@@ -39,16 +50,10 @@ public class InstagramShare extends SingleShareIntent {
39
50
  return;
40
51
  }
41
52
 
42
-
43
- if (!ShareIntent.hasValidKey("type", options)) {
44
- Log.e("RNShare", "No type provided");
45
- return;
46
- }
47
- String type = options.getString("type");
48
53
  String extension = this.getExtension(type);
49
54
  Boolean isImage = type.startsWith("image");
50
55
 
51
- this.openInstagramIntentChooser(url, chooserTitle, isImage, extension);
56
+ this.openInstagramIntentChooserForMedia(url, chooserTitle, isImage, extension);
52
57
  }
53
58
 
54
59
  protected void openInstagramUrlScheme(String url) {
@@ -63,7 +68,14 @@ public class InstagramShare extends SingleShareIntent {
63
68
  return ext[ext.length -1];
64
69
  }
65
70
 
66
- protected void openInstagramIntentChooser(String url, String chooserTitle, Boolean isImage, String extension) {
71
+ protected void openInstagramIntentChooserForText(String chooserTitle) {
72
+ this.getIntent().setPackage(PACKAGE);
73
+ this.getIntent().setType("text/plain");
74
+ this.getIntent().setAction(Intent.ACTION_SEND);
75
+ super.openIntentChooser();
76
+ }
77
+
78
+ protected void openInstagramIntentChooserForMedia(String url, String chooserTitle, Boolean isImage, String extension) {
67
79
  Boolean shouldUseInternalStorage = ShareIntent.hasValidKey("useInternalStorage", options) && options.getBoolean("useInternalStorage");
68
80
  ShareFile shareFile = isImage
69
81
  ? new ShareFile(url, "image/" + extension, "image", shouldUseInternalStorage, this.reactContext)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-share",
3
3
  "description": "Social share, sending simple data to other apps.",
4
- "version": "8.2.1",
4
+ "version": "8.2.2",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/react-native-community/react-native-share.git"