1
0
mirror of https://github.com/moparisthebest/k-9 synced 2025-01-31 07:10:14 -05:00

Move the message star into the chip. (Also, the "to me" information)

This commit is contained in:
Jesse Vincent 2012-09-20 23:30:52 -04:00
parent 8625ecf56d
commit e55b1e0738
5 changed files with 99 additions and 55 deletions

View File

@ -11,39 +11,27 @@
android:layout_width="36dip" android:layout_width="36dip"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:textColor="?android:attr/textColorPrimary" > android:textColor="?android:attr/textColorPrimary" >
<View <View
android:id="@+id/chip" android:id="@+id/chip"
android:layout_width="16dip" android:layout_width="16dip"
android:layout_height="16dip" android:layout_height="16dip"
android:layout_alignParentTop="true" android:layout_gravity="center|center_vertical"
android:layout_marginTop="5dip"
android:gravity="center"
android:layout_marginLeft="10dip" android:layout_marginLeft="10dip"
android:layout_marginRight="10dip" android:layout_marginRight="10dip"
android:background="@android:color/transparent" /> android:background="@android:color/transparent" />
<CheckBox </RelativeLayout>
android:id="@+id/flagged"
android:button="@drawable/star"
android:layout_width="36dip"
android:layout_marginLeft="7dip"
android:layout_marginRight="4dip"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:gravity="top|center"
android:focusable="false"
/>
<CheckBox <CheckBox
android:id="@+id/selected_checkbox" android:id="@+id/selected_checkbox"
android:layout_width="36dip" android:layout_width="36dip"
android:layout_below="@+id/chip" android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:focusable="false" android:focusable="false"
android:gravity="bottom|center" android:gravity="bottom|center"
android:visibility="visible" /> android:visibility="visible" />
</RelativeLayout>
<TextView <TextView
android:id="@+id/subject" android:id="@+id/subject"

View File

@ -192,6 +192,14 @@ public class Account implements BaseAccount {
private ColorChip mUnreadColorChip; private ColorChip mUnreadColorChip;
private ColorChip mReadColorChip; private ColorChip mReadColorChip;
private ColorChip mFlaggedUnreadColorChip;
private ColorChip mFlaggedReadColorChip;
private ColorChip mToMeUnreadColorChip;
private ColorChip mToMeReadColorChip;
private ColorChip mFromMeUnreadColorChip;
private ColorChip mFromMeReadColorChip;
/** /**
* Indicates whether this account is enabled, i.e. ready for use, or not. * Indicates whether this account is enabled, i.e. ready for use, or not.
* *
@ -444,6 +452,9 @@ public class Account implements BaseAccount {
mEnabled = prefs.getBoolean(mUuid + ".enabled", true); mEnabled = prefs.getBoolean(mUuid + ".enabled", true);
mMarkMessageAsReadOnView = prefs.getBoolean(mUuid + ".markMessageAsReadOnView", true); mMarkMessageAsReadOnView = prefs.getBoolean(mUuid + ".markMessageAsReadOnView", true);
mAlwaysShowCcBcc = prefs.getBoolean(mUuid + ".alwaysShowCcBcc", false); mAlwaysShowCcBcc = prefs.getBoolean(mUuid + ".alwaysShowCcBcc", false);
cacheChips();
} }
protected synchronized void delete(Preferences preferences) { protected synchronized void delete(Preferences preferences) {
@ -747,31 +758,58 @@ public class Account implements BaseAccount {
public synchronized void setChipColor(int color) { public synchronized void setChipColor(int color) {
mChipColor = color; mChipColor = color;
mUnreadColorChip = null; cacheChips();
mReadColorChip = null;
} }
public synchronized void cacheChips() {
mReadColorChip = new ColorChip(mChipColor, true, false, false, false);
mUnreadColorChip = new ColorChip(mChipColor, false, false, false, false);
mToMeReadColorChip = new ColorChip(mChipColor, true, true, false, false);
mToMeUnreadColorChip = new ColorChip(mChipColor, false,true, false, false);
mFromMeReadColorChip = new ColorChip(mChipColor, true, false, true, false);
mFromMeUnreadColorChip = new ColorChip(mChipColor, false, false, true, false);
mFlaggedReadColorChip = new ColorChip(mChipColor, true, false, false, true);
mFlaggedUnreadColorChip = new ColorChip(mChipColor, false, false, false, true);
}
public synchronized int getChipColor() { public synchronized int getChipColor() {
return mChipColor; return mChipColor;
} }
public ColorChip generateColorChip(boolean messageRead) { public ColorChip generateColorChip(boolean messageRead, boolean toMe, boolean fromMe, boolean messageFlagged) {
if (messageRead) { if (messageRead) {
if (mReadColorChip == null) { if (messageFlagged) {
mReadColorChip = new ColorChip(mChipColor, true); return mFlaggedReadColorChip;
} else if (toMe) {
return mToMeReadColorChip;
} else if (fromMe) {
return mFromMeReadColorChip;
} else {
return mReadColorChip;
} }
return mReadColorChip;
} else { } else {
if (mUnreadColorChip == null) { if (messageFlagged) {
mUnreadColorChip = new ColorChip(mChipColor, false); return mFlaggedUnreadColorChip;
} else if (toMe) {
return mToMeUnreadColorChip;
} else if (fromMe) {
return mFromMeUnreadColorChip;
} else {
return mUnreadColorChip;
} }
return mUnreadColorChip;
} }
} }
public ColorChip generateColorChip() { public ColorChip generateColorChip() {
return new ColorChip(mChipColor, false); return new ColorChip(mChipColor, false, false, false, false);
} }

View File

@ -1713,7 +1713,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
} }
} else { } else {
holder.chip.setBackgroundDrawable(new ColorChip(0xff999999, false).drawable()); holder.chip.setBackgroundDrawable(new ColorChip(0xff999999, false, false, false, false).drawable());
} }

View File

@ -1938,15 +1938,6 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
} }
} }
private final OnClickListener flagClickListener = new OnClickListener() {
@Override
public void onClick(View v) {
// Perform action on clicks
MessageInfoHolder message = (MessageInfoHolder) getItem((Integer)v.getTag());
onToggleFlag(message);
}
};
private final OnClickListener itemMenuClickListener = new OnClickListener() { private final OnClickListener itemMenuClickListener = new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -2097,15 +2088,9 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
holder.chip = view.findViewById(R.id.chip); holder.chip = view.findViewById(R.id.chip);
holder.preview = (TextView) view.findViewById(R.id.preview); holder.preview = (TextView) view.findViewById(R.id.preview);
holder.selected = (CheckBox) view.findViewById(R.id.selected_checkbox); holder.selected = (CheckBox) view.findViewById(R.id.selected_checkbox);
holder.flagged = (CheckBox) view.findViewById(R.id.flagged);
holder.itemMenu = (ImageButton) view.findViewById(R.id.item_menu); holder.itemMenu = (ImageButton) view.findViewById(R.id.item_menu);
holder.flagged.setOnClickListener(flagClickListener);
holder.itemMenu.setOnClickListener(itemMenuClickListener); holder.itemMenu.setOnClickListener(itemMenuClickListener);
if (!mStars) {
holder.flagged.setVisibility(View.GONE);
}
if (mCheckboxes) { if (mCheckboxes) {
holder.selected.setVisibility(View.VISIBLE); holder.selected.setVisibility(View.VISIBLE);
} }
@ -2160,7 +2145,6 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
if (!mCheckboxes) { if (!mCheckboxes) {
holder.selected.setVisibility(View.GONE); holder.selected.setVisibility(View.GONE);
} }
holder.flagged.setChecked(false);
} }
@ -2186,9 +2170,7 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
holder.subject.setTypeface(null, message.read ? Typeface.NORMAL : Typeface.BOLD); holder.subject.setTypeface(null, message.read ? Typeface.NORMAL : Typeface.BOLD);
// XXX TODO there has to be some way to walk our view hierarchy and get this // XXX TODO there has to be some way to walk our view hierarchy and get this
holder.flagged.setTag(position);
holder.itemMenu.setTag(position); holder.itemMenu.setTag(position);
holder.flagged.setChecked(message.flagged);
// So that the mSelectedCount is only incremented/decremented // So that the mSelectedCount is only incremented/decremented
// when a user checks the checkbox (vs code) // when a user checks the checkbox (vs code)
@ -2201,7 +2183,7 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
holder.chip.setBackgroundDrawable(message.message.getFolder().getAccount().generateColorChip(message.read).drawable()); holder.chip.setBackgroundDrawable(message.message.getFolder().getAccount().generateColorChip(message.read,message.message.toMe(), false, message.flagged).drawable());
// TODO: Make these colors part of the theme // TODO: Make these colors part of the theme
// if (K9.getK9Theme() == K9.THEME_LIGHT) { // if (K9.getK9Theme() == K9.THEME_LIGHT) {
@ -2297,7 +2279,6 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
public TextView from; public TextView from;
public TextView time; public TextView time;
public TextView date; public TextView date;
public CheckBox flagged;
public View chip; public View chip;
public CheckBox selected; public CheckBox selected;
public ImageButton itemMenu; public ImageButton itemMenu;

View File

@ -2,25 +2,62 @@ package com.fsck.k9.view;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Path; import android.graphics.Path;
import android.graphics.RectF;
import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.PathShape; import android.graphics.drawable.shapes.PathShape;
public class ColorChip { public class ColorChip {
private static final Path CHIP_PATH = new Path(); private static final Path CIRCULAR_CHIP_PATH = new Path();
private static final Path LEFT_POINTING_CHIP_PATH = new Path();
private static final Path RIGHT_POINTING_CHIP_PATH = new Path();
private static final Path STAR_CHIP_PATH = new Path();
static { static {
CHIP_PATH.addCircle(8,8,7f,Path.Direction.CW); CIRCULAR_CHIP_PATH.addCircle(8,8,7f,Path.Direction.CW);
CHIP_PATH.close(); CIRCULAR_CHIP_PATH.close();
}
RIGHT_POINTING_CHIP_PATH.addArc(new RectF(1f,1f,15f,15f) , 90, 180);
RIGHT_POINTING_CHIP_PATH.lineTo(16f,8f);
RIGHT_POINTING_CHIP_PATH.lineTo(8f, 15f);
RIGHT_POINTING_CHIP_PATH.close();
LEFT_POINTING_CHIP_PATH.addArc(new RectF(1f,1f,15f,15f) , 270, 180);
LEFT_POINTING_CHIP_PATH.moveTo(8f, 1f);
LEFT_POINTING_CHIP_PATH.lineTo(0f,8f);
LEFT_POINTING_CHIP_PATH.lineTo(8f, 15f);
LEFT_POINTING_CHIP_PATH.close();
STAR_CHIP_PATH.moveTo(8f,0f);
STAR_CHIP_PATH.lineTo(11f,5f);
STAR_CHIP_PATH.lineTo(16f,6f);
STAR_CHIP_PATH.lineTo(12f,10f);
STAR_CHIP_PATH.lineTo(14f,16f);
STAR_CHIP_PATH.lineTo(8f,13f);
STAR_CHIP_PATH.lineTo(2f,16f);
STAR_CHIP_PATH.lineTo(4f,10f);
STAR_CHIP_PATH.lineTo(0f,6f);
STAR_CHIP_PATH.lineTo(5f,5f);
STAR_CHIP_PATH.lineTo(8f,0f);
STAR_CHIP_PATH.close();
}
private ShapeDrawable mDrawable; private ShapeDrawable mDrawable;
public ColorChip(int color, boolean messageRead) { public ColorChip(int color, boolean messageRead, boolean toMe, boolean fromMe, boolean messageFlagged ) {
mDrawable = new ShapeDrawable(new PathShape(CHIP_PATH, 16f, 16f)); if (messageFlagged) {
mDrawable.getPaint().setStrokeWidth(2); mDrawable = new ShapeDrawable(new PathShape(STAR_CHIP_PATH, 16f, 16f));
} else if ( fromMe ) {
mDrawable = new ShapeDrawable(new PathShape(LEFT_POINTING_CHIP_PATH, 16f, 16f));
} else if ( toMe) {
mDrawable = new ShapeDrawable(new PathShape(RIGHT_POINTING_CHIP_PATH, 16f, 16f));
} else {
mDrawable = new ShapeDrawable(new PathShape(CIRCULAR_CHIP_PATH, 16f, 16f));
}
mDrawable.getPaint().setStrokeWidth(1);
if (messageRead) { if (messageRead) {
// Read messages get an outlined circle // Read messages get an outlined circle
mDrawable.getPaint().setStyle(Paint.Style.STROKE); mDrawable.getPaint().setStyle(Paint.Style.STROKE);