capacitor-plugin-vonage 0.0.1

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.
Files changed (40) hide show
  1. package/CapacitorPluginVonage.podspec +20 -0
  2. package/README.md +126 -0
  3. package/android/build.gradle +76 -0
  4. package/android/src/main/AndroidManifest.xml +6 -0
  5. package/android/src/main/java/com/managemyhealth/plugin/vonage/VideoCallActivity.java +434 -0
  6. package/android/src/main/java/com/managemyhealth/plugin/vonage/vonage.java +11 -0
  7. package/android/src/main/java/com/managemyhealth/plugin/vonage/vonagePlugin.java +125 -0
  8. package/android/src/main/res/.gitkeep +0 -0
  9. package/android/src/main/res/drawable/callend.png +0 -0
  10. package/android/src/main/res/drawable/callstart.png +0 -0
  11. package/android/src/main/res/drawable/cameraoff.png +0 -0
  12. package/android/src/main/res/drawable/cameraonwhite.png +0 -0
  13. package/android/src/main/res/drawable/cameraswitch.png +0 -0
  14. package/android/src/main/res/drawable/ic_launcher_background.xml +170 -0
  15. package/android/src/main/res/drawable/microphoneoff.png +0 -0
  16. package/android/src/main/res/drawable/microphoneonwhite.png +0 -0
  17. package/android/src/main/res/layout/activity_main.xml +36 -0
  18. package/android/src/main/res/layout/video_call_layout.xml +282 -0
  19. package/android/src/main/res.zip +0 -0
  20. package/dist/docs.json +370 -0
  21. package/dist/esm/definitions.d.ts +12 -0
  22. package/dist/esm/definitions.js +2 -0
  23. package/dist/esm/definitions.js.map +1 -0
  24. package/dist/esm/index.d.ts +4 -0
  25. package/dist/esm/index.js +7 -0
  26. package/dist/esm/index.js.map +1 -0
  27. package/dist/esm/web.d.ts +12 -0
  28. package/dist/esm/web.js +13 -0
  29. package/dist/esm/web.js.map +1 -0
  30. package/dist/plugin.cjs.js +29 -0
  31. package/dist/plugin.cjs.js.map +1 -0
  32. package/dist/plugin.js +32 -0
  33. package/dist/plugin.js.map +1 -0
  34. package/ios/Plugin/Info.plist +24 -0
  35. package/ios/Plugin/VideoChatViewController.swift +387 -0
  36. package/ios/Plugin/vonage.swift +8 -0
  37. package/ios/Plugin/vonagePlugin.h +10 -0
  38. package/ios/Plugin/vonagePlugin.m +9 -0
  39. package/ios/Plugin/vonagePlugin.swift +80 -0
  40. package/package.json +78 -0
@@ -0,0 +1,20 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'CapacitorPluginVonage'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.license = package['license']
10
+ s.homepage = package['repository']['url']
11
+ s.author = package['author']
12
+ s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
+ s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '13.0'
15
+ s.dependency 'Capacitor'
16
+ #s.dependency 'OpenTok','2.25.0'
17
+ s.dependency 'OTXCFramework','2.26.1'
18
+ s.swift_version = '5.1'
19
+ s.static_framework = true
20
+ end
package/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # capacitor-plugin-vonage
2
+
3
+ opentok sdk capacitor plugin
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install capacitor-plugin-vonage
9
+ npx cap sync
10
+ ```
11
+
12
+ ## API
13
+
14
+ <docgen-index>
15
+
16
+ * [`echo(...)`](#echo)
17
+ * [`openVideoCallWindow(...)`](#openvideocallwindow)
18
+ * [`addListener([eventName: 'VideoCallEnded', listenerFunc: (info: any) => void] | [eventName: 'VideoCallStarted', listenerFunc: (info: any) => void], ...)`](#addlistenereventname-videocallended-listenerfunc-info-any--void--eventname-videocallstarted-listenerfunc-info-any--void)
19
+ * [Interfaces](#interfaces)
20
+ * [Type Aliases](#type-aliases)
21
+
22
+ </docgen-index>
23
+
24
+ <docgen-api>
25
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
26
+
27
+ ### echo(...)
28
+
29
+ ```typescript
30
+ echo(options: { value: string; }) => Promise<{ value: string; }>
31
+ ```
32
+
33
+ | Param | Type |
34
+ | ------------- | ------------------------------- |
35
+ | **`options`** | <code>{ value: string; }</code> |
36
+
37
+ **Returns:** <code>Promise&lt;{ value: string; }&gt;</code>
38
+
39
+ --------------------
40
+
41
+
42
+ ### openVideoCallWindow(...)
43
+
44
+ ```typescript
45
+ openVideoCallWindow(options: Object) => Promise<{ value: any; }>
46
+ ```
47
+
48
+ | Param | Type |
49
+ | ------------- | ----------------------------------------- |
50
+ | **`options`** | <code><a href="#object">Object</a></code> |
51
+
52
+ **Returns:** <code>Promise&lt;{ value: any; }&gt;</code>
53
+
54
+ --------------------
55
+
56
+
57
+ ### addListener([eventName: 'VideoCallEnded', listenerFunc: (info: any) => void] | [eventName: 'VideoCallStarted', listenerFunc: (info: any) => void], ...)
58
+
59
+ ```typescript
60
+ addListener(...args: [eventName: "VideoCallEnded", listenerFunc: (info: any) => void] | [eventName: "VideoCallStarted", listenerFunc: (info: any) => void]) => Promise<PluginListenerHandle> & PluginListenerHandle
61
+ ```
62
+
63
+ | Param | Type |
64
+ | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
65
+ | **`args`** | <code>[eventName: 'VideoCallEnded', listenerFunc: (info: any) =&gt; void] \| [eventName: 'VideoCallStarted', listenerFunc: (info: any) =&gt; void]</code> |
66
+
67
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt; & <a href="#pluginlistenerhandle">PluginListenerHandle</a></code>
68
+
69
+ --------------------
70
+
71
+
72
+ ### Interfaces
73
+
74
+
75
+ #### Object
76
+
77
+ Provides functionality common to all JavaScript objects.
78
+
79
+ | Prop | Type | Description |
80
+ | ----------------- | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
81
+ | **`constructor`** | <code><a href="#function">Function</a></code> | The initial value of <a href="#object">Object</a>.prototype.constructor is the standard built-in <a href="#object">Object</a> constructor. |
82
+
83
+ | Method | Signature | Description |
84
+ | ------------------------ | --------------------------------------------------------- | ------------------------------------------------------------------------ |
85
+ | **toString** | () =&gt; string | Returns a string representation of an object. |
86
+ | **toLocaleString** | () =&gt; string | Returns a date converted to a string using the current locale. |
87
+ | **valueOf** | () =&gt; <a href="#object">Object</a> | Returns the primitive value of the specified object. |
88
+ | **hasOwnProperty** | (v: <a href="#propertykey">PropertyKey</a>) =&gt; boolean | Determines whether an object has a property with the specified name. |
89
+ | **isPrototypeOf** | (v: <a href="#object">Object</a>) =&gt; boolean | Determines whether an object exists in another object's prototype chain. |
90
+ | **propertyIsEnumerable** | (v: <a href="#propertykey">PropertyKey</a>) =&gt; boolean | Determines whether a specified property is enumerable. |
91
+
92
+
93
+ #### Function
94
+
95
+ Creates a new function.
96
+
97
+ | Prop | Type |
98
+ | --------------- | --------------------------------------------- |
99
+ | **`prototype`** | <code>any</code> |
100
+ | **`length`** | <code>number</code> |
101
+ | **`arguments`** | <code>any</code> |
102
+ | **`caller`** | <code><a href="#function">Function</a></code> |
103
+
104
+ | Method | Signature | Description |
105
+ | ------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
106
+ | **apply** | (this: <a href="#function">Function</a>, thisArg: any, argArray?: any) =&gt; any | Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. |
107
+ | **call** | (this: <a href="#function">Function</a>, thisArg: any, ...argArray: any[]) =&gt; any | Calls a method of an object, substituting another object for the current object. |
108
+ | **bind** | (this: <a href="#function">Function</a>, thisArg: any, ...argArray: any[]) =&gt; any | For a given function, creates a bound function that has the same body as the original function. The this object of the bound function is associated with the specified object, and has the specified initial parameters. |
109
+ | **toString** | () =&gt; string | Returns a string representation of a function. |
110
+
111
+
112
+ #### PluginListenerHandle
113
+
114
+ | Prop | Type |
115
+ | ------------ | ----------------------------------------- |
116
+ | **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |
117
+
118
+
119
+ ### Type Aliases
120
+
121
+
122
+ #### PropertyKey
123
+
124
+ <code>string | number | symbol</code>
125
+
126
+ </docgen-api>
@@ -0,0 +1,76 @@
1
+ ext {
2
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
4
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
5
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
6
+ }
7
+
8
+ buildscript {
9
+ repositories {
10
+ google()
11
+ mavenCentral()
12
+ }
13
+ dependencies {
14
+ classpath 'com.android.tools.build:gradle:8.0.0'
15
+ }
16
+ }
17
+
18
+ apply plugin: 'com.android.library'
19
+
20
+ android {
21
+ namespace "com.managemyhealth.plugin.vonage"
22
+ compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
23
+ defaultConfig {
24
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
25
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
26
+ versionCode 1
27
+ versionName "1.0"
28
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
29
+ }
30
+ buildTypes {
31
+ release {
32
+ minifyEnabled false
33
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
34
+ }
35
+ }
36
+ lintOptions {
37
+ abortOnError false
38
+ }
39
+ compileOptions {
40
+ sourceCompatibility JavaVersion.VERSION_1_8
41
+ targetCompatibility JavaVersion.VERSION_1_8
42
+ }
43
+ }
44
+
45
+ repositories {
46
+ google()
47
+ mavenCentral()
48
+ }
49
+
50
+
51
+ dependencies {
52
+ implementation 'com.google.android.material:material:1.4.0'
53
+ implementation 'pub.devrel:easypermissions:3.0.0'
54
+ implementation 'com.opentok.android:opentok-android-sdk:2.22.0'
55
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
56
+ implementation project(':capacitor-android')
57
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
58
+ implementation 'com.google.android.gms:play-services-cast-framework:21.3.0'
59
+ testImplementation "junit:junit:$junitVersion"
60
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
61
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
62
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
63
+ implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
64
+ implementation 'androidx.annotation:annotation:1.7.0'
65
+ implementation 'com.opentok.android:opentok-android-sdk:2.22.2'
66
+ androidTestImplementation 'androidx.test:runner:1.5.2'
67
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
68
+
69
+ // implementation 'pub.devrel:easypermissions:3.0.0'
70
+ // implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
71
+
72
+ implementation 'com.squareup.retrofit2:retrofit:2.7.2'
73
+ implementation 'com.squareup.okhttp3:okhttp:3.6.0'
74
+ implementation 'com.squareup.retrofit2:converter-moshi:2.7.2'
75
+ implementation "com.squareup.okhttp3:logging-interceptor:4.11.0"
76
+ }
@@ -0,0 +1,6 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <application>
3
+ <activity android:name="com.managemyhealth.plugin.vonage.VideoCallActivity">
4
+ </activity>
5
+ </application>
6
+ </manifest>
@@ -0,0 +1,434 @@
1
+ package com.managemyhealth.plugin.vonage;
2
+
3
+
4
+
5
+ import android.app.ActionBar;
6
+ import android.content.Intent;
7
+ import android.nfc.Tag;
8
+ import android.opengl.GLSurfaceView;
9
+ import android.os.Bundle;
10
+ import android.os.Handler;
11
+ import android.util.Log;
12
+ import android.view.View;
13
+ import android.widget.FrameLayout;
14
+ import android.widget.ImageView;
15
+ import android.widget.TextView;
16
+ import android.widget.Toast;
17
+
18
+ import androidx.annotation.NonNull;
19
+ import androidx.annotation.Nullable;
20
+ import androidx.appcompat.app.AppCompatActivity;
21
+
22
+ import com.getcapacitor.JSObject;
23
+ import com.google.android.material.floatingactionbutton.FloatingActionButton;
24
+ import com.opentok.android.BaseVideoRenderer;
25
+ import com.opentok.android.OpentokError;
26
+ import com.opentok.android.Publisher;
27
+ import com.opentok.android.PublisherKit;
28
+ import com.opentok.android.Session;
29
+ import com.opentok.android.Stream;
30
+ import com.opentok.android.Subscriber;
31
+ import com.opentok.android.SubscriberKit;
32
+ //import com.tokbox.sample.basicvideochat.network.APIService;
33
+ //import com.tokbox.sample.basicvideochat.network.GetSessionResponse;
34
+
35
+ import java.util.List;
36
+
37
+ import okhttp3.OkHttpClient;
38
+ import okhttp3.logging.HttpLoggingInterceptor;
39
+ import okhttp3.logging.HttpLoggingInterceptor.Level;
40
+ import pub.devrel.easypermissions.AfterPermissionGranted;
41
+ import pub.devrel.easypermissions.EasyPermissions;
42
+ import retrofit2.Retrofit;
43
+ import retrofit2.converter.moshi.MoshiConverterFactory;
44
+
45
+
46
+ public class VideoCallActivity extends AppCompatActivity implements EasyPermissions.PermissionCallbacks {
47
+ private static final String TAG = VideoCallActivity.class.getSimpleName();
48
+ private static final int PERMISSIONS_REQUEST_CODE = 124;
49
+
50
+ private Session session;
51
+ private Publisher publisher;
52
+ boolean isMuted = false;
53
+ boolean isCamOff = false;
54
+ boolean isTimeron = false;
55
+ private Subscriber subscriber;
56
+ private FrameLayout publisherViewContainer;
57
+ private FrameLayout subscriberViewContainer;
58
+ private FloatingActionButton fabCameraOff;
59
+ private ImageView imageViewEndcall;
60
+ private ImageView imageViewMute;
61
+ private ImageView imageViewCamOff;
62
+ private ImageView imageViewCamSwitch;
63
+ Boolean ISPROVIDER = false;
64
+ private TextView timerTextView;
65
+ private long startTime = 0;
66
+
67
+ private PublisherKit.PublisherListener publisherListener = new PublisherKit.PublisherListener() {
68
+ @Override
69
+ public void onStreamCreated(PublisherKit publisherKit, Stream stream) {
70
+ Log.d(TAG, "onStreamCreated: Publisher Stream Created. Own stream " + stream.getStreamId());
71
+ }
72
+
73
+ @Override
74
+ public void onStreamDestroyed(PublisherKit publisherKit, Stream stream) {
75
+ Log.d(TAG, "onStreamDestroyed: Publisher Stream Destroyed. Own stream " + stream.getStreamId());
76
+ }
77
+
78
+ @Override
79
+ public void onError(PublisherKit publisherKit, OpentokError opentokError) {
80
+ finishWithMessage("PublisherKit onError: " + opentokError.getMessage());
81
+ }
82
+ };
83
+
84
+ private final Session.SessionListener sessionListener = new Session.SessionListener() {
85
+ @Override
86
+ public void onConnected(Session session) {
87
+
88
+ Log.d(TAG, "onConnected: Connected to session: " + session.getSessionId());
89
+ // JSObject eventData = new JSObject();
90
+ // eventData.put("key", "value");
91
+ // notifyListeners("", eventData);
92
+ publisher = new Publisher.Builder(VideoCallActivity.this).build();
93
+ publisher.setPublisherListener(publisherListener);
94
+ publisher.getRenderer().setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);
95
+ Log.d("publisherViewContainer", "publisherViewContainer.toString()");
96
+ FrameLayout Framelayout = findViewById(R.id.publisher_container);
97
+
98
+ try {
99
+ if (Framelayout != null) {
100
+ Log.d("publisherViewContainer", "Inside if =======");
101
+ Framelayout.addView(publisher.getView());
102
+ }
103
+ } catch (Exception e) {
104
+ Log.d("publisherViewContainer", e.toString());
105
+ }
106
+
107
+ if (publisher.getView() instanceof GLSurfaceView) {
108
+ ((GLSurfaceView) publisher.getView()).setZOrderOnTop(true);
109
+ }
110
+
111
+ session.publish(publisher);
112
+ }
113
+
114
+ @Override
115
+ public void onDisconnected(Session session) {
116
+ isTimeron=false;
117
+
118
+ Log.d(TAG, "onDisconnected: Disconnected from session: " + session.getSessionId());
119
+ if (publisher != null) {
120
+ publisher = null;
121
+ publisherViewContainer.removeAllViews();
122
+ }
123
+ Intent resultIntent = new Intent();
124
+ String resultcode = ISPROVIDER?"999":"888";
125
+ resultIntent.putExtra("result_key", resultcode); // Optional: Pass data back to the calling activity
126
+ setResult(RESULT_OK, resultIntent);
127
+ // setResult(RESULT_CANCELED); // Use this to indicate cancellation
128
+
129
+
130
+ finish();
131
+ }
132
+
133
+ @Override
134
+ public void onStreamReceived(Session session, Stream stream) {
135
+ Log.d(TAG, "onStreamReceived: New Stream Received " + stream.getStreamId() + " in session: " + session.getSessionId());
136
+
137
+ if (subscriber == null) {
138
+ subscriber = new Subscriber.Builder(VideoCallActivity.this, stream).build();
139
+ subscriber.getRenderer().setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);
140
+ subscriber.setSubscriberListener(subscriberListener);
141
+ session.subscribe(subscriber);
142
+ try {
143
+ subscriberViewContainer.addView(subscriber.getView());
144
+ } catch (Exception e) {
145
+ Log.d("subscriberViewContainer", e.toString());
146
+
147
+ }
148
+ }
149
+ }
150
+
151
+ @Override
152
+ public void onStreamDropped(Session session, Stream stream) {
153
+
154
+ Log.d(TAG, "onStreamDropped: Stream Dropped: " + stream.getStreamId() + " in session: " + session.getSessionId());
155
+
156
+ if(!ISPROVIDER){
157
+ session.disconnect();
158
+ if (subscriber != null) {
159
+ subscriber = null;
160
+ subscriberViewContainer.removeAllViews();
161
+ Intent resultIntent = new Intent();
162
+ String resultcode = ISPROVIDER?"999":"888";
163
+ resultIntent.putExtra("result_key", resultcode); // Optional: Pass data back to the calling activity
164
+ setResult(RESULT_OK, resultIntent);
165
+ finish();
166
+ }
167
+ }
168
+ }
169
+
170
+ @Override
171
+ public void onError(Session session, OpentokError opentokError) {
172
+ finishWithMessage("Session error: " + opentokError.getMessage());
173
+ }
174
+ };
175
+
176
+ SubscriberKit.SubscriberListener subscriberListener = new SubscriberKit.SubscriberListener() {
177
+ @Override
178
+ public void onConnected(SubscriberKit subscriberKit) {
179
+ Log.d(TAG, "onConnected: Subscriber connected. Stream: " + subscriberKit.getStream().getStreamId());
180
+ }
181
+
182
+ @Override
183
+ public void onDisconnected(SubscriberKit subscriberKit) {
184
+ Log.d(TAG, "onDisconnected: Subscriber disconnected. Stream: " + subscriberKit.getStream().getStreamId());
185
+ }
186
+
187
+ @Override
188
+ public void onError(SubscriberKit subscriberKit, OpentokError opentokError) {
189
+ finishWithMessage("SubscriberKit onError: " + opentokError.getMessage());
190
+ }
191
+ };
192
+
193
+ @Override
194
+ protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
195
+ super.onActivityResult(requestCode, resultCode, data);
196
+ if (resultCode==99) {
197
+ Log.d(TAG,"code === 99 in second");
198
+ }else{
199
+ Log.d(TAG,"code === 98 in second");
200
+
201
+ }
202
+ }
203
+
204
+ @Override
205
+ protected void onCreate(Bundle savedInstanceState) {
206
+
207
+ Intent intent = getIntent();
208
+
209
+ super.onCreate(savedInstanceState);
210
+ setContentView(R.layout.video_call_layout);
211
+ getSupportActionBar().hide();
212
+ ActionBar actionBar = getActionBar();
213
+ if (actionBar != null) {
214
+ actionBar.hide();
215
+ }
216
+
217
+ if (intent != null) {
218
+ // Retrieve the data using the same key you used to put it in the Intent
219
+ String TOKEN = intent.getStringExtra("token");
220
+ String SESSION_ID = intent.getStringExtra("sessionId");
221
+ String API_KEY = intent.getStringExtra("apiKey");
222
+ String SUBSCRIBERNAME = intent.getStringExtra("subscriberName");
223
+ String PUBLISHERNAME = intent.getStringExtra("publisherName");
224
+ ISPROVIDER = intent.getBooleanExtra("isProvider",false);
225
+ publisherViewContainer = findViewById(R.id.publisher_container);
226
+ subscriberViewContainer = findViewById(R.id.subscriber_container);
227
+ TextView publisherNameTextView = findViewById(R.id.publisherName);
228
+ TextView subscriberNameTextView = findViewById(R.id.subscriberName);
229
+ publisherNameTextView.setText(PUBLISHERNAME);
230
+ subscriberNameTextView.setText(SUBSCRIBERNAME);
231
+ timerTextView = findViewById(R.id.timerTextView);
232
+ startTime = System.currentTimeMillis();
233
+ isTimeron =true;
234
+ startTimer();
235
+ initializeSession(API_KEY,SESSION_ID , TOKEN);
236
+
237
+ }
238
+
239
+
240
+
241
+ imageViewEndcall = findViewById(R.id.imageView1);
242
+ imageViewMute = findViewById(R.id.imageView2);
243
+ imageViewCamOff = findViewById(R.id.imageView3);
244
+ imageViewCamSwitch = findViewById(R.id.imageView4);
245
+
246
+ imageViewEndcall.setOnClickListener(new View.OnClickListener() {
247
+ @Override
248
+ public void onClick(View v) {
249
+
250
+ session.disconnect();
251
+
252
+ }
253
+ });
254
+
255
+ imageViewMute.setOnClickListener(new View.OnClickListener() {
256
+ @Override
257
+ public void onClick(View v) {
258
+
259
+ if (!isMuted) {
260
+ publisher.setPublishAudio(false);
261
+ imageViewMute.setImageResource(R.drawable.microphoneoff);
262
+ } else {
263
+ publisher.setPublishAudio(true);
264
+ imageViewMute.setImageResource(R.drawable.microphoneonwhite);
265
+ }
266
+ isMuted = !isMuted;
267
+
268
+ }
269
+ });
270
+ imageViewCamOff.setOnClickListener(new View.OnClickListener() {
271
+ @Override
272
+ public void onClick(View v) {
273
+
274
+ if (!isCamOff) {
275
+ publisher.setPublishVideo(false);
276
+ imageViewCamOff.setImageResource(R.drawable.cameraoff);
277
+ imageViewCamSwitch.setVisibility(View.GONE);
278
+
279
+ } else {
280
+ publisher.setPublishVideo(true);
281
+ imageViewCamOff.setImageResource(R.drawable.cameraonwhite);
282
+ imageViewCamSwitch.setVisibility(View.VISIBLE);
283
+
284
+ }
285
+ isCamOff = !isCamOff;
286
+
287
+ }
288
+ });
289
+ imageViewCamSwitch.setOnClickListener(new View.OnClickListener() {
290
+ @Override
291
+ public void onClick(View v) {
292
+ publisher.cycleCamera();
293
+
294
+
295
+
296
+ }
297
+ });
298
+
299
+
300
+
301
+ }
302
+
303
+ @Override
304
+ protected void onPause() {
305
+ super.onPause();
306
+ if (session != null) {
307
+ session.onPause();
308
+ }
309
+ }
310
+
311
+ @Override
312
+ protected void onResume() {
313
+ super.onResume();
314
+
315
+ if (session != null) {
316
+ session.onResume();
317
+ }
318
+ }
319
+ private void startTimer() {
320
+ // startTime = System.currentTimeMillis();
321
+ Handler handler = new Handler();
322
+ handler.postDelayed(new Runnable() {
323
+ @Override
324
+ public void run() {
325
+ long currentTime = System.currentTimeMillis() - startTime;
326
+ int seconds = (int) (currentTime / 1000);
327
+ int minutes = seconds / 60;
328
+ int hours = minutes / 60;
329
+ seconds %= 60;
330
+ minutes %= 60;
331
+
332
+ // Format the time as "00:00:00"
333
+ String timeString = String.format("%02d:%02d:%02d", hours, minutes, seconds);
334
+ Log.d(TAG, String.valueOf(currentTime));
335
+
336
+ // Update the TextView with the formatted time
337
+ timerTextView.setText(timeString);
338
+
339
+ // Continue updating the timer
340
+ if(isTimeron)
341
+ startTimer();
342
+ }
343
+ }, 1000); // Update the timer every 1 second (1000 milliseconds)
344
+ }
345
+ @Override
346
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
347
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults);
348
+ EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
349
+ }
350
+
351
+ @Override
352
+ public void onPermissionsGranted(int requestCode, List<String> perms) {
353
+ Log.d(TAG, "onPermissionsGranted:" + requestCode + ": " + perms);
354
+ }
355
+
356
+ @Override
357
+ public void onPermissionsDenied(int requestCode, List<String> perms) {
358
+ finishWithMessage("onPermissionsDenied: " + requestCode + ": " + perms);
359
+ }
360
+
361
+ @AfterPermissionGranted(PERMISSIONS_REQUEST_CODE)
362
+ // private void requestPermissions() {
363
+ // String[] perms = {Manifest.permission.INTERNET, Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO};
364
+ //
365
+ // if (EasyPermissions.hasPermissions(this, perms)) {
366
+ //
367
+ // if (ServerConfig.hasChatServerUrl()) {
368
+ // // Custom server URL exists - retrieve session config
369
+ // if(!ServerConfig.isValid()) {
370
+ // finishWithMessage("Invalid chat server url: " + ServerConfig.CHAT_SERVER_URL);
371
+ // return;
372
+ // }
373
+ //
374
+ // initRetrofit();
375
+ //// getSession();
376
+ // } else {
377
+ // // Use hardcoded session config
378
+ // if(!OpenTokConfig.isValid()) {
379
+ // finishWithMessage("Invalid OpenTokConfig. " + OpenTokConfig.getDescription());
380
+ // return;
381
+ // }
382
+ //
383
+ // initializeSession(OpenTokConfig.API_KEY, OpenTokConfig.SESSION_ID, OpenTokConfig.TOKEN);
384
+ // }
385
+ // } else {
386
+ // EasyPermissions.requestPermissions(this, getString(R.string.rationale_video_app), PERMISSIONS_REQUEST_CODE, perms);
387
+ // }
388
+ // }
389
+
390
+
391
+
392
+ private void initializeSession(String apiKey, String sessionId, String token) {
393
+ Log.i(TAG, "apiKey: " + apiKey);
394
+ Log.i(TAG, "sessionId: " + sessionId);
395
+ Log.i(TAG, "token: " + token);
396
+
397
+ /*
398
+ The context used depends on the specific use case, but usually, it is desired for the session to
399
+ live outside of the Activity e.g: live between activities. For a production applications,
400
+ it's convenient to use Application context instead of Activity context.
401
+ */
402
+ session = new Session.Builder(this, apiKey, sessionId).build();
403
+ session.setSessionListener(sessionListener);
404
+ session.connect(token);
405
+ }
406
+
407
+ // private void initRetrofit() {
408
+ // HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
409
+ // logging.setLevel(Level.BODY);
410
+ //
411
+ // OkHttpClient client = new OkHttpClient.Builder()
412
+ // .addInterceptor(logging)
413
+ // .build();
414
+ //
415
+ // retrofit = new Retrofit.Builder()
416
+ // .baseUrl(ServerConfig.CHAT_SERVER_URL)
417
+ // .addConverterFactory(MoshiConverterFactory.create())
418
+ // .client(client)
419
+ // .build();
420
+ //
421
+ //// apiService = retrofit.create(APIService.class);
422
+ // }
423
+
424
+ private void finishWithMessage(String message) {
425
+ Log.e(TAG, message);
426
+ Toast.makeText(this, message, Toast.LENGTH_LONG).show();
427
+ session.disconnect();
428
+ Intent resultIntent = new Intent();
429
+ String resultcode = ISPROVIDER?"999":"888";
430
+ resultIntent.putExtra("result_key", resultcode); // Optional: Pass data back to the calling activity
431
+ setResult(RESULT_OK, resultIntent);
432
+ this.finish();
433
+ }
434
+ }
@@ -0,0 +1,11 @@
1
+ package com.managemyhealth.plugin.vonage;
2
+
3
+ import android.util.Log;
4
+
5
+ public class vonage {
6
+
7
+ public String echo(String value) {
8
+ Log.i("Echo", value);
9
+ return value;
10
+ }
11
+ }