2015-11-24 15:06:41 +00:00
|
|
|
package org.thoughtcrime.securesms.components;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.res.TypedArray;
|
|
|
|
import android.graphics.Color;
|
|
|
|
import android.os.Build;
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
2018-07-12 23:03:32 +00:00
|
|
|
import android.view.animation.Animation;
|
|
|
|
import android.view.animation.LinearInterpolator;
|
|
|
|
import android.view.animation.RotateAnimation;
|
2015-11-24 15:06:41 +00:00
|
|
|
import android.widget.FrameLayout;
|
|
|
|
import android.widget.ImageView;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.R;
|
|
|
|
|
|
|
|
import pl.tajchert.sample.DotsTextView;
|
|
|
|
|
|
|
|
public class DeliveryStatusView extends FrameLayout {
|
|
|
|
|
|
|
|
private static final String TAG = DeliveryStatusView.class.getSimpleName();
|
|
|
|
|
2018-07-12 23:03:32 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-06-26 17:27:44 +00:00
|
|
|
private final ImageView pendingIndicator;
|
2015-11-24 15:06:41 +00:00
|
|
|
private final ImageView sentIndicator;
|
|
|
|
private final ImageView deliveredIndicator;
|
2017-09-16 05:38:53 +00:00
|
|
|
private final ImageView readIndicator;
|
2015-11-24 15:06:41 +00:00
|
|
|
|
|
|
|
public DeliveryStatusView(Context context) {
|
|
|
|
this(context, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2018-06-26 17:27:44 +00:00
|
|
|
this.deliveredIndicator = findViewById(R.id.delivered_indicator);
|
|
|
|
this.sentIndicator = findViewById(R.id.sent_indicator);
|
|
|
|
this.pendingIndicator = findViewById(R.id.pending_indicator);
|
|
|
|
this.readIndicator = findViewById(R.id.read_indicator);
|
2015-11-24 15:06:41 +00:00
|
|
|
|
|
|
|
if (attrs != null) {
|
|
|
|
TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.DeliveryStatusView, 0, 0);
|
2018-06-26 17:27:44 +00:00
|
|
|
setTint(typedArray.getColor(R.styleable.DeliveryStatusView_iconColor, getResources().getColor(R.color.core_white)));
|
2015-11-24 15:06:41 +00:00
|
|
|
typedArray.recycle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setNone() {
|
|
|
|
this.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPending() {
|
|
|
|
this.setVisibility(View.VISIBLE);
|
2018-06-26 17:27:44 +00:00
|
|
|
pendingIndicator.setVisibility(View.VISIBLE);
|
2018-07-12 23:03:32 +00:00
|
|
|
pendingIndicator.startAnimation(ROTATION_ANIMATION);
|
2015-11-24 15:06:41 +00:00
|
|
|
sentIndicator.setVisibility(View.GONE);
|
|
|
|
deliveredIndicator.setVisibility(View.GONE);
|
2017-09-16 05:38:53 +00:00
|
|
|
readIndicator.setVisibility(View.GONE);
|
2015-11-24 15:06:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setSent() {
|
|
|
|
this.setVisibility(View.VISIBLE);
|
2018-06-26 17:27:44 +00:00
|
|
|
pendingIndicator.setVisibility(View.GONE);
|
2018-07-12 23:03:32 +00:00
|
|
|
pendingIndicator.clearAnimation();
|
2015-11-24 15:06:41 +00:00
|
|
|
sentIndicator.setVisibility(View.VISIBLE);
|
|
|
|
deliveredIndicator.setVisibility(View.GONE);
|
2017-09-16 05:38:53 +00:00
|
|
|
readIndicator.setVisibility(View.GONE);
|
2015-11-24 15:06:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setDelivered() {
|
|
|
|
this.setVisibility(View.VISIBLE);
|
2018-06-26 17:27:44 +00:00
|
|
|
pendingIndicator.setVisibility(View.GONE);
|
2018-07-12 23:03:32 +00:00
|
|
|
pendingIndicator.clearAnimation();
|
2015-11-24 15:06:41 +00:00
|
|
|
sentIndicator.setVisibility(View.GONE);
|
|
|
|
deliveredIndicator.setVisibility(View.VISIBLE);
|
2017-09-16 05:38:53 +00:00
|
|
|
readIndicator.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setRead() {
|
|
|
|
this.setVisibility(View.VISIBLE);
|
2018-06-26 17:27:44 +00:00
|
|
|
pendingIndicator.setVisibility(View.GONE);
|
2018-07-12 23:03:32 +00:00
|
|
|
pendingIndicator.clearAnimation();
|
2017-09-16 05:38:53 +00:00
|
|
|
sentIndicator.setVisibility(View.GONE);
|
|
|
|
deliveredIndicator.setVisibility(View.GONE);
|
|
|
|
readIndicator.setVisibility(View.VISIBLE);
|
2015-11-24 15:06:41 +00:00
|
|
|
}
|
2018-06-26 17:27:44 +00:00
|
|
|
|
|
|
|
public void setTint(int color) {
|
|
|
|
pendingIndicator.setColorFilter(color);
|
|
|
|
deliveredIndicator.setColorFilter(color);
|
|
|
|
sentIndicator.setColorFilter(color);
|
|
|
|
readIndicator.setColorFilter(color);
|
|
|
|
}
|
2015-11-24 15:06:41 +00:00
|
|
|
}
|