mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-11 13:49:15 -05:00
message view: fix subject bugs
- Android does not support ellipsize in combination with maxlines for TextViews. This caused getEllipsisCount() in MessageTitleView to always fail, and the full subject was never shown in the regular headers area when needed. To work around that, check for ourselves whether the text is longer than 2, and ellipsize manually. - Clicking the star button on a message caused the subject line to re-appear, even if it fits in the action bar title without being cut off. This was caused by MessageHeader.populate(), which always set the subject to visible. As a workaround: Only set subject to visible in case populate() actually shows a new message. - delete res/layout/actionbar_message_view.xml, its already present in the actionbar_custom.xml
This commit is contained in:
parent
865151fef8
commit
8d4a82ba0e
@ -63,9 +63,7 @@
|
||||
android:id="@+id/message_title_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="2"
|
||||
android:textSize="16sp" />
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -63,9 +63,7 @@
|
||||
android:id="@+id/message_title_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="2"
|
||||
android:textSize="16sp" />
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -1,17 +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="horizontal" >
|
||||
|
||||
<com.fsck.k9.view.MessageTitleView
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:textSize="16sp"
|
||||
android:includeFontPadding="false"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
@ -128,11 +128,6 @@ public class MessageHeader extends ScrollView implements OnClickListener {
|
||||
|
||||
mMessageHelper = MessageHelper.getInstance(mContext);
|
||||
|
||||
|
||||
resetViews();
|
||||
}
|
||||
|
||||
private void resetViews() {
|
||||
mSubjectView.setVisibility(VISIBLE);
|
||||
hideAdditionalHeaders();
|
||||
}
|
||||
@ -250,10 +245,20 @@ public class MessageHeader extends ScrollView implements OnClickListener {
|
||||
counterpartyAddress = fromAddrs[0].getAddress();
|
||||
}
|
||||
|
||||
/*
|
||||
* Only reset visibility of the subject if populate() was called because a new
|
||||
* message is shown. If it is the same, do not force the subject visible, because
|
||||
* this breaks the MessageTitleView in the action bar, which may hide our subject
|
||||
* if it fits in the action bar but is only called when a new message is shown
|
||||
* or the device is rotated.
|
||||
*/
|
||||
if (mMessage == null || mMessage.getId() != message.getId()) {
|
||||
mSubjectView.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
mMessage = message;
|
||||
mAccount = account;
|
||||
|
||||
resetViews();
|
||||
if (K9.showContactPicture()) {
|
||||
mContactBadge.setVisibility(View.VISIBLE);
|
||||
mContactsPictureLoader = new ContactPictureLoader(mContext, R.drawable.ic_contact_picture);
|
||||
|
@ -12,7 +12,11 @@ import android.widget.TextView;
|
||||
* action bar's title view.
|
||||
*/
|
||||
public class MessageTitleView extends TextView {
|
||||
private static final int MAX_LINES = 2;
|
||||
private static final String ELLIPSIS = "\u2026";
|
||||
|
||||
private MessageHeader mHeader;
|
||||
private boolean mNeedEllipsizeCheck = true;
|
||||
|
||||
public MessageTitleView(Context context) {
|
||||
this(context, null);
|
||||
@ -26,13 +30,32 @@ public class MessageTitleView extends TextView {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTextChanged(CharSequence text, int start,
|
||||
int lengthBefore, int lengthAfter) {
|
||||
super.onTextChanged(text, start, lengthBefore, lengthAfter);
|
||||
mNeedEllipsizeCheck = true;
|
||||
}
|
||||
/**
|
||||
* Check to see if we need to hide the subject line in {@link MessageHeader} or not.
|
||||
*/
|
||||
@Override
|
||||
public void onDraw(Canvas canvas) {
|
||||
if (mHeader != null && getLayout() != null && getLayout().getEllipsisCount(1) == 0) {
|
||||
mHeader.hideSubjectLine();
|
||||
/*
|
||||
* Android does not support ellipsize in combination with maxlines
|
||||
* for TextViews. To work around that, check for ourselves whether
|
||||
* the text is longer than MAX_LINES, and ellipsize manually.
|
||||
*/
|
||||
if (mNeedEllipsizeCheck) {
|
||||
if (getLayout() != null && mHeader != null) {
|
||||
if (getLayout().getLineCount() > MAX_LINES) {
|
||||
int lineEndIndex = getLayout().getLineEnd(MAX_LINES - 1);
|
||||
setText(getText().subSequence(0, lineEndIndex - 2) + ELLIPSIS);
|
||||
} else {
|
||||
mHeader.hideSubjectLine();
|
||||
}
|
||||
mNeedEllipsizeCheck = false;
|
||||
}
|
||||
}
|
||||
super.onDraw(canvas);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user