summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNancy Chen <nancychen@google.com>2014-12-30 20:31:13 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-12-30 20:31:14 +0000
commit179f49b03bd5f95de448996b2aef1d97dcd17287 (patch)
treee2f1525db38c261bd77b4d8eca36862249b8da2f
parentad9aeb996dedb7b9d3c7b25edbcfe05f9779d51e (diff)
parent49ca77978e6d48a47d4c74afb1c2768f86e5d265 (diff)
downloadpackages_apps_InCallUI-179f49b03bd5f95de448996b2aef1d97dcd17287.tar.gz
packages_apps_InCallUI-179f49b03bd5f95de448996b2aef1d97dcd17287.tar.bz2
packages_apps_InCallUI-179f49b03bd5f95de448996b2aef1d97dcd17287.zip
Merge "Call duration should be verbalized as hours, minutes, seconds." into lmp-mr1-dev
-rw-r--r--src/com/android/incallui/CallCardFragment.java7
-rw-r--r--src/com/android/incallui/CallCardPresenter.java9
-rw-r--r--src/com/android/incallui/InCallDateUtils.java56
3 files changed, 66 insertions, 6 deletions
diff --git a/src/com/android/incallui/CallCardFragment.java b/src/com/android/incallui/CallCardFragment.java
index c70bd6ed..4bc98557 100644
--- a/src/com/android/incallui/CallCardFragment.java
+++ b/src/com/android/incallui/CallCardFragment.java
@@ -32,6 +32,7 @@ import android.telecom.DisconnectCause;
import android.telecom.VideoProfile;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
+import android.text.format.DateUtils;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
@@ -47,6 +48,7 @@ import android.view.animation.AnimationUtils;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
+
import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette;
import com.android.contacts.common.widget.FloatingActionButtonController;
import com.android.incallui.service.PhoneNumberService;
@@ -592,12 +594,15 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
}
@Override
- public void setPrimaryCallElapsedTime(boolean show, String callTimeElapsed) {
+ public void setPrimaryCallElapsedTime(boolean show, long duration) {
if (show) {
if (mElapsedTime.getVisibility() != View.VISIBLE) {
AnimUtils.fadeIn(mElapsedTime, AnimUtils.DEFAULT_DURATION);
}
+ String callTimeElapsed = DateUtils.formatElapsedTime(duration / 1000);
+ String durationDescription = InCallDateUtils.formatDetailedDuration(duration);
mElapsedTime.setText(callTimeElapsed);
+ mElapsedTime.setContentDescription(durationDescription);
} else {
// hide() animation has no effect if it is already hidden.
AnimUtils.fadeOut(mElapsedTime, AnimUtils.DEFAULT_DURATION);
diff --git a/src/com/android/incallui/CallCardPresenter.java b/src/com/android/incallui/CallCardPresenter.java
index a039637e..0d04f48f 100644
--- a/src/com/android/incallui/CallCardPresenter.java
+++ b/src/com/android/incallui/CallCardPresenter.java
@@ -33,7 +33,6 @@ import android.telecom.VideoProfile;
import android.telephony.PhoneNumberUtils;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
-import android.text.format.DateUtils;
import com.android.incallui.ContactInfoCache.ContactCacheEntry;
import com.android.incallui.ContactInfoCache.ContactInfoCacheCallback;
@@ -226,7 +225,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
} else {
Log.d(this, "Canceling the calltime timer");
mCallTimer.cancel();
- ui.setPrimaryCallElapsedTime(false, null);
+ ui.setPrimaryCallElapsedTime(false, 0);
}
// Set the call state
@@ -357,13 +356,13 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
if (ui == null || mPrimary == null || mPrimary.getState() != Call.State.ACTIVE) {
if (ui != null) {
- ui.setPrimaryCallElapsedTime(false, null);
+ ui.setPrimaryCallElapsedTime(false, 0);
}
mCallTimer.cancel();
} else {
final long callStart = mPrimary.getConnectTimeMillis();
final long duration = System.currentTimeMillis() - callStart;
- ui.setPrimaryCallElapsedTime(true, DateUtils.formatElapsedTime(duration / 1000));
+ ui.setPrimaryCallElapsedTime(true, duration);
}
}
@@ -734,7 +733,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
void setCallState(int state, int videoState, int sessionModificationState,
DisconnectCause disconnectCause, String connectionLabel,
Drawable connectionIcon, String gatewayNumber);
- void setPrimaryCallElapsedTime(boolean show, String duration);
+ void setPrimaryCallElapsedTime(boolean show, long duration);
void setPrimaryName(String name, boolean nameIsNumber);
void setPrimaryImage(Drawable image);
void setPrimaryPhoneNumber(String phoneNumber);
diff --git a/src/com/android/incallui/InCallDateUtils.java b/src/com/android/incallui/InCallDateUtils.java
new file mode 100644
index 00000000..88c5354c
--- /dev/null
+++ b/src/com/android/incallui/InCallDateUtils.java
@@ -0,0 +1,56 @@
+package com.android.incallui;
+
+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.
+ */
+ public static String formatDetailedDuration(long millis) {
+ int hours = 0;
+ int minutes = 0;
+ int seconds = 0;
+ int elapsedSeconds = (int) (millis / 1000);
+ if (elapsedSeconds >= 3600) {
+ hours = elapsedSeconds / 3600;
+ elapsedSeconds -= hours * 3600;
+ }
+ if (elapsedSeconds >= 60) {
+ minutes = elapsedSeconds / 60;
+ elapsedSeconds -= minutes * 60;
+ }
+ seconds = elapsedSeconds;
+
+ final Resources res = Resources.getSystem();
+ StringBuilder duration = new StringBuilder();
+ if (hours > 0) {
+ duration.append(res.getQuantityString(
+ com.android.internal.R.plurals.duration_hours, hours, hours));
+ }
+ if (minutes > 0) {
+ if (hours > 0) {
+ duration.append(' ');
+ }
+ duration.append(res.getQuantityString(
+ com.android.internal.R.plurals.duration_minutes, minutes, minutes));
+ }
+ if (seconds > 0) {
+ if (hours > 0 || minutes > 0) {
+ duration.append(' ');
+ }
+ duration.append(res.getQuantityString(
+ com.android.internal.R.plurals.duration_seconds, seconds, seconds));
+ }
+ return duration.toString();
+ }
+
+}