For #10107: Show Today and Yesterday labels in History (#15415)

pull/200/head^2
Jocelyne 4 years ago committed by GitHub
parent f690f8736d
commit 0154c81f81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -42,7 +42,7 @@ class HistoryRobot {
fun verifyVisitedTimeTitle() {
mDevice.waitNotNull(
Until.findObject(
By.text("Last 24 hours")
By.text("Today")
),
waitingTime
)
@ -99,7 +99,7 @@ class HistoryRobot {
}
fun openThreeDotMenu(interact: ThreeDotMenuHistoryItemRobot.() -> Unit):
ThreeDotMenuHistoryItemRobot.Transition {
ThreeDotMenuHistoryItemRobot.Transition {
threeDotMenu().click()
@ -143,7 +143,7 @@ private fun assertEmptyHistoryView() =
.check(matches(withText("No history here")))
private fun assertVisitedTimeTitle() =
onView(withId(R.id.header_title)).check(matches(withText("Last 24 hours")))
onView(withId(R.id.header_title)).check(matches(withText("Today")))
private fun assertTestPageTitle(title: String) = testPageTitle()
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))

@ -17,10 +17,11 @@ import java.util.Calendar
import java.util.Date
enum class HistoryItemTimeGroup {
Today, ThisWeek, ThisMonth, Older;
Today, Yesterday, ThisWeek, ThisMonth, Older;
fun humanReadable(context: Context): String = when (this) {
Today -> context.getString(R.string.history_24_hours)
Today -> context.getString(R.string.history_today)
Yesterday -> context.getString(R.string.history_yesterday)
ThisWeek -> context.getString(R.string.history_7_days)
ThisMonth -> context.getString(R.string.history_30_days)
Older -> context.getString(R.string.history_older)
@ -81,11 +82,14 @@ class HistoryAdapter(private val historyInteractor: HistoryInteractor) :
companion object {
private const val zeroDays = 0
private const val oneDay = 1
private const val sevenDays = 7
private const val thirtyDays = 30
private val oneDayAgo = getDaysAgo(zeroDays).time
private val zeroDaysAgo = getDaysAgo(zeroDays).time
private val oneDayAgo = getDaysAgo(oneDay).time
private val sevenDaysAgo = getDaysAgo(sevenDays).time
private val thirtyDaysAgo = getDaysAgo(thirtyDays).time
private val yesterdayRange = LongRange(oneDayAgo, zeroDaysAgo)
private val lastWeekRange = LongRange(sevenDaysAgo, oneDayAgo)
private val lastMonthRange = LongRange(thirtyDaysAgo, sevenDaysAgo)
@ -99,6 +103,7 @@ class HistoryAdapter(private val historyInteractor: HistoryInteractor) :
private fun timeGroupForHistoryItem(item: HistoryItem): HistoryItemTimeGroup {
return when {
DateUtils.isToday(item.visitedAt) -> HistoryItemTimeGroup.Today
yesterdayRange.contains(item.visitedAt) -> HistoryItemTimeGroup.Yesterday
lastWeekRange.contains(item.visitedAt) -> HistoryItemTimeGroup.ThisWeek
lastMonthRange.contains(item.visitedAt) -> HistoryItemTimeGroup.ThisMonth
else -> HistoryItemTimeGroup.Older

@ -643,6 +643,10 @@
<!-- Text for the button to clear selected history items. The first parameter
is a digit showing the number of items you have selected -->
<string name="history_delete_some">Delete %1$d items</string>
<!-- Text for the header that groups the history for today -->
<string name="history_today">Today</string>
<!-- Text for the header that groups the history for yesterday -->
<string name="history_yesterday">Yesterday</string>
<!-- Text for the header that groups the history for last 24 hours -->
<string name="history_24_hours">Last 24 hours</string>
<!-- Text for the header that groups the history the past 7 days -->

Loading…
Cancel
Save