2014-02-04 19:36:55 +01:00
|
|
|
/*
|
|
|
|
* This is the source code of Telegram for Android v. 1.3.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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.telegram.ui.Cells;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.graphics.Canvas;
|
2014-10-21 22:35:16 +02:00
|
|
|
import android.graphics.Paint;
|
2014-02-04 19:36:55 +01:00
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
|
import android.text.Html;
|
|
|
|
import android.text.Layout;
|
|
|
|
import android.text.StaticLayout;
|
|
|
|
import android.text.TextPaint;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
2014-07-03 00:39:05 +02:00
|
|
|
import org.telegram.android.AndroidUtilities;
|
2014-02-04 19:36:55 +01:00
|
|
|
import org.telegram.PhoneFormat.PhoneFormat;
|
2014-07-03 00:39:05 +02:00
|
|
|
import org.telegram.android.LocaleController;
|
2014-09-14 01:40:36 +02:00
|
|
|
import org.telegram.messenger.FileLog;
|
2014-02-28 23:28:25 +01:00
|
|
|
import org.telegram.messenger.TLRPC;
|
2014-07-03 00:39:05 +02:00
|
|
|
import org.telegram.android.ContactsController;
|
|
|
|
import org.telegram.android.Emoji;
|
|
|
|
import org.telegram.android.MessagesController;
|
2014-02-04 19:36:55 +01:00
|
|
|
import org.telegram.messenger.R;
|
|
|
|
import org.telegram.messenger.UserConfig;
|
2014-08-22 16:24:33 +02:00
|
|
|
import org.telegram.android.MessageObject;
|
|
|
|
import org.telegram.android.ImageReceiver;
|
2014-02-04 19:36:55 +01:00
|
|
|
|
|
|
|
public class DialogCell extends BaseCell {
|
|
|
|
private static TextPaint namePaint;
|
|
|
|
private static TextPaint nameEncryptedPaint;
|
|
|
|
private static TextPaint nameUnknownPaint;
|
|
|
|
private static TextPaint messagePaint;
|
|
|
|
private static TextPaint messagePrintingPaint;
|
|
|
|
private static TextPaint timePaint;
|
|
|
|
private static TextPaint countPaint;
|
|
|
|
|
|
|
|
private static Drawable checkDrawable;
|
|
|
|
private static Drawable halfCheckDrawable;
|
|
|
|
private static Drawable clockDrawable;
|
|
|
|
private static Drawable errorDrawable;
|
|
|
|
private static Drawable lockDrawable;
|
|
|
|
private static Drawable countDrawable;
|
2014-03-26 00:38:23 +01:00
|
|
|
private static Drawable groupDrawable;
|
2014-07-27 00:28:33 +02:00
|
|
|
private static Drawable broadcastDrawable;
|
2014-02-04 19:36:55 +01:00
|
|
|
|
2014-10-21 22:35:16 +02:00
|
|
|
private static Paint linePaint;
|
|
|
|
|
2014-02-04 19:36:55 +01:00
|
|
|
private TLRPC.TL_dialog currentDialog;
|
|
|
|
private ImageReceiver avatarImage;
|
|
|
|
|
|
|
|
private DialogCellLayout cellLayout;
|
|
|
|
private TLRPC.User user = null;
|
|
|
|
private TLRPC.Chat chat = null;
|
|
|
|
private TLRPC.EncryptedChat encryptedChat = null;
|
|
|
|
private CharSequence lastPrintString = null;
|
|
|
|
|
2014-10-21 22:35:16 +02:00
|
|
|
public boolean useSeparator = false;
|
|
|
|
|
2014-02-04 19:36:55 +01:00
|
|
|
private void init() {
|
|
|
|
if (namePaint == null) {
|
|
|
|
namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
2014-07-03 00:39:05 +02:00
|
|
|
namePaint.setTextSize(AndroidUtilities.dp(19));
|
2014-02-04 19:36:55 +01:00
|
|
|
namePaint.setColor(0xff222222);
|
2014-07-03 00:39:05 +02:00
|
|
|
namePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (nameEncryptedPaint == null) {
|
|
|
|
nameEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
2014-07-03 00:39:05 +02:00
|
|
|
nameEncryptedPaint.setTextSize(AndroidUtilities.dp(19));
|
2014-02-04 19:36:55 +01:00
|
|
|
nameEncryptedPaint.setColor(0xff00a60e);
|
2014-07-03 00:39:05 +02:00
|
|
|
nameEncryptedPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (nameUnknownPaint == null) {
|
|
|
|
nameUnknownPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
2014-07-03 00:39:05 +02:00
|
|
|
nameUnknownPaint.setTextSize(AndroidUtilities.dp(19));
|
2014-02-04 19:36:55 +01:00
|
|
|
nameUnknownPaint.setColor(0xff316f9f);
|
2014-07-03 00:39:05 +02:00
|
|
|
nameUnknownPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (messagePaint == null) {
|
|
|
|
messagePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
2014-07-03 00:39:05 +02:00
|
|
|
messagePaint.setTextSize(AndroidUtilities.dp(16));
|
2014-02-04 19:36:55 +01:00
|
|
|
messagePaint.setColor(0xff808080);
|
|
|
|
}
|
|
|
|
|
2014-10-21 22:35:16 +02:00
|
|
|
if (linePaint == null) {
|
|
|
|
linePaint = new Paint();
|
|
|
|
linePaint.setColor(0xffdcdcdc);
|
|
|
|
}
|
|
|
|
|
2014-02-04 19:36:55 +01:00
|
|
|
if (messagePrintingPaint == null) {
|
|
|
|
messagePrintingPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
2014-07-03 00:39:05 +02:00
|
|
|
messagePrintingPaint.setTextSize(AndroidUtilities.dp(16));
|
2014-02-04 19:36:55 +01:00
|
|
|
messagePrintingPaint.setColor(0xff316f9f);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (timePaint == null) {
|
|
|
|
timePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
2014-07-03 00:39:05 +02:00
|
|
|
timePaint.setTextSize(AndroidUtilities.dp(14));
|
2014-02-04 19:36:55 +01:00
|
|
|
timePaint.setColor(0xff9e9e9e);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (countPaint == null) {
|
|
|
|
countPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
2014-07-03 00:39:05 +02:00
|
|
|
countPaint.setTextSize(AndroidUtilities.dp(13));
|
2014-02-04 19:36:55 +01:00
|
|
|
countPaint.setColor(0xffffffff);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lockDrawable == null) {
|
|
|
|
lockDrawable = getResources().getDrawable(R.drawable.ic_lock_green);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (checkDrawable == null) {
|
|
|
|
checkDrawable = getResources().getDrawable(R.drawable.dialogs_check);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (halfCheckDrawable == null) {
|
|
|
|
halfCheckDrawable = getResources().getDrawable(R.drawable.dialogs_halfcheck);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (clockDrawable == null) {
|
|
|
|
clockDrawable = getResources().getDrawable(R.drawable.msg_clock);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (errorDrawable == null) {
|
|
|
|
errorDrawable = getResources().getDrawable(R.drawable.dialogs_warning);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (countDrawable == null) {
|
|
|
|
countDrawable = getResources().getDrawable(R.drawable.dialogs_badge);
|
|
|
|
}
|
|
|
|
|
2014-03-26 00:38:23 +01:00
|
|
|
if (groupDrawable == null) {
|
|
|
|
groupDrawable = getResources().getDrawable(R.drawable.grouplist);
|
|
|
|
}
|
|
|
|
|
2014-07-27 00:28:33 +02:00
|
|
|
if (broadcastDrawable == null) {
|
|
|
|
broadcastDrawable = getResources().getDrawable(R.drawable.broadcast);
|
|
|
|
}
|
|
|
|
|
2014-02-04 19:36:55 +01:00
|
|
|
if (avatarImage == null) {
|
2014-08-22 16:24:33 +02:00
|
|
|
avatarImage = new ImageReceiver(this);
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cellLayout == null) {
|
|
|
|
cellLayout = new DialogCellLayout();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public DialogCell(Context context) {
|
|
|
|
super(context);
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDialog(TLRPC.TL_dialog dialog) {
|
|
|
|
currentDialog = dialog;
|
|
|
|
update(0);
|
|
|
|
}
|
|
|
|
|
2014-09-24 04:17:27 +02:00
|
|
|
public TLRPC.TL_dialog getDialog() {
|
|
|
|
return currentDialog;
|
|
|
|
}
|
|
|
|
|
2014-03-27 15:25:53 +01:00
|
|
|
@Override
|
|
|
|
protected void onDetachedFromWindow() {
|
|
|
|
super.onDetachedFromWindow();
|
|
|
|
if (avatarImage != null) {
|
|
|
|
avatarImage.clearImage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-04 19:36:55 +01:00
|
|
|
@Override
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
2014-07-03 00:39:05 +02:00
|
|
|
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), AndroidUtilities.dp(70));
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
|
|
|
if (currentDialog == null) {
|
|
|
|
super.onLayout(changed, left, top, right, bottom);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (changed) {
|
|
|
|
buildLayout();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void buildLayout() {
|
|
|
|
cellLayout.build(getMeasuredWidth(), getMeasuredHeight());
|
|
|
|
}
|
|
|
|
|
|
|
|
public void update(int mask) {
|
|
|
|
if (mask != 0) {
|
|
|
|
boolean continueUpdate = false;
|
|
|
|
if ((mask & MessagesController.UPDATE_MASK_USER_PRINT) != 0) {
|
2014-03-22 23:31:55 +01:00
|
|
|
CharSequence printString = MessagesController.getInstance().printingStrings.get(currentDialog.id);
|
2014-02-04 19:36:55 +01:00
|
|
|
if (lastPrintString != null && printString == null || lastPrintString == null && printString != null || lastPrintString != null && printString != null && !lastPrintString.equals(printString)) {
|
|
|
|
continueUpdate = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0) {
|
|
|
|
if (chat == null) {
|
|
|
|
continueUpdate = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((mask & MessagesController.UPDATE_MASK_NAME) != 0) {
|
|
|
|
if (chat == null) {
|
|
|
|
continueUpdate = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((mask & MessagesController.UPDATE_MASK_CHAT_AVATAR) != 0) {
|
|
|
|
if (user == null) {
|
|
|
|
continueUpdate = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((mask & MessagesController.UPDATE_MASK_CHAT_NAME) != 0) {
|
|
|
|
if (user == null) {
|
|
|
|
continueUpdate = true;
|
|
|
|
}
|
|
|
|
}
|
2014-03-22 23:31:55 +01:00
|
|
|
if ((mask & MessagesController.UPDATE_MASK_READ_DIALOG_MESSAGE) != 0) {
|
|
|
|
continueUpdate = true;
|
|
|
|
}
|
2014-02-04 19:36:55 +01:00
|
|
|
|
|
|
|
if (!continueUpdate) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
user = null;
|
|
|
|
chat = null;
|
|
|
|
encryptedChat = null;
|
|
|
|
|
|
|
|
int lower_id = (int)currentDialog.id;
|
2014-07-27 12:53:00 +02:00
|
|
|
int high_id = (int)(currentDialog.id >> 32);
|
2014-02-04 19:36:55 +01:00
|
|
|
if (lower_id != 0) {
|
2014-07-27 12:53:00 +02:00
|
|
|
if (high_id == 1) {
|
2014-08-22 16:24:33 +02:00
|
|
|
chat = MessagesController.getInstance().getChat(lower_id);
|
2014-02-04 19:36:55 +01:00
|
|
|
} else {
|
2014-07-27 12:53:00 +02:00
|
|
|
if (lower_id < 0) {
|
2014-08-22 16:24:33 +02:00
|
|
|
chat = MessagesController.getInstance().getChat(-lower_id);
|
2014-07-27 12:53:00 +02:00
|
|
|
} else {
|
2014-08-22 16:24:33 +02:00
|
|
|
user = MessagesController.getInstance().getUser(lower_id);
|
2014-07-27 12:53:00 +02:00
|
|
|
}
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
|
|
|
} else {
|
2014-08-22 16:24:33 +02:00
|
|
|
encryptedChat = MessagesController.getInstance().getEncryptedChat(high_id);
|
2014-07-27 12:53:00 +02:00
|
|
|
if (encryptedChat != null) {
|
2014-08-22 16:24:33 +02:00
|
|
|
user = MessagesController.getInstance().getUser(encryptedChat.user_id);
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int placeHolderId = 0;
|
|
|
|
TLRPC.FileLocation photo = null;
|
|
|
|
if (user != null) {
|
|
|
|
if (user.photo != null) {
|
|
|
|
photo = user.photo.photo_small;
|
|
|
|
}
|
2014-09-24 04:17:27 +02:00
|
|
|
placeHolderId = AndroidUtilities.getUserAvatarForId(user.id);
|
2014-02-04 19:36:55 +01:00
|
|
|
} else if (chat != null) {
|
|
|
|
if (chat.photo != null) {
|
|
|
|
photo = chat.photo.photo_small;
|
|
|
|
}
|
2014-09-24 04:17:27 +02:00
|
|
|
if (chat.id > 0) {
|
|
|
|
placeHolderId = AndroidUtilities.getGroupAvatarForId(chat.id);
|
|
|
|
} else {
|
|
|
|
placeHolderId = AndroidUtilities.getBroadcastAvatarForId(chat.id);
|
|
|
|
}
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
2014-10-07 22:14:27 +02:00
|
|
|
avatarImage.setImage(photo, "50_50", placeHolderId == 0 ? null : getResources().getDrawable(placeHolderId), false);
|
2014-02-04 19:36:55 +01:00
|
|
|
|
|
|
|
if (getMeasuredWidth() != 0 || getMeasuredHeight() != 0) {
|
|
|
|
buildLayout();
|
|
|
|
} else {
|
|
|
|
requestLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onDraw(Canvas canvas) {
|
|
|
|
if (currentDialog == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cellLayout == null) {
|
|
|
|
requestLayout();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cellLayout.drawNameLock) {
|
|
|
|
setDrawableBounds(lockDrawable, cellLayout.nameLockLeft, cellLayout.nameLockTop);
|
|
|
|
lockDrawable.draw(canvas);
|
2014-03-26 00:38:23 +01:00
|
|
|
} else if (cellLayout.drawNameGroup) {
|
|
|
|
setDrawableBounds(groupDrawable, cellLayout.nameLockLeft, cellLayout.nameLockTop);
|
|
|
|
groupDrawable.draw(canvas);
|
2014-07-27 00:28:33 +02:00
|
|
|
} else if (cellLayout.drawNameBroadcast) {
|
|
|
|
setDrawableBounds(broadcastDrawable, cellLayout.nameLockLeft, cellLayout.nameLockTop);
|
|
|
|
broadcastDrawable.draw(canvas);
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
|
|
|
|
2014-09-14 01:40:36 +02:00
|
|
|
if (cellLayout.nameLayout != null) {
|
|
|
|
canvas.save();
|
|
|
|
canvas.translate(cellLayout.nameLeft, cellLayout.nameTop);
|
|
|
|
cellLayout.nameLayout.draw(canvas);
|
|
|
|
canvas.restore();
|
|
|
|
}
|
2014-02-04 19:36:55 +01:00
|
|
|
|
|
|
|
canvas.save();
|
|
|
|
canvas.translate(cellLayout.timeLeft, cellLayout.timeTop);
|
|
|
|
cellLayout.timeLayout.draw(canvas);
|
|
|
|
canvas.restore();
|
|
|
|
|
|
|
|
canvas.save();
|
|
|
|
canvas.translate(cellLayout.messageLeft, cellLayout.messageTop);
|
|
|
|
cellLayout.messageLayout.draw(canvas);
|
|
|
|
canvas.restore();
|
|
|
|
|
|
|
|
if (cellLayout.drawClock) {
|
|
|
|
setDrawableBounds(clockDrawable, cellLayout.checkDrawLeft, cellLayout.checkDrawTop);
|
|
|
|
clockDrawable.draw(canvas);
|
|
|
|
} else if (cellLayout.drawCheck2) {
|
|
|
|
if (cellLayout.drawCheck1) {
|
|
|
|
setDrawableBounds(halfCheckDrawable, cellLayout.halfCheckDrawLeft, cellLayout.checkDrawTop);
|
|
|
|
halfCheckDrawable.draw(canvas);
|
|
|
|
setDrawableBounds(checkDrawable, cellLayout.checkDrawLeft, cellLayout.checkDrawTop);
|
|
|
|
checkDrawable.draw(canvas);
|
|
|
|
} else {
|
|
|
|
setDrawableBounds(checkDrawable, cellLayout.checkDrawLeft, cellLayout.checkDrawTop);
|
|
|
|
checkDrawable.draw(canvas);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cellLayout.drawError) {
|
|
|
|
setDrawableBounds(errorDrawable, cellLayout.errorLeft, cellLayout.errorTop);
|
|
|
|
errorDrawable.draw(canvas);
|
|
|
|
} else if (cellLayout.drawCount) {
|
2014-07-03 00:39:05 +02:00
|
|
|
setDrawableBounds(countDrawable, cellLayout.countLeft - AndroidUtilities.dp(5), cellLayout.countTop, cellLayout.countWidth + AndroidUtilities.dp(10), countDrawable.getIntrinsicHeight());
|
2014-02-04 19:36:55 +01:00
|
|
|
countDrawable.draw(canvas);
|
|
|
|
canvas.save();
|
2014-07-03 00:39:05 +02:00
|
|
|
canvas.translate(cellLayout.countLeft, cellLayout.countTop + AndroidUtilities.dp(3));
|
2014-02-04 19:36:55 +01:00
|
|
|
cellLayout.countLayout.draw(canvas);
|
|
|
|
canvas.restore();
|
|
|
|
}
|
|
|
|
|
2014-10-21 22:35:16 +02:00
|
|
|
avatarImage.draw(canvas);
|
|
|
|
|
|
|
|
if (useSeparator) {
|
|
|
|
int h = getMeasuredHeight();
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
canvas.drawLine(0, h - 1, getMeasuredWidth(), h - 1, linePaint);
|
|
|
|
} else {
|
|
|
|
canvas.drawLine(AndroidUtilities.dp(11), h - 1, getMeasuredWidth() - AndroidUtilities.dp(11), h - 1, linePaint);
|
|
|
|
}
|
|
|
|
}
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private class DialogCellLayout {
|
|
|
|
private int nameLeft;
|
2014-07-03 00:39:05 +02:00
|
|
|
private int nameTop = AndroidUtilities.dp(10);
|
2014-02-04 19:36:55 +01:00
|
|
|
private int nameWidth;
|
|
|
|
private StaticLayout nameLayout;
|
|
|
|
private boolean drawNameLock;
|
2014-03-26 00:38:23 +01:00
|
|
|
private boolean drawNameGroup;
|
2014-07-27 00:28:33 +02:00
|
|
|
private boolean drawNameBroadcast;
|
2014-02-04 19:36:55 +01:00
|
|
|
private int nameLockLeft;
|
2014-03-26 00:38:23 +01:00
|
|
|
private int nameLockTop;
|
2014-02-04 19:36:55 +01:00
|
|
|
|
|
|
|
private int timeLeft;
|
2014-07-03 00:39:05 +02:00
|
|
|
private int timeTop = AndroidUtilities.dp(13);
|
2014-02-04 19:36:55 +01:00
|
|
|
private int timeWidth;
|
|
|
|
private StaticLayout timeLayout;
|
|
|
|
|
|
|
|
private boolean drawCheck1;
|
|
|
|
private boolean drawCheck2;
|
|
|
|
private boolean drawClock;
|
|
|
|
private int checkDrawLeft;
|
2014-07-03 00:39:05 +02:00
|
|
|
private int checkDrawTop = AndroidUtilities.dp(15);
|
2014-02-04 19:36:55 +01:00
|
|
|
private int halfCheckDrawLeft;
|
|
|
|
|
2014-07-03 00:39:05 +02:00
|
|
|
private int messageTop = AndroidUtilities.dp(40);
|
2014-02-04 19:36:55 +01:00
|
|
|
private int messageLeft;
|
|
|
|
private int messageWidth;
|
|
|
|
private StaticLayout messageLayout;
|
|
|
|
|
|
|
|
private boolean drawError;
|
2014-07-03 00:39:05 +02:00
|
|
|
private int errorTop = AndroidUtilities.dp(37);
|
2014-02-04 19:36:55 +01:00
|
|
|
private int errorLeft;
|
|
|
|
|
|
|
|
private boolean drawCount;
|
2014-07-03 00:39:05 +02:00
|
|
|
private int countTop = AndroidUtilities.dp(37);
|
2014-02-04 19:36:55 +01:00
|
|
|
private int countLeft;
|
|
|
|
private int countWidth;
|
|
|
|
private StaticLayout countLayout;
|
|
|
|
|
2014-07-03 00:39:05 +02:00
|
|
|
private int avatarTop = AndroidUtilities.dp(8);
|
2014-02-04 19:36:55 +01:00
|
|
|
private int avatarLeft;
|
|
|
|
|
|
|
|
public void build(int width, int height) {
|
2014-03-22 23:31:55 +01:00
|
|
|
MessageObject message = MessagesController.getInstance().dialogMessage.get(currentDialog.top_message);
|
2014-02-04 19:36:55 +01:00
|
|
|
String nameString = "";
|
|
|
|
String timeString = "";
|
|
|
|
String countString = null;
|
|
|
|
CharSequence messageString = "";
|
2014-03-22 23:31:55 +01:00
|
|
|
CharSequence printingString = MessagesController.getInstance().printingStrings.get(currentDialog.id);
|
2014-02-04 19:36:55 +01:00
|
|
|
TextPaint currentNamePaint = namePaint;
|
|
|
|
TextPaint currentMessagePaint = messagePaint;
|
|
|
|
boolean checkMessage = true;
|
|
|
|
|
2014-07-27 00:28:33 +02:00
|
|
|
drawNameGroup = false;
|
|
|
|
drawNameBroadcast = false;
|
|
|
|
drawNameLock = false;
|
|
|
|
|
2014-02-04 19:36:55 +01:00
|
|
|
if (encryptedChat != null) {
|
|
|
|
drawNameLock = true;
|
2014-07-03 00:39:05 +02:00
|
|
|
nameLockTop = AndroidUtilities.dp(13);
|
2014-03-25 01:25:32 +01:00
|
|
|
if (!LocaleController.isRTL) {
|
2014-07-03 00:39:05 +02:00
|
|
|
nameLockLeft = AndroidUtilities.dp(77);
|
|
|
|
nameLeft = AndroidUtilities.dp(81) + lockDrawable.getIntrinsicWidth();
|
2014-02-04 19:36:55 +01:00
|
|
|
} else {
|
2014-07-03 00:39:05 +02:00
|
|
|
nameLockLeft = width - AndroidUtilities.dp(77) - lockDrawable.getIntrinsicWidth();
|
|
|
|
nameLeft = AndroidUtilities.dp(14);
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
|
|
|
} else {
|
2014-03-26 00:38:23 +01:00
|
|
|
if (chat != null) {
|
2014-07-27 00:28:33 +02:00
|
|
|
if (chat.id < 0) {
|
|
|
|
drawNameBroadcast = true;
|
|
|
|
} else {
|
|
|
|
drawNameGroup = true;
|
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
nameLockTop = AndroidUtilities.dp(14);
|
2014-03-26 00:38:23 +01:00
|
|
|
if (!LocaleController.isRTL) {
|
2014-07-03 00:39:05 +02:00
|
|
|
nameLockLeft = AndroidUtilities.dp(77);
|
2014-07-27 00:28:33 +02:00
|
|
|
nameLeft = AndroidUtilities.dp(81) + (drawNameGroup ? groupDrawable.getIntrinsicWidth() : broadcastDrawable.getIntrinsicWidth());
|
2014-03-26 00:38:23 +01:00
|
|
|
} else {
|
2014-07-27 00:28:33 +02:00
|
|
|
nameLockLeft = width - AndroidUtilities.dp(77) - (drawNameGroup ? groupDrawable.getIntrinsicWidth() : broadcastDrawable.getIntrinsicWidth());
|
2014-07-03 00:39:05 +02:00
|
|
|
nameLeft = AndroidUtilities.dp(14);
|
2014-03-26 00:38:23 +01:00
|
|
|
}
|
2014-02-04 19:36:55 +01:00
|
|
|
} else {
|
2014-03-26 00:38:23 +01:00
|
|
|
if (!LocaleController.isRTL) {
|
2014-07-03 00:39:05 +02:00
|
|
|
nameLeft = AndroidUtilities.dp(77);
|
2014-03-26 00:38:23 +01:00
|
|
|
} else {
|
2014-07-03 00:39:05 +02:00
|
|
|
nameLeft = AndroidUtilities.dp(14);
|
2014-03-26 00:38:23 +01:00
|
|
|
}
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (message == null) {
|
|
|
|
if (printingString != null) {
|
|
|
|
lastPrintString = messageString = printingString;
|
|
|
|
currentMessagePaint = messagePrintingPaint;
|
|
|
|
} else {
|
|
|
|
lastPrintString = null;
|
|
|
|
if (encryptedChat != null) {
|
|
|
|
currentMessagePaint = messagePrintingPaint;
|
|
|
|
if (encryptedChat instanceof TLRPC.TL_encryptedChatRequested) {
|
2014-03-22 23:31:55 +01:00
|
|
|
messageString = LocaleController.getString("EncryptionProcessing", R.string.EncryptionProcessing);
|
2014-02-04 19:36:55 +01:00
|
|
|
} else if (encryptedChat instanceof TLRPC.TL_encryptedChatWaiting) {
|
2014-02-11 15:32:09 +01:00
|
|
|
if (user != null && user.first_name != null) {
|
2014-03-22 23:31:55 +01:00
|
|
|
messageString = LocaleController.formatString("AwaitingEncryption", R.string.AwaitingEncryption, user.first_name);
|
2014-02-11 15:32:09 +01:00
|
|
|
} else {
|
2014-03-22 23:31:55 +01:00
|
|
|
messageString = LocaleController.formatString("AwaitingEncryption", R.string.AwaitingEncryption, "");
|
2014-02-11 15:32:09 +01:00
|
|
|
}
|
2014-02-04 19:36:55 +01:00
|
|
|
} else if (encryptedChat instanceof TLRPC.TL_encryptedChatDiscarded) {
|
2014-03-22 23:31:55 +01:00
|
|
|
messageString = LocaleController.getString("EncryptionRejected", R.string.EncryptionRejected);
|
2014-02-04 19:36:55 +01:00
|
|
|
} else if (encryptedChat instanceof TLRPC.TL_encryptedChat) {
|
2014-06-13 12:42:21 +02:00
|
|
|
if (encryptedChat.admin_id == UserConfig.getClientUserId()) {
|
2014-02-11 15:32:09 +01:00
|
|
|
if (user != null && user.first_name != null) {
|
2014-03-22 23:31:55 +01:00
|
|
|
messageString = LocaleController.formatString("EncryptedChatStartedOutgoing", R.string.EncryptedChatStartedOutgoing, user.first_name);
|
2014-02-11 15:32:09 +01:00
|
|
|
} else {
|
2014-03-22 23:31:55 +01:00
|
|
|
messageString = LocaleController.formatString("EncryptedChatStartedOutgoing", R.string.EncryptedChatStartedOutgoing, "");
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
|
|
|
} else {
|
2014-03-22 23:31:55 +01:00
|
|
|
messageString = LocaleController.getString("EncryptedChatStartedIncoming", R.string.EncryptedChatStartedIncoming);
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (currentDialog.last_message_date != 0) {
|
2014-03-25 01:25:32 +01:00
|
|
|
timeString = LocaleController.stringForMessageListDate(currentDialog.last_message_date);
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
|
|
|
drawCheck1 = false;
|
|
|
|
drawCheck2 = false;
|
|
|
|
drawClock = false;
|
|
|
|
drawCount = false;
|
|
|
|
drawError = false;
|
|
|
|
} else {
|
2014-08-22 16:24:33 +02:00
|
|
|
TLRPC.User fromUser = MessagesController.getInstance().getUser(message.messageOwner.from_id);
|
2014-02-04 19:36:55 +01:00
|
|
|
|
|
|
|
if (currentDialog.last_message_date != 0) {
|
2014-03-25 01:25:32 +01:00
|
|
|
timeString = LocaleController.stringForMessageListDate(currentDialog.last_message_date);
|
2014-02-04 19:36:55 +01:00
|
|
|
} else {
|
2014-03-25 01:25:32 +01:00
|
|
|
timeString = LocaleController.stringForMessageListDate(message.messageOwner.date);
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
|
|
|
if (printingString != null) {
|
|
|
|
lastPrintString = messageString = printingString;
|
|
|
|
currentMessagePaint = messagePrintingPaint;
|
|
|
|
} else {
|
|
|
|
lastPrintString = null;
|
|
|
|
if (message.messageOwner instanceof TLRPC.TL_messageService) {
|
|
|
|
messageString = message.messageText;
|
|
|
|
currentMessagePaint = messagePrintingPaint;
|
|
|
|
} else {
|
2014-07-27 00:28:33 +02:00
|
|
|
if (chat != null && chat.id > 0) {
|
2014-02-04 19:36:55 +01:00
|
|
|
String name = "";
|
2014-04-03 23:18:54 +02:00
|
|
|
if (message.isFromMe()) {
|
2014-03-22 23:31:55 +01:00
|
|
|
name = LocaleController.getString("FromYou", R.string.FromYou);
|
2014-02-04 19:36:55 +01:00
|
|
|
} else {
|
|
|
|
if (fromUser != null) {
|
|
|
|
if (fromUser.first_name.length() > 0) {
|
|
|
|
name = fromUser.first_name;
|
|
|
|
} else {
|
|
|
|
name = fromUser.last_name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-05-17 01:05:49 +02:00
|
|
|
checkMessage = false;
|
2014-02-04 19:36:55 +01:00
|
|
|
if (message.messageOwner.media != null && !(message.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
|
|
|
|
currentMessagePaint = messagePrintingPaint;
|
2014-07-03 00:39:05 +02:00
|
|
|
messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("<font color=#316f9f>%s:</font> <font color=#316f9f>%s</font>", name, message.messageText)), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
|
2014-02-04 19:36:55 +01:00
|
|
|
} else {
|
|
|
|
if (message.messageOwner.message != null) {
|
2014-07-03 00:39:05 +02:00
|
|
|
messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("<font color=#316f9f>%s:</font> <font color=#808080>%s</font>", name, message.messageOwner.message.replace("\n", " ").replace("<", "<").replace(">", ">"))), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
messageString = message.messageText;
|
|
|
|
if (message.messageOwner.media != null && !(message.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
|
|
|
|
currentMessagePaint = messagePrintingPaint;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (currentDialog.unread_count != 0) {
|
|
|
|
drawCount = true;
|
|
|
|
countString = String.format("%d", currentDialog.unread_count);
|
|
|
|
} else {
|
|
|
|
drawCount = false;
|
|
|
|
}
|
|
|
|
|
2014-07-27 00:28:33 +02:00
|
|
|
if (message.isFromMe() && message.isOut()) {
|
2014-09-28 15:37:26 +02:00
|
|
|
if (message.isSending()) {
|
2014-02-04 19:36:55 +01:00
|
|
|
drawCheck1 = false;
|
|
|
|
drawCheck2 = false;
|
|
|
|
drawClock = true;
|
|
|
|
drawError = false;
|
2014-09-28 15:37:26 +02:00
|
|
|
} else if (message.isSendError()) {
|
2014-02-04 19:36:55 +01:00
|
|
|
drawCheck1 = false;
|
|
|
|
drawCheck2 = false;
|
|
|
|
drawClock = false;
|
|
|
|
drawError = true;
|
|
|
|
drawCount = false;
|
2014-09-28 15:37:26 +02:00
|
|
|
} else if (message.isSent()) {
|
2014-09-14 01:40:36 +02:00
|
|
|
if (!message.isUnread()) {
|
2014-02-04 19:36:55 +01:00
|
|
|
drawCheck1 = true;
|
|
|
|
drawCheck2 = true;
|
|
|
|
} else {
|
|
|
|
drawCheck1 = false;
|
|
|
|
drawCheck2 = true;
|
|
|
|
}
|
|
|
|
drawClock = false;
|
|
|
|
drawError = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
drawCheck1 = false;
|
|
|
|
drawCheck2 = false;
|
|
|
|
drawClock = false;
|
|
|
|
drawError = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
timeWidth = (int)Math.ceil(timePaint.measureText(timeString));
|
|
|
|
timeLayout = new StaticLayout(timeString, timePaint, timeWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
2014-03-25 01:25:32 +01:00
|
|
|
if (!LocaleController.isRTL) {
|
2014-07-03 00:39:05 +02:00
|
|
|
timeLeft = width - AndroidUtilities.dp(11) - timeWidth;
|
2014-02-04 19:36:55 +01:00
|
|
|
} else {
|
2014-07-03 00:39:05 +02:00
|
|
|
timeLeft = AndroidUtilities.dp(11);
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (chat != null) {
|
|
|
|
nameString = chat.title;
|
|
|
|
} else if (user != null) {
|
2014-06-22 11:36:52 +02:00
|
|
|
if (user.id / 1000 != 777 && user.id / 1000 != 333 && ContactsController.getInstance().contactsDict.get(user.id) == null) {
|
2014-06-13 12:42:21 +02:00
|
|
|
if (ContactsController.getInstance().contactsDict.size() == 0 && (!ContactsController.getInstance().contactsLoaded || ContactsController.getInstance().isLoadingContacts())) {
|
2014-09-24 04:17:27 +02:00
|
|
|
nameString = ContactsController.formatName(user.first_name, user.last_name);
|
2014-02-04 19:36:55 +01:00
|
|
|
} else {
|
|
|
|
if (user.phone != null && user.phone.length() != 0) {
|
2014-03-22 23:31:55 +01:00
|
|
|
nameString = PhoneFormat.getInstance().format("+" + user.phone);
|
2014-02-04 19:36:55 +01:00
|
|
|
} else {
|
|
|
|
currentNamePaint = nameUnknownPaint;
|
2014-09-24 04:17:27 +02:00
|
|
|
nameString = ContactsController.formatName(user.first_name, user.last_name);
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2014-09-24 04:17:27 +02:00
|
|
|
nameString = ContactsController.formatName(user.first_name, user.last_name);
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
|
|
|
if (encryptedChat != null) {
|
|
|
|
currentNamePaint = nameEncryptedPaint;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (nameString.length() == 0) {
|
2014-03-22 23:31:55 +01:00
|
|
|
nameString = LocaleController.getString("HiddenName", R.string.HiddenName);
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
|
|
|
|
2014-03-25 01:25:32 +01:00
|
|
|
if (!LocaleController.isRTL) {
|
2014-07-03 00:39:05 +02:00
|
|
|
nameWidth = width - nameLeft - AndroidUtilities.dp(14) - timeWidth;
|
2014-02-04 19:36:55 +01:00
|
|
|
} else {
|
2014-07-03 00:39:05 +02:00
|
|
|
nameWidth = width - nameLeft - AndroidUtilities.dp(77) - timeWidth;
|
2014-02-04 19:36:55 +01:00
|
|
|
nameLeft += timeWidth;
|
|
|
|
}
|
|
|
|
if (drawNameLock) {
|
2014-07-03 00:39:05 +02:00
|
|
|
nameWidth -= AndroidUtilities.dp(4) + lockDrawable.getIntrinsicWidth();
|
2014-03-26 00:38:23 +01:00
|
|
|
} else if (drawNameGroup) {
|
2014-07-03 00:39:05 +02:00
|
|
|
nameWidth -= AndroidUtilities.dp(4) + groupDrawable.getIntrinsicWidth();
|
2014-07-27 00:28:33 +02:00
|
|
|
} else if (drawNameBroadcast) {
|
|
|
|
nameWidth -= AndroidUtilities.dp(4) + broadcastDrawable.getIntrinsicWidth();
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
|
|
|
if (drawClock) {
|
2014-07-03 00:39:05 +02:00
|
|
|
int w = clockDrawable.getIntrinsicWidth() + AndroidUtilities.dp(2);
|
2014-02-04 19:36:55 +01:00
|
|
|
nameWidth -= w;
|
2014-03-25 01:25:32 +01:00
|
|
|
if (!LocaleController.isRTL) {
|
2014-02-04 19:36:55 +01:00
|
|
|
checkDrawLeft = timeLeft - w;
|
|
|
|
} else {
|
2014-07-03 00:39:05 +02:00
|
|
|
checkDrawLeft = timeLeft + timeWidth + AndroidUtilities.dp(2);
|
2014-02-04 19:36:55 +01:00
|
|
|
nameLeft += w;
|
|
|
|
}
|
|
|
|
} else if (drawCheck2) {
|
2014-07-03 00:39:05 +02:00
|
|
|
int w = checkDrawable.getIntrinsicWidth() + AndroidUtilities.dp(2);
|
2014-02-04 19:36:55 +01:00
|
|
|
nameWidth -= w;
|
|
|
|
if (drawCheck1) {
|
2014-07-03 00:39:05 +02:00
|
|
|
nameWidth -= halfCheckDrawable.getIntrinsicWidth() - AndroidUtilities.dp(5);
|
2014-03-25 01:25:32 +01:00
|
|
|
if (!LocaleController.isRTL) {
|
2014-02-04 19:36:55 +01:00
|
|
|
halfCheckDrawLeft = timeLeft - w;
|
2014-07-03 00:39:05 +02:00
|
|
|
checkDrawLeft = halfCheckDrawLeft - AndroidUtilities.dp(5);
|
2014-02-04 19:36:55 +01:00
|
|
|
} else {
|
2014-07-03 00:39:05 +02:00
|
|
|
checkDrawLeft = timeLeft + timeWidth + AndroidUtilities.dp(2);
|
|
|
|
halfCheckDrawLeft = checkDrawLeft + AndroidUtilities.dp(5);
|
|
|
|
nameLeft += w + halfCheckDrawable.getIntrinsicWidth() - AndroidUtilities.dp(5);
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
|
|
|
} else {
|
2014-03-25 01:25:32 +01:00
|
|
|
if (!LocaleController.isRTL) {
|
2014-02-04 19:36:55 +01:00
|
|
|
checkDrawLeft = timeLeft - w;
|
|
|
|
} else {
|
2014-07-03 00:39:05 +02:00
|
|
|
checkDrawLeft = timeLeft + timeWidth + AndroidUtilities.dp(2);
|
2014-02-04 19:36:55 +01:00
|
|
|
nameLeft += w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-03 00:39:05 +02:00
|
|
|
CharSequence nameStringFinal = TextUtils.ellipsize(nameString.replace("\n", " "), currentNamePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
|
2014-09-14 01:40:36 +02:00
|
|
|
try {
|
|
|
|
nameLayout = new StaticLayout(nameStringFinal, currentNamePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
|
|
|
}
|
2014-02-04 19:36:55 +01:00
|
|
|
|
2014-07-03 00:39:05 +02:00
|
|
|
messageWidth = width - AndroidUtilities.dp(88);
|
2014-03-25 01:25:32 +01:00
|
|
|
if (!LocaleController.isRTL) {
|
2014-07-03 00:39:05 +02:00
|
|
|
messageLeft = AndroidUtilities.dp(77);
|
|
|
|
avatarLeft = AndroidUtilities.dp(11);
|
2014-02-04 19:36:55 +01:00
|
|
|
} else {
|
2014-07-03 00:39:05 +02:00
|
|
|
messageLeft = AndroidUtilities.dp(11);
|
|
|
|
avatarLeft = width - AndroidUtilities.dp(65);
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
2014-08-22 16:24:33 +02:00
|
|
|
avatarImage.setImageCoords(avatarLeft, avatarTop, AndroidUtilities.dp(54), AndroidUtilities.dp(54));
|
2014-02-04 19:36:55 +01:00
|
|
|
if (drawError) {
|
2014-07-03 00:39:05 +02:00
|
|
|
int w = errorDrawable.getIntrinsicWidth() + AndroidUtilities.dp(8);
|
2014-02-04 19:36:55 +01:00
|
|
|
messageWidth -= w;
|
2014-03-25 01:25:32 +01:00
|
|
|
if (!LocaleController.isRTL) {
|
2014-07-03 00:39:05 +02:00
|
|
|
errorLeft = width - errorDrawable.getIntrinsicWidth() - AndroidUtilities.dp(11);
|
2014-02-04 19:36:55 +01:00
|
|
|
} else {
|
2014-07-03 00:39:05 +02:00
|
|
|
errorLeft = AndroidUtilities.dp(11);
|
2014-02-04 19:36:55 +01:00
|
|
|
messageLeft += w;
|
|
|
|
}
|
|
|
|
} else if (countString != null) {
|
2014-07-03 00:39:05 +02:00
|
|
|
countWidth = Math.max(AndroidUtilities.dp(12), (int)Math.ceil(countPaint.measureText(countString)));
|
2014-02-04 19:36:55 +01:00
|
|
|
countLayout = new StaticLayout(countString, countPaint, countWidth, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
|
2014-07-03 00:39:05 +02:00
|
|
|
int w = countWidth + AndroidUtilities.dp(18);
|
2014-02-04 19:36:55 +01:00
|
|
|
messageWidth -= w;
|
2014-03-25 01:25:32 +01:00
|
|
|
if (!LocaleController.isRTL) {
|
2014-07-03 00:39:05 +02:00
|
|
|
countLeft = width - countWidth - AndroidUtilities.dp(16);
|
2014-02-04 19:36:55 +01:00
|
|
|
} else {
|
2014-07-03 00:39:05 +02:00
|
|
|
countLeft = AndroidUtilities.dp(16);
|
2014-02-04 19:36:55 +01:00
|
|
|
messageLeft += w;
|
|
|
|
}
|
|
|
|
drawCount = true;
|
|
|
|
} else {
|
|
|
|
drawCount = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (checkMessage) {
|
|
|
|
if (messageString == null) {
|
|
|
|
messageString = "";
|
|
|
|
}
|
|
|
|
String mess = messageString.toString().replace("\n", " ");
|
|
|
|
if (mess.length() > 150) {
|
|
|
|
mess = mess.substring(0, 150);
|
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
messageString = Emoji.replaceEmoji(mess, messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
|
|
|
|
2014-07-03 00:39:05 +02:00
|
|
|
CharSequence messageStringFinal = TextUtils.ellipsize(messageString, currentMessagePaint, messageWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
|
2014-02-04 19:36:55 +01:00
|
|
|
messageLayout = new StaticLayout(messageStringFinal, currentMessagePaint, messageWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
|
|
|
|
|
|
|
double widthpx = 0;
|
|
|
|
float left = 0;
|
2014-03-25 01:25:32 +01:00
|
|
|
if (LocaleController.isRTL) {
|
2014-09-14 01:40:36 +02:00
|
|
|
if (nameLayout != null && nameLayout.getLineCount() > 0) {
|
2014-02-04 19:36:55 +01:00
|
|
|
left = nameLayout.getLineLeft(0);
|
|
|
|
if (left == 0) {
|
|
|
|
widthpx = Math.ceil(nameLayout.getLineWidth(0));
|
|
|
|
if (widthpx < nameWidth) {
|
|
|
|
nameLeft += (nameWidth - widthpx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (messageLayout.getLineCount() > 0) {
|
|
|
|
left = messageLayout.getLineLeft(0);
|
|
|
|
if (left == 0) {
|
|
|
|
widthpx = Math.ceil(messageLayout.getLineWidth(0));
|
|
|
|
if (widthpx < messageWidth) {
|
|
|
|
messageLeft += (messageWidth - widthpx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2014-09-14 01:40:36 +02:00
|
|
|
if (nameLayout != null && nameLayout.getLineCount() > 0) {
|
2014-02-04 19:36:55 +01:00
|
|
|
left = nameLayout.getLineRight(0);
|
|
|
|
if (left == nameWidth) {
|
|
|
|
widthpx = Math.ceil(nameLayout.getLineWidth(0));
|
|
|
|
if (widthpx < nameWidth) {
|
|
|
|
nameLeft -= (nameWidth - widthpx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (messageLayout.getLineCount() > 0) {
|
|
|
|
left = messageLayout.getLineRight(0);
|
|
|
|
if (left == messageWidth) {
|
|
|
|
widthpx = Math.ceil(messageLayout.getLineWidth(0));
|
|
|
|
if (widthpx < messageWidth) {
|
|
|
|
messageLeft -= (messageWidth - widthpx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|