diff --git a/res/layout/message_list_item.xml b/res/layout/message_list_item.xml index e547974de..04985fa49 100644 --- a/res/layout/message_list_item.xml +++ b/res/layout/message_list_item.xml @@ -108,7 +108,7 @@ android:layout_height="wrap_content" android:layout_toRightOf="@+id/contact_badge" android:layout_below="@+id/subject_wrapper" - android:layout_toLeftOf="@+id/thread_count" + android:layout_toLeftOf="@+id/flagged" android:layout_marginLeft="1dip" android:layout_marginBottom="3dip" android:layout_marginRight="3dip" @@ -128,6 +128,19 @@ android:singleLine="true" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="?android:attr/textColorSecondary"/> + mSelected = new HashSet(); @@ -787,6 +788,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick mPreviewLines = K9.messageListPreviewLines(); mCheckboxes = K9.messageListCheckboxes(); + mStars = K9.messageListStars(); if (K9.showContactPicture()) { mContactsPictureLoader = ContactPicture.getContactPictureLoader(getActivity()); @@ -1847,6 +1849,11 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick holder.threadCount = (TextView) view.findViewById(R.id.thread_count); 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.setOnClickListener(holder); @@ -1915,6 +1922,10 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick if (mCheckboxes) { holder.selected.setChecked(selected); } + + if (mStars) { + holder.flagged.setChecked(flagged); + } holder.position = cursor.getPosition(); if (holder.contactBadge != null) { @@ -2058,14 +2069,22 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick public TextView date; public View chip; public TextView threadCount; + public CheckBox flagged; public CheckBox selected; public int position = -1; public QuickContactBadge contactBadge; - @Override public void onClick(View view) { 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); } + 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) { Cursor cursor = (Cursor) mAdapter.getItem(adapterPosition); long uniqueId = cursor.getLong(mUniqueIdColumn);