mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
simplify delivery-icon
This commit is contained in:
@@ -28,10 +28,12 @@
|
||||
android:textColor="?conversation_item_outgoing_text_secondary_color"
|
||||
tools:text="30 mins"/>
|
||||
|
||||
<org.thoughtcrime.securesms.components.DeliveryStatusView
|
||||
android:id="@+id/footer_delivery_status"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
<ImageView android:id="@+id/delivery_indicator"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:tint="?attr/conversation_item_outgoing_text_secondary_color"
|
||||
android:paddingLeft="2dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
</merge>
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:minHeight="20dp"
|
||||
android:minHeight="21dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
@@ -117,12 +117,14 @@
|
||||
android:textColor="?attr/conversation_list_item_date_color"
|
||||
android:background="@drawable/archived_indicator_background" />
|
||||
|
||||
<org.thoughtcrime.securesms.components.DeliveryStatusView
|
||||
android:id="@+id/delivery_status"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:iconColor="?attr/conversation_list_item_delivery_icon_color"/>
|
||||
<ImageView android:id="@+id/delivery_indicator"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:paddingLeft="2dp"
|
||||
android:tint="?attr/conversation_item_outgoing_text_secondary_color"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView android:id="@+id/unread_indicator"
|
||||
android:layout_width="24dp"
|
||||
|
||||
@@ -2,44 +2,6 @@
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/pending_indicator"
|
||||
android:layout_width="12dp"
|
||||
android:layout_height="12dp"
|
||||
android:layout_marginRight="2dp"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:src="@drawable/ic_delivery_status_sending"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView android:id="@+id/sent_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:src="@drawable/ic_delivery_status_sent"
|
||||
android:paddingLeft="2dp"
|
||||
android:visibility="gone"
|
||||
android:contentDescription="@string/message_delivered" />
|
||||
|
||||
<ImageView android:id="@+id/read_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:src="@drawable/ic_delivery_status_read"
|
||||
android:paddingLeft="2dp"
|
||||
android:visibility="gone"
|
||||
android:contentDescription="@string/message_read"
|
||||
android:tint="@color/core_blue"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
<ImageView android:id="@+id/failed_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:src="@drawable/ic_delivery_status_failed"
|
||||
android:paddingLeft="2dp"
|
||||
android:visibility="gone"
|
||||
android:contentDescription="@string/error"
|
||||
android:tint="@color/core_blue"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
</merge>
|
||||
@@ -170,10 +170,6 @@
|
||||
<attr name="thumbnail_radius" format="dimension" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="DeliveryStatusView">
|
||||
<attr name="iconColor" format="color" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="AudioView">
|
||||
<attr name="widgetBackground" format="color"/>
|
||||
<attr name="foregroundTintColor" format="color" />
|
||||
|
||||
@@ -99,7 +99,7 @@ public class ConversationListItem extends RelativeLayout
|
||||
this.subjectView = findViewById(R.id.subject);
|
||||
this.fromView = findViewById(R.id.from_text);
|
||||
this.dateView = findViewById(R.id.date);
|
||||
this.deliveryStatusIndicator = findViewById(R.id.delivery_status);
|
||||
this.deliveryStatusIndicator = new DeliveryStatusView(findViewById(R.id.delivery_indicator));
|
||||
this.contactPhotoImage = findViewById(R.id.contact_photo_image);
|
||||
this.archivedView = findViewById(R.id.archived);
|
||||
this.unreadIndicator = findViewById(R.id.unread_indicator);
|
||||
|
||||
@@ -43,7 +43,7 @@ public class ConversationItemFooter extends LinearLayout {
|
||||
|
||||
dateView = findViewById(R.id.footer_date);
|
||||
secureIndicatorView = findViewById(R.id.footer_secure_indicator);
|
||||
deliveryStatusView = findViewById(R.id.footer_delivery_status);
|
||||
deliveryStatusView = new DeliveryStatusView(findViewById(R.id.delivery_indicator));
|
||||
|
||||
if (attrs != null) {
|
||||
TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.ConversationItemFooter, 0, 0);
|
||||
|
||||
@@ -1,107 +1,76 @@
|
||||
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.view.animation.Animation;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.view.animation.RotateAnimation;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.util.ResUtil;
|
||||
|
||||
public class DeliveryStatusView extends FrameLayout {
|
||||
public class DeliveryStatusView {
|
||||
|
||||
private static final String TAG = DeliveryStatusView.class.getSimpleName();
|
||||
private final ImageView deliveryIndicator;
|
||||
private static RotateAnimation animation;
|
||||
private boolean animated;
|
||||
|
||||
private static final RotateAnimation ROTATION_ANIMATION = new RotateAnimation(0, 360f,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f);
|
||||
static {
|
||||
ROTATION_ANIMATION.setInterpolator(new LinearInterpolator());
|
||||
ROTATION_ANIMATION.setDuration(1500);
|
||||
ROTATION_ANIMATION.setRepeatCount(Animation.INFINITE);
|
||||
public DeliveryStatusView(ImageView deliveryIndicator) {
|
||||
this.deliveryIndicator = deliveryIndicator;
|
||||
}
|
||||
|
||||
private final ImageView pendingIndicator;
|
||||
private final ImageView sentIndicator;
|
||||
private final ImageView readIndicator;
|
||||
private final ImageView failedIndicator;
|
||||
private void animate()
|
||||
{
|
||||
if(animation==null) {
|
||||
animation = new RotateAnimation(0, 360f,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f);
|
||||
animation.setInterpolator(new LinearInterpolator());
|
||||
animation.setDuration(1500);
|
||||
animation.setRepeatCount(Animation.INFINITE);
|
||||
}
|
||||
|
||||
public DeliveryStatusView(Context context) {
|
||||
this(context, null);
|
||||
deliveryIndicator.startAnimation(animation);
|
||||
animated = true;
|
||||
}
|
||||
|
||||
public DeliveryStatusView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public DeliveryStatusView(final Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
|
||||
inflate(context, R.layout.delivery_status_view, this);
|
||||
|
||||
this.sentIndicator = findViewById(R.id.sent_indicator);
|
||||
this.pendingIndicator = findViewById(R.id.pending_indicator);
|
||||
this.readIndicator = findViewById(R.id.read_indicator);
|
||||
this.failedIndicator = findViewById(R.id.failed_indicator);
|
||||
|
||||
if (attrs != null) {
|
||||
TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.DeliveryStatusView, 0, 0);
|
||||
int color = ResUtil.getColor(getContext(), R.attr.conversation_item_outgoing_text_secondary_color);
|
||||
setTint(color);
|
||||
typedArray.recycle();
|
||||
private void clearAnimation()
|
||||
{
|
||||
if(animated) {
|
||||
deliveryIndicator.clearAnimation();
|
||||
animated = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setNone() {
|
||||
this.setVisibility(View.GONE);
|
||||
deliveryIndicator.setVisibility(View.GONE);
|
||||
deliveryIndicator.clearAnimation();
|
||||
}
|
||||
|
||||
public void setPending() {
|
||||
this.setVisibility(View.VISIBLE);
|
||||
pendingIndicator.setVisibility(View.VISIBLE);
|
||||
pendingIndicator.startAnimation(ROTATION_ANIMATION);
|
||||
sentIndicator.setVisibility(View.GONE);
|
||||
readIndicator.setVisibility(View.GONE);
|
||||
failedIndicator.setVisibility(View.GONE);
|
||||
deliveryIndicator.setVisibility(View.VISIBLE);
|
||||
deliveryIndicator.setImageResource(R.drawable.ic_delivery_status_sending);
|
||||
animate();
|
||||
}
|
||||
|
||||
public void setSent() {
|
||||
this.setVisibility(View.VISIBLE);
|
||||
pendingIndicator.setVisibility(View.GONE);
|
||||
pendingIndicator.clearAnimation();
|
||||
sentIndicator.setVisibility(View.VISIBLE);
|
||||
readIndicator.setVisibility(View.GONE);
|
||||
failedIndicator.setVisibility(View.GONE);
|
||||
deliveryIndicator.setVisibility(View.VISIBLE);
|
||||
deliveryIndicator.setImageResource(R.drawable.ic_delivery_status_sent);
|
||||
clearAnimation();
|
||||
}
|
||||
|
||||
public void setRead() {
|
||||
this.setVisibility(View.VISIBLE);
|
||||
pendingIndicator.setVisibility(View.GONE);
|
||||
pendingIndicator.clearAnimation();
|
||||
sentIndicator.setVisibility(View.GONE);
|
||||
readIndicator.setVisibility(View.VISIBLE);
|
||||
failedIndicator.setVisibility(View.GONE);
|
||||
deliveryIndicator.setVisibility(View.VISIBLE);
|
||||
deliveryIndicator.setImageResource(R.drawable.ic_delivery_status_read);
|
||||
clearAnimation();
|
||||
}
|
||||
|
||||
public void setFailed() {
|
||||
this.setVisibility(View.VISIBLE);
|
||||
pendingIndicator.setVisibility(View.GONE);
|
||||
pendingIndicator.clearAnimation();
|
||||
sentIndicator.setVisibility(View.GONE);
|
||||
readIndicator.setVisibility(View.GONE);
|
||||
failedIndicator.setVisibility(View.VISIBLE);
|
||||
deliveryIndicator.setVisibility(View.VISIBLE);
|
||||
deliveryIndicator.setImageResource(R.drawable.ic_delivery_status_failed);
|
||||
clearAnimation();
|
||||
}
|
||||
|
||||
public void setTint(int color) {
|
||||
pendingIndicator.setColorFilter(color);
|
||||
sentIndicator.setColorFilter(color);
|
||||
readIndicator.setColorFilter(color);
|
||||
failedIndicator.setColorFilter(color);
|
||||
deliveryIndicator.setColorFilter(color);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user