From cb906ee6a43a8760d3c514bf2b0286fa89473dbf Mon Sep 17 00:00:00 2001 From: cketti Date: Fri, 7 Jun 2013 06:47:24 +0200 Subject: [PATCH] Use the color chip area as click target for the multi-select checkboxes --- .../fsck/k9/fragment/MessageListFragment.java | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/src/com/fsck/k9/fragment/MessageListFragment.java b/src/com/fsck/k9/fragment/MessageListFragment.java index 091b65af5..210884fe1 100644 --- a/src/com/fsck/k9/fragment/MessageListFragment.java +++ b/src/com/fsck/k9/fragment/MessageListFragment.java @@ -53,8 +53,6 @@ import android.widget.AdapterView; import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.OnItemClickListener; import android.widget.CheckBox; -import android.widget.CompoundButton; -import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.ListView; import android.widget.QuickContactBadge; import android.widget.TextView; @@ -1817,12 +1815,9 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick holder.threadCount = (TextView) view.findViewById(R.id.thread_count); holder.selected = (CheckBox) view.findViewById(R.id.selected_checkbox); - if (mCheckboxes) { - holder.selected.setOnCheckedChangeListener(holder); - holder.selected.setVisibility(View.VISIBLE); - } else { - holder.selected.setVisibility(View.GONE); - } + holder.selected.setVisibility((mCheckboxes) ? View.VISIBLE : View.GONE); + + view.findViewById(R.id.chip_wrapper).setOnClickListener(holder); view.setTag(holder); @@ -1890,17 +1885,9 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick } if (mCheckboxes) { - // Set holder.position to -1 to avoid MessageViewHolder.onCheckedChanged() toggling - // the selection state when setChecked() is called below. - holder.position = -1; - - // Only set the UI state, don't actually toggle the message selection. holder.selected.setChecked(selected); - - // Now save the position so MessageViewHolder.onCheckedChanged() will know what - // message to (de)select. - holder.position = cursor.getPosition(); } + holder.position = cursor.getPosition(); if (holder.contactBadge != null) { holder.contactBadge.assignContactFromEmail(counterpartyAddress, true); @@ -2035,7 +2022,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick } } - class MessageViewHolder implements OnCheckedChangeListener { + class MessageViewHolder implements View.OnClickListener { public TextView subject; public TextView preview; public TextView from; @@ -2048,7 +2035,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick public QuickContactBadge contactBadge; @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + public void onClick(View view) { if (position != -1) { toggleMessageSelectWithAdapterPosition(position); }