1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-30 12:00:32 +00:00

Merge pull request #10952 from bg172/release-0.27.0

Add an intuitive prefix for the duration of lists in the UI
This commit is contained in:
Stypox 2024-04-11 09:27:54 +02:00 committed by GitHub
commit 5bf77160f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 5 deletions

View File

@ -506,7 +506,7 @@ public class PlaylistFragment extends BaseListInfoFragment<StreamInfoItem, Playl
Localization.concatenateStrings(
Localization.localizeStreamCount(activity, streamCount),
Localization.getDurationString(playlistOverallDurationSeconds,
isDurationComplete))
isDurationComplete, true))
);
}
}

View File

@ -837,7 +837,8 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
headerBinding.playlistStreamCount.setText(
Localization.concatenateStrings(
Localization.localizeStreamCount(activity, streamCount),
Localization.getDurationString(playlistOverallDurationSeconds))
Localization.getDurationString(playlistOverallDurationSeconds,
true, true))
);
}
}

View File

@ -245,7 +245,7 @@ public final class Localization {
* @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);
}
/**
@ -254,9 +254,11 @@ public final class Localization {
* 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 */
@ -274,8 +276,9 @@ public final class Localization {
} 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;
}
/**