When tapping checkbox explicitly, go straight to toggling the checkbox.
Begin drag is only used if the user has performed a long press
Fixes b/7046061 Tap/Select the check box of any message in GmailEmail Inbox does not show the selection for ~ 20-30 secs
Change-Id: Ib8a2d04ff162fe509e8f38d6f61960a8d828efbe
diff --git a/src/com/android/mail/browse/ConversationItemView.java b/src/com/android/mail/browse/ConversationItemView.java
index caf9121..bb553bd 100644
--- a/src/com/android/mail/browse/ConversationItemView.java
+++ b/src/com/android/mail/browse/ConversationItemView.java
@@ -1172,32 +1172,37 @@
}
/**
- * Toggle the check mark on this view and update the conversation
+ * Toggle the check mark on this view and update the conversation or begin
+ * drag, if drag is enabled.
*/
- public void toggleCheckMark() {
+ public void toggleCheckMarkOrBeginDrag() {
ViewMode mode = mActivity.getViewMode();
if (!mTabletDevice || !mode.isListMode()) {
- if (mHeader != null && mHeader.conversation != null) {
- mChecked = !mChecked;
- Conversation conv = mHeader.conversation;
- // Set the list position of this item in the conversation
- ListView listView = getListView();
- conv.position = mChecked && listView != null ? listView.getPositionForView(this)
- : Conversation.NO_POSITION;
- if (mSelectedConversationSet != null) {
- mSelectedConversationSet.toggle(this, conv);
- }
- // We update the background after the checked state has changed
- // now that we have a selected background asset. Setting the background
- // usually waits for a layout pass, but we don't need a full layout,
- // just an update to the background.
- requestLayout();
- }
+ toggleCheckMark();
} else {
beginDragMode();
}
}
+ private void toggleCheckMark() {
+ if (mHeader != null && mHeader.conversation != null) {
+ mChecked = !mChecked;
+ Conversation conv = mHeader.conversation;
+ // Set the list position of this item in the conversation
+ ListView listView = getListView();
+ conv.position = mChecked && listView != null ? listView.getPositionForView(this)
+ : Conversation.NO_POSITION;
+ if (mSelectedConversationSet != null) {
+ mSelectedConversationSet.toggle(this, conv);
+ }
+ // We update the background after the checked state has changed
+ // now that we have a selected background asset. Setting the background
+ // usually waits for a layout pass, but we don't need a full layout,
+ // just an update to the background.
+ requestLayout();
+ }
+ }
+
/**
* Return if the checkbox for this item is checked.
*/
@@ -1500,30 +1505,13 @@
}
/**
- * Select the current conversation.
- */
- private void selectConversation() {
- if (!mSelectedConversationSet.containsKey(mHeader.conversation.id)) {
- mChecked = !mChecked;
- Conversation conv = mHeader.conversation;
- // Set the list position of this item in the conversation
- ListView listView = getListView();
- conv.position = mChecked && listView != null ? listView.getPositionForView(this)
- : Conversation.NO_POSITION;
- if (mSelectedConversationSet != null) {
- mSelectedConversationSet.toggle(this, conv);
- }
- }
- }
-
- /**
* Begin drag mode. Keep the conversation selected (NOT toggle selection) and start drag.
*/
private void beginDragMode() {
if (mLastTouchX < 0 || mLastTouchY < 0) {
return;
}
- selectConversation();
+ toggleCheckMark();
// Clip data has form: [conversations_uri, conversationId1,
// maxMessageId1, label1, conversationId2, maxMessageId2, label2, ...]
diff --git a/src/com/android/mail/ui/ConversationListFragment.java b/src/com/android/mail/ui/ConversationListFragment.java
index c6d4328..746ce02 100644
--- a/src/com/android/mail/ui/ConversationListFragment.java
+++ b/src/com/android/mail/ui/ConversationListFragment.java
@@ -405,7 +405,7 @@
if (!(view instanceof ConversationItemView)) {
return true;
}
- ((ConversationItemView) view).toggleCheckMark();
+ ((ConversationItemView) view).toggleCheckMarkOrBeginDrag();
return true;
}
@@ -429,7 +429,7 @@
return;
}
if (mAccount.settings.hideCheckboxes && !mSelectedSet.isEmpty()) {
- ((ConversationItemView) view).toggleCheckMark();
+ ((ConversationItemView) view).toggleCheckMarkOrBeginDrag();
} else {
viewConversation(position);
}