1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-30 13:12:25 -05:00

Merge branch 'messageheader'

This commit is contained in:
cketti 2012-03-06 05:26:11 +01:00
commit a089fadd9a
4 changed files with 120 additions and 55 deletions

View File

@ -17,7 +17,7 @@
android:layout_height="wrap_content"
android:stretchColumns="1"
android:shrinkColumns="1"
android:background="@color/message_view_header_background">
android:background="@drawable/message_view_header_background">
<TableRow>
@ -30,6 +30,7 @@
<LinearLayout
android:paddingTop="2dip"
android:paddingBottom="3dip"
android:layout_column="1"
android:layout_height="wrap_content"
android:orientation="vertical">
@ -134,14 +135,56 @@
</LinearLayout>
<!-- Dummy column that is used to ensure the height of the table row is large
enough to fit the date/time column -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Date/Time + Icons -->
<!-- Fixed spacing -->
<View
android:layout_width="0dp"
android:layout_height="18dp"/>
<!-- We don't want to hardcode the height of the star. The minHeight
is that of 'answered'. -->
<CheckBox
android:layout_width="0dp"
android:layout_height="wrap_content"
android:minHeight="22sp"
android:focusable="false"
style="?android:attr/starStyle"/>
<!-- Two text views that will be set to the same height as their
counterparts in the next colum -->
<TextView
android:id="@+id/dummy_date"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:singleLine="true"/>
<TextView
android:id="@+id/dummy_time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="10sp"
android:singleLine="true"/>
</LinearLayout>
<!-- Date/Time + Icons
The height of this column is 'fill_parent' so we can put the show more/less
indicator at the bottom. Unfortunately using 'fill_parent' also means that
the views in this column will be cut of if their combined height exceeds
that of the highest non-'fill_parent' column. That's why we need the dummy
column above. -->
<LinearLayout
android:id="@+id/topright_container"
android:layout_marginTop="2dip"
android:layout_marginRight="6dip"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="6dp"
android:gravity="right">
@ -188,58 +231,33 @@
android:textColor="?android:attr/textColorPrimary"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<!-- View that will take up all available space between the time and
the show more/less indicator -->
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>
<ImageView
android:id="@+id/show_additional_headers_icon"
android:src="@drawable/show_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="6dp"
android:layout_marginBottom="3dip"/>
</LinearLayout>
</TableRow>
</TableLayout>
<!-- Separator -->
<!-- This layout has an explicit height because otherwise there will be strange
display issues when the additional headers are shown. -->
<LinearLayout
android:id="@+id/show_additional_headers_area"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="21.5dp"
android:focusable="true"
android:clickable="true"
android:background="@drawable/separator_area_background">
<RelativeLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="20dp">
<!-- Color chip 2 -->
<View
android:id="@+id/chip2"
android:layout_marginRight="6dip"
android:layout_width="6dip"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"/>
<!-- Show more/less indicator -->
<ImageView
android:id="@+id/show_additional_headers_icon"
android:src="@drawable/show_more"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginRight="12dp"/>
</RelativeLayout>
<View
android:id="@+id/separator"
android:layout_width="fill_parent"
android:layout_height="1.5dp"
android:background="#59000000"/>
</LinearLayout>
<!-- Button area -->
<LinearLayout
android:layout_width="fill_parent"

View File

@ -49,7 +49,6 @@ public class MessageHeader extends ScrollView implements OnClickListener {
private DateFormat mTimeFormat;
private View mChip;
private View mChip2;
private CheckBox mFlagged;
private int defaultSubjectColor;
private LinearLayout mToContainerView;
@ -63,6 +62,8 @@ public class MessageHeader extends ScrollView implements OnClickListener {
private ImageView mShowAdditionalHeadersIcon;
private SavedState mSavedState;
private OnLayoutChangedListener mOnLayoutChangedListener;
/**
* Pair class is only available since API Level 5, so we need
* this helper class unfortunately
@ -95,13 +96,11 @@ public class MessageHeader extends ScrollView implements OnClickListener {
mSubjectView = (TextView) findViewById(R.id.subject);
mAdditionalHeadersView = (TextView) findViewById(R.id.additional_headers_view);
mChip = findViewById(R.id.chip);
mChip2 = findViewById(R.id.chip2);
mDateView = (TextView) findViewById(R.id.date);
mTimeView = (TextView) findViewById(R.id.time);
mFlagged = (CheckBox) findViewById(R.id.flagged);
mShowAdditionalHeadersIcon = (ImageView) findViewById(R.id.show_additional_headers_icon);
defaultSubjectColor = mSubjectView.getCurrentTextColor();
mSubjectView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageViewSubject());
mTimeView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageViewTime());
@ -116,14 +115,19 @@ public class MessageHeader extends ScrollView implements OnClickListener {
((TextView) findViewById(R.id.to_label)).setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageViewTo());
((TextView) findViewById(R.id.cc_label)).setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageViewCC());
findViewById(R.id.show_additional_headers_area).setOnClickListener(this);
mFromView.setOnClickListener(this);
findViewById(R.id.top_container).setOnClickListener(this);
TextView dummyDateView = (TextView) findViewById(R.id.dummy_date);
TextView dummyTimeView = (TextView) findViewById(R.id.dummy_time);
dummyTimeView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageViewTime());
dummyDateView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageViewDate());
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.show_additional_headers_area: {
case R.id.top_container: {
onShowAdditionalHeaders();
break;
}
@ -131,6 +135,11 @@ public class MessageHeader extends ScrollView implements OnClickListener {
onAddSenderToContacts();
break;
}
case R.id.to:
case R.id.cc: {
expand((TextView)view, ((TextView)view).getEllipsize() != null);
layoutChanged();
}
}
}
@ -250,8 +259,6 @@ public class MessageHeader extends ScrollView implements OnClickListener {
int chipColorAlpha = (!message.isSet(Flag.SEEN)) ? 255 : 127;
mChip.setBackgroundColor(chipColor);
mChip.getBackground().setAlpha(chipColorAlpha);
mChip2.setBackgroundColor(chipColor);
mChip2.getBackground().setAlpha(chipColorAlpha);
setVisibility(View.VISIBLE);
@ -269,8 +276,26 @@ public class MessageHeader extends ScrollView implements OnClickListener {
int currentVisibility = mAdditionalHeadersView.getVisibility();
if (currentVisibility == View.VISIBLE) {
hideAdditionalHeaders();
expand(mToView, false);
expand(mCcView, false);
} else {
showAdditionalHeaders();
expand(mToView, true);
expand(mCcView, true);
}
layoutChanged();
}
/**
* Expand or collapse a TextView by removing or adding the 2 lines limitation
*/
private void expand(TextView v, boolean expand) {
if (expand) {
v.setMaxLines(Integer.MAX_VALUE);
v.setEllipsize(null);
} else {
v.setMaxLines(2);
v.setEllipsize(android.text.TextUtils.TruncateAt.END);
}
}
@ -378,4 +403,18 @@ public class MessageHeader extends ScrollView implements OnClickListener {
out.writeInt((this.additionalHeadersVisible) ? 1 : 0);
}
}
public interface OnLayoutChangedListener {
void onLayoutChanged();
}
public void setOnLayoutChangedListener(OnLayoutChangedListener listener) {
mOnLayoutChangedListener = listener;
}
private void layoutChanged() {
if (mOnLayoutChangedListener != null) {
mOnLayoutChangedListener.onLayoutChanged();
}
}
}

View File

@ -33,7 +33,8 @@ import com.fsck.k9.mail.store.LocalStore.LocalMessage;
import java.util.List;
public class SingleMessageView extends LinearLayout implements OnClickListener {
public class SingleMessageView extends LinearLayout implements OnClickListener,
MessageHeader.OnLayoutChangedListener {
private boolean mScreenReaderEnabled;
private MessageCryptoView mCryptoView;
private MessageWebView mMessageContentView;
@ -65,6 +66,7 @@ public class SingleMessageView extends LinearLayout implements OnClickListener {
mHeaderPlaceHolder = (LinearLayout) findViewById(R.id.message_view_header_container);
mHeaderContainer = (MessageHeader) findViewById(R.id.header_container);
mHeaderContainer.setOnLayoutChangedListener(this);
mAttachmentsContainer = findViewById(R.id.attachments_container);
mInsideAttachmentsContainer = (LinearLayout) findViewById(R.id.inside_attachments_container);
@ -508,6 +510,12 @@ public class SingleMessageView extends LinearLayout implements OnClickListener {
mSavedState = savedState;
}
public void onLayoutChanged() {
if (mMessageContentView != null) {
mMessageContentView.invalidate();
}
}
static class SavedState extends BaseSavedState {
boolean attachmentViewVisible;
boolean hiddenAttachmentsVisible;