Commit e1acc275 authored by Jérôme Lebel's avatar Jérôme Lebel Committed by Commit Bot

[iOS] Adding commandID in CollectionViewTextItem

Command ids in CollectionViewTextItem are used in
GoogleServicesSettingsViewController. The command id lets the view
controller knows which command to send to the command handler when
the cell is tapped.

Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Iafa070c38362d0295a0100f99033972da26d435e
Reviewed-on: https://chromium-review.googlesource.com/1156692Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579471}
parent 69e4263a
...@@ -43,6 +43,9 @@ ...@@ -43,6 +43,9 @@
// The maximum number of lines of the secondary text. Default is 1. // The maximum number of lines of the secondary text. Default is 1.
@property(nonatomic, assign) NSInteger numberOfDetailTextLines; @property(nonatomic, assign) NSInteger numberOfDetailTextLines;
// Command to trigger when the cell is tapped. The default value is 0.
@property(nonatomic, assign) NSInteger commandID;
@end @end
#endif // IOS_CHROME_BROWSER_UI_COLLECTION_VIEW_CELLS_COLLECTION_VIEW_TEXT_ITEM_H_ #endif // IOS_CHROME_BROWSER_UI_COLLECTION_VIEW_CELLS_COLLECTION_VIEW_TEXT_ITEM_H_
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
@synthesize detailTextFont = _detailTextFont; @synthesize detailTextFont = _detailTextFont;
@synthesize detailTextColor = _detailTextColor; @synthesize detailTextColor = _detailTextColor;
@synthesize numberOfDetailTextLines = _numberOfDetailTextLines; @synthesize numberOfDetailTextLines = _numberOfDetailTextLines;
@synthesize commandID = _commandID;
- (instancetype)initWithType:(NSInteger)type { - (instancetype)initWithType:(NSInteger)type {
self = [super initWithType:type]; self = [super initWithType:type];
......
...@@ -35,6 +35,12 @@ typedef NS_ENUM(NSInteger, GoogleServicesSettingsCommandID) { ...@@ -35,6 +35,12 @@ typedef NS_ENUM(NSInteger, GoogleServicesSettingsCommandID) {
GoogleServicesSettingsCommandIDToggleImproveChromeService, GoogleServicesSettingsCommandIDToggleImproveChromeService,
// Enable/disabble better search and browsing service. // Enable/disabble better search and browsing service.
GoogleServicesSettingsCommandIDToggleBetterSearchAndBrowsingService, GoogleServicesSettingsCommandIDToggleBetterSearchAndBrowsingService,
// Opens the Google activity controls dialog.
GoogleServicesSettingsCommandIDOpenGoogleActivityPage,
// Opens the encryption dialog.
GoogleServicesSettingsCommandIDOpenEncryptionDialog,
// Opens manage synced data page.
GoogleServicesSettingsCommandIDOpenManageSyncedDataPage,
}; };
// Protocol to handle Google services settings commands. // Protocol to handle Google services settings commands.
...@@ -74,6 +80,15 @@ typedef NS_ENUM(NSInteger, GoogleServicesSettingsCommandID) { ...@@ -74,6 +80,15 @@ typedef NS_ENUM(NSInteger, GoogleServicesSettingsCommandID) {
// GoogleServicesSettingsCommandIDToggleBetterSearchAndBrowsingService is // GoogleServicesSettingsCommandIDToggleBetterSearchAndBrowsingService is
// triggered. // triggered.
- (void)toggleBetterSearchAndBrowsingServiceWithValue:(BOOL)on; - (void)toggleBetterSearchAndBrowsingServiceWithValue:(BOOL)on;
// Called when GoogleServicesSettingsCommandIDOpenGoogleActivityPage is
// triggered.
- (void)openGoogleActivityPage;
// Called when GoogleServicesSettingsCommandIDOpenEncryptionDialog is
// triggered.
- (void)openEncryptionDialog;
// Called when GoogleServicesSettingsCommandIDOpenManageSyncedDataPage is
// triggered.
- (void)openManageSyncedDataPage;
@end @end
......
...@@ -248,6 +248,7 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -248,6 +248,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
IDS_IOS_GOOGLE_SERVICES_SETTINGS_GOOGLE_ACTIVITY_CONTROL_DETAIL); IDS_IOS_GOOGLE_SERVICES_SETTINGS_GOOGLE_ACTIVITY_CONTROL_DETAIL);
item.numberOfDetailTextLines = 0; item.numberOfDetailTextLines = 0;
item.accessoryType = MDCCollectionViewCellAccessoryDisclosureIndicator; item.accessoryType = MDCCollectionViewCellAccessoryDisclosureIndicator;
item.commandID = GoogleServicesSettingsCommandIDOpenGoogleActivityPage;
return item; return item;
} }
...@@ -261,6 +262,7 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -261,6 +262,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
item.textColor = [[MDCPalette greyPalette] tint500]; item.textColor = [[MDCPalette greyPalette] tint500];
item.numberOfDetailTextLines = 0; item.numberOfDetailTextLines = 0;
item.accessoryType = MDCCollectionViewCellAccessoryDisclosureIndicator; item.accessoryType = MDCCollectionViewCellAccessoryDisclosureIndicator;
item.commandID = GoogleServicesSettingsCommandIDOpenEncryptionDialog;
return item; return item;
} }
...@@ -273,6 +275,7 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -273,6 +275,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
item.numberOfTextLines = 0; item.numberOfTextLines = 0;
if (!self.isAuthenticated) if (!self.isAuthenticated)
item.textColor = [[MDCPalette greyPalette] tint500]; item.textColor = [[MDCPalette greyPalette] tint500];
item.commandID = GoogleServicesSettingsCommandIDOpenManageSyncedDataPage;
return item; return item;
} }
...@@ -441,4 +444,16 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -441,4 +444,16 @@ typedef NS_ENUM(NSInteger, ItemType) {
// Needs to be implemented. // Needs to be implemented.
} }
- (void)openGoogleActivityPage {
// Needs to be implemented.
}
- (void)openEncryptionDialog {
// Needs to be implemented.
}
- (void)openManageSyncedDataPage {
// Needs to be implemented.
}
@end @end
...@@ -102,6 +102,9 @@ constexpr NSInteger kSectionOffset = 1000; ...@@ -102,6 +102,9 @@ constexpr NSInteger kSectionOffset = 1000;
static_cast<GoogleServicesSettingsCommandID>(syncSwitchItem.commandID); static_cast<GoogleServicesSettingsCommandID>(syncSwitchItem.commandID);
switch (commandID) { switch (commandID) {
case GoogleServicesSettingsCommandIDNoOp: case GoogleServicesSettingsCommandIDNoOp:
case GoogleServicesSettingsCommandIDOpenGoogleActivityPage:
case GoogleServicesSettingsCommandIDOpenEncryptionDialog:
case GoogleServicesSettingsCommandIDOpenManageSyncedDataPage:
NOTREACHED(); NOTREACHED();
break; break;
case GoogleServicesSettingsCommandIDToggleSyncEverything: case GoogleServicesSettingsCommandIDToggleSyncEverything:
...@@ -207,7 +210,16 @@ constexpr NSInteger kSectionOffset = 1000; ...@@ -207,7 +210,16 @@ constexpr NSInteger kSectionOffset = 1000;
shouldHighlightItemAtIndexPath:indexPath]; shouldHighlightItemAtIndexPath:indexPath];
CollectionViewItem* item = CollectionViewItem* item =
[self.collectionViewModel itemAtIndexPath:indexPath]; [self.collectionViewModel itemAtIndexPath:indexPath];
return ![item isKindOfClass:[SyncSwitchItem class]]; if ([item isKindOfClass:[SyncSwitchItem class]]) {
return NO;
} else if ([item isKindOfClass:[SettingsCollapsibleItem class]]) {
return YES;
} else if ([item isKindOfClass:[CollectionViewTextItem class]]) {
CollectionViewTextItem* textItem =
base::mac::ObjCCast<CollectionViewTextItem>(item);
return textItem.commandID != 0;
}
return NO;
} }
- (void)collectionView:(UICollectionView*)collectionView - (void)collectionView:(UICollectionView*)collectionView
...@@ -217,6 +229,39 @@ constexpr NSInteger kSectionOffset = 1000; ...@@ -217,6 +229,39 @@ constexpr NSInteger kSectionOffset = 1000;
[self.collectionViewModel itemAtIndexPath:indexPath]; [self.collectionViewModel itemAtIndexPath:indexPath];
if ([item isKindOfClass:[SettingsCollapsibleItem class]]) { if ([item isKindOfClass:[SettingsCollapsibleItem class]]) {
[self toggleSectionWithIndexPath:indexPath]; [self toggleSectionWithIndexPath:indexPath];
return;
}
CollectionViewTextItem* textItem =
base::mac::ObjCCastStrict<CollectionViewTextItem>(
[self.collectionViewModel itemAtIndexPath:indexPath]);
GoogleServicesSettingsCommandID commandID =
static_cast<GoogleServicesSettingsCommandID>(textItem.commandID);
switch (commandID) {
case GoogleServicesSettingsCommandIDOpenGoogleActivityPage:
[self.commandHandler openGoogleActivityPage];
break;
case GoogleServicesSettingsCommandIDOpenEncryptionDialog:
[self.commandHandler openEncryptionDialog];
break;
case GoogleServicesSettingsCommandIDOpenManageSyncedDataPage:
[self.commandHandler openManageSyncedDataPage];
break;
case GoogleServicesSettingsCommandIDNoOp:
case GoogleServicesSettingsCommandIDToggleSyncEverything:
case GoogleServicesSettingsCommandIDToggleBookmarkSync:
case GoogleServicesSettingsCommandIDToggleHistorySync:
case GoogleServicesSettingsCommandIDTogglePasswordsSync:
case GoogleServicesSettingsCommandIDToggleOpenTabsSync:
case GoogleServicesSettingsCommandIDToggleAutofillSync:
case GoogleServicesSettingsCommandIDToggleSettingsSync:
case GoogleServicesSettingsCommandIDToggleReadingListSync:
case GoogleServicesSettingsCommandIDToggleActivityAndInteractionsService:
case GoogleServicesSettingsCommandIDToggleAutocompleteSearchesService:
case GoogleServicesSettingsCommandIDTogglePreloadPagesService:
case GoogleServicesSettingsCommandIDToggleImproveChromeService:
case GoogleServicesSettingsCommandIDToggleBetterSearchAndBrowsingService:
NOTREACHED();
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