diff options
Diffstat (limited to 'InCallUI')
-rw-r--r-- | InCallUI/src/com/android/incallui/CallCardFragment.java | 10 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/InCallDateUtils.java | 41 |
2 files changed, 26 insertions, 25 deletions
diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index 3211c4784..3b126444d 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -708,11 +708,11 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr } String callTimeElapsed = DateUtils.formatElapsedTime(duration / 1000); mElapsedTime.setText(callTimeElapsed); - /* - * TODO: Temporarily disabled (b/20427882) - String durationDescription = InCallDateUtils.formatDetailedDuration(duration); - mElapsedTime.setContentDescription(durationDescription); - */ + + String durationDescription = + InCallDateUtils.formatDuration(getView().getContext(), duration); + mElapsedTime.setContentDescription( + !TextUtils.isEmpty(durationDescription) ? durationDescription : null); } else { // hide() animation has no effect if it is already hidden. AnimUtils.fadeOut(mElapsedTime, AnimUtils.DEFAULT_DURATION); diff --git a/InCallUI/src/com/android/incallui/InCallDateUtils.java b/InCallUI/src/com/android/incallui/InCallDateUtils.java index 156eea06f..da3bb6bf4 100644 --- a/InCallUI/src/com/android/incallui/InCallDateUtils.java +++ b/InCallUI/src/com/android/incallui/InCallDateUtils.java @@ -1,21 +1,18 @@ package com.android.incallui; +import android.content.Context; import android.content.res.Resources; /** * Methods to parse time and date information in the InCallUi */ public class InCallDateUtils { - public InCallDateUtils() { - - } /** - * Return given duration in a human-friendly format. For example, "4 - * minutes 3 seconds" or "3 hours 1 second". Returns the hours, minutes and seconds in that - * order if they exist. + * Return given duration in a human-friendly format. For example, "4 minutes 3 seconds" or + * "3 hours 1 second". Returns the hours, minutes and seconds in that order if they exist. */ - public static String formatDetailedDuration(long millis) { + public static String formatDuration(Context context, long millis) { int hours = 0; int minutes = 0; int seconds = 0; @@ -30,24 +27,28 @@ public class InCallDateUtils { } seconds = elapsedSeconds; - final Resources res = Resources.getSystem(); + final Resources res = context.getResources(); StringBuilder duration = new StringBuilder(); - if (hours > 0) { - duration.append(res.getQuantityString(R.plurals.duration_hours, hours, hours)); - } - if (minutes > 0) { + try { if (hours > 0) { - duration.append(' '); + duration.append(res.getQuantityString(R.plurals.duration_hours, hours, hours)); } - duration.append(res.getQuantityString(R.plurals.duration_minutes, minutes, minutes)); - } - if (seconds > 0) { - if (hours > 0 || minutes > 0) { - duration.append(' '); + if (minutes > 0) { + if (hours > 0) { + duration.append(' '); + } + duration.append(res.getQuantityString(R.plurals.duration_minutes, minutes, minutes)); + } + if (seconds > 0) { + if (hours > 0 || minutes > 0) { + duration.append(' '); + } + duration.append(res.getQuantityString(R.plurals.duration_seconds, seconds, seconds)); } - duration.append(res.getQuantityString(R.plurals.duration_seconds, seconds, seconds)); + } catch (Resources.NotFoundException e) { + // Ignore; plurals throws an exception for an untranslated quantity for a given locale. + return null; } return duration.toString(); } - } |