react-native-share 7.3.4 → 7.3.7
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.
- package/android/src/main/java/cl/json/RNShareModule.java +2 -1
- package/android/src/main/java/cl/json/social/InstagramStoriesShare.java +1 -1
- package/android/src/main/java/cl/json/social/WhatsAppBusinessShare.java +13 -13
- package/android/src/main/java/cl/json/social/WhatsAppShare.java +12 -12
- package/package.json +1 -1
|
@@ -14,6 +14,7 @@ import com.facebook.react.bridge.ReadableMap;
|
|
|
14
14
|
import com.facebook.react.bridge.Callback;
|
|
15
15
|
|
|
16
16
|
import java.util.HashMap;
|
|
17
|
+
import java.util.Locale;
|
|
17
18
|
import java.util.Map;
|
|
18
19
|
|
|
19
20
|
import cl.json.social.EmailShare;
|
|
@@ -141,7 +142,7 @@ public class RNShareModule extends ReactContextBaseJavaModule implements Activit
|
|
|
141
142
|
public Map<String, Object> getConstants() {
|
|
142
143
|
Map<String, Object> constants = new HashMap<>();
|
|
143
144
|
for (SHARES val : SHARES.values()) {
|
|
144
|
-
constants.put(val.toString().toUpperCase(), val.toString());
|
|
145
|
+
constants.put(val.toString().toUpperCase(Locale.ROOT), val.toString());
|
|
145
146
|
}
|
|
146
147
|
return constants;
|
|
147
148
|
}
|
|
@@ -100,7 +100,7 @@ public class InstagramStoriesShare extends SingleShareIntent {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
if (this.hasValidKey("stickerImage", options)) {
|
|
103
|
-
ShareFile stickerAsset = new ShareFile(options.getString("stickerImage"), "sticker", useInternalStorage, this.reactContext);
|
|
103
|
+
ShareFile stickerAsset = new ShareFile(options.getString("stickerImage"), "image/png", "sticker", useInternalStorage, this.reactContext);
|
|
104
104
|
|
|
105
105
|
if (!hasBackgroundAsset) {
|
|
106
106
|
this.intent.setType("image/*");
|
|
@@ -15,9 +15,9 @@ public class WhatsAppBusinessShare extends SingleShareIntent {
|
|
|
15
15
|
private static final String PLAY_STORE_LINK = "market://details?id=com.whatsapp.w4b";
|
|
16
16
|
|
|
17
17
|
private static final String START_CONVERSATION_CLASS = "com.whatsapp.Conversation";
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
private static final int START_ACTIVITY_TIME_GAP_MS =
|
|
18
|
+
|
|
19
|
+
// must be small enough so that both activities are triggered while the app is still on foreground
|
|
20
|
+
private static final int START_ACTIVITY_TIME_GAP_MS = 10;
|
|
21
21
|
|
|
22
22
|
public WhatsAppBusinessShare(ReactApplicationContext reactContext) {
|
|
23
23
|
super(reactContext);
|
|
@@ -27,22 +27,22 @@ public class WhatsAppBusinessShare extends SingleShareIntent {
|
|
|
27
27
|
super.open(options);
|
|
28
28
|
|
|
29
29
|
if (options.hasKey("whatsAppNumber")) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
try {
|
|
31
|
+
// create an empty conversation in case it's not on contacts
|
|
32
|
+
this.getIntent().setComponent(new ComponentName(PACKAGE, START_CONVERSATION_CLASS));
|
|
33
|
+
this.openIntentChooser();
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
try {
|
|
35
|
+
// leave room for the conversation to be created
|
|
37
36
|
Thread.sleep(START_ACTIVITY_TIME_GAP_MS);
|
|
38
|
-
|
|
37
|
+
|
|
38
|
+
} catch (Exception ex) {
|
|
39
39
|
ex.printStackTrace();
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
// share to conversation
|
|
43
|
-
this.getIntent().setComponent(new ComponentName(PACKAGE, SHARE_TO_CONVERSATION_CLASS));
|
|
44
41
|
}
|
|
45
42
|
|
|
43
|
+
// restore default behavior to share to conversation
|
|
44
|
+
this.getIntent().setComponent(null);
|
|
45
|
+
|
|
46
46
|
// extra params here
|
|
47
47
|
this.openIntentChooser();
|
|
48
48
|
}
|
|
@@ -15,9 +15,9 @@ public class WhatsAppShare extends SingleShareIntent {
|
|
|
15
15
|
private static final String PLAY_STORE_LINK = "market://details?id=com.whatsapp";
|
|
16
16
|
|
|
17
17
|
private static final String START_CONVERSATION_CLASS = "com.whatsapp.Conversation";
|
|
18
|
-
private static final String SHARE_TO_CONVERSATION_CLASS = "com.whatsapp.ContactPicker";
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
// must be small enough so that both activities are triggered while the app is still on foreground
|
|
20
|
+
private static final int START_ACTIVITY_TIME_GAP_MS = 10;
|
|
21
21
|
|
|
22
22
|
public WhatsAppShare(ReactApplicationContext reactContext) {
|
|
23
23
|
super(reactContext);
|
|
@@ -27,22 +27,22 @@ public class WhatsAppShare extends SingleShareIntent {
|
|
|
27
27
|
super.open(options);
|
|
28
28
|
|
|
29
29
|
if (options.hasKey("whatsAppNumber")) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
try {
|
|
31
|
+
// create an empty conversation in case it's not on contacts
|
|
32
|
+
this.getIntent().setComponent(new ComponentName(PACKAGE, START_CONVERSATION_CLASS));
|
|
33
|
+
this.openIntentChooser();
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
// leave room for the conversation to be created
|
|
36
|
-
try {
|
|
35
|
+
// leave room for the conversation to be created
|
|
37
36
|
Thread.sleep(START_ACTIVITY_TIME_GAP_MS);
|
|
38
|
-
|
|
37
|
+
|
|
38
|
+
} catch (Exception ex) {
|
|
39
39
|
ex.printStackTrace();
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
// share to conversation
|
|
43
|
-
this.getIntent().setComponent(new ComponentName(PACKAGE, SHARE_TO_CONVERSATION_CLASS));
|
|
44
41
|
}
|
|
45
42
|
|
|
43
|
+
// restore default behavior to share to conversation
|
|
44
|
+
this.getIntent().setComponent(null);
|
|
45
|
+
|
|
46
46
|
// extra params here
|
|
47
47
|
this.openIntentChooser();
|
|
48
48
|
}
|
package/package.json
CHANGED