OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ios/chrome/browser/ui/settings/voicesearch_collection_view_controller.h
" | 5 #import "ios/chrome/browser/ui/settings/voicesearch_collection_view_controller.h
" |
6 | 6 |
7 #import "base/ios/weak_nsobject.h" | 7 #import "base/ios/weak_nsobject.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
10 #import "base/mac/scoped_nsobject.h" | 10 #import "base/mac/scoped_nsobject.h" |
11 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
12 #include "components/prefs/pref_member.h" | 12 #include "components/prefs/pref_member.h" |
13 #include "components/prefs/pref_service.h" | 13 #include "components/prefs/pref_service.h" |
14 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item
.h" | 14 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item
.h" |
| 15 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_cell.h
" |
15 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h
" | 16 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h
" |
16 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" | 17 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" |
17 #include "ios/chrome/browser/voice/speech_input_locale_config.h" | 18 #include "ios/chrome/browser/voice/speech_input_locale_config.h" |
18 #include "ios/chrome/grit/ios_strings.h" | 19 #include "ios/chrome/grit/ios_strings.h" |
19 #include "ios/public/provider/chrome/browser/voice/voice_search_prefs.h" | 20 #include "ios/public/provider/chrome/browser/voice/voice_search_prefs.h" |
20 #import "ios/third_party/material_components_ios/src/components/CollectionCells/
src/MaterialCollectionCells.h" | 21 #import "ios/third_party/material_components_ios/src/components/CollectionCells/
src/MaterialCollectionCells.h" |
| 22 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" |
| 23 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
21 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
22 #include "ui/base/l10n/l10n_util_mac.h" | 25 #include "ui/base/l10n/l10n_util_mac.h" |
23 | 26 |
24 namespace { | 27 namespace { |
25 | 28 |
26 typedef NS_ENUM(NSInteger, SectionIdentifier) { | 29 typedef NS_ENUM(NSInteger, SectionIdentifier) { |
27 SectionIdentifierTTS = kSectionIdentifierEnumZero, | 30 SectionIdentifierTTS = kSectionIdentifierEnumZero, |
28 SectionIdentifierLanguages, | 31 SectionIdentifierLanguages, |
29 }; | 32 }; |
30 | 33 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 NSInteger itemType = | 126 NSInteger itemType = |
124 [self.collectionViewModel itemTypeForIndexPath:indexPath]; | 127 [self.collectionViewModel itemTypeForIndexPath:indexPath]; |
125 | 128 |
126 if (itemType == ItemTypeTTSEnabled) { | 129 if (itemType == ItemTypeTTSEnabled) { |
127 // Have the switch send a message on UIControlEventValueChanged. | 130 // Have the switch send a message on UIControlEventValueChanged. |
128 CollectionViewSwitchCell* switchCell = | 131 CollectionViewSwitchCell* switchCell = |
129 base::mac::ObjCCastStrict<CollectionViewSwitchCell>(cell); | 132 base::mac::ObjCCastStrict<CollectionViewSwitchCell>(cell); |
130 [switchCell.switchView addTarget:self | 133 [switchCell.switchView addTarget:self |
131 action:@selector(ttsToggled:) | 134 action:@selector(ttsToggled:) |
132 forControlEvents:UIControlEventValueChanged]; | 135 forControlEvents:UIControlEventValueChanged]; |
| 136 } else if (itemType == ItemTypeLanguagesLanguageOption) { |
| 137 CollectionViewTextCell* textCell = |
| 138 base::mac::ObjCCastStrict<CollectionViewTextCell>(cell); |
| 139 textCell.textLabel.font = [MDCTypography body2Font]; |
| 140 textCell.textLabel.textColor = [[MDCPalette greyPalette] tint900]; |
| 141 textCell.detailTextLabel.font = [MDCTypography body1Font]; |
| 142 textCell.detailTextLabel.textColor = [[MDCPalette greyPalette] tint500]; |
133 } | 143 } |
134 | 144 |
135 return cell; | 145 return cell; |
136 } | 146 } |
137 | 147 |
138 - (void)collectionView:(UICollectionView*)collectionView | 148 - (void)collectionView:(UICollectionView*)collectionView |
139 didSelectItemAtIndexPath:(NSIndexPath*)indexPath { | 149 didSelectItemAtIndexPath:(NSIndexPath*)indexPath { |
140 [super collectionView:collectionView didSelectItemAtIndexPath:indexPath]; | 150 [super collectionView:collectionView didSelectItemAtIndexPath:indexPath]; |
141 | 151 |
142 CollectionViewModel* model = self.collectionViewModel; | 152 CollectionViewModel* model = self.collectionViewModel; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 - (BOOL)currentLanguageSupportsTTS { | 255 - (BOOL)currentLanguageSupportsTTS { |
246 voice::SpeechInputLocaleConfig* localeConfig = | 256 voice::SpeechInputLocaleConfig* localeConfig = |
247 voice::SpeechInputLocaleConfig::GetInstance(); | 257 voice::SpeechInputLocaleConfig::GetInstance(); |
248 std::string localeCode = _selectedLanguage.GetValue().empty() | 258 std::string localeCode = _selectedLanguage.GetValue().empty() |
249 ? localeConfig->GetDefaultLocale().code | 259 ? localeConfig->GetDefaultLocale().code |
250 : _selectedLanguage.GetValue(); | 260 : _selectedLanguage.GetValue(); |
251 return localeConfig->IsTextToSpeechEnabledForCode(localeCode); | 261 return localeConfig->IsTextToSpeechEnabledForCode(localeCode); |
252 } | 262 } |
253 | 263 |
254 @end | 264 @end |
OLD | NEW |