2015-11-18 14:52:26 -08:00
|
|
|
package org.thoughtcrime.securesms.components;
|
|
|
|
|
|
|
|
import android.annotation.TargetApi;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.os.Build;
|
|
|
|
import android.support.v4.view.animation.FastOutSlowInInterpolator;
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.view.animation.AlphaAnimation;
|
|
|
|
import android.view.animation.Animation;
|
|
|
|
import android.view.animation.AnimationSet;
|
|
|
|
import android.view.animation.AnimationUtils;
|
|
|
|
import android.view.animation.ScaleAnimation;
|
|
|
|
import android.view.animation.TranslateAnimation;
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.R;
|
|
|
|
|
|
|
|
public class HidingLinearLayout extends LinearLayout {
|
|
|
|
|
|
|
|
public HidingLinearLayout(Context context) {
|
|
|
|
super(context);
|
|
|
|
}
|
|
|
|
|
|
|
|
public HidingLinearLayout(Context context, AttributeSet attrs) {
|
|
|
|
super(context, attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
|
|
|
public HidingLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
|
|
|
super(context, attrs, defStyleAttr);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void hide() {
|
|
|
|
if (!isEnabled() || getVisibility() == GONE) return;
|
|
|
|
|
|
|
|
AnimationSet animation = new AnimationSet(true);
|
2018-08-10 12:18:02 -04:00
|
|
|
animation.addAnimation(new ScaleAnimation(1, 0.5f, 1, 1, Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 0.5f));
|
2015-11-18 14:52:26 -08:00
|
|
|
animation.addAnimation(new AlphaAnimation(1, 0));
|
|
|
|
animation.setDuration(100);
|
|
|
|
|
|
|
|
animation.setAnimationListener(new Animation.AnimationListener() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationStart(Animation animation) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAnimationRepeat(Animation animation) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animation animation) {
|
|
|
|
setVisibility(GONE);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
animateWith(animation);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void show() {
|
|
|
|
if (!isEnabled() || getVisibility() == VISIBLE) return;
|
|
|
|
|
|
|
|
setVisibility(VISIBLE);
|
|
|
|
|
|
|
|
AnimationSet animation = new AnimationSet(true);
|
2018-08-10 12:18:02 -04:00
|
|
|
animation.addAnimation(new ScaleAnimation(0.5f, 1, 1, 1, Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 0.5f));
|
2015-11-18 14:52:26 -08:00
|
|
|
animation.addAnimation(new AlphaAnimation(0, 1));
|
|
|
|
animation.setDuration(100);
|
|
|
|
|
|
|
|
animateWith(animation);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void animateWith(Animation animation) {
|
|
|
|
animation.setDuration(150);
|
|
|
|
animation.setInterpolator(new FastOutSlowInInterpolator());
|
|
|
|
startAnimation(animation);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void disable() {
|
|
|
|
setVisibility(GONE);
|
|
|
|
setEnabled(false);
|
|
|
|
}
|
|
|
|
}
|