1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

add back stars to the message list UI

This commit is contained in:
Jesse Vincent 2013-08-16 14:02:52 -04:00
parent b2cfc40ab6
commit a8668f962d
2 changed files with 42 additions and 3 deletions

View File

@ -108,7 +108,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toRightOf="@+id/contact_badge" android:layout_toRightOf="@+id/contact_badge"
android:layout_below="@+id/subject_wrapper" android:layout_below="@+id/subject_wrapper"
android:layout_toLeftOf="@+id/thread_count" android:layout_toLeftOf="@+id/flagged"
android:layout_marginLeft="1dip" android:layout_marginLeft="1dip"
android:layout_marginBottom="3dip" android:layout_marginBottom="3dip"
android:layout_marginRight="3dip" android:layout_marginRight="3dip"
@ -128,6 +128,19 @@
android:singleLine="true" android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"/> android:textColor="?android:attr/textColorSecondary"/>
<CheckBox
android:id="@+id/flagged"
style="?android:attr/starStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/date"
android:layout_alignParentRight="true"
android:paddingTop="3dip"
android:paddingLeft="2dip"
android:paddingRight="4dip"
android:focusable="false"
/>
<TextView <TextView
android:id="@+id/thread_count" android:id="@+id/thread_count"

View File

@ -412,6 +412,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
private boolean mSortDateAscending = false; private boolean mSortDateAscending = false;
private boolean mSenderAboveSubject = false; private boolean mSenderAboveSubject = false;
private boolean mCheckboxes = true; private boolean mCheckboxes = true;
private boolean mStars = true;
private int mSelectedCount = 0; private int mSelectedCount = 0;
private Set<Long> mSelected = new HashSet<Long>(); private Set<Long> mSelected = new HashSet<Long>();
@ -787,6 +788,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
mPreviewLines = K9.messageListPreviewLines(); mPreviewLines = K9.messageListPreviewLines();
mCheckboxes = K9.messageListCheckboxes(); mCheckboxes = K9.messageListCheckboxes();
mStars = K9.messageListStars();
if (K9.showContactPicture()) { if (K9.showContactPicture()) {
mContactsPictureLoader = ContactPicture.getContactPictureLoader(getActivity()); mContactsPictureLoader = ContactPicture.getContactPictureLoader(getActivity());
@ -1847,6 +1849,11 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
holder.threadCount = (TextView) view.findViewById(R.id.thread_count); holder.threadCount = (TextView) view.findViewById(R.id.thread_count);
view.findViewById(R.id.selected_checkbox_wrapper).setVisibility((mCheckboxes) ? View.VISIBLE : View.GONE); view.findViewById(R.id.selected_checkbox_wrapper).setVisibility((mCheckboxes) ? View.VISIBLE : View.GONE);
holder.flagged = (CheckBox) view.findViewById(R.id.flagged);
holder.flagged.setVisibility(mStars ? View.VISIBLE : View.GONE);
holder.flagged.setOnClickListener(holder);
holder.selected = (CheckBox) view.findViewById(R.id.selected_checkbox); holder.selected = (CheckBox) view.findViewById(R.id.selected_checkbox);
holder.selected.setOnClickListener(holder); holder.selected.setOnClickListener(holder);
@ -1915,6 +1922,10 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
if (mCheckboxes) { if (mCheckboxes) {
holder.selected.setChecked(selected); holder.selected.setChecked(selected);
} }
if (mStars) {
holder.flagged.setChecked(flagged);
}
holder.position = cursor.getPosition(); holder.position = cursor.getPosition();
if (holder.contactBadge != null) { if (holder.contactBadge != null) {
@ -2058,14 +2069,22 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
public TextView date; public TextView date;
public View chip; public View chip;
public TextView threadCount; public TextView threadCount;
public CheckBox flagged;
public CheckBox selected; public CheckBox selected;
public int position = -1; public int position = -1;
public QuickContactBadge contactBadge; public QuickContactBadge contactBadge;
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (position != -1) { if (position != -1) {
toggleMessageSelectWithAdapterPosition(position);
switch (view.getId()) {
case R.id.selected_checkbox:
toggleMessageSelectWithAdapterPosition(position);
break;
case R.id.flagged:
toggleMessageFlagWithAdapterPosition(position);
break;
}
} }
} }
} }
@ -2181,6 +2200,13 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
toggleMessageSelectWithAdapterPosition(adapterPosition); toggleMessageSelectWithAdapterPosition(adapterPosition);
} }
private void toggleMessageFlagWithAdapterPosition(int adapterPosition) {
Cursor cursor = (Cursor) mAdapter.getItem(adapterPosition);
boolean flagged = (cursor.getInt(FLAGGED_COLUMN) == 1);
setFlag(adapterPosition,Flag.FLAGGED, !flagged);
}
private void toggleMessageSelectWithAdapterPosition(int adapterPosition) { private void toggleMessageSelectWithAdapterPosition(int adapterPosition) {
Cursor cursor = (Cursor) mAdapter.getItem(adapterPosition); Cursor cursor = (Cursor) mAdapter.getItem(adapterPosition);
long uniqueId = cursor.getLong(mUniqueIdColumn); long uniqueId = cursor.getLong(mUniqueIdColumn);