Commit 1bf739db authored by My Nguyen's avatar My Nguyen Committed by Commit Bot

[CrOS Settings] Add 'Add input methods' button for input_page

Spec: http://go/cros-lang-settings-ux slide 23.
Current view: http://screen/f9bbb539-b983-4ac7-aa9f-cb0886bd2f9f

Note: All strings are not finalised so they are translateable false
and no screenshots required.

Bug: 1113439
Change-Id: Ic1ab01755fe86c28b89468aba54cc5dff010ced5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2354113Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarRegan Hsu <hsuregan@chromium.org>
Commit-Queue: My Nguyen <myy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798527}
parent 9bdc2af5
...@@ -874,6 +874,9 @@ ...@@ -874,6 +874,9 @@
<message name="IDS_OS_SETTINGS_TAG_LANGUAGES_INPUT_ADD_LANGUAGE" desc="Text for search result item which, when clicked, navigates the user to languages and input settings, with an option to add a new language."> <message name="IDS_OS_SETTINGS_TAG_LANGUAGES_INPUT_ADD_LANGUAGE" desc="Text for search result item which, when clicked, navigates the user to languages and input settings, with an option to add a new language.">
Add languages Add languages
</message> </message>
<message name="IDS_OS_SETTINGS_TAG_LANGUAGES_ADD_INPUT_METHOD" translateable="false" desc="Text for search result item which, when clicked, navigates the user to input settings, with the option to add input methods (keyboard layouts and input method editors).">
Add input methods
</message>
<message name="IDS_OS_SETTINGS_TAG_LANGUAGES_INPUT_METHODS" desc="Text for search result item which, when clicked, navigates the user to input settings, with the option to enable/disable input in supported languages."> <message name="IDS_OS_SETTINGS_TAG_LANGUAGES_INPUT_METHODS" desc="Text for search result item which, when clicked, navigates the user to input settings, with the option to enable/disable input in supported languages.">
Manage input methods Manage input methods
</message> </message>
......
...@@ -277,6 +277,9 @@ ...@@ -277,6 +277,9 @@
<message name="IDS_OS_SETTINGS_LANGUAGES_OPEN_OPTIONS_PAGE_LABEL" translateable="false" desc="Title for the button to open the options page for a input method (keyboard layout and input method editor)."> <message name="IDS_OS_SETTINGS_LANGUAGES_OPEN_OPTIONS_PAGE_LABEL" translateable="false" desc="Title for the button to open the options page for a input method (keyboard layout and input method editor).">
Open options page for <ph name="INPUT_METHOD_NAME">$1<ex>US keyboard</ex></ph> Open options page for <ph name="INPUT_METHOD_NAME">$1<ex>US keyboard</ex></ph>
</message> </message>
<message name="IDS_OS_SETTINGS_LANGUAGES_ADD_INPUT_METHOD_LABEL" translateable="false" desc="Button under the list of input methods which opens a dialog that lets the user add keyboard layouts and input method editors.">
Add input methods
</message>
<message name="IDS_OS_SETTINGS_LANGUAGES_LIST_TITLE" desc="Title for the list of the user's preferred written languages."> <message name="IDS_OS_SETTINGS_LANGUAGES_LIST_TITLE" desc="Title for the list of the user's preferred written languages.">
Languages Languages
</message> </message>
......
<link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> <link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html"> <link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="import" href="input_method_util.html"> <link rel="import" href="input_method_util.html">
<link rel="import" href="languages_metrics_proxy.html"> <link rel="import" href="languages_metrics_proxy.html">
<link rel="import" href="../os_route.html"> <link rel="import" href="../os_route.html">
...@@ -39,6 +41,12 @@ ...@@ -39,6 +41,12 @@
.external-wrapper { .external-wrapper {
display: flex; display: flex;
} }
#addInputMethod {
--iron-icon-fill-color: var(--cr-link-color);
margin-inline-end: 4px;
margin-top: 16px;
}
</style> </style>
<div route-path="default"> <div route-path="default">
...@@ -88,6 +96,12 @@ ...@@ -88,6 +96,12 @@
</template> </template>
</div> </div>
</template> </template>
<div class="list-item">
<cr-button id="addInputMethod" on-click="onAddInputMethodClick_">
<iron-icon icon="cr:add"></iron-icon>
$i18n{addInputMethodLabel}
</cr-button>
</div>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -159,4 +159,10 @@ Polymer({ ...@@ -159,4 +159,10 @@ Polymer({
getOpenOptionsPageLabel_(inputMethodName) { getOpenOptionsPageLabel_(inputMethodName) {
return this.i18n('openOptionsPage', inputMethodName); return this.i18n('openOptionsPage', inputMethodName);
}, },
/** @private */
onAddInputMethodClick_() {
this.languagesMetricsProxy_.recordAddInputMethod();
// TODO(crbug/1113439): Add input methods dialog.
},
}); });
...@@ -170,6 +170,7 @@ enum Setting { ...@@ -170,6 +170,7 @@ enum Setting {
kShowEmojiSuggestions = 1203, kShowEmojiSuggestions = 1203,
kChangeSystemLanguage = 1204, kChangeSystemLanguage = 1204,
kOfferTranslation = 1205, kOfferTranslation = 1205,
kAddInputMethod = 1206,
// Files section. // Files section.
kGoogleDriveConnection = 1300, kGoogleDriveConnection = 1300,
......
...@@ -103,6 +103,12 @@ const std::vector<SearchConcept>& GetInputPageSearchConceptsV2() { ...@@ -103,6 +103,12 @@ const std::vector<SearchConcept>& GetInputPageSearchConceptsV2() {
{.setting = mojom::Setting::kShowInputOptionsInShelf}, {.setting = mojom::Setting::kShowInputOptionsInShelf},
{IDS_OS_SETTINGS_TAG_LANGUAGES_INPUT_INPUT_OPTIONS_SHELF_ALT1, {IDS_OS_SETTINGS_TAG_LANGUAGES_INPUT_INPUT_OPTIONS_SHELF_ALT1,
SearchConcept::kAltTagEnd}}, SearchConcept::kAltTagEnd}},
{IDS_OS_SETTINGS_TAG_LANGUAGES_ADD_INPUT_METHOD,
mojom::kInputSubpagePath,
mojom::SearchResultIcon::kGlobe,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
{.setting = mojom::Setting::kAddInputMethod}},
}); });
return *tags; return *tags;
} }
...@@ -264,6 +270,7 @@ void AddInputPageStringsV2(content::WebUIDataSource* html_source) { ...@@ -264,6 +270,7 @@ void AddInputPageStringsV2(content::WebUIDataSource* html_source) {
{"inputMethodListTitle", {"inputMethodListTitle",
IDS_OS_SETTINGS_LANGUAGES_INPUT_METHOD_LIST_TITLE}, IDS_OS_SETTINGS_LANGUAGES_INPUT_METHOD_LIST_TITLE},
{"openOptionsPage", IDS_OS_SETTINGS_LANGUAGES_OPEN_OPTIONS_PAGE_LABEL}, {"openOptionsPage", IDS_OS_SETTINGS_LANGUAGES_OPEN_OPTIONS_PAGE_LABEL},
{"addInputMethodLabel", IDS_OS_SETTINGS_LANGUAGES_ADD_INPUT_METHOD_LABEL},
}; };
AddLocalizedStringsBulk(html_source, kLocalizedStrings); AddLocalizedStringsBulk(html_source, kLocalizedStrings);
} }
...@@ -389,6 +396,11 @@ void LanguagesSection::RegisterHierarchy(HierarchyGenerator* generator) const { ...@@ -389,6 +396,11 @@ void LanguagesSection::RegisterHierarchy(HierarchyGenerator* generator) const {
IDS_OS_SETTINGS_LANGUAGES_INPUT_PAGE_TITLE, mojom::Subpage::kInput, IDS_OS_SETTINGS_LANGUAGES_INPUT_PAGE_TITLE, mojom::Subpage::kInput,
mojom::SearchResultIcon::kGlobe, mojom::SearchResultDefaultRank::kMedium, mojom::SearchResultIcon::kGlobe, mojom::SearchResultDefaultRank::kMedium,
mojom::kInputSubpagePath); mojom::kInputSubpagePath);
static constexpr mojom::Setting kInputPageSettings[] = {
mojom::Setting::kAddInputMethod,
};
RegisterNestedSettingBulk(mojom::Subpage::kInput, kInputPageSettings,
generator);
// Languages and input details. // Languages and input details.
generator->RegisterTopLevelSubpage( generator->RegisterTopLevelSubpage(
......
...@@ -71,7 +71,8 @@ suite('input page', () => { ...@@ -71,7 +71,8 @@ suite('input page', () => {
// The test input methods should appear. // The test input methods should appear.
const items = inputMethodsList.querySelectorAll('.list-item'); const items = inputMethodsList.querySelectorAll('.list-item');
assertEquals(2, items.length); // Two items for input methods // Two items for input methods and one item for add input methods.
assertEquals(3, items.length);
assertEquals( assertEquals(
'US keyboard', 'US keyboard',
items[0].querySelector('.display-name').textContent.trim()); items[0].querySelector('.display-name').textContent.trim());
...@@ -116,5 +117,12 @@ suite('input page', () => { ...@@ -116,5 +117,12 @@ suite('input page', () => {
assertTrue( assertTrue(
await metricsProxy.whenCalled('recordToggleShowInputOptionsOnShelf')); await metricsProxy.whenCalled('recordToggleShowInputOptionsOnShelf'));
}); });
test('when adding input methods', async () => {
inputPage.$$('#addInputMethod').click();
Polymer.dom.flush();
await metricsProxy.whenCalled('recordAddInputMethod');
});
}); });
}); });
...@@ -20,6 +20,7 @@ cr.define('settings', function() { ...@@ -20,6 +20,7 @@ cr.define('settings', function() {
'recordManageInputMethods', 'recordManageInputMethods',
'recordToggleShowInputOptionsOnShelf', 'recordToggleShowInputOptionsOnShelf',
'recordToggleTranslate', 'recordToggleTranslate',
'recordAddInputMethod',
]); ]);
} }
...@@ -47,6 +48,11 @@ cr.define('settings', function() { ...@@ -47,6 +48,11 @@ cr.define('settings', function() {
recordToggleTranslate(value) { recordToggleTranslate(value) {
this.methodCalled('recordToggleTranslate', value); this.methodCalled('recordToggleTranslate', value);
} }
/** @override */
recordAddInputMethod(value) {
this.methodCalled('recordAddInputMethod', value);
}
} }
// #cr_define_end // #cr_define_end
return { return {
......
...@@ -52697,6 +52697,7 @@ Called by update_net_trust_anchors.py.--> ...@@ -52697,6 +52697,7 @@ Called by update_net_trust_anchors.py.-->
<int value="1203" label="Show Emoji Suggestions"/> <int value="1203" label="Show Emoji Suggestions"/>
<int value="1204" label="Change System Language"/> <int value="1204" label="Change System Language"/>
<int value="1205" label="Offer Translation"/> <int value="1205" label="Offer Translation"/>
<int value="1206" label="Add Input Method"/>
<int value="1300" label="Google Drive Connection"/> <int value="1300" label="Google Drive Connection"/>
<int value="1400" label="Add Printer"/> <int value="1400" label="Add Printer"/>
<int value="1401" label="Saved Printers"/> <int value="1401" label="Saved Printers"/>
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