Commit 66b3060d authored by lpromero's avatar lpromero Committed by Commit bot

Revert to the old back arrow style with NavigationBar

MDC has a method to use the old style, but it's in a private component
and the wind is blowing towards removing it at some point, so this CL
just opt-s out of MDC driving the back button in Settings.

I still filed a request at MDC to have the method public, but it might
never come, or they might remove the old style before that.

BUG=none
R=sdefresne@chromium.org

Review-Url: https://codereview.chromium.org/2589193002
Cr-Commit-Position: refs/heads/master@{#439776}
parent ed90a677
...@@ -145,7 +145,7 @@ void ClearCountryValue() { ...@@ -145,7 +145,7 @@ void ClearCountryValue() {
// Close the settings. // Close the settings.
- (void)exitSettingsMenu { - (void)exitSettingsMenu {
NSString* backButtonA11yId = @"back_bar_button"; NSString* backButtonA11yId = @"ic_arrow_back";
[[EarlGrey [[EarlGrey
selectElementWithMatcher:grey_allOf( selectElementWithMatcher:grey_allOf(
grey_accessibilityID(backButtonA11yId), grey_accessibilityID(backButtonA11yId),
......
...@@ -81,13 +81,13 @@ void OpenBlockPopupsSettings() { ...@@ -81,13 +81,13 @@ void OpenBlockPopupsSettings() {
void CloseSettings() { void CloseSettings() {
[[EarlGrey [[EarlGrey
selectElementWithMatcher:grey_allOf( selectElementWithMatcher:grey_allOf(
grey_accessibilityID(@"back_bar_button"), grey_accessibilityID(@"ic_arrow_back"),
grey_accessibilityTrait( grey_accessibilityTrait(
UIAccessibilityTraitButton), UIAccessibilityTraitButton),
nil)] performAction:grey_tap()]; nil)] performAction:grey_tap()];
[[EarlGrey [[EarlGrey
selectElementWithMatcher:grey_allOf( selectElementWithMatcher:grey_allOf(
grey_accessibilityID(@"back_bar_button"), grey_accessibilityID(@"ic_arrow_back"),
grey_accessibilityTrait( grey_accessibilityTrait(
UIAccessibilityTraitButton), UIAccessibilityTraitButton),
nil)] performAction:grey_tap()]; nil)] performAction:grey_tap()];
......
...@@ -273,11 +273,11 @@ bool IsCertificateCleared() { ...@@ -273,11 +273,11 @@ bool IsCertificateCleared() {
performAction:grey_tap()]; performAction:grey_tap()];
} }
// Closes the a sub-settings menu, and then the general Settings menu. // Closes a sub-settings menu, and then the general Settings menu.
- (void)closeSubSettingsMenu { - (void)closeSubSettingsMenu {
[[EarlGrey [[EarlGrey
selectElementWithMatcher:grey_allOf( selectElementWithMatcher:grey_allOf(
grey_accessibilityID(@"back_bar_button"), grey_accessibilityID(@"ic_arrow_back"),
grey_accessibilityTrait( grey_accessibilityTrait(
UIAccessibilityTraitButton), UIAccessibilityTraitButton),
nil)] performAction:grey_tap()]; nil)] performAction:grey_tap()];
......
...@@ -78,6 +78,11 @@ ...@@ -78,6 +78,11 @@
// Closes the settings by calling |closeSettings| on |delegate|. // Closes the settings by calling |closeSettings| on |delegate|.
- (void)closeSettings; - (void)closeSettings;
// Creates an autoreleased Back button for a UINavigationItem which will pop the
// top view controller when it is pressed. Should only be called by view
// controllers owned by SettingsNavigationController.
- (UIBarButtonItem*)backButton;
// Creates an autoreleased "X" button that closes the settings when tapped. // Creates an autoreleased "X" button that closes the settings when tapped.
- (UIBarButtonItem*)closeButton; - (UIBarButtonItem*)closeButton;
...@@ -319,6 +324,10 @@ initWithRootViewController:(UIViewController*)rootViewController ...@@ -319,6 +324,10 @@ initWithRootViewController:(UIViewController*)rootViewController
[delegate_ closeSettings]; [delegate_ closeSettings];
} }
- (void)back {
[self popViewControllerAnimated:YES];
}
- (void)popViewControllerOrCloseSettingsAnimated:(BOOL)animated { - (void)popViewControllerOrCloseSettingsAnimated:(BOOL)animated {
if (self.viewControllers.count > 1) { if (self.viewControllers.count > 1) {
// Pop the top view controller to reveal the view controller underneath. // Pop the top view controller to reveal the view controller underneath.
...@@ -351,6 +360,14 @@ initWithRootViewController:(UIViewController*)rootViewController ...@@ -351,6 +360,14 @@ initWithRootViewController:(UIViewController*)rootViewController
[[rightButton title] compare:[doneButton title]] == NSOrderedSame; [[rightButton title] compare:[doneButton title]] == NSOrderedSame;
} }
- (UIBarButtonItem*)backButton {
// Create a custom Back bar button item, as Material Navigation Bar deprecated
// the back arrow with a shaft.
return [ChromeIcon templateBarButtonItemWithImage:[ChromeIcon backIcon]
target:self
action:@selector(back)];
}
- (UIBarButtonItem*)doneButton { - (UIBarButtonItem*)doneButton {
// Create a custom Done bar button item, as Material Navigation Bar does not // Create a custom Done bar button item, as Material Navigation Bar does not
// handle a system UIBarButtonSystemItemDone item. // handle a system UIBarButtonSystemItemDone item.
...@@ -408,6 +425,12 @@ initWithRootViewController:(UIViewController*)rootViewController ...@@ -408,6 +425,12 @@ initWithRootViewController:(UIViewController*)rootViewController
- (void)pushViewController:(UIViewController*)viewController - (void)pushViewController:(UIViewController*)viewController
animated:(BOOL)animated { animated:(BOOL)animated {
// Add a back button if the view controller is not the root view controller
// and doesn’t already have a left bar button item.
if (self.viewControllers.count > 0 &&
viewController.navigationItem.leftBarButtonItems.count == 0) {
viewController.navigationItem.leftBarButtonItem = [self backButton];
}
// Wrap the view controller in an MDCAppBarContainerViewController if needed. // Wrap the view controller in an MDCAppBarContainerViewController if needed.
[super pushViewController:[self wrappedControllerIfNeeded:viewController] [super pushViewController:[self wrappedControllerIfNeeded:viewController]
animated:animated]; animated:animated];
......
...@@ -58,13 +58,13 @@ const CGFloat kScrollDisplacement = 50.0; ...@@ -58,13 +58,13 @@ const CGFloat kScrollDisplacement = 50.0;
// Close settings. // Close settings.
[[EarlGrey [[EarlGrey
selectElementWithMatcher:grey_allOf( selectElementWithMatcher:grey_allOf(
grey_accessibilityID(@"back_bar_button"), grey_accessibilityID(@"ic_arrow_back"),
grey_accessibilityTrait( grey_accessibilityTrait(
UIAccessibilityTraitButton), UIAccessibilityTraitButton),
nil)] performAction:grey_tap()]; nil)] performAction:grey_tap()];
[[EarlGrey [[EarlGrey
selectElementWithMatcher:grey_allOf( selectElementWithMatcher:grey_allOf(
grey_accessibilityID(@"back_bar_button"), grey_accessibilityID(@"ic_arrow_back"),
grey_accessibilityTrait( grey_accessibilityTrait(
UIAccessibilityTraitButton), UIAccessibilityTraitButton),
nil)] performAction:grey_tap()]; nil)] performAction:grey_tap()];
......
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