cordova-plugin-ymchat 3.2.0 → 3.3.0

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/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.3.0]
9
+
10
+ ### Added
11
+
12
+ - **Configurable Upload Sources** (Android only) — restricts the attachment picker to specific sources via `cordova.plugins.ymchat.setAllowedUploadSources(['camera'])` (or `['file']`, or both). Bridges the native Android SDK's `allowedUploadSources` config for the first time (`YMChatbot-Android` since v3.3.0, already pinned since v3.0.0 of this plugin). No iOS equivalent exists natively, so calling this on iOS is a no-op — the plugin doesn't implement the selector there.
13
+
8
14
  ## [3.2.0]
9
15
 
10
16
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-ymchat",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "Cordova plugin to integrate yellow.ai chatbot",
5
5
  "cordova": {
6
6
  "id": "cordova-plugin-ymchat",
package/plugin.xml CHANGED
@@ -1,5 +1,5 @@
1
1
  <?xml version='1.0' encoding='utf-8'?>
2
- <plugin id="cordova-plugin-ymchat" version="3.2.0"
2
+ <plugin id="cordova-plugin-ymchat" version="3.3.0"
3
3
  xmlns="http://apache.org/cordova/ns/plugins/1.0"
4
4
  xmlns:android="http://schemas.android.com/apk/res/android">
5
5
  <name>ymchat</name>
@@ -10,6 +10,9 @@ import org.apache.cordova.CordovaPlugin;
10
10
  import org.json.JSONArray;
11
11
  import org.json.JSONObject;
12
12
 
13
+ import java.util.ArrayList;
14
+ import java.util.List;
15
+
13
16
  public class YmChatCordova extends CordovaPlugin {
14
17
 
15
18
  final String Tag = "YmChat";
@@ -89,6 +92,9 @@ public class YmChatCordova extends CordovaPlugin {
89
92
  case "useLiteVersion":
90
93
  useLiteVersion(args, callbackContext);
91
94
  return true;
95
+ case "setAllowedUploadSources":
96
+ setAllowedUploadSources(args, callbackContext);
97
+ return true;
92
98
  case "reloadBot":
93
99
  reloadBot();
94
100
  return true;
@@ -153,6 +159,19 @@ public class YmChatCordova extends CordovaPlugin {
153
159
  }
154
160
  }
155
161
 
162
+ private void setAllowedUploadSources(JSONArray args, CallbackContext callbackContext) {
163
+ try {
164
+ JSONArray sourcesArray = args.getJSONArray(0);
165
+ List<String> sources = new ArrayList<>();
166
+ for (int i = 0; i < sourcesArray.length(); i++) {
167
+ sources.add(sourcesArray.getString(i));
168
+ }
169
+ ymChatService.setAllowedUploadSources(sources, callbackContext);
170
+ } catch (Exception e) {
171
+ Utils.genericErrorHelper(e, callbackContext);
172
+ }
173
+ }
174
+
156
175
  private void setDisableActionsOnLoad(JSONArray args, CallbackContext callbackContext) {
157
176
  try {
158
177
  boolean shouldDisableActionsOnLoad = args.getBoolean(0);
@@ -8,6 +8,7 @@ import com.yellow.ai.ymchat.utils.Utils;
8
8
  import com.yellowmessenger.ymchat.YMChat;
9
9
  import com.yellowmessenger.ymchat.YMConfig;
10
10
  import com.yellowmessenger.ymchat.models.YMActivationMode;
11
+ import com.yellowmessenger.ymchat.models.YMUploadSource;
11
12
  import com.yellowmessenger.ymchat.models.YellowCallback;
12
13
  import com.yellowmessenger.ymchat.models.YellowDataCallback;
13
14
  import com.yellowmessenger.ymchat.models.YellowUnreadMessageResponse;
@@ -18,7 +19,9 @@ import org.apache.cordova.PluginResult;
18
19
  import org.json.JSONArray;
19
20
  import org.json.JSONObject;
20
21
 
22
+ import java.util.ArrayList;
21
23
  import java.util.HashMap;
24
+ import java.util.List;
22
25
 
23
26
  public class YmChatService {
24
27
  YMChat ymChat;
@@ -227,6 +230,14 @@ public class YmChatService {
227
230
  ymChat.config.useLiteVersion = shouldUseLiteVersion;
228
231
  }
229
232
 
233
+ public void setAllowedUploadSources(List<String> sources, CallbackContext callbackContext) {
234
+ List<YMUploadSource> uploadSources = new ArrayList<>();
235
+ for (String source : sources) {
236
+ uploadSources.add(YMUploadSource.valueOf(source.toUpperCase()));
237
+ }
238
+ ymChat.config.allowedUploadSources = uploadSources;
239
+ }
240
+
230
241
  public void setMicIconColor(String color, CallbackContext callbackContext) {
231
242
  ymChat.config.speechConfig.fabIconColor = color;
232
243
  }
package/www/ymchat.js CHANGED
@@ -71,6 +71,9 @@ const YmChatAPI = {
71
71
  useLiteVersion: (shouldUseLiteVersion) => {
72
72
  exec(null, null, "ymchat", "useLiteVersion", [shouldUseLiteVersion]);
73
73
  },
74
+ setAllowedUploadSources: (sources) => {
75
+ exec(null, null, "ymchat", "setAllowedUploadSources", [sources]);
76
+ },
74
77
  reloadBot: () => {
75
78
  exec(null, null, "ymchat", "reloadBot", []);
76
79
  },