capacitor-plugin-vonage 0.0.5 → 0.0.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.
@@ -1,4 +1,6 @@
1
1
  package com.managemyhealth.plugin.vonage;
2
+ import com.getcapacitor.Bridge;
3
+ import com.getcapacitor.PluginHandle;
2
4
  import com.getcapacitor.annotation.ActivityCallback;
3
5
  import com.opentok.android.OpentokError;
4
6
  import com.opentok.android.Session;
@@ -7,11 +9,15 @@ import com.opentok.android.Stream;
7
9
  import com.opentok.android.Subscriber;
8
10
 
9
11
  import android.app.Activity;
12
+ import android.content.Context;
10
13
  import android.content.Intent;
11
14
  import android.os.Handler;
12
15
  import android.os.Looper;
13
16
  import android.util.Log;
14
17
 
18
+ import androidx.activity.result.ActivityResult;
19
+ import androidx.lifecycle.ViewModelProvider;
20
+
15
21
  import com.getcapacitor.JSObject;
16
22
  import com.getcapacitor.Plugin;
17
23
  import com.getcapacitor.PluginCall;
@@ -20,15 +26,53 @@ import com.getcapacitor.annotation.CapacitorPlugin;
20
26
 
21
27
 
22
28
  @CapacitorPlugin(name = "vonage",requestCodes = {999})
23
- public class vonagePlugin extends Plugin {
29
+ public class vonagePlugin extends Plugin{
24
30
  String Tag = "VONAGETAG";
25
31
  Boolean isProvid=false;
32
+ Boolean videstarted=false;
26
33
  private Session session;
34
+ private static vonagePlugin instance;
35
+
36
+ public PluginCall endPluginCal;
37
+ private static Bridge staticBridge = null;
38
+
39
+ public static vonagePlugin getInstance() {
40
+ if (instance == null) {
41
+ instance = new vonagePlugin();
42
+ }
43
+ instance.videoCallStarted();
44
+ return instance;
45
+ }
46
+
27
47
 
28
48
  private String TAG = "Capacitor_Vonage_plugin";
29
49
 
30
- @PluginMethod()
50
+ @PluginMethod(returnType = PluginMethod.RETURN_CALLBACK)
51
+ public void setPatientOnlineStatus(PluginCall call) {
52
+ final Boolean isOnline = call.getBoolean("isOnline");
53
+
54
+ Handler mainHandler = new Handler(Looper.getMainLooper());
55
+ Context appCon = this.bridge.getContext();
56
+ Runnable myRunnable = new Runnable() {
57
+ @Override
58
+ public void run() {
59
+ try{
60
+ // VideoCallActivity temp = new VideoCallActivity();
61
+ VideoCallActivity.instance.patientStatusChanged(isOnline);
62
+ }catch (Exception e){
63
+ showLog("temp");
64
+ showLog(e.toString());
65
+ }
66
+ }
67
+ };
68
+ mainHandler.post(myRunnable);
69
+
70
+ }
71
+ @PluginMethod(returnType = PluginMethod.RETURN_CALLBACK)
31
72
  public void endVideoCall(PluginCall call) {
73
+
74
+
75
+
32
76
  showLog("endVideoCallPluginMethod");
33
77
 
34
78
 
@@ -48,42 +92,80 @@ public class vonagePlugin extends Plugin {
48
92
  mainHandler.post(myRunnable);
49
93
 
50
94
  }
51
- @PluginMethod()
95
+ @PluginMethod(returnType = PluginMethod.RETURN_CALLBACK)
52
96
  public void openVideoCallWindow(PluginCall call) {
97
+ endPluginCal = call;
53
98
 
54
- JSObject eventData = new JSObject();
55
- eventData.put("key", "value test value");
56
- final String API_KEY = call.getString("apiKey");
57
- final String SESSION_ID = call.getString("sessionId");
58
- final String TOKEN = call.getString("token");
59
- final String PUBLISHERNAME = call.getString("publisherName");
60
- final String SUBSCRIBERNAME = call.getString("subscriberName");
61
- final Boolean ISPROVIDER = call.getBoolean("isProvider");
62
- isProvid = ISPROVIDER;
99
+ {
100
+ call.setKeepAlive(true);
101
+ JSObject eventData = new JSObject();
102
+ eventData.put("key", "value test value");
103
+ final String API_KEY = call.getString("apiKey");
104
+ final String SESSION_ID = call.getString("sessionId");
105
+ final String TOKEN = call.getString("token");
106
+ final String PUBLISHERNAME = call.getString("publisherName");
107
+ final String SUBSCRIBERNAME = call.getString("subscriberName");
108
+ final Boolean ISPROVIDER = call.getBoolean("isProvider");
109
+ final Boolean isPatientOnline = call.getBoolean("isPatientOnline");
110
+ final String profilePicApiUrl = call.getString("profilePhoto");
111
+ showLog("profilePicApiUrl");
112
+ showLog(profilePicApiUrl);
113
+ isProvid = ISPROVIDER;
63
114
  // initializeSession(API_KEY, SESSION_ID, TOKEN);
64
- Intent intent = new Intent(getContext(), VideoCallActivity.class);
65
- intent.putExtra("apiKey",API_KEY);
66
- intent.putExtra("sessionId",SESSION_ID);
67
- intent.putExtra("token",TOKEN);
68
- intent.putExtra("subscriberName",SUBSCRIBERNAME);
69
- intent.putExtra("publisherName",PUBLISHERNAME);
70
- intent.putExtra("isProvider",ISPROVIDER);
71
- // intent.putExtra("callbackIdentifier", );
72
- // notifyListeners("onDataReceived", );
73
- // StartedCall();
74
- Handler handler = new Handler();
75
- int delayMillis = 2000;
115
+ Intent intent = new Intent(getBridge().getActivity(), VideoCallActivity.class);
116
+ intent.putExtra("apiKey", API_KEY);
117
+ intent.putExtra("sessionId", SESSION_ID);
118
+ intent.putExtra("token", TOKEN);
119
+ intent.putExtra("subscriberName", SUBSCRIBERNAME);
120
+ intent.putExtra("publisherName", PUBLISHERNAME);
121
+ intent.putExtra("isProvider", ISPROVIDER);
122
+ intent.putExtra("isPatientOnline", isPatientOnline);
123
+ intent.putExtra("profilePicApiUrl", profilePicApiUrl);
124
+
125
+ Handler handler = new Handler();
126
+ int delayMillis = 2000;
76
127
 
128
+ handler.postDelayed(new Runnable() {
129
+ @Override
130
+ public void run() {
131
+ eventData.put("isProvider", ISPROVIDER);
132
+
133
+ }
134
+ }, delayMillis);
135
+
136
+ eventData.put("isProvider", isProvid);
137
+ showLog("testing resolve endPluginCal");
138
+ endPluginCal.resolve(eventData);
139
+ this.startActivityForResult(call, intent, "onAcitivtyClosed");
140
+ call.setKeepAlive(false);
141
+ }
142
+
143
+ }
144
+ public void videoCallStarted() {
145
+
146
+ Handler handler = new Handler();
147
+ int delayMillis = 1000;
148
+ JSObject eventData1 = new JSObject();
149
+ eventData1.put("key", "value test value");
150
+ eventData1.put("isProvider", isProvid);
151
+ showLog("eventData");
152
+ showLog(eventData1.toString());
77
153
  handler.postDelayed(new Runnable() {
78
154
  @Override
79
155
  public void run() {
80
- eventData.put("isProvider", ISPROVIDER);
81
- notifyListeners("VideoCallStarted",eventData);
82
- Log.d("VIDEOCALL","isProvider634");
156
+
157
+ // notifyListeners("VideoCallStarted",eventData1);
158
+ notifing("VideoCallStarted",eventData1);
159
+ // Log.d("VIDEOCALL00","isProvider634");
160
+
83
161
  }
84
162
  }, delayMillis);
85
- startActivityForResult(call,intent,999);
86
- call.resolve();
163
+ }
164
+ private void notifing(String text,JSObject obj){
165
+ Log.d("VIDEOCALL0","isProvider634");
166
+
167
+ notifyListeners(text,obj);
168
+ Log.d("VIDEOCALL00","isProvider634");
87
169
 
88
170
  }
89
171
 
@@ -158,4 +240,72 @@ public class vonagePlugin extends Plugin {
158
240
  private void showLog(String log){
159
241
  Log.d(Tag,log);
160
242
  }
243
+ private void test(PluginCall call){
244
+ JSObject eventData = new JSObject();
245
+ eventData.put("key", "value test value");
246
+ eventData.put("isProvider", isProvid);
247
+ showLog("updatevonageplugin called");
248
+ notifyListeners("VideoCallStarted",eventData);
249
+ showLog("updatevonageplugin called after");
250
+ call.resolve();
251
+ }
252
+ @ActivityCallback
253
+ private void onAcitivtyClosed(PluginCall call, ActivityResult result) {
254
+ if (call == null) {
255
+ JSObject eventData = new JSObject();
256
+ if (isProvid) {
257
+ eventData.put("isProvider", true);
258
+ notifyListeners("VideoCallEnded", eventData);
259
+ } else {
260
+ eventData.put("isProvider", false);
261
+ Log.d(TAG, "CODE 98 -----------");
262
+ notifyListeners("VideoCallEnded", eventData);
263
+ }
264
+ return;
265
+ }
266
+ }
267
+ @Override
268
+ public void load() {
269
+ super.load();
270
+ staticBridge = this.bridge;
271
+ }
272
+
273
+ public void update(final String value) {
274
+ if (value=="admit") {
275
+ vonagePlugin
276
+ localNotificationsPlugin = vonagePlugin.getVonageLocalPluginInstance();
277
+ if (localNotificationsPlugin != null) {
278
+ JSObject eventData = new JSObject();
279
+ eventData.put("isProvider", true);
280
+ localNotificationsPlugin.notifyListeners("VideoCallStarted", eventData, true);
281
+ }
282
+ } else if(value=="deny") {
283
+ vonagePlugin
284
+ localNotificationsPlugin = vonagePlugin.getVonageLocalPluginInstance();
285
+ if (localNotificationsPlugin != null){
286
+ JSObject eventData = new JSObject();
287
+ eventData.put("isProvider", true);
288
+ localNotificationsPlugin.notifyListeners("VideoCallEnded", eventData, true);
289
+ }
290
+ }else if(value =="send"){
291
+ vonagePlugin
292
+ localNotificationsPlugin = vonagePlugin.getVonageLocalPluginInstance();
293
+ if (localNotificationsPlugin != null){
294
+ JSObject eventData = new JSObject();
295
+ eventData.put("isProvider", true);
296
+ localNotificationsPlugin.notifyListeners("SendNotification", eventData, true);
297
+ }
298
+
299
+ }
300
+ }
301
+ public static vonagePlugin getVonageLocalPluginInstance() {
302
+ if (staticBridge != null && staticBridge.getWebView() != null) {
303
+ PluginHandle handle = staticBridge.getPlugin("vonage");
304
+ if (handle == null) {
305
+ return null;
306
+ }
307
+ return (vonagePlugin) handle.getInstance();
308
+ }
309
+ return null;
310
+ }
161
311
  }
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <shape xmlns:android="http://schemas.android.com/apk/res/android">
3
+ <solid android:color="#DFF6ED"/> <!-- Set your desired background color -->
4
+ <corners android:radius="8dp"/> <!-- Set your desired border radius -->
5
+ <stroke
6
+ android:color="#60D2A7"
7
+ android:width="2dp"/>
8
+ </shape>
9
+
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <shape xmlns:android="http://schemas.android.com/apk/res/android">
3
+ <solid android:color="#E4EAED"/> <!-- Set your desired background color -->
4
+ <corners android:radius="8dp"/> <!-- Set your desired border radius -->
5
+ <stroke
6
+ android:color="#C4CBCF"
7
+ android:width="2dp"/>
8
+ </shape>
9
+
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <selector xmlns:android="http://schemas.android.com/apk/res/android">
3
+ <!-- res/drawable/circle_background.xml -->
4
+ <shape>
5
+ <solid android:color="#00FF00" />
6
+ <corners android:radius="500dp" />
7
+ </shape>
8
+
9
+ </selector>
@@ -8,6 +8,8 @@
8
8
  android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
9
9
  tools:context=".VideoCallActivity">
10
10
 
11
+
12
+
11
13
  <androidx.constraintlayout.widget.ConstraintLayout
12
14
  android:layout_width="match_parent"
13
15
  android:layout_height="match_parent"
@@ -36,14 +38,7 @@
36
38
  android:id="@+id/subscriber_container"
37
39
  android:layout_width="fill_parent"
38
40
  android:layout_height="match_parent"
39
- android:background="#9b9c98" >
40
-
41
- <ImageView
42
- android:id="@+id/image_view"
43
- android:layout_width="150dp"
44
- android:layout_height="150dp"
45
- android:scaleType="centerCrop" />
46
- </FrameLayout>
41
+ android:background="#ffffff" />
47
42
 
48
43
  <TextView
49
44
  android:id="@+id/publisherName"
@@ -56,8 +51,7 @@
56
51
 
57
52
  android:text="Publisher Name"
58
53
  android:textColor="@android:color/white"
59
- android:textSize="16sp"
60
- android:visibility="visible" />
54
+ android:textSize="16sp" />
61
55
  <TextView
62
56
  android:id="@+id/timerTextView"
63
57
  android:layout_width="140dp"
@@ -79,42 +73,135 @@
79
73
  android:layout_marginRight="16dp"
80
74
  android:layout_marginBottom="80dp"
81
75
  android:background="#9b9c98"
82
- android:layout_below="@id/subscriberName"
76
+ android:layout_below="@id/publisherName"
83
77
 
84
78
  android:padding="2dp" >
79
+ <TextView
80
+ android:id="@+id/subscriberName"
81
+ android:layout_width="100dp"
82
+ android:layout_height="wrap_content"
83
+ android:layout_gravity="center_vertical|bottom"
84
+ android:paddingBottom="6dp"
85
+ android:text="@string/subscriber_name"
86
+ android:textColor="@android:color/white"
87
+ android:visibility="visible"
88
+ android:textSize="12sp" />
85
89
 
86
90
  </FrameLayout>
87
- <TextView
88
- android:id="@+id/subscriberName"
89
- android:layout_width="100dp"
91
+
92
+ <de.hdodenhof.circleimageview.CircleImageView
93
+ xmlns:app="http://schemas.android.com/apk/res-auto"
94
+ android:id="@+id/image_view"
95
+ android:layout_width="120dp"
96
+ android:layout_height="120dp"
97
+ app:civ_border_width="2dp"
98
+ android:layout_gravity="center_horizontal"
99
+ android:layout_marginTop="130dp"
100
+ android:visibility="visible"
101
+ app:civ_border_color="#ffffff"/>
102
+ <LinearLayout
103
+ xmlns:android="http://schemas.android.com/apk/res/android"
104
+ android:id="@+id/providerViewLayout"
105
+ android:layout_width="match_parent"
106
+ android:layout_marginTop="250dp"
90
107
  android:layout_height="wrap_content"
91
- android:layout_gravity="bottom|end"
92
- android:textSize="12sp"
93
- android:text="Subscriber Name"
94
- android:paddingBottom="25dp"
95
- android:layout_marginRight="16dp"
96
- android:layout_marginBottom="80dp"
97
- android:textColor="@android:color/white" />
98
- <androidx.cardview.widget.CardView
99
- android:layout_width="155dp"
100
- android:layout_height="155dp"
101
- app:cardCornerRadius="250dp"
102
- app:cardBackgroundColor="@android:color/white">
108
+ android:orientation="vertical"
109
+ android:gravity="center"
110
+ android:padding="16dp">
111
+ <TextView
112
+ android:id="@+id/publisherNameView"
113
+ android:layout_width="180dp"
114
+ android:layout_height="wrap_content"
115
+ android:paddingBottom="4dp"
116
+ android:text="@string/publisher_name"
117
+ android:textColor="#000000"
118
+ android:textSize="18sp"
119
+ android:gravity="center"
120
+ />
121
+
122
+
123
+ <TextView
124
+ android:id="@+id/waiting"
125
+ android:layout_width="80dp"
126
+ android:layout_height="wrap_content"
127
+ android:text="@string/waiting"
128
+ android:textColor="#000000"
129
+ android:paddingBottom="4dp"
130
+ android:paddingTop="4dp"
131
+ android:textSize="12sp"
132
+ android:layout_marginTop="10dp"
133
+ android:background="#DFF6ED"
134
+ android:gravity="center_vertical|center_horizontal"
135
+ tools:ignore="DuplicateIds" />
136
+
137
+ <LinearLayout
138
+ android:layout_width="match_parent"
139
+ android:layout_height="wrap_content"
140
+ android:orientation="horizontal"
141
+ android:gravity="center"
142
+
143
+ android:padding="16dp">
144
+
145
+
146
+ <!-- Button 1 -->
147
+ <Button
148
+ android:id="@+id/admit"
149
+ android:layout_width="65dp"
150
+ android:layout_height="35dp"
151
+ android:background="@drawable/button_background"
152
+ android:text="@string/admit"
153
+ android:textColor="#000000"
154
+
155
+ android:layout_marginEnd="8dp"/>
156
+
157
+ <!-- Button 2 -->
158
+ <Button
159
+ android:id="@+id/deny"
160
+ android:layout_width="65dp"
161
+ android:layout_height="35dp"
162
+ android:background="@drawable/button_background2"
163
+ android:text="@string/deny"
164
+ android:textColor="#000000"
165
+ android:layout_marginStart="8dp"/>
166
+ <Button
167
+ android:id="@+id/senddata"
168
+ android:layout_width="205dp"
169
+ android:layout_height="35dp"
170
+ android:background="@drawable/button_background"
171
+ android:text="@string/sendvalue"
172
+ android:textColor="#000000"
173
+ android:layout_marginStart="8dp"/>
174
+
175
+
176
+
177
+ </LinearLayout>
178
+ <LinearLayout
179
+ android:layout_width="match_parent"
180
+ android:layout_height="wrap_content"
181
+ android:orientation="horizontal"
182
+ android:gravity="center"
183
+
184
+ android:padding="16dp">
185
+ <!-- Button 3 -->
186
+
187
+
188
+ </LinearLayout>
103
189
 
104
- <androidx.cardview.widget.CardView
105
- android:layout_width="150dp"
106
- android:layout_height="150dp"
107
- app:cardCornerRadius="250dp"
108
- android:layout_gravity="center">
109
190
 
110
- </androidx.cardview.widget.CardView>
191
+ </LinearLayout>
192
+
193
+ <!-- <ImageView-->
194
+ <!-- android:layout_width="150dp"-->
195
+ <!-- android:layout_height="150dp"-->
196
+ <!-- android:scaleType="centerCrop"/>-->
197
+
111
198
 
112
- </androidx.cardview.widget.CardView>
113
199
 
114
200
 
115
201
  </FrameLayout>
116
202
 
117
203
  </LinearLayout>
204
+
118
205
  <androidx.constraintlayout.widget.Guideline
119
206
  android:id="@+id/guidelineBottom"
120
207
  android:layout_width="wrap_content"
@@ -125,7 +212,7 @@
125
212
  android:layout_width="fill_parent"
126
213
  android:layout_height="53dp"
127
214
  android:layout_alignParentBottom="false"
128
- android:gravity="clip_horizontal"
215
+ android:gravity="clip_horizontal|center_horizontal"
129
216
  android:orientation="horizontal"
130
217
  app:layout_constraintBottom_toBottomOf="@+id/main"
131
218
  app:layout_constraintStart_toStartOf="parent"
@@ -134,40 +221,47 @@
134
221
  <!-- Image resource for the FAB -->
135
222
 
136
223
  <!-- Set the background image using android:background -->
137
- <ImageView
138
- android:id="@+id/imageView1"
139
- android:layout_width="0dp"
140
- android:layout_height="50dp"
141
- android:layout_weight="1"
142
- android:src="@drawable/callend"
143
- android:contentDescription="EndCall"
144
- />
224
+
145
225
  <ImageView
146
226
  android:id="@+id/imageView4"
147
- android:layout_width="0dp"
227
+ android:layout_width="50dp"
148
228
  android:layout_height="50dp"
149
- android:layout_weight="1"
150
229
  android:contentDescription="Switch Camera"
151
230
  android:src="@drawable/cameraswitch" />
231
+ <Space
232
+ android:layout_width="22dp"
233
+ android:layout_height="match_parent"/>
152
234
 
153
235
  <ImageView
154
236
  android:id="@+id/imageView3"
155
- android:layout_width="0dp"
237
+ android:layout_width="50dp"
156
238
  android:layout_height="50dp"
157
- android:layout_weight="1"
158
239
  android:src="@drawable/cameraonwhite"
159
240
  android:contentDescription="Camera On/Off"
160
241
  />
242
+ <Space
243
+ android:layout_width="22dp"
244
+ android:layout_height="match_parent"/>
161
245
 
162
246
 
163
247
  <ImageView
164
248
  android:id="@+id/imageView2"
165
- android:layout_width="0dp"
249
+ android:layout_width="50dp"
166
250
  android:layout_height="50dp"
167
- android:layout_weight="1"
168
251
  android:src="@drawable/microphoneonwhite"
169
252
  android:contentDescription="Mute"
170
253
  />
254
+ <Space
255
+ android:layout_width="22dp"
256
+ android:layout_height="match_parent"/>
257
+ <ImageView
258
+ android:id="@+id/imageView1"
259
+ android:layout_width="50dp"
260
+ android:layout_height="50dp"
261
+ android:src="@drawable/callend"
262
+ android:contentDescription="EndCall"
263
+ />
264
+
171
265
 
172
266
  ////////////////////////////
173
267
  </LinearLayout>
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <resources>
3
+ <color name="waiting">#DFF6ED</color>//DFF6ED
4
+ <color name="offline">#ffd6ca</color>//ffd6ca
5
+ </resources>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <resources>
3
+ <string name="subscriber_name">Subscriber Name</string>
4
+ <string name="admit">Admit</string>
5
+ <string name="deny">Deny</string>
6
+ <string name="sendvalue">SEND E-MAIL NOTIFICATION</string>
7
+ <string name="publisher_name">Publisher Name</string>
8
+ <string name="waiting">WAITING</string>
9
+ </resources>