Commit fd096a56 authored by Gabriele M's avatar Gabriele M

Allow to properly translate the download ETA string

Change-Id: Ie6bbbddbbd9fd7adbc16472ad9c42c1d257413a1
parent cc1ad0e8
......@@ -86,7 +86,7 @@
<string name="list_build_version">LineageOS <xliff:g id="version" example="14.1">%1$s</xliff:g></string>
<string name="list_build_version_date">LineageOS <xliff:g id="version" example="14.1">%1$s</xliff:g> - <xliff:g id="date" example="July 11, 2017">%2$s</xliff:g></string>
<string name="list_download_progress_new"><xliff:g id="filesize_without_unit" example="12.2">%1$s</xliff:g> of <xliff:g id="filesize_without_unit" example="310 MB">%2$s</xliff:g><xliff:g id="percentage" example="56">%3$s</xliff:g></string>
<string name="list_download_progress_eta_new"><xliff:g id="filesize_without_unit" example="12.2">%1$s</xliff:g> of <xliff:g id="filesize_without_unit" example="310 MB">%2$s</xliff:g> (<xliff:g id="duration" example="3 minutes">%3$s</xliff:g> left) • <xliff:g id="percentage" example="56">%4$s</xliff:g></string>
<string name="list_download_progress_eta_new"><xliff:g id="filesize_without_unit" example="12.2">%1$s</xliff:g> of <xliff:g id="filesize_without_unit" example="310 MB">%2$s</xliff:g> (<xliff:g id="eta" example="3 minutes left">%3$s</xliff:g>) • <xliff:g id="percentage" example="56">%4$s</xliff:g></string>
<string name="list_verifying_update">Verifying update</string>
<string name="list_no_updates">No new updates found. To manually check for new updates, use the Refresh button.</string>
......@@ -115,17 +115,17 @@
<string name="notification_export_fail">Export error</string>
<string name="toast_already_exporting">Already exporting an update</string>
<plurals name="duration_seconds">
<item quantity="one">1 second</item>
<item quantity="other"><xliff:g id="count">%d</xliff:g> seconds</item>
<plurals name="eta_seconds">
<item quantity="one">1 second left</item>
<item quantity="other"><xliff:g id="count">%d</xliff:g> seconds left</item>
</plurals>
<plurals name="duration_minutes">
<item quantity="one">1 minute</item>
<item quantity="other"><xliff:g id="count">%d</xliff:g> minutes</item>
<plurals name="eta_minutes">
<item quantity="one">1 minute left</item>
<item quantity="other"><xliff:g id="count">%d</xliff:g> minutes left</item>
</plurals>
<plurals name="duration_hours">
<plurals name="eta_hours">
<item quantity="one">1 hour</item>
<item quantity="other"><xliff:g id="count">%d</xliff:g> hours</item>
<item quantity="other"><xliff:g id="count">%d</xliff:g> hours left</item>
</plurals>
<string name="update_on_mobile_data_title">Warning</string>
......
......@@ -133,7 +133,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
update.getProgress() / 100.f);
long eta = update.getEta();
if (eta > 0) {
CharSequence etaString = StringGenerator.formatDuration(mActivity, eta * 1000);
CharSequence etaString = StringGenerator.formatETA(mActivity, eta * 1000);
viewHolder.mProgressText.setText(mActivity.getString(
R.string.list_download_progress_eta_new, downloaded, total, etaString,
percentage));
......
......@@ -393,7 +393,7 @@ public class UpdaterService extends Service {
setNotificationTitle(update);
String speed = Formatter.formatFileSize(this, update.getSpeed());
CharSequence eta = StringGenerator.formatDuration(this, update.getEta() * 1000);
CharSequence eta = StringGenerator.formatETA(this, update.getEta() * 1000);
mNotificationStyle.bigText(
getString(R.string.text_download_speed, eta, speed));
......
......@@ -67,20 +67,20 @@ public final class StringGenerator {
return String.format(getCurrentLocale(context), "%.0f", bytes / 1024.f / 1024.f);
}
public static String formatDuration(Context context, long millis) {
public static String formatETA(Context context, long millis) {
final long SECOND_IN_MILLIS = 1000;
final long MINUTE_IN_MILLIS = SECOND_IN_MILLIS * 60;
final long HOUR_IN_MILLIS = MINUTE_IN_MILLIS * 60;
Resources res = context.getResources();
if (millis >= HOUR_IN_MILLIS) {
final int hours = (int) ((millis + 1800000) / HOUR_IN_MILLIS);
return res.getQuantityString(R.plurals.duration_hours, hours, hours);
return res.getQuantityString(R.plurals.eta_hours, hours, hours);
} else if (millis >= MINUTE_IN_MILLIS) {
final int minutes = (int) ((millis + 30000) / MINUTE_IN_MILLIS);
return res.getQuantityString(R.plurals.duration_minutes, minutes, minutes);
return res.getQuantityString(R.plurals.eta_minutes, minutes, minutes);
} else {
final int seconds = (int) ((millis + 500) / SECOND_IN_MILLIS);
return res.getQuantityString(R.plurals.duration_seconds, seconds, seconds);
return res.getQuantityString(R.plurals.eta_seconds, seconds, seconds);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment