From 69d79a7002df96f2d69a83fd19c69b3bdb19c829 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Tue, 13 Feb 2018 16:48:33 +0100 Subject: #8831 add a fadeout animation for the progressbar --- .../java/se/leap/bitmaskclient/EipFragment.java | 4 ++-- .../se/leap/bitmaskclient/views/VpnStateImage.java | 26 ++++++++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java index a082b047..4bacfff8 100644 --- a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java @@ -416,7 +416,7 @@ public class EipFragment extends Fragment implements Observer { } else if (eipStatus.isConnected() || isOpenVpnRunningWithoutNetwork()) { mainButton.setText(activity.getString(R.string.vpn_button_turn_off)); vpnStateImage.setStateIcon(R.drawable.vpn_connected); - vpnStateImage.stopProgress(); + vpnStateImage.stopProgress(true); routedText.setVisibility(VISIBLE); vpnRoute.setVisibility(VISIBLE); vpnRoute.setText(ConfigHelper.getProviderName(preferences)); @@ -424,7 +424,7 @@ public class EipFragment extends Fragment implements Observer { } else { mainButton.setText(activity.getString(R.string.vpn_button_turn_on)); vpnStateImage.setStateIcon(R.drawable.vpn_disconnected); - vpnStateImage.stopProgress(); + vpnStateImage.stopProgress(false); routedText.setVisibility(GONE); vpnRoute.setVisibility(GONE); greyscaleBackground(); diff --git a/app/src/main/java/se/leap/bitmaskclient/views/VpnStateImage.java b/app/src/main/java/se/leap/bitmaskclient/views/VpnStateImage.java index 46221ae8..2efd83d6 100644 --- a/app/src/main/java/se/leap/bitmaskclient/views/VpnStateImage.java +++ b/app/src/main/java/se/leap/bitmaskclient/views/VpnStateImage.java @@ -6,6 +6,8 @@ import android.support.v7.widget.AppCompatImageView; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; +import android.view.animation.AlphaAnimation; +import android.view.animation.Animation; import android.widget.ProgressBar; import se.leap.bitmaskclient.R; @@ -49,8 +51,28 @@ public class VpnStateImage extends ConstraintLayout { } - public void stopProgress() { - progressBar.setVisibility(GONE); + public void stopProgress(boolean animated) { + if (!animated) { + progressBar.setVisibility(GONE); + return; + } + + AlphaAnimation fadeOutAnimation = new AlphaAnimation(1.0f, 0.0f); + fadeOutAnimation.setDuration(1000); + fadeOutAnimation.setAnimationListener(new Animation.AnimationListener() { + @Override + public void onAnimationStart(Animation animation) {} + + @Override + public void onAnimationEnd(Animation animation) { + progressBar.setVisibility(GONE); + } + + @Override + public void onAnimationRepeat(Animation animation) {} + }); + + progressBar.startAnimation(fadeOutAnimation); } public void setStateIcon(int resource) { -- cgit v1.2.3