UI improvements

This commit is contained in:
DrKLO 2014-10-15 22:43:52 +04:00
parent 2f23635e4a
commit 288fceeb9f
15 changed files with 921 additions and 1073 deletions

View file

@ -12,8 +12,11 @@ import android.graphics.Bitmap;
import android.graphics.Paint; import android.graphics.Paint;
import android.text.Layout; import android.text.Layout;
import android.text.Spannable; import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.StaticLayout; import android.text.StaticLayout;
import android.text.TextPaint; import android.text.TextPaint;
import android.text.TextUtils;
import android.text.util.Linkify; import android.text.util.Linkify;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
@ -22,6 +25,7 @@ import org.telegram.messenger.FileLog;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.ui.Views.URLSpanNoUnderline;
import java.util.AbstractMap; import java.util.AbstractMap;
import java.util.ArrayList; import java.util.ArrayList;
@ -91,7 +95,7 @@ public class MessageObject {
messageText = LocaleController.getString("ActionYouCreateGroup", R.string.ActionYouCreateGroup); messageText = LocaleController.getString("ActionYouCreateGroup", R.string.ActionYouCreateGroup);
} else { } else {
if (fromUser != null) { if (fromUser != null) {
messageText = LocaleController.getString("ActionCreateGroup", R.string.ActionCreateGroup).replace("un1", ContactsController.formatName(fromUser.first_name, fromUser.last_name)); messageText = replaceWithLink(LocaleController.getString("ActionCreateGroup", R.string.ActionCreateGroup), "un1", fromUser);
} else { } else {
messageText = LocaleController.getString("ActionCreateGroup", R.string.ActionCreateGroup).replace("un1", ""); messageText = LocaleController.getString("ActionCreateGroup", R.string.ActionCreateGroup).replace("un1", "");
} }
@ -102,26 +106,27 @@ public class MessageObject {
messageText = LocaleController.getString("ActionYouLeftUser", R.string.ActionYouLeftUser); messageText = LocaleController.getString("ActionYouLeftUser", R.string.ActionYouLeftUser);
} else { } else {
if (fromUser != null) { if (fromUser != null) {
messageText = LocaleController.getString("ActionLeftUser", R.string.ActionLeftUser).replace("un1", ContactsController.formatName(fromUser.first_name, fromUser.last_name)); messageText = replaceWithLink(LocaleController.getString("ActionLeftUser", R.string.ActionLeftUser), "un1", fromUser);
} else { } else {
messageText = LocaleController.getString("ActionLeftUser", R.string.ActionLeftUser).replace("un1", ""); messageText = LocaleController.getString("ActionLeftUser", R.string.ActionLeftUser).replace("un1", "");
} }
} }
} else { } else {
TLRPC.User who = null; TLRPC.User whoUser = null;
if (users != null) { if (users != null) {
who = users.get(message.action.user_id); whoUser = users.get(message.action.user_id);
} }
if (who == null) { if (whoUser == null) {
who = MessagesController.getInstance().getUser(message.action.user_id); whoUser = MessagesController.getInstance().getUser(message.action.user_id);
} }
if (who != null && fromUser != null) { if (whoUser != null && fromUser != null) {
if (isFromMe()) { if (isFromMe()) {
messageText = LocaleController.getString("ActionYouKickUser", R.string.ActionYouKickUser).replace("un2", ContactsController.formatName(who.first_name, who.last_name)); messageText = replaceWithLink(LocaleController.getString("ActionYouKickUser", R.string.ActionYouKickUser), "un2", whoUser);
} else if (message.action.user_id == UserConfig.getClientUserId()) { } else if (message.action.user_id == UserConfig.getClientUserId()) {
messageText = LocaleController.getString("ActionKickUserYou", R.string.ActionKickUserYou).replace("un1", ContactsController.formatName(fromUser.first_name, fromUser.last_name)); messageText = replaceWithLink(LocaleController.getString("ActionKickUserYou", R.string.ActionKickUserYou), "un1", fromUser);
} else { } else {
messageText = LocaleController.getString("ActionKickUser", R.string.ActionKickUser).replace("un2", ContactsController.formatName(who.first_name, who.last_name)).replace("un1", ContactsController.formatName(fromUser.first_name, fromUser.last_name)); messageText = replaceWithLink(LocaleController.getString("ActionKickUser", R.string.ActionKickUser), "un2", whoUser);
messageText = replaceWithLink(messageText, "un1", fromUser);
} }
} else { } else {
messageText = LocaleController.getString("ActionKickUser", R.string.ActionKickUser).replace("un2", "").replace("un1", ""); messageText = LocaleController.getString("ActionKickUser", R.string.ActionKickUser).replace("un2", "").replace("un1", "");
@ -137,11 +142,12 @@ public class MessageObject {
} }
if (whoUser != null && fromUser != null) { if (whoUser != null && fromUser != null) {
if (isFromMe()) { if (isFromMe()) {
messageText = LocaleController.getString("ActionYouAddUser", R.string.ActionYouAddUser).replace("un2", ContactsController.formatName(whoUser.first_name, whoUser.last_name)); messageText = replaceWithLink(LocaleController.getString("ActionYouAddUser", R.string.ActionYouAddUser), "un2", whoUser);
} else if (message.action.user_id == UserConfig.getClientUserId()) { } else if (message.action.user_id == UserConfig.getClientUserId()) {
messageText = LocaleController.getString("ActionAddUserYou", R.string.ActionAddUserYou).replace("un1", ContactsController.formatName(fromUser.first_name, fromUser.last_name)); messageText = replaceWithLink(LocaleController.getString("ActionAddUserYou", R.string.ActionAddUserYou), "un1", fromUser);
} else { } else {
messageText = LocaleController.getString("ActionAddUser", R.string.ActionAddUser).replace("un2", ContactsController.formatName(whoUser.first_name, whoUser.last_name)).replace("un1", ContactsController.formatName(fromUser.first_name, fromUser.last_name)); messageText = replaceWithLink(LocaleController.getString("ActionAddUser", R.string.ActionAddUser), "un2", whoUser);
messageText = replaceWithLink(messageText, "un1", fromUser);
} }
} else { } else {
messageText = LocaleController.getString("ActionAddUser", R.string.ActionAddUser).replace("un2", "").replace("un1", ""); messageText = LocaleController.getString("ActionAddUser", R.string.ActionAddUser).replace("un2", "").replace("un1", "");
@ -151,7 +157,7 @@ public class MessageObject {
messageText = LocaleController.getString("ActionYouChangedPhoto", R.string.ActionYouChangedPhoto); messageText = LocaleController.getString("ActionYouChangedPhoto", R.string.ActionYouChangedPhoto);
} else { } else {
if (fromUser != null) { if (fromUser != null) {
messageText = LocaleController.getString("ActionChangedPhoto", R.string.ActionChangedPhoto).replace("un1", ContactsController.formatName(fromUser.first_name, fromUser.last_name)); messageText = replaceWithLink(LocaleController.getString("ActionChangedPhoto", R.string.ActionChangedPhoto), "un1", fromUser);
} else { } else {
messageText = LocaleController.getString("ActionChangedPhoto", R.string.ActionChangedPhoto).replace("un1", ""); messageText = LocaleController.getString("ActionChangedPhoto", R.string.ActionChangedPhoto).replace("un1", "");
} }
@ -161,7 +167,7 @@ public class MessageObject {
messageText = LocaleController.getString("ActionYouChangedTitle", R.string.ActionYouChangedTitle).replace("un2", message.action.title); messageText = LocaleController.getString("ActionYouChangedTitle", R.string.ActionYouChangedTitle).replace("un2", message.action.title);
} else { } else {
if (fromUser != null) { if (fromUser != null) {
messageText = LocaleController.getString("ActionChangedTitle", R.string.ActionChangedTitle).replace("un1", ContactsController.formatName(fromUser.first_name, fromUser.last_name)).replace("un2", message.action.title); messageText = replaceWithLink(LocaleController.getString("ActionChangedTitle", R.string.ActionChangedTitle).replace("un2", message.action.title), "un1", fromUser);
} else { } else {
messageText = LocaleController.getString("ActionChangedTitle", R.string.ActionChangedTitle).replace("un1", "").replace("un2", message.action.title); messageText = LocaleController.getString("ActionChangedTitle", R.string.ActionChangedTitle).replace("un1", "").replace("un2", message.action.title);
} }
@ -171,7 +177,7 @@ public class MessageObject {
messageText = LocaleController.getString("ActionYouRemovedPhoto", R.string.ActionYouRemovedPhoto); messageText = LocaleController.getString("ActionYouRemovedPhoto", R.string.ActionYouRemovedPhoto);
} else { } else {
if (fromUser != null) { if (fromUser != null) {
messageText = LocaleController.getString("ActionRemovedPhoto", R.string.ActionRemovedPhoto).replace("un1", ContactsController.formatName(fromUser.first_name, fromUser.last_name)); messageText = replaceWithLink(LocaleController.getString("ActionRemovedPhoto", R.string.ActionRemovedPhoto), "un1", fromUser);
} else { } else {
messageText = LocaleController.getString("ActionRemovedPhoto", R.string.ActionRemovedPhoto).replace("un1", ""); messageText = LocaleController.getString("ActionRemovedPhoto", R.string.ActionRemovedPhoto).replace("un1", "");
} }
@ -232,7 +238,7 @@ public class MessageObject {
messageText = LocaleController.formatString("ActionTakeScreenshootYou", R.string.ActionTakeScreenshootYou); messageText = LocaleController.formatString("ActionTakeScreenshootYou", R.string.ActionTakeScreenshootYou);
} else { } else {
if (fromUser != null) { if (fromUser != null) {
messageText = LocaleController.formatString("ActionTakeScreenshoot", R.string.ActionTakeScreenshoot).replace("un1", fromUser.first_name); messageText = replaceWithLink(LocaleController.getString("ActionTakeScreenshoot", R.string.ActionTakeScreenshoot), "un1", fromUser);
} else { } else {
messageText = LocaleController.formatString("ActionTakeScreenshoot", R.string.ActionTakeScreenshoot).replace("un1", ""); messageText = LocaleController.formatString("ActionTakeScreenshoot", R.string.ActionTakeScreenshoot).replace("un1", "");
} }
@ -263,7 +269,7 @@ public class MessageObject {
} }
messageText = Emoji.replaceEmoji(messageText, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20)); messageText = Emoji.replaceEmoji(messageText, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20));
if (message instanceof TLRPC.TL_message || (message instanceof TLRPC.TL_messageForwarded && (message.media == null || !(message.media instanceof TLRPC.TL_messageMediaEmpty)))) { if (message instanceof TLRPC.TL_message || message instanceof TLRPC.TL_messageForwarded) {
if (message.media == null || message.media instanceof TLRPC.TL_messageMediaEmpty) { if (message.media == null || message.media instanceof TLRPC.TL_messageMediaEmpty) {
contentType = type = 0; contentType = type = 0;
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaPhoto) { } else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaPhoto) {
@ -275,13 +281,8 @@ public class MessageObject {
contentType = 1; contentType = 1;
type = 3; type = 3;
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaContact) { } else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaContact) {
if (isFromMe()) {
contentType = 3; contentType = 3;
type = 12; type = 12;
} else {
contentType = 4;
type = 13;
}
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaUnsupported) { } else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaUnsupported) {
contentType = type = 0; contentType = type = 0;
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaDocument) { } else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaDocument) {
@ -298,14 +299,12 @@ public class MessageObject {
if (message.action instanceof TLRPC.TL_messageActionLoginUnknownLocation) { if (message.action instanceof TLRPC.TL_messageActionLoginUnknownLocation) {
contentType = type = 0; contentType = type = 0;
} else if (message.action instanceof TLRPC.TL_messageActionChatEditPhoto || message.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) { } else if (message.action instanceof TLRPC.TL_messageActionChatEditPhoto || message.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) {
contentType = 8; contentType = 4;
type = 11; type = 11;
} else { } else {
contentType = 7; contentType = 4;
type = 10; type = 10;
} }
} else if (message instanceof TLRPC.TL_messageForwarded) {
contentType = type = 0;
} }
Calendar rightNow = new GregorianCalendar(); Calendar rightNow = new GregorianCalendar();
@ -319,6 +318,15 @@ public class MessageObject {
generateThumbs(false, preview); generateThumbs(false, preview);
} }
public CharSequence replaceWithLink(CharSequence source, String param, TLRPC.User user) {
String name = ContactsController.formatName(user.first_name, user.last_name);
int start = TextUtils.indexOf(source, param);
URLSpanNoUnderline span = new URLSpanNoUnderline("" + user.id);
SpannableStringBuilder builder = new SpannableStringBuilder(TextUtils.replace(source, new String[]{param}, new String[]{name}));
builder.setSpan(span, start, start + name.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
return builder;
}
public void generateThumbs(boolean update, int preview) { public void generateThumbs(boolean update, int preview) {
if (messageOwner instanceof TLRPC.TL_messageService) { if (messageOwner instanceof TLRPC.TL_messageService) {
if (messageOwner.action instanceof TLRPC.TL_messageActionChatEditPhoto) { if (messageOwner.action instanceof TLRPC.TL_messageActionChatEditPhoto) {

View file

@ -564,6 +564,17 @@ public class FileLoader {
if (message == null) { if (message == null) {
return new File(""); return new File("");
} }
if (message instanceof TLRPC.TL_messageService) {
if (message.action.photo != null) {
ArrayList<TLRPC.PhotoSize> sizes = message.action.photo.sizes;
if (sizes.size() > 0) {
TLRPC.PhotoSize sizeFull = getClosestPhotoSizeWithSize(sizes, AndroidUtilities.getPhotoSize());
if (sizeFull != null) {
return getPathToAttach(sizeFull);
}
}
}
} else {
if (message.media instanceof TLRPC.TL_messageMediaVideo) { if (message.media instanceof TLRPC.TL_messageMediaVideo) {
return getPathToAttach(message.media.video); return getPathToAttach(message.media.video);
} else if (message.media instanceof TLRPC.TL_messageMediaDocument) { } else if (message.media instanceof TLRPC.TL_messageMediaDocument) {
@ -579,6 +590,7 @@ public class FileLoader {
} }
} }
} }
}
return new File(""); return new File("");
} }

View file

@ -10,10 +10,43 @@ package org.telegram.ui.Cells;
import android.content.Context; import android.content.Context;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.view.HapticFeedbackConstants;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewConfiguration;
public class BaseCell extends View { public class BaseCell extends View {
private final class CheckForTap implements Runnable {
public void run() {
if (pendingCheckForLongPress == null) {
pendingCheckForLongPress = new CheckForLongPress();
}
pendingCheckForLongPress.currentPressCount = ++pressCount;
postDelayed(pendingCheckForLongPress, ViewConfiguration.getLongPressTimeout() - ViewConfiguration.getTapTimeout());
}
}
class CheckForLongPress implements Runnable {
public int currentPressCount;
public void run() {
if (checkingForLongPress && getParent() != null && currentPressCount == pressCount) {
checkingForLongPress = false;
MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_CANCEL, 0, 0, 0);
onTouchEvent(event);
event.recycle();
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
onLongPress();
}
}
}
private boolean checkingForLongPress = false;
private CheckForLongPress pendingCheckForLongPress = null;
private int pressCount = 0;
private CheckForTap pendingCheckForTap = null;
public BaseCell(Context context) { public BaseCell(Context context) {
super(context); super(context);
} }
@ -25,4 +58,29 @@ public class BaseCell extends View {
protected void setDrawableBounds(Drawable drawable, int x, int y, int w, int h) { protected void setDrawableBounds(Drawable drawable, int x, int y, int w, int h) {
drawable.setBounds(x, y, x + w, y + h); drawable.setBounds(x, y, x + w, y + h);
} }
protected void startCheckLongPress() {
if (checkingForLongPress) {
return;
}
checkingForLongPress = true;
if (pendingCheckForTap == null) {
pendingCheckForTap = new CheckForTap();
}
postDelayed(pendingCheckForTap, ViewConfiguration.getTapTimeout());
}
protected void cancelCheckLongPress() {
checkingForLongPress = false;
if (pendingCheckForLongPress != null) {
removeCallbacks(pendingCheckForLongPress);
}
if (pendingCheckForTap != null) {
removeCallbacks(pendingCheckForTap);
}
}
protected void onLongPress() {
}
} }

View file

@ -9,36 +9,58 @@
package org.telegram.ui.Cells; package org.telegram.ui.Cells;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.text.Layout; import android.text.Layout;
import android.text.Spannable;
import android.text.StaticLayout; import android.text.StaticLayout;
import android.text.TextPaint; import android.text.TextPaint;
import android.text.style.URLSpan;
import android.view.MotionEvent;
import android.view.SoundEffectConstants;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.ImageReceiver;
import org.telegram.android.MessageObject; import org.telegram.android.MessageObject;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.android.PhotoObject;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig;
import org.telegram.ui.PhotoViewer;
public class ChatActionCell extends BaseCell { public class ChatActionCell extends BaseCell {
public static interface ChatActionCellDelegate {
public abstract void didClickedImage(ChatActionCell cell);
public abstract void didLongPressed(ChatActionCell cell);
public abstract void needOpenUserProfile(int uid);
}
private static Drawable backgroundBlack; private static Drawable backgroundBlack;
private static Drawable backgroundBlue; private static Drawable backgroundBlue;
private static TextPaint textPaint; private static TextPaint textPaint;
private URLSpan pressedLink;
private ImageReceiver imageReceiver;
private StaticLayout textLayout; private StaticLayout textLayout;
private int textWidth = 0; private int textWidth = 0;
private int textHeight = 0; private int textHeight = 0;
private int textX = 0; private int textX = 0;
private int textXLeft = 0;
private int textY = 0; private int textY = 0;
private int textXLeft = 0;
private boolean useBlackBackground = false; private boolean useBlackBackground = false;
private boolean wasLayout = false; private int previousWidth = 0;
private boolean imagePressed = false;
private MessageObject currentMessageObject; private MessageObject currentMessageObject;
private ChatActionCellDelegate delegate;
public ChatActionCell(Context context) { public ChatActionCell(Context context) {
super(context); super(context);
if (backgroundBlack == null) { if (backgroundBlack == null) {
@ -47,49 +69,52 @@ public class ChatActionCell extends BaseCell {
textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
textPaint.setColor(0xffffffff); textPaint.setColor(0xffffffff);
textPaint.linkColor = 0xffffffff;
} }
imageReceiver = new ImageReceiver(this);
textPaint.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize)); textPaint.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize));
} }
public void setDelegate(ChatActionCellDelegate delegate) {
this.delegate = delegate;
}
public void setMessageObject(MessageObject messageObject) { public void setMessageObject(MessageObject messageObject) {
if (currentMessageObject == messageObject) { if (currentMessageObject == messageObject) {
return; return;
} }
currentMessageObject = messageObject; currentMessageObject = messageObject;
int size; previousWidth = 0;
if (AndroidUtilities.isTablet()) { if (currentMessageObject.type == 11) {
size = AndroidUtilities.getMinTabletSide(); int id = 0;
if (messageObject.messageOwner.to_id != null) {
if (messageObject.messageOwner.to_id.chat_id != 0) {
id = messageObject.messageOwner.to_id.chat_id;
} else { } else {
size = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y); id = messageObject.messageOwner.to_id.user_id;
if (id == UserConfig.getClientUserId()) {
id = messageObject.messageOwner.from_id;
} }
textLayout = new StaticLayout(currentMessageObject.messageText, textPaint, size - AndroidUtilities.dp(30), Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
textHeight = 0;
textWidth = 0;
try {
int linesCount = textLayout.getLineCount();
boolean hasNonRTL = false;
for (int a = 0; a < linesCount; a++) {
float lineWidth = 0;
float lineLeft = 0;
try {
lineWidth = textLayout.getLineWidth(a);
lineLeft = textLayout.getLineLeft(a);
textHeight = (int)Math.max(textHeight, Math.ceil(textLayout.getLineBottom(a)));
} catch (Exception e) {
FileLog.e("tmessages", e);
return;
} }
if (lineLeft == 0) {
hasNonRTL = true;
} }
textWidth = (int)Math.max(textWidth, Math.ceil(lineWidth)); if (currentMessageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) {
imageReceiver.setImage(currentMessageObject.messageOwner.action.newUserPhoto.photo_small, "50_50", getResources().getDrawable(AndroidUtilities.getUserAvatarForId(id)), false);
} else {
PhotoObject photo = PhotoObject.getClosestImageWithSize(currentMessageObject.photoThumbs, AndroidUtilities.dp(64));
if (photo != null) {
if (photo.image != null) {
imageReceiver.setImageBitmap(photo.image);
} else {
imageReceiver.setImage(photo.photoOwner.location, "50_50", getResources().getDrawable(AndroidUtilities.getGroupAvatarForId(id)), false);
} }
} catch (Exception e) { } else {
FileLog.e("tmessages", e); imageReceiver.setImageBitmap(getResources().getDrawable(AndroidUtilities.getGroupAvatarForId(id)));
}
}
imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(currentMessageObject), false);
} else {
imageReceiver.setImageBitmap((Bitmap)null);
} }
textY = AndroidUtilities.dp(7);
wasLayout = false;
requestLayout(); requestLayout();
} }
@ -97,23 +122,141 @@ public class ChatActionCell extends BaseCell {
useBlackBackground = value; useBlackBackground = value;
} }
public MessageObject getMessageObject() {
return currentMessageObject;
}
public ImageReceiver getPhotoImage() {
return imageReceiver;
}
@Override
protected void onLongPress() {
if (delegate != null) {
delegate.didLongPressed(this);
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
float x = event.getX();
float y = event.getY();
boolean result = false;
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if (delegate != null) {
if (currentMessageObject.type == 11 && imageReceiver.isInsideImage(x, y)) {
imagePressed = true;
result = true;
}
if (result) {
startCheckLongPress();
}
}
} else {
if (event.getAction() != MotionEvent.ACTION_MOVE) {
cancelCheckLongPress();
}
if (imagePressed) {
if (event.getAction() == MotionEvent.ACTION_UP) {
imagePressed = false;
if (delegate != null) {
delegate.didClickedImage(this);
playSoundEffect(SoundEffectConstants.CLICK);
}
} else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
imagePressed = false;
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
if (!imageReceiver.isInsideImage(x, y)) {
imagePressed = false;
}
}
}
}
if (!result) {
if (event.getAction() == MotionEvent.ACTION_DOWN || pressedLink != null && event.getAction() == MotionEvent.ACTION_UP) {
if (x >= textX && y >= textY && x <= textX + textWidth && y <= textY + textHeight) {
y -= textY;
x -= textXLeft;
final int line = textLayout.getLineForVertical((int)y);
final int off = textLayout.getOffsetForHorizontal(line, x);
final float left = textLayout.getLineLeft(line);
if (left <= x && left + textLayout.getLineWidth(line) >= x) {
Spannable buffer = (Spannable)currentMessageObject.messageText;
URLSpan[] link = buffer.getSpans(off, off, URLSpan.class);
if (link.length != 0) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
pressedLink = link[0];
result = true;
} else {
if (link[0] == pressedLink) {
if (delegate != null) {
delegate.needOpenUserProfile(Integer.parseInt(link[0].getURL()));
}
result = true;
}
}
} else {
pressedLink = null;
}
} else {
pressedLink = null;
}
} else {
pressedLink = null;
}
}
}
if (!result) {
result = super.onTouchEvent(event);
}
return result;
}
@Override @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), textHeight + AndroidUtilities.dp(14));
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
if (currentMessageObject == null) { if (currentMessageObject == null) {
super.onLayout(changed, left, top, right, bottom); setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), textHeight + AndroidUtilities.dp(14));
return; return;
} }
if (!wasLayout || changed) { int width = MeasureSpec.getSize(widthMeasureSpec);
textX = (right - left - textWidth) / 2; if (width != previousWidth) {
textXLeft = (right - left - textLayout.getWidth()) / 2; previousWidth = width;
wasLayout = true; textLayout = new StaticLayout(currentMessageObject.messageText, textPaint, width - AndroidUtilities.dp(30), Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
textHeight = 0;
textWidth = 0;
try {
int linesCount = textLayout.getLineCount();
for (int a = 0; a < linesCount; a++) {
float lineWidth = 0;
float lineLeft = 0;
try {
lineWidth = textLayout.getLineWidth(a);
textHeight = (int)Math.max(textHeight, Math.ceil(textLayout.getLineBottom(a)));
} catch (Exception e) {
FileLog.e("tmessages", e);
return;
} }
textWidth = (int)Math.max(textWidth, Math.ceil(lineWidth));
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
textX = (width - textWidth) / 2;
textY = AndroidUtilities.dp(7);
textXLeft = (width - textLayout.getWidth()) / 2;
if (currentMessageObject.type == 11) {
imageReceiver.setImageCoords((width - AndroidUtilities.dp(64)) / 2, textHeight + AndroidUtilities.dp(15), AndroidUtilities.dp(64), AndroidUtilities.dp(64));
}
}
setMeasuredDimension(width, textHeight + AndroidUtilities.dp(14 + (currentMessageObject.type == 11 ? 70 : 0)));
} }
@Override @Override
@ -121,10 +264,6 @@ public class ChatActionCell extends BaseCell {
if (currentMessageObject == null) { if (currentMessageObject == null) {
return; return;
} }
if (!wasLayout) {
requestLayout();
return;
}
Drawable backgroundDrawable = null; Drawable backgroundDrawable = null;
if (useBlackBackground) { if (useBlackBackground) {
@ -132,9 +271,13 @@ public class ChatActionCell extends BaseCell {
} else { } else {
backgroundDrawable = backgroundBlue; backgroundDrawable = backgroundBlue;
} }
backgroundDrawable.setBounds(textX - AndroidUtilities.dp(5), AndroidUtilities.dp(5), textX + textWidth + AndroidUtilities.dp(5), getMeasuredHeight() - AndroidUtilities.dp(5)); backgroundDrawable.setBounds(textX - AndroidUtilities.dp(5), AndroidUtilities.dp(5), textX + textWidth + AndroidUtilities.dp(5), AndroidUtilities.dp(9) + textHeight);
backgroundDrawable.draw(canvas); backgroundDrawable.draw(canvas);
if (currentMessageObject.type == 11) {
imageReceiver.draw(canvas, imageReceiver.getImageX(), imageReceiver.getImageY(), imageReceiver.getImageWidth(), imageReceiver.getImageHeight());
}
canvas.save(); canvas.save();
canvas.translate(textXLeft, textY); canvas.translate(textXLeft, textY);
textLayout.draw(canvas); textLayout.draw(canvas);

View file

@ -17,10 +17,8 @@ import android.text.Layout;
import android.text.StaticLayout; import android.text.StaticLayout;
import android.text.TextPaint; import android.text.TextPaint;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.HapticFeedbackConstants;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.SoundEffectConstants; import android.view.SoundEffectConstants;
import android.view.ViewConfiguration;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController; import org.telegram.android.ContactsController;
@ -108,45 +106,13 @@ public class ChatBaseCell extends BaseCell {
private TLRPC.User currentForwardUser; private TLRPC.User currentForwardUser;
private String currentForwardNameString; private String currentForwardNameString;
public ChatBaseCellDelegate delegate; protected ChatBaseCellDelegate delegate;
protected int namesOffset = 0; protected int namesOffset = 0;
private boolean checkingForLongPress = false;
private int pressCount = 0;
private CheckForLongPress pendingCheckForLongPress = null;
private CheckForTap pendingCheckForTap = null;
private int last_send_state = 0; private int last_send_state = 0;
private int last_delete_date = 0; private int last_delete_date = 0;
private final class CheckForTap implements Runnable {
public void run() {
if (pendingCheckForLongPress == null) {
pendingCheckForLongPress = new CheckForLongPress();
}
pendingCheckForLongPress.currentPressCount = ++pressCount;
postDelayed(pendingCheckForLongPress, ViewConfiguration.getLongPressTimeout() - ViewConfiguration.getTapTimeout());
}
}
class CheckForLongPress implements Runnable {
public int currentPressCount;
public void run() {
if (checkingForLongPress && getParent() != null && currentPressCount == pressCount) {
if (delegate != null) {
checkingForLongPress = false;
MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_CANCEL, 0, 0, 0);
onTouchEvent(event);
event.recycle();
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
delegate.didLongPressed(ChatBaseCell.this);
}
}
}
}
public ChatBaseCell(Context context) { public ChatBaseCell(Context context) {
super(context); super(context);
if (backgroundDrawableIn == null) { if (backgroundDrawableIn == null) {
@ -203,6 +169,10 @@ public class ChatBaseCell extends BaseCell {
invalidate(); invalidate();
} }
public void setDelegate(ChatBaseCellDelegate delegate) {
this.delegate = delegate;
}
public void setCheckPressed(boolean value, boolean pressed) { public void setCheckPressed(boolean value, boolean pressed) {
isCheckPressed = value; isCheckPressed = value;
isPressed = pressed; isPressed = pressed;
@ -345,27 +315,6 @@ public class ChatBaseCell extends BaseCell {
return backgroundWidth - AndroidUtilities.dp(8); return backgroundWidth - AndroidUtilities.dp(8);
} }
protected void startCheckLongPress() {
if (checkingForLongPress) {
return;
}
checkingForLongPress = true;
if (pendingCheckForTap == null) {
pendingCheckForTap = new CheckForTap();
}
postDelayed(pendingCheckForTap, ViewConfiguration.getTapTimeout());
}
protected void cancelCheckLongPress() {
checkingForLongPress = false;
if (pendingCheckForLongPress != null) {
removeCallbacks(pendingCheckForLongPress);
}
if (pendingCheckForTap != null) {
removeCallbacks(pendingCheckForTap);
}
}
@Override @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) {
boolean result = false; boolean result = false;
@ -462,6 +411,13 @@ public class ChatBaseCell extends BaseCell {
} }
@Override
protected void onLongPress() {
if (delegate != null) {
delegate.didLongPressed(this);
}
}
@Override @Override
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {
if (currentMessageObject == null) { if (currentMessageObject == null) {

View file

@ -0,0 +1,271 @@
/*
* This is the source code of Telegram for Android v. 1.7.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-2014.
*/
package org.telegram.ui.Cells;
import android.content.Context;
public class ChatContactCell extends ChatBaseCell {
public ChatContactCell(Context context) {
super(context);
}
/*
public class ChatListRowHolderEx {
public BackupImageView avatarImageView;
public TextView nameTextView;
public TextView messageTextView;
public TextView timeTextView;
public ImageView halfCheckImage;
public ImageView checkImage;
public MessageObject message;
public TextView phoneTextView;
public BackupImageView contactAvatar;
public View contactView;
public ImageView addContactButton;
public View addContactView;
public View chatBubbleView;
public void update() {
TLRPC.User fromUser = MessagesController.getInstance().getUser(message.messageOwner.from_id);
int type = message.type;
if (timeTextView != null) {
timeTextView.setText(LocaleController.formatterDay.format((long) (message.messageOwner.date) * 1000));
}
if (avatarImageView != null && fromUser != null) {
TLRPC.FileLocation photo = null;
if (fromUser.photo != null) {
photo = fromUser.photo.photo_small;
}
int placeHolderId = AndroidUtilities.getUserAvatarForId(fromUser.id);
avatarImageView.setImage(photo, "50_50", placeHolderId);
}
if (type != 12 && type != 13 && nameTextView != null && fromUser != null && type != 8 && type != 9) {
nameTextView.setText(ContactsController.formatName(fromUser.first_name, fromUser.last_name));
nameTextView.setTextColor(AndroidUtilities.getColorForId(message.messageOwner.from_id));
}
if (type == 12 || type == 13) {
TLRPC.User contactUser = MessagesController.getInstance().getUser(message.messageOwner.media.user_id);
if (contactUser != null) {
nameTextView.setText(ContactsController.formatName(message.messageOwner.media.first_name, message.messageOwner.media.last_name));
nameTextView.setTextColor(AndroidUtilities.getColorForId(contactUser.id));
String phone = message.messageOwner.media.phone_number;
if (phone != null && phone.length() != 0) {
if (!phone.startsWith("+")) {
phone = "+" + phone;
}
phoneTextView.setText(PhoneFormat.getInstance().format(phone));
} else {
phoneTextView.setText("Unknown");
}
TLRPC.FileLocation photo = null;
if (contactUser.photo != null) {
photo = contactUser.photo.photo_small;
}
int placeHolderId = AndroidUtilities.getUserAvatarForId(contactUser.id);
contactAvatar.setImage(photo, "50_50", placeHolderId);
if (contactUser.id != UserConfig.getClientUserId() && ContactsController.getInstance().contactsDict.get(contactUser.id) == null) {
addContactView.setVisibility(View.VISIBLE);
} else {
addContactView.setVisibility(View.GONE);
}
} else {
nameTextView.setText(ContactsController.formatName(message.messageOwner.media.first_name, message.messageOwner.media.last_name));
nameTextView.setTextColor(AndroidUtilities.getColorForId(message.messageOwner.media.user_id));
String phone = message.messageOwner.media.phone_number;
if (phone != null && phone.length() != 0) {
if (message.messageOwner.media.user_id != 0 && !phone.startsWith("+")) {
phone = "+" + phone;
}
phoneTextView.setText(PhoneFormat.getInstance().format(phone));
} else {
phoneTextView.setText("Unknown");
}
contactAvatar.setImageResource(AndroidUtilities.getUserAvatarForId(message.messageOwner.media.user_id));
addContactView.setVisibility(View.GONE);
}
} else if (type == 6) {
messageTextView.setTextSize(16);
messageTextView.setText(LocaleController.formatPluralString("NewMessages", unread_to_load));
}
if (message.isFromMe()) {
if (halfCheckImage != null) {
if (message.isSending()) {
checkImage.setVisibility(View.INVISIBLE);
halfCheckImage.setImageResource(R.drawable.msg_clock);
halfCheckImage.setVisibility(View.VISIBLE);
} else if (message.isSendError()) {
halfCheckImage.setVisibility(View.VISIBLE);
halfCheckImage.setImageResource(R.drawable.msg_warning);
if (checkImage != null) {
checkImage.setVisibility(View.INVISIBLE);
}
} else if (message.isSent()) {
if (!message.isUnread()) {
halfCheckImage.setVisibility(View.VISIBLE);
checkImage.setVisibility(View.VISIBLE);
halfCheckImage.setImageResource(R.drawable.msg_halfcheck);
} else {
halfCheckImage.setVisibility(View.VISIBLE);
checkImage.setVisibility(View.INVISIBLE);
halfCheckImage.setImageResource(R.drawable.msg_check);
}
}
}
}
}
public ChatListRowHolderEx(View view, int type) {
avatarImageView = (BackupImageView)view.findViewById(R.id.chat_group_avatar_image);
nameTextView = (TextView)view.findViewById(R.id.chat_user_group_name);
timeTextView = (TextView)view.findViewById(R.id.chat_time_text);
halfCheckImage = (ImageView)view.findViewById(R.id.chat_row_halfcheck);
checkImage = (ImageView)view.findViewById(R.id.chat_row_check);
messageTextView = (TextView)view.findViewById(R.id.chat_message_text);
phoneTextView = (TextView)view.findViewById(R.id.phone_text_view);
contactAvatar = (BackupImageView)view.findViewById(R.id.contact_avatar);
contactView = view.findViewById(R.id.shared_layout);
addContactButton = (ImageView)view.findViewById(R.id.add_contact_button);
addContactView = view.findViewById(R.id.add_contact_view);
chatBubbleView = view.findViewById(R.id.chat_bubble_layout);
if (messageTextView != null) {
messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, MessagesController.getInstance().fontSize);
}
if (addContactButton != null) {
addContactButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (actionBarLayer.isActionModeShowed()) {
processRowSelect(view);
return;
}
Bundle args = new Bundle();
args.putInt("user_id", message.messageOwner.media.user_id);
args.putString("phone", message.messageOwner.media.phone_number);
presentFragment(new ContactAddActivity(args));
}
});
addContactButton.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
createMenu(v, false);
return true;
}
});
}
if (contactView != null) {
contactView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (message.type == 12 || message.type == 13) {
if (actionBarLayer.isActionModeShowed()) {
processRowSelect(view);
return;
}
if (message.messageOwner.media.user_id != UserConfig.getClientUserId()) {
TLRPC.User user = null;
if (message.messageOwner.media.user_id != 0) {
user = MessagesController.getInstance().getUser(message.messageOwner.media.user_id);
}
if (user != null) {
Bundle args = new Bundle();
args.putInt("user_id", message.messageOwner.media.user_id);
presentFragment(new UserProfileActivity(args));
} else {
if (message.messageOwner.media.phone_number == null || message.messageOwner.media.phone_number.length() == 0) {
return;
}
if (getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setItems(new CharSequence[] {LocaleController.getString("Copy", R.string.Copy), LocaleController.getString("Call", R.string.Call)}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (i == 1) {
try {
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + message.messageOwner.media.phone_number));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getParentActivity().startActivity(intent);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
} else if (i == 0) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(message.messageOwner.media.phone_number);
} else {
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
android.content.ClipData clip = android.content.ClipData.newPlainText("label", message.messageOwner.media.phone_number);
clipboard.setPrimaryClip(clip);
}
}
}
}
);
showAlertDialog(builder);
}
}
}
}
});
contactView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
createMenu(v, false);
return true;
}
});
}
if (contactAvatar != null) {
contactAvatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
}
if (avatarImageView != null) {
avatarImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (actionBarLayer.isActionModeShowed()) {
processRowSelect(view);
return;
}
if (message != null) {
Bundle args = new Bundle();
args.putInt("user_id", message.messageOwner.from_id);
presentFragment(new UserProfileActivity(args));
}
}
});
}
}
private void processOnClick(View view) {
if (actionBarLayer.isActionModeShowed()) {
processRowSelect(view);
}
}
}
*/
}

View file

@ -93,7 +93,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
private int nameWidth = 0; private int nameWidth = 0;
private String currentNameString; private String currentNameString;
public ChatMediaCellDelegate mediaDelegate = null; private ChatMediaCellDelegate mediaDelegate = null;
private float currentProgress = 0; private float currentProgress = 0;
private RectF progressRect = new RectF(); private RectF progressRect = new RectF();
@ -165,6 +165,10 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
} }
} }
public void setMediaDelegate(ChatMediaCellDelegate delegate) {
this.mediaDelegate = delegate;
}
@Override @Override
protected void onDetachedFromWindow() { protected void onDetachedFromWindow() {
super.onDetachedFromWindow(); super.onDetachedFromWindow();

View file

@ -33,13 +33,11 @@ import android.provider.MediaStore;
import android.text.Html; import android.text.Html;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.SparseArray; import android.util.SparseArray;
import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import android.webkit.MimeTypeMap; import android.webkit.MimeTypeMap;
import android.widget.AbsListView; import android.widget.AbsListView;
@ -64,7 +62,6 @@ import org.telegram.messenger.TLRPC;
import org.telegram.android.ContactsController; import org.telegram.android.ContactsController;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.android.MessageObject; import org.telegram.android.MessageObject;
import org.telegram.android.PhotoObject;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter; import org.telegram.android.NotificationCenter;
@ -75,9 +72,11 @@ import org.telegram.ui.Adapters.BaseFragmentAdapter;
import org.telegram.ui.Cells.ChatActionCell; import org.telegram.ui.Cells.ChatActionCell;
import org.telegram.ui.Cells.ChatAudioCell; import org.telegram.ui.Cells.ChatAudioCell;
import org.telegram.ui.Cells.ChatBaseCell; import org.telegram.ui.Cells.ChatBaseCell;
import org.telegram.ui.Cells.ChatContactCell;
import org.telegram.ui.Cells.ChatMediaCell; import org.telegram.ui.Cells.ChatMediaCell;
import org.telegram.ui.Cells.ChatMessageCell; import org.telegram.ui.Cells.ChatMessageCell;
import org.telegram.ui.Views.ActionBar.ActionBarLayer; import org.telegram.ui.Views.ActionBar.ActionBarLayer;
import org.telegram.ui.Views.ActionBar.ActionBarLayout;
import org.telegram.ui.Views.ActionBar.ActionBarMenu; import org.telegram.ui.Views.ActionBar.ActionBarMenu;
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem; import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
import org.telegram.ui.Views.BackupImageView; import org.telegram.ui.Views.BackupImageView;
@ -85,7 +84,6 @@ import org.telegram.ui.Views.ActionBar.BaseFragment;
import org.telegram.ui.Views.ChatActivityEnterView; import org.telegram.ui.Views.ChatActivityEnterView;
import org.telegram.android.ImageReceiver; import org.telegram.android.ImageReceiver;
import org.telegram.ui.Views.LayoutListView; import org.telegram.ui.Views.LayoutListView;
import org.telegram.ui.Views.MessageActionLayout;
import org.telegram.ui.Views.SizeNotifierRelativeLayout; import org.telegram.ui.Views.SizeNotifierRelativeLayout;
import org.telegram.ui.Views.TimerButton; import org.telegram.ui.Views.TimerButton;
import org.telegram.ui.Views.TypingDotsDrawable; import org.telegram.ui.Views.TypingDotsDrawable;
@ -97,8 +95,7 @@ import java.util.HashMap;
import java.util.concurrent.Semaphore; import java.util.concurrent.Semaphore;
public class ChatActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, MessagesActivity.MessagesActivityDelegate, public class ChatActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, MessagesActivity.MessagesActivityDelegate,
DocumentSelectActivity.DocumentSelectActivityDelegate, PhotoViewer.PhotoViewerProvider, PhotoPickerActivity.PhotoPickerActivityDelegate, PhotoViewer.PhotoViewerProvider {
VideoEditorActivity.VideoEditorActivityDelegate, LocationActivity.LocationActivityDelegate {
private TLRPC.Chat currentChat; private TLRPC.Chat currentChat;
private TLRPC.User currentUser; private TLRPC.User currentUser;
@ -470,7 +467,23 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
} else if (id == attach_gallery) { } else if (id == attach_gallery) {
PhotoPickerActivity fragment = new PhotoPickerActivity(); PhotoPickerActivity fragment = new PhotoPickerActivity();
fragment.setDelegate(ChatActivity.this); fragment.setDelegate(new PhotoPickerActivity.PhotoPickerActivityDelegate() {
@Override
public void didSelectPhotos(ArrayList<String> photos) {
processSendingPhotos(photos, null);
}
@Override
public void startPhotoSelectActivity() {
try {
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
});
presentFragment(fragment); presentFragment(fragment);
} else if (id == attach_video) { } else if (id == attach_video) {
try { try {
@ -499,11 +512,39 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return; return;
} }
LocationActivity fragment = new LocationActivity(); LocationActivity fragment = new LocationActivity();
fragment.setDelegate(ChatActivity.this); fragment.setDelegate(new LocationActivity.LocationActivityDelegate() {
@Override
public void didSelectLocation(double latitude, double longitude) {
SendMessagesHelper.getInstance().sendMessage(latitude, longitude, dialog_id);
if (chatListView != null) {
chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop());
}
if (paused) {
scrollToTopOnResume = true;
}
}
});
presentFragment(fragment); presentFragment(fragment);
} else if (id == attach_document) { } else if (id == attach_document) {
DocumentSelectActivity fragment = new DocumentSelectActivity(); DocumentSelectActivity fragment = new DocumentSelectActivity();
fragment.setDelegate(ChatActivity.this); fragment.setDelegate(new DocumentSelectActivity.DocumentSelectActivityDelegate() {
@Override
public void didSelectFile(DocumentSelectActivity activity, String path) {
activity.finishFragment();
processSendingDocument(path, path);
}
@Override
public void startDocumentSelectActivity() {
try {
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("*/*");
startActivityForResult(photoPickerIntent, 21);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
});
presentFragment(fragment); presentFragment(fragment);
} else if (id == chat_menu_avatar) { } else if (id == chat_menu_avatar) {
if (currentUser != null) { if (currentUser != null) {
@ -1292,16 +1333,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
private void processRowSelect(View view) { private void processRowSelect(View view) {
View parentView = getRowParentView(view);
if (parentView == null) {
return;
}
MessageObject message = null; MessageObject message = null;
if (view instanceof ChatBaseCell) { if (view instanceof ChatBaseCell) {
message = ((ChatBaseCell)view).getMessageObject(); message = ((ChatBaseCell)view).getMessageObject();
} else { } else if (view instanceof ChatActionCell) {
ChatListRowHolderEx holder = (ChatListRowHolderEx)parentView.getTag(); message = ((ChatActionCell)view).getMessageObject();
message = holder.message;
} }
int type = getMessageType(message); int type = getMessageType(message);
@ -1375,6 +1411,25 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
} }
private void setTypingAnimation(boolean start) {
if (actionBarLayer == null) {
return;
}
if (start) {
try {
actionBarLayer.setSubTitleIcon(0, typingDotsDrawable, AndroidUtilities.dp(4));
typingDotsDrawable.start();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
} else {
actionBarLayer.setSubTitleIcon(0, null, 0);
if (typingDotsDrawable != null) {
typingDotsDrawable.stop();
}
}
}
private void checkAndUpdateAvatar() { private void checkAndUpdateAvatar() {
TLRPC.FileLocation newPhoto = null; TLRPC.FileLocation newPhoto = null;
int placeHolderId = 0; int placeHolderId = 0;
@ -1408,6 +1463,41 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
} }
public boolean openVideoEditor(String videoPath, boolean removeLast, ActionBarLayout parentLayout) {
Bundle args = new Bundle();
args.putString("videoPath", videoPath);
VideoEditorActivity fragment = new VideoEditorActivity(args);
fragment.setDelegate(new VideoEditorActivity.VideoEditorActivityDelegate() {
@Override
public void didFinishEditVideo(String videoPath, long startTime, long endTime, int resultWidth, int resultHeight, int rotationValue, int originalWidth, int originalHeight, int bitrate, long estimatedSize, long estimatedDuration) {
TLRPC.VideoEditedInfo videoEditedInfo = new TLRPC.VideoEditedInfo();
videoEditedInfo.startTime = startTime;
videoEditedInfo.endTime = endTime;
videoEditedInfo.rotationValue = rotationValue;
videoEditedInfo.originalWidth = originalWidth;
videoEditedInfo.originalHeight = originalHeight;
videoEditedInfo.bitrate = bitrate;
videoEditedInfo.resultWidth = resultWidth;
videoEditedInfo.resultHeight = resultHeight;
videoEditedInfo.originalPath = videoPath;
processSendingVideo(videoPath, estimatedSize, estimatedDuration, resultWidth, resultHeight, videoEditedInfo);
}
});
if (parentLayout == null || !parentLayout.presentFragment(fragment, removeLast, true, true)) {
processSendingVideo(videoPath, 0, 0, 0, 0, null);
return false;
}
return true;
}
private void showAttachmentError() {
if (getParentActivity() == null) {
return;
}
Toast toast = Toast.makeText(getParentActivity(), LocaleController.getString("UnsupportedAttachment", R.string.UnsupportedAttachment), Toast.LENGTH_SHORT);
toast.show();
}
@Override @Override
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) { public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) { if (resultCode == Activity.RESULT_OK) {
@ -1458,13 +1548,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (paused) { if (paused) {
startVideoEdit = videoPath; startVideoEdit = videoPath;
} else { } else {
Bundle args = new Bundle(); openVideoEditor(videoPath, false, parentLayout);
args.putString("videoPath", videoPath);
VideoEditorActivity fragment = new VideoEditorActivity(args);
fragment.setDelegate(this);
if (!presentFragment(fragment, false, true)) {
processSendingVideo(videoPath, 0, 0, 0, 0, null);
}
} }
} else { } else {
processSendingVideo(videoPath, 0, 0, 0, 0, null); processSendingVideo(videoPath, 0, 0, 0, 0, null);
@ -1489,29 +1573,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
} }
@Override
public void didFinishEditVideo(String videoPath, long startTime, long endTime, int resultWidth, int resultHeight, int rotationValue, int originalWidth, int originalHeight, int bitrate, long estimatedSize, long estimatedDuration) {
TLRPC.VideoEditedInfo videoEditedInfo = new TLRPC.VideoEditedInfo();
videoEditedInfo.startTime = startTime;
videoEditedInfo.endTime = endTime;
videoEditedInfo.rotationValue = rotationValue;
videoEditedInfo.originalWidth = originalWidth;
videoEditedInfo.originalHeight = originalHeight;
videoEditedInfo.bitrate = bitrate;
videoEditedInfo.resultWidth = resultWidth;
videoEditedInfo.resultHeight = resultHeight;
videoEditedInfo.originalPath = videoPath;
processSendingVideo(videoPath, estimatedSize, estimatedDuration, resultWidth, resultHeight, videoEditedInfo);
}
private void showAttachmentError() {
if (getParentActivity() == null) {
return;
}
Toast toast = Toast.makeText(getParentActivity(), LocaleController.getString("UnsupportedAttachment", R.string.UnsupportedAttachment), Toast.LENGTH_SHORT);
toast.show();
}
@Override @Override
public void saveSelfArgs(Bundle args) { public void saveSelfArgs(Bundle args) {
if (currentPicturePath != null) { if (currentPicturePath != null) {
@ -1524,6 +1585,20 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
currentPicturePath = args.getString("path"); currentPicturePath = args.getString("path");
} }
private void removeUnreadPlane(boolean reload) {
if (unreadMessageObject != null) {
messages.remove(unreadMessageObject);
unread_end_reached = true;
first_unread_id = 0;
last_unread_id = 0;
unread_to_load = 0;
unreadMessageObject = null;
if (reload) {
chatAdapter.notifyDataSetChanged();
}
}
}
public boolean processSendingText(String text) { public boolean processSendingText(String text) {
return chatActivityEnterView.processSendingText(text); return chatActivityEnterView.processSendingText(text);
} }
@ -1855,20 +1930,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}).start(); }).start();
} }
private void removeUnreadPlane(boolean reload) {
if (unreadMessageObject != null) {
messages.remove(unreadMessageObject);
unread_end_reached = true;
first_unread_id = 0;
last_unread_id = 0;
unread_to_load = 0;
unreadMessageObject = null;
if (reload) {
chatAdapter.notifyDataSetChanged();
}
}
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public void didReceivedNotification(int id, final Object... args) { public void didReceivedNotification(int id, final Object... args) {
@ -1948,7 +2009,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
dateMsg.id = 0; dateMsg.id = 0;
MessageObject dateObj = new MessageObject(dateMsg, null); MessageObject dateObj = new MessageObject(dateMsg, null);
dateObj.type = 10; dateObj.type = 10;
dateObj.contentType = 7; dateObj.contentType = 4;
if (forwardLoad) { if (forwardLoad) {
messages.add(0, dateObj); messages.add(0, dateObj);
} else { } else {
@ -2209,7 +2270,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
dateMsg.id = 0; dateMsg.id = 0;
MessageObject dateObj = new MessageObject(dateMsg, null); MessageObject dateObj = new MessageObject(dateMsg, null);
dateObj.type = 10; dateObj.type = 10;
dateObj.contentType = 7; dateObj.contentType = 4;
messages.add(0, dateObj); messages.add(0, dateObj);
} }
if (!obj.isOut() && obj.isUnread()) { if (!obj.isOut() && obj.isUnread()) {
@ -2655,13 +2716,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
AndroidUtilities.RunOnUIThread(new Runnable() { AndroidUtilities.RunOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
Bundle args = new Bundle(); openVideoEditor(startVideoEdit, false, parentLayout);
args.putString("videoPath", startVideoEdit);
VideoEditorActivity fragment = new VideoEditorActivity(args);
fragment.setDelegate(ChatActivity.this);
if (!presentFragment(fragment, false, true)) {
processSendingVideo(startVideoEdit, 0, 0, 0, 0, null);
}
startVideoEdit = null; startVideoEdit = null;
} }
}); });
@ -2672,58 +2727,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
chatListView.setLongClickable(true); chatListView.setLongClickable(true);
} }
@Override
public void didSelectPhotos(ArrayList<String> photos) {
processSendingPhotos(photos, null);
}
@Override
public void didSelectLocation(double latitude, double longitude) {
SendMessagesHelper.getInstance().sendMessage(latitude, longitude, dialog_id);
if (chatListView != null) {
chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop());
}
if (paused) {
scrollToTopOnResume = true;
}
}
@Override
public void startPhotoSelectActivity() {
try {
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
@Override @Override
public void onBeginSlide() { public void onBeginSlide() {
super.onBeginSlide(); super.onBeginSlide();
chatActivityEnterView.hideEmojiPopup(); chatActivityEnterView.hideEmojiPopup();
} }
private void setTypingAnimation(boolean start) {
if (actionBarLayer == null) {
return;
}
if (start) {
try {
actionBarLayer.setSubTitleIcon(0, typingDotsDrawable, AndroidUtilities.dp(4));
typingDotsDrawable.start();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
} else {
actionBarLayer.setSubTitleIcon(0, null, 0);
if (typingDotsDrawable != null) {
typingDotsDrawable.stop();
}
}
}
@Override @Override
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
@ -2759,12 +2768,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (view instanceof ChatBaseCell) { if (view instanceof ChatBaseCell) {
ChatBaseCell cell = (ChatBaseCell) view; ChatBaseCell cell = (ChatBaseCell) view;
object = cell.getMessageObject(); object = cell.getMessageObject();
} else {
Object tag = view.getTag();
if (tag instanceof ChatListRowHolderEx) {
ChatListRowHolderEx holder = (ChatListRowHolderEx) tag;
object = holder.message;
}
} }
if (object != null && object.messageOwner.id < 0 && object.messageOwner.random_id != 0) { if (object != null && object.messageOwner.id < 0 && object.messageOwner.random_id != 0) {
visibleMessages.add(object.messageOwner.random_id); visibleMessages.add(object.messageOwner.random_id);
@ -2817,39 +2820,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
fixLayout(false); fixLayout(false);
} }
private View getRowParentView(View v) {
if (v instanceof ChatBaseCell) {
return v;
} else {
while (!(v.getTag() instanceof ChatListRowHolderEx)) {
ViewParent parent = v.getParent();
if (!(parent instanceof View)) {
return null;
}
v = (View)v.getParent();
if (v == null) {
return null;
}
}
return v;
}
}
public void createMenu(View v, boolean single) { public void createMenu(View v, boolean single) {
if (actionBarLayer.isActionModeShowed()) { if (actionBarLayer.isActionModeShowed()) {
return; return;
} }
View parentView = getRowParentView(v);
if (parentView == null) {
return;
}
MessageObject message = null; MessageObject message = null;
if (v instanceof ChatBaseCell) { if (v instanceof ChatBaseCell) {
message = ((ChatBaseCell)v).getMessageObject(); message = ((ChatBaseCell)v).getMessageObject();
} else { } else if (v instanceof ChatActionCell) {
ChatListRowHolderEx holder = (ChatListRowHolderEx)parentView.getTag(); message = ((ChatActionCell)v).getMessageObject();
message = holder.message;
} }
final int type = getMessageType(message); final int type = getMessageType(message);
@ -3094,23 +3074,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
selectedObject = null; selectedObject = null;
} }
@Override
public void didSelectFile(DocumentSelectActivity activity, String path) {
activity.finishFragment();
processSendingDocument(path, path);
}
@Override
public void startDocumentSelectActivity() {
try {
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("*/*");
startActivityForResult(photoPickerIntent, 21);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
private void forwardSelectedMessages(long did, boolean fromMyName) { private void forwardSelectedMessages(long did, boolean fromMyName) {
if (forwaringMessage != null) { if (forwaringMessage != null) {
if (!fromMyName) { if (!fromMyName) {
@ -3225,25 +3188,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
for (int a = 0; a < count; a++) { for (int a = 0; a < count; a++) {
View view = chatListView.getChildAt(a); View view = chatListView.getChildAt(a);
Object tag = view.getTag(); Object tag = view.getTag();
if (tag instanceof ChatListRowHolderEx) { if (view instanceof ChatBaseCell) {
ChatListRowHolderEx holder = (ChatListRowHolderEx)tag;
holder.update();
boolean disableSelection = false;
boolean selected = false;
if (actionBarLayer.isActionModeShowed()) {
if (selectedMessagesIds.containsKey(holder.message.messageOwner.id)) {
view.setBackgroundColor(0x6633b5e5);
selected = true;
} else {
view.setBackgroundColor(0);
}
disableSelection = true;
} else {
view.setBackgroundColor(0);
}
updateRowBackground(holder, disableSelection, selected);
} else if (view instanceof ChatBaseCell) {
ChatBaseCell cell = (ChatBaseCell)view; ChatBaseCell cell = (ChatBaseCell)view;
boolean disableSelection = false; boolean disableSelection = false;
@ -3267,35 +3212,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
} }
private void updateRowBackground(ChatListRowHolderEx holder, boolean disableSelection, boolean selected) {
int messageType = holder.message.type;
if (!disableSelection) {
if (messageType == 12) {
holder.chatBubbleView.setBackgroundResource(R.drawable.chat_outgoing_text_states);
holder.chatBubbleView.setPadding(AndroidUtilities.dp(6), AndroidUtilities.dp(6), AndroidUtilities.dp(18), 0);
} else if (messageType == 13) {
holder.chatBubbleView.setBackgroundResource(R.drawable.chat_incoming_text_states);
holder.chatBubbleView.setPadding(AndroidUtilities.dp(15), AndroidUtilities.dp(6), AndroidUtilities.dp(9), 0);
}
} else {
if (messageType == 12) {
if (selected) {
holder.chatBubbleView.setBackgroundResource(R.drawable.msg_out_selected);
} else {
holder.chatBubbleView.setBackgroundResource(R.drawable.msg_out);
}
holder.chatBubbleView.setPadding(AndroidUtilities.dp(6), AndroidUtilities.dp(6), AndroidUtilities.dp(18), 0);
} else if (messageType == 13) {
if (selected) {
holder.chatBubbleView.setBackgroundResource(R.drawable.msg_in_selected);
} else {
holder.chatBubbleView.setBackgroundResource(R.drawable.msg_in);
}
holder.chatBubbleView.setPadding(AndroidUtilities.dp(15), AndroidUtilities.dp(6), AndroidUtilities.dp(9), 0);
}
}
}
private void alertUserOpenError(MessageObject message) { private void alertUserOpenError(MessageObject message) {
if (getParentActivity() == null) { if (getParentActivity() == null) {
return; return;
@ -3329,15 +3245,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
messageToOpen = message; messageToOpen = message;
imageReceiver = cell.getPhotoImage(); imageReceiver = cell.getPhotoImage();
} }
} else if (view.getTag() != null) { } else if (view instanceof ChatActionCell) {
Object tag = view.getTag(); ChatActionCell cell = (ChatActionCell)view;
if (tag instanceof ChatListRowHolderEx) { MessageObject message = cell.getMessageObject();
ChatListRowHolderEx holder = (ChatListRowHolderEx)tag; if (message != null && message.messageOwner.id == messageObject.messageOwner.id) {
if (holder.message != null && holder.message.messageOwner.id == messageObject.messageOwner.id) { messageToOpen = message;
messageToOpen = holder.message; imageReceiver = cell.getPhotoImage();
imageReceiver = holder.photoImage.imageReceiver;
view = holder.photoImage;
}
} }
} }
@ -3457,45 +3370,19 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
view = new ChatMessageCell(mContext); view = new ChatMessageCell(mContext);
} if (type == 1) { } if (type == 1) {
view = new ChatMediaCell(mContext); view = new ChatMediaCell(mContext);
} else if (type == 7) { } else if (type == 2) {
view = new ChatActionCell(mContext); view = new ChatAudioCell(mContext);
} else if (type == 8) {
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = li.inflate(R.layout.chat_action_change_photo_layout, viewGroup, false);
} else if (type == 3) { } else if (type == 3) {
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = new ChatContactCell(mContext);
view = li.inflate(R.layout.chat_outgoing_contact_layout, viewGroup, false);
} else if (type == 4) {
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (currentChat != null) {
view = li.inflate(R.layout.chat_group_incoming_contact_layout, viewGroup, false);
} else {
view = li.inflate(R.layout.chat_incoming_contact_layout, viewGroup, false);
}
} else if (type == 6) { } else if (type == 6) {
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = li.inflate(R.layout.chat_unread_layout, viewGroup, false); view = li.inflate(R.layout.chat_unread_layout, viewGroup, false);
} else if (type == 2) { } else if (type == 4) {
view = new ChatAudioCell(mContext); view = new ChatActionCell(mContext);
}
}
boolean selected = false;
boolean disableSelection = false;
if (actionBarLayer.isActionModeShowed()) {
if (selectedMessagesIds.containsKey(message.messageOwner.id)) {
view.setBackgroundColor(0x6633b5e5);
selected = true;
} else {
view.setBackgroundColor(0);
}
disableSelection = true;
} else {
view.setBackgroundColor(0);
} }
if (view instanceof ChatBaseCell) { if (view instanceof ChatBaseCell) {
((ChatBaseCell)view).delegate = new ChatBaseCell.ChatBaseCellDelegate() { ((ChatBaseCell)view).setDelegate(new ChatBaseCell.ChatBaseCellDelegate() {
@Override @Override
public void didPressedUserAvatar(ChatBaseCell cell, TLRPC.User user) { public void didPressedUserAvatar(ChatBaseCell cell, TLRPC.User user) {
if (user != null && user.id != UserConfig.getClientUserId()) { if (user != null && user.id != UserConfig.getClientUserId()) {
@ -3522,9 +3409,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
public boolean canPerformActions() { public boolean canPerformActions() {
return actionBarLayer != null && !actionBarLayer.isActionModeShowed(); return actionBarLayer != null && !actionBarLayer.isActionModeShowed();
} }
}; });
if (view instanceof ChatMediaCell) { if (view instanceof ChatMediaCell) {
((ChatMediaCell)view).mediaDelegate = new ChatMediaCell.ChatMediaCellDelegate() { ((ChatMediaCell) view).setMediaDelegate(new ChatMediaCell.ChatMediaCellDelegate() {
@Override @Override
public void didClickedImage(ChatMediaCell cell) { public void didClickedImage(ChatMediaCell cell) {
MessageObject message = cell.getMessageObject(); MessageObject message = cell.getMessageObject();
@ -3608,27 +3495,64 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
public void didPressedOther(ChatMediaCell cell) { public void didPressedOther(ChatMediaCell cell) {
createMenu(cell, true); createMenu(cell, true);
} }
}; });
}
} else if (view instanceof ChatActionCell) {
((ChatActionCell)view).setDelegate(new ChatActionCell.ChatActionCellDelegate() {
@Override
public void didClickedImage(ChatActionCell cell) {
MessageObject message = cell.getMessageObject();
PhotoViewer.getInstance().setParentActivity(getParentActivity());
PhotoViewer.getInstance().openPhoto(message, ChatActivity.this);
} }
((ChatBaseCell)view).isChat = currentChat != null; @Override
((ChatBaseCell)view).setMessageObject(message); public void didLongPressed(ChatActionCell cell) {
((ChatBaseCell)view).setCheckPressed(!disableSelection, disableSelection && selected); createMenu(cell, false);
}
@Override
public void needOpenUserProfile(int uid) {
if (uid != UserConfig.getClientUserId()) {
Bundle args = new Bundle();
args.putInt("user_id", uid);
presentFragment(new UserProfileActivity(args));
}
}
});
}
}
boolean selected = false;
boolean disableSelection = false;
if (actionBarLayer.isActionModeShowed()) {
if (selectedMessagesIds.containsKey(message.messageOwner.id)) {
view.setBackgroundColor(0x6633b5e5);
selected = true;
} else {
view.setBackgroundColor(0);
}
disableSelection = true;
} else {
view.setBackgroundColor(0);
}
if (view instanceof ChatBaseCell) {
ChatBaseCell baseCell = (ChatBaseCell)view;
baseCell.isChat = currentChat != null;
baseCell.setMessageObject(message);
baseCell.setCheckPressed(!disableSelection, disableSelection && selected);
if (view instanceof ChatAudioCell && MediaController.getInstance().canDownloadMedia(MediaController.AUTODOWNLOAD_MASK_AUDIO)) { if (view instanceof ChatAudioCell && MediaController.getInstance().canDownloadMedia(MediaController.AUTODOWNLOAD_MASK_AUDIO)) {
((ChatAudioCell)view).downloadAudioIfNeed(); ((ChatAudioCell)view).downloadAudioIfNeed();
} }
} else if (view instanceof ChatActionCell) { } else if (view instanceof ChatActionCell) {
((ChatActionCell)view).setMessageObject(message); ChatActionCell actionCell = (ChatActionCell)view;
((ChatActionCell)view).setUseBlackBackground(isCustomTheme); actionCell.setMessageObject(message);
} else { actionCell.setUseBlackBackground(isCustomTheme);
ChatListRowHolderEx holder = (ChatListRowHolderEx)view.getTag();
if (holder == null) {
holder = new ChatListRowHolderEx(view, message.type);
view.setTag(holder);
} }
holder.message = message; if (type == 6) {
updateRowBackground(holder, disableSelection, selected); TextView messageTextView = (TextView)view.findViewById(R.id.chat_message_text);
holder.update(); messageTextView.setText(LocaleController.formatPluralString("NewMessages", unread_to_load));
} }
return view; return view;
@ -3652,7 +3576,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
@Override @Override
public int getViewTypeCount() { public int getViewTypeCount() {
return 9; return 7;
} }
@Override @Override
@ -3669,318 +3593,4 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return count == 0; return count == 0;
} }
} }
public class ChatListRowHolderEx {
public BackupImageView avatarImageView;
public TextView nameTextView;
public TextView messageTextView;
public MessageActionLayout messageLayoutAction;
public TextView timeTextView;
public BackupImageView photoImage;
public ImageView halfCheckImage;
public ImageView checkImage;
public MessageObject message;
public TextView phoneTextView;
public BackupImageView contactAvatar;
public View contactView;
public ImageView addContactButton;
public View addContactView;
public View chatBubbleView;
public void update() {
TLRPC.User fromUser = MessagesController.getInstance().getUser(message.messageOwner.from_id);
int type = message.type;
if (timeTextView != null) {
timeTextView.setText(LocaleController.formatterDay.format((long) (message.messageOwner.date) * 1000));
}
if (avatarImageView != null && fromUser != null) {
TLRPC.FileLocation photo = null;
if (fromUser.photo != null) {
photo = fromUser.photo.photo_small;
}
int placeHolderId = AndroidUtilities.getUserAvatarForId(fromUser.id);
avatarImageView.setImage(photo, "50_50", placeHolderId);
}
if (type != 12 && type != 13 && nameTextView != null && fromUser != null && type != 8 && type != 9) {
nameTextView.setText(ContactsController.formatName(fromUser.first_name, fromUser.last_name));
nameTextView.setTextColor(AndroidUtilities.getColorForId(message.messageOwner.from_id));
}
if (type == 11 || type == 10) {
int width = 0;
if (AndroidUtilities.isTablet()) {
width = AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(30);
} else {
width = AndroidUtilities.displaySize.x - AndroidUtilities.dp(30);
}
messageTextView.setText(message.messageText);
messageTextView.setMaxWidth(width);
if (type == 11) {
if (message.messageOwner.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) {
photoImage.setImage(message.messageOwner.action.newUserPhoto.photo_small, "50_50", AndroidUtilities.getUserAvatarForId(currentUser.id));
} else {
PhotoObject photo = PhotoObject.getClosestImageWithSize(message.photoThumbs, AndroidUtilities.dp(64));
if (photo != null) {
if (photo.image != null) {
photoImage.setImageBitmap(photo.image);
} else {
photoImage.setImage(photo.photoOwner.location, "50_50", AndroidUtilities.getGroupAvatarForId(currentChat.id));
}
} else {
photoImage.setImageResource(AndroidUtilities.getGroupAvatarForId(currentChat.id));
}
}
photoImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(message), false);
}
} else if (type == 12 || type == 13) {
TLRPC.User contactUser = MessagesController.getInstance().getUser(message.messageOwner.media.user_id);
if (contactUser != null) {
nameTextView.setText(ContactsController.formatName(message.messageOwner.media.first_name, message.messageOwner.media.last_name));
nameTextView.setTextColor(AndroidUtilities.getColorForId(contactUser.id));
String phone = message.messageOwner.media.phone_number;
if (phone != null && phone.length() != 0) {
if (!phone.startsWith("+")) {
phone = "+" + phone;
}
phoneTextView.setText(PhoneFormat.getInstance().format(phone));
} else {
phoneTextView.setText("Unknown");
}
TLRPC.FileLocation photo = null;
if (contactUser.photo != null) {
photo = contactUser.photo.photo_small;
}
int placeHolderId = AndroidUtilities.getUserAvatarForId(contactUser.id);
contactAvatar.setImage(photo, "50_50", placeHolderId);
if (contactUser.id != UserConfig.getClientUserId() && ContactsController.getInstance().contactsDict.get(contactUser.id) == null) {
addContactView.setVisibility(View.VISIBLE);
} else {
addContactView.setVisibility(View.GONE);
}
} else {
nameTextView.setText(ContactsController.formatName(message.messageOwner.media.first_name, message.messageOwner.media.last_name));
nameTextView.setTextColor(AndroidUtilities.getColorForId(message.messageOwner.media.user_id));
String phone = message.messageOwner.media.phone_number;
if (phone != null && phone.length() != 0) {
if (message.messageOwner.media.user_id != 0 && !phone.startsWith("+")) {
phone = "+" + phone;
}
phoneTextView.setText(PhoneFormat.getInstance().format(phone));
} else {
phoneTextView.setText("Unknown");
}
contactAvatar.setImageResource(AndroidUtilities.getUserAvatarForId(message.messageOwner.media.user_id));
addContactView.setVisibility(View.GONE);
}
} else if (type == 6) {
messageTextView.setTextSize(16);
messageTextView.setText(LocaleController.formatPluralString("NewMessages", unread_to_load));
}
if (message.isFromMe()) {
if (halfCheckImage != null) {
if (message.isSending()) {
checkImage.setVisibility(View.INVISIBLE);
halfCheckImage.setImageResource(R.drawable.msg_clock);
halfCheckImage.setVisibility(View.VISIBLE);
} else if (message.isSendError()) {
halfCheckImage.setVisibility(View.VISIBLE);
halfCheckImage.setImageResource(R.drawable.msg_warning);
if (checkImage != null) {
checkImage.setVisibility(View.INVISIBLE);
}
} else if (message.isSent()) {
if (!message.isUnread()) {
halfCheckImage.setVisibility(View.VISIBLE);
checkImage.setVisibility(View.VISIBLE);
halfCheckImage.setImageResource(R.drawable.msg_halfcheck);
} else {
halfCheckImage.setVisibility(View.VISIBLE);
checkImage.setVisibility(View.INVISIBLE);
halfCheckImage.setImageResource(R.drawable.msg_check);
}
}
}
}
}
public ChatListRowHolderEx(View view, int type) {
avatarImageView = (BackupImageView)view.findViewById(R.id.chat_group_avatar_image);
nameTextView = (TextView)view.findViewById(R.id.chat_user_group_name);
messageLayoutAction = (MessageActionLayout)view.findViewById(R.id.message_action_layout);
timeTextView = (TextView)view.findViewById(R.id.chat_time_text);
photoImage = (BackupImageView)view.findViewById(R.id.chat_photo_image);
halfCheckImage = (ImageView)view.findViewById(R.id.chat_row_halfcheck);
checkImage = (ImageView)view.findViewById(R.id.chat_row_check);
messageTextView = (TextView)view.findViewById(R.id.chat_message_text);
phoneTextView = (TextView)view.findViewById(R.id.phone_text_view);
contactAvatar = (BackupImageView)view.findViewById(R.id.contact_avatar);
contactView = view.findViewById(R.id.shared_layout);
addContactButton = (ImageView)view.findViewById(R.id.add_contact_button);
addContactView = view.findViewById(R.id.add_contact_view);
chatBubbleView = view.findViewById(R.id.chat_bubble_layout);
if (messageTextView != null) {
messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, MessagesController.getInstance().fontSize);
}
if (messageLayoutAction != null) {
if (isCustomTheme) {
messageLayoutAction.setBackgroundResource(R.drawable.system_black);
} else {
messageLayoutAction.setBackgroundResource(R.drawable.system_blue);
}
}
if (addContactButton != null) {
addContactButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (actionBarLayer.isActionModeShowed()) {
processRowSelect(view);
return;
}
Bundle args = new Bundle();
args.putInt("user_id", message.messageOwner.media.user_id);
args.putString("phone", message.messageOwner.media.phone_number);
presentFragment(new ContactAddActivity(args));
}
});
addContactButton.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
createMenu(v, false);
return true;
}
});
}
if (contactView != null) {
contactView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (message.type == 12 || message.type == 13) {
if (actionBarLayer.isActionModeShowed()) {
processRowSelect(view);
return;
}
if (message.messageOwner.media.user_id != UserConfig.getClientUserId()) {
TLRPC.User user = null;
if (message.messageOwner.media.user_id != 0) {
user = MessagesController.getInstance().getUser(message.messageOwner.media.user_id);
}
if (user != null) {
Bundle args = new Bundle();
args.putInt("user_id", message.messageOwner.media.user_id);
presentFragment(new UserProfileActivity(args));
} else {
if (message.messageOwner.media.phone_number == null || message.messageOwner.media.phone_number.length() == 0) {
return;
}
if (getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setItems(new CharSequence[] {LocaleController.getString("Copy", R.string.Copy), LocaleController.getString("Call", R.string.Call)}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (i == 1) {
try {
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + message.messageOwner.media.phone_number));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getParentActivity().startActivity(intent);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
} else if (i == 0) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(message.messageOwner.media.phone_number);
} else {
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
android.content.ClipData clip = android.content.ClipData.newPlainText("label", message.messageOwner.media.phone_number);
clipboard.setPrimaryClip(clip);
}
}
}
}
);
showAlertDialog(builder);
}
}
}
}
});
contactView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
createMenu(v, false);
return true;
}
});
}
if (contactAvatar != null) {
contactAvatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
}
if (avatarImageView != null) {
avatarImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (actionBarLayer.isActionModeShowed()) {
processRowSelect(view);
return;
}
if (message != null) {
Bundle args = new Bundle();
args.putInt("user_id", message.messageOwner.from_id);
presentFragment(new UserProfileActivity(args));
}
}
});
}
if (photoImage != null) {
photoImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
processOnClick(view);
}
});
photoImage.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
createMenu(v, false);
return true;
}
});
}
}
private void processOnClick(View view) {
if (actionBarLayer.isActionModeShowed()) {
processRowSelect(view);
return;
}
if (message != null) {
if (message.type == 11) {
PhotoViewer.getInstance().setParentActivity(getParentActivity());
PhotoViewer.getInstance().openPhoto(message, ChatActivity.this);
}
}
}
}
} }

View file

@ -661,12 +661,11 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
actionBarLayout.presentFragment(fragment, false, true, true); actionBarLayout.presentFragment(fragment, false, true, true);
} }
Bundle args2 = new Bundle(); if (!fragment.openVideoEditor(videoPath, true, actionBarLayout)) {
args2.putString("videoPath", videoPath);
VideoEditorActivity fragment2 = new VideoEditorActivity(args2);
fragment2.setDelegate(fragment);
presentFragment(fragment2, true, true);
if (!AndroidUtilities.isTablet()) { if (!AndroidUtilities.isTablet()) {
actionBarLayout.presentFragment(fragment, true);
}
} else if (!AndroidUtilities.isTablet()) {
actionBarLayout.addFragmentToStack(fragment, actionBarLayout.fragmentsStack.size() - 1); actionBarLayout.addFragmentToStack(fragment, actionBarLayout.fragmentsStack.size() - 1);
} }
} else { } else {

View file

@ -207,7 +207,7 @@ public class HorizontalListView extends AdapterView<ListAdapter> {
v = list.poll(); v = list.poll();
} }
View child = mAdapter.getView(mRightViewIndex, v, this); View child = mAdapter.getView(mRightViewIndex, v, this);
child.setTag(1, type); child.setTag(type);
addAndMeasureChild(child, -1); addAndMeasureChild(child, -1);
rightEdge += child.getMeasuredWidth(); rightEdge += child.getMeasuredWidth();
@ -234,7 +234,7 @@ public class HorizontalListView extends AdapterView<ListAdapter> {
v = list.poll(); v = list.poll();
} }
View child = mAdapter.getView(mLeftViewIndex, v, this); View child = mAdapter.getView(mLeftViewIndex, v, this);
child.setTag(1, type); child.setTag(type);
addAndMeasureChild(child, 0); addAndMeasureChild(child, 0);
leftEdge -= child.getMeasuredWidth(); leftEdge -= child.getMeasuredWidth();
@ -248,7 +248,7 @@ public class HorizontalListView extends AdapterView<ListAdapter> {
while (child != null && child.getRight() + dx <= 0) { while (child != null && child.getRight() + dx <= 0) {
mDisplayOffset += child.getMeasuredWidth(); mDisplayOffset += child.getMeasuredWidth();
int type = (Integer) child.getTag(1); int type = (Integer) child.getTag();
LinkedList<View> list = mRemovedViewQueue.get(type); LinkedList<View> list = mRemovedViewQueue.get(type);
if (list == null) { if (list == null) {
list = new LinkedList<View>(); list = new LinkedList<View>();
@ -263,7 +263,7 @@ public class HorizontalListView extends AdapterView<ListAdapter> {
child = getChildAt(getChildCount() - 1); child = getChildAt(getChildCount() - 1);
while (child != null && child.getLeft() + dx >= getWidth()) { while (child != null && child.getLeft() + dx >= getWidth()) {
int type = (Integer) child.getTag(1); int type = (Integer) child.getTag();
LinkedList<View> list = mRemovedViewQueue.get(type); LinkedList<View> list = mRemovedViewQueue.get(type);
if (list == null) { if (list == null) {
list = new LinkedList<View>(); list = new LinkedList<View>();

View file

@ -1,42 +0,0 @@
/*
* This is the source code of Telegram for Android v. 1.3.2.
* 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.Views;
import android.widget.FrameLayout;
import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.R;
public class MessageActionLayout extends FrameLayout {
public TightTextView messageTextView;
public MessageActionLayout(android.content.Context context) {
super(context);
}
public MessageActionLayout(android.content.Context context, android.util.AttributeSet attrs) {
super(context, attrs);
}
public MessageActionLayout(android.content.Context context, android.util.AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
setMeasuredDimension(messageTextView.linesMaxWidth + AndroidUtilities.dp(14), getMeasuredHeight());
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
messageTextView = (TightTextView)findViewById(R.id.chat_message_text);
}
}

View file

@ -1,118 +0,0 @@
/*
* This is the source code of Telegram for Android v. 1.3.2.
* 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.Views;
import android.content.Context;
import android.text.Layout;
import android.util.AttributeSet;
import android.widget.TextView;
import org.telegram.messenger.FileLog;
public class TightTextView extends TextView {
private boolean hasMaxWidth;
public int maxWidth;
public int lastLineWidth = 0;
public int linesMaxWidth = 0;
public int lines = 0;
public TightTextView(Context context) {
this(context, null, 0);
}
public TightTextView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public TightTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
try {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int measuredWidth = getMeasuredWidth();
Layout layout = getLayout();
lines = layout.getLineCount();
float lastLeft = layout.getLineLeft(lines - 1);
float lastLine = layout.getLineWidth(lines - 1);
int lastLineWidthWithLeft;
int linesMaxWidthWithLeft;
boolean hasNonRTL = false;
linesMaxWidth = lastLineWidth = (int)Math.ceil(lastLine);
linesMaxWidthWithLeft = lastLineWidthWithLeft = (int)Math.ceil(lastLine + lastLeft);
if (lastLeft == 0) {
hasNonRTL = true;
}
if (hasMaxWidth) {
int specModeW = MeasureSpec.getMode(widthMeasureSpec);
if (specModeW != MeasureSpec.EXACTLY) {
if (lines > 1) {
float textRealMaxWidth = 0, textRealMaxWidthWithLeft = 0;
for (int n = 0; n < lines; ++n) {
float lineWidth;
float lineLeft;
try {
lineWidth = layout.getLineWidth(n);
lineLeft = layout.getLineLeft(n);
} catch (Exception e) {
FileLog.e("tmessages", e);
return;
}
if (lineLeft == 0) {
hasNonRTL = true;
}
textRealMaxWidth = Math.max(textRealMaxWidth, lineWidth);
textRealMaxWidthWithLeft = Math.max(textRealMaxWidthWithLeft, lineWidth + lineLeft);
linesMaxWidth = Math.max(linesMaxWidth, (int)Math.ceil(lineWidth));
linesMaxWidthWithLeft = Math.max(linesMaxWidthWithLeft, (int)Math.ceil(lineWidth + lineLeft));
}
if (hasNonRTL) {
textRealMaxWidth = textRealMaxWidthWithLeft;
lastLineWidth = lastLineWidthWithLeft;
linesMaxWidth = linesMaxWidthWithLeft;
} else {
lastLineWidth = linesMaxWidth;
}
int w = (int)Math.ceil(textRealMaxWidth);
if (w < getMeasuredWidth()) {
super.onMeasure(MeasureSpec.makeMeasureSpec(w, MeasureSpec.AT_MOST), heightMeasureSpec);
}
} else {
super.onMeasure(MeasureSpec.makeMeasureSpec(Math.min(maxWidth, linesMaxWidth), MeasureSpec.AT_MOST), heightMeasureSpec);
}
}
}
} catch (Exception e) {
FileLog.e("tmessages", e);
try {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
} catch (Exception e2) {
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.getSize(heightMeasureSpec));
FileLog.e("tmessages", e2);
}
}
}
@Override
public void setMaxWidth(int maxpixels) {
super.setMaxWidth(maxpixels);
hasMaxWidth = true;
maxWidth = maxpixels;
}
@Override
public void setMaxEms(int maxems) {
super.setMaxEms(maxems);
hasMaxWidth = true;
}
}

View file

@ -0,0 +1,24 @@
/*
* This is the source code of Telegram for Android v. 1.7.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-2014.
*/
package org.telegram.ui.Views;
import android.text.TextPaint;
import android.text.style.URLSpan;
public class URLSpanNoUnderline extends URLSpan {
public URLSpanNoUnderline(String url) {
super(url);
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
ds.setUnderlineText(false);
}
}

View file

@ -1,42 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="5dp"
android:gravity="center"
android:layout_gravity="top">
<org.telegram.ui.Views.MessageActionLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:id="@+id/message_action_layout">
<org.telegram.ui.Views.TightTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15dp"
android:id="@+id/chat_message_text"
android:textColor="#ffffff"
android:paddingTop="1dp"
android:paddingBottom="1dp"
android:ellipsize="none"
android:gravity="center"
android:maxLines="10"
android:maxWidth="380dp"
android:layout_gravity="center"/>
</org.telegram.ui.Views.MessageActionLayout>
<org.telegram.ui.Views.BackupImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginTop="5dp"
android:id="@+id/chat_photo_image"/>
</LinearLayout>

View file

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:gravity="center"
android:layout_gravity="top">
<org.telegram.ui.Views.MessageActionLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:id="@+id/message_action_layout">
<org.telegram.ui.Views.TightTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14dp"
android:id="@+id/chat_message_text"
android:textColor="#ffffff"
android:paddingTop="1dp"
android:paddingBottom="1dp"
android:ellipsize="none"
android:gravity="center"
android:maxLines="10"
android:layout_gravity="center"/>
</org.telegram.ui.Views.MessageActionLayout>
</LinearLayout>