2012-09-07 23:33:53 -04:00
|
|
|
package com.fsck.k9.view;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.graphics.Canvas;
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
/**
|
2013-01-31 20:50:00 -05:00
|
|
|
* This {@link TextView} is used in the custom view of the {@link com.fsck.k9.activity.MessageList}
|
|
|
|
* action bar.
|
|
|
|
* It will hide the subject line in {@link MessageHeader} if the subject fits completely into the
|
|
|
|
* action bar's title view.
|
2012-09-07 23:33:53 -04:00
|
|
|
*/
|
|
|
|
public class MessageTitleView extends TextView {
|
|
|
|
private MessageHeader mHeader;
|
|
|
|
|
|
|
|
public MessageTitleView(Context context) {
|
|
|
|
this(context, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public MessageTitleView(Context context, AttributeSet attrs) {
|
|
|
|
this(context, attrs, android.R.attr.textViewStyle);
|
|
|
|
}
|
|
|
|
|
|
|
|
public MessageTitleView(Context context, AttributeSet attrs, int defStyle) {
|
|
|
|
super(context, attrs, defStyle);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-01-31 20:50:00 -05:00
|
|
|
* Check to see if we need to hide the subject line in {@link MessageHeader} or not.
|
2012-09-07 23:33:53 -04:00
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void onDraw(Canvas canvas) {
|
2013-01-31 20:50:00 -05:00
|
|
|
if (mHeader != null && getLayout() != null && getLayout().getEllipsisCount(1) == 0) {
|
|
|
|
mHeader.hideSubjectLine();
|
2012-09-07 23:33:53 -04:00
|
|
|
}
|
|
|
|
super.onDraw(canvas);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setMessageHeader(final MessageHeader header) {
|
2013-01-31 20:50:00 -05:00
|
|
|
mHeader = header;
|
2012-09-07 23:33:53 -04:00
|
|
|
}
|
|
|
|
}
|