Commit 3fdfd2ba authored by Yuwei Huang's avatar Yuwei Huang Committed by Commit Bot

[CRD iOS] Fix accessibility focus on host connection flow

* Changes the accessibility focus order to Cancel button->PIN input->
  Pairing switch->Continue button.
* Makes the status label the default focus instead of the cancel button.

Bug: 770841
Change-Id: I02f0261a7b20da71485dacb4f7a09506fc09976b
Reviewed-on: https://chromium-review.googlesource.com/695838Reviewed-by: default avatarScott Nichols <nicholss@chromium.org>
Commit-Queue: Yuwei Huang <yuweih@chromium.org>
Cr-Commit-Position: refs/heads/master@{#505852}
parent 73358061
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#import "remoting/ios/app/pin_entry_view.h" #import "remoting/ios/app/pin_entry_view.h"
#import "remoting/ios/app/remoting_theme.h" #import "remoting/ios/app/remoting_theme.h"
#import "remoting/ios/app/session_reconnect_view.h" #import "remoting/ios/app/session_reconnect_view.h"
#import "remoting/ios/app/view_utils.h"
#import "remoting/ios/domain/client_session_details.h" #import "remoting/ios/domain/client_session_details.h"
#import "remoting/ios/domain/host_info.h" #import "remoting/ios/domain/host_info.h"
#import "remoting/ios/facade/remoting_authentication.h" #import "remoting/ios/facade/remoting_authentication.h"
...@@ -411,6 +412,7 @@ static const CGFloat kKeyboardAnimationTime = 0.3; ...@@ -411,6 +412,7 @@ static const CGFloat kKeyboardAnimationTime = 0.3;
[_pinEntryView endEditing:YES]; [_pinEntryView endEditing:YES];
_statusLabel.text = _statusLabel.text =
[self stringWithHostNameForId:IDS_CONNECTING_TO_HOST_MESSAGE]; [self stringWithHostNameForId:IDS_CONNECTING_TO_HOST_MESSAGE];
[self focusOnStatusLabel];
_pinEntryView.hidden = YES; _pinEntryView.hidden = YES;
...@@ -449,6 +451,7 @@ static const CGFloat kKeyboardAnimationTime = 0.3; ...@@ -449,6 +451,7 @@ static const CGFloat kKeyboardAnimationTime = 0.3;
[_pinEntryView endEditing:YES]; [_pinEntryView endEditing:YES];
_statusLabel.text = _statusLabel.text =
[self stringWithHostNameForId:IDS_CONNECTED_TO_HOST_MESSAGE]; [self stringWithHostNameForId:IDS_CONNECTED_TO_HOST_MESSAGE];
[self focusOnStatusLabel];
_pinEntryView.hidden = YES; _pinEntryView.hidden = YES;
[_pinEntryView clearPinEntry]; [_pinEntryView clearPinEntry];
...@@ -476,6 +479,7 @@ static const CGFloat kKeyboardAnimationTime = 0.3; ...@@ -476,6 +479,7 @@ static const CGFloat kKeyboardAnimationTime = 0.3;
- (void)showReconnect { - (void)showReconnect {
_statusLabel.text = _statusLabel.text =
[self stringWithHostNameForId:IDS_CONNECTION_CLOSED_FOR_HOST_MESSAGE]; [self stringWithHostNameForId:IDS_CONNECTION_CLOSED_FOR_HOST_MESSAGE];
[self focusOnStatusLabel];
_iconView.backgroundColor = RemotingTheme.hostErrorColor; _iconView.backgroundColor = RemotingTheme.hostErrorColor;
...@@ -551,6 +555,7 @@ static const CGFloat kKeyboardAnimationTime = 0.3; ...@@ -551,6 +555,7 @@ static const CGFloat kKeyboardAnimationTime = 0.3;
_reconnectView.errorText = message; _reconnectView.errorText = message;
} }
_reconnectView.hidden = NO; _reconnectView.hidden = NO;
remoting::SetAccessibilityFocusElement(_reconnectView);
} }
- (void)didProvidePin:(NSString*)pin createPairing:(BOOL)createPairing { - (void)didProvidePin:(NSString*)pin createPairing:(BOOL)createPairing {
...@@ -623,4 +628,8 @@ static const CGFloat kKeyboardAnimationTime = 0.3; ...@@ -623,4 +628,8 @@ static const CGFloat kKeyboardAnimationTime = 0.3;
base::SysNSStringToUTF16(_remoteHostName)); base::SysNSStringToUTF16(_remoteHostName));
} }
- (void)focusOnStatusLabel {
remoting::SetAccessibilityFocusElement(_statusLabel);
}
@end @end
...@@ -38,17 +38,19 @@ static const int kMinPinLength = 6; ...@@ -38,17 +38,19 @@ static const int kMinPinLength = 6;
if (self) { if (self) {
self.backgroundColor = [UIColor clearColor]; self.backgroundColor = [UIColor clearColor];
NSString* rememberPinText =
l10n_util::GetNSString(IDS_REMEMBER_PIN_ON_THIS_DEVICE);
_pairingSwitch = [[UISwitch alloc] init]; _pairingSwitch = [[UISwitch alloc] init];
_pairingSwitch.tintColor = RemotingTheme.pinEntryPairingColor; _pairingSwitch.tintColor = RemotingTheme.pinEntryPairingColor;
_pairingSwitch.transform = CGAffineTransformMakeScale(0.5, 0.5); _pairingSwitch.transform = CGAffineTransformMakeScale(0.5, 0.5);
_pairingSwitch.accessibilityLabel = rememberPinText;
_pairingSwitch.translatesAutoresizingMaskIntoConstraints = NO; _pairingSwitch.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:_pairingSwitch]; [self addSubview:_pairingSwitch];
_pairingLabel = [[UILabel alloc] init]; _pairingLabel = [[UILabel alloc] init];
_pairingLabel.textColor = RemotingTheme.pinEntryPairingColor; _pairingLabel.textColor = RemotingTheme.pinEntryPairingColor;
_pairingLabel.font = [UIFont systemFontOfSize:12.f]; _pairingLabel.font = [UIFont systemFontOfSize:12.f];
_pairingLabel.text = _pairingLabel.text = rememberPinText;
l10n_util::GetNSString(IDS_REMEMBER_PIN_ON_THIS_DEVICE);
_pairingLabel.translatesAutoresizingMaskIntoConstraints = NO; _pairingLabel.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:_pairingLabel]; [self addSubview:_pairingLabel];
...@@ -99,6 +101,8 @@ static const int kMinPinLength = 6; ...@@ -99,6 +101,8 @@ static const int kMinPinLength = 6;
_pinButton, _pinEntry)]; _pinButton, _pinEntry)];
_supportsPairing = YES; _supportsPairing = YES;
self.accessibilityElements = @[ _pinEntry, _pairingSwitch, _pinButton ];
} }
return self; return self;
} }
...@@ -155,6 +159,7 @@ static const int kMinPinLength = 6; ...@@ -155,6 +159,7 @@ static const int kMinPinLength = 6;
- (void)setSupportsPairing:(BOOL)supportsPairing { - (void)setSupportsPairing:(BOOL)supportsPairing {
_supportsPairing = supportsPairing; _supportsPairing = supportsPairing;
_pairingSwitch.hidden = !_supportsPairing; _pairingSwitch.hidden = !_supportsPairing;
_pairingSwitch.isAccessibilityElement = _supportsPairing;
[_pairingSwitch setOn:NO animated:NO]; [_pairingSwitch setOn:NO animated:NO];
_pairingLabel.hidden = !_supportsPairing; _pairingLabel.hidden = !_supportsPairing;
} }
......
...@@ -208,7 +208,7 @@ ConnectionType GetConnectionType() { ...@@ -208,7 +208,7 @@ ConnectionType GetConnectionType() {
[super viewWillAppear:animated]; [super viewWillAppear:animated];
// Just in case the view controller misses the host list state event before // Just in case the view controller misses the host list state event before
// the listener is registered. // gthe listener is registered.
[self refreshContent]; [self refreshContent];
} }
......
...@@ -22,6 +22,8 @@ void SetAccessibilityInfoFromImage(UIBarButtonItem* button); ...@@ -22,6 +22,8 @@ void SetAccessibilityInfoFromImage(UIBarButtonItem* button);
// Sets the a11y label of the UIButton according to the image it holds. // Sets the a11y label of the UIButton according to the image it holds.
void SetAccessibilityInfoFromImage(UIButton* button); void SetAccessibilityInfoFromImage(UIButton* button);
void SetAccessibilityFocusElement(id element);
} // namespace remoting } // namespace remoting
#endif // REMOTING_IOS_APP_VIEW_UTILS_H_ #endif // REMOTING_IOS_APP_VIEW_UTILS_H_
...@@ -55,4 +55,9 @@ void SetAccessibilityInfoFromImage(UIButton* button) { ...@@ -55,4 +55,9 @@ void SetAccessibilityInfoFromImage(UIButton* button) {
[button imageForState:UIControlStateNormal].accessibilityLabel; [button imageForState:UIControlStateNormal].accessibilityLabel;
} }
void SetAccessibilityFocusElement(id element) {
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification,
element);
}
} // namespace remoting } // namespace remoting
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment