mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
set delivery icon color to red if message failed
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -26,19 +28,25 @@ public class ConversationUpdateItem extends LinearLayout
|
||||
private DeliveryStatusView deliveryStatusView;
|
||||
private TextView body;
|
||||
private DcMsg messageRecord;
|
||||
private int textColor;
|
||||
|
||||
private final Context context;
|
||||
|
||||
public ConversationUpdateItem(Context context) {
|
||||
super(context);
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public ConversationUpdateItem(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
|
||||
initializeAttributes();
|
||||
|
||||
body = findViewById(R.id.conversation_update_body);
|
||||
deliveryStatusView = new DeliveryStatusView(findViewById(R.id.delivery_indicator));
|
||||
}
|
||||
@@ -57,6 +65,16 @@ public class ConversationUpdateItem extends LinearLayout
|
||||
bind(messageRecord);
|
||||
}
|
||||
|
||||
private void initializeAttributes() {
|
||||
final int[] attributes = new int[] {
|
||||
R.attr.conversation_item_update_text_color,
|
||||
};
|
||||
final TypedArray attrs = context.obtainStyledAttributes(attributes);
|
||||
|
||||
textColor = attrs.getColor(0, Color.WHITE);
|
||||
attrs.recycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEventListener(@Nullable EventListener listener) {
|
||||
// No events to report yet
|
||||
@@ -82,6 +100,12 @@ public class ConversationUpdateItem extends LinearLayout
|
||||
else if (messageRecord.isPreparing()) deliveryStatusView.setPreparing();
|
||||
else if (messageRecord.isPending()) deliveryStatusView.setPending();
|
||||
else deliveryStatusView.setNone();
|
||||
|
||||
if (messageRecord.isFailed()) {
|
||||
deliveryStatusView.setTint(Color.RED);
|
||||
} else {
|
||||
deliveryStatusView.setTint(textColor);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user