asking for camera permissions #1363
This commit is contained in:
parent
1912fbde72
commit
c152c1c83a
|
@ -473,6 +473,7 @@
|
|||
E197B62418BBF5BB00F073E5 /* SoundPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = E197B62318BBF5BB00F073E5 /* SoundPlayer.m */; };
|
||||
E197B62718BBF63B00F073E5 /* SoundBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = E197B62618BBF63B00F073E5 /* SoundBoard.m */; };
|
||||
E1CD329618BCFF9900B1A496 /* SoundInstance.m in Sources */ = {isa = PBXBuildFile; fileRef = E1CD329518BCFF9900B1A496 /* SoundInstance.m */; };
|
||||
EF764C351DB67CC5000D9A87 /* UIViewController+CameraPermissions.m in Sources */ = {isa = PBXBuildFile; fileRef = EF764C341DB67CC5000D9A87 /* UIViewController+CameraPermissions.m */; };
|
||||
FC31962A1A067D8F0094C78E /* MessageComposeTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FC3196291A067D8F0094C78E /* MessageComposeTableViewController.m */; };
|
||||
FC31962D1A06A2190094C78E /* FingerprintViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FC31962C1A06A2190094C78E /* FingerprintViewController.m */; };
|
||||
FC3196301A0814130094C78E /* SettingsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FC31962F1A0814130094C78E /* SettingsTableViewController.m */; };
|
||||
|
@ -1090,6 +1091,8 @@
|
|||
E1CD329418BCFF9900B1A496 /* SoundInstance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SoundInstance.h; sourceTree = "<group>"; };
|
||||
E1CD329518BCFF9900B1A496 /* SoundInstance.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SoundInstance.m; sourceTree = "<group>"; };
|
||||
E85DB184824BA9DC302EC8B3 /* Pods-SignalTests.app store release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SignalTests.app store release.xcconfig"; path = "Pods/Target Support Files/Pods-SignalTests/Pods-SignalTests.app store release.xcconfig"; sourceTree = "<group>"; };
|
||||
EF764C331DB67CC5000D9A87 /* UIViewController+CameraPermissions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIViewController+CameraPermissions.h"; path = "util/UIViewController+CameraPermissions.h"; sourceTree = "<group>"; };
|
||||
EF764C341DB67CC5000D9A87 /* UIViewController+CameraPermissions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIViewController+CameraPermissions.m"; path = "util/UIViewController+CameraPermissions.m"; sourceTree = "<group>"; };
|
||||
FC3196281A067D8F0094C78E /* MessageComposeTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageComposeTableViewController.h; sourceTree = "<group>"; };
|
||||
FC3196291A067D8F0094C78E /* MessageComposeTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageComposeTableViewController.m; sourceTree = "<group>"; };
|
||||
FC31962B1A06A2190094C78E /* FingerprintViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = FingerprintViewController.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||
|
@ -2412,6 +2415,8 @@
|
|||
FCFA64B61A24F6730007FB87 /* UIFont+OWS.m */,
|
||||
B68112E81A4D9EC400BA82FF /* UIImage+normalizeImage.h */,
|
||||
B68112E91A4D9EC400BA82FF /* UIImage+normalizeImage.m */,
|
||||
EF764C331DB67CC5000D9A87 /* UIViewController+CameraPermissions.h */,
|
||||
EF764C341DB67CC5000D9A87 /* UIViewController+CameraPermissions.m */,
|
||||
);
|
||||
name = "UI Categories";
|
||||
path = ..;
|
||||
|
@ -2820,6 +2825,7 @@
|
|||
76EB05A818170B33006006FC /* RtpSocket.m in Sources */,
|
||||
E197B61818BBEC1A00F073E5 /* RemoteIOAudio.m in Sources */,
|
||||
B67ADDC41989FF8700E1A773 /* RPServerRequestsManager.m in Sources */,
|
||||
EF764C351DB67CC5000D9A87 /* UIViewController+CameraPermissions.m in Sources */,
|
||||
76EB059418170B33006006FC /* HttpManager.m in Sources */,
|
||||
45CD81EF1DC030E7004C9430 /* AccountManager.swift in Sources */,
|
||||
76EB05EC18170B33006006FC /* CallState.m in Sources */,
|
||||
|
|
|
@ -912,9 +912,6 @@
|
|||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
<segue destination="tWr-1v-Sq9" kind="push" id="23M-9X-9xV"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
<connections>
|
||||
|
@ -923,10 +920,13 @@
|
|||
</connections>
|
||||
</tableView>
|
||||
<navigationItem key="navigationItem" title="Linked Devices" id="HAh-b7-E4Q"/>
|
||||
<connections>
|
||||
<segue destination="tWr-1v-Sq9" kind="push" identifier="LinkDeviceSegue" id="zMV-AS-COl"/>
|
||||
</connections>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="tUY-HM-TQP" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-2400" y="-3228"/>
|
||||
<point key="canvasLocation" x="-2404" y="-3229"/>
|
||||
</scene>
|
||||
<!--_7.0 - Settings-->
|
||||
<scene sceneID="BD7-1h-slc">
|
||||
|
@ -1519,6 +1519,7 @@
|
|||
<simulatedScreenMetrics key="destination" type="retina4_7.fullscreen"/>
|
||||
</simulatedMetricsContainer>
|
||||
<inferredMetricsTieBreakers>
|
||||
<segue reference="xo7-5J-BJb"/>
|
||||
<segue reference="tfr-ZV-qWs"/>
|
||||
<segue reference="E8S-Yc-X7E"/>
|
||||
</inferredMetricsTieBreakers>
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
//
|
||||
// UIViewController+CameraPermissions.h
|
||||
// Signal
|
||||
//
|
||||
// Created by Jarosław Pawlak on 18.10.2016.
|
||||
// Copyright © 2016 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@interface UIViewController (CameraPermissions)
|
||||
|
||||
-(void)ows_askForCameraPermissions:(void(^)())permissionsGrantedCallback;
|
||||
|
||||
@end
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,46 @@
|
|||
//
|
||||
// UIViewController+CameraPermissions.m
|
||||
// Signal
|
||||
//
|
||||
// Created by Jarosław Pawlak on 18.10.2016.
|
||||
// Copyright © 2016 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
#import "UIUtil.h"
|
||||
#import "UIViewController+CameraPermissions.h"
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation UIViewController (CameraPermissions)
|
||||
|
||||
-(void)ows_askForCameraPermissions:(void(^)())permissionsGrantedCallback
|
||||
{
|
||||
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
|
||||
DDLogError(@"Camera ImagePicker source not available");
|
||||
return;
|
||||
}
|
||||
AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
|
||||
if (status == AVAuthorizationStatusDenied) {
|
||||
UIAlertController* alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"CAMERA_PERMISSION_TITLE",nil) message:NSLocalizedString(@"CAMERA_PERMISSION_MESSAGE",nil) preferredStyle:UIAlertControllerStyleAlert];
|
||||
|
||||
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"CAMERA_PERMISSION_PROCEED",nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
||||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
|
||||
}]];
|
||||
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"CAMERA_PERMISSION_CANCEL",nil) style:UIAlertActionStyleCancel handler:nil]];
|
||||
[self presentViewController:alert animated:YES completion:[UIUtil modalCompletionBlock]];
|
||||
} else if (status == AVAuthorizationStatusAuthorized) {
|
||||
permissionsGrantedCallback();
|
||||
} else if (status == AVAuthorizationStatusNotDetermined) {
|
||||
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
|
||||
if (granted) {
|
||||
permissionsGrantedCallback();
|
||||
}
|
||||
}];
|
||||
} else {
|
||||
DDLogError(@"Unknown AVAuthorizationStatus: %ld", (long)status);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -10,6 +10,7 @@
|
|||
#import "DJWActionSheet+OWS.h"
|
||||
#import "Environment.h"
|
||||
#import "OWSConversationSettingsTableViewController.h"
|
||||
#import "UIViewController+CameraPermissions.h"
|
||||
#import "Signal-Swift.h"
|
||||
#import <SignalServiceKit/NSDate+millisecondTimeStamp.h>
|
||||
#import <SignalServiceKit/OWSFingerprint.h>
|
||||
|
@ -137,20 +138,22 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
- (void)showScanner
|
||||
{
|
||||
DDLogInfo(@"%@ Showing Scanner", self.tag);
|
||||
self.qrScanningView.hidden = NO;
|
||||
self.scanningInstructions.hidden = NO;
|
||||
[UIView animateWithDuration:0.4
|
||||
delay:0.0
|
||||
options:UIViewAnimationOptionCurveEaseInOut
|
||||
animations:^{
|
||||
self.scanningContainer.frame = self.qrContainer.frame;
|
||||
self.qrContainer.frame = self.instructionsContainer.frame;
|
||||
self.instructionsContainer.alpha = 0.0f;
|
||||
}
|
||||
completion:nil];
|
||||
|
||||
[self.qrScanningController startCapture];
|
||||
[self ows_askForCameraPermissions:^{
|
||||
DDLogInfo(@"%@ Showing Scanner", self.tag);
|
||||
self.qrScanningView.hidden = NO;
|
||||
self.scanningInstructions.hidden = NO;
|
||||
[UIView animateWithDuration:0.4
|
||||
delay:0.0
|
||||
options:UIViewAnimationOptionCurveEaseInOut
|
||||
animations:^{
|
||||
self.scanningContainer.frame = self.qrContainer.frame;
|
||||
self.qrContainer.frame = self.instructionsContainer.frame;
|
||||
self.instructionsContainer.alpha = 0.0f;
|
||||
}
|
||||
completion:nil];
|
||||
|
||||
[self.qrScanningController startCapture];
|
||||
}];
|
||||
}
|
||||
|
||||
// pragma mark - OWSQRScannerDelegate
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#import "TSInvalidIdentityKeyErrorMessage.h"
|
||||
#import "UIFont+OWS.h"
|
||||
#import "UIUtil.h"
|
||||
#import "UIViewController+CameraPermissions.h"
|
||||
#import <AddressBookUI/AddressBookUI.h>
|
||||
#import <ContactsUI/CNContactViewController.h>
|
||||
#import <JSQMessagesViewController/JSQMessagesBubbleImage.h>
|
||||
|
@ -64,6 +65,7 @@
|
|||
#import <SignalServiceKit/TSNetworkManager.h>
|
||||
#import <YapDatabase/YapDatabaseView.h>
|
||||
|
||||
|
||||
@import Photos;
|
||||
|
||||
#define kYapDatabaseRangeLength 50
|
||||
|
@ -1560,19 +1562,16 @@ typedef enum : NSUInteger {
|
|||
*/
|
||||
|
||||
- (void)takePictureOrVideo {
|
||||
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
|
||||
DDLogError(@"Camera ImagePicker source not available");
|
||||
return;
|
||||
}
|
||||
[self ows_askForCameraPermissions:^{
|
||||
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
|
||||
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
|
||||
picker.mediaTypes = @[ (__bridge NSString *)kUTTypeImage, (__bridge NSString *)kUTTypeMovie ];
|
||||
picker.allowsEditing = NO;
|
||||
picker.delegate = self;
|
||||
[self presentViewController:picker animated:YES completion:[UIUtil modalCompletionBlock]];
|
||||
|
||||
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
|
||||
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
|
||||
picker.mediaTypes = @[ (__bridge NSString *)kUTTypeImage, (__bridge NSString *)kUTTypeMovie ];
|
||||
picker.allowsEditing = NO;
|
||||
picker.delegate = self;
|
||||
[self presentViewController:picker animated:YES completion:[UIUtil modalCompletionBlock]];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)chooseFromLibrary {
|
||||
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
|
||||
DDLogError(@"PhotoLibrary ImagePicker source not available");
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#import "OWSLinkedDevicesTableViewController.h"
|
||||
#import "OWSDeviceTableViewCell.h"
|
||||
#import "OWSLinkDeviceViewController.h"
|
||||
#import "UIViewController+CameraPermissions.h"
|
||||
#import <SignalServiceKit/OWSDevice.h>
|
||||
#import <SignalServiceKit/OWSDevicesService.h>
|
||||
#import <SignalServiceKit/TSDatabaseView.h>
|
||||
|
@ -248,6 +249,15 @@ int const OWSLinkedDevicesTableViewControllerSectionAddDevice = 1;
|
|||
}
|
||||
}
|
||||
|
||||
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (indexPath.section == OWSLinkedDevicesTableViewControllerSectionAddDevice)
|
||||
{
|
||||
[self ows_askForCameraPermissions:^{
|
||||
[self performSegueWithIdentifier:@"LinkDeviceSegue" sender:self];
|
||||
}];
|
||||
}
|
||||
}
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (indexPath.section == OWSLinkedDevicesTableViewControllerSectionAddDevice) {
|
||||
|
|
Loading…
Reference in New Issue