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

Use the color chip area as click target for the multi-select checkboxes

This commit is contained in:
cketti 2013-06-07 06:47:24 +02:00
parent a485c4c0d1
commit cb906ee6a4

View File

@ -53,8 +53,6 @@ import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ListView; import android.widget.ListView;
import android.widget.QuickContactBadge; import android.widget.QuickContactBadge;
import android.widget.TextView; 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.threadCount = (TextView) view.findViewById(R.id.thread_count);
holder.selected = (CheckBox) view.findViewById(R.id.selected_checkbox); holder.selected = (CheckBox) view.findViewById(R.id.selected_checkbox);
if (mCheckboxes) { holder.selected.setVisibility((mCheckboxes) ? View.VISIBLE : View.GONE);
holder.selected.setOnCheckedChangeListener(holder);
holder.selected.setVisibility(View.VISIBLE); view.findViewById(R.id.chip_wrapper).setOnClickListener(holder);
} else {
holder.selected.setVisibility(View.GONE);
}
view.setTag(holder); view.setTag(holder);
@ -1890,17 +1885,9 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
} }
if (mCheckboxes) { 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); 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) { if (holder.contactBadge != null) {
holder.contactBadge.assignContactFromEmail(counterpartyAddress, true); 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 subject;
public TextView preview; public TextView preview;
public TextView from; public TextView from;
@ -2048,7 +2035,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
public QuickContactBadge contactBadge; public QuickContactBadge contactBadge;
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onClick(View view) {
if (position != -1) { if (position != -1) {
toggleMessageSelectWithAdapterPosition(position); toggleMessageSelectWithAdapterPosition(position);
} }