Commit f2072e2f authored by Stepan Khapugin's avatar Stepan Khapugin Committed by Chromium LUCI CQ

[iOS][Getaway] Improve the locking UI and add it to Showcase.

Adds the Getaway UI to showcase for convenient debugging/iteration.
Improves the UI per new mocks. Capitalizes an existing string (no need
to re-translate, only capitalization in En-US changed).
Makes the blur less transparent by adding a black semi-transparent view
below it.

Bug: none
Change-Id: I69f9fb932b210143780a9be736201daa6be0a689
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2602418
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840212}
parent bbe6f2f3
...@@ -946,7 +946,7 @@ Because your account is managed by <ph name="HOSTED_DOMAIN">$1<ex>google.com</ex ...@@ -946,7 +946,7 @@ Because your account is managed by <ph name="HOSTED_DOMAIN">$1<ex>google.com</ex
Unlock Incognito Tabs With <ph name="BIOMETRIC_AUTHENITCATION_TYPE">$1<ex>Face ID</ex></ph> Unlock Incognito Tabs With <ph name="BIOMETRIC_AUTHENITCATION_TYPE">$1<ex>Face ID</ex></ph>
</message> </message>
<message name="IDS_IOS_INCOGNITO_REAUTH_SETTING_NAME" desc="Name of the Setting to protect incognito tabs with biometric authentication, e.g. Face ID or Touch ID. [iOS only]"> <message name="IDS_IOS_INCOGNITO_REAUTH_SETTING_NAME" desc="Name of the Setting to protect incognito tabs with biometric authentication, e.g. Face ID or Touch ID. [iOS only]">
Lock Incognito tabs when you close Chrome Lock Incognito Tabs When You Close Chrome
</message> </message>
<message name="IDS_IOS_INCOGNITO_REAUTH_PASSCODE" desc="The passcode (pin code or password) used instead of biometric authentication, e.g. Face ID or Touch ID, for device authentication. [iOS only]"> <message name="IDS_IOS_INCOGNITO_REAUTH_PASSCODE" desc="The passcode (pin code or password) used instead of biometric authentication, e.g. Face ID or Touch ID, for device authentication. [iOS only]">
Passcode Passcode
......
4f06b511b226e1cccc3abacd6362998af0c1703c 58532f8ae7bc67e05f952fdf67525539fa188ed3
\ No newline at end of file \ No newline at end of file
...@@ -36,6 +36,7 @@ source_set("incognito_reauth_ui") { ...@@ -36,6 +36,7 @@ source_set("incognito_reauth_ui") {
deps = [ deps = [
":incognito_reauth_util", ":incognito_reauth_util",
"//ios/chrome/app/strings:ios_strings_grit", "//ios/chrome/app/strings:ios_strings_grit",
"//ios/chrome/browser/ui/incognito_reauth/resources:incognito_logo_reauth",
"//ios/chrome/common/ui/util", "//ios/chrome/common/ui/util",
"//ui/base", "//ui/base",
] ]
......
...@@ -15,9 +15,11 @@ ...@@ -15,9 +15,11 @@
#endif #endif
namespace { namespace {
const CGFloat kButtonHeight = 60.0f; // Button content padding (Vertical and Horizontal).
const CGFloat kButtonWidth = 190.0f; const CGFloat kButtonPaddingV = 15.0f;
const CGFloat kButtonSpacing = 16.0f; const CGFloat kButtonPaddingH = 38.0f;
// Distance from top and bottom to content (buttons/logos).
const CGFloat kVerticalContentPadding = 70.0f;
} // namespace } // namespace
@implementation IncognitoReauthView @implementation IncognitoReauthView
...@@ -25,6 +27,14 @@ const CGFloat kButtonSpacing = 16.0f; ...@@ -25,6 +27,14 @@ const CGFloat kButtonSpacing = 16.0f;
- (instancetype)init { - (instancetype)init {
self = [super init]; self = [super init];
if (self) { if (self) {
// Add a dark view to block the content better. Using only a blur view
// (below) might be too revealing.
UIView* darkBackgroundView = [[UIView alloc] init];
darkBackgroundView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.8];
[self addSubview:darkBackgroundView];
darkBackgroundView.translatesAutoresizingMaskIntoConstraints = NO;
AddSameConstraints(self, darkBackgroundView);
UIBlurEffect* blurEffect = UIBlurEffect* blurEffect =
[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
UIVisualEffectView* blurBackgroundView = UIVisualEffectView* blurBackgroundView =
...@@ -37,30 +47,48 @@ const CGFloat kButtonSpacing = 16.0f; ...@@ -37,30 +47,48 @@ const CGFloat kButtonSpacing = 16.0f;
blurBackgroundView.isAccessibilityElement = YES; blurBackgroundView.isAccessibilityElement = YES;
AddSameConstraints(self, blurBackgroundView); AddSameConstraints(self, blurBackgroundView);
UIImage* incognitoLogo = [UIImage imageNamed:@"incognito_logo_reauth"];
UIImageView* logoView = [[UIImageView alloc] initWithImage:incognitoLogo];
logoView.translatesAutoresizingMaskIntoConstraints = NO;
[blurBackgroundView.contentView addSubview:logoView];
AddSameCenterXConstraint(logoView, blurBackgroundView);
[logoView.topAnchor
constraintEqualToAnchor:blurBackgroundView.safeAreaLayoutGuide.topAnchor
constant:kVerticalContentPadding]
.active = YES;
NSString* unlockButtonTitle = l10n_util::GetNSStringF( NSString* unlockButtonTitle = l10n_util::GetNSStringF(
IDS_IOS_INCOGNITO_REAUTH_UNLOCK_BUTTON, IDS_IOS_INCOGNITO_REAUTH_UNLOCK_BUTTON,
base::SysNSStringToUTF16(biometricAuthenticationTypeString())); base::SysNSStringToUTF16(biometricAuthenticationTypeString()));
_authenticateButton = _authenticateButton =
[IncognitoReauthView newRoundButtonWithBlurEffect:blurEffect]; [IncognitoReauthView newRoundButtonWithBlurEffect:blurEffect];
[_authenticateButton setTitle:unlockButtonTitle [_authenticateButton setTitle:unlockButtonTitle
forState:UIControlStateNormal]; forState:UIControlStateNormal];
_authenticateButton.accessibilityLabel = l10n_util::GetNSStringF( _authenticateButton.accessibilityLabel = l10n_util::GetNSStringF(
IDS_IOS_INCOGNITO_REAUTH_UNLOCK_BUTTON_VOICEOVER_LABEL, IDS_IOS_INCOGNITO_REAUTH_UNLOCK_BUTTON_VOICEOVER_LABEL,
base::SysNSStringToUTF16(biometricAuthenticationTypeString())); base::SysNSStringToUTF16(biometricAuthenticationTypeString()));
_tabSwitcherButton = _tabSwitcherButton = [[UIButton alloc] init];
[IncognitoReauthView newRoundButtonWithBlurEffect:blurEffect]; _tabSwitcherButton.translatesAutoresizingMaskIntoConstraints = NO;
[_tabSwitcherButton setTitleColor:[UIColor whiteColor]
forState:UIControlStateNormal];
[_tabSwitcherButton setTitle:l10n_util::GetNSString( [_tabSwitcherButton setTitle:l10n_util::GetNSString(
IDS_IOS_INCOGNITO_REAUTH_GO_TO_NORMAL_TABS) IDS_IOS_INCOGNITO_REAUTH_GO_TO_NORMAL_TABS)
forState:UIControlStateNormal]; forState:UIControlStateNormal];
_tabSwitcherButton.titleLabel.font =
UIStackView* stackView = [[UIStackView alloc] [UIFont preferredFontForTextStyle:UIFontTextStyleTitle2];
initWithArrangedSubviews:@[ _authenticateButton, _tabSwitcherButton ]];
stackView.axis = UILayoutConstraintAxisVertical; [blurBackgroundView.contentView addSubview:_authenticateButton];
stackView.translatesAutoresizingMaskIntoConstraints = NO; AddSameCenterConstraints(blurBackgroundView, _authenticateButton);
stackView.spacing = kButtonSpacing;
[self addSubview:stackView]; [blurBackgroundView.contentView addSubview:_tabSwitcherButton];
AddSameCenterConstraints(blurBackgroundView, stackView); AddSameCenterXConstraint(_tabSwitcherButton, blurBackgroundView);
[_tabSwitcherButton.topAnchor
constraintEqualToAnchor:blurBackgroundView.safeAreaLayoutGuide
.bottomAnchor
constant:-kVerticalContentPadding]
.active = YES;
} }
return self; return self;
...@@ -69,11 +97,18 @@ const CGFloat kButtonSpacing = 16.0f; ...@@ -69,11 +97,18 @@ const CGFloat kButtonSpacing = 16.0f;
+ (UIButton*)newRoundButtonWithBlurEffect:(UIBlurEffect*)blurEffect { + (UIButton*)newRoundButtonWithBlurEffect:(UIBlurEffect*)blurEffect {
UIButton* button = [[UIButton alloc] init]; UIButton* button = [[UIButton alloc] init];
button.backgroundColor = [UIColor clearColor]; button.backgroundColor = [UIColor clearColor];
button.titleLabel.font =
[NSLayoutConstraint activateConstraints:@[ [UIFont preferredFontForTextStyle:UIFontTextStyleTitle2];
[button.heightAnchor constraintEqualToConstant:kButtonHeight], button.contentEdgeInsets = UIEdgeInsetsMake(kButtonPaddingV, kButtonPaddingH,
[button.widthAnchor constraintEqualToConstant:kButtonWidth], kButtonPaddingV, kButtonPaddingH);
]]; [button
setContentCompressionResistancePriority:UILayoutPriorityRequired
forAxis:UILayoutConstraintAxisHorizontal];
[button
setContentCompressionResistancePriority:UILayoutPriorityRequired
forAxis:UILayoutConstraintAxisVertical];
button.translatesAutoresizingMaskIntoConstraints = NO;
[button sizeToFit];
UIView* backgroundView = nil; UIView* backgroundView = nil;
if (@available(iOS 13, *)) { if (@available(iOS 13, *)) {
...@@ -85,7 +120,7 @@ const CGFloat kButtonSpacing = 16.0f; ...@@ -85,7 +120,7 @@ const CGFloat kButtonSpacing = 16.0f;
backgroundView = [[UIView alloc] init]; backgroundView = [[UIView alloc] init];
} }
backgroundView.backgroundColor = [UIColor colorWithWhite:1 alpha:0.2]; backgroundView.backgroundColor = [UIColor colorWithWhite:1 alpha:0.2];
backgroundView.layer.cornerRadius = kButtonHeight / 2; backgroundView.layer.cornerRadius = button.frame.size.height / 2;
backgroundView.translatesAutoresizingMaskIntoConstraints = NO; backgroundView.translatesAutoresizingMaskIntoConstraints = NO;
backgroundView.userInteractionEnabled = NO; backgroundView.userInteractionEnabled = NO;
[button addSubview:backgroundView]; [button addSubview:backgroundView];
......
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/ios/asset_catalog.gni")
imageset("incognito_logo_reauth") {
sources = [
"incognito_logo_reauth.imageset/Contents.json",
"incognito_logo_reauth.imageset/incognito_logo_reauth@2x.png",
"incognito_logo_reauth.imageset/incognito_logo_reauth@3x.png",
]
}
{
"images": [
{
"idiom": "universal",
"scale": "2x",
"filename": "incognito_logo_reauth@2x.png"
},
{
"idiom": "universal",
"scale": "3x",
"filename": "incognito_logo_reauth@3x.png"
}
],
"info": {
"version": 1,
"author": "xcode"
}
}
...@@ -48,6 +48,7 @@ namespace { ...@@ -48,6 +48,7 @@ namespace {
typedef NS_ENUM(NSInteger, SectionIdentifier) { typedef NS_ENUM(NSInteger, SectionIdentifier) {
SectionIdentifierPrivacyContent = kSectionIdentifierEnumZero, SectionIdentifierPrivacyContent = kSectionIdentifierEnumZero,
SectionIdentifierWebServices, SectionIdentifierWebServices,
SectionIdentifierIncognitoAuth,
}; };
...@@ -151,6 +152,9 @@ const char kGoogleServicesSettingsURL[] = "settings://open_google_services"; ...@@ -151,6 +152,9 @@ const char kGoogleServicesSettingsURL[] = "settings://open_google_services";
TableViewModel* model = self.tableViewModel; TableViewModel* model = self.tableViewModel;
[model addSectionWithIdentifier:SectionIdentifierPrivacyContent]; [model addSectionWithIdentifier:SectionIdentifierPrivacyContent];
[model addSectionWithIdentifier:SectionIdentifierWebServices]; [model addSectionWithIdentifier:SectionIdentifierWebServices];
if (base::FeatureList::IsEnabled(kIncognitoAuthentication)) {
[model addSectionWithIdentifier:SectionIdentifierIncognitoAuth];
}
// Clear Browsing item. // Clear Browsing item.
[model addItem:[self clearBrowsingDetailItem] [model addItem:[self clearBrowsingDetailItem]
...@@ -166,7 +170,7 @@ const char kGoogleServicesSettingsURL[] = "settings://open_google_services"; ...@@ -166,7 +170,7 @@ const char kGoogleServicesSettingsURL[] = "settings://open_google_services";
if (base::FeatureList::IsEnabled(kIncognitoAuthentication)) { if (base::FeatureList::IsEnabled(kIncognitoAuthentication)) {
// Incognito authentication item. // Incognito authentication item.
[model addItem:self.incognitoReauthItem [model addItem:self.incognitoReauthItem
toSectionWithIdentifier:SectionIdentifierWebServices]; toSectionWithIdentifier:SectionIdentifierIncognitoAuth];
} }
} }
......
...@@ -30,6 +30,7 @@ group("features") { ...@@ -30,6 +30,7 @@ group("features") {
"//ios/showcase/bubble", "//ios/showcase/bubble",
"//ios/showcase/content_suggestions", "//ios/showcase/content_suggestions",
"//ios/showcase/credential_provider", "//ios/showcase/credential_provider",
"//ios/showcase/incognito_reauth",
"//ios/showcase/infobars", "//ios/showcase/infobars",
"//ios/showcase/omnibox_popup", "//ios/showcase/omnibox_popup",
"//ios/showcase/recent_tabs", "//ios/showcase/recent_tabs",
......
...@@ -162,6 +162,11 @@ ...@@ -162,6 +162,11 @@
kClassForInstantiationKey : @"SCInfobarModalSaveCardCoordinator", kClassForInstantiationKey : @"SCInfobarModalSaveCardCoordinator",
showcase::kUseCaseKey : @"Save Card Modal", showcase::kUseCaseKey : @"Save Card Modal",
}, },
@{
showcase::kClassForDisplayKey : @"SCIncognitoReauthViewController",
showcase::kClassForInstantiationKey : @"SCIncognitoReauthViewController",
showcase::kUseCaseKey : @"Incognito Reauth Blocker",
},
]; ];
} }
......
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
source_set("incognito_reauth") {
sources = [
"sc_incognito_reauth_view_controller.h",
"sc_incognito_reauth_view_controller.mm",
]
deps = [
"//base",
"//ios/chrome/browser/ui/incognito_reauth:incognito_reauth_ui",
"//ios/showcase/common",
]
frameworks = [ "UIKit.framework" ]
configs += [ "//build/config/compiler:enable_arc" ]
}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_SHOWCASE_INCOGNITO_REAUTH_SC_INCOGNITO_REAUTH_VIEW_CONTROLLER_H_
#define IOS_SHOWCASE_INCOGNITO_REAUTH_SC_INCOGNITO_REAUTH_VIEW_CONTROLLER_H_
#import <UIKit/UIKit.h>
@interface SCIncognitoReauthViewController : UIViewController
@end
#endif // IOS_SHOWCASE_INCOGNITO_REAUTH_SC_INCOGNITO_REAUTH_VIEW_CONTROLLER_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/showcase/incognito_reauth/sc_incognito_reauth_view_controller.h"
#import "ios/chrome/browser/ui/incognito_reauth/incognito_reauth_view.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation SCIncognitoReauthViewController
- (void)loadView {
self.view = [[IncognitoReauthView alloc] init];
}
@end
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