OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 /** | |
6 * @typedef {{ | |
7 * tetherNostDeviceName: string, | |
8 * batteryPercentage: number, | |
9 * connectionStrength: number, | |
10 * isTetherHostCurrentlyOnWifi: boolean | |
11 * }} | |
12 */ | |
13 var TetherConnectionData; | |
14 | |
15 Polymer({ | |
16 is: 'tether-connection-dialog', | |
17 | |
18 behaviors: [ | |
19 I18nBehavior, | |
stevenjb
2017/03/17 20:50:44
Also, minor nit: if you remove the , here clang wi
Kyle Horimoto
2017/03/17 20:56:19
Done.
| |
20 ], | |
21 | |
22 properties: { | |
23 /** | |
24 * The data used to display the tether connection dialog. | |
25 * @private {!TetherConnectionData|undefined} | |
26 */ | |
27 tetherData_: { | |
28 type: Object, | |
29 // TODO(khorimoto): Remove this and use real data when available. | |
30 value: { | |
31 tetherNostDeviceName: 'Pixel XL', | |
32 batteryPercentage: 100, | |
33 connectionStrength: 4, | |
34 isTetherHostCurrentlyOnWifi: false | |
35 }, | |
36 }, | |
37 }, | |
38 | |
39 open: function() { | |
40 this.getDialog_().showModal(); | |
41 }, | |
42 | |
43 close: function() { | |
44 var dialog = this.getDialog_(); | |
45 if (dialog.open) | |
46 dialog.close(); | |
47 }, | |
48 | |
49 /** @override */ | |
50 ready: function() { | |
51 this.open(); | |
52 }, | |
53 | |
54 /** | |
55 * @return {!CrDialogElement} | |
56 * @private | |
57 */ | |
58 getDialog_: function() { | |
59 return /** @type {!CrDialogElement} */ (this.$.dialog); | |
60 }, | |
61 | |
62 /** @private */ | |
63 onNotNowTap_: function() { | |
64 this.getDialog_().cancel(); | |
65 }, | |
66 | |
67 /** | |
68 * @param {!TetherConnectionData|undefined} tetherData | |
69 * @return {string} | |
70 * @private | |
71 */ | |
72 getReceptionIcon_: function(tetherData) { | |
73 var connectionStrength; | |
74 | |
75 if (!tetherData || !tetherData.connectionStrength) { | |
76 connectionStrength = 0; | |
77 } else { | |
78 // Ensure that 0 <= connectionStrength <= 4, since these values are the | |
79 // limits of the cellular strength icons. | |
80 connectionStrength = | |
81 Math.min(Math.max(tetherData.connectionStrength, 0), 4); | |
82 } | |
83 | |
84 return 'device:signal-cellular-' + connectionStrength + '-bar'; | |
85 } | |
86 }); | |
OLD | NEW |