Commit b8711233 authored by nancy's avatar nancy Committed by Commit Bot

Use the unified time format function in the app pause dialog.

Use the unified time format function to show the time limit in the
app pause dialog.

For example,
hour = 1 minute = 1
Show: You can use it for 1 hour and 1 minute tomorrow.

hour = 11 minute = 59
Show: You can use it for 11 hours and 59 minutes tomorrow.

hour = 10 minute = 0
Show: You can use it for 10 hours tomorrow.

hour = 0 minute = 10
Show: You can use it for 10 minutes tomorrow.

hour = 0 minute = 0
Show: You can use it for 0 seconds tomorrow.

BUG=1011235

Change-Id: I27619b2b7f999c68eabff6a337e9d54eb661db86
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1913360
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Reviewed-by: default avatarAga Wronska <agawronska@chromium.org>
Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715233}
parent 2ee47a83
......@@ -10263,26 +10263,9 @@ Please help our engineers fix this problem. Tell us what happened right before y
App paused
</message>
<message name="IDS_APP_PAUSE_HEADING_HOURS_AND_MINUTES" desc="Tells the user the app will be paused.">
The limit on "<ph name="APP_NAME">$1<ex>Google Photos</ex></ph>" that your parent set ran out. You can use it for <ph name="HOURS">$2<ex>2 hours</ex></ph> <ph name="MINUTES">$3<ex>30 minutes</ex></ph> tomorrow.
<message name="IDS_APP_PAUSE_HEADING" desc="Tells the user the app will be paused.">
The limit on "<ph name="APP_NAME">$1<ex>Google Photos</ex></ph>" that your parent set ran out. You can use it for <ph name="TIME_LIMIT">$2<ex>2 hours and 30 minutes</ex></ph> tomorrow.
</message>
<message name="IDS_APP_PAUSE_HEADING_HOURS_ONLY" desc="Tells the user the app will be paused.">
The limit on "<ph name="APP_NAME">$1<ex>Google Photos</ex></ph>" that your parent set ran out. You can use it for <ph name="HOURS">$2<ex>2 hours</ex></ph> tomorrow.
</message>
<message name="IDS_APP_PAUSE_HEADING_MINUTES_ONLY" desc="Tells the user the app will be paused.">
The limit on "<ph name="APP_NAME">$1<ex>Google Photos</ex></ph>" that your parent set ran out. You can use it for <ph name="MINUTES">$2<ex>30 minutes</ex></ph> tomorrow.
</message>
<message name="IDS_APP_PAUSE_HEADING_HOURS" desc="Tells the user the app can be run how many hours. [ICU Syntax]">
{HOURS, plural,
=1 {# hour}
other {# hours}}
</message>
<message name="IDS_APP_PAUSE_HEADING_MINUTES" desc="Tells the user the app can be run how many minutes. [ICU Syntax]">
{MINUTES, plural,
=1 {# minute}
other {# minutes}}
</message>
</messages>
</release>
......
b9d8a5bb225403e83014694d7c8693d652003cb8
\ No newline at end of file
ac9f6657699ab90f5ed2c65d5de7b67e4fdc7be8
\ No newline at end of file
8b21c8dff4948451dc44ca53f6c3ab4d4b676921
\ No newline at end of file
b9d8a5bb225403e83014694d7c8693d652003cb8
\ No newline at end of file
19bdab026c688357ed9f0275d0b795fc6f0cb23a
\ No newline at end of file
......@@ -8,6 +8,7 @@
#include <utility>
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/chrome_typography.h"
#include "chrome/grit/chromium_strings.h"
......@@ -15,12 +16,12 @@
#include "components/constrained_window/constrained_window_views.h"
#include "components/strings/grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/time_format.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"
// static
void apps::AppServiceProxy::CreatePauseDialog(
const std::string& app_name,
......@@ -50,25 +51,14 @@ AppPauseDialogView::AppPauseDialogView(
auto* icon_view = AddChildView(std::make_unique<views::ImageView>());
icon_view->SetImage(image);
base::string16 pause_hours = l10n_util::GetPluralStringFUTF16(
IDS_APP_PAUSE_HEADING_HOURS, pause_data.hours);
base::string16 pause_minutes = l10n_util::GetPluralStringFUTF16(
IDS_APP_PAUSE_HEADING_MINUTES, pause_data.minutes);
base::string16 heading_text;
if (pause_data.hours != 0 && pause_data.minutes != 0) {
heading_text = l10n_util::GetStringFUTF16(
IDS_APP_PAUSE_HEADING_HOURS_AND_MINUTES, base::UTF8ToUTF16(app_name),
pause_hours, pause_minutes);
} else if (pause_data.hours != 0) {
heading_text =
l10n_util::GetStringFUTF16(IDS_APP_PAUSE_HEADING_HOURS_ONLY,
base::UTF8ToUTF16(app_name), pause_hours);
} else if (pause_data.minutes != 0) {
heading_text =
l10n_util::GetStringFUTF16(IDS_APP_PAUSE_HEADING_MINUTES_ONLY,
base::UTF8ToUTF16(app_name), pause_minutes);
}
const int cutoff = pause_data.minutes == 0 || pause_data.hours == 0 ? 0 : -1;
base::string16 heading_text = l10n_util::GetStringFUTF16(
IDS_APP_PAUSE_HEADING, base::UTF8ToUTF16(app_name),
ui::TimeFormat::Detailed(
ui::TimeFormat::Format::FORMAT_DURATION,
ui::TimeFormat::Length::LENGTH_LONG, cutoff,
base::TimeDelta::FromHours(pause_data.hours) +
base::TimeDelta::FromMinutes(pause_data.minutes)));
auto* label = AddChildView(std::make_unique<views::Label>(heading_text));
label->SetMultiLine(true);
......
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