mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Remove typing animation code.
This commit is contained in:
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* This is the source code of Telegram for Android v. 3.x.x
|
||||
* It is licensed under GNU GPL v. 2 or later.
|
||||
* You should have received a copy of the license in this archive (see LICENSE).
|
||||
*
|
||||
* Copyright Nikolai Kudashov, 2013-2016.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Components;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
|
||||
public class RecordStatusDrawable extends Drawable {
|
||||
|
||||
private boolean isChat = false;
|
||||
private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
private long lastUpdateTime = 0;
|
||||
private boolean started = false;
|
||||
private RectF rect = new RectF();
|
||||
private float progress;
|
||||
|
||||
public RecordStatusDrawable() {
|
||||
super();
|
||||
paint.setColor(Theme.ACTION_BAR_SUBTITLE_COLOR);
|
||||
paint.setStyle(Paint.Style.STROKE);
|
||||
paint.setStrokeWidth(AndroidUtilities.dp(2));
|
||||
paint.setStrokeCap(Paint.Cap.ROUND);
|
||||
}
|
||||
|
||||
public void setIsChat(boolean value) {
|
||||
isChat = value;
|
||||
}
|
||||
|
||||
private void update() {
|
||||
long newTime = System.currentTimeMillis();
|
||||
long dt = newTime - lastUpdateTime;
|
||||
lastUpdateTime = newTime;
|
||||
if (dt > 50) {
|
||||
dt = 50;
|
||||
}
|
||||
progress += dt / 300.0f;
|
||||
while (progress > 1.0f) {
|
||||
progress -= 1.0f;
|
||||
}
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
public void start() {
|
||||
lastUpdateTime = System.currentTimeMillis();
|
||||
started = true;
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
started = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
canvas.save();
|
||||
canvas.translate(0, getIntrinsicHeight() / 2 + AndroidUtilities.dp(isChat ? 1 : 2));
|
||||
for (int a = 0; a < 4; a++) {
|
||||
if (a == 0) {
|
||||
paint.setAlpha((int) (255 * progress));
|
||||
} else if (a == 3) {
|
||||
paint.setAlpha((int) (255 * (1.0f - progress)));
|
||||
} else {
|
||||
paint.setAlpha(255);
|
||||
}
|
||||
float side = AndroidUtilities.dp(4) * a + AndroidUtilities.dp(4) * progress;
|
||||
rect.set(-side, -side, side, side);
|
||||
canvas.drawArc(rect, -15, 30, false, paint);
|
||||
}
|
||||
canvas.restore();
|
||||
if (started) {
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter cf) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicWidth() {
|
||||
return AndroidUtilities.dp(18);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicHeight() {
|
||||
return AndroidUtilities.dp(14);
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
/*
|
||||
* This is the source code of Telegram for Android v. 3.x.x.
|
||||
* It is licensed under GNU GPL v. 2 or later.
|
||||
* You should have received a copy of the license in this archive (see LICENSE).
|
||||
*
|
||||
* Copyright Nikolai Kudashov, 2013-2016.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Components;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
|
||||
public class TypingDotsDrawable extends Drawable {
|
||||
|
||||
private boolean isChat = false;
|
||||
private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
private float[] scales = new float[3];
|
||||
private float[] startTimes = new float[] {0, 150, 300};
|
||||
private float[] elapsedTimes = new float[] {0, 0, 0};
|
||||
private long lastUpdateTime = 0;
|
||||
private boolean started = false;
|
||||
private DecelerateInterpolator decelerateInterpolator = new DecelerateInterpolator();
|
||||
|
||||
public TypingDotsDrawable() {
|
||||
super();
|
||||
paint.setColor(Theme.ACTION_BAR_SUBTITLE_COLOR);
|
||||
}
|
||||
|
||||
public void setIsChat(boolean value) {
|
||||
isChat = value;
|
||||
}
|
||||
|
||||
private void update() {
|
||||
long newTime = System.currentTimeMillis();
|
||||
long dt = newTime - lastUpdateTime;
|
||||
lastUpdateTime = newTime;
|
||||
if (dt > 50) {
|
||||
dt = 50;
|
||||
}
|
||||
|
||||
for (int a = 0; a < 3; a++) {
|
||||
elapsedTimes[a] += dt;
|
||||
float timeSinceStart = elapsedTimes[a] - startTimes[a];
|
||||
if (timeSinceStart > 0) {
|
||||
if (timeSinceStart <= 320) {
|
||||
float diff = decelerateInterpolator.getInterpolation(timeSinceStart / 320.0f);
|
||||
scales[a] = 1.33f + diff;
|
||||
} else if (timeSinceStart <= 640) {
|
||||
float diff = decelerateInterpolator.getInterpolation((timeSinceStart - 320.0f) / 320.0f);
|
||||
scales[a] = 1.33f + (1 - diff);
|
||||
} else if (timeSinceStart >= 800) {
|
||||
elapsedTimes[a] = 0;
|
||||
startTimes[a] = 0;
|
||||
scales[a] = 1.33f;
|
||||
} else {
|
||||
scales[a] = 1.33f;
|
||||
}
|
||||
} else {
|
||||
scales[a] = 1.33f;
|
||||
}
|
||||
}
|
||||
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
public void start() {
|
||||
lastUpdateTime = System.currentTimeMillis();
|
||||
started = true;
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
for (int a = 0; a < 3; a++) {
|
||||
elapsedTimes[a] = 0;
|
||||
scales[a] = 1.33f;
|
||||
}
|
||||
startTimes[0] = 0;
|
||||
startTimes[1] = 150;
|
||||
startTimes[2] = 300;
|
||||
started = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
int y;
|
||||
if (isChat) {
|
||||
y = AndroidUtilities.dp(8.5f) + getBounds().top;
|
||||
} else {
|
||||
y = AndroidUtilities.dp(9.3f) + getBounds().top;
|
||||
}
|
||||
canvas.drawCircle(AndroidUtilities.dp(3), y, scales[0] * AndroidUtilities.density, paint);
|
||||
canvas.drawCircle(AndroidUtilities.dp(9), y, scales[1] * AndroidUtilities.density, paint);
|
||||
canvas.drawCircle(AndroidUtilities.dp(15), y, scales[2] * AndroidUtilities.density, paint);
|
||||
checkUpdate();
|
||||
}
|
||||
|
||||
private void checkUpdate() {
|
||||
if (started) {
|
||||
if (!NotificationCenter.getInstance().isAnimationInProgress()) {
|
||||
update();
|
||||
} else {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
checkUpdate();
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter cf) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicWidth() {
|
||||
return AndroidUtilities.dp(18);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicHeight() {
|
||||
return AndroidUtilities.dp(18);
|
||||
}
|
||||
}
|
||||
@@ -59,10 +59,8 @@ import org.telegram.ui.Components.BackupImageView;
|
||||
import org.telegram.ui.Components.ChatActivityEnterView;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.PopupAudioView;
|
||||
import org.telegram.ui.Components.RecordStatusDrawable;
|
||||
import org.telegram.ui.Components.SizeNotifierFrameLayout;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Components.TypingDotsDrawable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -86,8 +84,8 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
||||
private ArrayList<ViewGroup> imageViews = new ArrayList<>();
|
||||
private ArrayList<ViewGroup> audioViews = new ArrayList<>();
|
||||
private VelocityTracker velocityTracker = null;
|
||||
private TypingDotsDrawable typingDotsDrawable;
|
||||
private RecordStatusDrawable recordStatusDrawable;
|
||||
//private TypingDotsDrawable typingDotsDrawable;
|
||||
//private RecordStatusDrawable recordStatusDrawable;
|
||||
|
||||
private int classGuid;
|
||||
private TLRPC.User currentUser;
|
||||
@@ -175,14 +173,14 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.contactsDidLoaded);
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded);
|
||||
|
||||
typingDotsDrawable = new TypingDotsDrawable();
|
||||
recordStatusDrawable = new RecordStatusDrawable();
|
||||
//typingDotsDrawable = new TypingDotsDrawable();
|
||||
//recordStatusDrawable = new RecordStatusDrawable();
|
||||
|
||||
SizeNotifierFrameLayout contentView = new SizeNotifierFrameLayout(this) {
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
|
||||
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
|
||||
//int widthMode = MeasureSpec.getMode(widthMeasureSpec);
|
||||
//int heightMode = MeasureSpec.getMode(heightMeasureSpec);
|
||||
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
|
||||
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
|
||||
|
||||
@@ -1045,7 +1043,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
||||
CharSequence printString = MessagesController.getInstance().printingStrings.get(currentMessageObject.getDialogId());
|
||||
if (printString == null || printString.length() == 0) {
|
||||
lastPrintString = null;
|
||||
setTypingAnimation(false);
|
||||
//setTypingAnimation(false);
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(currentUser.id);
|
||||
if (user != null) {
|
||||
currentUser = user;
|
||||
@@ -1054,7 +1052,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
||||
} else {
|
||||
lastPrintString = printString;
|
||||
onlineTextView.setText(printString);
|
||||
setTypingAnimation(true);
|
||||
//setTypingAnimation(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1087,6 +1085,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
private void setTypingAnimation(boolean start) {
|
||||
if (actionBar == null) {
|
||||
return;
|
||||
@@ -1115,6 +1114,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
||||
recordStatusDrawable.stop();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
|
||||
Reference in New Issue
Block a user