1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00

Go back to the old behavior for batch mark as (un)read, (un)flag

If there is at least one unread message among the selected messages the
action is "mark as read". Otherwise, "mark as unread".
If there is at least one unstarred message among the selected messages
the action is "add star". Otherwise, "remove star".
This commit is contained in:
cketti 2012-09-14 00:34:25 +02:00
parent 937168895d
commit 0878de5936
25 changed files with 117 additions and 38 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 982 B

View File

Before

Width:  |  Height:  |  Size: 771 B

After

Width:  |  Height:  |  Size: 771 B

View File

Before

Width:  |  Height:  |  Size: 875 B

After

Width:  |  Height:  |  Size: 875 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

View File

Before

Width:  |  Height:  |  Size: 357 B

After

Width:  |  Height:  |  Size: 357 B

View File

Before

Width:  |  Height:  |  Size: 430 B

After

Width:  |  Height:  |  Size: 430 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 646 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 753 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 672 B

View File

Before

Width:  |  Height:  |  Size: 458 B

After

Width:  |  Height:  |  Size: 458 B

View File

Before

Width:  |  Height:  |  Size: 545 B

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 929 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1017 B

After

Width:  |  Height:  |  Size: 1017 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -7,10 +7,16 @@
android:icon="?attr/iconActionDelete" android:icon="?attr/iconActionDelete"
/> />
<item <item
android:id="@+id/read_toggle" android:id="@+id/mark_as_read"
android:title="@string/read_toggle_action" android:title="@string/mark_as_read_action"
android:showAsAction="always" android:showAsAction="always"
android:icon="?attr/iconActionToggleRead" android:icon="?attr/iconActionMarkAsRead"
/>
<item
android:id="@+id/mark_as_unread"
android:title="@string/mark_as_unread_action"
android:showAsAction="always"
android:icon="?attr/iconActionMarkAsUnread"
/> />
<item <item
android:id="@+id/archive" android:id="@+id/archive"
@ -29,10 +35,16 @@
android:title="@string/copy_action" android:title="@string/copy_action"
/> />
<item <item
android:id="@+id/flag_toggle" android:id="@+id/flag"
android:title="@string/flag_toggle_action" android:title="@string/flag_action"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:icon="?attr/iconActionToggleFlag" android:icon="?attr/iconActionFlag"
/>
<item
android:id="@+id/unflag"
android:title="@string/unflag_action"
android:showAsAction="ifRoom"
android:icon="?attr/iconActionUnflag"
/> />
<item <item
android:id="@+id/spam" android:id="@+id/spam"

View File

@ -65,7 +65,6 @@
android:id="@+id/toggle_unread" android:id="@+id/toggle_unread"
android:alphabeticShortcut="u" android:alphabeticShortcut="u"
android:title="@string/read_toggle_action" android:title="@string/read_toggle_action"
android:icon="?attr/iconActionToggleRead"
android:showAsAction="never" android:showAsAction="never"
/> />
<item <item

View File

@ -14,7 +14,6 @@
<attr name="iconActionMoveOrCopy" format="reference" /> <attr name="iconActionMoveOrCopy" format="reference" />
<attr name="iconActionNextMessage" format="reference" /> <attr name="iconActionNextMessage" format="reference" />
<attr name="iconActionPreviousMessage" format="reference" /> <attr name="iconActionPreviousMessage" format="reference" />
<attr name="iconActionRead" format="reference" />
<attr name="iconActionRefresh" format="reference" /> <attr name="iconActionRefresh" format="reference" />
<attr name="iconActionSearch" format="reference" /> <attr name="iconActionSearch" format="reference" />
<attr name="iconActionSend" format="reference" /> <attr name="iconActionSend" format="reference" />
@ -22,8 +21,10 @@
<attr name="iconActionSingleMessageOptions" format="reference" /> <attr name="iconActionSingleMessageOptions" format="reference" />
<attr name="iconActionSort" format="reference" /> <attr name="iconActionSort" format="reference" />
<attr name="iconActionSpam" format="reference" /> <attr name="iconActionSpam" format="reference" />
<attr name="iconActionToggleFlag" format="reference" /> <attr name="iconActionFlag" format="reference" />
<attr name="iconActionToggleRead" format="reference" /> <attr name="iconActionUnflag" format="reference" />
<attr name="iconActionMarkAsRead" format="reference" />
<attr name="iconActionMarkAsUnread" format="reference" />
<attr name="iconMenuAdd" format="reference" /> <attr name="iconMenuAdd" format="reference" />
<attr name="iconMenuAttachment" format="reference" /> <attr name="iconMenuAttachment" format="reference" />
<attr name="iconMenuClear" format="reference" /> <attr name="iconMenuClear" format="reference" />

View File

@ -15,7 +15,6 @@
<item name="iconActionMoveOrCopy">@drawable/ic_action_move_or_copy_light</item> <item name="iconActionMoveOrCopy">@drawable/ic_action_move_or_copy_light</item>
<item name="iconActionNextMessage">@drawable/ic_action_next_message_light</item> <item name="iconActionNextMessage">@drawable/ic_action_next_message_light</item>
<item name="iconActionPreviousMessage">@drawable/ic_action_previous_message_light</item> <item name="iconActionPreviousMessage">@drawable/ic_action_previous_message_light</item>
<item name="iconActionRead">@drawable/ic_action_read_light</item>
<item name="iconActionRefresh">@drawable/ic_action_refresh_light</item> <item name="iconActionRefresh">@drawable/ic_action_refresh_light</item>
<item name="iconActionSearch">@drawable/ic_action_search_light</item> <item name="iconActionSearch">@drawable/ic_action_search_light</item>
<item name="iconActionSend">@drawable/ic_action_send_light</item> <item name="iconActionSend">@drawable/ic_action_send_light</item>
@ -23,8 +22,10 @@
<item name="iconActionSingleMessageOptions">@drawable/ic_action_single_message_options_light</item> <item name="iconActionSingleMessageOptions">@drawable/ic_action_single_message_options_light</item>
<item name="iconActionSort">@drawable/ic_action_sort_light</item> <item name="iconActionSort">@drawable/ic_action_sort_light</item>
<item name="iconActionSpam">@drawable/ic_action_spam_light</item> <item name="iconActionSpam">@drawable/ic_action_spam_light</item>
<item name="iconActionToggleFlag">@drawable/ic_action_toggle_flag_light</item> <item name="iconActionFlag">@drawable/ic_action_flag_light</item>
<item name="iconActionToggleRead">@drawable/ic_action_toggle_read_light</item> <item name="iconActionUnflag">@drawable/ic_action_unflag_light</item>
<item name="iconActionMarkAsRead">@drawable/ic_action_mark_as_read_light</item>
<item name="iconActionMarkAsUnread">@drawable/ic_action_mark_as_unread_light</item>
<item name="iconMenuAdd">@drawable/ic_menu_add</item> <item name="iconMenuAdd">@drawable/ic_menu_add</item>
<item name="iconMenuAttachment">@drawable/ic_menu_attachment</item> <item name="iconMenuAttachment">@drawable/ic_menu_attachment</item>
<item name="iconMenuClear">@drawable/ic_menu_clear</item> <item name="iconMenuClear">@drawable/ic_menu_clear</item>
@ -55,7 +56,6 @@
<item name="iconActionMoveOrCopy">@drawable/ic_action_move_or_copy_dark</item> <item name="iconActionMoveOrCopy">@drawable/ic_action_move_or_copy_dark</item>
<item name="iconActionNextMessage">@drawable/ic_action_next_message_dark</item> <item name="iconActionNextMessage">@drawable/ic_action_next_message_dark</item>
<item name="iconActionPreviousMessage">@drawable/ic_action_previous_message_dark</item> <item name="iconActionPreviousMessage">@drawable/ic_action_previous_message_dark</item>
<item name="iconActionRead">@drawable/ic_action_read_dark</item>
<item name="iconActionRefresh">@drawable/ic_action_refresh_dark</item> <item name="iconActionRefresh">@drawable/ic_action_refresh_dark</item>
<item name="iconActionSearch">@drawable/ic_action_search_dark</item> <item name="iconActionSearch">@drawable/ic_action_search_dark</item>
<item name="iconActionSend">@drawable/ic_action_send_dark</item> <item name="iconActionSend">@drawable/ic_action_send_dark</item>
@ -63,8 +63,10 @@
<item name="iconActionSingleMessageOptions">@drawable/ic_action_single_message_options_dark</item> <item name="iconActionSingleMessageOptions">@drawable/ic_action_single_message_options_dark</item>
<item name="iconActionSort">@drawable/ic_action_sort_dark</item> <item name="iconActionSort">@drawable/ic_action_sort_dark</item>
<item name="iconActionSpam">@drawable/ic_action_spam_dark</item> <item name="iconActionSpam">@drawable/ic_action_spam_dark</item>
<item name="iconActionToggleFlag">@drawable/ic_action_toggle_flag_dark</item> <item name="iconActionFlag">@drawable/ic_action_flag_light</item>
<item name="iconActionToggleRead">@drawable/ic_action_toggle_read_dark</item> <item name="iconActionUnflag">@drawable/ic_action_unflag_light</item>
<item name="iconActionMarkAsRead">@drawable/ic_action_mark_as_read_light</item>
<item name="iconActionMarkAsUnread">@drawable/ic_action_mark_as_unread_light</item>
<item name="iconMenuAdd">@drawable/ic_menu_add</item> <item name="iconMenuAdd">@drawable/ic_menu_add</item>
<item name="iconMenuAttachment">@drawable/ic_menu_attachment</item> <item name="iconMenuAttachment">@drawable/ic_menu_attachment</item>
<item name="iconMenuClear">@drawable/ic_menu_clear</item> <item name="iconMenuClear">@drawable/ic_menu_clear</item>

View File

@ -26,10 +26,8 @@ import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan; import android.text.style.StyleSpan;
import android.util.Log; import android.util.Log;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.GestureDetector;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -1402,6 +1400,8 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
messageInfo.flagged = !messageInfo.flagged; messageInfo.flagged = !messageInfo.flagged;
mAdapter.sortMessages(); mAdapter.sortMessages();
} }
computeBatchDirection();
} }
private void checkMail(Account account, String folderName) { private void checkMail(Account account, String folderName) {
@ -2368,6 +2368,7 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
mSelectedCount += (isSelected ? 1 : 0); mSelectedCount += (isSelected ? 1 : 0);
} }
computeBatchDirection();
mAdapter.notifyDataSetChanged(); mAdapter.notifyDataSetChanged();
if (isSelected) { if (isSelected) {
@ -2395,6 +2396,7 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
mActionMode = MessageList.this.startActionMode(mActionModeCallback); mActionMode = MessageList.this.startActionMode(mActionModeCallback);
updateActionModeTitle(); updateActionModeTitle();
computeSelectAllVisibility(); computeSelectAllVisibility();
computeBatchDirection();
} else { } else {
mSelectedCount = 0; mSelectedCount = 0;
mActionMode.finish(); mActionMode.finish();
@ -2408,7 +2410,7 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
return; return;
} }
} else { } else {
mActionMode = MessageList.this.startActionMode(mActionModeCallback); mActionMode = startActionMode(mActionModeCallback);
} }
if (holder.selected) { if (holder.selected) {
@ -2419,6 +2421,8 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
mSelectedCount += 1; mSelectedCount += 1;
} }
mAdapter.notifyDataSetChanged(); mAdapter.notifyDataSetChanged();
computeBatchDirection();
updateActionModeTitle(); updateActionModeTitle();
// make sure the onPrepareActionMode is called // make sure the onPrepareActionMode is called
@ -2435,6 +2439,29 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
mActionModeCallback.showSelectAll(mSelectedCount != mAdapter.getCount()); mActionModeCallback.showSelectAll(mSelectedCount != mAdapter.getCount());
} }
private void computeBatchDirection() {
boolean isBatchFlag = false;
boolean isBatchRead = false;
for (MessageInfoHolder holder : mAdapter.getMessages()) {
if (holder.selected) {
if (!holder.flagged) {
isBatchFlag = true;
}
if (!holder.read) {
isBatchRead = true;
}
if (isBatchFlag && isBatchRead) {
break;
}
}
}
mActionModeCallback.showMarkAsRead(isBatchRead);
mActionModeCallback.showFlag(isBatchFlag);
}
/** /**
* @param holders * @param holders
* Messages to update. Never {@code null}. * Messages to update. Never {@code null}.
@ -2744,10 +2771,18 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
class ActionModeCallback implements ActionMode.Callback { class ActionModeCallback implements ActionMode.Callback {
private MenuItem mSelectAll; private MenuItem mSelectAll;
private MenuItem mMarkAsRead;
private MenuItem mMarkAsUnread;
private MenuItem mFlag;
private MenuItem mUnflag;
@Override @Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) { public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
mSelectAll = menu.findItem(R.id.select_all); mSelectAll = menu.findItem(R.id.select_all);
mMarkAsRead = menu.findItem(R.id.mark_as_read);
mMarkAsUnread = menu.findItem(R.id.mark_as_unread);
mFlag = menu.findItem(R.id.flag);
mUnflag = menu.findItem(R.id.unflag);
if (mQueryString != null) { if (mQueryString != null) {
// show all // show all
@ -2777,6 +2812,10 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
public void onDestroyActionMode(ActionMode mode) { public void onDestroyActionMode(ActionMode mode) {
mActionMode = null; mActionMode = null;
mSelectAll = null; mSelectAll = null;
mMarkAsRead = null;
mMarkAsUnread = null;
mFlag = null;
mUnflag = null;
setAllSelected(false); setAllSelected(false);
} }
@ -2842,6 +2881,20 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
} }
} }
public void showMarkAsRead(boolean show) {
if (mActionMode != null) {
mMarkAsRead.setVisible(show);
mMarkAsUnread.setVisible(!show);
}
}
public void showFlag(boolean show) {
if (mActionMode != null) {
mFlag.setVisible(show);
mUnflag.setVisible(!show);
}
}
@Override @Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) { public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
final List<MessageInfoHolder> selection = getSelectionFromCheckboxes(); final List<MessageInfoHolder> selection = getSelectionFromCheckboxes();
@ -2859,12 +2912,24 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
mSelectedCount = 0; mSelectedCount = 0;
break; break;
} }
case R.id.read_toggle: { case R.id.mark_as_read: {
onToggleRead(selection); setFlag(selection, Flag.SEEN, true);
computeBatchDirection();
break; break;
} }
case R.id.flag_toggle: { case R.id.mark_as_unread: {
onToggleFlag(selection); setFlag(selection, Flag.SEEN, false);
computeBatchDirection();
break;
}
case R.id.flag: {
setFlag(selection, Flag.FLAGGED, true);
computeBatchDirection();
break;
}
case R.id.unflag: {
setFlag(selection, Flag.FLAGGED, false);
computeBatchDirection();
break; break;
} }
case R.id.select_all: { case R.id.select_all: {
@ -2900,6 +2965,6 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
return true; return true;
} }
}; }
} }