Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Cast2Class] Add basic code input, add i18n
Add code_input.ts and code_input.html with a basic input box for typing access code. Handle input events and transform them into custom events, which will be useful in the future once the input is stylized and more complicated. Transform all inputs to uppercase. Add unit test for code_input value handling. Additionally, add internationalization for the WebUI. This includes adding access_code_cast_strings.grdp with the few strings we already have, and adding translation screenshots. Add OWNERS to relevant file and directory. Bug: b/209046365 Change-Id: Ia1ad05fa2630d2e7a9440776f33ee80ad32adddc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3315427 Reviewed-by: Takumi Fujimoto <takumif@chromium.org> Reviewed-by: Ken Rockot <rockot@google.com> Commit-Queue: Benjamin Zielinski <bzielinski@google.com> Cr-Commit-Position: refs/heads/main@{#949201}
- Loading branch information
Benjamin Zielinski
authored and
Chromium LUCI CQ
committed
Dec 7, 2021
1 parent
bf26cc6
commit 5f6ea93
Showing
19 changed files
with
209 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Access Code Cast-specific strings (included from generated_resources.grd). --> | ||
<grit-part> | ||
<message name="IDS_ACCESS_CODE_CAST_BACK" desc="Label for the 'back' button to return to the previous screen"> | ||
Back | ||
</message> | ||
<message name="IDS_ACCESS_CODE_CAST_CAST" desc="Label for the button to start casting"> | ||
Cast | ||
</message> | ||
<message name="IDS_ACCESS_CODE_CAST_DIALOG_TITLE" desc="Title for access code cast dialog"> | ||
Cast to a new display | ||
</message> | ||
<message name="IDS_ACCESS_CODE_CAST_USE_CAMERA" desc="Label for the button to use the device camera to scan a QR code"> | ||
Use the camera to scan QR code | ||
</message> | ||
</grit-part> |
1 change: 1 addition & 0 deletions
1
chrome/app/access_code_cast_strings_grdp/IDS_ACCESS_CODE_CAST_BACK.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
91687f84bc741017567a8e2ac9f6678066b0b877 |
1 change: 1 addition & 0 deletions
1
chrome/app/access_code_cast_strings_grdp/IDS_ACCESS_CODE_CAST_CAST.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cb57fa67c57448a6862dcac40af6059e8a8a20e9 |
1 change: 1 addition & 0 deletions
1
chrome/app/access_code_cast_strings_grdp/IDS_ACCESS_CODE_CAST_DIALOG_TITLE.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cb57fa67c57448a6862dcac40af6059e8a8a20e9 |
1 change: 1 addition & 0 deletions
1
chrome/app/access_code_cast_strings_grdp/IDS_ACCESS_CODE_CAST_USE_CAMERA.png.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cb57fa67c57448a6862dcac40af6059e8a8a20e9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
file://chrome/browser/ui/webui/access_code_cast/OWNERS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
# ChromeOS EDU Team Members | ||
gbj@google.com | ||
bzielinski@google.com | ||
bmalcolm@google.com | ||
jacqueli@googlle.com | ||
file://chrome/browser/ui/webui/access_code_cast/OWNERS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
gbj@google.com | ||
bmalcolm@chromium.org | ||
bzielinski@google.com | ||
jacqueli@google.com | ||
file://chrome/browser/ui/webui/access_code_cast/OWNERS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
chrome/browser/resources/access_code_cast/code_input/code_input.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<style> | ||
cr-input { | ||
font-size: 50px; | ||
margin: auto; | ||
width: 300px; | ||
} | ||
</style> | ||
<cr-input | ||
type="text" | ||
minlength="[[length]]" | ||
maxlength="[[length]]" | ||
id="accessCodeInput" | ||
value="{{value}}"> | ||
</cr-input> |
64 changes: 64 additions & 0 deletions
64
chrome/browser/resources/access_code_cast/code_input/code_input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright 2021 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'chrome://resources/cr_elements/cr_input/cr_input.m.js'; | ||
|
||
import {CrInputElement} from 'chrome://resources/cr_elements/cr_input/cr_input.m.js'; | ||
import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; | ||
|
||
export interface CodeInputElement { | ||
$: { | ||
accessCodeInput: CrInputElement; | ||
} | ||
} | ||
|
||
export class CodeInputElement extends PolymerElement { | ||
static get is() { | ||
return 'c2c-code-input'; | ||
} | ||
|
||
static get template() { | ||
return html`{__html_template__}`; | ||
} | ||
|
||
static get properties() { | ||
return { | ||
length: Number, | ||
value: { | ||
type: String, | ||
value: '', | ||
} | ||
}; | ||
} | ||
|
||
get crInput() { | ||
return this.$.accessCodeInput; | ||
} | ||
|
||
value: string; | ||
|
||
ready() { | ||
super.ready(); | ||
this.$.accessCodeInput.addEventListener('input', () => { | ||
this.handleInput(); | ||
}); | ||
} | ||
|
||
clearInput() { | ||
this.$.accessCodeInput.value = ''; | ||
} | ||
|
||
focusInput() { | ||
this.$.accessCodeInput.focusInput(); | ||
} | ||
|
||
private handleInput() { | ||
this.$.accessCodeInput.value = this.$.accessCodeInput.value.toUpperCase(); | ||
this.dispatchEvent(new CustomEvent('access-code-input', { | ||
detail: {value: this.$.accessCodeInput.value} | ||
})); | ||
} | ||
} | ||
|
||
customElements.define(CodeInputElement.is, CodeInputElement); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
chrome/test/data/webui/access_code_cast/code_input_test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2021 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'chrome://access-code-cast/code_input/code_input.js'; | ||
|
||
suite('CodeInputElementTest', () => { | ||
/** @type {!CodeInputElement} */ | ||
let c2cInput; | ||
|
||
/** @type {!CrInputElement} */ | ||
let crInput; | ||
|
||
setup(() => { | ||
PolymerTest.clearBody(); | ||
|
||
c2cInput = document.createElement('c2c-code-input'); | ||
document.body.appendChild(c2cInput); | ||
crInput = c2cInput.crInput; | ||
}); | ||
|
||
test('value set correctly', () => { | ||
c2cInput.value = 'hello'; | ||
assertEquals(c2cInput.value, crInput.value); | ||
|
||
// |value| is copied to uppercase when typing triggers inputEvent. | ||
let testString = 'hello world'; | ||
crInput.value = testString; | ||
crInput.dispatchEvent(new InputEvent('input')); | ||
assertEquals(c2cInput.value, testString.toUpperCase()); | ||
}); | ||
}); |
?