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:
parent
8625ecf56d
commit
e55b1e0738
@ -11,39 +11,27 @@
|
||||
android:layout_width="36dip"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:textColor="?android:attr/textColorPrimary" >
|
||||
|
||||
<View
|
||||
android:id="@+id/chip"
|
||||
android:layout_width="16dip"
|
||||
android:layout_height="16dip"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginTop="5dip"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="center|center_vertical"
|
||||
android:layout_marginLeft="10dip"
|
||||
android:layout_marginRight="10dip"
|
||||
android:background="@android:color/transparent" />
|
||||
<CheckBox
|
||||
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"
|
||||
/>
|
||||
|
||||
</RelativeLayout>
|
||||
<CheckBox
|
||||
android:id="@+id/selected_checkbox"
|
||||
android:layout_width="36dip"
|
||||
android:layout_below="@+id/chip"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_height="fill_parent"
|
||||
android:focusable="false"
|
||||
android:gravity="bottom|center"
|
||||
android:visibility="visible" />
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subject"
|
||||
|
@ -192,6 +192,14 @@ public class Account implements BaseAccount {
|
||||
private ColorChip mUnreadColorChip;
|
||||
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.
|
||||
*
|
||||
@ -444,6 +452,9 @@ public class Account implements BaseAccount {
|
||||
mEnabled = prefs.getBoolean(mUuid + ".enabled", true);
|
||||
mMarkMessageAsReadOnView = prefs.getBoolean(mUuid + ".markMessageAsReadOnView", true);
|
||||
mAlwaysShowCcBcc = prefs.getBoolean(mUuid + ".alwaysShowCcBcc", false);
|
||||
|
||||
cacheChips();
|
||||
|
||||
}
|
||||
|
||||
protected synchronized void delete(Preferences preferences) {
|
||||
@ -747,31 +758,58 @@ public class Account implements BaseAccount {
|
||||
|
||||
public synchronized void setChipColor(int color) {
|
||||
mChipColor = color;
|
||||
mUnreadColorChip = null;
|
||||
mReadColorChip = null;
|
||||
cacheChips();
|
||||
|
||||
}
|
||||
|
||||
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() {
|
||||
return mChipColor;
|
||||
}
|
||||
|
||||
|
||||
public ColorChip generateColorChip(boolean messageRead) {
|
||||
public ColorChip generateColorChip(boolean messageRead, boolean toMe, boolean fromMe, boolean messageFlagged) {
|
||||
|
||||
if (messageRead) {
|
||||
if (mReadColorChip == null) {
|
||||
mReadColorChip = new ColorChip(mChipColor, true);
|
||||
if (messageFlagged) {
|
||||
return mFlaggedReadColorChip;
|
||||
} else if (toMe) {
|
||||
return mToMeReadColorChip;
|
||||
|
||||
} else if (fromMe) {
|
||||
return mFromMeReadColorChip;
|
||||
} else {
|
||||
return mReadColorChip;
|
||||
}
|
||||
return mReadColorChip;
|
||||
|
||||
} else {
|
||||
if (mUnreadColorChip == null) {
|
||||
mUnreadColorChip = new ColorChip(mChipColor, false);
|
||||
if (messageFlagged) {
|
||||
return mFlaggedUnreadColorChip;
|
||||
} else if (toMe) {
|
||||
return mToMeUnreadColorChip;
|
||||
|
||||
} else if (fromMe) {
|
||||
return mFromMeUnreadColorChip;
|
||||
} else {
|
||||
return mUnreadColorChip;
|
||||
}
|
||||
return mUnreadColorChip;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ColorChip generateColorChip() {
|
||||
return new ColorChip(mChipColor, false);
|
||||
return new ColorChip(mChipColor, false, false, false, false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1713,7 +1713,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
}
|
||||
|
||||
} else {
|
||||
holder.chip.setBackgroundDrawable(new ColorChip(0xff999999, false).drawable());
|
||||
holder.chip.setBackgroundDrawable(new ColorChip(0xff999999, false, false, false, false).drawable());
|
||||
}
|
||||
|
||||
|
||||
|
@ -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() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -2097,15 +2088,9 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
|
||||
holder.chip = view.findViewById(R.id.chip);
|
||||
holder.preview = (TextView) view.findViewById(R.id.preview);
|
||||
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.flagged.setOnClickListener(flagClickListener);
|
||||
holder.itemMenu.setOnClickListener(itemMenuClickListener);
|
||||
|
||||
if (!mStars) {
|
||||
holder.flagged.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (mCheckboxes) {
|
||||
holder.selected.setVisibility(View.VISIBLE);
|
||||
}
|
||||
@ -2160,7 +2145,6 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
|
||||
if (!mCheckboxes) {
|
||||
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);
|
||||
|
||||
// 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.flagged.setChecked(message.flagged);
|
||||
|
||||
// So that the mSelectedCount is only incremented/decremented
|
||||
// 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
|
||||
|
||||
// if (K9.getK9Theme() == K9.THEME_LIGHT) {
|
||||
@ -2297,7 +2279,6 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
|
||||
public TextView from;
|
||||
public TextView time;
|
||||
public TextView date;
|
||||
public CheckBox flagged;
|
||||
public View chip;
|
||||
public CheckBox selected;
|
||||
public ImageButton itemMenu;
|
||||
|
@ -2,25 +2,62 @@ package com.fsck.k9.view;
|
||||
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.ShapeDrawable;
|
||||
import android.graphics.drawable.shapes.PathShape;
|
||||
|
||||
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 {
|
||||
|
||||
CHIP_PATH.addCircle(8,8,7f,Path.Direction.CW);
|
||||
CHIP_PATH.close();
|
||||
}
|
||||
CIRCULAR_CHIP_PATH.addCircle(8,8,7f,Path.Direction.CW);
|
||||
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;
|
||||
|
||||
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));
|
||||
mDrawable.getPaint().setStrokeWidth(2);
|
||||
if (messageFlagged) {
|
||||
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) {
|
||||
// Read messages get an outlined circle
|
||||
mDrawable.getPaint().setStyle(Paint.Style.STROKE);
|
||||
|
Loading…
Reference in New Issue
Block a user