mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 14:35:03 +01:00
Fixed RTL name position in messages
This commit is contained in:
parent
aa5ff577c4
commit
ea8f92441c
7 changed files with 18 additions and 11 deletions
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.telegram.messenger"
|
||||
android:versionCode="175"
|
||||
android:versionCode="177"
|
||||
android:versionName="1.3.26">
|
||||
|
||||
<supports-screens android:anyDensity="true"
|
||||
|
|
|
@ -35,6 +35,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
|||
public static String APP_HASH = "5bce48dc7d331e62c955669eb7233217";
|
||||
public static String HOCKEY_APP_HASH = "your-hockeyapp-api-key-here";
|
||||
public static String GCM_SENDER_ID = "760348033672";
|
||||
public static String SEND_LOGS_EMAIL = "email@gmail.com";
|
||||
|
||||
private HashMap<Integer, Datacenter> datacenters = new HashMap<Integer, Datacenter>();
|
||||
private HashMap<Long, ArrayList<Long>> processedMessageIdsSet = new HashMap<Long, ArrayList<Long>>();
|
||||
|
|
|
@ -376,9 +376,9 @@ public class MessageObject {
|
|||
textLayoutBlocks = new ArrayList<TextLayoutBlock>();
|
||||
|
||||
if (messageText instanceof Spannable) {
|
||||
if (messageOwner.message != null && messageOwner.message.contains(".")) {
|
||||
if (messageOwner.message != null && messageOwner.message.contains(".") && (messageOwner.message.contains(".com") || messageOwner.message.contains("http") || messageOwner.message.contains(".ru") || messageOwner.message.contains(".org") || messageOwner.message.contains(".net"))) {
|
||||
Linkify.addLinks((Spannable)messageText, Linkify.WEB_URLS);
|
||||
} else if (messageText.length() < 400) {
|
||||
} else if (messageText.length() < 100) {
|
||||
Linkify.addLinks((Spannable)messageText, Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES | Linkify.PHONE_NUMBERS);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ public class ChatBaseCell extends BaseCell {
|
|||
|
||||
private StaticLayout nameLayout;
|
||||
protected int nameWidth;
|
||||
private float nameOffsetX = 0;
|
||||
protected boolean drawName = false;
|
||||
|
||||
private StaticLayout forwardedNameLayout;
|
||||
|
@ -75,6 +76,7 @@ public class ChatBaseCell extends BaseCell {
|
|||
protected boolean drawForwardedName = false;
|
||||
private int forwardNameX;
|
||||
private int forwardNameY;
|
||||
private float forwardNameOffsetX = 0;
|
||||
|
||||
private StaticLayout timeLayout;
|
||||
protected int timeWidth;
|
||||
|
@ -218,6 +220,7 @@ public class ChatBaseCell extends BaseCell {
|
|||
if (nameLayout.getLineCount() > 0) {
|
||||
nameWidth = (int)Math.ceil(nameLayout.getLineWidth(0));
|
||||
namesOffset += Utilities.dp(18);
|
||||
nameOffsetX = nameLayout.getLineLeft(0);
|
||||
} else {
|
||||
nameWidth = 0;
|
||||
}
|
||||
|
@ -240,6 +243,7 @@ public class ChatBaseCell extends BaseCell {
|
|||
if (forwardedNameLayout.getLineCount() > 1) {
|
||||
forwardedNameWidth = Math.max((int) Math.ceil(forwardedNameLayout.getLineWidth(0)), (int) Math.ceil(forwardedNameLayout.getLineWidth(1)));
|
||||
namesOffset += Utilities.dp(36);
|
||||
forwardNameOffsetX = Math.min(forwardedNameLayout.getLineLeft(0), forwardedNameLayout.getLineLeft(1));
|
||||
} else {
|
||||
forwardedNameWidth = 0;
|
||||
}
|
||||
|
@ -381,7 +385,7 @@ public class ChatBaseCell extends BaseCell {
|
|||
|
||||
if (drawName && nameLayout != null) {
|
||||
canvas.save();
|
||||
canvas.translate(currentBackgroundDrawable.getBounds().left + Utilities.dp(19), Utilities.dp(10));
|
||||
canvas.translate(currentBackgroundDrawable.getBounds().left + Utilities.dp(19) - nameOffsetX, Utilities.dp(10));
|
||||
namePaint.setColor(Utilities.getColorForId(currentUser.id));
|
||||
nameLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
|
@ -398,7 +402,7 @@ public class ChatBaseCell extends BaseCell {
|
|||
forwardNameX = currentBackgroundDrawable.getBounds().left + Utilities.dp(19);
|
||||
forwardNameY = Utilities.dp(10 + (drawName ? 18 : 0));
|
||||
}
|
||||
canvas.translate(forwardNameX, forwardNameY);
|
||||
canvas.translate(forwardNameX - forwardNameOffsetX, forwardNameY);
|
||||
forwardedNameLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import android.content.Context;
|
|||
import android.graphics.Canvas;
|
||||
import android.text.Spannable;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import org.telegram.messenger.Utilities;
|
||||
|
@ -30,6 +29,8 @@ public class ChatMessageCell extends ChatBaseCell {
|
|||
private int firstVisibleBlockNum = 0;
|
||||
private int totalVisibleBlocksCount = 0;
|
||||
|
||||
private boolean wasLayout = false;
|
||||
|
||||
public ChatMessageCell(Context context, boolean isChat) {
|
||||
super(context, isChat);
|
||||
drawForwardedName = true;
|
||||
|
@ -88,9 +89,6 @@ public class ChatMessageCell extends ChatBaseCell {
|
|||
public void setVisiblePart(int position, int height) {
|
||||
visibleY = position;
|
||||
visibleHeight = height;
|
||||
if (visibleY < 0) {
|
||||
Log.e("tmessages", "vis = " + visibleY);
|
||||
}
|
||||
|
||||
int newFirst = -1, newLast = -1, newCount = 0;
|
||||
|
||||
|
@ -126,6 +124,7 @@ public class ChatMessageCell extends ChatBaseCell {
|
|||
@Override
|
||||
public void setMessageObject(MessageObject messageObject) {
|
||||
if (currentMessageObject != messageObject || isUserDataChanged()) {
|
||||
wasLayout = false;
|
||||
pressedLink = null;
|
||||
int maxWidth;
|
||||
if (chat) {
|
||||
|
@ -173,7 +172,7 @@ public class ChatMessageCell extends ChatBaseCell {
|
|||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
|
||||
if (changed) {
|
||||
if (changed || !wasLayout) {
|
||||
if (currentMessageObject.messageOwner.out) {
|
||||
textX = layoutWidth - backgroundWidth + Utilities.dp(10);
|
||||
textY = Utilities.dp(10) + namesOffset;
|
||||
|
@ -181,6 +180,7 @@ public class ChatMessageCell extends ChatBaseCell {
|
|||
textX = Utilities.dp(19) + (chat ? Utilities.dp(52) : 0);
|
||||
textY = Utilities.dp(10) + namesOffset;
|
||||
}
|
||||
wasLayout = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2897,6 +2897,8 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
|||
view.setBackgroundColor(0);
|
||||
}
|
||||
|
||||
cell.setMessageObject(cell.getMessageObject());
|
||||
|
||||
cell.setCheckPressed(!disableSelection, disableSelection && selected);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -456,7 +456,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
}
|
||||
Intent i = new Intent(Intent.ACTION_SEND_MULTIPLE);
|
||||
i.setType("message/rfc822") ;
|
||||
i.putExtra(Intent.EXTRA_EMAIL, new String[]{"drklo.2kb@gmail.com"});
|
||||
i.putExtra(Intent.EXTRA_EMAIL, new String[]{ConnectionsManager.SEND_LOGS_EMAIL});
|
||||
i.putExtra(Intent.EXTRA_SUBJECT, "last logs");
|
||||
i.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
|
||||
startActivity(Intent.createChooser(i, "Select email application."));
|
||||
|
|
Loading…
Reference in a new issue