1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

Eliminate "select" mode in favor of a unified swipe and context menu -based

always-available select action.  For the moment, this means
that widgets_on_left does nothing at all. based on feedback, I may kill
the preference and multi-mode behaviour entirely in favor of "show stars?"
(and possibly "show stars on left"

Stars, "checkboxes" and color bars updated to actually fit in wide mode.
This commit is contained in:
Jesse Vincent 2010-01-17 04:20:39 +00:00
parent 0de7b15aa1
commit 591a3af6dc
18 changed files with 137 additions and 142 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 879 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 821 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 362 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 774 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 895 B

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false"
android:drawable="@drawable/btn_check_small_off" />
<item android:state_checked="true"
android:drawable="@drawable/btn_check_small_on" />
</selector>

8
res/drawable/star.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false"
android:drawable="@drawable/btn_star_big_buttonless_off" />
<item android:state_checked="true"
android:drawable="@drawable/btn_star_big_buttonless_on" />
</selector>

View File

@ -4,28 +4,38 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:paddingRight="1dip" android:paddingRight="1dip"
android:paddingTop="2dip"
android:background="#cccccc" android:background="#cccccc"
> >
<LinearLayout android:id="@+id/widgets_right" <CheckBox
android:layout_width="wrap_content" android:id="@+id/flagged"
android:layout_height="fill_parent" android:focusable="false"
android:layout_alignParentRight="true" android:button="@drawable/star"
/>
<View android:layout_gravity="center_vertical"
android:layout_height="20dip"
android:layout_width="20dip"
android:layout_alignParentRight="true"
/>
<RelativeLayout
android:id="@+id/chip" android:id="@+id/chip"
android:background="@drawable/appointment_indicator_leftside_1" android:background="@drawable/appointment_indicator_leftside_1"
android:layout_width="4dip" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:layout_marginRight="2dip"
android:layout_height="20dip"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:padding="0dip" >
/> <CheckBox
android:id="@+id/selected_checkbox"
<LinearLayout android:id="@+id/widgets_left" android:layout_width="12dip"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_height="fill_parent" android:button="@drawable/checkbox_small"
android:layout_toRightOf="@id/chip" android:layout_centerVertical="true"
/> android:layout_centerHorizontal="true"
android:focusable="false"
android:visibility="gone"
/>
</RelativeLayout>
<TextView <TextView
android:id="@+id/date" android:id="@+id/date"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
@ -36,7 +46,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="right" android:gravity="right"
android:layout_alignWithParentIfMissing="true" android:layout_alignWithParentIfMissing="true"
android:layout_toLeftOf="@+id/widgets_right" /> android:layout_toLeftOf="@+id/flagged"/>
<TextView <TextView
android:id="@+id/from" android:id="@+id/from"
android:ellipsize="end" android:ellipsize="end"
@ -59,6 +69,6 @@
android:paddingLeft="10dip" android:paddingLeft="10dip"
android:layout_marginRight="1dip" android:layout_marginRight="1dip"
android:layout_alignWithParentIfMissing="true" android:layout_alignWithParentIfMissing="true"
android:layout_toRightOf="@+id/widgets_left" android:layout_toRightOf="@+id/chip"
android:layout_toLeftOf="@+id/from" /> android:layout_toLeftOf="@+id/from" />
</RelativeLayout> </RelativeLayout>

View File

@ -7,23 +7,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
> >
<CheckBox
android:id="@+id/flagged"
android:focusable="false"
style="?android:attr/starStyle"
android:layout_gravity="center_vertical"
android:layout_height="15dip"
android:layout_width="15dip"
/>
<!-- http://stackoverflow.com/questions/1121192/android-custom-listview-unable-to-click-on-items <!-- http://stackoverflow.com/questions/1121192/android-custom-listview-unable-to-click-on-items
we want something a bit bigger than it is right now --> we want something a bit bigger than it is right now -->
<CheckBox
android:id="@+id/selected_checkbox"
android:layout_width="18dip"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:focusable="false"
android:button="@drawable/checkbox"
android:background="@drawable/checkbox_background"
/>
</LinearLayout> </LinearLayout>

View File

@ -7,24 +7,38 @@
android:paddingTop="2dip" android:paddingTop="2dip"
android:background="#cccccc" android:background="#cccccc"
> >
<LinearLayout android:id="@+id/widgets_right" <RelativeLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
/>
<View
android:id="@+id/chip" android:id="@+id/chip"
android:background="@drawable/appointment_indicator_leftside_1" android:background="@drawable/appointment_indicator_leftside_1"
android:layout_width="4dip" android:layout_width="wrap_content"
android:layout_marginRight="2dip"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
/> >
<LinearLayout android:id="@+id/widgets_left" <CheckBox
android:layout_width="wrap_content" android:id="@+id/selected_checkbox"
android:layout_height="fill_parent" android:layout_width="24dip"
android:layout_toRightOf="@id/chip" android:layout_height="wrap_content"
/> android:button="@drawable/checkbox"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:focusable="false"
android:visibility="gone"
/>
</RelativeLayout>
<CheckBox
android:id="@+id/flagged"
android:focusable="false"
android:button="@drawable/star"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center_vertical"
android:layout_height="20dip"
android:layout_width="20dip"
/>
<TextView <TextView
android:id="@+id/subject" android:id="@+id/subject"
android:ellipsize="end" android:ellipsize="end"
@ -34,8 +48,8 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="10dip" android:paddingLeft="10dip"
android:layout_toLeftOf="@id/widgets_right" android:layout_toLeftOf="@id/flagged"
android:layout_toRightOf="@+id/widgets_left" android:layout_toRightOf="@+id/chip"
android:layout_alignWithParentIfMissing="true" android:layout_alignWithParentIfMissing="true"
android:layout_marginRight="1dip" /> android:layout_marginRight="1dip" />
<TextView <TextView
@ -48,7 +62,7 @@
android:textColor="?android:attr/textColorSecondary" android:textColor="?android:attr/textColorSecondary"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toLeftOf="@id/widgets_right" android:layout_toLeftOf="@id/flagged"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:background="@android:color/transparent" android:background="@android:color/transparent"
android:layout_alignWithParentIfMissing="true" android:layout_alignWithParentIfMissing="true"
@ -64,7 +78,7 @@
android:paddingLeft="12dip" android:paddingLeft="12dip"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_toLeftOf="@id/date" android:layout_toLeftOf="@id/date"
android:layout_toRightOf="@id/widgets_left" android:layout_toRightOf="@id/chip"
/> />
</RelativeLayout> </RelativeLayout>

View File

@ -16,12 +16,4 @@
/> />
<!-- http://stackoverflow.com/questions/1121192/android-custom-listview-unable-to-click-on-items <!-- http://stackoverflow.com/questions/1121192/android-custom-listview-unable-to-click-on-items
we want something a bit bigger than it is right now --> we want something a bit bigger than it is right now -->
<CheckBox
android:id="@+id/selected_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:focusable="false"
android:button="@drawable/checkbox"
/>
</LinearLayout> </LinearLayout>

View File

@ -3,6 +3,15 @@
<item <item
android:id="@+id/open" android:id="@+id/open"
android:title="@string/open_action" android:title="@string/open_action"
/>
<item
android:id="@+id/select"
android:title="@string/select_action"
/>
<item
android:id="@+id/unselect"
android:visible="false"
android:title="@string/unselect_action"
/> />
<item <item
android:id="@+id/delete" android:id="@+id/delete"

View File

@ -47,11 +47,6 @@
android:title="@string/batch_flag_mode" android:title="@string/batch_flag_mode"
android:visible="false" android:visible="false"
/> />
<item
android:id="@+id/batch_select_mode"
android:title="@string/batch_select_mode"
android:visible="false"
/>
<item <item
android:id="@+id/batch_plain_mode" android:id="@+id/batch_plain_mode"
android:title="@string/batch_plain_mode" android:title="@string/batch_plain_mode"

View File

@ -35,6 +35,8 @@
<string name="okay_action">OK</string> <!-- User to confirm acceptance of dialog boxes, warnings, errors, etc. --> <string name="okay_action">OK</string> <!-- User to confirm acceptance of dialog boxes, warnings, errors, etc. -->
<string name="cancel_action">Cancel</string> <string name="cancel_action">Cancel</string>
<string name="send_action">Send</string> <string name="send_action">Send</string>
<string name="select_action">Select</string>
<string name="unselect_action">Unselect</string>
<string name="reply_action">Reply</string> <string name="reply_action">Reply</string>
<string name="reply_all_action">Reply all</string> <string name="reply_all_action">Reply all</string>
<string name="delete_action">Delete</string> <string name="delete_action">Delete</string>

View File

@ -464,7 +464,7 @@ public class MessagingController implements Runnable
} }
} }
} }
for (MessagingListener l : getListeners()) for (MessagingListener l : getListeners())
{ {
l.listFoldersFinished(account); l.listFoldersFinished(account);

View File

@ -76,7 +76,6 @@ public class MessageList
private static final int WIDGET_NONE = 1; private static final int WIDGET_NONE = 1;
private static final int WIDGET_FLAG = 2; private static final int WIDGET_FLAG = 2;
private static final int WIDGET_MULTISELECT = 3;
private ListView mListView; private ListView mListView;
@ -309,7 +308,7 @@ public class MessageList
mController.loadMoreMessages(mAccount, mFolderName, mAdapter.mListener); mController.loadMoreMessages(mAccount, mFolderName, mAdapter.mListener);
return; return;
} }
else if (mSelectedWidget == WIDGET_MULTISELECT || (mTouchView != false && mSelectedCount > 0)) else if (mSelectedCount > 0)
{ {
// In multiselect mode make sure that clicking on the item results in // In multiselect mode make sure that clicking on the item results in
// toggling the 'selected' checkbox // toggling the 'selected' checkbox
@ -726,11 +725,6 @@ public class MessageList
switch (mSelectedWidget) switch (mSelectedWidget)
{ {
case WIDGET_FLAG: case WIDGET_FLAG:
{
mSelectedWidget = WIDGET_MULTISELECT;
break;
}
case WIDGET_MULTISELECT:
{ {
mSelectedWidget = WIDGET_NONE; mSelectedWidget = WIDGET_NONE;
break; break;
@ -753,11 +747,6 @@ public class MessageList
break; break;
} }
case WIDGET_NONE: case WIDGET_NONE:
{
mSelectedWidget=WIDGET_MULTISELECT;
break;
}
case WIDGET_MULTISELECT:
{ {
mSelectedWidget=WIDGET_FLAG; mSelectedWidget=WIDGET_FLAG;
break; break;
@ -781,9 +770,6 @@ public class MessageList
case WIDGET_NONE: case WIDGET_NONE:
hideBatchButtons(); hideBatchButtons();
break; break;
case WIDGET_MULTISELECT:
toggleBatchButtons();
break;
} }
int count = mListView.getChildCount(); int count = mListView.getChildCount();
@ -807,26 +793,14 @@ public class MessageList
if (showWidget == WIDGET_NONE) if (showWidget == WIDGET_NONE)
{ {
v.findViewById(R.id.widgets).setVisibility(View.GONE); flagged.setVisibility(View.GONE);
return; return;
} }
else else
{
v.findViewById(R.id.widgets).setVisibility(View.VISIBLE);
}
if (showWidget == WIDGET_MULTISELECT)
{
flagged.setVisibility(View.GONE);
selected.setVisibility(View.VISIBLE);
}
else
{ {
flagged.setVisibility(View.VISIBLE); flagged.setVisibility(View.VISIBLE);
selected.setVisibility(View.GONE);
} }
} }
private void onAccounts() private void onAccounts()
@ -1290,11 +1264,6 @@ public class MessageList
configureWidgets(); configureWidgets();
return true; return true;
case R.id.batch_select_mode:
mSelectedWidget = WIDGET_MULTISELECT;
configureWidgets();
return true;
case R.id.batch_flag_mode: case R.id.batch_flag_mode:
mSelectedWidget = WIDGET_FLAG; mSelectedWidget = WIDGET_FLAG;
configureWidgets(); configureWidgets();
@ -1317,7 +1286,7 @@ public class MessageList
R.id.batch_select_all, R.id.batch_deselect_all R.id.batch_select_all, R.id.batch_deselect_all
}; };
private final int[] batch_modes = { R.id.batch_flag_mode, R.id.batch_select_mode, R.id.batch_plain_mode }; private final int[] batch_modes = { R.id.batch_flag_mode, R.id.batch_plain_mode };
private void setOpsState(Menu menu, boolean state, boolean enabled) private void setOpsState(Menu menu, boolean state, boolean enabled)
{ {
@ -1349,17 +1318,21 @@ public class MessageList
menu.findItem(R.id.list_folders).setVisible(false); menu.findItem(R.id.list_folders).setVisible(false);
menu.findItem(R.id.expunge).setVisible(false); menu.findItem(R.id.expunge).setVisible(false);
} }
if (mTouchView == true || mSelectedWidget == WIDGET_MULTISELECT) if (mSelectedWidget == WIDGET_FLAG)
{
setOpsState(menu, false, false);
setOpsMode(menu, R.id.batch_flag_mode);
}
else if (mSelectedWidget == WIDGET_NONE)
{
setOpsState(menu, false, false);
setOpsMode(menu, R.id.batch_plain_mode);
}
else
{ {
boolean anySelected = anySelected(); boolean anySelected = anySelected();
setOpsState(menu, true, anySelected); setOpsState(menu, true, anySelected);
if (mTouchView == false)
{
setOpsMode(menu, R.id.batch_select_mode);
}
boolean newFlagState = computeBatchDirection(true); boolean newFlagState = computeBatchDirection(true);
boolean newReadState = computeBatchDirection(false); boolean newReadState = computeBatchDirection(false);
menu.findItem(R.id.batch_flag_op).setVisible(newFlagState); menu.findItem(R.id.batch_flag_op).setVisible(newFlagState);
@ -1372,16 +1345,6 @@ public class MessageList
menu.findItem(R.id.batch_move_op).setVisible(false); menu.findItem(R.id.batch_move_op).setVisible(false);
menu.findItem(R.id.batch_copy_op).setVisible(false); menu.findItem(R.id.batch_copy_op).setVisible(false);
} }
else if (mSelectedWidget == WIDGET_FLAG)
{
setOpsState(menu, false, false);
setOpsMode(menu, R.id.batch_flag_mode);
}
else if (mSelectedWidget == WIDGET_NONE)
{
setOpsState(menu, false, false);
setOpsMode(menu, R.id.batch_plain_mode);
}
if (mCurrentFolder != null && mCurrentFolder.outbox) if (mCurrentFolder != null && mCurrentFolder.outbox)
{ {
@ -1420,17 +1383,22 @@ public class MessageList
{ {
case R.id.open: case R.id.open:
onOpenMessage(holder); onOpenMessage(holder);
break;
case R.id.select:
setSelected(holder, true);
break;
case R.id.unselect:
setSelected(holder, false);
break; break;
case R.id.delete: case R.id.delete:
onDelete(holder, info.position); onDelete(holder, info.position);
break; break;
case R.id.reply: case R.id.reply:
onReply(holder); onReply(holder);
break; break;
case R.id.reply_all: case R.id.reply_all:
@ -1536,13 +1504,6 @@ public class MessageList
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
MessageInfoHolder message = (MessageInfoHolder) mAdapter.getItem(info.position); MessageInfoHolder message = (MessageInfoHolder) mAdapter.getItem(info.position);
// in multi-select mode, the context menu pops up unintentionally
// causes misclicks
if (mSelectedWidget == WIDGET_MULTISELECT)
{
return;
}
if (message == null) if (message == null)
{ {
return; return;
@ -1571,6 +1532,17 @@ public class MessageList
{ {
menu.findItem(R.id.move).setVisible(false); menu.findItem(R.id.move).setVisible(false);
} }
if (message.selected)
{
menu.findItem(R.id.select).setVisible(false);
menu.findItem(R.id.unselect).setVisible(true);
}
else
{
menu.findItem(R.id.select).setVisible(true);
menu.findItem(R.id.unselect).setVisible(false);
}
} }
class MessageListAdapter extends BaseAdapter class MessageListAdapter extends BaseAdapter
@ -1999,18 +1971,6 @@ public class MessageList
{ {
view = mInflater.inflate(R.layout.message_list_item, parent, false); view = mInflater.inflate(R.layout.message_list_item, parent, false);
view.setId(R.layout.message_list_item); view.setId(R.layout.message_list_item);
View widgetParent;
if (mLeftHanded == false)
{
widgetParent = view.findViewById(R.id.widgets_right);
}
else
{
widgetParent = view.findViewById(R.id.widgets_left);
}
View widgets = mInflater.inflate(R.layout.message_list_widgets,parent,false);
widgets.setId(R.id.widgets);
((LinearLayout) widgetParent).addView(widgets);
} }
} }
@ -2701,6 +2661,20 @@ public class MessageList
toggleBatchButtons(); toggleBatchButtons();
} }
private void setSelected(MessageInfoHolder holder, boolean newState)
{
if (holder.selected != newState)
{
holder.selected = newState;
mSelectedCount += (newState ? 1 : -1);
}
mAdapter.notifyDataSetChanged();
toggleBatchButtons();
}
private void flagSelected(Flag flag, boolean newState) private void flagSelected(Flag flag, boolean newState)
{ {
List<Message> messageList = new ArrayList<Message>(); List<Message> messageList = new ArrayList<Message>();

View File

@ -610,7 +610,7 @@ public class ImapStore extends Store
{ {
return mName; return mName;
} }
private boolean exists(String folderName) throws MessagingException private boolean exists(String folderName) throws MessagingException
{ {
try try
@ -741,7 +741,7 @@ public class ImapStore extends Store
try try
{ {
String remoteDestName = encodeFolderName(iFolder.getPrefixedName()); String remoteDestName = encodeFolderName(iFolder.getPrefixedName());
if (!exists(remoteDestName)) if (!exists(remoteDestName))
{ {
/* /*