Commit ece2ca38 authored by Regan Hsu's avatar Regan Hsu Committed by Commit Bot

[CrOS PhoneHub] Show connecting state always upon clicking confirm.

Currently, if the dialog does not receive a 'Connecting' status, it
will not advance to the next state. This may happen if there is no
bluetooth connection. This CL ensures that the dialog shows the next
page upon requesting a connection instead of being stuck in the initial
state.

Bug: 1141596, 1106937
Change-Id: If671d9c3d5bf2561944707b5686f2dd4a71bb47d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2499368
Commit-Queue: Regan Hsu <hsuregan@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821733}
parent fdffed1d
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
$i18n{ok} $i18n{ok}
</cr-button> </cr-button>
</template> </template>
<template is="dom-if" if="[[!setupState_]]" restamp> <template is="dom-if" if="[[showConfirmButton_(setupState_)]]" restamp>
<cr-button id="confirmButton" class="action-button" <cr-button id="confirmButton" class="action-button"
on-click="onConfirmButtonClicked_"> on-click="onConfirmButtonClicked_">
$i18n{confirm} $i18n{confirm}
......
...@@ -11,11 +11,12 @@ ...@@ -11,11 +11,12 @@
/** /**
* Numerical values should not be changed because they must stay in sync with * Numerical values should not be changed because they must stay in sync with
* notification_access_setup_operation.h, with the exception of NOT_STARTED. * notification_access_setup_operation.h, with the exception of
* CONNECTION_REQUESTED.
* @enum{number} * @enum{number}
*/ */
/* #export */ const NotificationAccessSetupOperationStatus = { /* #export */ const NotificationAccessSetupOperationStatus = {
NOT_STARTED: 0, CONNECTION_REQUESTED: 0,
CONNECTING: 1, CONNECTING: 1,
TIMED_OUT_CONNECTING: 2, TIMED_OUT_CONNECTING: 2,
CONNECTION_DISCONNECTED: 3, CONNECTION_DISCONNECTED: 3,
...@@ -32,10 +33,13 @@ Polymer({ ...@@ -32,10 +33,13 @@ Polymer({
], ],
properties: { properties: {
/** @private {NotificationAccessSetupOperationStatus} */ /**
* A null |setupState_| indicates that the operation has not yet started.
* @private {?NotificationAccessSetupOperationStatus}
*/
setupState_: { setupState_: {
type: Number, type: Number,
value: NotificationAccessSetupOperationStatus.NOT_STARTED, value: null,
}, },
/** @private */ /** @private */
...@@ -77,8 +81,9 @@ Polymer({ ...@@ -77,8 +81,9 @@ Polymer({
/** @private */ /** @private */
showCancelButton_() { showCancelButton_() {
return this.setupState_ === return this.setupState_ === null ||
NotificationAccessSetupOperationStatus.NOT_STARTED || this.setupState_ ===
NotificationAccessSetupOperationStatus.CONNECTION_REQUESTED ||
this.setupState_ === this.setupState_ ===
NotificationAccessSetupOperationStatus.CONNECTING || NotificationAccessSetupOperationStatus.CONNECTING ||
this.setupState_ === this.setupState_ ===
...@@ -86,6 +91,11 @@ Polymer({ ...@@ -86,6 +91,11 @@ Polymer({
.SENT_MESSAGE_TO_PHONE_AND_WAITING_FOR_RESPONSE; .SENT_MESSAGE_TO_PHONE_AND_WAITING_FOR_RESPONSE;
}, },
/** @private */
showConfirmButton_() {
return this.setupState_ === null;
},
/** @private */ /** @private */
showOkButton_() { showOkButton_() {
return this.setupState_ === return this.setupState_ ===
...@@ -95,6 +105,8 @@ Polymer({ ...@@ -95,6 +105,8 @@ Polymer({
/** @private */ /** @private */
onConfirmButtonClicked_() { onConfirmButtonClicked_() {
this.browserProxy_.attemptNotificationSetup(); this.browserProxy_.attemptNotificationSetup();
this.setupState_ =
NotificationAccessSetupOperationStatus.CONNECTION_REQUESTED;
}, },
/** @private */ /** @private */
...@@ -113,17 +125,24 @@ Polymer({ ...@@ -113,17 +125,24 @@ Polymer({
* @private * @private
*/ */
getTitle_() { getTitle_() {
if (this.setupState_ === null) {
return this.i18n('multideviceNotificationAccessSetupAckTitle');
}
const Status = NotificationAccessSetupOperationStatus; const Status = NotificationAccessSetupOperationStatus;
switch (this.setupState_) { switch (this.setupState_) {
case Status.NOT_STARTED: case Status.CONNECTION_REQUESTED:
return this.i18n('multideviceNotificationAccessSetupAckTitle');
case Status.CONNECTING: case Status.CONNECTING:
case Status.SENT_MESSAGE_TO_PHONE_AND_WAITING_FOR_RESPONSE: case Status.SENT_MESSAGE_TO_PHONE_AND_WAITING_FOR_RESPONSE:
return this.i18n('multideviceNotificationAccessSetupConnectingTitle'); return this.i18n('multideviceNotificationAccessSetupConnectingTitle');
case Status.COMPLETED_SUCCESSFULLY: case Status.COMPLETED_SUCCESSFULLY:
return this.i18n('multideviceNotificationAccessSetupCompletedTitle'); return this.i18n('multideviceNotificationAccessSetupCompletedTitle');
case Status.TIMED_OUT_CONNECTING: case Status.TIMED_OUT_CONNECTING:
// TODO(hsuregan): Get the appropriate strings.
return 'Timed out connecting title';
case Status.CONNECTION_DISCONNECTED: case Status.CONNECTION_DISCONNECTED:
// TODO(hsuregan): Get the appropriate strings.
return 'Connection disconnected title';
default: default:
return ''; return '';
} }
...@@ -134,16 +153,24 @@ Polymer({ ...@@ -134,16 +153,24 @@ Polymer({
* @private * @private
*/ */
getDescription_() { getDescription_() {
if (this.setupState_ === null) {
return this.i18n('multideviceNotificationAccessSetupInstructions');
}
const Status = NotificationAccessSetupOperationStatus; const Status = NotificationAccessSetupOperationStatus;
switch (this.setupState_) { switch (this.setupState_) {
case Status.NOT_STARTED: case Status.CONNECTION_REQUESTED:
case Status.CONNECTING: case Status.CONNECTING:
case Status.SENT_MESSAGE_TO_PHONE_AND_WAITING_FOR_RESPONSE: case Status.SENT_MESSAGE_TO_PHONE_AND_WAITING_FOR_RESPONSE:
return this.i18n('multideviceNotificationAccessSetupInstructions'); return this.i18n('multideviceNotificationAccessSetupInstructions');
case Status.COMPLETED_SUCCESSFULLY: case Status.COMPLETED_SUCCESSFULLY:
return this.i18n('multideviceNotificationAccessSetupCompletedSummary'); return this.i18n('multideviceNotificationAccessSetupCompletedSummary');
case Status.TIMED_OUT_CONNECTING: case Status.TIMED_OUT_CONNECTING:
// TODO(hsuregan): Get the appropriate strings.
return 'Timed out connecting body';
case Status.CONNECTION_DISCONNECTED: case Status.CONNECTION_DISCONNECTED:
// TODO(hsuregan): Get the appropriate strings.
return 'Connection disconnected body';
default: default:
return ''; return '';
} }
......
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