capacitor-plugin-vonage 0.1.1 → 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,74 +62,39 @@ 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) {
154
96
  main.setVisibility(View.VISIBLE);
97
+ startTimer();
155
98
  progressBar.setVisibility(View.INVISIBLE);
156
99
  publisher = new Publisher.Builder(VideoCallActivity.this).build();
157
100
  publisher.setPublisherListener(publisherListener);
@@ -204,7 +147,6 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
204
147
  }
205
148
  @Override
206
149
  public void onStreamReceived(Session session, Stream stream) {
207
- isCallinprogress = true;
208
150
  ProviderViewLayout = findViewById(R.id.providerViewLayout);
209
151
  if(ISPROVIDER) {
210
152
  ProviderViewLayout.setVisibility(View.VISIBLE);
@@ -215,7 +157,6 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
215
157
  admit.setVisibility(View.GONE);
216
158
  deny.setVisibility(View.GONE);
217
159
  sendNotifications.setVisibility(View.GONE);
218
-
219
160
  if (subscriber == null) {
220
161
  subscriber = new Subscriber.Builder(VideoCallActivity.this, stream).build();
221
162
  subscriber.getRenderer().setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);
@@ -228,10 +169,11 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
228
169
  showToast(SUBSCRIBERNAME + "joined the call");
229
170
  }
230
171
  }
231
-
232
172
  @Override
233
173
  public void onStreamDropped(Session session, Stream stream) {
234
174
  circleAvatar.setVisibility(View.VISIBLE); // Show the view
175
+ publishernameView.setVisibility(View.VISIBLE);
176
+
235
177
  if(!ISPROVIDER){
236
178
  if(session!=null){
237
179
  session.disconnect();
@@ -250,12 +192,9 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
250
192
  subscriber = null;
251
193
  subscriberViewContainer.removeAllViews();
252
194
  showToast(SUBSCRIBERNAME + " left the call");
253
-
254
195
  }
255
196
  }
256
197
  }
257
-
258
-
259
198
  @Override
260
199
  public void onError(Session session, OpentokError opentokError) {
261
200
  finishWithMessage("Session error: " + opentokError.getMessage());
@@ -264,76 +203,46 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
264
203
  SubscriberKit.AudioStatsListener aaa = new SubscriberKit.AudioStatsListener(){
265
204
  @Override
266
205
  public void onAudioStats(SubscriberKit subscriberKit, SubscriberKit.SubscriberAudioStats subscriberAudioStats) {
267
-
268
206
  }
269
207
  };
270
208
  SubscriberKit.AudioLevelListener sss = new SubscriberKit.AudioLevelListener(){
271
-
272
209
  @Override
273
- public void onAudioLevelUpdated(SubscriberKit subscriberKit, float v) {
274
-
275
- }
210
+ public void onAudioLevelUpdated(SubscriberKit subscriberKit, float v) {}
276
211
  };
277
-
278
212
  SubscriberKit.VideoListener videoListener = new SubscriberKit.VideoListener() {
279
-
280
213
  @Override
281
- public void onVideoDataReceived(SubscriberKit subscriberKit) {
282
-
283
- }
284
-
214
+ public void onVideoDataReceived(SubscriberKit subscriberKit) {}
285
215
  @Override
286
216
  public void onVideoDisabled(SubscriberKit subscriberKit, String s) {
287
217
  showToast(SUBSCRIBERNAME + " video disabled");
288
-
289
218
  circleAvatar.setVisibility(View.VISIBLE); // Show the view
290
-
291
-
292
219
  }
293
-
294
220
  @Override
295
221
  public void onVideoEnabled(SubscriberKit subscriberKit, String s) {
296
222
  showToast(SUBSCRIBERNAME + " video enabled");
297
223
  circleAvatar.setVisibility(View.GONE); // Hide the view
298
-
299
-
300
224
  }
301
-
302
225
  @Override
303
- public void onVideoDisableWarning(SubscriberKit subscriberKit) {
304
-
305
- }
306
-
226
+ public void onVideoDisableWarning(SubscriberKit subscriberKit) {}
307
227
  @Override
308
- public void onVideoDisableWarningLifted(SubscriberKit subscriberKit) {
309
-
310
- }
228
+ public void onVideoDisableWarningLifted(SubscriberKit subscriberKit) {}
311
229
  };
312
-
313
230
  SubscriberKit.SubscriberListener subscriberListener = new SubscriberKit.SubscriberListener() {
314
-
315
231
  @Override
316
232
  public void onConnected(SubscriberKit subscriberKit) {
317
233
  Log.d(TAG, "onConnected: Subscriber connected. Stream: " + subscriberKit.getStream().getStreamId());
318
234
  }
319
-
320
235
  @Override
321
236
  public void onDisconnected(SubscriberKit subscriberKit) {
322
237
  Log.d(TAG, "onDisconnected: Subscriber disconnected. Stream: " + subscriberKit.getStream().getStreamId());
323
238
  showToast(SUBSCRIBERNAME+" left the call");
324
-
325
-
326
239
  }
327
-
328
-
329
-
330
240
  @Override
331
241
  public void onError(SubscriberKit subscriberKit, OpentokError opentokError) {
332
242
  showToast(SUBSCRIBERNAME + " failed to connect to the call");
333
243
  finishWithMessage("SubscriberKit onError: " + opentokError.getMessage());
334
244
  }
335
245
  };
336
-
337
246
  @Override
338
247
  protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
339
248
  super.onActivityResult(requestCode, resultCode, data);
@@ -341,55 +250,40 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
341
250
  Log.d(TAG,"code === 99 in second");
342
251
  }else{
343
252
  Log.d(TAG,"code === 98 in second");
344
-
345
- }
346
253
  }
347
-
254
+ }
348
255
  @Override
349
256
  public void onBackPressed() {
350
257
  if(session!=null){
351
258
  session.disconnect();
352
259
  }
353
260
  }
354
-
355
-
356
261
  @SuppressLint("MissingInflatedId")
357
262
  @Override
358
263
  protected void onCreate(Bundle savedInstanceState) {
359
-
360
264
  Intent intent = getIntent();
361
-
362
265
  super.onCreate(savedInstanceState);
363
- // observers = new ArrayList<>();
364
- // observers1 = new ArrayList<>();
365
266
  instance = new VideoCallActivity();
366
- handler.post(logRunnable);
367
-
368
267
  setContentView(R.layout.video_call_layout);
369
268
  sendNotifications = findViewById(R.id.senddata);
370
269
  main = findViewById(R.id.main);
371
270
  progressBar = findViewById(R.id.progressBar);
372
-
373
- circleAvatar = findViewById(R.id.image_view);
374
-
271
+ circleAvatar = findViewById(R.id.image_view);
375
272
  getSupportActionBar().hide();
376
273
  ActionBar actionBar = getActionBar();
377
274
  if (actionBar != null) {
378
275
  actionBar.hide();
379
276
  }
380
- patientStatus = findViewById(R.id.waiting);
277
+ patientStatus = findViewById(R.id.waiting);
381
278
  admit = findViewById(R.id.admit);
382
279
  deny = findViewById(R.id.deny);
383
-
384
280
  if (intent != null) {
385
- // Retrieve the data using the same key you used to put it in the Intent
386
281
  String TOKEN = intent.getStringExtra("token");
387
282
  String SESSION_ID = intent.getStringExtra("sessionId");
388
283
  String API_KEY = intent.getStringExtra("apiKey");
389
- SUBSCRIBERNAME = intent.getStringExtra("subscriberName");
390
- PUBLISHERNAME = intent.getStringExtra("publisherName");
284
+ SUBSCRIBERNAME = intent.getStringExtra("subscriberName");
285
+ PUBLISHERNAME = intent.getStringExtra("publisherName");
391
286
  profilePicApiUrl = intent.getStringExtra("profilePicApiUrl");
392
- Log.d("profilePicApiUrl",profilePicApiUrl);
393
287
  isPatientOnline = intent.getBooleanExtra("isPatientOnline",false);
394
288
  ISPROVIDER = intent.getBooleanExtra("isProvider",false);
395
289
  publisherViewContainer = findViewById(R.id.publisher_container);
@@ -397,7 +291,6 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
397
291
  publisherNameTextView = findViewById(R.id.publisherName);
398
292
  publishernameView = findViewById(R.id.publisherNameView);
399
293
  TextView subscriberNameTextView = findViewById(R.id.subscriberName);
400
-
401
294
  if(ISPROVIDER){
402
295
  if (isPatientOnline) {
403
296
  patientStatus.setText("WAITING");
@@ -412,8 +305,6 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
412
305
  patientStatus.setText("OFFLINE");
413
306
  patientStatus.setBackgroundColor(getResources().getColor(R.color.offline));
414
307
  }
415
- }else{
416
-
417
308
  }
418
309
  publisherNameTextView.setText(SUBSCRIBERNAME);
419
310
  publishernameView.setText(SUBSCRIBERNAME);
@@ -422,7 +313,6 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
422
313
  timerTextView = findViewById(R.id.timerTextView);
423
314
  startTime = System.currentTimeMillis();
424
315
  isTimeron =true;
425
- startTimer();
426
316
  ProviderViewLayout = findViewById(R.id.providerViewLayout);
427
317
  if(ISPROVIDER){
428
318
  ProviderViewLayout.setVisibility(View.VISIBLE);
@@ -432,27 +322,16 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
432
322
  String dummyImage = profilePicApiUrl.length()>10?profilePicApiUrl:dummyProfile;
433
323
  new urltoSource((ImageView) findViewById(R.id.image_view)).execute(dummyImage);
434
324
  initializeSession(API_KEY,SESSION_ID , TOKEN);
435
-
436
-
437
325
  }
438
-
439
-
440
-
441
326
  imageViewEndcall = findViewById(R.id.imageView1);
442
327
  imageViewMute = findViewById(R.id.imageView2);
443
328
  imageViewCamOff = findViewById(R.id.imageView3);
444
329
  imageViewCamSwitch = findViewById(R.id.imageView4);
445
-
446
-
447
-
448
330
  sendNotifications.setOnClickListener(new View.OnClickListener() {
449
331
  @Override
450
332
  public void onClick(View v) {
451
-
452
333
  notifyObservers("send");
453
334
  sendNotifications.setVisibility(View.GONE);
454
-
455
-
456
335
  }
457
336
  });
458
337
  admit.setOnClickListener(new View.OnClickListener() {
@@ -483,11 +362,9 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
483
362
  }
484
363
  }
485
364
  });
486
-
487
365
  imageViewMute.setOnClickListener(new View.OnClickListener() {//mute and unmute audio
488
366
  @Override
489
367
  public void onClick(View v) {
490
-
491
368
  if(publisher!=null) {
492
369
  if (!isMuted) {
493
370
  publisher.setPublishAudio(false);
@@ -505,21 +382,14 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
505
382
  @Override
506
383
  public void onClick(View v) {
507
384
  if(publisher!=null) {
508
-
509
385
  if (!isCamOff) {
510
386
  publisher.setPublishVideo(false);
511
387
  imageViewCamOff.setImageResource(R.drawable.cameraoff);
512
- imageViewCamSwitch.setVisibility(View.GONE);
513
-
514
-
515
388
  } else {
516
389
  publisher.setPublishVideo(true);
517
390
  imageViewCamOff.setImageResource(R.drawable.cameraonwhite);
518
- imageViewCamSwitch.setVisibility(View.VISIBLE);
519
-
520
391
  }
521
392
  isCamOff = !isCamOff;
522
-
523
393
  }
524
394
  }
525
395
  });
@@ -531,11 +401,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
531
401
  }
532
402
  }
533
403
  });
534
-
535
-
536
-
537
404
  }
538
-
539
405
  @Override
540
406
  protected void onPause() {
541
407
  super.onPause();
@@ -543,11 +409,9 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
543
409
  session.onPause();
544
410
  }
545
411
  }
546
-
547
412
  @Override
548
413
  protected void onResume() {
549
414
  super.onResume();
550
-
551
415
  if (session != null) {
552
416
  session.onResume();
553
417
  }
@@ -556,23 +420,8 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
556
420
  if(session!=null){
557
421
  session.disconnect();
558
422
  }
559
-
560
423
  isEndall =true;
561
- // killvc();
562
-
563
424
  }
564
- // public void killvc(){
565
- // runOnUiThread(new Runnable() {
566
- // @Override
567
- // public void run() {
568
- // Log.d("endVideoCall","PluginMethodendVideoCall");
569
- // Log.d("endVideoCall",session.toString());
570
- //
571
- // }
572
- // });
573
- //
574
- //
575
- // }
576
425
  private void startTimer() {
577
426
  Handler handler = new Handler();
578
427
  handler.postDelayed(new Runnable() {
@@ -584,14 +433,9 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
584
433
  int hours = minutes / 60;
585
434
  seconds %= 60;
586
435
  minutes %= 60;
587
-
588
436
  String timeString = String.format("%02d:%02d:%02d", hours, minutes, seconds);
589
- // Log.d(TAG, String.valueOf(currentTime));
590
-
591
437
  // Update the TextView with the formatted time
592
438
  timerTextView.setText(timeString);
593
-
594
- // Continue updating the timer
595
439
  if(isTimeron)
596
440
  startTimer();
597
441
  }
@@ -602,54 +446,15 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
602
446
  super.onRequestPermissionsResult(requestCode, permissions, grantResults);
603
447
  EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
604
448
  }
605
-
606
449
  @Override
607
450
  public void onPermissionsGranted(int requestCode, List<String> perms) {
608
451
  Log.d(TAG, "onPermissionsGranted:" + requestCode + ": " + perms);
609
452
  }
610
-
611
453
  @Override
612
454
  public void onPermissionsDenied(int requestCode, List<String> perms) {
613
455
  finishWithMessage("onPermissionsDenied: " + requestCode + ": " + perms);
614
456
  }
615
-
616
- @AfterPermissionGranted(PERMISSIONS_REQUEST_CODE)
617
- // private void requestPermissions() {
618
- // String[] perms = {Manifest.permission.INTERNET, Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO};
619
- //
620
- // if (EasyPermissions.hasPermissions(this, perms)) {
621
- //
622
- // if (ServerConfig.hasChatServerUrl()) {
623
- // // Custom server URL exists - retrieve session config
624
- // if(!ServerConfig.isValid()) {
625
- // finishWithMessage("Invalid chat server url: " + ServerConfig.CHAT_SERVER_URL);
626
- // return;
627
- // }
628
- //
629
- // initRetrofit();
630
- //// getSession();
631
- // } else {
632
- // // Use hardcoded session config
633
- // if(!OpenTokConfig.isValid()) {
634
- // finishWithMessage("Invalid OpenTokConfig. " + OpenTokConfig.getDescription());
635
- // return;
636
- // }
637
- //
638
- // initializeSession(OpenTokConfig.API_KEY, OpenTokConfig.SESSION_ID, OpenTokConfig.TOKEN);
639
- // }
640
- // } else {
641
- // EasyPermissions.requestPermissions(this, getString(R.string.rationale_video_app), PERMISSIONS_REQUEST_CODE, perms);
642
- // }
643
- // }
644
-
645
-
646
-
647
457
  private void initializeSession(String apiKey, String sessionId, String token) {
648
- instance.isCallinprogress= false;
649
- Log.i(TAG, "initializeSession: " + "initializeSession");
650
- Log.i(TAG, "apiKey: " + apiKey);
651
- Log.i(TAG, "sessionId: " + sessionId);
652
- Log.i(TAG, "token: " + token);
653
458
  /*
654
459
  The context used depends on the specific use case, but usually, it is desired for the session to
655
460
  live outside of the Activity e.g: live between activities. For a production applications,
@@ -658,51 +463,12 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
658
463
  session = new Session.Builder(this, apiKey, sessionId).build();
659
464
  session.setSessionListener(sessionListener);
660
465
  session.connect(token);
661
- // circleAvatar.setVisibility(View.GONE); // Hide the view
662
-
663
- Log.d("initializeSession","session.toString()");
664
- Log.d("initializeSession",session.toString());
665
466
  }
666
467
 
667
- // private void initRetrofit() {
668
- // HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
669
- // logging.setLevel(Level.BODY);
670
- //
671
- // OkHttpClient client = new OkHttpClient.Builder()
672
- // .addInterceptor(logging)
673
- // .build();
674
- //
675
- // retrofit = new Retrofit.Builder()
676
- // .baseUrl(ServerConfig.CHAT_SERVER_URL)
677
- // .addConverterFactory(MoshiConverterFactory.create())
678
- // .client(client)
679
- // .build();
680
- //
681
- //// apiService = retrofit.create(APIService.class);
682
- // }
683
-
684
- private void showToast(String message) {
685
- // try{
686
- // if(isAppInForeground()){
687
- showGreenToast(getApplicationContext(),message);
688
- // }
689
- // Toast toast = Toast.makeText(this, message, Toast.LENGTH_LONG);
690
- // View view = toast.getView();
691
- // int color = Color.parseColor("#1fc600");
692
- // int colorText = Color.parseColor("#ffffff");
693
- // view.getBackground().setColorFilter(Color.GREEN, PorterDuff.Mode.SRC_IN);
694
- // TextView text = view.findViewById(android.R.id.message);
695
- // text.setTextColor(Color.BLACK);
696
- // toast.setGravity(Gravity.TOP, 0, 0);
697
- // toast.show();
698
- // }catch(Exception e){
699
- // Log.d("toastlogex",e.toString());
700
- // }
701
- }
702
468
 
469
+ private void showToast(String message) {showGreenToast(getApplicationContext(),message);}
703
470
  private void finishWithMessage(String message) {
704
471
  Log.e(TAG, message);
705
- // Toast.makeText(this, message, Toast.LENGTH_LONG).show();
706
472
  if(session!=null){
707
473
  session.disconnect();
708
474
  }
@@ -713,16 +479,15 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
713
479
  this.finish();
714
480
  }
715
481
 
716
-
717
-
718
-
719
-
720
482
  public void patientStatusChanged(Boolean isOnline) {
721
483
  Log.d("patientStatusChanged", String.valueOf(isOnline));
722
484
  Log.d("patientStatusChanged2", String.valueOf(isOnline));
723
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));
724
490
 
725
- if(!instance.isCallinprogress){
726
491
  runOnUiThread(new Runnable() {
727
492
  @Override
728
493
  public void run() {
@@ -734,91 +499,46 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
734
499
  sendNotifications.setVisibility(View.GONE);
735
500
  admit.setVisibility(View.VISIBLE);
736
501
  deny.setVisibility(View.VISIBLE);
502
+ publishernameView.setVisibility(View.VISIBLE);
503
+
737
504
  patientStatus.setBackgroundResource(R.color.waiting);
738
- // patientStatus.setBackgroundColor(getResources().getColor(R.color.waiting));
739
505
  } else {
740
506
  Log.d("OFFLINE", String.valueOf(isOnline));
741
507
  patientStatus.setText("OFFLINE");
742
508
  admit.setVisibility(View.GONE);
743
509
  deny.setVisibility(View.GONE);
510
+ publishernameView.setVisibility(View.VISIBLE);
744
511
  sendNotifications.setVisibility(View.VISIBLE);
745
512
  patientStatus.setText("OFFLINE");
746
513
  patientStatus.setBackgroundResource(R.color.offline);
747
- // patientStatus.setBackgroundColor(getResources().getColor(R.color.offline));
748
514
  }
749
515
 
750
516
 
751
517
  }
752
518
  });
753
- }
519
+ // }
754
520
  }
755
521
  public static void showGreenToast(Context context, String message) {
756
522
  LayoutInflater inflater = LayoutInflater.from(context);
757
523
  View layout = inflater.inflate(R.layout.custom_toast_green_layout, null);
758
-
759
524
  TextView text = layout.findViewById(R.id.toastView);
760
525
  text.setText(message);
761
-
762
526
  Toast toast = new Toast(context);
763
527
  toast.setDuration(Toast.LENGTH_SHORT);
764
528
  toast.setView(layout);
765
-
766
- // Set toast position to top right corner
767
529
  toast.setGravity(Gravity.TOP | Gravity.END, 0, 0);
768
-
769
530
  toast.show();
770
531
  }
771
- private boolean isAppInForeground() {
772
- return isAppInForeground;
773
- }
532
+
774
533
 
775
534
  public void notifyObservers(String value) {
776
535
  vonagePlugin temp = new vonagePlugin();
777
536
  temp.update(value);
778
537
  }
779
-
780
- @Override
781
- public void onActivityCreated(@NonNull Activity activity, @androidx.annotation.Nullable Bundle bundle) {
782
-
783
- }
784
-
785
- @Override
786
- public void onActivityStarted(@NonNull Activity activity) {
787
-
788
- }
789
-
790
- @Override
791
- public void onActivityResumed(@NonNull Activity activity) {
792
- Log.d("isAppInForeground", String.valueOf(isAppInForeground));
793
- isAppInForeground = true;
794
- }
795
-
796
- @Override
797
- public void onActivityPaused(@NonNull Activity activity) {
798
- Log.d("isAppInForeground", String.valueOf(isAppInForeground));
799
- isAppInForeground = false;
800
- }
801
-
802
- @Override
803
- public void onActivityStopped(@NonNull Activity activity) {
804
-
805
- }
806
-
807
- @Override
808
- public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle bundle) {
809
-
810
- }
811
-
812
- @Override
813
- public void onActivityDestroyed(@NonNull Activity activity) {
814
-
815
- }
816
-
817
538
  private class urltoSource extends AsyncTask<String, Void, Bitmap> {
818
539
  ImageView imageView;
819
540
  public urltoSource(ImageView imageView) {
820
541
  this.imageView=imageView;
821
- // Toast.makeText(getApplicationContext(), "Please wait, it may take a few minute...",Toast.LENGTH_SHORT).show();
822
542
  }
823
543
  protected Bitmap doInBackground(String... urls) {
824
544
  String imageURL=urls[0];
@@ -827,7 +547,6 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
827
547
  InputStream in=new java.net.URL(imageURL).openStream();
828
548
  bimage= BitmapFactory.decodeStream(in);
829
549
  } catch (Exception e) {
830
- Log.e("Error Message", e.getMessage());
831
550
  e.printStackTrace();
832
551
  }
833
552
  return bimage;
@@ -4,15 +4,16 @@
4
4
  android:layout_width="wrap_content"
5
5
  android:layout_height="wrap_content"
6
6
  android:orientation="vertical"
7
- android:padding="16dp"
8
- android:background="#00FF00">
7
+ android:padding="7dp"
8
+ android:background="#0B6623">
9
9
 
10
10
  <TextView
11
11
  android:id="@+id/toastView"
12
12
  android:layout_width="wrap_content"
13
13
  android:layout_height="wrap_content"
14
14
  android:text="Custom Toast"
15
- android:textColor="#0B6623"
15
+ android:textSize="11sp"
16
+ android:textColor="#FFFFFF"
16
17
  android:textStyle="bold"
17
18
  android:layout_gravity="center_horizontal"/>
18
19
  </LinearLayout>
@@ -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
- if(!isCallInProgress){
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 {
@@ -327,21 +328,23 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
327
328
 
328
329
  self.view.addSubview(bottomView)
329
330
 
330
- localView = UIView(frame: CGRect(x: screenWidth - 140, y: screenHeight - 250, width: 120, height: 120))
331
+ localView = UIView(frame: CGRect(x: screenWidth - 140, y: screenHeight - 260, width: 120, height: 120))
331
332
  localView.backgroundColor = UIColor(red: 31/255, green: 33/255, blue: 36/255, alpha: 1.0)
332
-
333
+ localView.layer.borderColor = UIColor(hex: "#9b9c98").cgColor
334
+ localView.layer.borderWidth = 1.0
333
335
  localView.layer.cornerRadius = 10;
334
336
  localView.clipsToBounds = true
335
337
  localView.isHidden = true
336
338
 
337
- publisherLabel = UILabel(frame: CGRect(x: 0, y: Int(localView.frame.size.height - 40.0), width: Int(localView.frame.size.width), height: 40))
338
- publisherLabel.text = publisherName
339
+ publisherLabel = UILabel(frame: CGRect(x: Int(screenWidth - 160), y: Int(screenHeight - 140), width: 160, height: 40))
340
+ //publisherLabel.text = publisherName
339
341
  // publisherLabel.backgroundColor = UIColor(red: 31/255, green: 33/255, blue: 36/255, alpha: 1.0)
340
- publisherLabel.textColor = .white//UIColor(hex: "#000000")
342
+ publisherLabel.textColor = .black//UIColor(hex: "#000000")
341
343
  publisherLabel.textAlignment = .center
342
344
  publisherLabel.layer.zPosition = 1;
343
345
  publisherLabel.font = publisherLabel.font.withSize(dynamicFontSize(UIDevice.current.userInterfaceIdiom == .pad ? 10 : 15))
344
- localView.addSubview(publisherLabel)
346
+ remoteView.addSubview(publisherLabel)
347
+ //localView.addSubview(publisherLabel)
345
348
  self.view.addSubview(localView)
346
349
 
347
350
  callBtn = UIButton(frame: CGRect(x: 240, y: 0, width: 60, height: 60))
@@ -377,6 +380,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
377
380
  sendNotificationBtn.isHidden = true
378
381
  adminBtn.isHidden = false
379
382
  denyBtn.isHidden = false
383
+ subscriberStatusLabel.isHidden = false
380
384
  subscriberStatusLabel.text = "WAITING"
381
385
  subscriberStatusLabel.backgroundColor = UIColor(hex: "#DFF6ED")
382
386
  subscriberNameLabel.isHidden = false
@@ -385,6 +389,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
385
389
  sendNotificationBtn.isHidden = false
386
390
  adminBtn.isHidden = true
387
391
  denyBtn.isHidden = true
392
+ subscriberStatusLabel.isHidden = false
388
393
  subscriberStatusLabel.text = "OFFLINE"
389
394
  subscriberStatusLabel.backgroundColor = UIColor(hex: "#ffd6ca")
390
395
  subscriberNameLabel.isHidden = false
@@ -538,7 +543,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
538
543
  // let screenBounds = UIScreen.main.bounds
539
544
  //changed
540
545
  publisherView.frame = CGRect(x: 0, y: 0 , width: localView.frame.width, height: localView.frame.height)
541
-
546
+ publisherLabel.text = publisherName
542
547
  localView.addSubview(publisherView)
543
548
  startTimer()
544
549
  DispatchQueue.main.async {
@@ -584,6 +589,8 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
584
589
  if(stream.videoType == .screen){
585
590
  subscriberView.accessibilityValue = "from screen"
586
591
  }
592
+ timerLabel.textColor = .white
593
+ publisherLabel.textColor = .white
587
594
  remoteView.addSubview(subscriberView)
588
595
  }
589
596
 
@@ -642,6 +649,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
642
649
  subscriberStatusLabel.isHidden = true
643
650
  subscriberNameLabel.isHidden = true
644
651
  timerLabel.textColor = .white
652
+ publisherLabel.textColor = .white
645
653
  isCallInProgress = true
646
654
  adminBtn.isHidden = true
647
655
  denyBtn.isHidden = true
@@ -673,6 +681,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
673
681
  subscriberStatusLabel.isHidden = true
674
682
  subscriberNameLabel.isHidden = true
675
683
  timerLabel.textColor = .white
684
+ publisherLabel.textColor = .white
676
685
  // showToast(message: "is provider \(isProvider) video enabled")
677
686
 
678
687
  // Remove the video disabled indicator
@@ -710,6 +719,8 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
710
719
  //}
711
720
  }
712
721
  fileprivate func cleanupSubscriber() {
722
+ timerLabel.textColor = .black
723
+ publisherLabel.textColor = .black
713
724
  subscriber?.view?.removeFromSuperview()
714
725
  subscriber = nil
715
726
  remoteView.backgroundColor = .white
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-plugin-vonage",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "opentok sdk capacitor plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",