Commit b28c3398 authored by Eugene But's avatar Eugene But Committed by Commit Bot

Integrate Drive icon into New Download Manager UI.

This adds Drive icon below "Download state" icon.

UI Mocks: https://docs.google.com/presentation/d/1GzbAoJrpW9IAQF78afh5SZLWJWErNcC67t_ctujjEus/edit#slide=id.g2f6fee2339_3_0

Bug: 791806
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Id0405502a338aacfe4c2de331adbca89f1fe747e
Reviewed-on: https://chromium-review.googlesource.com/956700
Commit-Queue: Eugene But <eugenebut@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542811}
parent 907fc9ac
...@@ -630,6 +630,9 @@ locale. The strings in this file are specific to iOS. ...@@ -630,6 +630,9 @@ locale. The strings in this file are specific to iOS.
<message name="IDS_IOS_DOWNLOAD_MANAGER_UPLOAD_TO_GOOGLE_DRIVE" desc="Button for uploading a downloaded file to Google Drive. It's displayed on the dialog presented when no app on the device can open the file. [Length: 25em] [iOS only]"> <message name="IDS_IOS_DOWNLOAD_MANAGER_UPLOAD_TO_GOOGLE_DRIVE" desc="Button for uploading a downloaded file to Google Drive. It's displayed on the dialog presented when no app on the device can open the file. [Length: 25em] [iOS only]">
Upload to Google Drive Upload to Google Drive
</message> </message>
<message name="IDS_IOS_DOWNLOAD_MANAGER_GOOGLE_DRIVE" desc="Button for installing Google Drive app. Google Drive is a product name and should use the correct localized version of the product name. [Length: 25em] [iOS only]">
Google Drive
</message>
<message name="IDS_IOS_FACETIME_BUTTON" desc="Text in the confirmation dialog button that will initiate a FaceTime call for the presented number. [Length: 10em] [iOS only]"> <message name="IDS_IOS_FACETIME_BUTTON" desc="Text in the confirmation dialog button that will initiate a FaceTime call for the presented number. [Length: 10em] [iOS only]">
FaceTime FaceTime
</message> </message>
......
...@@ -44,6 +44,8 @@ source_set("download") { ...@@ -44,6 +44,8 @@ source_set("download") {
"//ios/chrome/browser/ui/presenters", "//ios/chrome/browser/ui/presenters",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
"//ios/chrome/browser/web:web_internal", "//ios/chrome/browser/web:web_internal",
"//ios/public/provider/chrome/browser",
"//ios/public/provider/chrome/browser/images",
"//ios/third_party/material_components_ios", "//ios/third_party/material_components_ios",
"//ios/third_party/material_roboto_font_loader_ios", "//ios/third_party/material_roboto_font_loader_ios",
"//ios/web", "//ios/web",
......
...@@ -68,6 +68,14 @@ extern NSString* const kDownloadManagerFailedImage; ...@@ -68,6 +68,14 @@ extern NSString* const kDownloadManagerFailedImage;
// setInstallGoogleDriveButtonVisible:animated: was called with YES. // setInstallGoogleDriveButtonVisible:animated: was called with YES.
@property(nonatomic, readonly) UIButton* installDriveButton; @property(nonatomic, readonly) UIButton* installDriveButton;
// Install Google Drive app icon. Only visible if
// setInstallGoogleDriveButtonVisible:animated: was called with YES.
@property(nonatomic, readonly) UIImageView* installDriveIcon;
// Install Google Drive label. Only visible if
// setInstallGoogleDriveButtonVisible:animated: was called with YES.
@property(nonatomic, readonly) UILabel* installDriveLabel;
// View that represents download progress. // View that represents download progress.
@property(nonatomic, readonly) RadialProgressView* progressView; @property(nonatomic, readonly) RadialProgressView* progressView;
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#import "ios/chrome/browser/ui/download/radial_progress_view.h" #import "ios/chrome/browser/ui/download/radial_progress_view.h"
#import "ios/chrome/browser/ui/util/named_guide.h" #import "ios/chrome/browser/ui/util/named_guide.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
#import "ios/public/provider/chrome/browser/images/branded_image_provider.h"
#import "ios/third_party/material_components_ios/src/components/Palettes/src/MaterialPalettes.h" #import "ios/third_party/material_components_ios/src/components/Palettes/src/MaterialPalettes.h"
#import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h" #import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h"
#include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/l10n/l10n_util_mac.h"
...@@ -45,6 +47,8 @@ NSString* GetSizeString(long long size_in_bytes) { ...@@ -45,6 +47,8 @@ NSString* GetSizeString(long long size_in_bytes) {
UILabel* _statusLabel; UILabel* _statusLabel;
UIButton* _actionButton; UIButton* _actionButton;
UIButton* _installDriveButton; UIButton* _installDriveButton;
UIImageView* _installDriveIcon;
UILabel* _installDriveLabel;
RadialProgressView* _progressView; RadialProgressView* _progressView;
NSString* _fileName; NSString* _fileName;
...@@ -107,6 +111,8 @@ NSString* GetSizeString(long long size_in_bytes) { ...@@ -107,6 +111,8 @@ NSString* GetSizeString(long long size_in_bytes) {
[self.downloadControlsRow addSubview:self.progressView]; [self.downloadControlsRow addSubview:self.progressView];
[self.downloadControlsRow addSubview:self.actionButton]; [self.downloadControlsRow addSubview:self.actionButton];
[self.installDriveControlsRow addSubview:self.installDriveButton]; [self.installDriveControlsRow addSubview:self.installDriveButton];
[self.installDriveControlsRow addSubview:self.installDriveIcon];
[self.installDriveControlsRow addSubview:self.installDriveLabel];
[self.installDriveControlsRow addSubview:self.horizontalLine]; [self.installDriveControlsRow addSubview:self.horizontalLine];
NamedGuide* actionButtonGuide = NamedGuide* actionButtonGuide =
...@@ -225,6 +231,29 @@ NSString* GetSizeString(long long size_in_bytes) { ...@@ -225,6 +231,29 @@ NSString* GetSizeString(long long size_in_bytes) {
constant:-kElementMargin], constant:-kElementMargin],
]]; ]];
// install google drive icon constraints.
UIImageView* installDriveIcon = self.installDriveIcon;
[NSLayoutConstraint activateConstraints:@[
[installDriveIcon.centerYAnchor
constraintEqualToAnchor:installDriveRow.centerYAnchor],
[installDriveIcon.leadingAnchor
constraintEqualToAnchor:installDriveRow.layoutMarginsGuide
.leadingAnchor],
]];
// install google drive label constraints.
UILabel* installDriveLabel = self.installDriveLabel;
[NSLayoutConstraint activateConstraints:@[
[installDriveLabel.centerYAnchor
constraintEqualToAnchor:installDriveRow.centerYAnchor],
[installDriveLabel.leadingAnchor
constraintEqualToAnchor:installDriveIcon.trailingAnchor
constant:kElementMargin],
[installDriveLabel.trailingAnchor
constraintLessThanOrEqualToAnchor:installDriveButton.leadingAnchor
constant:-kElementMargin],
]];
// constraint line which separates download controls and install drive rows. // constraint line which separates download controls and install drive rows.
UIView* horizontalLine = self.horizontalLine; UIView* horizontalLine = self.horizontalLine;
[NSLayoutConstraint activateConstraints:@[ [NSLayoutConstraint activateConstraints:@[
...@@ -401,6 +430,29 @@ NSString* GetSizeString(long long size_in_bytes) { ...@@ -401,6 +430,29 @@ NSString* GetSizeString(long long size_in_bytes) {
return _installDriveButton; return _installDriveButton;
} }
- (UIImageView*)installDriveIcon {
if (!_installDriveIcon) {
_installDriveIcon = [[UIImageView alloc] initWithFrame:CGRectZero];
_installDriveIcon.translatesAutoresizingMaskIntoConstraints = NO;
_installDriveIcon.image = ios::GetChromeBrowserProvider()
->GetBrandedImageProvider()
->GetDownloadGoogleDriveImage();
}
return _installDriveIcon;
}
- (UILabel*)installDriveLabel {
if (!_installDriveLabel) {
_installDriveLabel = [[UILabel alloc] initWithFrame:CGRectZero];
_installDriveLabel.translatesAutoresizingMaskIntoConstraints = NO;
_installDriveLabel.font = [MDCTypography subheadFont];
_installDriveLabel.text =
l10n_util::GetNSString(IDS_IOS_DOWNLOAD_MANAGER_GOOGLE_DRIVE);
[_installDriveLabel sizeToFit];
}
return _installDriveLabel;
}
- (RadialProgressView*)progressView { - (RadialProgressView*)progressView {
if (!_progressView) { if (!_progressView) {
_progressView = [[RadialProgressView alloc] initWithFrame:CGRectZero]; _progressView = [[RadialProgressView alloc] initWithFrame:CGRectZero];
......
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