mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-03 09:49:21 +02:00
add call duration to message bubble
This commit is contained in:
parent
ae8ce94c00
commit
8ae6407461
4 changed files with 48 additions and 2 deletions
|
@ -55,6 +55,12 @@ public class CallItemView extends FrameLayout {
|
|||
|
||||
public void setCallItem(boolean isOutgoing, CallInfo callInfo) {
|
||||
this.callInfo = callInfo;
|
||||
if (callInfo.state instanceof CallState.Completed) {
|
||||
footer.setCallDuration(((CallState.Completed) callInfo.state).duration);
|
||||
} else {
|
||||
footer.setCallDuration(0); // reset
|
||||
}
|
||||
|
||||
if (callInfo.state instanceof CallState.Missed) {
|
||||
title.setText(R.string.missed_call);
|
||||
} else if (callInfo.state instanceof CallState.Cancelled) {
|
||||
|
|
|
@ -26,6 +26,7 @@ public class ConversationItemFooter extends LinearLayout {
|
|||
private ImageView locationIndicatorView;
|
||||
private DeliveryStatusView deliveryStatusView;
|
||||
private Integer textColor = null;
|
||||
private int callDuration = 0;
|
||||
|
||||
public ConversationItemFooter(Context context) {
|
||||
super(context);
|
||||
|
@ -59,6 +60,11 @@ public class ConversationItemFooter extends LinearLayout {
|
|||
}
|
||||
}
|
||||
|
||||
/* Call duration in seconds. Only >0 if this is a call message */
|
||||
public void setCallDuration(int duration) {
|
||||
callDuration = duration;
|
||||
}
|
||||
|
||||
public void setMessageRecord(@NonNull DcMsg messageRecord) {
|
||||
presentDate(messageRecord);
|
||||
boolean bookmark = messageRecord.getOriginalMsgId() != 0 || messageRecord.getSavedMsgId() != 0;
|
||||
|
@ -86,9 +92,18 @@ public class ConversationItemFooter extends LinearLayout {
|
|||
deliveryStatusView.setTint(color);
|
||||
}
|
||||
|
||||
private void presentDate(@NonNull DcMsg messageRecord) {
|
||||
private void presentDate(@NonNull DcMsg dcMsg) {
|
||||
dateView.forceLayout();
|
||||
dateView.setText(DateUtils.getExtendedRelativeTimeSpanString(getContext(), messageRecord.getTimestamp()));
|
||||
Context context = getContext();
|
||||
String date = dcMsg.getType() == DcMsg.DC_MSG_CALL?
|
||||
DateUtils.getFormattedCallTime(context, dcMsg.getTimestamp())
|
||||
: DateUtils.getExtendedRelativeTimeSpanString(context, dcMsg.getTimestamp());
|
||||
if (callDuration > 0) {
|
||||
String duration = DateUtils.getFormattedCallDuration(context, callDuration);
|
||||
dateView.setText(context.getString(R.string.call_date_and_duration, date, duration));
|
||||
} else {
|
||||
dateView.setText(date);
|
||||
}
|
||||
}
|
||||
|
||||
private void presentDeliveryStatus(@NonNull DcMsg messageRecord) {
|
||||
|
|
|
@ -119,6 +119,19 @@ public class DateUtils extends android.text.format.DateUtils {
|
|||
TimeUnit.MILLISECONDS.toSeconds(millis-(TimeUnit.MILLISECONDS.toMinutes(millis)*60000)));
|
||||
}
|
||||
|
||||
public static String getFormattedCallDuration(Context c, int seconds) {
|
||||
if (seconds < 60) {
|
||||
return c.getResources().getQuantityString(R.plurals.n_seconds_ext, seconds, seconds);
|
||||
}
|
||||
|
||||
int mins = seconds / 60;
|
||||
return c.getResources().getQuantityString(R.plurals.n_minutes_ext, mins, mins);
|
||||
}
|
||||
|
||||
public static String getFormattedCallTime(final Context c, final long timestamp) {
|
||||
return getFormattedDateTime(timestamp, DateFormat.is24HourFormat(c)? "HH:mm" : "hh:mm a");
|
||||
}
|
||||
|
||||
public static String getFormattedTimespan(Context c, int timestamp) {
|
||||
int mins = timestamp / (1000 * 60);
|
||||
if (mins / 60 == 0) {
|
||||
|
|
|
@ -118,11 +118,22 @@
|
|||
<!-- Refers to the time a contact was last seen. Shown below contact name in the profile. The placeholder will be replaced by a relative point in time as "3 minutes ago" (see https://momentjs.com for more examples and languages)-->
|
||||
<string name="last_seen_relative">Last seen %1$s</string>
|
||||
<string name="last_seen_unknown">Last seen: Unknown</string>
|
||||
<!-- Shown in call duration. Avoid abbreviations, prefer full words ex. "N seconds". -->
|
||||
<plurals name="n_seconds_ext">
|
||||
<item quantity="one">%d second</item>
|
||||
<item quantity="other">%d seconds</item>
|
||||
</plurals>
|
||||
<!-- Shown in call duration. Avoid abbreviations, prefer full words ex. "N minutes". -->
|
||||
<plurals name="n_minutes_ext">
|
||||
<item quantity="one">%d minute</item>
|
||||
<item quantity="other">%d minutes</item>
|
||||
</plurals>
|
||||
<!-- Shown beside messages that are "N minutes old". Prefer short strings, or well-known abbreviations. -->
|
||||
<plurals name="n_minutes">
|
||||
<item quantity="one">%d min</item>
|
||||
<item quantity="other">%d min</item>
|
||||
</plurals>
|
||||
|
||||
<!-- Shown beside messages that are "N hours old". Prefer short strings, or well-known abbreviations. -->
|
||||
<plurals name="n_hours">
|
||||
<item quantity="one">%d hour</item>
|
||||
|
@ -377,6 +388,7 @@
|
|||
<string name="declined_call">Declined Call</string>
|
||||
<string name="canceled_call">Canceled Call</string>
|
||||
<string name="missed_call">Missed Call</string>
|
||||
<string name="call_date_and_duration">%1$s, %2$s</string>
|
||||
|
||||
<!-- deprecated -->
|
||||
<string name="videochat">Video Chat</string>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue