Commit e4b00aa5 authored by David Jean's avatar David Jean Committed by Chromium LUCI CQ

[ios] Handle deprecated activity indicator

And menu api,
and one remaining status bar orientation related issue.

Bug: 1131852
Change-Id: I74747b488608a6156d5f1ef15b8d6e52c1aa4741
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2621307
Commit-Queue: David Jean <djean@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843484}
parent 04129072
......@@ -4,6 +4,7 @@
#import "ios/chrome/browser/ui/elements/chrome_activity_overlay_view_controller.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.h"
#import "ios/chrome/common/ui/util/constraints_ui_util.h"
......@@ -30,8 +31,7 @@ const CGFloat kActivityIndicatorViewSize = 55;
containerView.backgroundColor = [UIColor colorNamed:kBackgroundColor];
containerView.layer.cornerRadius = kContainerCornerRadius;
containerView.layer.masksToBounds = YES;
UIActivityIndicatorView* activityView = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
UIActivityIndicatorView* activityView = GetLargeUIActivityIndicatorView();
activityView.color = [UIColor colorNamed:kTextPrimaryColor];
activityView.translatesAutoresizingMaskIntoConstraints = NO;
[activityView startAnimating];
......
......@@ -334,11 +334,11 @@
}
}
// Dismiss the edit menu.
if (@available(iOS 13, *)) {
[[UIMenuController sharedMenuController] hideMenu];
} else {
[[UIMenuController sharedMenuController] setMenuVisible:NO animated:NO];
}
#if !defined(__IPHONE_13_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_13_0
[[UIMenuController sharedMenuController] setMenuVisible:NO animated:NO];
#else
[[UIMenuController sharedMenuController] hideMenu];
#endif
// When the NTP and fakebox are visible, make the fakebox animates into place
// before focusing the omnibox.
......
......@@ -597,12 +597,12 @@ const NSString* kScribbleOmniboxElementId = @"omnibox";
action:@selector(searchCopiedText:)]);
BOOL updateSuccessful = [self updateCachedClipboardStateWithCompletion:^() {
if (@available(iOS 13, *)) {
[menu showMenuFromView:self.view rect:self.locationBarSteadyView.frame];
} else {
[menu setTargetRect:self.locationBarSteadyView.frame inView:self.view];
[menu setMenuVisible:YES animated:YES];
}
#if !defined(__IPHONE_13_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_13_0
[menu setTargetRect:self.locationBarSteadyView.frame inView:self.view];
[menu setMenuVisible:YES animated:YES];
#else
[menu showMenuFromView:self.view rect:self.locationBarSteadyView.frame];
#endif
// When the menu is manually presented, it doesn't get focused by
// Voiceover. This notification forces voiceover to select the
// presented menu.
......
......@@ -496,12 +496,22 @@ const CGFloat kClearButtonSize = 28.0f;
// Cancel original menu opening.
UIMenuController* menuController = [UIMenuController sharedMenuController];
#if !defined(__IPHONE_13_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_13_0
[menuController setMenuVisible:NO animated:NO];
// Reset where it should open below text field and reopen it.
menuController.arrowDirection = UIMenuControllerArrowUp;
[menuController setTargetRect:self.textField.frame inView:self.textField];
[menuController setMenuVisible:YES animated:YES];
#else
[menuController hideMenu];
// Reset where it should open below text field and reopen it.
menuController.arrowDirection = UIMenuControllerArrowUp;
[menuController showMenuFromView:self.textField rect:self.textField.frame];
#endif
self.showingEditMenu = NO;
}
......
......@@ -482,8 +482,7 @@ class OpenInControllerBridge
UIViewAutoresizingFlexibleHeight)];
[_overlayedView addSubview:grayBackgroundView];
UIActivityIndicatorView* spinner = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
UIActivityIndicatorView* spinner = GetLargeUIActivityIndicatorView();
[spinner setFrame:[_overlayedView frame]];
[spinner setHidesWhenStopped:YES];
[spinner setUserInteractionEnabled:NO];
......
......@@ -769,11 +769,19 @@ NSString* const kOverscrollActionsDidEnd = @"OverscrollActionsDidStop";
switch (self.overscrollState) {
case OverscrollState::NO_PULL_STARTED: {
[self.overscrollActionView removeFromSuperview];
SetViewFrameHeight(self.overscrollActionView,
self.initialContentInset +
[UIApplication sharedApplication]
.statusBarFrame.size.height,
0);
#if !defined(__IPHONE_13_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_13_0
CGRect statusBarFrame =
[UIApplication sharedApplication].statusBarFrame;
#else
CGRect statusBarFrame =
[self scrollView]
.window.windowScene.statusBarManager
.statusBarFrame;
#endif
SetViewFrameHeight(
self.overscrollActionView,
self.initialContentInset + statusBarFrame.size.height,
0);
self.panPointScreenOrigin = CGPointZero;
[[NSNotificationCenter defaultCenter]
postNotificationName:kOverscrollActionsDidEnd
......
......@@ -5,6 +5,7 @@
#import "ios/chrome/browser/ui/settings/bar_button_activity_indicator.h"
#include "ios/chrome/browser/ui/util/ui_util.h"
#include "ios/chrome/browser/ui/util/uikit_ui_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
......@@ -17,8 +18,7 @@
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
_activityIndicator = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
_activityIndicator = GetMediumUIActivityIndicatorView();
[_activityIndicator setBackgroundColor:[UIColor clearColor]];
[_activityIndicator setHidesWhenStopped:YES];
[_activityIndicator startAnimating];
......
......@@ -98,8 +98,7 @@
} else {
// For iOS 12 and lower the color should be always gray otherwise
// indicator is not visible.
_activityIndicator = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
_activityIndicator = GetMediumUIActivityIndicatorView();
}
_activityIndicator.translatesAutoresizingMaskIntoConstraints = NO;
_activityIndicator.hidden = YES;
......
......@@ -362,14 +362,14 @@ typedef NS_ENUM(NSInteger, ReauthenticationReason) {
if (![menu isMenuVisible]) {
menu.menuItems = [self menuItemsForItemType:itemType];
if (@available(iOS 13, *)) {
[menu showMenuFromView:tableView
rect:[tableView rectForRowAtIndexPath:indexPath]];
} else {
[menu setTargetRect:[tableView rectForRowAtIndexPath:indexPath]
inView:tableView];
[menu setMenuVisible:YES animated:YES];
}
#if !defined(__IPHONE_13_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_13_0
[menu setTargetRect:[tableView rectForRowAtIndexPath:indexPath]
inView:tableView];
[menu setMenuVisible:YES animated:YES];
#else
[menu showMenuFromView:tableView
rect:[tableView rectForRowAtIndexPath:indexPath]];
#endif
}
}
......
......@@ -419,8 +419,7 @@ const CGFloat kSpinnerButtonPadding = 18;
kSpinnerButtonCustomViewSize);
UIView* customView = [[UIView alloc] initWithFrame:customViewFrame];
UIActivityIndicatorView* spinner = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
UIActivityIndicatorView* spinner = GetMediumUIActivityIndicatorView();
CGRect spinnerFrame = [spinner bounds];
spinnerFrame.origin.x = kSpinnerButtonPadding;
......
......@@ -207,4 +207,12 @@ void RegisterEditMenuItem(UIMenuItem* item);
// the first (recursive) superview with no superview.
UIView* ViewHierarchyRootForView(UIView* view);
// Creates and inits a medium-sized UIActivityIndicatorView, regardless of iOS
// version.
UIActivityIndicatorView* GetMediumUIActivityIndicatorView();
// Creates and inits a large-sized UIActivityIndicatorView, regardless of iOS
// version.
UIActivityIndicatorView* GetLargeUIActivityIndicatorView();
#endif // IOS_CHROME_BROWSER_UI_UTIL_UIKIT_UI_UTIL_H_
......@@ -193,6 +193,26 @@ UIInterfaceOrientation GetInterfaceOrientation(UIWindow* window) {
#endif
}
UIActivityIndicatorView* GetMediumUIActivityIndicatorView() {
#if !defined(__IPHONE_13_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_13_0
return [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
#else
return [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleMedium];
#endif
}
UIActivityIndicatorView* GetLargeUIActivityIndicatorView() {
#if !defined(__IPHONE_13_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_13_0
return [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
#else
return [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleLarge];
#endif
}
CGFloat CurrentKeyboardHeight(NSValue* keyboardFrameValue) {
return [keyboardFrameValue CGRectValue].size.height;
}
......
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