Search in sources :

Example 1 with SimpleColorFilter

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

the class ManageProfileFragment method presentAvatarPlaceholder.

private void presentAvatarPlaceholder(@NonNull AvatarState avatarState) {
    if (avatarState.getAvatar() == null) {
        CharSequence initials = NameUtil.getAbbreviation(avatarState.getSelf().getDisplayName(requireContext()));
        Avatars.ForegroundColor foregroundColor = Avatars.getForegroundColor(avatarState.getSelf().getAvatarColor());
        avatarBackground.setColorFilter(new SimpleColorFilter(avatarState.getSelf().getAvatarColor().colorInt()));
        avatarPlaceholderView.setColorFilter(new SimpleColorFilter(foregroundColor.getColorInt()));
        avatarInitials.setTextColor(foregroundColor.getColorInt());
        if (TextUtils.isEmpty(initials)) {
            avatarPlaceholderView.setVisibility(View.VISIBLE);
            avatarInitials.setVisibility(View.GONE);
        } else {
            updateInitials(initials.toString());
            avatarPlaceholderView.setVisibility(View.GONE);
            avatarInitials.setVisibility(View.VISIBLE);
        }
    } else {
        avatarPlaceholderView.setVisibility(View.GONE);
        avatarInitials.setVisibility(View.GONE);
    }
    if (avatarProgress == null && avatarState.getLoadingState() == ManageProfileViewModel.LoadingState.LOADING) {
        avatarProgress = SimpleProgressDialog.show(requireContext());
    } else if (avatarProgress != null && avatarState.getLoadingState() == ManageProfileViewModel.LoadingState.LOADED) {
        avatarProgress.dismiss();
    }
}
Also used : Avatars(org.thoughtcrime.securesms.avatar.Avatars) SimpleColorFilter(com.airbnb.lottie.SimpleColorFilter)

Example 2 with SimpleColorFilter

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

the class AudioView method setTint.

public void setTint(int foregroundTint) {
    post(() -> this.playPauseButton.addValueCallback(new KeyPath("**"), LottieProperty.COLOR_FILTER, new LottieValueCallback<>(new SimpleColorFilter(foregroundTint))));
    this.downloadButton.setColorFilter(foregroundTint, PorterDuff.Mode.SRC_IN);
    if (circleProgress != null) {
        this.circleProgress.setBarColor(foregroundTint);
    }
    if (this.duration != null) {
        this.duration.setTextColor(foregroundTint);
    }
    this.seekBar.getProgressDrawable().setColorFilter(foregroundTint, PorterDuff.Mode.SRC_IN);
    this.seekBar.getThumb().setColorFilter(foregroundTint, PorterDuff.Mode.SRC_IN);
}
Also used : SimpleColorFilter(com.airbnb.lottie.SimpleColorFilter) LottieValueCallback(com.airbnb.lottie.value.LottieValueCallback) KeyPath(com.airbnb.lottie.model.KeyPath)

Example 3 with SimpleColorFilter

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

the class EditProfileFragment method initializeProfileAvatar.

private void initializeProfileAvatar() {
    viewModel.avatar().observe(getViewLifecycleOwner(), bytes -> {
        if (bytes == null) {
            GlideApp.with(this).clear(avatar);
            return;
        }
        GlideApp.with(this).load(bytes).circleCrop().into(avatar);
    });
    viewModel.avatarColor().observe(getViewLifecycleOwner(), avatarColor -> {
        Avatars.ForegroundColor foregroundColor = Avatars.getForegroundColor(avatarColor);
        avatarPreview.getDrawable().setColorFilter(new SimpleColorFilter(foregroundColor.getColorInt()));
        avatarPreviewBackground.getDrawable().setColorFilter(new SimpleColorFilter(avatarColor.colorInt()));
    });
}
Also used : Avatars(org.thoughtcrime.securesms.avatar.Avatars) SimpleColorFilter(com.airbnb.lottie.SimpleColorFilter)

Example 4 with SimpleColorFilter

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

the class GeneratedContactPhoto method asDrawable.

@Override
public Drawable asDrawable(@NonNull Context context, @NonNull AvatarColor color, boolean inverted) {
    int targetSize = this.targetSize > 0 ? this.targetSize : context.getResources().getDimensionPixelSize(R.dimen.contact_photo_target_size);
    String character = NameUtil.getAbbreviation(name);
    if (!TextUtils.isEmpty(character)) {
        Avatars.ForegroundColor foregroundColor = Avatars.getForegroundColor(color);
        Avatar.Text avatar = new Avatar.Text(character, new Avatars.ColorPair(color, foregroundColor), Avatar.DatabaseId.DoNotPersist.INSTANCE);
        Drawable foreground = AvatarRenderer.createTextDrawable(context, avatar, inverted, targetSize, false);
        Drawable background = Objects.requireNonNull(ContextCompat.getDrawable(context, R.drawable.circle_tintable));
        background.setColorFilter(new SimpleColorFilter(inverted ? foregroundColor.getColorInt() : color.colorInt()));
        return new LayerDrawable(new Drawable[] { background, foreground });
    }
    return newFallbackDrawable(context, color, inverted);
}
Also used : Avatars(org.thoughtcrime.securesms.avatar.Avatars) LayerDrawable(android.graphics.drawable.LayerDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) Drawable(android.graphics.drawable.Drawable) SimpleColorFilter(com.airbnb.lottie.SimpleColorFilter) Avatar(org.thoughtcrime.securesms.avatar.Avatar)

Aggregations

SimpleColorFilter (com.airbnb.lottie.SimpleColorFilter)4 Avatars (org.thoughtcrime.securesms.avatar.Avatars)3 Drawable (android.graphics.drawable.Drawable)1 LayerDrawable (android.graphics.drawable.LayerDrawable)1 KeyPath (com.airbnb.lottie.model.KeyPath)1 LottieValueCallback (com.airbnb.lottie.value.LottieValueCallback)1 Avatar (org.thoughtcrime.securesms.avatar.Avatar)1