Show text 'Group image changed.' beside such action images.

This commit is contained in:
B. Petersen
2017-07-22 13:32:58 +02:00
parent 4a9f9eefd2
commit e365a20d6e
3 changed files with 22 additions and 14 deletions
@@ -58,6 +58,8 @@ public class MrMsg {
public final static int MR_MSG_ID_MARKER1 = 1;
public final static int MR_MSG_ID_DAYMARKER = 9;
public final static int MR_SYSTEM_GROUPIMAGE_CHANGED = 3; // this is very special: all other commands do not need a special handling as the performed action is already explained in the normal text field (which does not exist for images)
public MrMsg(long hMsg) {
m_hMsg = hMsg;
}
@@ -152,6 +154,7 @@ public class MrMsg {
ret.out = ret.from_id==MrContact.MR_CONTACT_ID_SELF; // true=outgoing message, read eg. in MessageObject.isOutOwner()
ret.created_by_mr = true;
ret.e2ee = getParamInt('c', 0)!=0;
ret.system_cmd = getParamInt('S', 0);
if( type == MR_MSG_TEXT ) {
ret.message = getText();
@@ -292,6 +292,7 @@ public class TLRPC {
public final int layer = 0; //custom
public boolean created_by_mr;
public boolean e2ee;
public int system_cmd;
}
public static class TL_message extends Message {
@@ -55,6 +55,7 @@ import com.b44t.messenger.MessageObject;
import com.b44t.messenger.MrChat;
import com.b44t.messenger.MrContact;
import com.b44t.messenger.MrMailbox;
import com.b44t.messenger.MrMsg;
import com.b44t.messenger.MrPoortext;
import com.b44t.messenger.R;
import com.b44t.messenger.TLRPC;
@@ -1077,12 +1078,12 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
int minutes = duration / 60;
int seconds = duration - minutes * 60;
String str = String.format("%d:%02d, %s", minutes, seconds, formatFileSize(documentAttach.size));
String infoString = String.format("%d:%02d, %s", minutes, seconds, formatFileSize(documentAttach.size));
if( MrMailbox.getMsg(messageObject.getId()).isIncreation()!=0 ) {
str = ApplicationLoader.applicationContext.getString(R.string.OneMoment);
infoString = ApplicationLoader.applicationContext.getString(R.string.OneMoment);
}
infoWidth = (int) Math.ceil(infoPaint.measureText(str));
infoLayout = new StaticLayout(str, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
infoWidth = (int) Math.ceil(infoPaint.measureText(infoString));
infoLayout = new StaticLayout(infoString, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
}
else
{
@@ -1107,17 +1108,14 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
docTitleOffsetX = 0;
}
String str = formatFileSize(documentAttach.size) + " " + FileLoader.getDocumentExtension(documentAttach);
infoWidth = Math.min(maxWidth - AndroidUtilities.dp(30), (int) Math.ceil(infoPaint.measureText(str)));
CharSequence str2 = TextUtils.ellipsize(str, infoPaint, infoWidth, TextUtils.TruncateAt.END);
try {
if (infoWidth < 0) {
infoWidth = dp(10);
}
infoLayout = new StaticLayout(str2, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
} catch (Exception e) {
String infoString = formatFileSize(documentAttach.size) + " " + FileLoader.getDocumentExtension(documentAttach);
infoWidth = Math.min(maxWidth - AndroidUtilities.dp(30), (int) Math.ceil(infoPaint.measureText(infoString)));
CharSequence str2 = TextUtils.ellipsize(infoString, infoPaint, infoWidth, TextUtils.TruncateAt.END);
if (infoWidth < 0) {
infoWidth = dp(10);
}
infoLayout = new StaticLayout(str2, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
if (drawPhotoImage) {
currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, getPhotoSize());
@@ -1411,6 +1409,12 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
if (messageObject.type == MessageObject.MO_TYPE1_PHOTO) {
currentPhotoObjectThumb = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 80);
if( messageObject.messageOwner.system_cmd == MrMsg.MR_SYSTEM_GROUPIMAGE_CHANGED ) {
String infoString = ApplicationLoader.applicationContext.getString(R.string.MsgGroupImageChanged);
infoWidth = (int) Math.ceil(infoPaint.measureText(infoString));
infoLayout = new StaticLayout(infoString, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
}
} else if (messageObject.type == MessageObject.MO_TYPE3_VIDEO) {
createDocumentLayout(0, messageObject);
photoImage.setNeedsQualityThumb(true);
@@ -1839,7 +1843,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
else if (currentMessageObject.type == MessageObject.MO_TYPE1_PHOTO || documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO) {
if (photoImage.getVisible()) {
if (infoLayout != null && (buttonState == BS1_CLICK_TO_PAUSE || buttonState == BS0_CLICK_TO_PLAY || buttonState == BS3_NORMAL)) {
if (infoLayout != null /*&& (buttonState == BS1_CLICK_TO_PAUSE || buttonState == BS0_CLICK_TO_PLAY || buttonState == BS3_NORMAL)*/) {
infoPaint.setColor(Theme.MSG_MEDIA_INFO_TEXT_COLOR);
setDrawableBounds(Theme.timeBackgroundDrawable, photoImage.getImageX() + dp(4), photoImage.getImageY() + dp(4), infoWidth + dp(8), dp(16.5f));
Theme.timeBackgroundDrawable.draw(canvas);