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: [I18nBehavior], |
| 19 |
| 20 properties: { |
| 21 /** |
| 22 * The data used to display the tether connection dialog. |
| 23 * @private {!TetherConnectionData|undefined} |
| 24 */ |
| 25 tetherData_: { |
| 26 type: Object, |
| 27 // TODO(khorimoto): Remove this and use real data when available. |
| 28 value: { |
| 29 tetherNostDeviceName: 'Pixel XL', |
| 30 batteryPercentage: 100, |
| 31 connectionStrength: 4, |
| 32 isTetherHostCurrentlyOnWifi: false |
| 33 }, |
| 34 }, |
| 35 }, |
| 36 |
| 37 open: function() { |
| 38 var dialog = this.getDialog_(); |
| 39 if (!dialog.open) |
| 40 this.getDialog_().showModal(); |
| 41 }, |
| 42 |
| 43 close: function() { |
| 44 var dialog = this.getDialog_(); |
| 45 if (dialog.open) |
| 46 dialog.close(); |
| 47 }, |
| 48 |
| 49 /** |
| 50 * @return {!CrDialogElement} |
| 51 * @private |
| 52 */ |
| 53 getDialog_: function() { |
| 54 return /** @type {!CrDialogElement} */ (this.$.dialog); |
| 55 }, |
| 56 |
| 57 /** @private */ |
| 58 onNotNowTap_: function() { |
| 59 this.getDialog_().cancel(); |
| 60 }, |
| 61 |
| 62 /** |
| 63 * @param {!TetherConnectionData|undefined} tetherData |
| 64 * @return {string} |
| 65 * @private |
| 66 */ |
| 67 getReceptionIcon_: function(tetherData) { |
| 68 var connectionStrength; |
| 69 |
| 70 if (!tetherData || !tetherData.connectionStrength) { |
| 71 connectionStrength = 0; |
| 72 } else { |
| 73 // Ensure that 0 <= connectionStrength <= 4, since these values are the |
| 74 // limits of the cellular strength icons. |
| 75 connectionStrength = |
| 76 Math.min(Math.max(tetherData.connectionStrength, 0), 4); |
| 77 } |
| 78 |
| 79 return 'settings:signal-cellular-' + connectionStrength + '-bar'; |
| 80 } |
| 81 }); |
OLD | NEW |