prevent expandable alert collapse when accessibilty focused. top alert notification callout fix.
This commit is contained in:
parent
e119e269b8
commit
01b52bc479
@ -74,6 +74,7 @@
|
||||
self.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
self.clipsToBounds = YES;
|
||||
self.expanded = NO;
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(accessibilityFocusChanged:) name:UIAccessibilityElementFocusedNotification object:nil];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -162,6 +163,7 @@
|
||||
|
||||
- (void)setupTopAlertWithButton:(MVMCoreUITopAlertMainView *)topAlertWithButton {
|
||||
topAlertWithButton.label.alpha = 0;
|
||||
topAlertWithButton.label.accessibilityLabel = [NSString stringWithFormat:@"%@ - %@", [MVMCoreUIUtility hardcodedStringWithKey:@"top_alert_notification"], topAlertWithButton.label.accessibilityLabel];
|
||||
topAlertWithButton.button.alpha = 0;
|
||||
topAlertWithButton.backgroundColor = [UIColor clearColor];
|
||||
[self insertSubview:topAlertWithButton belowSubview:self.shortView];
|
||||
@ -304,7 +306,6 @@
|
||||
//accessibility - added to make only top alert label and close button accessible. Posted notification when top alert is displayed
|
||||
weakSelf.accessibilityElements = @[weakSelf.buttonView];
|
||||
weakSelf.shortView.isAccessibilityElement = NO;
|
||||
weakSelf.buttonView.label.accessibilityLabel = [NSString stringWithFormat:@"%@ - %@", [MVMCoreUIUtility hardcodedStringWithKey:@"top_alert_notification"],weakSelf.buttonView.label.accessibilityLabel];
|
||||
|
||||
void(^completion)(void) = ^(void) {
|
||||
UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, weakSelf.buttonView.label);
|
||||
@ -346,7 +347,7 @@
|
||||
}
|
||||
dispatch_time_t dispatchTime = dispatch_time(DISPATCH_TIME_NOW, dismissTime * NSEC_PER_SEC);
|
||||
dispatch_after(dispatchTime, dispatch_get_main_queue(), ^(void){
|
||||
if (weakSelf && weakSelf.expanded && weakSelf.collapseAutomaticallyAfterExpanded) {
|
||||
if (weakSelf && weakSelf.expanded && weakSelf.collapseAutomaticallyAfterExpanded && ![self containsAccessiblityFocus]) {
|
||||
[weakSelf collapse];
|
||||
}
|
||||
});
|
||||
@ -390,4 +391,28 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)containsAccessiblityFocus {
|
||||
if (!UIAccessibilityIsVoiceOverRunning()) {
|
||||
return NO;
|
||||
}
|
||||
id focusedElement = UIAccessibilityFocusedElement(UIAccessibilityNotificationVoiceOverIdentifier);
|
||||
if (![focusedElement isKindOfClass:[UIView class]]) {
|
||||
return NO;
|
||||
}
|
||||
UIView *focusedView = focusedElement;
|
||||
while (focusedView != nil) {
|
||||
if (focusedView == self) {
|
||||
return YES;
|
||||
}
|
||||
focusedView = [focusedView superview];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)accessibilityFocusChanged:(NSNotification *)notification {
|
||||
if (![self containsAccessiblityFocus]) {
|
||||
[self collapse];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user