react-native-share 7.9.0 → 7.9.1

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.
@@ -45,13 +45,10 @@ public class InstagramShare extends SingleShareIntent {
45
45
  return;
46
46
  }
47
47
  String type = options.getString("type");
48
+ String extension = this.getExtension(type);
48
49
  Boolean isImage = type.startsWith("image");
49
50
 
50
- if (isImage) {
51
- this.openInstagramIntentChooserForImage(url, chooserTitle);
52
- } else {
53
- super.openIntentChooser();
54
- }
51
+ this.openInstagramIntentChooser(url, chooserTitle, isImage, extension);
55
52
  }
56
53
 
57
54
  protected void openInstagramUrlScheme(String url) {
@@ -61,18 +58,33 @@ public class InstagramShare extends SingleShareIntent {
61
58
  super.openIntentChooser();
62
59
  }
63
60
 
64
- protected void openInstagramIntentChooserForImage(String url, String chooserTitle) {
61
+ private String getExtension(String url) {
62
+ String[] ext = url.split("/");
63
+ return ext[ext.length -1];
64
+ }
65
+
66
+ protected void openInstagramIntentChooser(String url, String chooserTitle, Boolean isImage, String extension) {
65
67
  Boolean shouldUseInternalStorage = ShareIntent.hasValidKey("useInternalStorage", options) && options.getBoolean("useInternalStorage");
66
- ShareFile shareFile = new ShareFile(url, "image/jpeg", "image", shouldUseInternalStorage, this.reactContext);
68
+ ShareFile shareFile = isImage
69
+ ? new ShareFile(url, "image/" + extension, "image", shouldUseInternalStorage, this.reactContext)
70
+ : new ShareFile(url, "video/" + extension, "video", shouldUseInternalStorage, this.reactContext);
67
71
  Uri uri = shareFile.getURI();
68
72
 
69
73
  Intent feedIntent = new Intent(Intent.ACTION_SEND);
70
- feedIntent.setType("image/*");
74
+
75
+ if (isImage) {
76
+ feedIntent.setType("image/*");
77
+ } else {
78
+ feedIntent.setType("video/*");
79
+ }
80
+
71
81
  feedIntent.putExtra(Intent.EXTRA_STREAM, uri);
72
82
  feedIntent.setPackage(PACKAGE);
73
83
 
74
84
  Intent storiesIntent = new Intent("com.instagram.share.ADD_TO_STORY");
75
- storiesIntent.setDataAndType(uri, "jpg");
85
+
86
+ storiesIntent.setDataAndType(uri, extension);
87
+
76
88
  storiesIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
77
89
  storiesIntent.setPackage(PACKAGE);
78
90
 
@@ -83,6 +95,7 @@ public class InstagramShare extends SingleShareIntent {
83
95
  Activity activity = this.reactContext.getCurrentActivity();
84
96
  activity.grantUriPermission(PACKAGE, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
85
97
  this.reactContext.startActivity(chooserIntent);
98
+ TargetChosenReceiver.sendCallback(true, true, this.getIntent().getPackage());
86
99
  }
87
100
 
88
101
  @Override
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": "7.9.0",
4
+ "version": "7.9.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/react-native-community/react-native-share.git"