metamap-capacitor-plugin 4.0.2 → 4.0.3
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/build.gradle
CHANGED
|
@@ -51,7 +51,7 @@ dependencies {
|
|
|
51
51
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
52
52
|
implementation project(':capacitor-android')
|
|
53
53
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
54
|
-
implementation ('com.metamap:android-sdk:3.
|
|
54
|
+
implementation ('com.metamap:android-sdk:3.32.0')
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
|
|
@@ -15,6 +15,11 @@ import com.metamap.metamap_sdk.Metadata;
|
|
|
15
15
|
import org.json.JSONObject;
|
|
16
16
|
import org.json.JSONException;
|
|
17
17
|
|
|
18
|
+
|
|
19
|
+
import java.util.Iterator;
|
|
20
|
+
|
|
21
|
+
import android.graphics.Color;
|
|
22
|
+
|
|
18
23
|
@CapacitorPlugin(name = "MetaMapCapacitor")
|
|
19
24
|
public class MetaMapCapacitorPlugin extends Plugin {
|
|
20
25
|
|
|
@@ -30,14 +35,41 @@ public class MetaMapCapacitorPlugin extends Plugin {
|
|
|
30
35
|
final String flowId = call.getString("flowId");
|
|
31
36
|
final JSONObject metadata = call.getObject("metadata", new JSObject());
|
|
32
37
|
try {
|
|
33
|
-
metadata.put("sdkType", "capacitor");
|
|
34
38
|
if (clientId == null) {
|
|
35
|
-
|
|
39
|
+
Log.e("MetaMapCapacitorPlugin", "\"Client Id should be not null\"");
|
|
36
40
|
} else {
|
|
37
|
-
|
|
41
|
+
|
|
42
|
+
Iterator<String> keys = metadata.keys();
|
|
43
|
+
|
|
44
|
+
Metadata.Builder metadataBuilder = new Metadata.Builder();
|
|
45
|
+
|
|
46
|
+
while (keys.hasNext()) {
|
|
47
|
+
String key = keys.next();
|
|
48
|
+
try {
|
|
49
|
+
if (key.toLowerCase().contains("color")) {
|
|
50
|
+
String hexColor = (String) metadata.get(key);
|
|
51
|
+
int color = Color.parseColor(hexColor);
|
|
52
|
+
if (hexColor.length() == 9) {
|
|
53
|
+
color = Color.argb(Color.blue(color), Color.alpha(color), Color.red(color), Color.green(color));
|
|
54
|
+
}
|
|
55
|
+
metadataBuilder.with(key, color);
|
|
56
|
+
} else {
|
|
57
|
+
metadataBuilder.with(key, metadata.get(key));
|
|
58
|
+
}
|
|
59
|
+
} catch (Exception e) {
|
|
60
|
+
throw new RuntimeException(e);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
metadataBuilder.with("sdkType", "capacitor");
|
|
64
|
+
Metadata data = metadataBuilder.build();
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
Intent flowIntent = MetamapSdk.INSTANCE.createFlowIntent(bridge.getActivity(), clientId, flowId, data);
|
|
38
70
|
startActivityForResult(call, flowIntent, "callback");
|
|
39
71
|
}
|
|
40
|
-
} catch(
|
|
72
|
+
} catch(Exception excepion) {
|
|
41
73
|
call.reject("Verification failed");
|
|
42
74
|
}
|
|
43
75
|
}
|