mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-17 07:30:16 -05: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:
parent
f1baa8f461
commit
8d12244a9c
@ -17,7 +17,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:stretchColumns="1"
|
android:stretchColumns="1"
|
||||||
android:shrinkColumns="1"
|
android:shrinkColumns="1"
|
||||||
android:background="@color/message_view_header_background">
|
android:background="@drawable/message_view_header_background">
|
||||||
|
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
|
||||||
@ -194,51 +194,11 @@
|
|||||||
|
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
|
|
||||||
<!-- Separator -->
|
<View
|
||||||
<!-- This layout has an explicit height because otherwise there will be strange
|
android:id="@+id/separator"
|
||||||
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_width="fill_parent"
|
||||||
android:layout_height="21.5dp"
|
android:layout_height="1.5dp"
|
||||||
android:focusable="true"
|
android:background="#59000000"/>
|
||||||
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 -->
|
<!-- Button area -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -49,7 +49,6 @@ public class MessageHeader extends ScrollView implements OnClickListener {
|
|||||||
private DateFormat mTimeFormat;
|
private DateFormat mTimeFormat;
|
||||||
|
|
||||||
private View mChip;
|
private View mChip;
|
||||||
private View mChip2;
|
|
||||||
private CheckBox mFlagged;
|
private CheckBox mFlagged;
|
||||||
private int defaultSubjectColor;
|
private int defaultSubjectColor;
|
||||||
private LinearLayout mToContainerView;
|
private LinearLayout mToContainerView;
|
||||||
@ -60,7 +59,6 @@ public class MessageHeader extends ScrollView implements OnClickListener {
|
|||||||
private Account mAccount;
|
private Account mAccount;
|
||||||
private FontSizes mFontSizes = K9.getFontSizes();
|
private FontSizes mFontSizes = K9.getFontSizes();
|
||||||
private Contacts mContacts;
|
private Contacts mContacts;
|
||||||
private ImageView mShowAdditionalHeadersIcon;
|
|
||||||
private SavedState mSavedState;
|
private SavedState mSavedState;
|
||||||
|
|
||||||
private OnLayoutChangedListener mOnLayoutChangedListener;
|
private OnLayoutChangedListener mOnLayoutChangedListener;
|
||||||
@ -97,12 +95,9 @@ public class MessageHeader extends ScrollView implements OnClickListener {
|
|||||||
mSubjectView = (TextView) findViewById(R.id.subject);
|
mSubjectView = (TextView) findViewById(R.id.subject);
|
||||||
mAdditionalHeadersView = (TextView) findViewById(R.id.additional_headers_view);
|
mAdditionalHeadersView = (TextView) findViewById(R.id.additional_headers_view);
|
||||||
mChip = findViewById(R.id.chip);
|
mChip = findViewById(R.id.chip);
|
||||||
mChip2 = findViewById(R.id.chip2);
|
|
||||||
mDateView = (TextView) findViewById(R.id.date);
|
mDateView = (TextView) findViewById(R.id.date);
|
||||||
mTimeView = (TextView) findViewById(R.id.time);
|
mTimeView = (TextView) findViewById(R.id.time);
|
||||||
mFlagged = (CheckBox) findViewById(R.id.flagged);
|
mFlagged = (CheckBox) findViewById(R.id.flagged);
|
||||||
mShowAdditionalHeadersIcon = (ImageView) findViewById(R.id.show_additional_headers_icon);
|
|
||||||
|
|
||||||
|
|
||||||
defaultSubjectColor = mSubjectView.getCurrentTextColor();
|
defaultSubjectColor = mSubjectView.getCurrentTextColor();
|
||||||
mSubjectView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageViewSubject());
|
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.to_label)).setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageViewTo());
|
||||||
((TextView) findViewById(R.id.cc_label)).setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageViewCC());
|
((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);
|
mFromView.setOnClickListener(this);
|
||||||
|
findViewById(R.id.top_container).setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
switch (view.getId()) {
|
switch (view.getId()) {
|
||||||
case R.id.show_additional_headers_area: {
|
case R.id.top_container: {
|
||||||
onShowAdditionalHeaders();
|
onShowAdditionalHeaders();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -133,6 +130,11 @@ public class MessageHeader extends ScrollView implements OnClickListener {
|
|||||||
onAddSenderToContacts();
|
onAddSenderToContacts();
|
||||||
break;
|
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() {
|
private void hideAdditionalHeaders() {
|
||||||
mAdditionalHeadersView.setVisibility(View.GONE);
|
mAdditionalHeadersView.setVisibility(View.GONE);
|
||||||
mAdditionalHeadersView.setText("");
|
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.
|
// Show the additional headers that we have got.
|
||||||
populateAdditionalHeadersView(additionalHeaders);
|
populateAdditionalHeadersView(additionalHeaders);
|
||||||
mAdditionalHeadersView.setVisibility(View.VISIBLE);
|
mAdditionalHeadersView.setVisibility(View.VISIBLE);
|
||||||
mShowAdditionalHeadersIcon.setImageResource(R.drawable.show_less);
|
|
||||||
}
|
}
|
||||||
if (!allHeadersDownloaded) {
|
if (!allHeadersDownloaded) {
|
||||||
/*
|
/*
|
||||||
@ -252,8 +252,6 @@ public class MessageHeader extends ScrollView implements OnClickListener {
|
|||||||
int chipColorAlpha = (!message.isSet(Flag.SEEN)) ? 255 : 127;
|
int chipColorAlpha = (!message.isSet(Flag.SEEN)) ? 255 : 127;
|
||||||
mChip.setBackgroundColor(chipColor);
|
mChip.setBackgroundColor(chipColor);
|
||||||
mChip.getBackground().setAlpha(chipColorAlpha);
|
mChip.getBackground().setAlpha(chipColorAlpha);
|
||||||
mChip2.setBackgroundColor(chipColor);
|
|
||||||
mChip2.getBackground().setAlpha(chipColorAlpha);
|
|
||||||
|
|
||||||
setVisibility(View.VISIBLE);
|
setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
@ -271,12 +269,29 @@ public class MessageHeader extends ScrollView implements OnClickListener {
|
|||||||
int currentVisibility = mAdditionalHeadersView.getVisibility();
|
int currentVisibility = mAdditionalHeadersView.getVisibility();
|
||||||
if (currentVisibility == View.VISIBLE) {
|
if (currentVisibility == View.VISIBLE) {
|
||||||
hideAdditionalHeaders();
|
hideAdditionalHeaders();
|
||||||
|
expand(mToView, false);
|
||||||
|
expand(mCcView, false);
|
||||||
} else {
|
} else {
|
||||||
showAdditionalHeaders();
|
showAdditionalHeaders();
|
||||||
|
expand(mToView, true);
|
||||||
|
expand(mCcView, true);
|
||||||
}
|
}
|
||||||
layoutChanged();
|
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)
|
private List<HeaderEntry> getAdditionalHeaders(final Message message)
|
||||||
throws MessagingException {
|
throws MessagingException {
|
||||||
List<HeaderEntry> additionalHeaders = new LinkedList<HeaderEntry>();
|
List<HeaderEntry> additionalHeaders = new LinkedList<HeaderEntry>();
|
||||||
|
Loading…
Reference in New Issue
Block a user