Commit 3ab6dcb4 authored by Chris Lu's avatar Chris Lu Committed by Commit Bot

[ios] Don't show day if time synced is today or yesterday in Recent Tabs

Removes the date for sync times that occur within the same calendar day. Replaces date with "Yesterday" for sync times that occur in the previous calendar day.

Screenshot: https://drive.google.com/open?id=1uFZHxOgHytaARm97MWONgekuymVxRBvJ, https://drive.google.com/open?id=1ZZr5HR___1y_CuQKcoNP-5Umd2Lz5K3n

Bug: 870043
Change-Id: Id6d4ecb424d5e709e66e48cd57d0c4add5683b1c
Reviewed-on: https://chromium-review.googlesource.com/1177891Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Commit-Queue: Chris Lu <thegreenfrog@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583871}
parent 938e3b65
...@@ -939,6 +939,9 @@ locale. The strings in this file are specific to iOS. ...@@ -939,6 +939,9 @@ locale. The strings in this file are specific to iOS.
<message name="IDS_IOS_OPEN_TABS_RECENTLY_SYNCED" desc="Relative time display for small time deltas, anything less than a minute [Length: 10em] [iOS only]"> <message name="IDS_IOS_OPEN_TABS_RECENTLY_SYNCED" desc="Relative time display for small time deltas, anything less than a minute [Length: 10em] [iOS only]">
Seconds ago Seconds ago
</message> </message>
<message name="IDS_IOS_OPEN_TABS_SYNCED_YESTERDAY" desc="Relative time display for time deltas that cover yesterday [Length: 10em] [iOS only]">
Yesterday
</message>
<message name="IDS_IOS_OPTIONS_ACCOUNTS_ADD_ACCOUNT_BUTTON" desc="The title of the Add account button on the accounts settings screen [iOS only] [30em]"> <message name="IDS_IOS_OPTIONS_ACCOUNTS_ADD_ACCOUNT_BUTTON" desc="The title of the Add account button on the accounts settings screen [iOS only] [30em]">
Add Account… Add Account…
</message> </message>
......
...@@ -90,9 +90,6 @@ int const kNumberOfSectionsBeforeSessions = 1; ...@@ -90,9 +90,6 @@ int const kNumberOfSectionsBeforeSessions = 1;
const CGFloat kEstimatedRowHeight = 56; const CGFloat kEstimatedRowHeight = 56;
// Separation space between sections. // Separation space between sections.
const CGFloat kSeparationSpaceBetweenSections = 9; const CGFloat kSeparationSpaceBetweenSections = 9;
// The UI displays relative time for up to this number of hours and then
// switches to absolute values.
const int kRelativeTimeMaxHours = 4;
// Section index for recently closed tabs. // Section index for recently closed tabs.
const int kRecentlyClosedTabsSectionIndex = 0; const int kRecentlyClosedTabsSectionIndex = 0;
...@@ -832,23 +829,35 @@ const int kRecentlyClosedTabsSectionIndex = 0; ...@@ -832,23 +829,35 @@ const int kRecentlyClosedTabsSectionIndex = 0;
if (last_used_delta.InMicroseconds() < base::Time::kMicrosecondsPerMinute) { if (last_used_delta.InMicroseconds() < base::Time::kMicrosecondsPerMinute) {
timeString = l10n_util::GetNSString(IDS_IOS_OPEN_TABS_RECENTLY_SYNCED); timeString = l10n_util::GetNSString(IDS_IOS_OPEN_TABS_RECENTLY_SYNCED);
// This will return something similar to "Seconds ago mm/dd/yy" // This will return something similar to "Seconds ago"
return [NSString stringWithFormat:@"%@ %@", timeString, dateString]; return [NSString stringWithFormat:@"%@", timeString];
} }
if (last_used_delta.InHours() < kRelativeTimeMaxHours) { NSDate* date = [NSDate dateWithTimeIntervalSince1970:time.ToTimeT()];
timeString =
[NSDateFormatter localizedStringFromDate:date
dateStyle:NSDateFormatterNoStyle
timeStyle:NSDateFormatterShortStyle];
NSInteger today = [[NSCalendar currentCalendar] component:NSCalendarUnitDay
fromDate:[NSDate date]];
NSInteger dateDay =
[[NSCalendar currentCalendar] component:NSCalendarUnitDay fromDate:date];
if (today == dateDay) {
timeString = base::SysUTF16ToNSString( timeString = base::SysUTF16ToNSString(
ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_ELAPSED, ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_ELAPSED,
ui::TimeFormat::LENGTH_SHORT, last_used_delta)); ui::TimeFormat::LENGTH_SHORT, last_used_delta));
// This will return something similar to "1 min/hour ago mm/dd/yy" // This will return something similar to "1 min/hour ago"
return [NSString stringWithFormat:@"%@", timeString];
}
if (today - dateDay == 1) {
dateString = l10n_util::GetNSString(IDS_IOS_OPEN_TABS_SYNCED_YESTERDAY);
// This will return something similar to "H:MM Yesterday"
return [NSString stringWithFormat:@"%@ %@", timeString, dateString]; return [NSString stringWithFormat:@"%@ %@", timeString, dateString];
} }
NSDate* date = [NSDate dateWithTimeIntervalSince1970:time.ToTimeT()];
timeString =
[NSDateFormatter localizedStringFromDate:date
dateStyle:NSDateFormatterNoStyle
timeStyle:NSDateFormatterShortStyle];
// This will return something similar to "H:MM mm/dd/yy" // This will return something similar to "H:MM mm/dd/yy"
return [NSString stringWithFormat:@"%@ %@", timeString, dateString]; return [NSString stringWithFormat:@"%@ %@", timeString, dateString];
} }
......
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