Print duration as number of days only on Echo (#6842)

Reverts an accidental change to the queue time display
This commit is contained in:
ByteHamster 2024-01-03 20:32:56 +01:00 committed by GitHub
parent f476086114
commit bf67218422
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View File

@ -523,7 +523,7 @@ public class QueueFragment extends Fragment implements MaterialToolbar.OnMenuIte
}
info += "";
info += getString(R.string.time_left_label);
info += Converter.getDurationStringLocalized(getActivity(), timeLeft);
info += Converter.getDurationStringLocalized(getResources(), timeLeft, false);
}
infoBar.setText(info);
}

View File

@ -83,14 +83,16 @@ public final class Converter {
* Converts milliseconds to a localized string containing hours and minutes.
*/
public static String getDurationStringLocalized(Context context, long duration) {
return getDurationStringLocalized(context.getResources(), duration);
return getDurationStringLocalized(context.getResources(), duration, false);
}
public static String getDurationStringLocalized(Resources resources, long duration) {
public static String getDurationStringLocalized(Resources resources, long duration, boolean includeDays) {
String result = "";
int h = (int) (duration / HOURS_MIL);
int d = h / 24;
if (d > 0) {
if (!includeDays) {
d = 0;
} else if (d > 0) {
String days = resources.getQuantityString(R.plurals.time_days_quantified, d, d);
result += days.replace(" ", "\u00A0") + " ";
h -= d * 24;

View File

@ -210,7 +210,7 @@ public class EchoActivity extends AppCompatActivity {
int daysUntil2024 = Math.max(356 - Calendar.getInstance().get(Calendar.DAY_OF_YEAR) + 1, 1);
long secondsPerDay = queueSecondsLeft / daysUntil2024;
String timePerDay = Converter.getDurationStringLocalized(
getLocalizedResources(this, getEchoLanguage()), secondsPerDay * 1000);
getLocalizedResources(this, getEchoLanguage()), secondsPerDay * 1000, true);
double hoursPerDay = (double) (secondsPerDay / 3600);
if (hoursPerDay < 1.5) {
viewBinding.aboveLabel.setText(R.string.echo_queue_title_clean);
@ -235,7 +235,7 @@ public class EchoActivity extends AppCompatActivity {
}
viewBinding.smallLabel.setText(getString(R.string.echo_listened_after_time,
Converter.getDurationStringLocalized(
getLocalizedResources(this, getEchoLanguage()), timeBetweenReleaseAndPlay)));
getLocalizedResources(this, getEchoLanguage()), timeBetweenReleaseAndPlay, true)));
currentDrawable = new RotatingSquaresScreen(this);
break;
case 4: