Search in sources :

Example 1 with LottieAnimationView

use of com.airbnb.lottie.LottieAnimationView in project Rocket by mozilla-tw.

the class ScreenCaptureDialogFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.dialog_capture_screen, container, false);
    mLottieAnimationView = (LottieAnimationView) view.findViewById(R.id.animation_view);
    return view;
}
Also used : LottieAnimationView(com.airbnb.lottie.LottieAnimationView) View(android.view.View)

Example 2 with LottieAnimationView

use of com.airbnb.lottie.LottieAnimationView 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 3 with LottieAnimationView

use of com.airbnb.lottie.LottieAnimationView 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)

Example 4 with LottieAnimationView

use of com.airbnb.lottie.LottieAnimationView in project Signal-Android by WhisperSystems.

the class PaymentsHomeFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    Toolbar toolbar = view.findViewById(R.id.payments_home_fragment_toolbar);
    RecyclerView recycler = view.findViewById(R.id.payments_home_fragment_recycler);
    View header = view.findViewById(R.id.payments_home_fragment_header);
    MoneyView balance = view.findViewById(R.id.payments_home_fragment_header_balance);
    TextView exchange = view.findViewById(R.id.payments_home_fragment_header_exchange);
    View addMoney = view.findViewById(R.id.button_start_frame);
    View sendMoney = view.findViewById(R.id.button_end_frame);
    View refresh = view.findViewById(R.id.payments_home_fragment_header_refresh);
    LottieAnimationView refreshAnimation = view.findViewById(R.id.payments_home_fragment_header_refresh_animation);
    toolbar.setNavigationOnClickListener(v -> {
        viewModel.markAllPaymentsSeen();
        requireActivity().finish();
    });
    toolbar.setOnMenuItemClickListener(this::onMenuItemSelected);
    addMoney.setOnClickListener(v -> {
        if (SignalStore.paymentsValues().getPaymentsAvailability().isSendAllowed()) {
            SafeNavigation.safeNavigate(Navigation.findNavController(v), PaymentsHomeFragmentDirections.actionPaymentsHomeToPaymentsAddMoney());
        } else {
            showPaymentsDisabledDialog();
        }
    });
    sendMoney.setOnClickListener(v -> {
        if (SignalStore.paymentsValues().getPaymentsAvailability().isSendAllowed()) {
            SafeNavigation.safeNavigate(Navigation.findNavController(v), PaymentsHomeFragmentDirections.actionPaymentsHomeToPaymentRecipientSelectionFragment());
        } else {
            showPaymentsDisabledDialog();
        }
    });
    PaymentsHomeAdapter adapter = new PaymentsHomeAdapter(new HomeCallbacks());
    recycler.setAdapter(adapter);
    viewModel = ViewModelProviders.of(this, new PaymentsHomeViewModel.Factory()).get(PaymentsHomeViewModel.class);
    viewModel.getList().observe(getViewLifecycleOwner(), list -> {
        boolean hadPaymentItems = Stream.of(adapter.getCurrentList()).anyMatch(model -> model instanceof PaymentItem);
        if (!hadPaymentItems) {
            adapter.submitList(list, () -> recycler.scrollToPosition(0));
        } else {
            adapter.submitList(list);
        }
    });
    viewModel.getPaymentsEnabled().observe(getViewLifecycleOwner(), enabled -> {
        if (enabled) {
            toolbar.inflateMenu(R.menu.payments_home_fragment_menu);
        } else {
            toolbar.getMenu().clear();
        }
        header.setVisibility(enabled ? View.VISIBLE : View.GONE);
    });
    viewModel.getBalance().observe(getViewLifecycleOwner(), balance::setMoney);
    viewModel.getExchange().observe(getViewLifecycleOwner(), amount -> {
        if (amount != null) {
            exchange.setText(FiatMoneyUtil.format(getResources(), amount));
        } else {
            exchange.setText(R.string.PaymentsHomeFragment__unknown_amount);
        }
    });
    refresh.setOnClickListener(v -> viewModel.refreshExchangeRates(true));
    exchange.setOnClickListener(v -> viewModel.refreshExchangeRates(true));
    viewModel.getExchangeLoadState().observe(getViewLifecycleOwner(), loadState -> {
        switch(loadState) {
            case INITIAL:
            case LOADED:
                refresh.setVisibility(View.VISIBLE);
                refreshAnimation.cancelAnimation();
                refreshAnimation.setVisibility(View.GONE);
                break;
            case LOADING:
                refresh.setVisibility(View.INVISIBLE);
                refreshAnimation.playAnimation();
                refreshAnimation.setVisibility(View.VISIBLE);
                break;
            case ERROR:
                refresh.setVisibility(View.VISIBLE);
                refreshAnimation.cancelAnimation();
                refreshAnimation.setVisibility(View.GONE);
                exchange.setText(R.string.PaymentsHomeFragment__currency_conversion_not_available);
                Toast.makeText(view.getContext(), R.string.PaymentsHomeFragment__cant_display_currency_conversion, Toast.LENGTH_SHORT).show();
                break;
        }
    });
    viewModel.getPaymentStateEvents().observe(getViewLifecycleOwner(), paymentStateEvent -> {
        AlertDialog.Builder builder = new AlertDialog.Builder(requireContext());
        builder.setTitle(R.string.PaymentsHomeFragment__deactivate_payments_question);
        builder.setMessage(R.string.PaymentsHomeFragment__you_will_not_be_able_to_send);
        builder.setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.dismiss());
        switch(paymentStateEvent) {
            case NO_BALANCE:
                Toast.makeText(requireContext(), R.string.PaymentsHomeFragment__balance_is_not_currently_available, Toast.LENGTH_SHORT).show();
                return;
            case DEACTIVATED:
                Snackbar.make(requireView(), R.string.PaymentsHomeFragment__payments_deactivated, Snackbar.LENGTH_SHORT).setTextColor(Color.WHITE).show();
                return;
            case DEACTIVATE_WITHOUT_BALANCE:
                builder.setPositiveButton(SpanUtil.color(ContextCompat.getColor(requireContext(), R.color.signal_alert_primary), getString(R.string.PaymentsHomeFragment__deactivate)), (dialog, which) -> {
                    viewModel.confirmDeactivatePayments();
                    dialog.dismiss();
                });
                break;
            case DEACTIVATE_WITH_BALANCE:
                builder.setPositiveButton(getString(R.string.PaymentsHomeFragment__continue), (dialog, which) -> {
                    dialog.dismiss();
                    SafeNavigation.safeNavigate(NavHostFragment.findNavController(this), R.id.deactivateWallet);
                });
                break;
            case ACTIVATED:
                return;
            default:
                throw new IllegalStateException("Unsupported event type: " + paymentStateEvent.name());
        }
        builder.show();
    });
    viewModel.getErrorEnablingPayments().observe(getViewLifecycleOwner(), errorEnabling -> {
        switch(errorEnabling) {
            case REGION:
                Toast.makeText(view.getContext(), R.string.PaymentsHomeFragment__payments_is_not_available_in_your_region, Toast.LENGTH_LONG).show();
                break;
            case NETWORK:
                Toast.makeText(view.getContext(), R.string.PaymentsHomeFragment__could_not_enable_payments, Toast.LENGTH_SHORT).show();
                break;
            default:
                throw new AssertionError();
        }
    });
    requireActivity().getOnBackPressedDispatcher().addCallback(onBackPressed);
}
Also used : AlertDialog(android.app.AlertDialog) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) LottieAnimationView(com.airbnb.lottie.LottieAnimationView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) MoneyView(org.thoughtcrime.securesms.payments.MoneyView) TextView(android.widget.TextView) PaymentItem(org.thoughtcrime.securesms.payments.preferences.model.PaymentItem) MoneyView(org.thoughtcrime.securesms.payments.MoneyView) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) LottieAnimationView(com.airbnb.lottie.LottieAnimationView) Toolbar(androidx.appcompat.widget.Toolbar)

Example 5 with LottieAnimationView

use of com.airbnb.lottie.LottieAnimationView in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SettingsHomepageActivity method recreateSpacer.

private void recreateSpacer() {
    homepageSpacer = findViewById(R.id.settings_homepage_spacer);
    homepageMainLayout = findViewById(R.id.main_content_scrollable_container);
    LottieAnimationView view = homepageSpacer.findViewById(R.id.home_animation);
    TextView tv = homepageSpacer.findViewById(R.id.spacer_text);
    iv = homepageSpacer.findViewById(R.id.spacer_image);
    mCustomImage = homepageSpacer.findViewById(R.id.custom_image);
    mStockDrawable = context.getDrawable(R.drawable.rr_spacer);
    Drawable rrDrawable = context.getDrawable(R.drawable.rr_spacer_main_icon);
    Drawable rrDrawable2 = context.getDrawable(R.drawable.rr_main_conf_shortcut_icon_primay);
    Drawable rrDrawable3 = context.getDrawable(R.drawable.rr_main_conf_shortcut_icon);
    final int spacermargin = getResources().getDimensionPixelSize(R.dimen.homepage_spacer_height);
    try {
        RRFontHelper.setFontType(tv, getFontStyle());
        tv.setTextSize(getFontSize());
        if (configAnim() == 0) {
            if (isProfileAvatar() == 1) {
                homepageSpacer.setBackground(null);
                mCustomImage.setImageDrawable(null);
                mCustomImage.setVisibility(View.GONE);
                iv.setVisibility(View.VISIBLE);
                iv.setImageDrawable(getCircularUserIcon(context));
                iv.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(Intent.ACTION_MAIN);
                        intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$UserSettingsActivity"));
                        startActivity(intent);
                    }
                });
            } else if (isProfileAvatar() == 0) {
                homepageSpacer.setBackground(null);
                mCustomImage.setImageDrawable(null);
                mCustomImage.setVisibility(View.GONE);
                iv.setVisibility(View.VISIBLE);
                iv.setClickable(false);
                if (mStockDrawable != null) {
                    iv.setImageDrawable(mStockDrawable);
                }
            } else if (isProfileAvatar() == 2) {
                homepageSpacer.setBackground(null);
                mCustomImage.setImageDrawable(null);
                mCustomImage.setVisibility(View.GONE);
                iv.setVisibility(View.VISIBLE);
                if (rrDrawable != null) {
                    iv.setImageDrawable(rrDrawable);
                }
                iv.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(Intent.ACTION_MAIN);
                        intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$MainSettingsLayoutActivity"));
                        startActivity(intent);
                    }
                });
            } else if (isProfileAvatar() == 3) {
                iv.setVisibility(View.GONE);
                BitmapDrawable bp = getCustomImageFromString(SPACER_IMAGE, context);
                if (bp == null)
                    Log.d(TAG, "Bitmap is null!!");
                if (bp != null) {
                    if (isCrop() == 0) {
                        homepageSpacer.setBackground(bp);
                        mCustomImage.setVisibility(View.GONE);
                    } else {
                        homepageSpacer.setBackground(null);
                        mCustomImage.setImageDrawable(bp);
                        mCustomImage.setVisibility(View.VISIBLE);
                    }
                }
            } else if (isProfileAvatar() == 4) {
                homepageSpacer.setBackground(null);
                mCustomImage.setImageDrawable(null);
                mCustomImage.setVisibility(View.GONE);
                iv.setVisibility(View.VISIBLE);
                if (rrDrawable2 != null) {
                    iv.setImageDrawable(rrDrawable2);
                }
                iv.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(Intent.ACTION_MAIN);
                        intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$MainSettingsLayoutActivity"));
                        startActivity(intent);
                    }
                });
            } else if (isProfileAvatar() == 5) {
                homepageSpacer.setBackground(null);
                mCustomImage.setImageDrawable(null);
                mCustomImage.setVisibility(View.GONE);
                iv.setVisibility(View.VISIBLE);
                if (rrDrawable3 != null) {
                    iv.setImageDrawable(rrDrawable3);
                }
                iv.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(Intent.ACTION_MAIN);
                        intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$MainSettingsLayoutActivity"));
                        startActivity(intent);
                    }
                });
            }
            tv.setVisibility(View.GONE);
            view.setVisibility(View.GONE);
        } else if (configAnim() == 1) {
            homepageSpacer.setBackground(null);
            mCustomImage.setImageDrawable(null);
            mCustomImage.setVisibility(View.GONE);
            iv.setVisibility(View.GONE);
            tv.setVisibility(View.GONE);
            view.setVisibility(View.VISIBLE);
        } else if (configAnim() == 2) {
            mCustomImage.setImageDrawable(null);
            homepageSpacer.setBackground(null);
            mCustomImage.setVisibility(View.GONE);
            iv.setVisibility(View.GONE);
            tv.setVisibility(View.VISIBLE);
            view.setVisibility(View.GONE);
        } else if (configAnim() == 3) {
            homepageSpacer.setBackground(null);
            mCustomImage.setImageDrawable(null);
            mCustomImage.setVisibility(View.GONE);
            iv.setVisibility(View.GONE);
            tv.setVisibility(View.GONE);
            view.setVisibility(View.GONE);
        }
        if (avatarView != null) {
            avatarView.setVisibility(isSearchDisabled() ? View.GONE : View.VISIBLE);
        }
    } catch (Exception e) {
    }
    if (!isHomepageSpacerEnabled() && homepageSpacer != null && homepageMainLayout != null) {
        homepageSpacer.setVisibility(View.GONE);
        setMargins(homepageMainLayout, 0, 0, 0, 0);
    } else if (isHomepageSpacerEnabled() && homepageSpacer != null && homepageMainLayout != null) {
        homepageSpacer.setVisibility(View.VISIBLE);
        setMargins(homepageMainLayout, 0, spacermargin, 0, 0);
    }
}
Also used : Drawable(android.graphics.drawable.Drawable) CircleFramedDrawable(com.android.settingslib.drawable.CircleFramedDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) TextView(android.widget.TextView) Intent(android.content.Intent) ComponentName(android.content.ComponentName) BitmapDrawable(android.graphics.drawable.BitmapDrawable) LottieAnimationView(com.airbnb.lottie.LottieAnimationView) LottieAnimationView(com.airbnb.lottie.LottieAnimationView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) IOException(java.io.IOException)

Aggregations

LottieAnimationView (com.airbnb.lottie.LottieAnimationView)11 View (android.view.View)5 TextView (android.widget.TextView)3 Animator (android.animation.Animator)2 Intent (android.content.Intent)2 ImageView (android.widget.ImageView)2 LottieComposition (com.airbnb.lottie.LottieComposition)2 OnCompositionLoadedListener (com.airbnb.lottie.OnCompositionLoadedListener)2 AnimationCompleteListener (org.thoughtcrime.securesms.animation.AnimationCompleteListener)2 Activity (android.app.Activity)1 AlertDialog (android.app.AlertDialog)1 ComponentName (android.content.ComponentName)1 AnimatedVectorDrawable (android.graphics.drawable.AnimatedVectorDrawable)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1 RecyclerView (android.support.v7.widget.RecyclerView)1 NonNull (androidx.annotation.NonNull)1 RawRes (androidx.annotation.RawRes)1 AlertDialog (androidx.appcompat.app.AlertDialog)1