OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/common/system/chromeos/power/power_status_view.h" | 5 #include "ash/common/system/chromeos/power/power_status_view.h" |
6 | 6 |
7 #include "ash/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
8 #include "ash/common/system/chromeos/power/power_status.h" | 8 #include "ash/common/system/chromeos/power/power_status.h" |
9 #include "ash/common/system/chromeos/power/tray_power.h" | 9 #include "ash/common/system/chromeos/power/tray_power.h" |
10 #include "ash/common/system/tray/fixed_sized_image_view.h" | 10 #include "ash/common/system/tray/fixed_sized_image_view.h" |
11 #include "ash/common/system/tray/tray_constants.h" | 11 #include "ash/common/system/tray/tray_constants.h" |
12 #include "base/i18n/message_formatter.h" | 12 #include "base/i18n/number_formatting.h" |
13 #include "base/i18n/time_formatting.h" | 13 #include "base/i18n/time_formatting.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "grit/ash_strings.h" | 15 #include "grit/ash_strings.h" |
16 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
17 #include "ui/views/controls/image_view.h" | 17 #include "ui/views/controls/image_view.h" |
18 #include "ui/views/controls/label.h" | 18 #include "ui/views/controls/label.h" |
19 #include "ui/views/layout/box_layout.h" | 19 #include "ui/views/layout/box_layout.h" |
20 #include "ui/views/layout/grid_layout.h" | 20 #include "ui/views/layout/grid_layout.h" |
21 | 21 |
22 namespace ash { | 22 namespace ash { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 void PowerStatusView::UpdateText() { | 92 void PowerStatusView::UpdateText() { |
93 const PowerStatus& status = *PowerStatus::Get(); | 93 const PowerStatus& status = *PowerStatus::Get(); |
94 base::string16 battery_percentage; | 94 base::string16 battery_percentage; |
95 base::string16 battery_time_status; | 95 base::string16 battery_time_status; |
96 | 96 |
97 if (status.IsBatteryFull()) { | 97 if (status.IsBatteryFull()) { |
98 battery_time_status = | 98 battery_time_status = |
99 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_FULL); | 99 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_FULL); |
100 } else { | 100 } else { |
101 battery_percentage = base::i18n::MessageFormatter::FormatWithNumberedArgs( | 101 battery_percentage = base::FormatPercent(status.GetRoundedBatteryPercent()); |
102 base::ASCIIToUTF16("{0,number,percent}"), | |
103 static_cast<double>(status.GetRoundedBatteryPercent()) / 100.0); | |
104 if (status.IsUsbChargerConnected()) { | 102 if (status.IsUsbChargerConnected()) { |
105 battery_time_status = l10n_util::GetStringUTF16( | 103 battery_time_status = l10n_util::GetStringUTF16( |
106 IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE); | 104 IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE); |
107 } else if (status.IsBatteryTimeBeingCalculated()) { | 105 } else if (status.IsBatteryTimeBeingCalculated()) { |
108 battery_time_status = | 106 battery_time_status = |
109 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING); | 107 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING); |
110 } else { | 108 } else { |
111 base::TimeDelta time = status.IsBatteryCharging() | 109 base::TimeDelta time = status.IsBatteryCharging() |
112 ? status.GetBatteryTimeToFull() | 110 ? status.GetBatteryTimeToFull() |
113 : status.GetBatteryTimeToEmpty(); | 111 : status.GetBatteryTimeToEmpty(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 // Move the time_status_label_, separator_label_, and percentage_label_ | 146 // Move the time_status_label_, separator_label_, and percentage_label_ |
149 // closer to each other. | 147 // closer to each other. |
150 if (percentage_label_ && separator_label_ && time_status_label_ && | 148 if (percentage_label_ && separator_label_ && time_status_label_ && |
151 percentage_label_->visible() && time_status_label_->visible()) { | 149 percentage_label_->visible() && time_status_label_->visible()) { |
152 separator_label_->SetX(percentage_label_->bounds().right() + 1); | 150 separator_label_->SetX(percentage_label_->bounds().right() + 1); |
153 time_status_label_->SetX(separator_label_->bounds().right() + 1); | 151 time_status_label_->SetX(separator_label_->bounds().right() + 1); |
154 } | 152 } |
155 } | 153 } |
156 | 154 |
157 } // namespace ash | 155 } // namespace ash |
OLD | NEW |