unify status line (#4255)

* less formal duration string

* use standard status footer

* move call icon to call information

* add duration line

* update CHANGELOG
This commit is contained in:
biörn
2026-03-09 10:54:54 +01:00
committed by GitHub
parent 7eb0a99fc7
commit 7ce8ccff78
7 changed files with 36 additions and 62 deletions
+1
View File
@@ -3,6 +3,7 @@
## Unreleased
* Allow to set chat description
* Unified date display in call bubbles
* Fix: keep original sent timestamp for resent messages
* Fix: make clicking on broadcast member-added messages work always
* Update to core 2.44.0
@@ -803,8 +803,6 @@ public class ConversationItem extends BaseConversationItem
return stickerStub.get().getFooter();
} else if (hasOnlyThumbnail(messageRecord) && TextUtils.isEmpty(messageRecord.getText())) {
return mediaThumbnailStub.get().getFooter();
} else if (messageRecord.getType() == DcMsg.DC_MSG_CALL) {
return callViewStub.get().getFooter();
} else {
return footer;
}
@@ -12,6 +12,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.util.DateUtils;
import chat.delta.rpc.types.CallInfo;
import chat.delta.rpc.types.CallState;
@@ -21,7 +22,7 @@ public class CallItemView extends FrameLayout {
private final @NonNull ImageView icon;
private final @NonNull TextView title;
private final @NonNull ConversationItemFooter footer;
private final @NonNull TextView duration;
private CallInfo callInfo;
private CallClickListener viewListener;
@@ -40,7 +41,7 @@ public class CallItemView extends FrameLayout {
this.icon = findViewById(R.id.call_icon);
this.title = findViewById(R.id.title);
this.footer = findViewById(R.id.footer);
this.duration = findViewById(R.id.duration);
setOnClickListener(v -> {
if (viewListener != null && callInfo != null) {
@@ -55,10 +56,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);
duration.setText(DateUtils.getFormattedCallDuration(getContext(), ((CallState.Completed) callInfo.state).duration));
duration.setVisibility(VISIBLE);
} else {
footer.setCallDuration(0); // reset
duration.setVisibility(GONE);
}
if (callInfo.state instanceof CallState.Missed) {
@@ -79,26 +82,19 @@ public class CallItemView extends FrameLayout {
if (isOutgoing) {
attrs = new int[]{
R.attr.conversation_item_outgoing_text_primary_color,
R.attr.conversation_item_outgoing_text_secondary_color,
};
} else {
attrs = new int[]{
R.attr.conversation_item_incoming_text_primary_color,
R.attr.conversation_item_incoming_text_secondary_color,
};
}
try (TypedArray ta = getContext().obtainStyledAttributes(attrs)) {
icon.setColorFilter(ta.getColor(0, Color.BLACK));
footer.setTextColor(ta.getColor(1, Color.BLACK));
}
}
public ConversationItemFooter getFooter() {
return footer;
}
public String getDescription() {
return title.getText() + "\n" + footer.getDescription();
return title.getText() + (duration.getVisibility()==VISIBLE ? ("\n" + duration.getText()) : "");
}
public interface CallClickListener {
@@ -2,7 +2,6 @@ package org.thoughtcrime.securesms.components;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
@@ -32,7 +31,6 @@ public class ConversationItemFooter extends LinearLayout {
private ImageView locationIndicatorView;
private DeliveryStatusView deliveryStatusView;
private Integer textColor = null;
private int callDuration = 0;
private Context context;
private Rpc rpc;
@@ -72,11 +70,6 @@ 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;
@@ -112,7 +105,7 @@ public class ConversationItemFooter extends LinearLayout {
presentDeliveryStatus(messageRecord, isOutChannel);
}
public void setTextColor(int color) {
private void setTextColor(int color) {
textColor = color;
dateView.setTextColor(color);
editedView.setTextColor(color);
@@ -126,27 +119,17 @@ public class ConversationItemFooter extends LinearLayout {
private void presentDate(@NonNull DcMsg dcMsg) {
dateView.forceLayout();
Context context = getContext();
String date = dcMsg.getType() == DcMsg.DC_MSG_CALL?
DateUtils.getExtendedTimeSpanString(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);
}
dateView.setText(DateUtils.getExtendedRelativeTimeSpanString(getContext(), dcMsg.getTimestamp()));
}
private void presentDeliveryStatus(@NonNull DcMsg messageRecord, boolean isOutChannel) {
// isDownloading is temporary and should be checked first.
boolean isDownloading = messageRecord.getDownloadState() == DcMsg.DC_DOWNLOAD_IN_PROGRESS;
boolean isCall = messageRecord.getType() == DcMsg.DC_MSG_CALL;
if (isDownloading) deliveryStatusView.setDownloading();
else if (messageRecord.isPending()) deliveryStatusView.setPending();
else if (messageRecord.isFailed()) deliveryStatusView.setFailed();
else if (!messageRecord.isOutgoing() || isCall || isOutChannel) deliveryStatusView.setNone();
else if (!messageRecord.isOutgoing() || isOutChannel) deliveryStatusView.setNone();
else if (messageRecord.isRemoteRead()) deliveryStatusView.setRead();
else if (messageRecord.isDelivered()) deliveryStatusView.setSent();
else if (messageRecord.isPreparing()) deliveryStatusView.setPreparing();
@@ -121,11 +121,11 @@ public class DateUtils extends android.text.format.DateUtils {
public static String getFormattedCallDuration(Context c, int seconds) {
if (seconds < 60) {
return c.getResources().getQuantityString(R.plurals.n_seconds_ext, seconds, seconds);
return c.getResources().getString(R.string.call_duration_less_than_a_minute);
}
int mins = seconds / 60;
return c.getResources().getQuantityString(R.plurals.n_minutes_ext, mins, mins);
return c.getResources().getQuantityString(R.plurals.call_duration_minutes, mins, mins);
}
public static String getFormattedTimespan(Context c, int timestamp) {
+18 -16
View File
@@ -9,10 +9,17 @@
android:gravity="center_vertical"
android:focusable="true">
<ImageView
android:id="@+id/call_icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:contentDescription="@null" />
<LinearLayout android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginEnd="16dp"
android:layout_marginStart="6dp"
android:layout_marginEnd="6dp"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
@@ -27,23 +34,18 @@
android:textColor="?conversation_item_outgoing_text_primary_color"
tools:text="Incoming call" />
<org.thoughtcrime.securesms.components.ConversationItemFooter
android:id="@+id/footer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:gravity="start"
android:clipChildren="false"
android:clipToPadding="false"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:singleLine="true"
android:fontFamily="sans-serif"
android:textColor="?conversation_item_incoming_text_secondary_color"
tools:text="Incoming call" />
</LinearLayout>
<ImageView
android:id="@+id/call_icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:contentDescription="@null"
/>
</LinearLayout>
+4 -10
View File
@@ -118,16 +118,12 @@
<!-- 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 name="call_duration_minutes">
<item quantity="one">%d minute duration</item>
<item quantity="other">%d minutes duration</item>
</plurals>
<string name="call_duration_less_than_a_minute">Less than a minute</string>
<!-- 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>
@@ -400,8 +396,6 @@
<string name="declined_call">Declined call</string>
<string name="canceled_call">Canceled call</string>
<string name="missed_call">Missed call</string>
<!-- the first placeholder will be replaced by a date, the second placeholder by duration, example: "Thu, 08:12 pm, 2 minutes" -->
<string name="call_date_and_duration">%1$s, %2$s</string>
<!-- get confirmations -->
<!-- confirmation for leaving groups or channels. If a subject is needed, "Are you sure you want to leave the chat?" would work as well -->