Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3841: 'time_ago' & quantity plurals should be combined #4558

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,14 @@ public static void setDrawableEndCompat(
}

private static String getTimeAgo(View view, long lastVisitedTimestamp) {
long timeStampMillis = ensureTimestampIsInMilliseconds(lastVisitedTimestamp);
long currentTimeMillis = getOppiaClock(view).getCurrentTimeMs();
AppLanguageResourceHandler resourceHandler = getResourceHandler(view);

if (timeStampMillis > currentTimeMillis || timeStampMillis <= 0) {
if (lastVisitedTimestamp > currentTimeMillis || lastVisitedTimestamp <= 0) {
return resourceHandler.getStringInLocale(R.string.last_logged_in_recently);
}

long timeDifferenceMillis = currentTimeMillis - timeStampMillis;
long timeDifferenceMillis = currentTimeMillis - lastVisitedTimestamp;

if (timeDifferenceMillis < (int) TimeUnit.MINUTES.toMillis(1)) {
return resourceHandler.getStringInLocale(R.string.just_now);
Expand Down Expand Up @@ -107,24 +106,11 @@ private static String getPluralString(
@PluralsRes int pluralsResId,
int count
) {
// TODO(#3841): Combine these strings together.
return resourceHandler.getStringInLocaleWithWrapping(
R.string.time_ago,
resourceHandler.getQuantityStringInLocaleWithWrapping(
pluralsResId, count, String.valueOf(count)
)
return resourceHandler.getQuantityStringInLocaleWithWrapping(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this change going to remove the time_ago text altogether? I'm not sure that's what we want without the code that combines plurals. Is there a reason that was removed in this new PR?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured yesterday there's this problem from CI tests. I'll work to resolve this.

pluralsResId, count, String.valueOf(count)
);
}

private static long ensureTimestampIsInMilliseconds(long lastVisitedTimestamp) {
// TODO(#3842): Investigate & remove this check.
if (lastVisitedTimestamp < 1000000000000L) {
// If timestamp is given in seconds, convert that to milliseconds.
return TimeUnit.SECONDS.toMillis(lastVisitedTimestamp);
}
return lastVisitedTimestamp;
}

private static AppLanguageResourceHandler getResourceHandler(View view) {
AppLanguageActivityInjectorProvider provider =
(AppLanguageActivityInjectorProvider) getAttachedActivity(view);
Expand Down