Skip to content

Commit

Permalink
screenSharing minor bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirBrejcha committed Jun 5, 2020
1 parent 193d35a commit faa991b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion ScreenSharing/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSCameraUsageDescription</key>
Expand Down
12 changes: 4 additions & 8 deletions ScreenSharing/Stories/Main/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ final class MainViewController:
guard let self = self else { return }
do {
try self.callManager.makeOutgoingCall(to: username ?? "")
DispatchQueue.main.async {
self.view.endEditing(true)
self.present(self.storyAssembler.call, animated: true)
}
self.view.endEditing(true)
self.present(self.storyAssembler.call, animated: true)
} catch (let error) {
Log.e(error.localizedDescription)
AlertHelper.showError(message: error.localizedDescription, on: self)
Expand Down Expand Up @@ -68,10 +66,8 @@ final class MainViewController:
callManager.didReceiveIncomingCall = { [weak self] in
guard let self = self else { return }

DispatchQueue.main.async {
self.view.endEditing(true)
self.present(self.storyAssembler.incomingCall, animated: true)
}
self.view.endEditing(true)
self.present(self.storyAssembler.incomingCall, animated: true)
}
}

Expand Down
18 changes: 14 additions & 4 deletions Shared/PermissionsHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import AVFoundation
final class PermissionsHelper {
static func requestRecordPermissions(
includingVideo video: Bool,
accessRequestCompletionQueue: DispatchQueue = .main,
completion: @escaping (Error?) -> Void
) {
requestPermissions(for: .audio) { granted in
requestPermissions(for: .audio, queue: accessRequestCompletionQueue) { granted in
if granted {
if video {
requestPermissions(for: .video) { granted in
requestPermissions(for: .video, queue: accessRequestCompletionQueue) { granted in
completion(granted ? nil : PermissionError.videoPermissionDenied)
}
return
Expand All @@ -24,10 +25,19 @@ final class PermissionsHelper {
}
}

static func requestPermissions(for mediaType: AVMediaType, completion: @escaping (Bool) -> Void) {
static func requestPermissions(
for mediaType: AVMediaType,
queue: DispatchQueue = .main,
completion: @escaping (Bool) -> Void
) {
switch AVCaptureDevice.authorizationStatus(for: mediaType) {
case .notDetermined:
AVCaptureDevice.requestAccess(for: mediaType) { granted in
queue.async {
completion(granted)
}
}
case .authorized: completion(true)
case .notDetermined: AVCaptureDevice.requestAccess(for: mediaType, completionHandler: completion)
case .denied: completion(false)
case .restricted: completion(false)
@unknown default: completion(false)
Expand Down
3 changes: 1 addition & 2 deletions Shared/UI/AlertHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ final class AlertHelper {
}

static func showErrorWithSettingsAction(
title: String = "Something went wrong",
message: String,
on viewController: UIViewController? = nil
) {
showError(message: title, action: accessSettingsAction, on: viewController)
showError(message: message, action: accessSettingsAction, on: viewController)
}

static func showAlert(
Expand Down
2 changes: 2 additions & 0 deletions Swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1716,6 +1716,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_OBJC_WEAK = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = W9BHJBL635;
INFOPLIST_FILE = "$(SRCROOT)/ScreenSharing/Resources/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
Expand All @@ -1735,6 +1736,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_OBJC_WEAK = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = W9BHJBL635;
INFOPLIST_FILE = "$(SRCROOT)/ScreenSharing/Resources/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
Expand Down

0 comments on commit faa991b

Please sign in to comment.