mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 14:35:03 +01:00
UI improvements
This commit is contained in:
parent
2f23635e4a
commit
288fceeb9f
15 changed files with 921 additions and 1073 deletions
|
@ -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) {
|
||||||
|
|
|
@ -564,18 +564,30 @@ public class FileLoader {
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
return new File("");
|
return new File("");
|
||||||
}
|
}
|
||||||
if (message.media instanceof TLRPC.TL_messageMediaVideo) {
|
if (message instanceof TLRPC.TL_messageService) {
|
||||||
return getPathToAttach(message.media.video);
|
if (message.action.photo != null) {
|
||||||
} else if (message.media instanceof TLRPC.TL_messageMediaDocument) {
|
ArrayList<TLRPC.PhotoSize> sizes = message.action.photo.sizes;
|
||||||
return getPathToAttach(message.media.document);
|
if (sizes.size() > 0) {
|
||||||
} else if (message.media instanceof TLRPC.TL_messageMediaAudio) {
|
TLRPC.PhotoSize sizeFull = getClosestPhotoSizeWithSize(sizes, AndroidUtilities.getPhotoSize());
|
||||||
return getPathToAttach(message.media.audio);
|
if (sizeFull != null) {
|
||||||
} else if (message.media instanceof TLRPC.TL_messageMediaPhoto) {
|
return getPathToAttach(sizeFull);
|
||||||
ArrayList<TLRPC.PhotoSize> sizes = message.media.photo.sizes;
|
}
|
||||||
if (sizes.size() > 0) {
|
}
|
||||||
TLRPC.PhotoSize sizeFull = getClosestPhotoSizeWithSize(sizes, AndroidUtilities.getPhotoSize());
|
}
|
||||||
if (sizeFull != null) {
|
} else {
|
||||||
return getPathToAttach(sizeFull);
|
if (message.media instanceof TLRPC.TL_messageMediaVideo) {
|
||||||
|
return getPathToAttach(message.media.video);
|
||||||
|
} else if (message.media instanceof TLRPC.TL_messageMediaDocument) {
|
||||||
|
return getPathToAttach(message.media.document);
|
||||||
|
} else if (message.media instanceof TLRPC.TL_messageMediaAudio) {
|
||||||
|
return getPathToAttach(message.media.audio);
|
||||||
|
} else if (message.media instanceof TLRPC.TL_messageMediaPhoto) {
|
||||||
|
ArrayList<TLRPC.PhotoSize> sizes = message.media.photo.sizes;
|
||||||
|
if (sizes.size() > 0) {
|
||||||
|
TLRPC.PhotoSize sizeFull = getClosestPhotoSizeWithSize(sizes, AndroidUtilities.getPhotoSize());
|
||||||
|
if (sizeFull != null) {
|
||||||
|
return getPathToAttach(sizeFull);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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() {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
} else {
|
if (messageObject.messageOwner.to_id != null) {
|
||||||
size = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y);
|
if (messageObject.messageOwner.to_id.chat_id != 0) {
|
||||||
}
|
id = messageObject.messageOwner.to_id.chat_id;
|
||||||
textLayout = new StaticLayout(currentMessageObject.messageText, textPaint, size - AndroidUtilities.dp(30), Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
|
} else {
|
||||||
textHeight = 0;
|
id = messageObject.messageOwner.to_id.user_id;
|
||||||
textWidth = 0;
|
if (id == UserConfig.getClientUserId()) {
|
||||||
try {
|
id = messageObject.messageOwner.from_id;
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
if (currentMessageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) {
|
||||||
FileLog.e("tmessages", e);
|
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);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public MessageObject getMessageObject() {
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
return currentMessageObject;
|
||||||
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), textHeight + AndroidUtilities.dp(14));
|
}
|
||||||
|
|
||||||
|
public ImageReceiver getPhotoImage() {
|
||||||
|
return imageReceiver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
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
|
||||||
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
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);
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
|
@ -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();
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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);
|
if (!AndroidUtilities.isTablet()) {
|
||||||
VideoEditorActivity fragment2 = new VideoEditorActivity(args2);
|
actionBarLayout.presentFragment(fragment, true);
|
||||||
fragment2.setDelegate(fragment);
|
}
|
||||||
presentFragment(fragment2, true, true);
|
} else if (!AndroidUtilities.isTablet()) {
|
||||||
if (!AndroidUtilities.isTablet()) {
|
|
||||||
actionBarLayout.addFragmentToStack(fragment, actionBarLayout.fragmentsStack.size() - 1);
|
actionBarLayout.addFragmentToStack(fragment, actionBarLayout.fragmentsStack.size() - 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -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>();
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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>
|
|
|
@ -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>
|
|
Loading…
Reference in a new issue