1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-08-13 17:03:48 -04:00

Message header changes

* remove expand/collapse arrows, instead use the background area of the header to toggle
* allow expanding of To: and Cc: texts when too long and cut off by clicking on them
This commit is contained in:
m0viefreak 2012-03-02 05:41:01 +01:00
parent f1baa8f461
commit 8d12244a9c
3 changed files with 31 additions and 56 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>
@ -194,51 +194,11 @@
</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"
<View
android:id="@+id/separator"
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>
android:layout_height="1.5dp"
android:background="#59000000"/>
<!-- Button area -->
<LinearLayout

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;
@ -60,7 +59,6 @@ public class MessageHeader extends ScrollView implements OnClickListener {
private Account mAccount;
private FontSizes mFontSizes = K9.getFontSizes();
private Contacts mContacts;
private ImageView mShowAdditionalHeadersIcon;
private SavedState mSavedState;
private OnLayoutChangedListener mOnLayoutChangedListener;
@ -97,12 +95,9 @@ 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());
@ -118,14 +113,16 @@ 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);
mToView.setOnClickListener(this);
mCcView.setOnClickListener(this);
mFromView.setOnClickListener(this);
findViewById(R.id.top_container).setOnClickListener(this);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.show_additional_headers_area: {
case R.id.top_container: {
onShowAdditionalHeaders();
break;
}
@ -133,6 +130,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();
}
}
}
@ -166,7 +168,6 @@ public class MessageHeader extends ScrollView implements OnClickListener {
private void hideAdditionalHeaders() {
mAdditionalHeadersView.setVisibility(View.GONE);
mAdditionalHeadersView.setText("");
mShowAdditionalHeadersIcon.setImageResource(R.drawable.show_more);
}
@ -185,7 +186,6 @@ public class MessageHeader extends ScrollView implements OnClickListener {
// Show the additional headers that we have got.
populateAdditionalHeadersView(additionalHeaders);
mAdditionalHeadersView.setVisibility(View.VISIBLE);
mShowAdditionalHeadersIcon.setImageResource(R.drawable.show_less);
}
if (!allHeadersDownloaded) {
/*
@ -252,8 +252,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);
@ -271,12 +269,29 @@ 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);
}
}
private List<HeaderEntry> getAdditionalHeaders(final Message message)
throws MessagingException {
List<HeaderEntry> additionalHeaders = new LinkedList<HeaderEntry>();