mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
add a different animation for 'prepare'
This commit is contained in:
@@ -20,6 +20,7 @@ public class DcMsg {
|
||||
public final static int DC_STATE_IN_FRESH = 10;
|
||||
public final static int DC_STATE_IN_NOTICED = 13;
|
||||
public final static int DC_STATE_IN_SEEN = 16;
|
||||
public final static int DC_STATE_OUT_PREPARING = 18;
|
||||
public final static int DC_STATE_OUT_PENDING = 20;
|
||||
public final static int DC_STATE_OUT_ERROR = 24;
|
||||
public final static int DC_STATE_OUT_DELIVERED = 26;
|
||||
@@ -127,6 +128,9 @@ public class DcMsg {
|
||||
public boolean isFailed() {
|
||||
return getState() == DC_STATE_OUT_ERROR;
|
||||
}
|
||||
public boolean isPreparing() {
|
||||
return getState() == DC_STATE_OUT_PREPARING;
|
||||
}
|
||||
public long getExpiresIn() {
|
||||
return -1; // never.
|
||||
}
|
||||
|
||||
@@ -305,6 +305,8 @@ public class ConversationListItem extends RelativeLayout
|
||||
deliveryStatusIndicator.setRead();
|
||||
} else if (state == DcMsg.DC_STATE_OUT_DELIVERED) {
|
||||
deliveryStatusIndicator.setSent();
|
||||
} else if (state == DcMsg.DC_STATE_OUT_PREPARING) {
|
||||
deliveryStatusIndicator.setPreparing();
|
||||
} else if (state == DcMsg.DC_STATE_OUT_PENDING) {
|
||||
deliveryStatusIndicator.setPending();
|
||||
} else {
|
||||
|
||||
@@ -88,6 +88,7 @@ public class ConversationItemFooter extends LinearLayout {
|
||||
else if (messageRecord.isRemoteRead()) deliveryStatusView.setRead();
|
||||
else if (messageRecord.isDelivered()) deliveryStatusView.setSent();
|
||||
else if (messageRecord.isFailed()) deliveryStatusView.setFailed();
|
||||
else if (messageRecord.isPreparing()) deliveryStatusView.setPreparing();
|
||||
else deliveryStatusView.setPending();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,25 +11,41 @@ import org.thoughtcrime.securesms.R;
|
||||
public class DeliveryStatusView {
|
||||
|
||||
private final ImageView deliveryIndicator;
|
||||
private static RotateAnimation animation;
|
||||
private static RotateAnimation prepareAnimation;
|
||||
private static RotateAnimation sendingAnimation;
|
||||
private boolean animated;
|
||||
|
||||
public DeliveryStatusView(ImageView deliveryIndicator) {
|
||||
this.deliveryIndicator = deliveryIndicator;
|
||||
}
|
||||
|
||||
private void animate()
|
||||
private void animatePrepare()
|
||||
{
|
||||
if(animation==null) {
|
||||
animation = new RotateAnimation(0, 360f,
|
||||
if(prepareAnimation ==null) {
|
||||
prepareAnimation = new RotateAnimation(360f, 0f,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f);
|
||||
animation.setInterpolator(new LinearInterpolator());
|
||||
animation.setDuration(1500);
|
||||
animation.setRepeatCount(Animation.INFINITE);
|
||||
prepareAnimation.setInterpolator(new LinearInterpolator());
|
||||
prepareAnimation.setDuration(2500);
|
||||
prepareAnimation.setRepeatCount(Animation.INFINITE);
|
||||
}
|
||||
|
||||
deliveryIndicator.startAnimation(animation);
|
||||
deliveryIndicator.startAnimation(prepareAnimation);
|
||||
animated = true;
|
||||
}
|
||||
|
||||
private void animateSending()
|
||||
{
|
||||
if(sendingAnimation ==null) {
|
||||
sendingAnimation = new RotateAnimation(0, 360f,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f);
|
||||
sendingAnimation.setInterpolator(new LinearInterpolator());
|
||||
sendingAnimation.setDuration(1500);
|
||||
sendingAnimation.setRepeatCount(Animation.INFINITE);
|
||||
}
|
||||
|
||||
deliveryIndicator.startAnimation(sendingAnimation);
|
||||
animated = true;
|
||||
}
|
||||
|
||||
@@ -46,10 +62,16 @@ public class DeliveryStatusView {
|
||||
deliveryIndicator.clearAnimation();
|
||||
}
|
||||
|
||||
public void setPreparing() {
|
||||
deliveryIndicator.setVisibility(View.VISIBLE);
|
||||
deliveryIndicator.setImageResource(R.drawable.ic_delivery_status_sending);
|
||||
animatePrepare();
|
||||
}
|
||||
|
||||
public void setPending() {
|
||||
deliveryIndicator.setVisibility(View.VISIBLE);
|
||||
deliveryIndicator.setImageResource(R.drawable.ic_delivery_status_sending);
|
||||
animate();
|
||||
animateSending();
|
||||
}
|
||||
|
||||
public void setSent() {
|
||||
|
||||
Reference in New Issue
Block a user