capacitor-plugin-vonage 0.1.2 → 0.1.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.
@@ -3,11 +3,7 @@ package com.managemyhealth.plugin.vonage;
|
|
3
3
|
|
4
4
|
|
5
5
|
import android.annotation.SuppressLint;
|
6
|
-
import android.app.Activity;
|
7
|
-
import android.app.Application;
|
8
6
|
import android.content.Context;
|
9
|
-
import android.graphics.Color;
|
10
|
-
import android.graphics.PorterDuff;
|
11
7
|
import android.os.AsyncTask;
|
12
8
|
import android.app.ActionBar;
|
13
9
|
import android.content.Intent;
|
@@ -16,7 +12,6 @@ import android.graphics.BitmapFactory;
|
|
16
12
|
import android.opengl.GLSurfaceView;
|
17
13
|
import android.os.Bundle;
|
18
14
|
import android.os.Handler;
|
19
|
-
import android.os.Looper;
|
20
15
|
import android.util.Log;
|
21
16
|
import android.view.Gravity;
|
22
17
|
import android.view.LayoutInflater;
|
@@ -28,15 +23,9 @@ import android.widget.LinearLayout;
|
|
28
23
|
import android.widget.ProgressBar;
|
29
24
|
import android.widget.TextView;
|
30
25
|
import android.widget.Toast;
|
31
|
-
|
32
26
|
import androidx.annotation.NonNull;
|
33
27
|
import androidx.appcompat.app.AppCompatActivity;
|
34
|
-
import androidx.lifecycle.ViewModelProvider;
|
35
|
-
|
36
|
-
|
37
28
|
import com.getcapacitor.Bridge;
|
38
|
-
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
39
|
-
|
40
29
|
import com.opentok.android.BaseVideoRenderer;
|
41
30
|
import com.opentok.android.OpentokError;
|
42
31
|
import com.opentok.android.Publisher;
|
@@ -45,22 +34,12 @@ import com.opentok.android.Session;
|
|
45
34
|
import com.opentok.android.Stream;
|
46
35
|
import com.opentok.android.Subscriber;
|
47
36
|
import com.opentok.android.SubscriberKit;
|
48
|
-
//import com.tokbox.sample.basicvideochat.network.APIService;
|
49
|
-
//import com.tokbox.sample.basicvideochat.network.GetSessionResponse;
|
50
|
-
|
51
37
|
import java.io.InputStream;
|
52
38
|
import java.util.List;
|
53
|
-
|
54
39
|
import javax.annotation.Nullable;
|
55
|
-
|
56
|
-
import pub.devrel.easypermissions.AfterPermissionGranted;
|
57
40
|
import pub.devrel.easypermissions.EasyPermissions;
|
58
|
-
|
59
|
-
|
60
|
-
public class VideoCallActivity extends AppCompatActivity implements EasyPermissions.PermissionCallbacks , Application.ActivityLifecycleCallbacks{
|
41
|
+
public class VideoCallActivity extends AppCompatActivity implements EasyPermissions.PermissionCallbacks{
|
61
42
|
private static final String TAG = VideoCallActivity.class.getSimpleName();
|
62
|
-
private static final int PERMISSIONS_REQUEST_CODE = 124;
|
63
|
-
|
64
43
|
public Session session;
|
65
44
|
private static Bridge staticBridge = null;
|
66
45
|
private String dummyProfile = "https://www.gravatar.com/avatar/?d=mp";
|
@@ -73,7 +52,6 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
73
52
|
boolean isPatientOnline = false;
|
74
53
|
boolean isMuted = false;
|
75
54
|
boolean isCamOff = false;
|
76
|
-
private static boolean isCallinprogress = false;
|
77
55
|
public boolean temptest = false;
|
78
56
|
boolean isTimeron = false;
|
79
57
|
boolean isEndall = false;
|
@@ -84,70 +62,34 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
84
62
|
private ProgressBar progressBar;
|
85
63
|
private FrameLayout subscriberViewContainer;
|
86
64
|
private TextView publisherNameTextView;
|
87
|
-
private FloatingActionButton fabCameraOff;
|
88
65
|
private ImageView imageViewEndcall;
|
89
66
|
private ImageView imageViewMute;
|
90
67
|
private ImageView imageViewCamOff;
|
91
68
|
private ImageView circleAvatar;
|
92
|
-
private boolean isAppInForeground;
|
93
|
-
|
94
69
|
private ImageView imageViewCamSwitch;
|
95
70
|
public static Button sendNotifications ;
|
96
71
|
public static TextView patientStatus;
|
97
72
|
public static TextView publishernameView;
|
98
73
|
public static Button admit;
|
99
74
|
public static Button deny ;
|
100
|
-
|
101
|
-
|
102
|
-
private static final int LOG_INTERVAL_MILLIS = 1000; // Log every 100 milliseconds
|
103
|
-
|
104
|
-
private final Handler handler = new Handler();
|
105
|
-
private final Runnable logRunnable = new Runnable() {
|
106
|
-
@Override
|
107
|
-
public void run() {
|
108
|
-
Log.d(TAG, "Log message");
|
109
|
-
// if(temptest){
|
110
|
-
// Log.d(TAG, "temptest "+ temptest);
|
111
|
-
//
|
112
|
-
// }else{
|
113
|
-
// Log.d(TAG, "temptest "+temptest);
|
114
|
-
//
|
115
|
-
// }
|
116
|
-
handler.postDelayed(this, LOG_INTERVAL_MILLIS);
|
117
|
-
}
|
118
|
-
};
|
119
75
|
Boolean ISPROVIDER = false;
|
120
|
-
// Boolean testobserver = false;
|
121
76
|
private TextView timerTextView;
|
122
77
|
private long startTime = 0;
|
123
|
-
// private List<Observer> observers;
|
124
|
-
// private List<String> observers1;
|
125
|
-
// public VideoCallActivity() {
|
126
|
-
// observers = new ArrayList<>();
|
127
|
-
// observers1 = new ArrayList<>();
|
128
|
-
// }
|
129
|
-
|
130
78
|
|
131
79
|
private PublisherKit.PublisherListener publisherListener = new PublisherKit.PublisherListener() {
|
132
80
|
@Override
|
133
81
|
public void onStreamCreated(PublisherKit publisherKit, Stream stream) {
|
134
82
|
Log.d(TAG, "onStreamCreated: Publisher Stream Created. Own stream " + stream.getStreamId());
|
135
|
-
|
136
|
-
|
137
83
|
}
|
138
|
-
|
139
84
|
@Override
|
140
85
|
public void onStreamDestroyed(PublisherKit publisherKit, Stream stream) {
|
141
86
|
Log.d(TAG, "onStreamDestroyed: Publisher Stream Destroyed. Own stream " + stream.getStreamId());
|
142
87
|
}
|
143
|
-
|
144
88
|
@Override
|
145
89
|
public void onError(PublisherKit publisherKit, OpentokError opentokError) {
|
146
90
|
finishWithMessage("PublisherKit onError: " + opentokError.getMessage());
|
147
91
|
}
|
148
|
-
|
149
92
|
};
|
150
|
-
|
151
93
|
private final Session.SessionListener sessionListener = new Session.SessionListener() {
|
152
94
|
@Override
|
153
95
|
public void onConnected(Session session) {
|
@@ -205,7 +147,6 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
205
147
|
}
|
206
148
|
@Override
|
207
149
|
public void onStreamReceived(Session session, Stream stream) {
|
208
|
-
isCallinprogress = true;
|
209
150
|
ProviderViewLayout = findViewById(R.id.providerViewLayout);
|
210
151
|
if(ISPROVIDER) {
|
211
152
|
ProviderViewLayout.setVisibility(View.VISIBLE);
|
@@ -216,7 +157,6 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
216
157
|
admit.setVisibility(View.GONE);
|
217
158
|
deny.setVisibility(View.GONE);
|
218
159
|
sendNotifications.setVisibility(View.GONE);
|
219
|
-
|
220
160
|
if (subscriber == null) {
|
221
161
|
subscriber = new Subscriber.Builder(VideoCallActivity.this, stream).build();
|
222
162
|
subscriber.getRenderer().setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);
|
@@ -229,10 +169,11 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
229
169
|
showToast(SUBSCRIBERNAME + "joined the call");
|
230
170
|
}
|
231
171
|
}
|
232
|
-
|
233
172
|
@Override
|
234
173
|
public void onStreamDropped(Session session, Stream stream) {
|
235
174
|
circleAvatar.setVisibility(View.VISIBLE); // Show the view
|
175
|
+
publishernameView.setVisibility(View.VISIBLE);
|
176
|
+
|
236
177
|
if(!ISPROVIDER){
|
237
178
|
if(session!=null){
|
238
179
|
session.disconnect();
|
@@ -251,12 +192,9 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
251
192
|
subscriber = null;
|
252
193
|
subscriberViewContainer.removeAllViews();
|
253
194
|
showToast(SUBSCRIBERNAME + " left the call");
|
254
|
-
|
255
195
|
}
|
256
196
|
}
|
257
197
|
}
|
258
|
-
|
259
|
-
|
260
198
|
@Override
|
261
199
|
public void onError(Session session, OpentokError opentokError) {
|
262
200
|
finishWithMessage("Session error: " + opentokError.getMessage());
|
@@ -265,76 +203,46 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
265
203
|
SubscriberKit.AudioStatsListener aaa = new SubscriberKit.AudioStatsListener(){
|
266
204
|
@Override
|
267
205
|
public void onAudioStats(SubscriberKit subscriberKit, SubscriberKit.SubscriberAudioStats subscriberAudioStats) {
|
268
|
-
|
269
206
|
}
|
270
207
|
};
|
271
208
|
SubscriberKit.AudioLevelListener sss = new SubscriberKit.AudioLevelListener(){
|
272
|
-
|
273
209
|
@Override
|
274
|
-
public void onAudioLevelUpdated(SubscriberKit subscriberKit, float v) {
|
275
|
-
|
276
|
-
}
|
210
|
+
public void onAudioLevelUpdated(SubscriberKit subscriberKit, float v) {}
|
277
211
|
};
|
278
|
-
|
279
212
|
SubscriberKit.VideoListener videoListener = new SubscriberKit.VideoListener() {
|
280
|
-
|
281
213
|
@Override
|
282
|
-
public void onVideoDataReceived(SubscriberKit subscriberKit) {
|
283
|
-
|
284
|
-
}
|
285
|
-
|
214
|
+
public void onVideoDataReceived(SubscriberKit subscriberKit) {}
|
286
215
|
@Override
|
287
216
|
public void onVideoDisabled(SubscriberKit subscriberKit, String s) {
|
288
217
|
showToast(SUBSCRIBERNAME + " video disabled");
|
289
|
-
|
290
218
|
circleAvatar.setVisibility(View.VISIBLE); // Show the view
|
291
|
-
|
292
|
-
|
293
219
|
}
|
294
|
-
|
295
220
|
@Override
|
296
221
|
public void onVideoEnabled(SubscriberKit subscriberKit, String s) {
|
297
222
|
showToast(SUBSCRIBERNAME + " video enabled");
|
298
223
|
circleAvatar.setVisibility(View.GONE); // Hide the view
|
299
|
-
|
300
|
-
|
301
224
|
}
|
302
|
-
|
303
225
|
@Override
|
304
|
-
public void onVideoDisableWarning(SubscriberKit subscriberKit) {
|
305
|
-
|
306
|
-
}
|
307
|
-
|
226
|
+
public void onVideoDisableWarning(SubscriberKit subscriberKit) {}
|
308
227
|
@Override
|
309
|
-
public void onVideoDisableWarningLifted(SubscriberKit subscriberKit) {
|
310
|
-
|
311
|
-
}
|
228
|
+
public void onVideoDisableWarningLifted(SubscriberKit subscriberKit) {}
|
312
229
|
};
|
313
|
-
|
314
230
|
SubscriberKit.SubscriberListener subscriberListener = new SubscriberKit.SubscriberListener() {
|
315
|
-
|
316
231
|
@Override
|
317
232
|
public void onConnected(SubscriberKit subscriberKit) {
|
318
233
|
Log.d(TAG, "onConnected: Subscriber connected. Stream: " + subscriberKit.getStream().getStreamId());
|
319
234
|
}
|
320
|
-
|
321
235
|
@Override
|
322
236
|
public void onDisconnected(SubscriberKit subscriberKit) {
|
323
237
|
Log.d(TAG, "onDisconnected: Subscriber disconnected. Stream: " + subscriberKit.getStream().getStreamId());
|
324
238
|
showToast(SUBSCRIBERNAME+" left the call");
|
325
|
-
|
326
|
-
|
327
239
|
}
|
328
|
-
|
329
|
-
|
330
|
-
|
331
240
|
@Override
|
332
241
|
public void onError(SubscriberKit subscriberKit, OpentokError opentokError) {
|
333
242
|
showToast(SUBSCRIBERNAME + " failed to connect to the call");
|
334
243
|
finishWithMessage("SubscriberKit onError: " + opentokError.getMessage());
|
335
244
|
}
|
336
245
|
};
|
337
|
-
|
338
246
|
@Override
|
339
247
|
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
340
248
|
super.onActivityResult(requestCode, resultCode, data);
|
@@ -342,55 +250,40 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
342
250
|
Log.d(TAG,"code === 99 in second");
|
343
251
|
}else{
|
344
252
|
Log.d(TAG,"code === 98 in second");
|
345
|
-
|
346
|
-
}
|
347
253
|
}
|
348
|
-
|
254
|
+
}
|
349
255
|
@Override
|
350
256
|
public void onBackPressed() {
|
351
257
|
if(session!=null){
|
352
258
|
session.disconnect();
|
353
259
|
}
|
354
260
|
}
|
355
|
-
|
356
|
-
|
357
261
|
@SuppressLint("MissingInflatedId")
|
358
262
|
@Override
|
359
263
|
protected void onCreate(Bundle savedInstanceState) {
|
360
|
-
|
361
264
|
Intent intent = getIntent();
|
362
|
-
|
363
265
|
super.onCreate(savedInstanceState);
|
364
|
-
// observers = new ArrayList<>();
|
365
|
-
// observers1 = new ArrayList<>();
|
366
266
|
instance = new VideoCallActivity();
|
367
|
-
handler.post(logRunnable);
|
368
|
-
|
369
267
|
setContentView(R.layout.video_call_layout);
|
370
268
|
sendNotifications = findViewById(R.id.senddata);
|
371
269
|
main = findViewById(R.id.main);
|
372
270
|
progressBar = findViewById(R.id.progressBar);
|
373
|
-
|
374
|
-
circleAvatar = findViewById(R.id.image_view);
|
375
|
-
|
271
|
+
circleAvatar = findViewById(R.id.image_view);
|
376
272
|
getSupportActionBar().hide();
|
377
273
|
ActionBar actionBar = getActionBar();
|
378
274
|
if (actionBar != null) {
|
379
275
|
actionBar.hide();
|
380
276
|
}
|
381
|
-
|
277
|
+
patientStatus = findViewById(R.id.waiting);
|
382
278
|
admit = findViewById(R.id.admit);
|
383
279
|
deny = findViewById(R.id.deny);
|
384
|
-
|
385
280
|
if (intent != null) {
|
386
|
-
// Retrieve the data using the same key you used to put it in the Intent
|
387
281
|
String TOKEN = intent.getStringExtra("token");
|
388
282
|
String SESSION_ID = intent.getStringExtra("sessionId");
|
389
283
|
String API_KEY = intent.getStringExtra("apiKey");
|
390
|
-
|
391
|
-
|
284
|
+
SUBSCRIBERNAME = intent.getStringExtra("subscriberName");
|
285
|
+
PUBLISHERNAME = intent.getStringExtra("publisherName");
|
392
286
|
profilePicApiUrl = intent.getStringExtra("profilePicApiUrl");
|
393
|
-
Log.d("profilePicApiUrl",profilePicApiUrl);
|
394
287
|
isPatientOnline = intent.getBooleanExtra("isPatientOnline",false);
|
395
288
|
ISPROVIDER = intent.getBooleanExtra("isProvider",false);
|
396
289
|
publisherViewContainer = findViewById(R.id.publisher_container);
|
@@ -398,7 +291,6 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
398
291
|
publisherNameTextView = findViewById(R.id.publisherName);
|
399
292
|
publishernameView = findViewById(R.id.publisherNameView);
|
400
293
|
TextView subscriberNameTextView = findViewById(R.id.subscriberName);
|
401
|
-
|
402
294
|
if(ISPROVIDER){
|
403
295
|
if (isPatientOnline) {
|
404
296
|
patientStatus.setText("WAITING");
|
@@ -413,8 +305,6 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
413
305
|
patientStatus.setText("OFFLINE");
|
414
306
|
patientStatus.setBackgroundColor(getResources().getColor(R.color.offline));
|
415
307
|
}
|
416
|
-
}else{
|
417
|
-
|
418
308
|
}
|
419
309
|
publisherNameTextView.setText(SUBSCRIBERNAME);
|
420
310
|
publishernameView.setText(SUBSCRIBERNAME);
|
@@ -423,7 +313,6 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
423
313
|
timerTextView = findViewById(R.id.timerTextView);
|
424
314
|
startTime = System.currentTimeMillis();
|
425
315
|
isTimeron =true;
|
426
|
-
// startTimer();
|
427
316
|
ProviderViewLayout = findViewById(R.id.providerViewLayout);
|
428
317
|
if(ISPROVIDER){
|
429
318
|
ProviderViewLayout.setVisibility(View.VISIBLE);
|
@@ -433,27 +322,16 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
433
322
|
String dummyImage = profilePicApiUrl.length()>10?profilePicApiUrl:dummyProfile;
|
434
323
|
new urltoSource((ImageView) findViewById(R.id.image_view)).execute(dummyImage);
|
435
324
|
initializeSession(API_KEY,SESSION_ID , TOKEN);
|
436
|
-
|
437
|
-
|
438
325
|
}
|
439
|
-
|
440
|
-
|
441
|
-
|
442
326
|
imageViewEndcall = findViewById(R.id.imageView1);
|
443
327
|
imageViewMute = findViewById(R.id.imageView2);
|
444
328
|
imageViewCamOff = findViewById(R.id.imageView3);
|
445
329
|
imageViewCamSwitch = findViewById(R.id.imageView4);
|
446
|
-
|
447
|
-
|
448
|
-
|
449
330
|
sendNotifications.setOnClickListener(new View.OnClickListener() {
|
450
331
|
@Override
|
451
332
|
public void onClick(View v) {
|
452
|
-
|
453
333
|
notifyObservers("send");
|
454
334
|
sendNotifications.setVisibility(View.GONE);
|
455
|
-
|
456
|
-
|
457
335
|
}
|
458
336
|
});
|
459
337
|
admit.setOnClickListener(new View.OnClickListener() {
|
@@ -484,11 +362,9 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
484
362
|
}
|
485
363
|
}
|
486
364
|
});
|
487
|
-
|
488
365
|
imageViewMute.setOnClickListener(new View.OnClickListener() {//mute and unmute audio
|
489
366
|
@Override
|
490
367
|
public void onClick(View v) {
|
491
|
-
|
492
368
|
if(publisher!=null) {
|
493
369
|
if (!isMuted) {
|
494
370
|
publisher.setPublishAudio(false);
|
@@ -506,21 +382,14 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
506
382
|
@Override
|
507
383
|
public void onClick(View v) {
|
508
384
|
if(publisher!=null) {
|
509
|
-
|
510
385
|
if (!isCamOff) {
|
511
386
|
publisher.setPublishVideo(false);
|
512
387
|
imageViewCamOff.setImageResource(R.drawable.cameraoff);
|
513
|
-
// imageViewCamSwitch.setVisibility(View.GONE);
|
514
|
-
|
515
|
-
|
516
388
|
} else {
|
517
389
|
publisher.setPublishVideo(true);
|
518
390
|
imageViewCamOff.setImageResource(R.drawable.cameraonwhite);
|
519
|
-
// imageViewCamSwitch.setVisibility(View.VISIBLE);
|
520
|
-
|
521
391
|
}
|
522
392
|
isCamOff = !isCamOff;
|
523
|
-
|
524
393
|
}
|
525
394
|
}
|
526
395
|
});
|
@@ -532,11 +401,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
532
401
|
}
|
533
402
|
}
|
534
403
|
});
|
535
|
-
|
536
|
-
|
537
|
-
|
538
404
|
}
|
539
|
-
|
540
405
|
@Override
|
541
406
|
protected void onPause() {
|
542
407
|
super.onPause();
|
@@ -544,11 +409,9 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
544
409
|
session.onPause();
|
545
410
|
}
|
546
411
|
}
|
547
|
-
|
548
412
|
@Override
|
549
413
|
protected void onResume() {
|
550
414
|
super.onResume();
|
551
|
-
|
552
415
|
if (session != null) {
|
553
416
|
session.onResume();
|
554
417
|
}
|
@@ -557,23 +420,8 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
557
420
|
if(session!=null){
|
558
421
|
session.disconnect();
|
559
422
|
}
|
560
|
-
|
561
423
|
isEndall =true;
|
562
|
-
// killvc();
|
563
|
-
|
564
424
|
}
|
565
|
-
// public void killvc(){
|
566
|
-
// runOnUiThread(new Runnable() {
|
567
|
-
// @Override
|
568
|
-
// public void run() {
|
569
|
-
// Log.d("endVideoCall","PluginMethodendVideoCall");
|
570
|
-
// Log.d("endVideoCall",session.toString());
|
571
|
-
//
|
572
|
-
// }
|
573
|
-
// });
|
574
|
-
//
|
575
|
-
//
|
576
|
-
// }
|
577
425
|
private void startTimer() {
|
578
426
|
Handler handler = new Handler();
|
579
427
|
handler.postDelayed(new Runnable() {
|
@@ -585,14 +433,9 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
585
433
|
int hours = minutes / 60;
|
586
434
|
seconds %= 60;
|
587
435
|
minutes %= 60;
|
588
|
-
|
589
436
|
String timeString = String.format("%02d:%02d:%02d", hours, minutes, seconds);
|
590
|
-
// Log.d(TAG, String.valueOf(currentTime));
|
591
|
-
|
592
437
|
// Update the TextView with the formatted time
|
593
438
|
timerTextView.setText(timeString);
|
594
|
-
|
595
|
-
// Continue updating the timer
|
596
439
|
if(isTimeron)
|
597
440
|
startTimer();
|
598
441
|
}
|
@@ -603,54 +446,15 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
603
446
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
604
447
|
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
|
605
448
|
}
|
606
|
-
|
607
449
|
@Override
|
608
450
|
public void onPermissionsGranted(int requestCode, List<String> perms) {
|
609
451
|
Log.d(TAG, "onPermissionsGranted:" + requestCode + ": " + perms);
|
610
452
|
}
|
611
|
-
|
612
453
|
@Override
|
613
454
|
public void onPermissionsDenied(int requestCode, List<String> perms) {
|
614
455
|
finishWithMessage("onPermissionsDenied: " + requestCode + ": " + perms);
|
615
456
|
}
|
616
|
-
|
617
|
-
@AfterPermissionGranted(PERMISSIONS_REQUEST_CODE)
|
618
|
-
// private void requestPermissions() {
|
619
|
-
// String[] perms = {Manifest.permission.INTERNET, Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO};
|
620
|
-
//
|
621
|
-
// if (EasyPermissions.hasPermissions(this, perms)) {
|
622
|
-
//
|
623
|
-
// if (ServerConfig.hasChatServerUrl()) {
|
624
|
-
// // Custom server URL exists - retrieve session config
|
625
|
-
// if(!ServerConfig.isValid()) {
|
626
|
-
// finishWithMessage("Invalid chat server url: " + ServerConfig.CHAT_SERVER_URL);
|
627
|
-
// return;
|
628
|
-
// }
|
629
|
-
//
|
630
|
-
// initRetrofit();
|
631
|
-
//// getSession();
|
632
|
-
// } else {
|
633
|
-
// // Use hardcoded session config
|
634
|
-
// if(!OpenTokConfig.isValid()) {
|
635
|
-
// finishWithMessage("Invalid OpenTokConfig. " + OpenTokConfig.getDescription());
|
636
|
-
// return;
|
637
|
-
// }
|
638
|
-
//
|
639
|
-
// initializeSession(OpenTokConfig.API_KEY, OpenTokConfig.SESSION_ID, OpenTokConfig.TOKEN);
|
640
|
-
// }
|
641
|
-
// } else {
|
642
|
-
// EasyPermissions.requestPermissions(this, getString(R.string.rationale_video_app), PERMISSIONS_REQUEST_CODE, perms);
|
643
|
-
// }
|
644
|
-
// }
|
645
|
-
|
646
|
-
|
647
|
-
|
648
457
|
private void initializeSession(String apiKey, String sessionId, String token) {
|
649
|
-
instance.isCallinprogress= false;
|
650
|
-
Log.i(TAG, "initializeSession: " + "initializeSession");
|
651
|
-
Log.i(TAG, "apiKey: " + apiKey);
|
652
|
-
Log.i(TAG, "sessionId: " + sessionId);
|
653
|
-
Log.i(TAG, "token: " + token);
|
654
458
|
/*
|
655
459
|
The context used depends on the specific use case, but usually, it is desired for the session to
|
656
460
|
live outside of the Activity e.g: live between activities. For a production applications,
|
@@ -659,51 +463,12 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
659
463
|
session = new Session.Builder(this, apiKey, sessionId).build();
|
660
464
|
session.setSessionListener(sessionListener);
|
661
465
|
session.connect(token);
|
662
|
-
// circleAvatar.setVisibility(View.GONE); // Hide the view
|
663
|
-
|
664
|
-
Log.d("initializeSession","session.toString()");
|
665
|
-
Log.d("initializeSession",session.toString());
|
666
466
|
}
|
667
467
|
|
668
|
-
// private void initRetrofit() {
|
669
|
-
// HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
670
|
-
// logging.setLevel(Level.BODY);
|
671
|
-
//
|
672
|
-
// OkHttpClient client = new OkHttpClient.Builder()
|
673
|
-
// .addInterceptor(logging)
|
674
|
-
// .build();
|
675
|
-
//
|
676
|
-
// retrofit = new Retrofit.Builder()
|
677
|
-
// .baseUrl(ServerConfig.CHAT_SERVER_URL)
|
678
|
-
// .addConverterFactory(MoshiConverterFactory.create())
|
679
|
-
// .client(client)
|
680
|
-
// .build();
|
681
|
-
//
|
682
|
-
//// apiService = retrofit.create(APIService.class);
|
683
|
-
// }
|
684
|
-
|
685
|
-
private void showToast(String message) {
|
686
|
-
// try{
|
687
|
-
// if(isAppInForeground()){
|
688
|
-
showGreenToast(getApplicationContext(),message);
|
689
|
-
// }
|
690
|
-
// Toast toast = Toast.makeText(this, message, Toast.LENGTH_LONG);
|
691
|
-
// View view = toast.getView();
|
692
|
-
// int color = Color.parseColor("#1fc600");
|
693
|
-
// int colorText = Color.parseColor("#ffffff");
|
694
|
-
// view.getBackground().setColorFilter(Color.GREEN, PorterDuff.Mode.SRC_IN);
|
695
|
-
// TextView text = view.findViewById(android.R.id.message);
|
696
|
-
// text.setTextColor(Color.BLACK);
|
697
|
-
// toast.setGravity(Gravity.TOP, 0, 0);
|
698
|
-
// toast.show();
|
699
|
-
// }catch(Exception e){
|
700
|
-
// Log.d("toastlogex",e.toString());
|
701
|
-
// }
|
702
|
-
}
|
703
468
|
|
469
|
+
private void showToast(String message) {showGreenToast(getApplicationContext(),message);}
|
704
470
|
private void finishWithMessage(String message) {
|
705
471
|
Log.e(TAG, message);
|
706
|
-
// Toast.makeText(this, message, Toast.LENGTH_LONG).show();
|
707
472
|
if(session!=null){
|
708
473
|
session.disconnect();
|
709
474
|
}
|
@@ -714,16 +479,15 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
714
479
|
this.finish();
|
715
480
|
}
|
716
481
|
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
482
|
public void patientStatusChanged(Boolean isOnline) {
|
722
483
|
Log.d("patientStatusChanged", String.valueOf(isOnline));
|
723
484
|
Log.d("patientStatusChanged2", String.valueOf(isOnline));
|
724
485
|
Log.d("patientStatusChanged2", String.valueOf(isOnline));
|
486
|
+
Log.d("patientStatusChanged2", String.valueOf(instance.ISPROVIDER));
|
487
|
+
|
488
|
+
// if(instance.ISPROVIDER){
|
489
|
+
Log.d("patientStatuISPROVIDER", String.valueOf(isOnline));
|
725
490
|
|
726
|
-
if(!instance.isCallinprogress){
|
727
491
|
runOnUiThread(new Runnable() {
|
728
492
|
@Override
|
729
493
|
public void run() {
|
@@ -735,91 +499,46 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
735
499
|
sendNotifications.setVisibility(View.GONE);
|
736
500
|
admit.setVisibility(View.VISIBLE);
|
737
501
|
deny.setVisibility(View.VISIBLE);
|
502
|
+
publishernameView.setVisibility(View.VISIBLE);
|
503
|
+
|
738
504
|
patientStatus.setBackgroundResource(R.color.waiting);
|
739
|
-
// patientStatus.setBackgroundColor(getResources().getColor(R.color.waiting));
|
740
505
|
} else {
|
741
506
|
Log.d("OFFLINE", String.valueOf(isOnline));
|
742
507
|
patientStatus.setText("OFFLINE");
|
743
508
|
admit.setVisibility(View.GONE);
|
744
509
|
deny.setVisibility(View.GONE);
|
510
|
+
publishernameView.setVisibility(View.VISIBLE);
|
745
511
|
sendNotifications.setVisibility(View.VISIBLE);
|
746
512
|
patientStatus.setText("OFFLINE");
|
747
513
|
patientStatus.setBackgroundResource(R.color.offline);
|
748
|
-
// patientStatus.setBackgroundColor(getResources().getColor(R.color.offline));
|
749
514
|
}
|
750
515
|
|
751
516
|
|
752
517
|
}
|
753
518
|
});
|
754
|
-
}
|
519
|
+
// }
|
755
520
|
}
|
756
521
|
public static void showGreenToast(Context context, String message) {
|
757
522
|
LayoutInflater inflater = LayoutInflater.from(context);
|
758
523
|
View layout = inflater.inflate(R.layout.custom_toast_green_layout, null);
|
759
|
-
|
760
524
|
TextView text = layout.findViewById(R.id.toastView);
|
761
525
|
text.setText(message);
|
762
|
-
|
763
526
|
Toast toast = new Toast(context);
|
764
527
|
toast.setDuration(Toast.LENGTH_SHORT);
|
765
528
|
toast.setView(layout);
|
766
|
-
|
767
|
-
// Set toast position to top right corner
|
768
529
|
toast.setGravity(Gravity.TOP | Gravity.END, 0, 0);
|
769
|
-
|
770
530
|
toast.show();
|
771
531
|
}
|
772
|
-
|
773
|
-
return isAppInForeground;
|
774
|
-
}
|
532
|
+
|
775
533
|
|
776
534
|
public void notifyObservers(String value) {
|
777
535
|
vonagePlugin temp = new vonagePlugin();
|
778
536
|
temp.update(value);
|
779
537
|
}
|
780
|
-
|
781
|
-
@Override
|
782
|
-
public void onActivityCreated(@NonNull Activity activity, @androidx.annotation.Nullable Bundle bundle) {
|
783
|
-
|
784
|
-
}
|
785
|
-
|
786
|
-
@Override
|
787
|
-
public void onActivityStarted(@NonNull Activity activity) {
|
788
|
-
|
789
|
-
}
|
790
|
-
|
791
|
-
@Override
|
792
|
-
public void onActivityResumed(@NonNull Activity activity) {
|
793
|
-
Log.d("isAppInForeground", String.valueOf(isAppInForeground));
|
794
|
-
isAppInForeground = true;
|
795
|
-
}
|
796
|
-
|
797
|
-
@Override
|
798
|
-
public void onActivityPaused(@NonNull Activity activity) {
|
799
|
-
Log.d("isAppInForeground", String.valueOf(isAppInForeground));
|
800
|
-
isAppInForeground = false;
|
801
|
-
}
|
802
|
-
|
803
|
-
@Override
|
804
|
-
public void onActivityStopped(@NonNull Activity activity) {
|
805
|
-
|
806
|
-
}
|
807
|
-
|
808
|
-
@Override
|
809
|
-
public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle bundle) {
|
810
|
-
|
811
|
-
}
|
812
|
-
|
813
|
-
@Override
|
814
|
-
public void onActivityDestroyed(@NonNull Activity activity) {
|
815
|
-
|
816
|
-
}
|
817
|
-
|
818
538
|
private class urltoSource extends AsyncTask<String, Void, Bitmap> {
|
819
539
|
ImageView imageView;
|
820
540
|
public urltoSource(ImageView imageView) {
|
821
541
|
this.imageView=imageView;
|
822
|
-
// Toast.makeText(getApplicationContext(), "Please wait, it may take a few minute...",Toast.LENGTH_SHORT).show();
|
823
542
|
}
|
824
543
|
protected Bitmap doInBackground(String... urls) {
|
825
544
|
String imageURL=urls[0];
|
@@ -828,7 +547,6 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
828
547
|
InputStream in=new java.net.URL(imageURL).openStream();
|
829
548
|
bimage= BitmapFactory.decodeStream(in);
|
830
549
|
} catch (Exception e) {
|
831
|
-
Log.e("Error Message", e.getMessage());
|
832
550
|
e.printStackTrace();
|
833
551
|
}
|
834
552
|
return bimage;
|
@@ -59,6 +59,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
59
59
|
NotificationCenter.default.addObserver(self, selector: #selector(appMovedToBackground), name: UIApplication.willResignActiveNotification, object: nil)
|
60
60
|
NotificationCenter.default.addObserver(self, selector: #selector(appMovedToForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
|
61
61
|
showActivityIndicator()
|
62
|
+
UserDefaults.standard.set(isProvider, forKey: "isProvider")
|
62
63
|
self.viewSetupMethod()
|
63
64
|
// let jsonParam = videoCallParam.toJSON() as? [String:AnyObject] // can be any type here
|
64
65
|
// print(jsonParam as Any)
|
@@ -147,7 +148,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
147
148
|
}
|
148
149
|
@objc func setPatientOnlineStatus(_ notification: Notification) {
|
149
150
|
// let userinfo = notification.userInfo?["isOnline"] as? Bool
|
150
|
-
|
151
|
+
// if(!isCallInProgress){
|
151
152
|
if let ispatientOnline = notification.userInfo?["isOnline"] as? Bool{
|
152
153
|
isPatientOnLine = ispatientOnline
|
153
154
|
}else{
|
@@ -156,7 +157,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
156
157
|
DispatchQueue.main.async {
|
157
158
|
self.patientStatusChanged()
|
158
159
|
}
|
159
|
-
|
160
|
+
// }
|
160
161
|
// if let isOnline = notification.userInfo?["isOnline"] as? Bool , !isCallInProgress {
|
161
162
|
// isPatientOnLine = isOnline
|
162
163
|
// DispatchQueue.main.async {
|
@@ -379,6 +380,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
379
380
|
sendNotificationBtn.isHidden = true
|
380
381
|
adminBtn.isHidden = false
|
381
382
|
denyBtn.isHidden = false
|
383
|
+
subscriberStatusLabel.isHidden = false
|
382
384
|
subscriberStatusLabel.text = "WAITING"
|
383
385
|
subscriberStatusLabel.backgroundColor = UIColor(hex: "#DFF6ED")
|
384
386
|
subscriberNameLabel.isHidden = false
|
@@ -387,6 +389,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
387
389
|
sendNotificationBtn.isHidden = false
|
388
390
|
adminBtn.isHidden = true
|
389
391
|
denyBtn.isHidden = true
|
392
|
+
subscriberStatusLabel.isHidden = false
|
390
393
|
subscriberStatusLabel.text = "OFFLINE"
|
391
394
|
subscriberStatusLabel.backgroundColor = UIColor(hex: "#ffd6ca")
|
392
395
|
subscriberNameLabel.isHidden = false
|