Skip to content

Commit

Permalink
Merge pull request #10952 from bg172/release-0.27.0
Browse files Browse the repository at this point in the history
Add an intuitive prefix for the duration of lists in the UI
  • Loading branch information
Stypox authored Apr 11, 2024
2 parents d9da84c + 13baaa3 commit 5bf7716
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
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;
}

/**
Expand Down

0 comments on commit 5bf7716

Please sign in to comment.