Search in sources :

Example 1 with AnimationCompleteListener

use of org.thoughtcrime.securesms.animation.AnimationCompleteListener in project Signal-Android by signalapp.

the class RegistrationActivity method displayInitialView.

private void displayInitialView(boolean forwards) {
    int startDirectionMultiplier = forwards ? -1 : 1;
    int endDirectionMultiplier = forwards ? 1 : -1;
    title.animate().translationX(startDirectionMultiplier * title.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {

        @Override
        public void onAnimationEnd(Animator animation) {
            title.setText(R.string.registration_activity__verify_your_number);
            title.clearAnimation();
            title.setTranslationX(endDirectionMultiplier * title.getWidth());
            title.animate().translationX(0).setListener(null).setInterpolator(new OvershootInterpolator()).setDuration(SCENE_TRANSITION_DURATION).start();
        }
    }).start();
    subtitle.animate().translationX(startDirectionMultiplier * subtitle.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {

        @Override
        public void onAnimationEnd(Animator animation) {
            subtitle.setText(R.string.registration_activity__please_enter_your_mobile_number_to_receive_a_verification_code_carrier_rates_may_apply);
            subtitle.clearAnimation();
            subtitle.setTranslationX(endDirectionMultiplier * subtitle.getWidth());
            subtitle.animate().translationX(0).setListener(null).setInterpolator(new OvershootInterpolator()).setDuration(SCENE_TRANSITION_DURATION).start();
        }
    }).start();
    View container;
    if (verificationContainer.getVisibility() == View.VISIBLE)
        container = verificationContainer;
    else
        container = restoreContainer;
    container.animate().translationX(startDirectionMultiplier * container.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {

        @Override
        public void onAnimationEnd(Animator animation) {
            container.clearAnimation();
            container.setVisibility(View.INVISIBLE);
            container.setTranslationX(0);
            registrationContainer.setTranslationX(endDirectionMultiplier * registrationContainer.getWidth());
            registrationContainer.setVisibility(View.VISIBLE);
            createButton.setProgress(0);
            createButton.setIndeterminateProgressMode(false);
            registrationContainer.animate().translationX(0).setDuration(SCENE_TRANSITION_DURATION).setListener(null).setInterpolator(new OvershootInterpolator()).start();
        }
    }).start();
    fab.animate().rotationBy(startDirectionMultiplier * 360f).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {

        @Override
        public void onAnimationEnd(Animator animation) {
            fab.clearAnimation();
            fab.setImageResource(R.drawable.ic_action_name);
            fab.animate().rotationBy(startDirectionMultiplier * 375f).setDuration(SCENE_TRANSITION_DURATION).setListener(null).start();
        }
    }).start();
}
Also used : Animator(android.animation.Animator) OvershootInterpolator(android.view.animation.OvershootInterpolator) View(android.view.View) TextView(android.widget.TextView) CallMeCountDownView(org.thoughtcrime.securesms.components.registration.CallMeCountDownView) VerificationCodeView(org.thoughtcrime.securesms.components.registration.VerificationCodeView) TextPaint(android.text.TextPaint) SuppressLint(android.annotation.SuppressLint) AnimationCompleteListener(org.thoughtcrime.securesms.animation.AnimationCompleteListener)

Example 2 with AnimationCompleteListener

use of org.thoughtcrime.securesms.animation.AnimationCompleteListener in project Signal-Android by signalapp.

the class RegistrationActivity method displayVerificationView.

private void displayVerificationView(@NonNull String e164number, int callCountdown) {
    ServiceUtil.getInputMethodManager(this).hideSoftInputFromWindow(countryCode.getWindowToken(), 0);
    ServiceUtil.getInputMethodManager(this).hideSoftInputFromWindow(number.getWindowToken(), 0);
    title.animate().translationX(-1 * title.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {

        @Override
        public void onAnimationEnd(Animator animation) {
            title.setText(getString(R.string.RegistrationActivity_verify_s, e164number));
            title.clearAnimation();
            title.setTranslationX(title.getWidth());
            title.animate().translationX(0).setListener(null).setInterpolator(new OvershootInterpolator()).setDuration(SCENE_TRANSITION_DURATION).start();
        }
    }).start();
    subtitle.animate().translationX(-1 * subtitle.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {

        @Override
        public void onAnimationEnd(Animator animation) {
            SpannableString subtitleDescription = new SpannableString(getString(R.string.RegistrationActivity_please_enter_the_verification_code_sent_to_s, e164number));
            SpannableString wrongNumber = new SpannableString(getString(R.string.RegistrationActivity_wrong_number));
            ClickableSpan clickableSpan = new ClickableSpan() {

                @Override
                public void onClick(View widget) {
                    displayInitialView(false);
                    registrationState = new RegistrationState(RegistrationState.State.INITIAL, null, null, null);
                }

                @Override
                public void updateDrawState(TextPaint paint) {
                    paint.setColor(Color.WHITE);
                    paint.setUnderlineText(true);
                }
            };
            wrongNumber.setSpan(clickableSpan, 0, wrongNumber.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            subtitle.setText(new SpannableStringBuilder(subtitleDescription).append(" ").append(wrongNumber));
            subtitle.setMovementMethod(LinkMovementMethod.getInstance());
            subtitle.clearAnimation();
            subtitle.setTranslationX(subtitle.getWidth());
            subtitle.animate().translationX(0).setListener(null).setInterpolator(new OvershootInterpolator()).setDuration(SCENE_TRANSITION_DURATION).start();
        }
    }).start();
    registrationContainer.animate().translationX(-1 * registrationContainer.getWidth()).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {

        @Override
        public void onAnimationEnd(Animator animation) {
            registrationContainer.clearAnimation();
            registrationContainer.setVisibility(View.INVISIBLE);
            registrationContainer.setTranslationX(0);
            verificationContainer.setTranslationX(verificationContainer.getWidth());
            verificationContainer.setVisibility(View.VISIBLE);
            verificationContainer.animate().translationX(0).setListener(null).setInterpolator(new OvershootInterpolator()).setDuration(SCENE_TRANSITION_DURATION).start();
        }
    }).start();
    fab.animate().rotationBy(-360f).setDuration(SCENE_TRANSITION_DURATION).setListener(new AnimationCompleteListener() {

        @Override
        public void onAnimationEnd(Animator animation) {
            fab.clearAnimation();
            fab.setImageResource(R.drawable.ic_textsms_24dp);
            fab.animate().rotationBy(-375f).setDuration(SCENE_TRANSITION_DURATION).setListener(null).start();
        }
    }).start();
    this.callMeCountDownView.startCountDown(callCountdown);
}
Also used : SpannableString(android.text.SpannableString) Animator(android.animation.Animator) OvershootInterpolator(android.view.animation.OvershootInterpolator) ClickableSpan(android.text.style.ClickableSpan) View(android.view.View) TextView(android.widget.TextView) CallMeCountDownView(org.thoughtcrime.securesms.components.registration.CallMeCountDownView) VerificationCodeView(org.thoughtcrime.securesms.components.registration.VerificationCodeView) SpannableStringBuilder(android.text.SpannableStringBuilder) AnimationCompleteListener(org.thoughtcrime.securesms.animation.AnimationCompleteListener) TextPaint(android.text.TextPaint)

Example 3 with AnimationCompleteListener

use of org.thoughtcrime.securesms.animation.AnimationCompleteListener in project Signal-Android by WhisperSystems.

the class ConversationItemFooter method hidePlaybackSpeedToggle.

private void hidePlaybackSpeedToggle() {
    if (!hasShrunkDate) {
        return;
    }
    hasShrunkDate = false;
    playbackSpeedToggleTextView.animate().alpha(0f).scaleX(0.5f).scaleY(0.5f).setDuration(150L).setListener(new AnimationCompleteListener() {

        @Override
        public void onAnimationEnd(Animator animation) {
            playbackSpeedToggleTextView.setClickable(false);
            playbackSpeedToggleTextView.clearRequestedSpeed();
        }
    });
    if (isOutgoing) {
        dateView.setMaxWidth(Integer.MAX_VALUE);
    } else {
        ConstraintSet constraintSet = new ConstraintSet();
        constraintSet.clone(this);
        constraintSet.constrainMaxWidth(R.id.date_and_expiry_wrapper, -1);
        constraintSet.applyTo(this);
    }
}
Also used : Animator(android.animation.Animator) ConstraintSet(androidx.constraintlayout.widget.ConstraintSet) AnimationCompleteListener(org.thoughtcrime.securesms.animation.AnimationCompleteListener)

Example 4 with AnimationCompleteListener

use of org.thoughtcrime.securesms.animation.AnimationCompleteListener in project Signal-Android by WhisperSystems.

the class ConfirmKbsPinFragment method startEndAnimationOnNextProgressRepetition.

private void startEndAnimationOnNextProgressRepetition(@RawRes int lottieAnimationId, @NonNull AnimationCompleteListener listener) {
    LottieAnimationView lottieProgress = getLottieProgress();
    LottieAnimationView lottieEnd = getLottieEnd();
    lottieEnd.setAnimation(lottieAnimationId);
    lottieEnd.removeAllAnimatorListeners();
    lottieEnd.setRepeatCount(0);
    lottieEnd.addAnimatorListener(listener);
    if (lottieProgress.isAnimating()) {
        lottieProgress.addAnimatorListener(new AnimationRepeatListener(animator -> hideProgressAndStartEndAnimation(lottieProgress, lottieEnd)));
    } else {
        hideProgressAndStartEndAnimation(lottieProgress, lottieEnd);
    }
}
Also used : ViewCompat(androidx.core.view.ViewCompat) LottieAnimationView(com.airbnb.lottie.LottieAnimationView) AlertDialog(androidx.appcompat.app.AlertDialog) NonNull(androidx.annotation.NonNull) ApplicationDependencies(org.thoughtcrime.securesms.dependencies.ApplicationDependencies) Megaphones(org.thoughtcrime.securesms.megaphone.Megaphones) SpanUtil(org.thoughtcrime.securesms.util.SpanUtil) Animator(android.animation.Animator) R(org.thoughtcrime.securesms.R) AnimationRepeatListener(org.thoughtcrime.securesms.animation.AnimationRepeatListener) Objects(java.util.Objects) RawRes(androidx.annotation.RawRes) LottieDrawable(com.airbnb.lottie.LottieDrawable) StorageSyncHelper(org.thoughtcrime.securesms.storage.StorageSyncHelper) RegistrationUtil(org.thoughtcrime.securesms.registration.RegistrationUtil) View(android.view.View) ViewModelProviders(androidx.lifecycle.ViewModelProviders) AnimationCompleteListener(org.thoughtcrime.securesms.animation.AnimationCompleteListener) Activity(android.app.Activity) ContextCompat(androidx.core.content.ContextCompat) HintConstants(androidx.autofill.HintConstants) AnimationRepeatListener(org.thoughtcrime.securesms.animation.AnimationRepeatListener) LottieAnimationView(com.airbnb.lottie.LottieAnimationView)

Example 5 with AnimationCompleteListener

use of org.thoughtcrime.securesms.animation.AnimationCompleteListener in project Signal-Android by WhisperSystems.

the class ConfirmKbsPinFragment method updateSaveAnimation.

private void updateSaveAnimation(@NonNull ConfirmKbsPinViewModel.SaveAnimation animation) {
    updateAnimationAndInputVisibility(animation);
    LottieAnimationView lottieProgress = getLottieProgress();
    switch(animation) {
        case NONE:
            lottieProgress.cancelAnimation();
            break;
        case LOADING:
            lottieProgress.setAnimation(R.raw.lottie_kbs_loading);
            lottieProgress.setRepeatMode(LottieDrawable.RESTART);
            lottieProgress.setRepeatCount(LottieDrawable.INFINITE);
            lottieProgress.playAnimation();
            break;
        case SUCCESS:
            startEndAnimationOnNextProgressRepetition(R.raw.lottie_kbs_success, new AnimationCompleteListener() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    requireActivity().setResult(Activity.RESULT_OK);
                    closeNavGraphBranch();
                    RegistrationUtil.maybeMarkRegistrationComplete(requireContext());
                    StorageSyncHelper.scheduleSyncForDataChange();
                }
            });
            break;
        case FAILURE:
            startEndAnimationOnNextProgressRepetition(R.raw.lottie_kbs_fail, new AnimationCompleteListener() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    RegistrationUtil.maybeMarkRegistrationComplete(requireContext());
                    displayFailedDialog();
                }
            });
            break;
    }
}
Also used : Animator(android.animation.Animator) LottieAnimationView(com.airbnb.lottie.LottieAnimationView) AnimationCompleteListener(org.thoughtcrime.securesms.animation.AnimationCompleteListener)

Aggregations

Animator (android.animation.Animator)28 AnimationCompleteListener (org.thoughtcrime.securesms.animation.AnimationCompleteListener)28 AnimatorSet (android.animation.AnimatorSet)4 ObjectAnimator (android.animation.ObjectAnimator)4 ValueAnimator (android.animation.ValueAnimator)4 View (android.view.View)4 OvershootInterpolator (android.view.animation.OvershootInterpolator)4 NonNull (androidx.annotation.NonNull)4 ConstraintSet (androidx.constraintlayout.widget.ConstraintSet)4 LottieAnimationView (com.airbnb.lottie.LottieAnimationView)4 TextPaint (android.text.TextPaint)3 SuppressLint (android.annotation.SuppressLint)2 Activity (android.app.Activity)2 Point (android.graphics.Point)2 TextView (android.widget.TextView)2 MainThread (androidx.annotation.MainThread)2 RawRes (androidx.annotation.RawRes)2 AlertDialog (androidx.appcompat.app.AlertDialog)2 HintConstants (androidx.autofill.HintConstants)2 ContextCompat (androidx.core.content.ContextCompat)2