mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-18 07:38:27 +00:00
![Greyson Parrelli](/assets/img/avatar_default.png)
Previously, we'd only show the attachment button when the user had yet to enter any text. To add an attachment after text was entered, you'd have to go to the three-dot menu. Now we just show a little attach button in the text area. I also took the opportunity to clean up other button paddings and stuff in the compose area so things look better and react to text sizes more predictably.
84 lines
2.4 KiB
Java
84 lines
2.4 KiB
Java
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);
|
|
animation.addAnimation(new ScaleAnimation(1, 0.5f, 1, 1, Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 0.5f));
|
|
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);
|
|
animation.addAnimation(new ScaleAnimation(0.5f, 1, 1, 1, Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 0.5f));
|
|
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);
|
|
}
|
|
}
|