Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(564)

Side by Side Diff: ash/system/chromeos/power/power_status_view.cc

Issue 147443007: Add support for localized time strings with two units, eg. "2 hours 17 minutes" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Tony's comments Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/system/chromeos/power/power_status_view.h" 5 #include "ash/system/chromeos/power/power_status_view.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_delegate.h" 8 #include "ash/shell_delegate.h"
9 #include "ash/system/chromeos/power/power_status.h" 9 #include "ash/system/chromeos/power/power_status.h"
10 #include "ash/system/chromeos/power/tray_power.h" 10 #include "ash/system/chromeos/power/tray_power.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 int hour = 0, min = 0; 179 int hour = 0, min = 0;
180 PowerStatus::SplitTimeIntoHoursAndMinutes(time, &hour, &min); 180 PowerStatus::SplitTimeIntoHoursAndMinutes(time, &hour, &min);
181 if (status.IsBatteryCharging()) { 181 if (status.IsBatteryCharging()) {
182 time_label_->SetText( 182 time_label_->SetText(
183 l10n_util::GetStringFUTF16( 183 l10n_util::GetStringFUTF16(
184 IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL, 184 IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL,
185 base::IntToString16(hour), 185 base::IntToString16(hour),
186 base::IntToString16(min))); 186 base::IntToString16(min)));
187 } else { 187 } else {
188 // This is a low battery warning prompting the user in minutes. 188 // This is a low battery warning prompting the user in minutes.
189 time_label_->SetText(ui::TimeFormat::TimeRemainingLong( 189 time_label_->SetText(ui::TimeFormat::Simple(
190 ui::TimeFormat::FORMAT_REMAINING, ui::TimeFormat::LENGTH_LONG,
190 base::TimeDelta::FromMinutes(hour * 60 + min))); 191 base::TimeDelta::FromMinutes(hour * 60 + min)));
191 } 192 }
192 } else { 193 } else {
193 time_label_->SetText(base::string16()); 194 time_label_->SetText(base::string16());
194 } 195 }
195 } 196 }
196 197
197 void PowerStatusView::ChildPreferredSizeChanged(views::View* child) { 198 void PowerStatusView::ChildPreferredSizeChanged(views::View* child) {
198 PreferredSizeChanged(); 199 PreferredSizeChanged();
199 } 200 }
(...skipping 12 matching lines...) Expand all
212 213
213 // Move the time_status_label_ closer to percentage_label_. 214 // Move the time_status_label_ closer to percentage_label_.
214 if (percentage_label_ && time_status_label_ && 215 if (percentage_label_ && time_status_label_ &&
215 percentage_label_->visible() && time_status_label_->visible()) { 216 percentage_label_->visible() && time_status_label_->visible()) {
216 time_status_label_->SetX(percentage_label_->bounds().right() + 1); 217 time_status_label_->SetX(percentage_label_->bounds().right() + 1);
217 } 218 }
218 } 219 }
219 220
220 } // namespace internal 221 } // namespace internal
221 } // namespace ash 222 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/power/power_status.cc ('k') | ash/system/logout_button/logout_confirmation_dialog_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698