Commit f0db4720 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Convert DataplanVC to TableView

This CL converts the DataplanUsageCollectionViewController to
UITableViewController.
It also adds the cellBackgroundColor property to the styler so the cells
can have a background color different from the table view's background.
It also adds an accessoryType for the DetailTextItem.

Bug: 894791
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: Ie1332811d3df6d8ef7650fb34fa3a17a515da3d9
Reviewed-on: https://chromium-review.googlesource.com/c/1286142
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601109}
parent 12076064
......@@ -42,8 +42,8 @@ source_set("settings") {
"compose_email_handler_collection_view_controller.mm",
"content_settings_collection_view_controller.h",
"content_settings_collection_view_controller.mm",
"dataplan_usage_collection_view_controller.h",
"dataplan_usage_collection_view_controller.mm",
"dataplan_usage_table_view_controller.h",
"dataplan_usage_table_view_controller.mm",
"google_services_navigation_coordinator.h",
"google_services_navigation_coordinator.mm",
"google_services_settings_consumer.h",
......@@ -278,7 +278,7 @@ source_set("unit_tests") {
"clear_browsing_data_manager_unittest.mm",
"compose_email_handler_collection_view_controller_unittest.mm",
"content_settings_collection_view_controller_unittest.mm",
"dataplan_usage_collection_view_controller_unittest.mm",
"dataplan_usage_table_view_controller_unittest.mm",
"import_data_collection_view_controller_unittest.mm",
"password_details_collection_view_controller_unittest.mm",
"password_exporter_unittest.mm",
......
......@@ -11,7 +11,7 @@
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/pref_names.h"
#import "ios/chrome/browser/ui/settings/cells/settings_detail_item.h"
#import "ios/chrome/browser/ui/settings/dataplan_usage_collection_view_controller.h"
#import "ios/chrome/browser/ui/settings/dataplan_usage_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/settings_utils.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_link_header_footer_item.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_text_header_footer_item.h"
......@@ -126,12 +126,11 @@ typedef NS_ENUM(NSInteger, ItemType) {
if (type == ItemTypePreload) {
NSString* preloadTitle =
l10n_util::GetNSString(IDS_IOS_OPTIONS_PRELOAD_WEBPAGES);
UIViewController* controller =
[[DataplanUsageCollectionViewController alloc]
initWithPrefs:_browserState->GetPrefs()
basePref:prefs::kNetworkPredictionEnabled
wifiPref:prefs::kNetworkPredictionWifiOnly
title:preloadTitle];
UIViewController* controller = [[DataplanUsageTableViewController alloc]
initWithPrefs:_browserState->GetPrefs()
basePref:prefs::kNetworkPredictionEnabled
wifiPref:prefs::kNetworkPredictionWifiOnly
title:preloadTitle];
[self.navigationController pushViewController:controller animated:YES];
}
}
......@@ -141,7 +140,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
- (void)onPreferenceChanged:(const std::string&)preferenceName {
if (preferenceName == prefs::kNetworkPredictionEnabled ||
preferenceName == prefs::kNetworkPredictionWifiOnly) {
NSString* detailText = [DataplanUsageCollectionViewController
NSString* detailText = [DataplanUsageTableViewController
currentLabelForPreference:_browserState->GetPrefs()
basePref:prefs::kNetworkPredictionEnabled
wifiPref:prefs::kNetworkPredictionWifiOnly];
......@@ -156,7 +155,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
// Returns a newly created SettingsDetailItem for the preload webpages menu.
- (SettingsDetailItem*)preloadWebpagesItem {
NSString* detailText = [DataplanUsageCollectionViewController
NSString* detailText = [DataplanUsageTableViewController
currentLabelForPreference:_browserState->GetPrefs()
basePref:prefs::kNetworkPredictionEnabled
wifiPref:prefs::kNetworkPredictionWifiOnly];
......
......@@ -16,7 +16,7 @@
#include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
#include "ios/chrome/browser/pref_names.h"
#include "ios/chrome/browser/prefs/browser_prefs.h"
#import "ios/chrome/browser/ui/settings/dataplan_usage_collection_view_controller.h"
#import "ios/chrome/browser/ui/settings/dataplan_usage_table_view_controller.h"
#import "ios/chrome/browser/ui/table_view/chrome_table_view_controller_test.h"
#import "ios/chrome/browser/ui/table_view/table_view_model.h"
#include "ios/chrome/grit/ios_strings.h"
......@@ -80,7 +80,7 @@ TEST_F(BandwidthManagementTableViewControllerTest, TestModel) {
// Preload webpages item.
NSString* expected_title =
l10n_util::GetNSString(IDS_IOS_OPTIONS_PRELOAD_WEBPAGES);
NSString* expected_subtitle = [DataplanUsageCollectionViewController
NSString* expected_subtitle = [DataplanUsageTableViewController
currentLabelForPreference:chrome_browser_state_->GetPrefs()
basePref:prefs::kNetworkPredictionEnabled
wifiPref:prefs::kNetworkPredictionWifiOnly];
......
......@@ -2,25 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_DATAPLAN_USAGE_COLLECTION_VIEW_CONTROLLER_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_DATAPLAN_USAGE_COLLECTION_VIEW_CONTROLLER_H_
#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_DATAPLAN_USAGE_TABLE_VIEW_CONTROLLER_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_DATAPLAN_USAGE_TABLE_VIEW_CONTROLLER_H_
#import "ios/chrome/browser/ui/settings/settings_root_collection_view_controller.h"
#import "ios/chrome/browser/ui/settings/settings_root_table_view_controller.h"
class PrefService;
// Class that handles the UI and preference setting for options that require
// three states: 'Always', 'Only on WiFi', and 'Never'.
@interface DataplanUsageCollectionViewController
: SettingsRootCollectionViewController
@interface DataplanUsageTableViewController : SettingsRootTableViewController
- (instancetype)initWithPrefs:(PrefService*)prefs
basePref:(const char*)basePreference
wifiPref:(const char*)wifiPreference
title:(NSString*)title NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithLayout:(UICollectionViewLayout*)layout
style:(CollectionViewControllerStyle)style
- (instancetype)initWithTableViewStyle:(UITableViewStyle)style
appBarStyle:
(ChromeTableViewControllerStyle)appBarStyle
NS_UNAVAILABLE;
// Returns the text for the current setting, based on the values of the
......@@ -31,4 +31,4 @@ class PrefService;
wifiPref:(const char*)wifiPreference;
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_DATAPLAN_USAGE_COLLECTION_VIEW_CONTROLLER_H_
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_DATAPLAN_USAGE_TABLE_VIEW_CONTROLLER_H_
......@@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/ui/settings/dataplan_usage_collection_view_controller.h"
#import "ios/chrome/browser/ui/settings/dataplan_usage_table_view_controller.h"
#include "base/logging.h"
#import "base/mac/foundation_util.h"
#include "components/prefs/pref_member.h"
#include "components/prefs/pref_service.h"
#import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
#import "ios/chrome/browser/ui/settings/cells/settings_text_item.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_detail_text_item.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_text_item.h"
#import "ios/chrome/browser/ui/table_view/chrome_table_view_styler.h"
#include "ios/chrome/grit/ios_strings.h"
#import "ios/third_party/material_components_ios/src/components/CollectionCells/src/MaterialCollectionCells.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/l10n_util_mac.h"
......@@ -33,7 +33,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
} // namespace.
@interface DataplanUsageCollectionViewController () {
@interface DataplanUsageTableViewController () {
BooleanPrefMember basePreference_;
BooleanPrefMember wifiPreference_;
}
......@@ -45,7 +45,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
- (void)updateBasePref:(BOOL)basePref wifiPref:(BOOL)wifiPref;
@end
@implementation DataplanUsageCollectionViewController
@implementation DataplanUsageTableViewController
#pragma mark - Initialization
......@@ -53,40 +53,45 @@ typedef NS_ENUM(NSInteger, ItemType) {
basePref:(const char*)basePreference
wifiPref:(const char*)wifiPreference
title:(NSString*)title {
UICollectionViewLayout* layout = [[MDCCollectionViewFlowLayout alloc] init];
self =
[super initWithLayout:layout style:CollectionViewControllerStyleAppBar];
[super initWithTableViewStyle:UITableViewStyleGrouped
appBarStyle:ChromeTableViewControllerStyleWithAppBar];
if (self) {
self.title = title;
basePreference_.Init(basePreference, prefs);
wifiPreference_.Init(wifiPreference, prefs);
// TODO(crbug.com/764578): -loadModel should not be called from
// initializer. A possible fix is to move this call to -viewDidLoad.
[self loadModel];
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.estimatedRowHeight = 70;
self.tableView.rowHeight = UITableViewAutomaticDimension;
[self loadModel];
}
- (void)loadModel {
[super loadModel];
CollectionViewModel* model = self.collectionViewModel;
self.styler.cellTitleColor = [UIColor blackColor];
TableViewModel<TableViewItem*>* model = self.tableViewModel;
[model addSectionWithIdentifier:SectionIdentifierOptions];
SettingsTextItem* always =
[[SettingsTextItem alloc] initWithType:ItemTypeOptionsAlways];
TableViewDetailTextItem* always =
[[TableViewDetailTextItem alloc] initWithType:ItemTypeOptionsAlways];
[always setText:l10n_util::GetNSString(IDS_IOS_OPTIONS_DATA_USAGE_ALWAYS)];
[always setAccessibilityTraits:UIAccessibilityTraitButton];
[model addItem:always toSectionWithIdentifier:SectionIdentifierOptions];
SettingsTextItem* wifi =
[[SettingsTextItem alloc] initWithType:ItemTypeOptionsOnlyOnWiFi];
TableViewDetailTextItem* wifi =
[[TableViewDetailTextItem alloc] initWithType:ItemTypeOptionsOnlyOnWiFi];
[wifi setText:l10n_util::GetNSString(IDS_IOS_OPTIONS_DATA_USAGE_ONLY_WIFI)];
[wifi setAccessibilityTraits:UIAccessibilityTraitButton];
[model addItem:wifi toSectionWithIdentifier:SectionIdentifierOptions];
SettingsTextItem* never =
[[SettingsTextItem alloc] initWithType:ItemTypeOptionsNever];
TableViewDetailTextItem* never =
[[TableViewDetailTextItem alloc] initWithType:ItemTypeOptionsNever];
[never setText:l10n_util::GetNSString(IDS_IOS_OPTIONS_DATA_USAGE_NEVER)];
[never setAccessibilityTraits:UIAccessibilityTraitButton];
[model addItem:never toSectionWithIdentifier:SectionIdentifierOptions];
......@@ -97,7 +102,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
- (void)updateCheckedState {
BOOL basePrefOn = basePreference_.GetValue();
BOOL wifiPrefOn = wifiPreference_.GetValue();
CollectionViewModel* model = self.collectionViewModel;
TableViewModel<TableViewItem*>* model = self.tableViewModel;
std::unordered_map<NSInteger, bool> optionsMap = {
{ItemTypeOptionsAlways, basePrefOn && !wifiPrefOn},
......@@ -106,14 +111,14 @@ typedef NS_ENUM(NSInteger, ItemType) {
};
NSMutableArray* modifiedItems = [NSMutableArray array];
for (SettingsTextItem* item in
for (TableViewDetailTextItem* item in
[model itemsInSectionWithIdentifier:SectionIdentifierOptions]) {
auto value = optionsMap.find(item.type);
DCHECK(value != optionsMap.end());
MDCCollectionViewCellAccessoryType desiredType =
value->second ? MDCCollectionViewCellAccessoryCheckmark
: MDCCollectionViewCellAccessoryNone;
UITableViewCellAccessoryType desiredType =
value->second ? UITableViewCellAccessoryCheckmark
: UITableViewCellAccessoryNone;
if (item.accessoryType != desiredType) {
item.accessoryType = desiredType;
[modifiedItems addObject:item];
......@@ -145,13 +150,11 @@ typedef NS_ENUM(NSInteger, ItemType) {
return l10n_util::GetNSString(IDS_IOS_OPTIONS_DATA_USAGE_NEVER);
}
#pragma mark - UICollectionViewDelegate
#pragma mark - UITableViewDelegate
- (void)collectionView:(UICollectionView*)collectionView
didSelectItemAtIndexPath:(NSIndexPath*)indexPath {
[super collectionView:collectionView didSelectItemAtIndexPath:indexPath];
NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath];
- (void)tableView:(UITableView*)tableView
didSelectRowAtIndexPath:(NSIndexPath*)indexPath {
NSInteger type = [self.tableViewModel itemTypeForIndexPath:indexPath];
switch (type) {
case ItemTypeOptionsAlways:
[self updateBasePref:YES wifiPref:NO];
......@@ -163,6 +166,8 @@ typedef NS_ENUM(NSInteger, ItemType) {
[self updateBasePref:NO wifiPref:NO];
break;
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
@end
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/ui/settings/dataplan_usage_collection_view_controller.h"
#import "ios/chrome/browser/ui/settings/dataplan_usage_table_view_controller.h"
#include <memory>
......@@ -13,8 +13,8 @@
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "components/sync_preferences/pref_service_mock_factory.h"
#import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h"
#import "ios/chrome/browser/ui/settings/cells/settings_text_item.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_detail_text_item.h"
#import "ios/chrome/browser/ui/table_view/chrome_table_view_controller_test.h"
#include "ios/chrome/grit/ios_strings.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util_mac.h"
......@@ -23,7 +23,7 @@
#error "This file requires ARC support."
#endif
@interface DataplanUsageCollectionViewController (ExposedForTesting)
@interface DataplanUsageTableViewController (ExposedForTesting)
- (void)updateBasePref:(BOOL)basePref wifiPref:(BOOL)wifiPref;
@end
......@@ -32,17 +32,17 @@ namespace {
const char* kBasePref = "BasePref";
const char* kWifiPref = "WifiPref";
class DataplanUsageCollectionViewControllerTest
: public CollectionViewControllerTest {
class DataplanUsageTableViewControllerTest
: public ChromeTableViewControllerTest {
protected:
void SetUp() override {
CollectionViewControllerTest::SetUp();
ChromeTableViewControllerTest::SetUp();
pref_service_ = CreateLocalState();
CreateController();
}
CollectionViewController* InstantiateController() override {
dataplanController_ = [[DataplanUsageCollectionViewController alloc]
ChromeTableViewController* InstantiateController() override {
dataplanController_ = [[DataplanUsageTableViewController alloc]
initWithPrefs:pref_service_.get()
basePref:kBasePref
wifiPref:kWifiPref
......@@ -56,65 +56,64 @@ class DataplanUsageCollectionViewControllerTest
registry->RegisterBooleanPref(kWifiPref, false);
sync_preferences::PrefServiceMockFactory factory;
base::FilePath path("DataplanUsageCollectionViewControllerTest.pref");
base::FilePath path("DataplanUsageTableViewControllerTest.pref");
factory.SetUserPrefsFile(path, message_loop_.task_runner().get());
return factory.Create(registry.get());
}
// Verifies that the cell at |item| in |section| has the given |accessory|
// type.
void CheckTextItemAccessoryType(
MDCCollectionViewCellAccessoryType accessory_type,
int section,
int item) {
SettingsTextItem* cell = GetCollectionViewItem(section, item);
void CheckTextItemAccessoryType(UITableViewCellAccessoryType accessory_type,
int section,
int item) {
TableViewDetailTextItem* cell = GetTableViewItem(section, item);
EXPECT_EQ(accessory_type, cell.accessoryType);
}
base::MessageLoopForUI message_loop_;
std::unique_ptr<PrefService> pref_service_;
DataplanUsageCollectionViewController* dataplanController_;
DataplanUsageTableViewController* dataplanController_;
};
TEST_F(DataplanUsageCollectionViewControllerTest, TestModel) {
TEST_F(DataplanUsageTableViewControllerTest, TestModel) {
CheckController();
EXPECT_EQ(1, NumberOfSections());
// No section header + 3 rows
EXPECT_EQ(3, NumberOfItemsInSection(0));
CheckTextItemAccessoryType(MDCCollectionViewCellAccessoryNone, 0, 0);
CheckTextItemAccessoryType(MDCCollectionViewCellAccessoryNone, 0, 1);
CheckTextItemAccessoryType(MDCCollectionViewCellAccessoryCheckmark, 0, 2);
CheckTextItemAccessoryType(UITableViewCellAccessoryNone, 0, 0);
CheckTextItemAccessoryType(UITableViewCellAccessoryNone, 0, 1);
CheckTextItemAccessoryType(UITableViewCellAccessoryCheckmark, 0, 2);
CheckTextCellTitleWithId(IDS_IOS_OPTIONS_DATA_USAGE_ALWAYS, 0, 0);
CheckTextCellTitleWithId(IDS_IOS_OPTIONS_DATA_USAGE_ONLY_WIFI, 0, 1);
CheckTextCellTitleWithId(IDS_IOS_OPTIONS_DATA_USAGE_NEVER, 0, 2);
CheckTextCellTextWithId(IDS_IOS_OPTIONS_DATA_USAGE_ALWAYS, 0, 0);
CheckTextCellTextWithId(IDS_IOS_OPTIONS_DATA_USAGE_ONLY_WIFI, 0, 1);
CheckTextCellTextWithId(IDS_IOS_OPTIONS_DATA_USAGE_NEVER, 0, 2);
}
TEST_F(DataplanUsageCollectionViewControllerTest, TestUpdateCheckedState) {
TEST_F(DataplanUsageTableViewControllerTest, TestUpdateCheckedState) {
CheckController();
ASSERT_EQ(1, NumberOfSections());
ASSERT_EQ(3, NumberOfItemsInSection(0));
[dataplanController_ updateBasePref:YES wifiPref:YES];
CheckTextItemAccessoryType(MDCCollectionViewCellAccessoryNone, 0, 0);
CheckTextItemAccessoryType(MDCCollectionViewCellAccessoryCheckmark, 0, 1);
CheckTextItemAccessoryType(MDCCollectionViewCellAccessoryNone, 0, 2);
CheckTextItemAccessoryType(UITableViewCellAccessoryNone, 0, 0);
CheckTextItemAccessoryType(UITableViewCellAccessoryCheckmark, 0, 1);
CheckTextItemAccessoryType(UITableViewCellAccessoryNone, 0, 2);
[dataplanController_ updateBasePref:YES wifiPref:NO];
CheckTextItemAccessoryType(MDCCollectionViewCellAccessoryCheckmark, 0, 0);
CheckTextItemAccessoryType(MDCCollectionViewCellAccessoryNone, 0, 1);
CheckTextItemAccessoryType(MDCCollectionViewCellAccessoryNone, 0, 2);
CheckTextItemAccessoryType(UITableViewCellAccessoryCheckmark, 0, 0);
CheckTextItemAccessoryType(UITableViewCellAccessoryNone, 0, 1);
CheckTextItemAccessoryType(UITableViewCellAccessoryNone, 0, 2);
[dataplanController_ updateBasePref:NO wifiPref:YES];
CheckTextItemAccessoryType(MDCCollectionViewCellAccessoryNone, 0, 0);
CheckTextItemAccessoryType(MDCCollectionViewCellAccessoryNone, 0, 1);
CheckTextItemAccessoryType(MDCCollectionViewCellAccessoryCheckmark, 0, 2);
CheckTextItemAccessoryType(UITableViewCellAccessoryNone, 0, 0);
CheckTextItemAccessoryType(UITableViewCellAccessoryNone, 0, 1);
CheckTextItemAccessoryType(UITableViewCellAccessoryCheckmark, 0, 2);
[dataplanController_ updateBasePref:NO wifiPref:NO];
CheckTextItemAccessoryType(MDCCollectionViewCellAccessoryNone, 0, 0);
CheckTextItemAccessoryType(MDCCollectionViewCellAccessoryNone, 0, 1);
CheckTextItemAccessoryType(MDCCollectionViewCellAccessoryCheckmark, 0, 2);
CheckTextItemAccessoryType(UITableViewCellAccessoryNone, 0, 0);
CheckTextItemAccessoryType(UITableViewCellAccessoryNone, 0, 1);
CheckTextItemAccessoryType(UITableViewCellAccessoryCheckmark, 0, 2);
}
} // namespace
......@@ -31,7 +31,7 @@
#import "ios/chrome/browser/ui/settings/cells/settings_switch_item.h"
#import "ios/chrome/browser/ui/settings/cells/settings_text_item.h"
#import "ios/chrome/browser/ui/settings/clear_browsing_data_collection_view_controller.h"
#import "ios/chrome/browser/ui/settings/dataplan_usage_collection_view_controller.h"
#import "ios/chrome/browser/ui/settings/dataplan_usage_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/handoff_collection_view_controller.h"
#import "ios/chrome/browser/ui/settings/settings_navigation_controller.h"
#import "ios/chrome/browser/ui/settings/settings_utils.h"
......@@ -269,7 +269,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
}
- (CollectionViewItem*)sendUsageDetailItem {
NSString* detailText = [DataplanUsageCollectionViewController
NSString* detailText = [DataplanUsageTableViewController
currentLabelForPreference:GetApplicationContext()->GetLocalState()
basePref:metrics::prefs::kMetricsReportingEnabled
wifiPref:prefs::kMetricsReportingWifiOnly];
......@@ -329,7 +329,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
[self.collectionViewModel itemTypeForIndexPath:indexPath];
// Items that push a new view controller.
SettingsRootCollectionViewController* controller;
UIViewController<SettingsRootViewControlling>* controller;
switch (itemType) {
case ItemTypeOtherDevicesHandoff:
......@@ -337,7 +337,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
initWithBrowserState:_browserState];
break;
case ItemTypeWebServicesSendUsageData:
controller = [[DataplanUsageCollectionViewController alloc]
controller = [[DataplanUsageTableViewController alloc]
initWithPrefs:GetApplicationContext()->GetLocalState()
basePref:metrics::prefs::kMetricsReportingEnabled
wifiPref:prefs::kMetricsReportingWifiOnly
......@@ -485,7 +485,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
if (preferenceName == metrics::prefs::kMetricsReportingEnabled ||
preferenceName == prefs::kMetricsReportingWifiOnly) {
NSString* detailText = [DataplanUsageCollectionViewController
NSString* detailText = [DataplanUsageTableViewController
currentLabelForPreference:GetApplicationContext()->GetLocalState()
basePref:metrics::prefs::kMetricsReportingEnabled
wifiPref:prefs::kMetricsReportingWifiOnly];
......
......@@ -25,6 +25,7 @@
[UIColor groupTableViewBackgroundColor];
self.styler.tableViewSectionHeaderBlurEffect = nil;
[super viewDidLoad];
self.styler.cellBackgroundColor = [UIColor whiteColor];
}
- (void)viewWillAppear:(BOOL)animated {
......
......@@ -16,6 +16,9 @@
// Text Alignment for the cell's textLabel. Default is NSTextAlignmentNatural.
@property(nonatomic, assign) NSTextAlignment textAlignment;
// The accessory type to display on the trailing edge of the cell.
@property(nonatomic) UITableViewCellAccessoryType accessoryType;
// UIColor for the cell's textLabel. Default is
// kTableViewTextLabelColorLightGrey. ChromeTableViewStyler's |cellTitleColor|
// takes precedence over the default color, but not over |textColor|.
......
......@@ -34,6 +34,7 @@ const CGFloat kMinimalHeight = 48;
- (void)configureCell:(TableViewDetailTextCell*)cell
withStyler:(ChromeTableViewStyler*)styler {
[super configureCell:cell withStyler:styler];
cell.accessoryType = self.accessoryType;
cell.textLabel.text = self.text;
cell.detailTextLabel.text = self.detailText;
cell.isAccessibilityElement = YES;
......
......@@ -27,7 +27,11 @@
cell.accessibilityTraits = self.accessibilityTraits;
cell.accessibilityIdentifier = self.accessibilityIdentifier;
if (!cell.backgroundView) {
cell.backgroundColor = styler.tableViewBackgroundColor;
if (styler.cellBackgroundColor) {
cell.backgroundColor = styler.cellBackgroundColor;
} else {
cell.backgroundColor = styler.tableViewBackgroundColor;
}
}
// Since this Cell might get reconfigured while it's being highlighted,
// re-setting the selectedBackgroundView will interrupt the higlight
......
......@@ -17,6 +17,9 @@
// opaque color, cells can choose to make themselves opaque and draw their own
// background as a performance optimization.
@property(nonatomic, readwrite, strong) UIColor* tableViewBackgroundColor;
// The background color for the cell. It overrides |tableViewBackgroundColor|
// for the cell background if it is not nil.
@property(nonatomic, readwrite, strong) UIColor* cellBackgroundColor;
// Text colors.
@property(nonatomic, readwrite, strong) UIColor* cellTitleColor;
@property(nonatomic, readwrite, strong) UIColor* headerFooterTitleColor;
......
......@@ -24,6 +24,7 @@ const CGFloat kDefaultTableViewSeparatorColor = 0xC8C7CC;
@synthesize tableViewSectionHeaderBlurEffect =
_tableViewSectionHeaderBlurEffect;
@synthesize tableViewBackgroundColor = _tableViewBackgroundColor;
@synthesize cellBackgroundColor = _cellBackgroundColor;
@synthesize cellTitleColor = _cellTitleColor;
@synthesize headerFooterTitleColor = _headerFooterTitleColor;
@synthesize cellHighlightColor = _cellHighlightColor;
......
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