Skip to content

Commit

Permalink
Merge branch 'release/1.1_41'
Browse files Browse the repository at this point in the history
  • Loading branch information
duemunk committed Dec 6, 2014
2 parents 6966541 + 639c5e0 commit e6650c3
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 33 deletions.
28 changes: 16 additions & 12 deletions BeMyEyes Tests/ClientTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ class ClientTest: XCTestCase {
if let error = error {
XCTFail("...with error: " + error.localizedDescription)
}
let user = BMEClient.sharedClient().currentUser
XCTAssert(user != nil, "No current user")
XCTAssert(user.email == email, "Wrong email")
XCTAssert(user.firstName == firstName, "Wrong first name")
XCTAssert(user.lastName == lastName, "Wrong last name")
XCTAssert(user.role == role, "Wrong role")
if let user = BMEClient.sharedClient().currentUser {
XCTAssert(user.email == email, "Wrong email")
XCTAssert(user.firstName == firstName, "Wrong first name")
XCTAssert(user.lastName == lastName, "Wrong last name")
XCTAssert(user.role == role, "Wrong role")
} else {
XCTFail("No current user")
}
let token = BMEClient.sharedClient().token()
XCTAssert(token != nil, "No token")
}
Expand All @@ -57,12 +59,14 @@ class ClientTest: XCTestCase {
BMEClient.sharedClient().createUserWithEmail(email, password: password, firstName: firstName, lastName: lastName, role: role) { (success, error) in
BMEClient.sharedClient().loginWithEmail(email, password: password, deviceToken: nil, success: { token in
expectation.fulfill()
let user = BMEClient.sharedClient().currentUser
XCTAssert(user != nil, "No current user")
XCTAssert(user.email == email, "Wrong email")
XCTAssert(user.firstName == firstName, "Wrong first name")
XCTAssert(user.lastName == lastName, "Wrong last name")
XCTAssert(user.role == role, "Wrong role")
if let user = BMEClient.sharedClient().currentUser {
XCTAssert(user.email == email, "Wrong email")
XCTAssert(user.firstName == firstName, "Wrong first name")
XCTAssert(user.lastName == lastName, "Wrong last name")
XCTAssert(user.role == role, "Wrong role")
} else {
XCTFail("No current user")
}
let token = BMEClient.sharedClient().token()
XCTAssert(token != nil, "No token")
}, failure: { (error) -> Void in
Expand Down
2 changes: 1 addition & 1 deletion BeMyEyes/BeMyEyes-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>40</string>
<string>41</string>
<key>FacebookAppID</key>
<string>771890076161460</string>
<key>FacebookDisplayName</key>
Expand Down
26 changes: 16 additions & 10 deletions BeMyEyes/Source/Application/BMEAccessControlHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -205,18 +205,24 @@ + (void)requireCameraEnabled:(void(^)(BOOL isEnabled))completion {
}

+ (void)hasVideoEnabled:(void(^)(BOOL isEnabled))completion {
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
AVCaptureDeviceInput *deviceInput = [AVCaptureDeviceInput deviceInputWithDevice:device error:nil];
if (deviceInput)
{
// Access to the camera succeeded.
if (completion) {
completion(YES);
}
return;
BOOL enabled;
switch ([AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]) {
case AVAuthorizationStatusNotDetermined:
enabled = NO;
break;
case AVAuthorizationStatusDenied:
enabled = NO;
break;
case AVAuthorizationStatusRestricted:
enabled = NO;
break;
case AVAuthorizationStatusAuthorized:
enabled = YES;
default:
break;
}
if (completion) {
completion(NO);
completion(enabled);
}
}

Expand Down
20 changes: 10 additions & 10 deletions BeMyEyes/Source/Controllers/BMEMainViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,16 @@ - (void)askForAccessIfNecessary
{
[BMEAccessControlHandler enabledForRole:[BMEClient sharedClient].currentUser.role completion:^(BOOL isEnabled, BOOL validToken) {
if (isEnabled) {
return;
}
if (!validToken) {
// User has enable push, but something else went wrong
NSString *title = MKLocalizedFromTable(BME_MAIN_ALERT_NOTIFICATIONS_ERROR_TITLE, BMEMainLocalizationTable);
NSString *message = MKLocalizedFromTable(BME_MAIN_ALERT_NOTIFICATIONS_ERROR_MESSAGE, BMEMainLocalizationTable);
NSString *cancelButton = MKLocalizedFromTable(BME_MAIN_ALERT_CANCEL, BMEMainLocalizationTable);
PSPDFAlertView *alertView = [[PSPDFAlertView alloc] initWithTitle:title message:message];
[alertView setCancelButtonWithTitle:cancelButton block:nil];
[alertView show];
if (!validToken) {
// User has enable push, but something else went wrong
NSString *title = MKLocalizedFromTable(BME_MAIN_ALERT_NOTIFICATIONS_ERROR_TITLE, BMEMainLocalizationTable);
NSString *message = MKLocalizedFromTable(BME_MAIN_ALERT_NOTIFICATIONS_ERROR_MESSAGE, BMEMainLocalizationTable);
NSString *cancelButton = MKLocalizedFromTable(BME_MAIN_ALERT_CANCEL, BMEMainLocalizationTable);
PSPDFAlertView *alertView = [[PSPDFAlertView alloc] initWithTitle:title message:message];
[alertView setCancelButtonWithTitle:cancelButton block:nil];
[alertView show];
return;
}
return;
}
[self performSegueWithIdentifier:BMEAccessViewSegue sender:self];
Expand Down

0 comments on commit e6650c3

Please sign in to comment.