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

Add an intuitive prefix for the duration of lists in the UI #10952

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
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 @@ -506,7 +506,7 @@ private void setStreamCountAndOverallDuration(final List<StreamInfoItem> list,
Localization.concatenateStrings(
Localization.localizeStreamCount(activity, streamCount),
Localization.getDurationString(playlistOverallDurationSeconds,
isDurationComplete))
isDurationComplete, true))
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,8 @@ private void setStreamCountAndOverallDuration(final ArrayList<LocalItem> itemsLi
headerBinding.playlistStreamCount.setText(
Localization.concatenateStrings(
Localization.localizeStreamCount(activity, streamCount),
Localization.getDurationString(playlistOverallDurationSeconds))
Localization.getDurationString(playlistOverallDurationSeconds,
true, true))
);
}
}
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/java/org/schabi/newpipe/util/Localization.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public static String likeCount(@NonNull final Context context, final int likeCou
* @return a formatted duration String or {@code 0:00} if the duration is zero.
*/
public static String getDurationString(final long duration) {
return getDurationString(duration, true);
return getDurationString(duration, true, false);
}

/**
Expand All @@ -254,9 +254,11 @@ public static String getDurationString(final long duration) {
* duration string.
* @param duration the duration in seconds
* @param isDurationComplete whether the given duration is complete or whether info is missing
* @param showDurationPrefix whether the duration-prefix shall be shown
* @return a formatted duration String or {@code 0:00} if the duration is zero.
*/
public static String getDurationString(final long duration, final boolean isDurationComplete) {
public static String getDurationString(final long duration, final boolean isDurationComplete,
final boolean showDurationPrefix) {
final String output;

final long days = duration / (24 * 60 * 60L); /* greater than a day */
Expand All @@ -274,8 +276,9 @@ public static String getDurationString(final long duration, final boolean isDura
} else {
output = String.format(Locale.US, "%d:%02d", minutes, seconds);
}
final String durationPrefix = showDurationPrefix ? "⏱ " : "";
final String durationPostfix = isDurationComplete ? "" : "+";
return output + durationPostfix;
return durationPrefix + output + durationPostfix;
AudricV marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
Loading