capacitor-plugin-vonage 0.1.0 → 0.1.2

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.
@@ -25,6 +25,7 @@ import android.widget.Button;
25
25
  import android.widget.FrameLayout;
26
26
  import android.widget.ImageView;
27
27
  import android.widget.LinearLayout;
28
+ import android.widget.ProgressBar;
28
29
  import android.widget.TextView;
29
30
  import android.widget.Toast;
30
31
 
@@ -72,13 +73,15 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
72
73
  boolean isPatientOnline = false;
73
74
  boolean isMuted = false;
74
75
  boolean isCamOff = false;
75
- boolean isCallinprogress = false;
76
+ private static boolean isCallinprogress = false;
76
77
  public boolean temptest = false;
77
78
  boolean isTimeron = false;
78
79
  boolean isEndall = false;
79
80
  private Subscriber subscriber;
80
81
  private FrameLayout publisherViewContainer;
81
82
  private LinearLayout ProviderViewLayout;
83
+ private LinearLayout main;
84
+ private ProgressBar progressBar;
82
85
  private FrameLayout subscriberViewContainer;
83
86
  private TextView publisherNameTextView;
84
87
  private FloatingActionButton fabCameraOff;
@@ -148,6 +151,9 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
148
151
  private final Session.SessionListener sessionListener = new Session.SessionListener() {
149
152
  @Override
150
153
  public void onConnected(Session session) {
154
+ main.setVisibility(View.VISIBLE);
155
+ startTimer();
156
+ progressBar.setVisibility(View.INVISIBLE);
151
157
  publisher = new Publisher.Builder(VideoCallActivity.this).build();
152
158
  publisher.setPublisherListener(publisherListener);
153
159
  publisher.getRenderer().setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);
@@ -315,6 +321,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
315
321
  @Override
316
322
  public void onDisconnected(SubscriberKit subscriberKit) {
317
323
  Log.d(TAG, "onDisconnected: Subscriber disconnected. Stream: " + subscriberKit.getStream().getStreamId());
324
+ showToast(SUBSCRIBERNAME+" left the call");
318
325
 
319
326
 
320
327
  }
@@ -361,6 +368,8 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
361
368
 
362
369
  setContentView(R.layout.video_call_layout);
363
370
  sendNotifications = findViewById(R.id.senddata);
371
+ main = findViewById(R.id.main);
372
+ progressBar = findViewById(R.id.progressBar);
364
373
 
365
374
  circleAvatar = findViewById(R.id.image_view);
366
375
 
@@ -414,7 +423,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
414
423
  timerTextView = findViewById(R.id.timerTextView);
415
424
  startTime = System.currentTimeMillis();
416
425
  isTimeron =true;
417
- startTimer();
426
+ // startTimer();
418
427
  ProviderViewLayout = findViewById(R.id.providerViewLayout);
419
428
  if(ISPROVIDER){
420
429
  ProviderViewLayout.setVisibility(View.VISIBLE);
@@ -501,13 +510,13 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
501
510
  if (!isCamOff) {
502
511
  publisher.setPublishVideo(false);
503
512
  imageViewCamOff.setImageResource(R.drawable.cameraoff);
504
- imageViewCamSwitch.setVisibility(View.GONE);
513
+ // imageViewCamSwitch.setVisibility(View.GONE);
505
514
 
506
515
 
507
516
  } else {
508
517
  publisher.setPublishVideo(true);
509
518
  imageViewCamOff.setImageResource(R.drawable.cameraonwhite);
510
- imageViewCamSwitch.setVisibility(View.VISIBLE);
519
+ // imageViewCamSwitch.setVisibility(View.VISIBLE);
511
520
 
512
521
  }
513
522
  isCamOff = !isCamOff;
@@ -637,6 +646,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
637
646
 
638
647
 
639
648
  private void initializeSession(String apiKey, String sessionId, String token) {
649
+ instance.isCallinprogress= false;
640
650
  Log.i(TAG, "initializeSession: " + "initializeSession");
641
651
  Log.i(TAG, "apiKey: " + apiKey);
642
652
  Log.i(TAG, "sessionId: " + sessionId);
@@ -673,10 +683,10 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
673
683
  // }
674
684
 
675
685
  private void showToast(String message) {
676
- try{
677
- if(isAppInForeground()){
686
+ // try{
687
+ // if(isAppInForeground()){
678
688
  showGreenToast(getApplicationContext(),message);
679
- }
689
+ // }
680
690
  // Toast toast = Toast.makeText(this, message, Toast.LENGTH_LONG);
681
691
  // View view = toast.getView();
682
692
  // int color = Color.parseColor("#1fc600");
@@ -686,9 +696,9 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
686
696
  // text.setTextColor(Color.BLACK);
687
697
  // toast.setGravity(Gravity.TOP, 0, 0);
688
698
  // toast.show();
689
- }catch(Exception e){
690
- Log.d("toastlogex",e.toString());
691
- }
699
+ // }catch(Exception e){
700
+ // Log.d("toastlogex",e.toString());
701
+ // }
692
702
  }
693
703
 
694
704
  private void finishWithMessage(String message) {
@@ -713,7 +723,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
713
723
  Log.d("patientStatusChanged2", String.valueOf(isOnline));
714
724
  Log.d("patientStatusChanged2", String.valueOf(isOnline));
715
725
 
716
- if(!isCallinprogress){
726
+ if(!instance.isCallinprogress){
717
727
  runOnUiThread(new Runnable() {
718
728
  @Override
719
729
  public void run() {
@@ -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>
@@ -15,11 +15,25 @@
15
15
  android:layout_height="match_parent"
16
16
  >
17
17
 
18
+ <ProgressBar
19
+ android:id="@+id/progressBar"
20
+ style="?android:attr/progressBarStyleLarge"
21
+ android:layout_width="57dp"
22
+ android:layout_height="56dp"
23
+ android:layout_gravity="center"
24
+ android:visibility="visible"
25
+ app:layout_constraintBottom_toBottomOf="parent"
26
+ app:layout_constraintEnd_toEndOf="parent"
27
+ app:layout_constraintStart_toStartOf="@+id/main"
28
+ app:layout_constraintTop_toTopOf="parent" />
29
+
30
+
18
31
 
19
32
  <LinearLayout
20
33
  android:id="@+id/main"
21
34
  android:layout_width="match_parent"
22
35
  android:layout_height="match_parent"
36
+ android:visibility="invisible"
23
37
  >
24
38
 
25
39
 
@@ -76,6 +90,7 @@
76
90
  android:padding="2dp" >
77
91
 
78
92
 
93
+
79
94
  </FrameLayout>
80
95
  <TextView
81
96
  android:id="@+id/subscriberName"
@@ -327,21 +327,23 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
327
327
 
328
328
  self.view.addSubview(bottomView)
329
329
 
330
- localView = UIView(frame: CGRect(x: screenWidth - 140, y: screenHeight - 250, width: 120, height: 120))
330
+ localView = UIView(frame: CGRect(x: screenWidth - 140, y: screenHeight - 260, width: 120, height: 120))
331
331
  localView.backgroundColor = UIColor(red: 31/255, green: 33/255, blue: 36/255, alpha: 1.0)
332
-
332
+ localView.layer.borderColor = UIColor(hex: "#9b9c98").cgColor
333
+ localView.layer.borderWidth = 1.0
333
334
  localView.layer.cornerRadius = 10;
334
335
  localView.clipsToBounds = true
335
336
  localView.isHidden = true
336
337
 
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
338
+ publisherLabel = UILabel(frame: CGRect(x: Int(screenWidth - 160), y: Int(screenHeight - 140), width: 160, height: 40))
339
+ //publisherLabel.text = publisherName
339
340
  // publisherLabel.backgroundColor = UIColor(red: 31/255, green: 33/255, blue: 36/255, alpha: 1.0)
340
- publisherLabel.textColor = .white//UIColor(hex: "#000000")
341
+ publisherLabel.textColor = .black//UIColor(hex: "#000000")
341
342
  publisherLabel.textAlignment = .center
342
343
  publisherLabel.layer.zPosition = 1;
343
344
  publisherLabel.font = publisherLabel.font.withSize(dynamicFontSize(UIDevice.current.userInterfaceIdiom == .pad ? 10 : 15))
344
- localView.addSubview(publisherLabel)
345
+ remoteView.addSubview(publisherLabel)
346
+ //localView.addSubview(publisherLabel)
345
347
  self.view.addSubview(localView)
346
348
 
347
349
  callBtn = UIButton(frame: CGRect(x: 240, y: 0, width: 60, height: 60))
@@ -407,7 +409,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
407
409
  subscriberStatusLabel.isHidden = false
408
410
  subscriberNameLabel.isHidden = false
409
411
  subscriberStatusLabel.text = "Please Wait.."
410
- let userInfo = ["userInfo": ["isProvider": isProvider]]
412
+ let userInfo = ["isProvider": isProvider]
411
413
  // NotificationCenter.default.post(name: NSNotification.Name("SendNotification"),object: nil,userInfo: userInfo)
412
414
  delegate?.videoCallSendNotification(userInfo)
413
415
  // self.session?.disconnect(nil)
@@ -429,14 +431,14 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
429
431
  // self.session?.disconnect(nil)
430
432
  // self.stopTimer()
431
433
  // self.dismiss(animated: true, completion: nil)
432
- let userInfo = ["userInfo": ["isProvider": isProvider]]
434
+ let userInfo = ["isProvider": isProvider]
433
435
  // NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoStarted),object: nil,userInfo: userInfo)
434
436
  delegate?.videoCallStarted(userInfo)
435
437
  }
436
438
  @objc func denybuttonClicked() {
437
439
  print("deny button clicked")
438
440
  centerView.isHidden = true
439
- let userInfo = ["userInfo": ["isProvider": isProvider]]
441
+ let userInfo = ["isProvider": isProvider]
440
442
 
441
443
  // NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
442
444
  delegate?.videoCallEnded(userInfo)
@@ -449,7 +451,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
449
451
 
450
452
  @objc func callBtnbuttonClicked() {
451
453
 
452
- let userInfo = ["userInfo": ["isProvider": isProvider]]
454
+ let userInfo = ["isProvider": isProvider]
453
455
  // NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
454
456
  delegate?.videoCallEnded(userInfo)
455
457
  self.endVonageCall()
@@ -512,7 +514,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
512
514
  hideActivityIndicator()
513
515
  localView.isHidden = false
514
516
  print("The client connected to the OpenTok session.")
515
- let userInfo = ["userInfo": ["isProvider": isProvider]]
517
+ let userInfo = ["isProvider": isProvider]
516
518
  // NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoStarted),object: nil,userInfo: userInfo)
517
519
  let settings = OTPublisherSettings()
518
520
  settings.cameraResolution = .high
@@ -538,7 +540,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
538
540
  // let screenBounds = UIScreen.main.bounds
539
541
  //changed
540
542
  publisherView.frame = CGRect(x: 0, y: 0 , width: localView.frame.width, height: localView.frame.height)
541
-
543
+ publisherLabel.text = publisherName
542
544
  localView.addSubview(publisherView)
543
545
  startTimer()
544
546
  DispatchQueue.main.async {
@@ -584,9 +586,8 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
584
586
  if(stream.videoType == .screen){
585
587
  subscriberView.accessibilityValue = "from screen"
586
588
  }
587
- adminBtn.isHidden = true
588
- denyBtn.isHidden = true
589
- sendNotificationBtn.isHidden = true
589
+ timerLabel.textColor = .white
590
+ publisherLabel.textColor = .white
590
591
  remoteView.addSubview(subscriberView)
591
592
  }
592
593
 
@@ -600,7 +601,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
600
601
  // }
601
602
  if let subStream = subscriber?.stream, subStream.streamId == stream.streamId,!isProvider, stream.videoType != .screen {
602
603
  // cleanupSubscriber()
603
- let userInfo = ["userInfo": ["isProvider": isProvider]]
604
+ let userInfo = ["isProvider": isProvider]
604
605
  // NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
605
606
  delegate?.videoCallEnded(userInfo)
606
607
  // self.session?.disconnect(nil)
@@ -645,7 +646,11 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
645
646
  subscriberStatusLabel.isHidden = true
646
647
  subscriberNameLabel.isHidden = true
647
648
  timerLabel.textColor = .white
649
+ publisherLabel.textColor = .white
648
650
  isCallInProgress = true
651
+ adminBtn.isHidden = true
652
+ denyBtn.isHidden = true
653
+ sendNotificationBtn.isHidden = true
649
654
  if(subscriber.stream?.videoType != .screen){
650
655
  showToast(message: "\(subscriberName) is joined the call")
651
656
  }
@@ -673,6 +678,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
673
678
  subscriberStatusLabel.isHidden = true
674
679
  subscriberNameLabel.isHidden = true
675
680
  timerLabel.textColor = .white
681
+ publisherLabel.textColor = .white
676
682
  // showToast(message: "is provider \(isProvider) video enabled")
677
683
 
678
684
  // Remove the video disabled indicator
@@ -688,6 +694,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
688
694
  }
689
695
  fileprivate func endVonageCall(){
690
696
  isCallEnded = true
697
+ self.stopTimer()
691
698
  //let userInfo = ["userInfo": ["isProvider": self.isProvider]]
692
699
  // NotificationCenter.default.post(name: NSNotification.Name("RemoveObservers"),object: nil,userInfo: userInfo)
693
700
  // DispatchQueue.main.async {
@@ -695,16 +702,22 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
695
702
  // self.publisher?.publishVideo = false
696
703
  // self.publisher?.videoCapture?.stop()
697
704
  // self.publisher?.publishAudio = false
698
- self.session?.disconnect(nil)
705
+
699
706
  // self.cleanupSubscriber()
700
707
  //self.cleanupPublisher()
701
- self.stopTimer()
708
+ var error: OTError?
709
+ self.session?.disconnect(&error)
710
+ if error != nil {
711
+ print(error!)
712
+ }
702
713
  self.dismiss(animated: true) {
703
714
  print("video ended")
704
715
  }
705
716
  //}
706
717
  }
707
718
  fileprivate func cleanupSubscriber() {
719
+ timerLabel.textColor = .black
720
+ publisherLabel.textColor = .black
708
721
  subscriber?.view?.removeFromSuperview()
709
722
  subscriber = nil
710
723
  remoteView.backgroundColor = .white
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-plugin-vonage",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "opentok sdk capacitor plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",