fix gingerbread view issues

Closes #4085
// FREEBIE
This commit is contained in:
Jake McGinty
2015-09-17 17:53:09 -07:00
committed by Moxie Marlinspike
parent 6ae38d0718
commit 9ea53d7b1e
9 changed files with 55 additions and 33 deletions

View File

@@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.components;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.animation.FastOutSlowInInterpolator;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
@@ -32,6 +33,8 @@ public class AnimatingToggle extends FrameLayout {
super(context, attrs, defStyleAttr);
this.outAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.animation_toggle_out);
this.inAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.animation_toggle_in);
this.outAnimation.setInterpolator(new FastOutSlowInInterpolator());
this.inAnimation.setInterpolator(new FastOutSlowInInterpolator());
}
@Override

View File

@@ -1,14 +1,17 @@
package org.thoughtcrime.securesms.components;
import android.content.Context;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.animation.FastOutSlowInInterpolator;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.FrameLayout;
import android.widget.TextView;
@@ -34,8 +37,6 @@ public class TransferControlView extends FrameLayout {
private final ProgressWheel progressWheel;
private final TextView downloadDetails;
private final Animation inAnimation;
private final Animation outAnimation;
private final int contractedWidth;
private final int expandedWidth;
@@ -50,18 +51,18 @@ public class TransferControlView extends FrameLayout {
public TransferControlView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
inflate(context, R.layout.transfer_controls_view, this);
setBackgroundResource(R.drawable.transfer_controls_background);
final Drawable background = ContextCompat.getDrawable(context, R.drawable.transfer_controls_background);
if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) {
background.setColorFilter(0x66ffffff, Mode.MULTIPLY);
}
ViewUtil.setBackground(this, background);
setVisibility(GONE);
this.progressWheel = ViewUtil.findById(this, R.id.progress_wheel);
this.downloadDetails = ViewUtil.findById(this, R.id.download_details);
this.contractedWidth = getResources().getDimensionPixelSize(R.dimen.transfer_controls_contracted_width);
this.expandedWidth = getResources().getDimensionPixelSize(R.dimen.transfer_controls_expanded_width);
this.outAnimation = new AlphaAnimation(1f, 0f);
this.inAnimation = new AlphaAnimation(0f, 1f);
this.outAnimation.setInterpolator(new FastOutSlowInInterpolator());
this.inAnimation.setInterpolator(new FastOutSlowInInterpolator());
this.outAnimation.setDuration(TRANSITION_MS);
this.inAnimation.setDuration(TRANSITION_MS);
}
@Override protected void onAttachedToWindow() {
@@ -115,16 +116,16 @@ public class TransferControlView extends FrameLayout {
layoutParams.width = targetWidth;
setLayoutParams(layoutParams);
} else {
ViewUtil.animateOut(current, outAnimation);
ViewUtil.fadeOut(current, TRANSITION_MS);
Animator anim = getWidthAnimator(sourceWidth, targetWidth);
anim.start();
}
if (view == null) {
ViewUtil.animateOut(this, outAnimation);
ViewUtil.fadeOut(this, TRANSITION_MS);
} else {
ViewUtil.animateIn(this, inAnimation);
ViewUtil.animateIn(view, inAnimation);
ViewUtil.fadeIn(this, TRANSITION_MS);
ViewUtil.fadeIn(view, TRANSITION_MS);
}
current = view;