Commit 11a9ee5f authored by Andre Le's avatar Andre Le Committed by Commit Bot

[CrOS PhoneHub] Add tooltip for phone status and task continuation.

Add tooltip texts for signal icon, battery icon and continue browsing
chips.

Bug: 1106937,1126208
Change-Id: I2dfd71a84b735c311825dc74c5713ca7457bc0f7
Fixed: 1147083
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2527585Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarTim Song <tengs@chromium.org>
Commit-Queue: Andre Le <leandre@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826503}
parent 4c500b6a
...@@ -1027,6 +1027,33 @@ This file contains the strings for ash. ...@@ -1027,6 +1027,33 @@ This file contains the strings for ash.
<message name="IDS_ASH_PHONE_HUB_TRAY_ACCESSIBLE_NAME" desc="The accessible name of the Phone Hub tray bubble for screen readers."> <message name="IDS_ASH_PHONE_HUB_TRAY_ACCESSIBLE_NAME" desc="The accessible name of the Phone Hub tray bubble for screen readers.">
Phone Hub Phone Hub
</message> </message>
<message name="IDS_ASH_PHONE_HUB_MOBILE_STATUS_NO_SIM" desc="The tooltip text indicating the phone does not have a physical SIM inserted or an eSIM profile set up.">
No SIM
</message>
<message name="IDS_ASH_PHONE_HUB_MOBILE_STATUS_NO_NETWORK" desc="The tooltip text indicating the phone has a SIM, but it is not connected to a mobile network.">
No mobile network
</message>
<message name="IDS_ASH_PHONE_HUB_MOBILE_STATUS_NETWORK_STRENGTH" desc="The tooltip text indicating the strength of the phone's mobile network">
Mobile network. Signal strength of <ph name="SIGNAL_STRENGTH">$1<ex>1</ex></ph>
</message>
<message name="IDS_ASH_PHONE_HUB_BATTERY_STATUS_NOT_CHARGING" desc="The tooltip text indicating the phone is currently not charging">
Not charging
</message>
<message name="IDS_ASH_PHONE_HUB_BATTERY_STATUS_CHARGING_AC" desc="The tooltip text indicating the phone is currently charging via AC adapter.">
Charging via adapter
</message>
<message name="IDS_ASH_PHONE_HUB_BATTERY_STATUS_CHARGING_USB" desc="The tooltip text indicating the phone is currently charging via a USB connection.">
Charging via USB
</message>
<message name="IDS_ASH_PHONE_HUB_BATTERY_SAVER_ON" desc="The tooltip text indicating the phone is currently in battery saver mode.">
Battery saver mode is on
</message>
<message name="IDS_ASH_PHONE_HUB_BATTERY_SAVER_OFF" desc="The tooltip text indicating the phone is currently not in battery saver mode.">
Battery saver mode is off
</message>
<message name="IDS_ASH_PHONE_HUB_BATTERY_TOOLTIP" desc="The tooltip text describing the state of the phone's battery.">
<ph name="CHARGING_STATE">$1<ex>Not charging</ex></ph>. <ph name="BATTERY_SAVER_STATE">$2<ex>Battery saver mode is on</ex></ph>
</message>
<message name="IDS_ASH_PHONE_HUB_ENABLE_HOTSPOT_TITLE" desc="Title of the enable hotspot toggle in the phone hub bubble."> <message name="IDS_ASH_PHONE_HUB_ENABLE_HOTSPOT_TITLE" desc="Title of the enable hotspot toggle in the phone hub bubble.">
Enable hotspot Enable hotspot
</message> </message>
......
087c578cad7aab48a0799f305b0ab48a7f3fc8c1
\ No newline at end of file
06b308c9fa3bbe524efd9203fcacc85d2a580edc
\ No newline at end of file
06b308c9fa3bbe524efd9203fcacc85d2a580edc
\ No newline at end of file
10511bdfef1c21794c7585bfbdb81ef3ae02d6a7
\ No newline at end of file
087c578cad7aab48a0799f305b0ab48a7f3fc8c1
\ No newline at end of file
06b308c9fa3bbe524efd9203fcacc85d2a580edc
\ No newline at end of file
4d827dabdd9bdb8ddec9e95ec622f33dff3e620b
\ No newline at end of file
a10b1688a4118382c159f29acef49e4df4f49ebc
\ No newline at end of file
e755f5584d211d6fa4ad7092c9f8d8f683a97551
\ No newline at end of file
...@@ -91,6 +91,8 @@ ContinueBrowsingChip::ContinueBrowsingChip( ...@@ -91,6 +91,8 @@ ContinueBrowsingChip::ContinueBrowsingChip(
title_label->SetMaxLines(kTitleMaxLines); title_label->SetMaxLines(kTitleMaxLines);
title_label->SetFontList( title_label->SetFontList(
title_label->font_list().DeriveWithWeight(gfx::Font::Weight::BOLD)); title_label->font_list().DeriveWithWeight(gfx::Font::Weight::BOLD));
SetTooltipText(metadata.title);
} }
void ContinueBrowsingChip::OnPaintBackground(gfx::Canvas* canvas) { void ContinueBrowsingChip::OnPaintBackground(gfx::Canvas* canvas) {
......
...@@ -17,7 +17,9 @@ ...@@ -17,7 +17,9 @@
#include "ash/system/tray/tray_constants.h" #include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_popup_utils.h" #include "ash/system/tray/tray_popup_utils.h"
#include "base/i18n/number_formatting.h" #include "base/i18n/number_formatting.h"
#include "base/strings/strcat.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/color_utils.h" #include "ui/gfx/color_utils.h"
#include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/insets.h"
...@@ -200,13 +202,18 @@ void PhoneStatusView::UpdateMobileStatus() { ...@@ -200,13 +202,18 @@ void PhoneStatusView::UpdateMobileStatus() {
AshColorProvider::ContentLayerType::kIconColorPrimary); AshColorProvider::ContentLayerType::kIconColorPrimary);
gfx::ImageSkia signal_image; gfx::ImageSkia signal_image;
base::string16 tooltip_text;
switch (phone_status.mobile_status()) { switch (phone_status.mobile_status()) {
case PhoneStatusModel::MobileStatus::kNoSim: case PhoneStatusModel::MobileStatus::kNoSim:
signal_image = CreateVectorIcon(kPhoneHubMobileNoSimIcon, primary_color); signal_image = CreateVectorIcon(kPhoneHubMobileNoSimIcon, primary_color);
tooltip_text =
l10n_util::GetStringUTF16(IDS_ASH_PHONE_HUB_MOBILE_STATUS_NO_SIM);
break; break;
case PhoneStatusModel::MobileStatus::kSimButNoReception: case PhoneStatusModel::MobileStatus::kSimButNoReception:
signal_image = signal_image =
CreateVectorIcon(kPhoneHubMobileNoConnectionIcon, primary_color); CreateVectorIcon(kPhoneHubMobileNoConnectionIcon, primary_color);
tooltip_text =
l10n_util::GetStringUTF16(IDS_ASH_PHONE_HUB_MOBILE_STATUS_NO_NETWORK);
break; break;
case PhoneStatusModel::MobileStatus::kSimWithReception: case PhoneStatusModel::MobileStatus::kSimWithReception:
const PhoneStatusModel::MobileConnectionMetadata& metadata = const PhoneStatusModel::MobileConnectionMetadata& metadata =
...@@ -216,11 +223,15 @@ void PhoneStatusView::UpdateMobileStatus() { ...@@ -216,11 +223,15 @@ void PhoneStatusView::UpdateMobileStatus() {
network_icon::SignalStrengthImageSource>( network_icon::SignalStrengthImageSource>(
network_icon::ImageType::BARS, primary_color, kStatusIconSize, network_icon::ImageType::BARS, primary_color, kStatusIconSize,
signal_strength); signal_strength);
tooltip_text = l10n_util::GetStringFUTF16(
IDS_ASH_PHONE_HUB_MOBILE_STATUS_NETWORK_STRENGTH,
base::NumberToString16(signal_strength));
break; break;
} }
signal_icon_->SetImage(signal_image); signal_icon_->SetImage(signal_image);
signal_icon_->SetImageSize(kStatusIconSize); signal_icon_->SetImageSize(kStatusIconSize);
signal_icon_->SetTooltipText(tooltip_text);
} }
void PhoneStatusView::UpdateBatteryStatus() { void PhoneStatusView::UpdateBatteryStatus() {
...@@ -243,6 +254,7 @@ void PhoneStatusView::UpdateBatteryStatus() { ...@@ -243,6 +254,7 @@ void PhoneStatusView::UpdateBatteryStatus() {
in_battery_saver_mode); in_battery_saver_mode);
battery_icon_->SetImage( battery_icon_->SetImage(
gfx::ImageSkia(base::WrapUnique(source), source->size())); gfx::ImageSkia(base::WrapUnique(source), source->size()));
SetBatteryTooltipText();
battery_label_->SetText( battery_label_->SetText(
base::FormatPercent(phone_status.battery_percentage())); base::FormatPercent(phone_status.battery_percentage()));
} }
...@@ -276,6 +288,37 @@ PowerStatus::BatteryImageInfo PhoneStatusView::CalculateBatteryInfo() { ...@@ -276,6 +288,37 @@ PowerStatus::BatteryImageInfo PhoneStatusView::CalculateBatteryInfo() {
return info; return info;
} }
void PhoneStatusView::SetBatteryTooltipText() {
const PhoneStatusModel& phone_status =
phone_model_->phone_status_model().value();
int charging_tooltip_id;
switch (phone_status.charging_state()) {
case PhoneStatusModel::ChargingState::kNotCharging:
charging_tooltip_id = IDS_ASH_PHONE_HUB_BATTERY_STATUS_NOT_CHARGING;
break;
case PhoneStatusModel::ChargingState::kChargingAc:
charging_tooltip_id = IDS_ASH_PHONE_HUB_BATTERY_STATUS_CHARGING_AC;
break;
case PhoneStatusModel::ChargingState::kChargingUsb:
charging_tooltip_id = IDS_ASH_PHONE_HUB_BATTERY_STATUS_CHARGING_USB;
break;
}
base::string16 charging_tooltip =
l10n_util::GetStringUTF16(charging_tooltip_id);
bool battery_saver_on = phone_status.battery_saver_state() ==
PhoneStatusModel::BatterySaverState::kOn;
base::string16 batter_saver_tooltip =
battery_saver_on
? l10n_util::GetStringUTF16(IDS_ASH_PHONE_HUB_BATTERY_SAVER_ON)
: l10n_util::GetStringUTF16(IDS_ASH_PHONE_HUB_BATTERY_SAVER_OFF);
battery_icon_->SetTooltipText(
l10n_util::GetStringFUTF16(IDS_ASH_PHONE_HUB_BATTERY_TOOLTIP,
charging_tooltip, batter_saver_tooltip));
}
void PhoneStatusView::ClearExistingStatus() { void PhoneStatusView::ClearExistingStatus() {
// Clear mobile status. // Clear mobile status.
signal_icon_->SetImage(gfx::ImageSkia()); signal_icon_->SetImage(gfx::ImageSkia());
......
...@@ -51,6 +51,7 @@ class ASH_EXPORT PhoneStatusView ...@@ -51,6 +51,7 @@ class ASH_EXPORT PhoneStatusView
void UpdateMobileStatus(); void UpdateMobileStatus();
void UpdateBatteryStatus(); void UpdateBatteryStatus();
PowerStatus::BatteryImageInfo CalculateBatteryInfo(); PowerStatus::BatteryImageInfo CalculateBatteryInfo();
void SetBatteryTooltipText();
// Clear the existing labels and icons for the phone status. // Clear the existing labels and icons for the phone status.
void ClearExistingStatus(); void ClearExistingStatus();
......
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