From 3433c786e6c3678bd45638bfe9015260034f4a5a Mon Sep 17 00:00:00 2001 From: Makhorin Date: Tue, 7 Mar 2023 01:04:07 +0300 Subject: [PATCH 1/2] Remove WaveDrawable. Replace constants that were pulled out from WaveDrawable. --- .../telegram/ui/Cells/GroupCallUserCell.java | 7 +- .../ui/Components/ChatActivityEnterView.java | 12 +- .../GroupCallFullscreenAdapter.java | 6 +- .../telegram/ui/Components/WaveDrawable.java | 378 ------------------ .../org/telegram/ui/GroupCallActivity.java | 5 +- 5 files changed, 14 insertions(+), 394 deletions(-) delete mode 100644 TMessagesProj/src/main/java/org/telegram/ui/Components/WaveDrawable.java diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupCallUserCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupCallUserCell.java index 97f5e27100f..c03306060bf 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupCallUserCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupCallUserCell.java @@ -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; @@ -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), 76)); + blobDrawable2.paint.setColor(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_voipgroup_speakingText), 76)); } public void update() { @@ -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, 76)); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java index 193f781ce5c..01e76a397b8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java @@ -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(1800, value) / 1800), true); + tinyWaveDrawable.setValue((float) (Math.min(1800, value) / 1800), false); - animateToAmplitude = (float) (Math.min(WaveDrawable.MAX_AMPLITUDE, value) / WaveDrawable.MAX_AMPLITUDE); - animateAmplitudeDiff = (animateToAmplitude - amplitude) / (100 + 500.0f * WaveDrawable.animationSpeedCircle); + animateToAmplitude = (float) (Math.min(1800, value) / 1800); + animateAmplitudeDiff = (animateToAmplitude - amplitude) / (100f + 500.0f * 0.55f); invalidate(); } @@ -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), 38)); + bigWaveDrawable.paint.setColor(ColorUtils.setAlphaComponent(getThemedColor(Theme.key_chat_messagePanelVoiceBackground), 76)); 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)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/GroupCallFullscreenAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/GroupCallFullscreenAdapter.java index c253edbec52..682b59483b7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/GroupCallFullscreenAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/GroupCallFullscreenAdapter.java @@ -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, 76)); invalidate(); } else { int colorFrom = lastColor; @@ -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, 76)); invalidate(); }); colorAnimator.addListener(new AnimatorListenerAdapter() { @@ -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, 76)); } }); colorAnimator.start(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/WaveDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/WaveDrawable.java deleted file mode 100644 index c0be56c5765..00000000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/WaveDrawable.java +++ /dev/null @@ -1,378 +0,0 @@ -package org.telegram.ui.Components; - -import android.animation.Animator; -import android.animation.AnimatorSet; -import android.animation.ValueAnimator; -import android.graphics.Canvas; -import android.graphics.Paint; -import android.os.Build; -import android.os.SystemClock; -import android.view.View; -import android.view.animation.Interpolator; -import android.view.animation.LinearInterpolator; - -import org.telegram.messenger.AndroidUtilities; -import org.telegram.messenger.LiteMode; -import org.telegram.messenger.SharedConfig; - -public class WaveDrawable { - - public final static float MAX_AMPLITUDE = 1800f; - - private final static float ROTATION_SPEED = 0.36f * 0.1f; - public final static float SINE_WAVE_SPEED = 0.81f; - public final static float SMALL_WAVE_RADIUS = 0.55f; - public final static float SMALL_WAVE_SCALE = 0.40f; - public final static float SMALL_WAVE_SCALE_SPEED = 0.60f; - public final static float FLING_DISTANCE = 0.50f; - private final static float WAVE_ANGLE = 0.03f; - private final static float RANDOM_RADIUS_SIZE = 0.3f; - - private final static float ANIMATION_SPEED_CIRCLE = 0.45f; - public final static float CIRCLE_ALPHA_1 = 0.30f; - public final static float CIRCLE_ALPHA_2 = 0.15f; - - private final static float IDLE_ROTATION_SPEED = 0.2f; - private final static float IDLE_WAVE_ANGLE = 0.5f; - private final static float IDLE_SCALE_SPEED = 0.3f; - private final static float IDLE_RADIUS = 0.56f; - private final static float IDLE_ROTATE_DIF = 0.1f * IDLE_ROTATION_SPEED; - - private final static float ANIMATION_SPEED_WAVE_HUGE = 0.65f; - private final static float ANIMATION_SPEED_WAVE_SMALL = 0.45f; - private final static float animationSpeed = 1f - ANIMATION_SPEED_WAVE_HUGE; - private final static float animationSpeedTiny = 1f - ANIMATION_SPEED_WAVE_SMALL; - public final static float animationSpeedCircle = 1f - ANIMATION_SPEED_CIRCLE; - - private Paint paintRecordWaveBig = new Paint(); - private Paint paintRecordWaveTin = new Paint(); - - public float fling; - private float animateToAmplitude; - private float amplitude; - private float slowAmplitude; - private float animateAmplitudeDiff; - private float animateAmplitudeSlowDiff; - float lastRadius; - float radiusDiff; - float waveDif; - double waveAngle; - private boolean incRandomAdditionals; - - public float rotation; - float idleRotation; - - private float circleRadius; - - private Interpolator linearInterpolator = new LinearInterpolator(); - - public float amplitudeWaveDif; - private final CircleBezierDrawable circleBezierDrawable; - public float amplitudeRadius; - private float idleRadius = 0; - private float idleRadiusK = 0.15f * IDLE_WAVE_ANGLE; - private boolean expandIdleRadius; - private boolean expandScale; - - private boolean isBig; - - private boolean isIdle = true; - private float scaleIdleDif; - private float scaleDif; - public float scaleSpeed = 0.00008f; - public float scaleSpeedIdle = 0.0002f * IDLE_SCALE_SPEED; - public float maxScale; - - private float flingRadius; - private Animator flingAnimator; - - private ValueAnimator animator; - - float randomAdditions = AndroidUtilities.dp(8) * RANDOM_RADIUS_SIZE; - - private final ValueAnimator.AnimatorUpdateListener flingUpdateListener = animation -> flingRadius = (float) animation.getAnimatedValue(); - private float idleGlobalRadius = AndroidUtilities.dp(10f) * IDLE_RADIUS; - - private float sineAngleMax; - - private WaveDrawable tinyWaveDrawable; - - private long lastUpdateTime; - private View parentView; - - public WaveDrawable(View parent, int n, float rotateDif, float radius, WaveDrawable tinyDrawable) { - parentView = parent; - circleBezierDrawable = new CircleBezierDrawable(n); - amplitudeRadius = radius; - isBig = tinyDrawable != null; - tinyWaveDrawable = tinyDrawable; - expandIdleRadius = isBig; - radiusDiff = AndroidUtilities.dp(34) * 0.0012f; - - if (Build.VERSION.SDK_INT >= 26) { - paintRecordWaveBig.setAntiAlias(true); - paintRecordWaveTin.setAntiAlias(true); - } - } - - public void setValue(float value) { - animateToAmplitude = value; - - if (isBig) { - if (animateToAmplitude > amplitude) { - animateAmplitudeDiff = (animateToAmplitude - amplitude) / (100f + 300f * animationSpeed); - } else { - animateAmplitudeDiff = (animateToAmplitude - amplitude) / (100 + 500f * animationSpeed); - } - animateAmplitudeSlowDiff = (animateToAmplitude - slowAmplitude) / (100f + 500 * animationSpeed); - } else { - if (animateToAmplitude > amplitude) { - animateAmplitudeDiff = (animateToAmplitude - amplitude) / (100f + 400f * animationSpeedTiny); - } else { - animateAmplitudeDiff = (animateToAmplitude - amplitude) / (100f + 500f * animationSpeedTiny); - } - animateAmplitudeSlowDiff = (animateToAmplitude - slowAmplitude) / (100f + 500 * animationSpeedTiny); - } - - boolean idle = value < 0.1f; - if (isIdle != idle && idle && isBig) { - float bRotation = rotation; - int k = 60; - float animateToBRotation = Math.round(rotation / k) * k + k / 2; - float tRotation = tinyWaveDrawable.rotation; - float animateToTRotation = Math.round(tRotation / k) * k; - - float bWaveDif = waveDif; - float tWaveDif = tinyWaveDrawable.waveDif; - animator = ValueAnimator.ofFloat(1f, 0f); - animator.addUpdateListener(animation -> { - float v = (float) animation.getAnimatedValue(); - rotation = animateToBRotation + (bRotation - animateToBRotation) * v; - tinyWaveDrawable.rotation = animateToTRotation + (tRotation - animateToTRotation) * v; - waveDif = 1f + (bWaveDif - 1f) * v; - tinyWaveDrawable.waveDif = 1 + (tWaveDif - 1f) * v; - - waveAngle = (float) Math.acos(waveDif); - tinyWaveDrawable.waveAngle = (float) Math.acos(-tinyWaveDrawable.waveDif); - }); - animator.setDuration(1200); - animator.start(); - } - - isIdle = idle; - - if (!isIdle && animator != null) { - animator.cancel(); - animator = null; - } - } - - private void startFling(float delta) { - if (!LiteMode.isEnabled(LiteMode.FLAG_CALLS_ANIMATIONS)) { - return; - } - if (flingAnimator != null) { - flingAnimator.cancel(); - } - float fling = this.fling * 2; - float flingDistance = delta * amplitudeRadius * (isBig ? 8 : 20) * 16 * fling; - ValueAnimator valueAnimator = ValueAnimator.ofFloat(flingRadius, flingDistance); - valueAnimator.addUpdateListener(flingUpdateListener); - - valueAnimator.setDuration((long) ((isBig ? 200 : 350) * fling)); - valueAnimator.setInterpolator(linearInterpolator); - ValueAnimator valueAnimator1 = ValueAnimator.ofFloat(flingDistance, 0); - valueAnimator1.addUpdateListener(flingUpdateListener); - - valueAnimator1.setInterpolator(linearInterpolator); - valueAnimator1.setDuration((long) ((isBig ? 220 : 380) * fling)); - - AnimatorSet animatorSet = new AnimatorSet(); - flingAnimator = animatorSet; - animatorSet.playSequentially(valueAnimator, valueAnimator1); - animatorSet.start(); - - } - - boolean wasFling; - - public void tick(float circleRadius) { - if (!LiteMode.isEnabled(LiteMode.FLAG_CALLS_ANIMATIONS)) { - return; - } - long newTime = SystemClock.elapsedRealtime(); - long dt = newTime - lastUpdateTime; - lastUpdateTime = newTime; - if (dt > 20) { - dt = 17; - } - - if (animateToAmplitude != amplitude) { - amplitude += animateAmplitudeDiff * dt; - if (animateAmplitudeDiff > 0) { - if (amplitude > animateToAmplitude) { - amplitude = animateToAmplitude; - } - } else { - if (amplitude < animateToAmplitude) { - amplitude = animateToAmplitude; - } - } - - if (Math.abs(amplitude - animateToAmplitude) * amplitudeRadius < AndroidUtilities.dp(4)) { - if (!wasFling) { - startFling(animateAmplitudeDiff); - wasFling = true; - } - } else { - wasFling = false; - } - } - - if (animateToAmplitude != slowAmplitude) { - slowAmplitude += animateAmplitudeSlowDiff * dt; - if (Math.abs(slowAmplitude - amplitude) > 0.2f) { - slowAmplitude = amplitude + (slowAmplitude > amplitude ? - 0.2f : -0.2f); - } - if (animateAmplitudeSlowDiff > 0) { - if (slowAmplitude > animateToAmplitude) { - slowAmplitude = animateToAmplitude; - } - } else { - if (slowAmplitude < animateToAmplitude) { - slowAmplitude = animateToAmplitude; - } - } - } - - - idleRadius = circleRadius * idleRadiusK; - if (expandIdleRadius) { - scaleIdleDif += scaleSpeedIdle * dt; - if (scaleIdleDif >= 0.05f) { - scaleIdleDif = 0.05f; - expandIdleRadius = false; - } - } else { - scaleIdleDif -= scaleSpeedIdle * dt; - if (scaleIdleDif < 0f) { - scaleIdleDif = 0f; - expandIdleRadius = true; - } - } - - if (maxScale > 0) { - if (expandScale) { - scaleDif += scaleSpeed * dt; - if (scaleDif >= maxScale) { - scaleDif = maxScale; - expandScale = false; - } - } else { - scaleDif -= scaleSpeed * dt; - if (scaleDif < 0f) { - scaleDif = 0f; - expandScale = true; - } - } - } - - - if (sineAngleMax > animateToAmplitude) { - sineAngleMax -= 0.25f; - if (sineAngleMax < animateToAmplitude) { - sineAngleMax = animateToAmplitude; - } - } else if (sineAngleMax < animateToAmplitude) { - sineAngleMax += 0.25f; - if (sineAngleMax > animateToAmplitude) { - sineAngleMax = animateToAmplitude; - } - } - - if (!isIdle) { - rotation += (ROTATION_SPEED * 0.5f + ROTATION_SPEED * 4f * (amplitude > 0.5f ? 1 : amplitude / 0.5f)) * dt; - if (rotation > 360) rotation %= 360; - } else { - idleRotation += IDLE_ROTATE_DIF * dt; - if (idleRotation > 360) idleRotation %= 360; - } - - if (lastRadius < circleRadius) { - lastRadius = circleRadius; - } else { - lastRadius -= radiusDiff * dt; - if (lastRadius < circleRadius) { - lastRadius = circleRadius; - } - } - - lastRadius = circleRadius; - - if (!isIdle) { - waveAngle += (amplitudeWaveDif * sineAngleMax) * dt; - if (isBig) { - waveDif = (float) Math.cos(waveAngle); - } else { - waveDif = -(float) Math.cos(waveAngle); - } - - if (waveDif > 0f && incRandomAdditionals) { - circleBezierDrawable.calculateRandomAdditionals(); - incRandomAdditionals = false; - } else if (waveDif < 0f && !incRandomAdditionals) { - circleBezierDrawable.calculateRandomAdditionals(); - incRandomAdditionals = true; - } - } - - parentView.invalidate(); - } - - public void draw(float cx, float cy, float scale, Canvas canvas) { - if (!LiteMode.isEnabled(LiteMode.FLAG_CALLS_ANIMATIONS)) { - return; - } - float waveAmplitude = amplitude < 0.3f ? amplitude / 0.3f : 1f; - float radiusDiff = AndroidUtilities.dp(10) + AndroidUtilities.dp(50) * WAVE_ANGLE * animateToAmplitude; - - circleBezierDrawable.idleStateDiff = idleRadius * (1f - waveAmplitude); - - float kDiff = 0.35f * waveAmplitude * waveDif; - circleBezierDrawable.radiusDiff = radiusDiff * kDiff; - circleBezierDrawable.cubicBezierK = 1f + Math.abs(kDiff) * waveAmplitude + (1f - waveAmplitude) * idleRadiusK; - - - circleBezierDrawable.radius = (lastRadius + amplitudeRadius * amplitude) + idleGlobalRadius + (flingRadius * waveAmplitude); - - if (circleBezierDrawable.radius + circleBezierDrawable.radiusDiff < circleRadius) { - circleBezierDrawable.radiusDiff = circleRadius - circleBezierDrawable.radius; - } - - if (isBig) { - circleBezierDrawable.globalRotate = rotation + idleRotation; - } else { - circleBezierDrawable.globalRotate = -rotation + idleRotation; - } - - canvas.save(); - float s = scale + scaleIdleDif * (1f - waveAmplitude) + scaleDif * waveAmplitude; - canvas.scale(s, s, cx, cy); - circleBezierDrawable.setRandomAdditions(waveAmplitude * waveDif * randomAdditions); - - circleBezierDrawable.draw(cx, cy, canvas, isBig ? paintRecordWaveBig : paintRecordWaveTin); - canvas.restore(); - } - - public void setCircleRadius(float radius) { - circleRadius = radius; - } - - public void setColor(int color, int alpha) { - paintRecordWaveBig.setColor(color); - paintRecordWaveTin.setColor(color); - paintRecordWaveBig.setAlpha(alpha); - paintRecordWaveTin.setAlpha(alpha); - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java index a98b2f4496b..d944967d89b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java @@ -142,7 +142,6 @@ import org.telegram.ui.Components.ShareAlert; import org.telegram.ui.Components.TypefaceSpan; import org.telegram.ui.Components.UndoView; -import org.telegram.ui.Components.WaveDrawable; import org.telegram.ui.Components.voip.CellFlickerDrawable; import org.telegram.ui.Components.voip.GroupCallGridCell; import org.telegram.ui.Components.voip.GroupCallMiniTextureView; @@ -4066,8 +4065,8 @@ protected boolean drawChild(Canvas canvas, View child, long drawingTime) { bigWaveDrawable.maxRadius = AndroidUtilities.dp(75); bigWaveDrawable.generateBlob(); - tinyWaveDrawable.paint.setColor(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_voipgroup_unmuteButton), (int) (255 * WaveDrawable.CIRCLE_ALPHA_2))); - bigWaveDrawable.paint.setColor(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_voipgroup_unmuteButton), (int) (255 * WaveDrawable.CIRCLE_ALPHA_1))); + tinyWaveDrawable.paint.setColor(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_voipgroup_unmuteButton), 38)); + bigWaveDrawable.paint.setColor(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_voipgroup_unmuteButton),76)); soundButton = new VoIPToggleButton(context); soundButton.setCheckable(true); From 97c4ac68d94835fe002e5e2428f471dae3038ca3 Mon Sep 17 00:00:00 2001 From: Makhorin Date: Mon, 13 Mar 2023 00:36:02 +0300 Subject: [PATCH 2/2] Replace magic numbers with constants and move them to BlobDrawable. --- .../org/telegram/ui/Cells/GroupCallUserCell.java | 6 +++--- .../org/telegram/ui/Components/BlobDrawable.java | 7 +++++++ .../ui/Components/ChatActivityEnterView.java | 12 ++++++------ .../ui/Components/GroupCallFullscreenAdapter.java | 6 +++--- .../main/java/org/telegram/ui/GroupCallActivity.java | 4 ++-- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupCallUserCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupCallUserCell.java index c03306060bf..96d88b944ee 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupCallUserCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupCallUserCell.java @@ -952,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), 76)); - blobDrawable2.paint.setColor(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_voipgroup_speakingText), 76)); + 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() { @@ -1011,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, 76)); + blobDrawable.paint.setColor(ColorUtils.setAlphaComponent(color, BlobDrawable.ALPHA_2)); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/BlobDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/BlobDrawable.java index 789d0165e2f..e95a8a54658 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/BlobDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/BlobDrawable.java @@ -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; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java index 01e76a397b8..9ab1ad9afa7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java @@ -1002,11 +1002,11 @@ private void checkDrawables() { } public void setAmplitude(double value) { - bigWaveDrawable.setValue((float) (Math.min(1800, value) / 1800), true); - tinyWaveDrawable.setValue((float) (Math.min(1800, value) / 1800), 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(1800, value) / 1800); - animateAmplitudeDiff = (animateToAmplitude - amplitude) / (100f + 500.0f * 0.55f); + animateToAmplitude = (float) (Math.min(BlobDrawable.MAX_AMPLITUDE, value) / BlobDrawable.MAX_AMPLITUDE); + animateAmplitudeDiff = (animateToAmplitude - amplitude) / (100f + 500.0f * BlobDrawable.ANIMATION_SPEED); invalidate(); } @@ -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), 38)); - bigWaveDrawable.paint.setColor(ColorUtils.setAlphaComponent(getThemedColor(Theme.key_chat_messagePanelVoiceBackground), 76)); + 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)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/GroupCallFullscreenAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/GroupCallFullscreenAdapter.java index 682b59483b7..63ea2525cf9 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/GroupCallFullscreenAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/GroupCallFullscreenAdapter.java @@ -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, 76)); + avatarWavesDrawable.setColor(ColorUtils.setAlphaComponent(newWavesColor, BlobDrawable.ALPHA_2)); invalidate(); } else { int colorFrom = lastColor; @@ -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, 76)); + avatarWavesDrawable.setColor(ColorUtils.setAlphaComponent(lastWavesColor, BlobDrawable.ALPHA_2)); invalidate(); }); colorAnimator.addListener(new AnimatorListenerAdapter() { @@ -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, 76)); + avatarWavesDrawable.setColor(ColorUtils.setAlphaComponent(lastWavesColor, BlobDrawable.ALPHA_2)); } }); colorAnimator.start(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java index d944967d89b..9627dc1f547 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java @@ -4065,8 +4065,8 @@ protected boolean drawChild(Canvas canvas, View child, long drawingTime) { bigWaveDrawable.maxRadius = AndroidUtilities.dp(75); bigWaveDrawable.generateBlob(); - tinyWaveDrawable.paint.setColor(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_voipgroup_unmuteButton), 38)); - bigWaveDrawable.paint.setColor(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_voipgroup_unmuteButton),76)); + tinyWaveDrawable.paint.setColor(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_voipgroup_unmuteButton), BlobDrawable.ALPHA_2)); + bigWaveDrawable.paint.setColor(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_voipgroup_unmuteButton),BlobDrawable.ALPHA_1)); soundButton = new VoIPToggleButton(context); soundButton.setCheckable(true);