Bläddra i källkod

Codying style: naming, formatting, comments

j8
Lyubo Marinov 7 år sedan
förälder
incheckning
5e79bbecef

+ 2
- 2
android/sdk/src/main/java/org/jitsi/meet/sdk/invite/AddPeopleController.java Visa fil

@@ -110,7 +110,7 @@ public class AddPeopleController {
110 110
 
111 111
         if (owner != null) {
112 112
             WritableArray invitees = new WritableNativeArray();
113
-    
113
+
114 114
             for(int i = 0, size = ids.size(); i < size; i++) {
115 115
                 String id = ids.get(i);
116 116
 
@@ -123,7 +123,7 @@ public class AddPeopleController {
123 123
                     // so just skip it.
124 124
                 }
125 125
             }
126
-    
126
+
127 127
             owner.invite(this, invitees);
128 128
         }
129 129
     }

+ 3
- 3
ios/example-pip-app/example-pip-app.xcodeproj/project.pbxproj Visa fil

@@ -79,11 +79,11 @@
79 79
 			isa = PBXGroup;
80 80
 			children = (
81 81
 				C6F99C3A204DE6BE0001F710 /* AppDelegate.swift */,
82
-				C6F99C3C204DE6BE0001F710 /* ViewController.swift */,
83
-				C6F99C3E204DE6BE0001F710 /* Main.storyboard */,
84 82
 				C6F99C41204DE6BE0001F710 /* Assets.xcassets */,
85
-				C6F99C43204DE6BE0001F710 /* LaunchScreen.storyboard */,
86 83
 				C6F99C46204DE6BE0001F710 /* Info.plist */,
84
+				C6F99C43204DE6BE0001F710 /* LaunchScreen.storyboard */,
85
+				C6F99C3E204DE6BE0001F710 /* Main.storyboard */,
86
+				C6F99C3C204DE6BE0001F710 /* ViewController.swift */,
87 87
 			);
88 88
 			path = src;
89 89
 			sourceTree = "<group>";

+ 4
- 4
ios/example-pip-app/src/AppDelegate.swift Visa fil

@@ -20,21 +20,21 @@ import JitsiMeet
20 20
 class AppDelegate: UIResponder, UIApplicationDelegate {
21 21
 
22 22
     var window: UIWindow?
23
-    
23
+
24 24
     func application(_ application: UIApplication,
25 25
                      didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
26 26
         guard let launchOptions = launchOptions else { return false }
27 27
         return JitsiMeetView.application(application, didFinishLaunchingWithOptions: launchOptions)
28 28
     }
29
-    
29
+
30 30
     // MARK: - Linking delegate methods
31
-    
31
+
32 32
     func application(_ application: UIApplication,
33 33
                      continue userActivity: NSUserActivity,
34 34
                      restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
35 35
         return JitsiMeetView.application(application, continue: userActivity, restorationHandler: restorationHandler)
36 36
     }
37
-    
37
+
38 38
     func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
39 39
         return JitsiMeetView.application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
40 40
     }

+ 14
- 14
ios/example-pip-app/src/ViewController.swift Visa fil

@@ -20,27 +20,27 @@ import JitsiMeet
20 20
 class ViewController: UIViewController {
21 21
 
22 22
     @IBOutlet weak var videoButton: UIButton?
23
-    
23
+
24 24
     fileprivate var pipViewCoordinator: PiPViewCoordinator?
25 25
     fileprivate var jitsiMeetView: JitsiMeetView?
26
-    
26
+
27 27
     override func viewDidLoad() {
28 28
         super.viewDidLoad()
29 29
     }
30
-    
30
+
31 31
     override func viewWillTransition(to size: CGSize,
32 32
                                      with coordinator: UIViewControllerTransitionCoordinator) {
33 33
         super.viewWillTransition(to: size, with: coordinator)
34
-        
34
+
35 35
         let rect = CGRect(origin: CGPoint.zero, size: size)
36 36
         pipViewCoordinator?.resetBounds(bounds: rect)
37 37
     }
38
-    
38
+
39 39
     // MARK: - Actions
40
-    
40
+
41 41
     @IBAction func openJitsiMeet(sender: Any?) {
42 42
         cleanUp()
43
-        
43
+
44 44
         // create and configure jitsimeet view
45 45
         let jitsiMeetView = JitsiMeetView()
46 46
         jitsiMeetView.welcomePageEnabled = true
@@ -48,18 +48,18 @@ class ViewController: UIViewController {
48 48
         jitsiMeetView.load(nil)
49 49
         jitsiMeetView.delegate = self
50 50
         self.jitsiMeetView = jitsiMeetView
51
-        
51
+
52 52
         // Enable jitsimeet view to be a view that can be displayed
53 53
         // on top of all the things, and let the coordinator to manage
54 54
         // the view state and interactions
55 55
         pipViewCoordinator = PiPViewCoordinator(withView: jitsiMeetView)
56 56
         pipViewCoordinator?.configureAsStickyView(withParentView: view)
57
-        
57
+
58 58
         // animate in
59 59
         jitsiMeetView.alpha = 0
60 60
         pipViewCoordinator?.show()
61 61
     }
62
-    
62
+
63 63
     fileprivate func cleanUp() {
64 64
         jitsiMeetView?.removeFromSuperview()
65 65
         jitsiMeetView = nil
@@ -68,21 +68,21 @@ class ViewController: UIViewController {
68 68
 }
69 69
 
70 70
 extension ViewController: JitsiMeetViewDelegate {
71
-    
71
+
72 72
     func conferenceFailed(_ data: [AnyHashable : Any]!) {
73 73
         hideJitsiMeetViewAndCleanUp()
74 74
     }
75
-    
75
+
76 76
     func conferenceLeft(_ data: [AnyHashable : Any]!) {
77 77
         hideJitsiMeetViewAndCleanUp()
78 78
     }
79
-    
79
+
80 80
     func enterPicture(inPicture data: [AnyHashable : Any]!) {
81 81
         DispatchQueue.main.async {
82 82
             self.pipViewCoordinator?.enterPictureInPicture()
83 83
         }
84 84
     }
85
-    
85
+
86 86
     private func hideJitsiMeetViewAndCleanUp() {
87 87
         DispatchQueue.main.async {
88 88
             self.pipViewCoordinator?.hide() { _ in

+ 20
- 20
ios/sdk/sdk.xcodeproj/project.pbxproj Visa fil

@@ -38,9 +38,9 @@
38 38
 		B386B85D20981A75000DEF7A /* Invite.m in Sources */ = {isa = PBXBuildFile; fileRef = B386B85620981A75000DEF7A /* Invite.m */; };
39 39
 		C6245F5D2053091D0040BE68 /* image-resize@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = C6245F5B2053091D0040BE68 /* image-resize@2x.png */; };
40 40
 		C6245F5E2053091D0040BE68 /* image-resize@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = C6245F5C2053091D0040BE68 /* image-resize@3x.png */; };
41
-		C69EFA0C209A0F660027712B /* JMCallKitNotifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = C69EFA09209A0F650027712B /* JMCallKitNotifier.swift */; };
41
+		C69EFA0C209A0F660027712B /* JMCallKitEmitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C69EFA09209A0F650027712B /* JMCallKitEmitter.swift */; };
42 42
 		C69EFA0D209A0F660027712B /* JMCallKitProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C69EFA0A209A0F660027712B /* JMCallKitProxy.swift */; };
43
-		C69EFA0E209A0F660027712B /* JMCallKitEventListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = C69EFA0B209A0F660027712B /* JMCallKitEventListener.swift */; };
43
+		C69EFA0E209A0F660027712B /* JMCallKitListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = C69EFA0B209A0F660027712B /* JMCallKitListener.swift */; };
44 44
 		C6A34261204EF76800E062DD /* DragGestureController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6A3425E204EF76800E062DD /* DragGestureController.swift */; };
45 45
 		C6CC49AF207412CF000DFA42 /* PiPViewCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6CC49AE207412CF000DFA42 /* PiPViewCoordinator.swift */; };
46 46
 		C6F99C15204DB63E0001F710 /* JitsiMeetView+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = C6F99C13204DB63D0001F710 /* JitsiMeetView+Private.h */; };
@@ -86,9 +86,9 @@
86 86
 		B386B85620981A75000DEF7A /* Invite.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Invite.m; sourceTree = "<group>"; };
87 87
 		C6245F5B2053091D0040BE68 /* image-resize@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "image-resize@2x.png"; path = "src/picture-in-picture/image-resize@2x.png"; sourceTree = "<group>"; };
88 88
 		C6245F5C2053091D0040BE68 /* image-resize@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "image-resize@3x.png"; path = "src/picture-in-picture/image-resize@3x.png"; sourceTree = "<group>"; };
89
-		C69EFA09209A0F650027712B /* JMCallKitNotifier.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JMCallKitNotifier.swift; sourceTree = "<group>"; };
89
+		C69EFA09209A0F650027712B /* JMCallKitEmitter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JMCallKitEmitter.swift; sourceTree = "<group>"; };
90 90
 		C69EFA0A209A0F660027712B /* JMCallKitProxy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JMCallKitProxy.swift; sourceTree = "<group>"; };
91
-		C69EFA0B209A0F660027712B /* JMCallKitEventListener.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JMCallKitEventListener.swift; sourceTree = "<group>"; };
91
+		C69EFA0B209A0F660027712B /* JMCallKitListener.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JMCallKitListener.swift; sourceTree = "<group>"; };
92 92
 		C6A3425E204EF76800E062DD /* DragGestureController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DragGestureController.swift; sourceTree = "<group>"; };
93 93
 		C6CC49AE207412CF000DFA42 /* PiPViewCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PiPViewCoordinator.swift; sourceTree = "<group>"; };
94 94
 		C6F99C13204DB63D0001F710 /* JitsiMeetView+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "JitsiMeetView+Private.h"; sourceTree = "<group>"; };
@@ -112,12 +112,12 @@
112 112
 		0BCA49681EC4BBE500B793EE /* Resources */ = {
113 113
 			isa = PBXGroup;
114 114
 			children = (
115
-				75635B0820751D6D00F29C9F /* joined.wav */,
116
-				75635B0920751D6D00F29C9F /* left.wav */,
117 115
 				0BC4B8681F8C01E100CE8B21 /* CallKitIcon.png */,
118 116
 				C6245F5B2053091D0040BE68 /* image-resize@2x.png */,
119 117
 				C6245F5C2053091D0040BE68 /* image-resize@3x.png */,
120 118
 				0BCA496B1EC4BBF900B793EE /* jitsi.ttf */,
119
+				75635B0820751D6D00F29C9F /* joined.wav */,
120
+				75635B0920751D6D00F29C9F /* left.wav */,
121 121
 			);
122 122
 			name = Resources;
123 123
 			sourceTree = "<group>";
@@ -144,25 +144,24 @@
144 144
 		0BD906E71EC0C00300C8C18E /* src */ = {
145 145
 			isa = PBXGroup;
146 146
 			children = (
147
-				C69EFA02209A0EFD0027712B /* callkit */,
148
-				B386B84F20981A11000DEF7A /* invite */,
149
-				C6A3426B204F127900E062DD /* picture-in-picture */,
150
-				0BCA495C1EC4B6C600B793EE /* AudioMode.m */,
151 147
 				0BB9AD7C1F60356D001C08DB /* AppInfo.m */,
152
-				0BB9AD7A1F5EC8F4001C08DB /* CallKit.m */,
148
+				0BCA495C1EC4B6C600B793EE /* AudioMode.m */,
149
+				C69EFA02209A0EFD0027712B /* callkit */,
153 150
 				0BA13D301EE83FF8007BEF7F /* ExternalAPI.m */,
154 151
 				0BD906E91EC0C00300C8C18E /* Info.plist */,
155
-				0B7C2CFC200F51D60060D076 /* LaunchOptions.m */,
152
+				B386B84F20981A11000DEF7A /* invite */,
156 153
 				0BD906E81EC0C00300C8C18E /* JitsiMeet.h */,
157 154
 				0B412F161EDEC65D00B1A0A6 /* JitsiMeetView.h */,
158 155
 				0B412F171EDEC65D00B1A0A6 /* JitsiMeetView.m */,
159 156
 				C6F99C13204DB63D0001F710 /* JitsiMeetView+Private.h */,
160 157
 				0B412F1B1EDEC80100B1A0A6 /* JitsiMeetViewDelegate.h */,
158
+				0B7C2CFC200F51D60060D076 /* LaunchOptions.m */,
161 159
 				0B44A0181F902126009D1D64 /* MPVolumeViewManager.m */,
162
-				0B93EF7C1EC9DDCD0030D24D /* RCTBridgeWrapper.h */,
163
-				0B93EF7D1EC9DDCD0030D24D /* RCTBridgeWrapper.m */,
160
+				C6A3426B204F127900E062DD /* picture-in-picture */,
164 161
 				0BCA495D1EC4B6C600B793EE /* POSIX.m */,
165 162
 				0BCA495E1EC4B6C600B793EE /* Proximity.m */,
163
+				0B93EF7C1EC9DDCD0030D24D /* RCTBridgeWrapper.h */,
164
+				0B93EF7D1EC9DDCD0030D24D /* RCTBridgeWrapper.m */,
166 165
 			);
167 166
 			path = src;
168 167
 			sourceTree = "<group>";
@@ -170,11 +169,11 @@
170 169
 		9C3C6FA2341729836589B856 /* Frameworks */ = {
171 170
 			isa = PBXGroup;
172 171
 			children = (
173
-				0BB9AD781F5EC6D7001C08DB /* Intents.framework */,
174 172
 				0BB9AD761F5EC6CE001C08DB /* CallKit.framework */,
175 173
 				0B93EF7A1EC608550030D24D /* CoreText.framework */,
176
-				0BCA49631EC4B76D00B793EE /* WebRTC.framework */,
174
+				0BB9AD781F5EC6D7001C08DB /* Intents.framework */,
177 175
 				03F2ADC957FF109849B7FCA1 /* libPods-JitsiMeet.a */,
176
+				0BCA49631EC4B76D00B793EE /* WebRTC.framework */,
178 177
 			);
179 178
 			name = Frameworks;
180 179
 			sourceTree = "<group>";
@@ -208,8 +207,9 @@
208 207
 		C69EFA02209A0EFD0027712B /* callkit */ = {
209 208
 			isa = PBXGroup;
210 209
 			children = (
211
-				C69EFA0B209A0F660027712B /* JMCallKitEventListener.swift */,
212
-				C69EFA09209A0F650027712B /* JMCallKitNotifier.swift */,
210
+				0BB9AD7A1F5EC8F4001C08DB /* CallKit.m */,
211
+				C69EFA09209A0F650027712B /* JMCallKitEmitter.swift */,
212
+				C69EFA0B209A0F660027712B /* JMCallKitListener.swift */,
213 213
 				C69EFA0A209A0F660027712B /* JMCallKitProxy.swift */,
214 214
 			);
215 215
 			path = callkit;
@@ -407,10 +407,10 @@
407 407
 				0BCA495F1EC4B6C600B793EE /* AudioMode.m in Sources */,
408 408
 				0B44A0191F902126009D1D64 /* MPVolumeViewManager.m in Sources */,
409 409
 				0BCA49611EC4B6C600B793EE /* Proximity.m in Sources */,
410
-				C69EFA0C209A0F660027712B /* JMCallKitNotifier.swift in Sources */,
410
+				C69EFA0C209A0F660027712B /* JMCallKitEmitter.swift in Sources */,
411 411
 				C6A34261204EF76800E062DD /* DragGestureController.swift in Sources */,
412 412
 				C69EFA0D209A0F660027712B /* JMCallKitProxy.swift in Sources */,
413
-				C69EFA0E209A0F660027712B /* JMCallKitEventListener.swift in Sources */,
413
+				C69EFA0E209A0F660027712B /* JMCallKitListener.swift in Sources */,
414 414
 				0B412F191EDEC65D00B1A0A6 /* JitsiMeetView.m in Sources */,
415 415
 			);
416 416
 			runOnlyForDeploymentPostprocessing = 0;

ios/sdk/src/CallKit.m → ios/sdk/src/callkit/CallKit.m Visa fil

@@ -39,7 +39,7 @@ static NSString * const RNCallKitPerformSetMutedCallAction
39 39
 static NSString * const RNCallKitProviderDidReset
40 40
     = @"providerDidReset";
41 41
 
42
-@interface RNCallKit : RCTEventEmitter <JMCallKitEventListener>
42
+@interface RNCallKit : RCTEventEmitter <JMCallKitListener>
43 43
 @end
44 44
 
45 45
 @implementation RNCallKit
@@ -112,12 +112,12 @@ RCT_EXPORT_METHOD(setProviderConfiguration:(NSDictionary *)dictionary) {
112 112
         dictionary);
113 113
 #endif
114 114
 
115
-    if (![JMCallKitProxy hasProviderBeenConfigurated]) {
115
+    if (![JMCallKitProxy isProviderConfigured]) {
116 116
         [self configureProviderFromDictionary:dictionary];
117 117
     }
118
-    
118
+
119 119
     // register to receive CallKit proxy events
120
-    [JMCallKitProxy addListener: self];
120
+    [JMCallKitProxy addListener:self];
121 121
 }
122 122
 
123 123
 // Start outgoing call
@@ -130,18 +130,16 @@ RCT_EXPORT_METHOD(startCall:(NSString *)callUUID
130 130
     NSLog(@"[RNCallKit][startCall] callUUID = %@", callUUID);
131 131
 #endif
132 132
 
133
-    NSUUID *callUUID_ = [[NSUUID alloc] initWithUUIDString:callUUID];
134
-    
135
-    // Don't start a call action if there's
136
-    // an active call for this UUID
137
-    // (i.e. JitsiMeetView was configured from an incoming call
133
+    // Don't start a new call if there's an active call for the specified
134
+    // callUUID. JitsiMeetView was configured for an incoming call.
138 135
     if ([JMCallKitProxy hasActiveCallForUUID:callUUID]) {
139 136
         resolve(nil);
140 137
         return;
141 138
     }
142
-    
139
+
143 140
     CXHandle *handle_
144 141
         = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:handle];
142
+    NSUUID *callUUID_ = [[NSUUID alloc] initWithUUIDString:callUUID];
145 143
     CXStartCallAction *action
146 144
         = [[CXStartCallAction alloc] initWithCallUUID:callUUID_
147 145
                                                handle:handle_];
@@ -156,8 +154,8 @@ RCT_EXPORT_METHOD(reportCallFailed:(NSString *)callUUID
156 154
                             reject:(RCTPromiseRejectBlock)reject) {
157 155
     NSUUID *callUUID_ = [[NSUUID alloc] initWithUUIDString:callUUID];
158 156
     [JMCallKitProxy reportCallWith:callUUID_
159
-                         endedAt:nil
160
-                          reason:CXCallEndedReasonFailed];
157
+                           endedAt:nil
158
+                            reason:CXCallEndedReasonFailed];
161 159
     resolve(nil);
162 160
 }
163 161
 
@@ -167,7 +165,7 @@ RCT_EXPORT_METHOD(reportConnectedOutgoingCall:(NSString *)callUUID
167 165
                                        reject:(RCTPromiseRejectBlock)reject) {
168 166
     NSUUID *callUUID_ = [[NSUUID alloc] initWithUUIDString:callUUID];
169 167
     [JMCallKitProxy reportOutgoingCallWith:callUUID_
170
-                             connectedAt:nil];
168
+                               connectedAt:nil];
171 169
     resolve(nil);
172 170
 }
173 171
 
@@ -186,12 +184,12 @@ RCT_EXPORT_METHOD(updateCall:(NSString *)callUUID
186 184
     NSUUID *callUUID_ = [[NSUUID alloc] initWithUUIDString:callUUID];
187 185
     NSString *displayName = options[@"displayName"];
188 186
     BOOL hasVideo = [(NSNumber*)options[@"hasVideo"] boolValue];
189
-    
187
+
190 188
     [JMCallKitProxy reportCallUpdateWith:callUUID_
191
-                                handle:nil
192
-                           displayName:displayName
193
-                              hasVideo:hasVideo];
194
-    
189
+                                  handle:nil
190
+                             displayName:displayName
191
+                                hasVideo:hasVideo];
192
+
195 193
     resolve(nil);
196 194
 }
197 195
 
@@ -228,10 +226,11 @@ RCT_EXPORT_METHOD(updateCall:(NSString *)callUUID
228 226
     }
229 227
 
230 228
     NSString *ringtoneSound = dictionary[@"ringtoneSound"];
231
-    
232
-    [JMCallKitProxy configureCallKitProviderWithLocalizedName:localizedName
233
-                                              ringtoneSound:ringtoneSound
234
-                                      iconTemplateImageData:iconTemplateImageData];
229
+
230
+    [JMCallKitProxy
231
+        configureProviderWithLocalizedName:localizedName
232
+                             ringtoneSound:ringtoneSound
233
+                     iconTemplateImageData:iconTemplateImageData];
235 234
 }
236 235
 
237 236
 - (void)requestTransaction:(CXTransaction *)transaction
@@ -242,7 +241,7 @@ RCT_EXPORT_METHOD(updateCall:(NSString *)callUUID
242 241
 #endif
243 242
 
244 243
     [JMCallKitProxy request:transaction
245
-               completion:^(NSError * _Nullable error) {
244
+                 completion:^(NSError * _Nullable error) {
246 245
         if (error) {
247 246
             NSLog(
248 247
                 @"[RNCallKit][requestTransaction] Error requesting transaction (%@): (%@)",
@@ -255,7 +254,7 @@ RCT_EXPORT_METHOD(updateCall:(NSString *)callUUID
255 254
     }];
256 255
 }
257 256
 
258
-#pragma mark - JitsiMeetCallKitListener
257
+#pragma mark - JMCallKitListener
259 258
 
260 259
 // Called when the provider has been reset. We should terminate all calls.
261 260
 - (void)providerDidReset {
@@ -307,7 +306,7 @@ RCT_EXPORT_METHOD(updateCall:(NSString *)callUUID
307 306
     NSLog(@"[RNCallKit][CXProviderDelegate][provider:performStartCallAction:]");
308 307
 #endif
309 308
     [JMCallKitProxy reportOutgoingCallWith:UUID
310
-                     startedConnectingAt:nil];
309
+                       startedConnectingAt:nil];
311 310
 }
312 311
 
313 312
 // The following just help with debugging:

ios/sdk/src/callkit/JMCallKitNotifier.swift → ios/sdk/src/callkit/JMCallKitEmitter.swift Visa fil

@@ -18,87 +18,113 @@ import AVKit
18 18
 import CallKit
19 19
 import Foundation
20 20
 
21
-internal final class JMCallKitNotifier: NSObject, CXProviderDelegate {
22
-    
21
+internal final class JMCallKitEmitter: NSObject, CXProviderDelegate {
22
+
23 23
     private var listeners = Set<JMCallKitEventListenerWrapper>()
24
-    
24
+
25 25
     internal override init() {}
26
-    
26
+
27 27
     // MARK: - Add/remove listeners
28
-    
29
-    func addListener(_ listener: JMCallKitEventListener) {
28
+
29
+    func addListener(_ listener: JMCallKitListener) {
30 30
         let wrapper = JMCallKitEventListenerWrapper(listener: listener)
31 31
         objc_sync_enter(listeners)
32 32
         listeners.insert(wrapper)
33 33
         objc_sync_exit(listeners)
34 34
     }
35
-    
36
-    func removeListener(_ listener: JMCallKitEventListener) {
35
+
36
+    func removeListener(_ listener: JMCallKitListener) {
37 37
         let wrapper = JMCallKitEventListenerWrapper(listener: listener)
38 38
         objc_sync_enter(listeners)
39 39
         listeners.remove(wrapper)
40 40
         objc_sync_exit(listeners)
41 41
     }
42
-    
42
+
43 43
     // MARK: - CXProviderDelegate
44
-    
44
+
45 45
     func providerDidReset(_ provider: CXProvider) {
46 46
         objc_sync_enter(listeners)
47 47
         listeners.forEach { $0.listener?.providerDidReset?() }
48 48
         objc_sync_exit(listeners)
49 49
     }
50
-    
50
+
51 51
     func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
52 52
         objc_sync_enter(listeners)
53
-        listeners.forEach { $0.listener?.performAnswerCall?(UUID: action.callUUID) }
53
+        listeners.forEach {
54
+            $0.listener?.performAnswerCall?(UUID: action.callUUID)
55
+        }
54 56
         objc_sync_exit(listeners)
55
-        
57
+
56 58
         action.fulfill()
57 59
     }
58
-    
60
+
59 61
     func provider(_ provider: CXProvider, perform action: CXEndCallAction) {
60 62
         objc_sync_enter(listeners)
61
-        listeners.forEach { $0.listener?.performEndCall?(UUID: action.callUUID) }
63
+        listeners.forEach {
64
+            $0.listener?.performEndCall?(UUID: action.callUUID)
65
+        }
62 66
         objc_sync_exit(listeners)
63
-        
67
+
64 68
         action.fulfill()
65 69
     }
66
-    
70
+
67 71
     func provider(_ provider: CXProvider, perform action: CXSetMutedCallAction) {
68 72
         objc_sync_enter(listeners)
69 73
         listeners.forEach {
70 74
             $0.listener?.performSetMutedCall?(UUID: action.callUUID,
71
-                                             isMuted: action.isMuted)
75
+                                              isMuted: action.isMuted)
72 76
         }
73 77
         objc_sync_exit(listeners)
74
-        
78
+
75 79
         action.fulfill()
76 80
     }
77
-    
81
+
78 82
     func provider(_ provider: CXProvider, perform action: CXStartCallAction) {
79 83
         objc_sync_enter(listeners)
80 84
         listeners.forEach {
81 85
             $0.listener?.performStartCall?(UUID: action.callUUID,
82
-                                          isVideo: action.isVideo)
86
+                                           isVideo: action.isVideo)
83 87
         }
84 88
         objc_sync_exit(listeners)
85
-        
89
+
86 90
         action.fulfill()
87 91
     }
88
-    
89
-    func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
92
+
93
+    func provider(_ provider: CXProvider,
94
+                  didActivate audioSession: AVAudioSession) {
90 95
         objc_sync_enter(listeners)
91 96
         listeners.forEach {
92 97
             $0.listener?.providerDidActivateAudioSession?(session: audioSession)
93 98
         }
94 99
         objc_sync_exit(listeners)
95 100
     }
96
-    
97
-    func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {
101
+
102
+    func provider(_ provider: CXProvider,
103
+                  didDeactivate audioSession: AVAudioSession) {
98 104
         objc_sync_enter(listeners)
99 105
         listeners.forEach {
100
-            $0.listener?.providerDidDeactivateAudioSession?(session: audioSession)
106
+            $0.listener?.providerDidDeactivateAudioSession?(
107
+                session: audioSession)
101 108
         }
102 109
         objc_sync_exit(listeners)
103 110
     }
104 111
 }
112
+
113
+fileprivate struct JMCallKitEventListenerWrapper: Hashable {
114
+
115
+    public var hashValue: Int
116
+
117
+    internal weak var listener: JMCallKitListener?
118
+
119
+    public init(listener: JMCallKitListener) {
120
+        self.listener = listener
121
+        self.hashValue = listener.hash
122
+    }
123
+
124
+    public static func ==(lhs: JMCallKitEventListenerWrapper,
125
+                          rhs: JMCallKitEventListenerWrapper) -> Bool {
126
+        // XXX We're aware that "[t]wo instances with equal hash values are not
127
+        // necessarily equal to each other."
128
+        return lhs.hashValue == rhs.hashValue
129
+    }
130
+}

ios/sdk/src/callkit/JMCallKitEventListener.swift → ios/sdk/src/callkit/JMCallKitListener.swift Visa fil

@@ -18,46 +18,29 @@ import AVKit
18 18
 import CallKit
19 19
 import Foundation
20 20
 
21
-@objc public protocol JMCallKitEventListener: NSObjectProtocol {
22
-    
21
+@objc public protocol JMCallKitListener: NSObjectProtocol {
22
+
23 23
     @available(iOS 10.0, *)
24 24
     @objc optional func providerDidReset()
25
-    
25
+
26 26
     @available(iOS 10.0, *)
27 27
     @objc optional func performAnswerCall(UUID: UUID)
28
-    
28
+
29 29
     @available(iOS 10.0, *)
30 30
     @objc optional func performEndCall(UUID: UUID)
31
-    
31
+
32 32
     @available(iOS 10.0, *)
33 33
     @objc optional func performSetMutedCall(UUID: UUID, isMuted: Bool)
34
-    
34
+
35 35
     @available(iOS 10.0, *)
36 36
     @objc optional func performStartCall(UUID: UUID, isVideo: Bool)
37
-    
37
+
38 38
     @available(iOS 10.0, *)
39 39
     @objc optional func providerDidActivateAudioSession(session: AVAudioSession)
40
-    
40
+
41 41
     @available(iOS 10.0, *)
42 42
     @objc optional func providerDidDeactivateAudioSession(session: AVAudioSession)
43
-    
43
+
44 44
     @available(iOS 10.0, *)
45 45
     @objc optional func providerTimedOutPerformingAction(action: CXAction)
46 46
 }
47
-
48
-internal struct JMCallKitEventListenerWrapper: Hashable {
49
-    
50
-    public var hashValue: Int
51
-    
52
-    internal weak var listener: JMCallKitEventListener?
53
-    
54
-    public init(listener: JMCallKitEventListener) {
55
-        self.listener = listener
56
-        self.hashValue = listener.hash
57
-    }
58
-    
59
-    public static func ==(lhs: JMCallKitEventListenerWrapper,
60
-                          rhs: JMCallKitEventListenerWrapper) -> Bool {
61
-        return lhs.hashValue == rhs.hashValue
62
-    }
63
-}

+ 93
- 90
ios/sdk/src/callkit/JMCallKitProxy.swift Visa fil

@@ -20,138 +20,142 @@ import Foundation
20 20
 /// JitsiMeet CallKit proxy
21 21
 @available(iOS 10.0, *)
22 22
 @objc public final class JMCallKitProxy: NSObject {
23
-    
24
-    override private init() {}
25
-    
23
+
24
+    private override init() {}
25
+
26 26
     // MARK: - CallKit proxy
27
-    
28
-    internal static let cxProvider: CXProvider = {
29
-        let config = CXProviderConfiguration(localizedName: "")
30
-        let provider = CXProvider(configuration: config)
31
-        return provider
32
-    }()
33
-    
34
-    internal static let cxCallController: CXCallController = {
35
-        return CXCallController()
36
-    }()
37
-    
38
-    internal static let callKitNotifier: JMCallKitNotifier = {
39
-        return JMCallKitNotifier()
27
+
28
+    private static let provider: CXProvider = {
29
+        let configuration = CXProviderConfiguration(localizedName: "")
30
+        return CXProvider(configuration: configuration)
40 31
     }()
41
-    
42
-    internal static var cxProviderConfiguration: CXProviderConfiguration? {
32
+
33
+    private static var providerConfiguration: CXProviderConfiguration? {
43 34
         didSet {
44
-            guard let providerConfiguration = cxProviderConfiguration else { return }
45
-            cxProvider.configuration = providerConfiguration
46
-            cxProvider.setDelegate(callKitNotifier, queue: nil)
35
+            guard let configuration = providerConfiguration else { return }
36
+            provider.configuration = configuration
37
+            provider.setDelegate(emitter, queue: nil)
47 38
         }
48 39
     }
49
-    
50
-    /// Enables the proxy in between callkit and the consumers of the SDK
51
-    /// Default to enabled, set to false when you don't want to use callkit
40
+
41
+    private static let callController: CXCallController = {
42
+        return CXCallController()
43
+    }()
44
+
45
+    private static let emitter: JMCallKitEmitter = {
46
+        return JMCallKitEmitter()
47
+    }()
48
+
49
+    /// Enables the proxy in between CallKit and the consumers of the SDK.
50
+    /// Defaults to enabled, set to false when you don't want to use CallKit.
52 51
     @objc public static var enabled: Bool = true {
53 52
         didSet {
54 53
             if enabled == false {
55
-                cxProvider.setDelegate(nil, queue: nil)
54
+                provider.setDelegate(nil, queue: nil)
56 55
             }
57 56
         }
58 57
     }
59
-    
60
-    @objc public static func hasProviderBeenConfigurated() -> Bool {
61
-        return cxProviderConfiguration != nil
62
-    }
63
-        
64
-    @objc public static func configureCallKitProvider(localizedName: String,
65
-                                                      ringtoneSound: String?,
66
-                                                      iconTemplateImageData: Data?) {
58
+
59
+    @objc public static func configureProvider(localizedName: String,
60
+                                               ringtoneSound: String?,
61
+                                               iconTemplateImageData: Data?) {
67 62
         let configuration = CXProviderConfiguration(localizedName: localizedName)
68
-        configuration.ringtoneSound = ringtoneSound
69 63
         configuration.iconTemplateImageData = iconTemplateImageData
70
-        
71 64
         configuration.maximumCallGroups = 1
72 65
         configuration.maximumCallsPerCallGroup = 1
66
+        configuration.ringtoneSound = ringtoneSound
73 67
         configuration.supportedHandleTypes = [CXHandle.HandleType.generic]
74 68
         configuration.supportsVideo = true
75
-        cxProviderConfiguration = configuration
69
+
70
+        providerConfiguration = configuration
76 71
     }
77
-    
78
-    @objc public static func addListener(_ listener: JMCallKitEventListener) {
79
-        callKitNotifier.addListener(listener)
72
+
73
+    @objc public static func isProviderConfigured() -> Bool {
74
+        return providerConfiguration != nil
80 75
     }
81
-    
82
-    @objc public static func removeListener(_ listener: JMCallKitEventListener) {
83
-        callKitNotifier.removeListener(listener)
76
+
77
+    @objc public static func addListener(_ listener: JMCallKitListener) {
78
+        emitter.addListener(listener)
84 79
     }
85
-    
80
+
81
+    @objc public static func removeListener(_ listener: JMCallKitListener) {
82
+        emitter.removeListener(listener)
83
+    }
84
+
86 85
     @objc public static func hasActiveCallForUUID(_ callUUID: String) -> Bool {
87
-        let activeCallForUUID = cxCallController.callObserver.calls.first {
86
+        let activeCallForUUID = callController.callObserver.calls.first {
88 87
             $0.uuid == UUID(uuidString: callUUID)
89 88
         }
90 89
         guard activeCallForUUID != nil else { return false }
91 90
         return true
92 91
     }
93
-    
94
-    @objc public static func reportNewIncomingCall(UUID: UUID,
95
-                                             handle: String?,
96
-                                             displayName: String?,
97
-                                             hasVideo: Bool,
98
-                                             completion: @escaping (Error?) -> Void) {
92
+
93
+    @objc public static func reportNewIncomingCall(
94
+            UUID: UUID,
95
+            handle: String?,
96
+            displayName: String?,
97
+            hasVideo: Bool,
98
+            completion: @escaping (Error?) -> Void) {
99 99
         guard enabled else { return }
100
-        
100
+
101 101
         let callUpdate = makeCXUpdate(handle: handle,
102 102
                                       displayName: displayName,
103 103
                                       hasVideo: hasVideo)
104
-        cxProvider.reportNewIncomingCall(with: UUID,
105
-                                         update: callUpdate,
106
-                                         completion: completion)
104
+        provider.reportNewIncomingCall(with: UUID,
105
+                                       update: callUpdate,
106
+                                       completion: completion)
107 107
     }
108
-    
108
+
109 109
     @objc public static func reportCallUpdate(with UUID: UUID,
110
-                                        handle: String?,
111
-                                        displayName: String?,
112
-                                        hasVideo: Bool) {
110
+                                              handle: String?,
111
+                                              displayName: String?,
112
+                                              hasVideo: Bool) {
113 113
         guard enabled else { return }
114
-        
114
+
115 115
         let callUpdate = makeCXUpdate(handle: handle,
116 116
                                       displayName: displayName,
117 117
                                       hasVideo: hasVideo)
118
-        cxProvider.reportCall(with: UUID, updated: callUpdate)
118
+        provider.reportCall(with: UUID, updated: callUpdate)
119 119
     }
120
-    
121
-    @objc public static func reportCall(with UUID: UUID,
122
-                           endedAt dateEnded: Date?,
123
-                           reason endedReason: CXCallEndedReason) {
120
+
121
+    @objc public static func reportCall(
122
+            with UUID: UUID,
123
+            endedAt dateEnded: Date?,
124
+            reason endedReason: CXCallEndedReason) {
124 125
         guard enabled else { return }
125
-        
126
-        cxProvider.reportCall(with: UUID,
127
-                              endedAt: dateEnded,
128
-                              reason: endedReason)
126
+
127
+        provider.reportCall(with: UUID,
128
+                            endedAt: dateEnded,
129
+                            reason: endedReason)
129 130
     }
130
-    
131
-    @objc public static func reportOutgoingCall(with UUID: UUID,
132
-          startedConnectingAt dateStartedConnecting: Date?) {
131
+
132
+    @objc public static func reportOutgoingCall(
133
+            with UUID: UUID,
134
+            startedConnectingAt dateStartedConnecting: Date?) {
133 135
         guard enabled else { return }
134
-        
135
-        cxProvider.reportOutgoingCall(with: UUID,
136
-                                      startedConnectingAt: dateStartedConnecting)
136
+
137
+        provider.reportOutgoingCall(with: UUID,
138
+                                    startedConnectingAt: dateStartedConnecting)
137 139
     }
138
-    
139
-    @objc public static func reportOutgoingCall(with UUID: UUID,
140
-                                          connectedAt dateConnected: Date?) {
140
+
141
+    @objc public static func reportOutgoingCall(
142
+            with UUID: UUID,
143
+            connectedAt dateConnected: Date?) {
141 144
         guard enabled else { return }
142
-        
143
-        cxProvider.reportOutgoingCall(with: UUID, connectedAt: dateConnected)
145
+
146
+        provider.reportOutgoingCall(with: UUID, connectedAt: dateConnected)
144 147
     }
145
-    
146
-    @objc public static func request(_ transaction: CXTransaction,
147
-                                completion: @escaping (Error?) -> Swift.Void) {
148
+
149
+    @objc public static func request(
150
+            _ transaction: CXTransaction,
151
+            completion: @escaping (Error?) -> Swift.Void) {
148 152
         guard enabled else { return }
149
-        
150
-        cxCallController.request(transaction, completion: completion)
153
+
154
+        callController.request(transaction, completion: completion)
151 155
     }
152
-    
156
+
153 157
     // MARK: - Callkit Proxy helpers
154
-    
158
+
155 159
     private static func makeCXUpdate(handle: String?,
156 160
                                      displayName: String?,
157 161
                                      hasVideo: Bool) -> CXCallUpdate {
@@ -161,17 +165,16 @@ import Foundation
161 165
         update.supportsGrouping = false
162 166
         update.supportsUngrouping = false
163 167
         update.hasVideo = hasVideo
164
-        
168
+
165 169
         if let handle = handle {
166 170
             update.remoteHandle = CXHandle(type: .generic,
167 171
                                            value: handle)
168 172
         }
169
-        
173
+
170 174
         if let displayName = displayName {
171 175
             update.localizedCallerName = displayName
172 176
         }
173
-        
177
+
174 178
         return update
175 179
     }
176
-
177 180
 }

+ 20
- 20
ios/sdk/src/picture-in-picture/DragGestureController.swift Visa fil

@@ -15,48 +15,48 @@
15 15
  */
16 16
 
17 17
 final class DragGestureController {
18
-    
18
+
19 19
     var insets: UIEdgeInsets = UIEdgeInsets.zero
20
-    
20
+
21 21
     private var frameBeforeDragging: CGRect = CGRect.zero
22 22
     private weak var view: UIView?
23 23
     private lazy var panGesture: UIPanGestureRecognizer = {
24 24
         return UIPanGestureRecognizer(target: self,
25 25
                                       action: #selector(handlePan(gesture:)))
26 26
     }()
27
-    
27
+
28 28
     func startDragListener(inView view: UIView) {
29 29
         self.view = view
30 30
         view.addGestureRecognizer(panGesture)
31 31
         panGesture.isEnabled = true
32 32
     }
33
-    
33
+
34 34
     func stopDragListener() {
35 35
         panGesture.isEnabled = false
36 36
         view?.removeGestureRecognizer(panGesture)
37 37
         view = nil
38 38
     }
39
-    
39
+
40 40
     @objc private func handlePan(gesture: UIPanGestureRecognizer) {
41 41
         guard let view = self.view else { return }
42
-        
42
+
43 43
         let translation = gesture.translation(in: view.superview)
44 44
         let velocity = gesture.velocity(in: view.superview)
45 45
         var frame = frameBeforeDragging
46
-        
46
+
47 47
         switch gesture.state {
48 48
         case .began:
49 49
             frameBeforeDragging = view.frame
50
-            
50
+
51 51
         case .changed:
52 52
             frame.origin.x = floor(frame.origin.x + translation.x)
53 53
             frame.origin.y = floor(frame.origin.y + translation.y)
54 54
             view.frame = frame
55
-            
55
+
56 56
         case .ended:
57 57
             let currentPos = view.frame.origin
58 58
             let finalPos = calculateFinalPosition()
59
-            
59
+
60 60
             let distance = CGPoint(x: currentPos.x - finalPos.x,
61 61
                                    y: currentPos.y - finalPos.y)
62 62
             let distanceMagnitude = magnitude(vector: distance)
@@ -64,9 +64,9 @@ final class DragGestureController {
64 64
             let animationDuration = 0.5
65 65
             let initialSpringVelocity =
66 66
                 velocityMagnitude / distanceMagnitude / CGFloat(animationDuration)
67
-            
67
+
68 68
             frame.origin = CGPoint(x: finalPos.x, y: finalPos.y)
69
-            
69
+
70 70
             UIView.animate(withDuration: animationDuration,
71 71
                            delay: 0,
72 72
                            usingSpringWithDamping: 0.9,
@@ -75,38 +75,38 @@ final class DragGestureController {
75 75
                            animations: {
76 76
                             view.frame = frame
77 77
             }, completion: nil)
78
-            
78
+
79 79
         default:
80 80
             break
81 81
         }
82 82
     }
83
-    
83
+
84 84
     private func calculateFinalPosition() -> CGPoint {
85 85
         guard
86 86
             let view = self.view,
87 87
             let bounds = view.superview?.frame
88 88
             else { return CGPoint.zero }
89
-        
89
+
90 90
         let currentSize = view.frame.size
91 91
         let adjustedBounds = UIEdgeInsetsInsetRect(bounds, insets)
92 92
         let threshold: CGFloat = 20.0
93 93
         let velocity = panGesture.velocity(in: view.superview)
94 94
         let location = panGesture.location(in: view.superview)
95
-        
95
+
96 96
         let goLeft: Bool
97 97
         if fabs(velocity.x) > threshold {
98 98
             goLeft = velocity.x < -threshold
99 99
         } else {
100 100
             goLeft = location.x < bounds.midX
101 101
         }
102
-        
102
+
103 103
         let goUp: Bool
104 104
         if fabs(velocity.y) > threshold {
105 105
             goUp = velocity.y < -threshold
106 106
         } else {
107 107
             goUp = location.y < bounds.midY
108 108
         }
109
-        
109
+
110 110
         let finalPosX: CGFloat =
111 111
             goLeft
112 112
                 ? adjustedBounds.origin.x
@@ -115,10 +115,10 @@ final class DragGestureController {
115 115
             goUp
116 116
                 ? adjustedBounds.origin.y
117 117
                 : bounds.size.height - insets.bottom - currentSize.height
118
-        
118
+
119 119
         return CGPoint(x: finalPosX, y: finalPosY)
120 120
     }
121
-    
121
+
122 122
     private func magnitude(vector: CGPoint) -> CGFloat {
123 123
         return sqrt(pow(vector.x, 2) + pow(vector.y, 2))
124 124
     }

+ 31
- 31
ios/sdk/src/picture-in-picture/PiPViewCoordinator.swift Visa fil

@@ -21,7 +21,7 @@ public typealias AnimationCompletion = (Bool) -> Void
21 21
 /// This object will also provide the drag and tap interactions of the view
22 22
 /// when is presented in Picure in Picture mode.
23 23
 public class PiPViewCoordinator {
24
-    
24
+
25 25
     /// Limits the boundries of view position on screen when minimized
26 26
     public var dragBoundInsets: UIEdgeInsets = UIEdgeInsets(top: 25,
27 27
                                                             left: 5,
@@ -31,7 +31,7 @@ public class PiPViewCoordinator {
31 31
             dragController.insets = dragBoundInsets
32 32
         }
33 33
     }
34
-    
34
+
35 35
     /// The size ratio of the view when in PiP mode
36 36
     public var pipSizeRatio: CGFloat = {
37 37
         let deviceIdiom = UIScreen.main.traitCollection.userInterfaceIdiom
@@ -44,21 +44,21 @@ public class PiPViewCoordinator {
44 44
             return 0.25
45 45
         }
46 46
     }()
47
-    
47
+
48 48
     private(set) var isInPiP: Bool = false // true if view is in PiP mode
49
-    
49
+
50 50
     private(set) var view: UIView
51 51
     private var currentBounds: CGRect = CGRect.zero
52
-    
52
+
53 53
     private var tapGestureRecognizer: UITapGestureRecognizer?
54 54
     private var exitPiPButton: UIButton?
55
-    
55
+
56 56
     private let dragController: DragGestureController = DragGestureController()
57
-    
57
+
58 58
     public init(withView view: UIView) {
59 59
         self.view = view
60 60
     }
61
-    
61
+
62 62
     /// Configure the view to be always on top of all the contents
63 63
     /// of the provided parent view.
64 64
     /// If a parentView is not provided it will try to use the main window
@@ -66,25 +66,25 @@ public class PiPViewCoordinator {
66 66
         guard
67 67
             let parentView = parentView ?? UIApplication.shared.keyWindow
68 68
             else { return }
69
-        
69
+
70 70
         parentView.addSubview(view)
71 71
         currentBounds = parentView.bounds
72 72
         view.frame = currentBounds
73 73
         view.layer.zPosition = CGFloat(Float.greatestFiniteMagnitude)
74 74
     }
75
-    
75
+
76 76
     /// Show view with fade in animation
77 77
     public func show(completion: AnimationCompletion? = nil) {
78 78
         if view.isHidden || view.alpha < 1 {
79 79
             view.isHidden = false
80 80
             view.alpha = 0
81
-            
81
+
82 82
             animateTransition(animations: { [weak self] in
83 83
                 self?.view.alpha = 1
84 84
             }, completion: completion)
85 85
         }
86 86
     }
87
-    
87
+
88 88
     /// Hide view with fade out animation
89 89
     public func hide(completion: AnimationCompletion? = nil) {
90 90
         if view.isHidden || view.alpha > 0 {
@@ -94,7 +94,7 @@ public class PiPViewCoordinator {
94 94
             }, completion: completion)
95 95
         }
96 96
     }
97
-    
97
+
98 98
     /// Resize view to and change state to custom PictureInPicture mode
99 99
     /// This will resize view, add a  gesture to enable user to "drag" view
100 100
     /// around screen, and add a button of top of the view to be able to exit mode
@@ -103,7 +103,7 @@ public class PiPViewCoordinator {
103 103
         animateViewChange()
104 104
         dragController.startDragListener(inView: view)
105 105
         dragController.insets = dragBoundInsets
106
-        
106
+
107 107
         // add single tap gesture recognition for displaying exit PiP UI
108 108
         let exitSelector = #selector(toggleExitPiP)
109 109
         let tapGestureRecognizer = UITapGestureRecognizer(target: self,
@@ -111,36 +111,36 @@ public class PiPViewCoordinator {
111 111
         self.tapGestureRecognizer = tapGestureRecognizer
112 112
         view.addGestureRecognizer(tapGestureRecognizer)
113 113
     }
114
-    
114
+
115 115
     /// Exit Picture in picture mode, this will resize view, remove
116 116
     /// exit pip button, and disable the drag gesture
117 117
     @objc public func exitPictureInPicture() {
118 118
         isInPiP = false
119 119
         animateViewChange()
120 120
         dragController.stopDragListener()
121
-        
121
+
122 122
         // hide PiP UI
123 123
         exitPiPButton?.removeFromSuperview()
124 124
         exitPiPButton = nil
125
-        
125
+
126 126
         // remove gesture
127 127
         let exitSelector = #selector(toggleExitPiP)
128 128
         tapGestureRecognizer?.removeTarget(self, action: exitSelector)
129 129
         tapGestureRecognizer = nil
130 130
     }
131
-    
131
+
132 132
     /// Reset view to provide bounds, use this method on rotation or
133 133
     /// screen size changes
134 134
     public func resetBounds(bounds: CGRect) {
135 135
         currentBounds = bounds
136 136
         exitPictureInPicture()
137 137
     }
138
-    
138
+
139 139
     /// Stop the dragging gesture of the root view
140 140
     public func stopDragGesture() {
141 141
         dragController.stopDragListener()
142 142
     }
143
-    
143
+
144 144
     /// Customize the presentation of exit pip button
145 145
     open func configureExitPiPButton(target: Any,
146 146
                                      action: Selector) -> UIButton {
@@ -157,9 +157,9 @@ public class PiPViewCoordinator {
157 157
         button.addTarget(target, action: action, for: .touchUpInside)
158 158
         return button
159 159
     }
160
-    
160
+
161 161
     // MARK: - Interactions
162
-    
162
+
163 163
     @objc private func toggleExitPiP() {
164 164
         if exitPiPButton == nil {
165 165
             // show button
@@ -168,30 +168,30 @@ public class PiPViewCoordinator {
168 168
                                                 action: exitSelector)
169 169
             view.addSubview(button)
170 170
             exitPiPButton = button
171
-            
171
+
172 172
         } else {
173 173
             // hide button
174 174
             exitPiPButton?.removeFromSuperview()
175 175
             exitPiPButton = nil
176 176
         }
177 177
     }
178
-    
178
+
179 179
     // MARK: - Size calculation
180
-    
180
+
181 181
     private func animateViewChange() {
182 182
         UIView.animate(withDuration: 0.25) {
183 183
             self.view.frame = self.changeViewRect()
184 184
             self.view.setNeedsLayout()
185 185
         }
186 186
     }
187
-    
187
+
188 188
     private func changeViewRect() -> CGRect {
189 189
         let bounds = currentBounds
190
-        
190
+
191 191
         guard isInPiP else {
192 192
             return bounds
193 193
         }
194
-        
194
+
195 195
         // resize to suggested ratio and position to the bottom right
196 196
         let adjustedBounds = UIEdgeInsetsInsetRect(bounds, dragBoundInsets)
197 197
         let size = CGSize(width: bounds.size.width * pipSizeRatio,
@@ -200,9 +200,9 @@ public class PiPViewCoordinator {
200 200
         let y: CGFloat = adjustedBounds.maxY - size.height
201 201
         return CGRect(x: x, y: y, width: size.width, height: size.height)
202 202
     }
203
-    
203
+
204 204
     // MARK: - Animation helpers
205
-    
205
+
206 206
     private func animateTransition(animations: @escaping () -> Void,
207 207
                                    completion: AnimationCompletion?) {
208 208
         UIView.animate(withDuration: 0.1,
@@ -211,5 +211,5 @@ public class PiPViewCoordinator {
211 211
                        animations: animations,
212 212
                        completion: completion)
213 213
     }
214
-    
214
+
215 215
 }

+ 49
- 54
react/features/mobile/callkit/middleware.js Visa fil

@@ -2,10 +2,7 @@
2 2
 
3 3
 import uuid from 'uuid';
4 4
 
5
-import {
6
-    createTrackMutedEvent,
7
-    sendAnalytics
8
-} from '../../analytics';
5
+import { createTrackMutedEvent, sendAnalytics } from '../../analytics';
9 6
 import {
10 7
     APP_WILL_MOUNT,
11 8
     APP_WILL_UNMOUNT,
@@ -29,16 +26,13 @@ import {
29 26
     setAudioMuted
30 27
 } from '../../base/media';
31 28
 import { MiddlewareRegistry } from '../../base/redux';
32
-import {
33
-    TRACK_CREATE_ERROR,
34
-    isLocalTrackMuted
35
-} from '../../base/tracks';
29
+import { TRACK_CREATE_ERROR, isLocalTrackMuted } from '../../base/tracks';
36 30
 
37 31
 import { _SET_CALLKIT_SUBSCRIPTIONS } from './actionTypes';
38 32
 import CallKit from './CallKit';
39 33
 
40 34
 /**
41
- * Middleware that captures several system actions and hooks up CallKit.
35
+ * Middleware that captures system actions and hooks up CallKit.
42 36
  *
43 37
  * @param {Store} store - The redux store.
44 38
  * @returns {Function}
@@ -84,17 +78,17 @@ CallKit && MiddlewareRegistry.register(store => next => action => {
84 78
 });
85 79
 
86 80
 /**
87
- * Notifies the feature jwt that the action {@link APP_WILL_MOUNT} is being
81
+ * Notifies the feature callkit that the action {@link APP_WILL_MOUNT} is being
88 82
  * dispatched within a specific redux {@code store}.
89 83
  *
90 84
  * @param {Store} store - The redux store in which the specified {@code action}
91 85
  * is being dispatched.
92
- * @param {Dispatch} next - The redux dispatch function to dispatch the
93
- * specified {@code action} to the specified {@code store}.
86
+ * @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
87
+ * specified {@code action} in the specified {@code store}.
94 88
  * @param {Action} action - The redux action {@code APP_WILL_MOUNT} which is
95 89
  * being dispatched in the specified {@code store}.
96 90
  * @private
97
- * @returns {*}
91
+ * @returns {*} The value returned by {@code next(action)}.
98 92
  */
99 93
 function _appWillMount({ dispatch, getState }, next, action) {
100 94
     const result = next(action);
@@ -119,8 +113,8 @@ function _appWillMount({ dispatch, getState }, next, action) {
119 113
             context),
120 114
 
121 115
         // According to CallKit's documentation, when the system resets we
122
-        // should terminate all calls. Hence, providerDidReset is the same
123
-        // to us as performEndCallAction.
116
+        // should terminate all calls. Hence, providerDidReset is the same to us
117
+        // as performEndCallAction.
124 118
         CallKit.addListener(
125 119
             'providerDidReset',
126 120
             _onPerformEndCallAction,
@@ -136,17 +130,17 @@ function _appWillMount({ dispatch, getState }, next, action) {
136 130
 }
137 131
 
138 132
 /**
139
- * Notifies the feature jwt that the action {@link CONFERENCE_FAILED} is being
140
- * dispatched within a specific redux {@code store}.
133
+ * Notifies the feature callkit that the action {@link CONFERENCE_FAILED} is
134
+ * being dispatched within a specific redux {@code store}.
141 135
  *
142 136
  * @param {Store} store - The redux store in which the specified {@code action}
143 137
  * is being dispatched.
144
- * @param {Dispatch} next - The redux dispatch function to dispatch the
145
- * specified {@code action} to the specified {@code store}.
138
+ * @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
139
+ * specified {@code action} in the specified {@code store}.
146 140
  * @param {Action} action - The redux action {@code CONFERENCE_FAILED} which is
147 141
  * being dispatched in the specified {@code store}.
148 142
  * @private
149
- * @returns {*}
143
+ * @returns {*} The value returned by {@code next(action)}.
150 144
  */
151 145
 function _conferenceFailed(store, next, action) {
152 146
     const result = next(action);
@@ -166,17 +160,17 @@ function _conferenceFailed(store, next, action) {
166 160
 }
167 161
 
168 162
 /**
169
- * Notifies the feature jwt that the action {@link CONFERENCE_JOINED} is being
170
- * dispatched within a specific redux {@code store}.
163
+ * Notifies the feature callkit that the action {@link CONFERENCE_JOINED} is
164
+ * being dispatched within a specific redux {@code store}.
171 165
  *
172 166
  * @param {Store} store - The redux store in which the specified {@code action}
173 167
  * is being dispatched.
174
- * @param {Dispatch} next - The redux dispatch function to dispatch the
175
- * specified {@code action} to the specified {@code store}.
168
+ * @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
169
+ * specified {@code action} in the specified {@code store}.
176 170
  * @param {Action} action - The redux action {@code CONFERENCE_JOINED} which is
177 171
  * being dispatched in the specified {@code store}.
178 172
  * @private
179
- * @returns {*}
173
+ * @returns {*} The value returned by {@code next(action)}.
180 174
  */
181 175
 function _conferenceJoined(store, next, action) {
182 176
     const result = next(action);
@@ -191,17 +185,17 @@ function _conferenceJoined(store, next, action) {
191 185
 }
192 186
 
193 187
 /**
194
- * Notifies the feature jwt that the action {@link CONFERENCE_LEFT} is being
188
+ * Notifies the feature callkit that the action {@link CONFERENCE_LEFT} is being
195 189
  * dispatched within a specific redux {@code store}.
196 190
  *
197 191
  * @param {Store} store - The redux store in which the specified {@code action}
198 192
  * is being dispatched.
199
- * @param {Dispatch} next - The redux dispatch function to dispatch the
200
- * specified {@code action} to the specified {@code store}.
193
+ * @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
194
+ * specified {@code action} in the specified {@code store}.
201 195
  * @param {Action} action - The redux action {@code CONFERENCE_LEFT} which is
202 196
  * being dispatched in the specified {@code store}.
203 197
  * @private
204
- * @returns {*}
198
+ * @returns {*} The value returned by {@code next(action)}.
205 199
  */
206 200
 function _conferenceLeft(store, next, action) {
207 201
     const result = next(action);
@@ -216,29 +210,29 @@ function _conferenceLeft(store, next, action) {
216 210
 }
217 211
 
218 212
 /**
219
- * Notifies the feature jwt that the action {@link CONFERENCE_WILL_JOIN} is
213
+ * Notifies the feature callkit that the action {@link CONFERENCE_WILL_JOIN} is
220 214
  * being dispatched within a specific redux {@code store}.
221 215
  *
222 216
  * @param {Store} store - The redux store in which the specified {@code action}
223 217
  * is being dispatched.
224
- * @param {Dispatch} next - The redux dispatch function to dispatch the
225
- * specified {@code action} to the specified {@code store}.
218
+ * @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
219
+ * specified {@code action} in the specified {@code store}.
226 220
  * @param {Action} action - The redux action {@code CONFERENCE_WILL_JOIN} which
227 221
  * is being dispatched in the specified {@code store}.
228 222
  * @private
229
- * @returns {*}
223
+ * @returns {*} The value returned by {@code next(action)}.
230 224
  */
231 225
 function _conferenceWillJoin({ getState }, next, action) {
232 226
     const result = next(action);
233 227
 
234 228
     const { conference } = action;
235 229
     const state = getState();
230
+    const { callUUID } = state['features/base/config'];
236 231
     const url = getInviteURL(state);
237 232
     const hasVideo = !isVideoMutedByAudioOnly(state);
238
-    const { callUUID } = state['features/base/config'];
239 233
 
240
-    // When assigning the call UUID, do so in upper case, since iOS will
241
-    // return it upper cased.
234
+    // When assigning the call UUID, do so in upper case, since iOS will return
235
+    // it upper cased.
242 236
     conference.callUUID = (callUUID || uuid.v4()).toUpperCase();
243 237
 
244 238
     CallKit.startCall(conference.callUUID, url.toString(), hasVideo)
@@ -306,17 +300,17 @@ function _onPerformSetMutedCallAction({ callUUID, muted: newValue }) {
306 300
 }
307 301
 
308 302
 /**
309
- * Notifies the feature jwt that the action {@link SET_AUDIO_MUTED} is being
303
+ * Notifies the feature callkit that the action {@link SET_AUDIO_MUTED} is being
310 304
  * dispatched within a specific redux {@code store}.
311 305
  *
312 306
  * @param {Store} store - The redux store in which the specified {@code action}
313 307
  * is being dispatched.
314
- * @param {Dispatch} next - The redux dispatch function to dispatch the
315
- * specified {@code action} to the specified {@code store}.
308
+ * @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
309
+ * specified {@code action} in the specified {@code store}.
316 310
  * @param {Action} action - The redux action {@code SET_AUDIO_MUTED} which is
317 311
  * being dispatched in the specified {@code store}.
318 312
  * @private
319
- * @returns {*}
313
+ * @returns {*} The value returned by {@code next(action)}.
320 314
  */
321 315
 function _setAudioMuted({ getState }, next, action) {
322 316
     const result = next(action);
@@ -331,17 +325,18 @@ function _setAudioMuted({ getState }, next, action) {
331 325
 }
332 326
 
333 327
 /**
334
- * Notifies the feature jwt that the action {@link _SET_CALLKIT_SUBSCRIPTIONS}
335
- * is being dispatched within a specific redux {@code store}.
328
+ * Notifies the feature callkit that the action
329
+ * {@link _SET_CALLKIT_SUBSCRIPTIONS} is being dispatched within a specific
330
+ * redux {@code store}.
336 331
  *
337 332
  * @param {Store} store - The redux store in which the specified {@code action}
338 333
  * is being dispatched.
339
- * @param {Dispatch} next - The redux dispatch function to dispatch the
340
- * specified {@code action} to the specified {@code store}.
334
+ * @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
335
+ * specified {@code action} in the specified {@code store}.
341 336
  * @param {Action} action - The redux action {@code _SET_CALLKIT_SUBSCRIPTIONS}
342 337
  * which is being dispatched in the specified {@code store}.
343 338
  * @private
344
- * @returns {*}
339
+ * @returns {*} The value returned by {@code next(action)}.
345 340
  */
346 341
 function _setCallKitSubscriptions({ getState }, next, action) {
347 342
     const { subscriptions } = getState()['features/callkit'];
@@ -356,17 +351,17 @@ function _setCallKitSubscriptions({ getState }, next, action) {
356 351
 }
357 352
 
358 353
 /**
359
- * Notifies the feature jwt that the action {@link SET_VIDEO_MUTED} is being
354
+ * Notifies the feature callkit that the action {@link SET_VIDEO_MUTED} is being
360 355
  * dispatched within a specific redux {@code store}.
361 356
  *
362 357
  * @param {Store} store - The redux store in which the specified {@code action}
363 358
  * is being dispatched.
364
- * @param {Dispatch} next - The redux dispatch function to dispatch the
365
- * specified {@code action} to the specified {@code store}.
359
+ * @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
360
+ * specified {@code action} in the specified {@code store}.
366 361
  * @param {Action} action - The redux action {@code SET_VIDEO_MUTED} which is
367 362
  * being dispatched in the specified {@code store}.
368 363
  * @private
369
- * @returns {*}
364
+ * @returns {*} The value returned by {@code next(action)}.
370 365
  */
371 366
 function _setVideoMuted({ getState }, next, action) {
372 367
     const result = next(action);
@@ -385,17 +380,17 @@ function _setVideoMuted({ getState }, next, action) {
385 380
 /**
386 381
  * Handles a track creation failure. This is relevant to us in the following
387 382
  * (corner) case: if the user never gave their permission to use the microphone
388
- * and try to unmute from the CallKit interface, this will fail, and we need
389
- * to sync back the CallKit button state.
383
+ * and try to unmute from the CallKit interface, this will fail, and we need to
384
+ * sync back the CallKit button state.
390 385
  *
391 386
  * @param {Store} store - The redux store in which the specified {@code action}
392 387
  * is being dispatched.
393
- * @param {Dispatch} next - The redux dispatch function to dispatch the
394
- * specified {@code action} to the specified {@code store}.
388
+ * @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
389
+ * specified {@code action} in the specified {@code store}.
395 390
  * @param {Action} action - The redux action {@code TRACK_CREARE_ERROR} which is
396 391
  * being dispatched in the specified {@code store}.
397 392
  * @private
398
- * @returns {*}
393
+ * @returns {*} The value returned by {@code next(action)}.
399 394
  */
400 395
 function _trackCreateError({ getState }, next, action) {
401 396
     const result = next(action);

Laddar…
Avbryt
Spara