Commit e68291f7 authored by Huanzhong Huang's avatar Huanzhong Huang Committed by Commit Bot

[iOS] Keep Separators from Being Hidden in CBD

In normal mode, a table view has such default behavior that a table
view cell's selectedBackgroundView hides its separator.

In order to conform to the new interface design and keeps separators
appearing (when cell in selected state), we discard the default
behavior and resort to manually maintain the backgroundColor of a
cell in the new Clear Browsing Data dialog.

Bug: 935346
Change-Id: Ia9decf2be993c2c61a53166e6892397dc0e5f5e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1591531Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Reviewed-by: default avatarChris Lu <thegreenfrog@chromium.org>
Commit-Queue: Huanzhong Huang <huanzhong@chromium.org>
Cr-Commit-Position: refs/heads/master@{#656450}
parent 21a302c5
...@@ -21,6 +21,10 @@ enum class BrowsingDataRemoveMask; ...@@ -21,6 +21,10 @@ enum class BrowsingDataRemoveMask;
// Whether or not the cell should show a checkmark. // Whether or not the cell should show a checkmark.
@property(nonatomic, assign) BOOL checked; @property(nonatomic, assign) BOOL checked;
// If not nil, specified color will be cell's backgroundColor
// when self.checked == YES
@property(nonatomic, strong) UIColor* checkedBackgroundColor;
// Mask of the data to be cleared. // Mask of the data to be cleared.
@property(nonatomic, assign) BrowsingDataRemoveMask dataTypeMask; @property(nonatomic, assign) BrowsingDataRemoveMask dataTypeMask;
......
...@@ -46,6 +46,10 @@ const CGFloat kImageHeight = 30; ...@@ -46,6 +46,10 @@ const CGFloat kImageHeight = 30;
image = [UIImage imageNamed:self.imageName]; image = [UIImage imageNamed:self.imageName];
} }
[cell setImage:image]; [cell setImage:image];
if (self.checkedBackgroundColor) {
// Overrides |styler|'s cellBackgroundColor (if set in the call to super).
cell.backgroundColor = self.checked ? self.checkedBackgroundColor : nil;
}
cell.textLabel.text = self.text; cell.textLabel.text = self.text;
cell.detailTextLabel.text = self.detailText; cell.detailTextLabel.text = self.detailText;
cell.optionalTextLabel.text = self.optionalText; cell.optionalTextLabel.text = self.optionalText;
......
...@@ -64,6 +64,9 @@ namespace { ...@@ -64,6 +64,9 @@ namespace {
const int kMaxTimesHistoryNoticeShown = 1; const int kMaxTimesHistoryNoticeShown = 1;
// The tableView button red background color. // The tableView button red background color.
const CGFloat kTableViewButtonBackgroundColor = 0xE94235; const CGFloat kTableViewButtonBackgroundColor = 0xE94235;
// Highlighted background color for cells in the Data Types section.
const CGFloat kCellHightlightedColorAlpha = 0.05;
const int kCellHighlightedColorRGB = 0x4285F4;
// List of flags that have corresponding counters. // List of flags that have corresponding counters.
const std::vector<BrowsingDataRemoveMask> _browsingDataRemoveFlags = { const std::vector<BrowsingDataRemoveMask> _browsingDataRemoveFlags = {
...@@ -491,6 +494,8 @@ static NSDictionary* _imageNamesByItemTypes = @{ ...@@ -491,6 +494,8 @@ static NSDictionary* _imageNamesByItemTypes = @{
tableViewClearDataItem.prefName = prefName; tableViewClearDataItem.prefName = prefName;
if (IsNewClearBrowsingDataUIEnabled()) { if (IsNewClearBrowsingDataUIEnabled()) {
tableViewClearDataItem.useCustomSeparator = YES; tableViewClearDataItem.useCustomSeparator = YES;
tableViewClearDataItem.checkedBackgroundColor =
UIColorFromRGB(kCellHighlightedColorRGB, kCellHightlightedColorAlpha);
tableViewClearDataItem.imageName = [_imageNamesByItemTypes tableViewClearDataItem.imageName = [_imageNamesByItemTypes
objectForKey:[NSNumber numberWithInteger:itemType]]; objectForKey:[NSNumber numberWithInteger:itemType]];
if (itemType == ItemTypeDataTypeCookiesSiteData) { if (itemType == ItemTypeDataTypeCookiesSiteData) {
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#import "ios/chrome/browser/ui/table_view/cells/table_view_text_button_item.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_text_button_item.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_text_link_item.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_text_link_item.h"
#import "ios/chrome/browser/ui/table_view/chrome_table_view_styler.h" #import "ios/chrome/browser/ui/table_view/chrome_table_view_styler.h"
#include "ios/chrome/browser/ui/util/uikit_ui_util.h"
#include "ios/chrome/grit/ios_chromium_strings.h" #include "ios/chrome/grit/ios_chromium_strings.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -35,11 +34,6 @@ ...@@ -35,11 +34,6 @@
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
namespace {
const CGFloat kCellHightlightColorAlpha = 0.05;
const int kCellHighlightColorRgb = 0x4285F4;
} // namespace
@interface ClearBrowsingDataTableViewController () < @interface ClearBrowsingDataTableViewController () <
TableViewTextLinkCellDelegate, TableViewTextLinkCellDelegate,
ClearBrowsingDataConsumer> ClearBrowsingDataConsumer>
...@@ -132,8 +126,6 @@ const int kCellHighlightColorRgb = 0x4285F4; ...@@ -132,8 +126,6 @@ const int kCellHighlightColorRgb = 0x4285F4;
[super viewDidLoad]; [super viewDidLoad];
if (IsNewClearBrowsingDataUIEnabled()) { if (IsNewClearBrowsingDataUIEnabled()) {
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.styler.cellHighlightColor =
UIColorFromRGB(kCellHighlightColorRgb, kCellHightlightColorAlpha);
} }
self.styler.tableViewBackgroundColor = UIColor.whiteColor; self.styler.tableViewBackgroundColor = UIColor.whiteColor;
self.tableView.accessibilityIdentifier = self.tableView.accessibilityIdentifier =
...@@ -264,6 +256,12 @@ const int kCellHighlightColorRgb = 0x4285F4; ...@@ -264,6 +256,12 @@ const int kCellHighlightColorRgb = 0x4285F4;
case ItemTypeDataTypeCache: case ItemTypeDataTypeCache:
case ItemTypeDataTypeSavedPasswords: case ItemTypeDataTypeSavedPasswords:
case ItemTypeDataTypeAutofill: case ItemTypeDataTypeAutofill:
// For these cells the selection style application is specified in the
// corresponding item definition.
if (IsNewClearBrowsingDataUIEnabled()) {
cellToReturn.selectionStyle = UITableViewCellSelectionStyleNone;
}
break;
default: default:
break; break;
} }
......
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