Fixed RTL name position in messages

This commit is contained in:
DrKLO 2014-03-02 13:23:06 +04:00
parent aa5ff577c4
commit ea8f92441c
7 changed files with 18 additions and 11 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.telegram.messenger" package="org.telegram.messenger"
android:versionCode="175" android:versionCode="177"
android:versionName="1.3.26"> android:versionName="1.3.26">
<supports-screens android:anyDensity="true" <supports-screens android:anyDensity="true"

View file

@ -35,6 +35,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
public static String APP_HASH = "5bce48dc7d331e62c955669eb7233217"; public static String APP_HASH = "5bce48dc7d331e62c955669eb7233217";
public static String HOCKEY_APP_HASH = "your-hockeyapp-api-key-here"; public static String HOCKEY_APP_HASH = "your-hockeyapp-api-key-here";
public static String GCM_SENDER_ID = "760348033672"; 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<Integer, Datacenter> datacenters = new HashMap<Integer, Datacenter>();
private HashMap<Long, ArrayList<Long>> processedMessageIdsSet = new HashMap<Long, ArrayList<Long>>(); private HashMap<Long, ArrayList<Long>> processedMessageIdsSet = new HashMap<Long, ArrayList<Long>>();

View file

@ -376,9 +376,9 @@ public class MessageObject {
textLayoutBlocks = new ArrayList<TextLayoutBlock>(); textLayoutBlocks = new ArrayList<TextLayoutBlock>();
if (messageText instanceof Spannable) { 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); 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); Linkify.addLinks((Spannable)messageText, Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES | Linkify.PHONE_NUMBERS);
} }
} }

View file

@ -68,6 +68,7 @@ public class ChatBaseCell extends BaseCell {
private StaticLayout nameLayout; private StaticLayout nameLayout;
protected int nameWidth; protected int nameWidth;
private float nameOffsetX = 0;
protected boolean drawName = false; protected boolean drawName = false;
private StaticLayout forwardedNameLayout; private StaticLayout forwardedNameLayout;
@ -75,6 +76,7 @@ public class ChatBaseCell extends BaseCell {
protected boolean drawForwardedName = false; protected boolean drawForwardedName = false;
private int forwardNameX; private int forwardNameX;
private int forwardNameY; private int forwardNameY;
private float forwardNameOffsetX = 0;
private StaticLayout timeLayout; private StaticLayout timeLayout;
protected int timeWidth; protected int timeWidth;
@ -218,6 +220,7 @@ public class ChatBaseCell extends BaseCell {
if (nameLayout.getLineCount() > 0) { if (nameLayout.getLineCount() > 0) {
nameWidth = (int)Math.ceil(nameLayout.getLineWidth(0)); nameWidth = (int)Math.ceil(nameLayout.getLineWidth(0));
namesOffset += Utilities.dp(18); namesOffset += Utilities.dp(18);
nameOffsetX = nameLayout.getLineLeft(0);
} else { } else {
nameWidth = 0; nameWidth = 0;
} }
@ -240,6 +243,7 @@ public class ChatBaseCell extends BaseCell {
if (forwardedNameLayout.getLineCount() > 1) { if (forwardedNameLayout.getLineCount() > 1) {
forwardedNameWidth = Math.max((int) Math.ceil(forwardedNameLayout.getLineWidth(0)), (int) Math.ceil(forwardedNameLayout.getLineWidth(1))); forwardedNameWidth = Math.max((int) Math.ceil(forwardedNameLayout.getLineWidth(0)), (int) Math.ceil(forwardedNameLayout.getLineWidth(1)));
namesOffset += Utilities.dp(36); namesOffset += Utilities.dp(36);
forwardNameOffsetX = Math.min(forwardedNameLayout.getLineLeft(0), forwardedNameLayout.getLineLeft(1));
} else { } else {
forwardedNameWidth = 0; forwardedNameWidth = 0;
} }
@ -381,7 +385,7 @@ public class ChatBaseCell extends BaseCell {
if (drawName && nameLayout != null) { if (drawName && nameLayout != null) {
canvas.save(); 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)); namePaint.setColor(Utilities.getColorForId(currentUser.id));
nameLayout.draw(canvas); nameLayout.draw(canvas);
canvas.restore(); canvas.restore();
@ -398,7 +402,7 @@ public class ChatBaseCell extends BaseCell {
forwardNameX = currentBackgroundDrawable.getBounds().left + Utilities.dp(19); forwardNameX = currentBackgroundDrawable.getBounds().left + Utilities.dp(19);
forwardNameY = Utilities.dp(10 + (drawName ? 18 : 0)); forwardNameY = Utilities.dp(10 + (drawName ? 18 : 0));
} }
canvas.translate(forwardNameX, forwardNameY); canvas.translate(forwardNameX - forwardNameOffsetX, forwardNameY);
forwardedNameLayout.draw(canvas); forwardedNameLayout.draw(canvas);
canvas.restore(); canvas.restore();
} }

View file

@ -12,7 +12,6 @@ import android.content.Context;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.text.Spannable; import android.text.Spannable;
import android.text.style.ClickableSpan; import android.text.style.ClickableSpan;
import android.util.Log;
import android.view.MotionEvent; import android.view.MotionEvent;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
@ -30,6 +29,8 @@ public class ChatMessageCell extends ChatBaseCell {
private int firstVisibleBlockNum = 0; private int firstVisibleBlockNum = 0;
private int totalVisibleBlocksCount = 0; private int totalVisibleBlocksCount = 0;
private boolean wasLayout = false;
public ChatMessageCell(Context context, boolean isChat) { public ChatMessageCell(Context context, boolean isChat) {
super(context, isChat); super(context, isChat);
drawForwardedName = true; drawForwardedName = true;
@ -88,9 +89,6 @@ public class ChatMessageCell extends ChatBaseCell {
public void setVisiblePart(int position, int height) { public void setVisiblePart(int position, int height) {
visibleY = position; visibleY = position;
visibleHeight = height; visibleHeight = height;
if (visibleY < 0) {
Log.e("tmessages", "vis = " + visibleY);
}
int newFirst = -1, newLast = -1, newCount = 0; int newFirst = -1, newLast = -1, newCount = 0;
@ -126,6 +124,7 @@ public class ChatMessageCell extends ChatBaseCell {
@Override @Override
public void setMessageObject(MessageObject messageObject) { public void setMessageObject(MessageObject messageObject) {
if (currentMessageObject != messageObject || isUserDataChanged()) { if (currentMessageObject != messageObject || isUserDataChanged()) {
wasLayout = false;
pressedLink = null; pressedLink = null;
int maxWidth; int maxWidth;
if (chat) { if (chat) {
@ -173,7 +172,7 @@ public class ChatMessageCell extends ChatBaseCell {
protected void onLayout(boolean changed, int left, int top, int right, int bottom) { protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom); super.onLayout(changed, left, top, right, bottom);
if (changed) { if (changed || !wasLayout) {
if (currentMessageObject.messageOwner.out) { if (currentMessageObject.messageOwner.out) {
textX = layoutWidth - backgroundWidth + Utilities.dp(10); textX = layoutWidth - backgroundWidth + Utilities.dp(10);
textY = Utilities.dp(10) + namesOffset; textY = Utilities.dp(10) + namesOffset;
@ -181,6 +180,7 @@ public class ChatMessageCell extends ChatBaseCell {
textX = Utilities.dp(19) + (chat ? Utilities.dp(52) : 0); textX = Utilities.dp(19) + (chat ? Utilities.dp(52) : 0);
textY = Utilities.dp(10) + namesOffset; textY = Utilities.dp(10) + namesOffset;
} }
wasLayout = true;
} }
} }

View file

@ -2897,6 +2897,8 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
view.setBackgroundColor(0); view.setBackgroundColor(0);
} }
cell.setMessageObject(cell.getMessageObject());
cell.setCheckPressed(!disableSelection, disableSelection && selected); cell.setCheckPressed(!disableSelection, disableSelection && selected);
} }
} }

View file

@ -456,7 +456,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
} }
Intent i = new Intent(Intent.ACTION_SEND_MULTIPLE); Intent i = new Intent(Intent.ACTION_SEND_MULTIPLE);
i.setType("message/rfc822") ; 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.putExtra(Intent.EXTRA_SUBJECT, "last logs");
i.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); i.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
startActivity(Intent.createChooser(i, "Select email application.")); startActivity(Intent.createChooser(i, "Select email application."));