Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove WaveDrawable completely. #1747

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import org.telegram.ui.Components.RLottieDrawable;
import org.telegram.ui.Components.RLottieImageView;
import org.telegram.ui.Components.RadialProgressView;
import org.telegram.ui.Components.WaveDrawable;

import java.util.ArrayList;

Expand Down Expand Up @@ -953,8 +952,8 @@ public AvatarWavesDrawable(int minRadius, int maxRadius) {
blobDrawable2.maxRadius = maxRadius;
blobDrawable.generateBlob();
blobDrawable2.generateBlob();
blobDrawable.paint.setColor(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_voipgroup_speakingText), (int) (255 * WaveDrawable.CIRCLE_ALPHA_2)));
blobDrawable2.paint.setColor(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_voipgroup_speakingText), (int) (255 * WaveDrawable.CIRCLE_ALPHA_2)));
blobDrawable.paint.setColor(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_voipgroup_speakingText), BlobDrawable.ALPHA_2));
blobDrawable2.paint.setColor(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_voipgroup_speakingText), BlobDrawable.ALPHA_2));
}

public void update() {
Expand Down Expand Up @@ -1012,7 +1011,7 @@ public void draw(Canvas canvas, float cx, float cy, View parentView) {

if (invalidateColor) {
int color = ColorUtils.blendARGB(Theme.getColor(Theme.key_voipgroup_speakingText), isMuted == 2 ? Theme.getColor(Theme.key_voipgroup_mutedByAdminIcon) : Theme.getColor(Theme.key_voipgroup_listeningText), progressToMuted);
blobDrawable.paint.setColor(ColorUtils.setAlphaComponent(color, (int) (255 * WaveDrawable.CIRCLE_ALPHA_2)));
blobDrawable.paint.setColor(ColorUtils.setAlphaComponent(color, BlobDrawable.ALPHA_2));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ public class BlobDrawable {

public static float LIGHT_GRADIENT_SIZE = 0.5f;

public static int MAX_AMPLITUDE = 1800;

public static float ANIMATION_SPEED = 0.55f;

public static int ALPHA_1 = 76;
public static int ALPHA_2 = 38;

public float minRadius;
public float maxRadius;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1002,11 +1002,11 @@ private void checkDrawables() {
}

public void setAmplitude(double value) {
bigWaveDrawable.setValue((float) (Math.min(WaveDrawable.MAX_AMPLITUDE, value) / WaveDrawable.MAX_AMPLITUDE), true);
tinyWaveDrawable.setValue((float) (Math.min(WaveDrawable.MAX_AMPLITUDE, value) / WaveDrawable.MAX_AMPLITUDE), false);
bigWaveDrawable.setValue((float) (Math.min(BlobDrawable.MAX_AMPLITUDE, value) / BlobDrawable.MAX_AMPLITUDE), true);
tinyWaveDrawable.setValue((float) (Math.min(BlobDrawable.MAX_AMPLITUDE, value) / BlobDrawable.MAX_AMPLITUDE), false);

animateToAmplitude = (float) (Math.min(WaveDrawable.MAX_AMPLITUDE, value) / WaveDrawable.MAX_AMPLITUDE);
animateAmplitudeDiff = (animateToAmplitude - amplitude) / (100 + 500.0f * WaveDrawable.animationSpeedCircle);
animateToAmplitude = (float) (Math.min(BlobDrawable.MAX_AMPLITUDE, value) / BlobDrawable.MAX_AMPLITUDE);
animateAmplitudeDiff = (animateToAmplitude - amplitude) / (100f + 500.0f * BlobDrawable.ANIMATION_SPEED);

invalidate();
}
Expand Down Expand Up @@ -1646,8 +1646,8 @@ public void setExitTransition(float exitTransition) {

public void updateColors() {
paint.setColor(getThemedColor(Theme.key_chat_messagePanelVoiceBackground));
tinyWaveDrawable.paint.setColor(ColorUtils.setAlphaComponent(getThemedColor(Theme.key_chat_messagePanelVoiceBackground), (int) (255 * WaveDrawable.CIRCLE_ALPHA_2)));
bigWaveDrawable.paint.setColor(ColorUtils.setAlphaComponent(getThemedColor(Theme.key_chat_messagePanelVoiceBackground), (int) (255 * WaveDrawable.CIRCLE_ALPHA_1)));
tinyWaveDrawable.paint.setColor(ColorUtils.setAlphaComponent(getThemedColor(Theme.key_chat_messagePanelVoiceBackground), BlobDrawable.ALPHA_2));
bigWaveDrawable.paint.setColor(ColorUtils.setAlphaComponent(getThemedColor(Theme.key_chat_messagePanelVoiceBackground), BlobDrawable.ALPHA_1));
tooltipPaint.setColor(getThemedColor(Theme.key_chat_gifSaveHintText));
tooltipBackground = Theme.createRoundRectDrawable(AndroidUtilities.dp(5), getThemedColor(Theme.key_chat_gifSaveHintBackground));
tooltipBackgroundArrow.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_gifSaveHintBackground), PorterDuff.Mode.MULTIPLY));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ public void updateState(boolean animated) {
muteButton.setColorFilter(new PorterDuffColorFilter(newColor, PorterDuff.Mode.MULTIPLY));
textPaint.setColor(lastColor);
selectionPaint.setColor(newWavesColor);
avatarWavesDrawable.setColor(ColorUtils.setAlphaComponent(newWavesColor, (int) (255 * WaveDrawable.CIRCLE_ALPHA_2)));
avatarWavesDrawable.setColor(ColorUtils.setAlphaComponent(newWavesColor, BlobDrawable.ALPHA_2));
invalidate();
} else {
int colorFrom = lastColor;
Expand All @@ -521,7 +521,7 @@ public void updateState(boolean animated) {
muteButton.setColorFilter(new PorterDuffColorFilter(lastColor, PorterDuff.Mode.MULTIPLY));
textPaint.setColor(lastColor);
selectionPaint.setColor(lastWavesColor);
avatarWavesDrawable.setColor(ColorUtils.setAlphaComponent(lastWavesColor, (int) (255 * WaveDrawable.CIRCLE_ALPHA_2)));
avatarWavesDrawable.setColor(ColorUtils.setAlphaComponent(lastWavesColor, BlobDrawable.ALPHA_2));
invalidate();
});
colorAnimator.addListener(new AnimatorListenerAdapter() {
Expand All @@ -532,7 +532,7 @@ public void onAnimationEnd(Animator animation) {
muteButton.setColorFilter(new PorterDuffColorFilter(lastColor, PorterDuff.Mode.MULTIPLY));
textPaint.setColor(lastColor);
selectionPaint.setColor(lastWavesColor);
avatarWavesDrawable.setColor(ColorUtils.setAlphaComponent(lastWavesColor, (int) (255 * WaveDrawable.CIRCLE_ALPHA_2)));
avatarWavesDrawable.setColor(ColorUtils.setAlphaComponent(lastWavesColor, BlobDrawable.ALPHA_2));
}
});
colorAnimator.start();
Expand Down
Loading