@@ -14,7 +14,8 @@ namespace CommunicationCallingXamarinSampleApp.Droid
14
14
{
15
15
public class Composite : IComposite
16
16
{
17
- public void joinCall ( string name , string acsToken , string callID , bool isTeamsCall , LocalizationProps ? localization , DataModelInjectionProps ? dataModelInjection ) {
17
+ public void joinCall ( string name , string acsToken , string callID , bool isTeamsCall , LocalizationProps ? localization , DataModelInjectionProps ? dataModelInjection , OrientationProps orientationProps , CallControlProps callControlProps )
18
+ {
18
19
CommunicationTokenCredential credentials = new CommunicationTokenCredential ( acsToken ) ;
19
20
20
21
@@ -23,16 +24,25 @@ public void joinCall(string name, string acsToken, string callID, bool isTeamsCa
23
24
CallComposite callComposite =
24
25
new CallCompositeBuilder ( )
25
26
. Theme ( Resource . Style . MyCompany_CallComposite )
26
- . Localization ( new CallCompositeLocalizationOptions ( Locale . ForLanguageTag ( localization . Value . locale ) , layoutDirection ) ) . Build ( ) ;
27
+ . Localization ( new CallCompositeLocalizationOptions ( Locale . ForLanguageTag ( localization . Value . locale ) , layoutDirection ) )
28
+ . SetupScreenOrientation ( GetOrientation ( orientationProps . setupScreenOrientation ) )
29
+ . CallScreenOrientation ( GetOrientation ( orientationProps . callScreenOrientation ) )
30
+ . Build ( ) ;
27
31
28
32
29
33
callComposite . AddOnErrorEventHandler ( new EventHandler ( ) ) ;
30
34
callComposite . AddOnRemoteParticipantJoinedEventHandler ( new RemoteParticipantJoinedHandler ( callComposite , dataModelInjection ) ) ;
35
+ callComposite . AddOnCallStateChangedEventHandler ( new CallStateChangedEventHandler ( ) ) ;
36
+ callComposite . AddOnDismissedEventHandler ( new CallCompositeDismissedEventHandler ( ) ) ;
37
+
38
+ CallCompositeLocalOptions localOptions = new CallCompositeLocalOptions ( )
39
+ . SetSkipSetupScreen ( callControlProps . isSkipSetupON )
40
+ . SetCameraOn ( callControlProps . isCameraON )
41
+ . SetMicrophoneOn ( callControlProps . isMicrophoneON ) ;
31
42
32
-
33
43
CallCompositeParticipantViewData personaData = null ;
34
44
35
- if ( dataModelInjection != null )
45
+ if ( dataModelInjection != null )
36
46
{
37
47
var context = MainActivity . Instance . ApplicationContext ;
38
48
int resID = context . Resources . GetIdentifier ( dataModelInjection . Value . localAvatar , "drawable" , context . PackageName ) ;
@@ -54,14 +64,10 @@ public void joinCall(string name, string acsToken, string callID, bool isTeamsCa
54
64
55
65
if ( personaData != null )
56
66
{
57
- callComposite . Launch ( MainActivity . Instance , remoteOptions , new CallCompositeLocalOptions ( personaData ) ) ;
58
-
67
+ localOptions . SetParticipantViewData ( personaData ) ;
59
68
}
60
- else
61
- {
62
- callComposite . Launch ( MainActivity . Instance , remoteOptions ) ;
63
69
64
- }
70
+ callComposite . Launch ( MainActivity . Instance , remoteOptions , localOptions ) ;
65
71
}
66
72
else
67
73
{
@@ -72,16 +78,14 @@ public void joinCall(string name, string acsToken, string callID, bool isTeamsCa
72
78
73
79
if ( personaData != null )
74
80
{
75
- callComposite . Launch ( MainActivity . Instance , remoteOptions , new CallCompositeLocalOptions ( personaData ) ) ;
76
-
77
- }
78
- else
79
- {
80
- callComposite . Launch ( MainActivity . Instance , remoteOptions ) ;
81
-
81
+ localOptions . SetParticipantViewData ( personaData ) ;
82
82
}
83
83
84
+ callComposite . Launch ( MainActivity . Instance , remoteOptions , localOptions ) ;
84
85
}
86
+
87
+ // to dismiss composite
88
+ // callComposite.Dismiss();
85
89
}
86
90
87
91
public List < string > languages ( )
@@ -96,6 +100,48 @@ public List<string> languages()
96
100
return localeStrings ;
97
101
}
98
102
103
+ public List < string > orientations ( )
104
+ {
105
+ List < String > orientationStrings = new List < String > ( ) ;
106
+
107
+ foreach ( CallCompositeSupportedScreenOrientation orientation in CallCompositeSupportedScreenOrientation . Values ( ) )
108
+ {
109
+ orientationStrings . Add ( orientation . ToString ( ) ) ;
110
+ }
111
+
112
+ return orientationStrings ;
113
+ }
114
+
115
+ private CallCompositeSupportedScreenOrientation GetOrientation ( string orientation )
116
+ {
117
+ CallCompositeSupportedScreenOrientation _orientation = CallCompositeSupportedScreenOrientation . User ;
118
+ switch ( orientation )
119
+ {
120
+ case "PORTRAIT" :
121
+ _orientation = CallCompositeSupportedScreenOrientation . Portrait ;
122
+ break ;
123
+ case "LANDSCAPE" :
124
+ _orientation = CallCompositeSupportedScreenOrientation . Landscape ;
125
+ break ;
126
+ case "REVERSE_LANDSCAPE" :
127
+ _orientation = CallCompositeSupportedScreenOrientation . ReverseLandscape ;
128
+ break ;
129
+ case "USER_LANDSCAPE" :
130
+ _orientation = CallCompositeSupportedScreenOrientation . UserLandscape ;
131
+ break ;
132
+ case "FULL_SENSOR" :
133
+ _orientation = CallCompositeSupportedScreenOrientation . FullSensor ;
134
+ break ;
135
+ case "USER" :
136
+ _orientation = CallCompositeSupportedScreenOrientation . User ;
137
+ break ;
138
+ default :
139
+ _orientation = CallCompositeSupportedScreenOrientation . User ;
140
+ break ;
141
+ }
142
+ return _orientation ;
143
+ }
144
+
99
145
public class EventHandler : Java . Lang . Object , ICallCompositeEventHandler
100
146
{
101
147
public void Disposed ( )
@@ -145,7 +191,105 @@ public void Dispose()
145
191
146
192
}
147
193
}
148
- }
149
194
195
+ private class CallStateChangedEventHandler : Java . Lang . Object , ICallCompositeEventHandler
196
+ {
197
+ public void Disposed ( )
198
+ {
199
+ }
200
+
201
+ public void DisposeUnlessReferenced ( )
202
+ {
203
+ }
204
+
205
+ public void Finalized ( )
206
+ {
207
+ }
208
+
209
+ public void Handle ( Java . Lang . Object eventArgs )
210
+ {
211
+ if ( eventArgs is CallCompositeCallStateChangedEvent )
212
+ {
213
+ var callState = eventArgs as CallCompositeCallStateChangedEvent ;
214
+ Console . WriteLine ( callState . Code . ToString ( ) ) ;
215
+ }
216
+ }
217
+
218
+ public void SetJniIdentityHashCode ( int value )
219
+ {
220
+ }
221
+
222
+ public void SetJniManagedPeerState ( JniManagedPeerStates value )
223
+ {
224
+ }
225
+
226
+ public void SetPeerReference ( JniObjectReference reference )
227
+ {
228
+ }
229
+
230
+ public void UnregisterFromRuntime ( )
231
+ {
232
+ }
233
+
234
+ protected virtual void Dispose ( bool disposing )
235
+ {
236
+
237
+ }
238
+
239
+ public void Dispose ( )
240
+ {
150
241
242
+ }
243
+ }
244
+
245
+ private class CallCompositeDismissedEventHandler : Java . Lang . Object , ICallCompositeEventHandler
246
+ {
247
+ public void Disposed ( )
248
+ {
249
+ }
250
+
251
+ public void DisposeUnlessReferenced ( )
252
+ {
253
+ }
254
+
255
+ public void Finalized ( )
256
+ {
257
+ }
258
+
259
+ public void Handle ( Java . Lang . Object eventArgs )
260
+ {
261
+ if ( eventArgs is CallCompositeDismissedEvent )
262
+ {
263
+ var dismissedEvent = eventArgs as CallCompositeDismissedEvent ;
264
+ Console . WriteLine ( "CallCompositeDismissedEvent" ) ;
265
+ }
266
+ }
267
+
268
+ public void SetJniIdentityHashCode ( int value )
269
+ {
270
+ }
271
+
272
+ public void SetJniManagedPeerState ( JniManagedPeerStates value )
273
+ {
274
+ }
275
+
276
+ public void SetPeerReference ( JniObjectReference reference )
277
+ {
278
+ }
279
+
280
+ public void UnregisterFromRuntime ( )
281
+ {
282
+ }
283
+
284
+ protected virtual void Dispose ( bool disposing )
285
+ {
286
+
287
+ }
288
+
289
+ public void Dispose ( )
290
+ {
291
+
292
+ }
293
+ }
294
+ }
151
295
}
0 commit comments