mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
add call duration to message bubble
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user