mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-25 00:58:50 -05:00
Fix batch operations menu
* Add an explicit configuration option for stars * Replace now-outdated "left handed" widgets config option, now that select widgets are always on the left. * since the multi-modality of the message list was now only a "toggle stars" option, kill that, as it was lots of code and rather redundant
This commit is contained in:
parent
4aca44c1aa
commit
591ca5bc5e
@ -421,7 +421,7 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
|
||||
<string name="account_settings_notify_summary">Notify in status bar when mail arrives</string>
|
||||
<string name="account_settings_notify_sync_summary">Notify in status bar while mail is checked</string>
|
||||
<string name="account_settings_show_combined_label">Show combined Inbox</string>
|
||||
<string name="account_settings_left_handed_label">Widgets on the left</string>
|
||||
<string name="account_settings_star_label">Star flagged messages</string>
|
||||
<string name="account_settings_touchable_label">Touch-friendly view</string>
|
||||
<string name="account_settings_notify_self_label">Notify for mail I sent</string>
|
||||
<string name="account_settings_notify_self_summary">Notify even for mail sent from an account identity</string>
|
||||
|
@ -44,8 +44,8 @@
|
||||
android:title="@string/account_settings_touchable_label"/>
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="messagelist_lefthanded_widgets"
|
||||
android:title="@string/account_settings_left_handed_label"/>
|
||||
android:key="messagelist_stars"
|
||||
android:title="@string/account_settings_star_label"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/operational_preferences" android:key="operational_preferences">
|
||||
|
@ -58,7 +58,6 @@ public class Account implements Serializable
|
||||
boolean mNotifySync;
|
||||
HideButtons mHideMessageViewButtons;
|
||||
boolean mIsSignatureBeforeQuotedText;
|
||||
boolean mLeftHanded;
|
||||
private String mExpungePolicy = EXPUNGE_IMMEDIATELY;
|
||||
private int mMaxPushFolders;
|
||||
|
||||
@ -100,7 +99,6 @@ public class Account implements Serializable
|
||||
mVibrate = false;
|
||||
mRing = true;
|
||||
mNotifySelfNewMail = true;
|
||||
mLeftHanded = false;
|
||||
mFolderDisplayMode = FolderMode.NOT_SECOND_CLASS;
|
||||
mFolderSyncMode = FolderMode.FIRST_CLASS;
|
||||
mFolderPushMode = FolderMode.FIRST_CLASS;
|
||||
@ -181,7 +179,6 @@ public class Account implements Serializable
|
||||
mTransportUri = Utility.base64Decode(preferences.getPreferences().getString(mUuid
|
||||
+ ".transportUri", null));
|
||||
mDescription = preferences.getPreferences().getString(mUuid + ".description", null);
|
||||
mLeftHanded = preferences.getPreferences().getBoolean(mUuid + ".leftHanded", false);
|
||||
mAlwaysBcc = preferences.getPreferences().getString(mUuid + ".alwaysBcc", mAlwaysBcc);
|
||||
mAutomaticCheckIntervalMinutes = preferences.getPreferences().getInt(mUuid
|
||||
+ ".automaticCheckIntervalMinutes", -1);
|
||||
@ -445,17 +442,6 @@ public class Account implements Serializable
|
||||
identities.get(0).setEmail(email);
|
||||
}
|
||||
|
||||
|
||||
public boolean getLeftHanded()
|
||||
{
|
||||
return mLeftHanded;
|
||||
}
|
||||
|
||||
public void setLeftHanded(boolean leftie)
|
||||
{
|
||||
mLeftHanded = leftie;
|
||||
}
|
||||
|
||||
public String getAlwaysBcc()
|
||||
{
|
||||
return mAlwaysBcc;
|
||||
@ -521,7 +507,6 @@ public class Account implements Serializable
|
||||
editor.remove(mUuid + ".name");
|
||||
editor.remove(mUuid + ".email");
|
||||
editor.remove(mUuid + ".alwaysBcc");
|
||||
editor.remove(mUuid + ".mLeftHanded");
|
||||
editor.remove(mUuid + ".automaticCheckIntervalMinutes");
|
||||
editor.remove(mUuid + ".lastAutomaticCheckTime");
|
||||
editor.remove(mUuid + ".notifyNewMail");
|
||||
@ -593,7 +578,6 @@ public class Account implements Serializable
|
||||
editor.putString(mUuid + ".transportUri", Utility.base64Encode(mTransportUri));
|
||||
editor.putString(mUuid + ".description", mDescription);
|
||||
editor.putString(mUuid + ".alwaysBcc", mAlwaysBcc);
|
||||
editor.putBoolean(mUuid + ".leftHanded", mLeftHanded);
|
||||
editor.putInt(mUuid + ".automaticCheckIntervalMinutes", mAutomaticCheckIntervalMinutes);
|
||||
editor.putInt(mUuid + ".displayCount", mDisplayCount);
|
||||
editor.putLong(mUuid + ".lastAutomaticCheckTime", mLastAutomaticCheckTime);
|
||||
|
@ -66,7 +66,7 @@ public class K9 extends Application
|
||||
private static boolean mAnimations = true;
|
||||
|
||||
|
||||
private static boolean mMessageListLefthandedWidgets = false;
|
||||
private static boolean mMessageListStars = true;
|
||||
private static boolean mMessageListTouchable = false;
|
||||
|
||||
|
||||
@ -307,7 +307,7 @@ public class K9 extends Application
|
||||
editor.putBoolean("enableSensitiveLogging", K9.DEBUG_SENSITIVE);
|
||||
editor.putString("backgroundOperations", K9.backgroundOps.toString());
|
||||
editor.putBoolean("animations", mAnimations);
|
||||
editor.putBoolean("messageListLefthandedWidgets",mMessageListLefthandedWidgets);
|
||||
editor.putBoolean("messageListStars",mMessageListStars);
|
||||
editor.putBoolean("messageListTouchable",mMessageListTouchable);
|
||||
editor.putInt("theme", theme);
|
||||
}
|
||||
@ -322,7 +322,7 @@ public class K9 extends Application
|
||||
DEBUG = sprefs.getBoolean("enableDebugLogging", false);
|
||||
DEBUG_SENSITIVE = sprefs.getBoolean("enableSensitiveLogging", false);
|
||||
mAnimations = sprefs.getBoolean("animations", true);
|
||||
mMessageListLefthandedWidgets = sprefs.getBoolean("messageListLefthandedWidgets",false);
|
||||
mMessageListStars = sprefs.getBoolean("messageListStars",true);
|
||||
mMessageListTouchable = sprefs.getBoolean("messageListTouchable",false);
|
||||
|
||||
|
||||
@ -454,14 +454,14 @@ public class K9 extends Application
|
||||
mMessageListTouchable = touchy;
|
||||
}
|
||||
|
||||
public static boolean messageListLefthandedWidgets()
|
||||
public static boolean messageListStars()
|
||||
{
|
||||
return mMessageListLefthandedWidgets;
|
||||
return mMessageListStars;
|
||||
}
|
||||
|
||||
public static void setMessageListLefthandedWidgets(boolean lefty)
|
||||
public static void setMessageListStars(boolean stars)
|
||||
{
|
||||
mMessageListLefthandedWidgets = lefty;
|
||||
mMessageListStars = stars;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,16 +74,11 @@ public class MessageList
|
||||
private static final String STATE_KEY_SELECTION = "com.fsck.k9.activity.messagelist_selection";
|
||||
private static final String STATE_KEY_SELECTED_COUNT = "com.fsck.k9.activity.messagelist_selected_count";
|
||||
|
||||
private static final int WIDGET_NONE = 1;
|
||||
private static final int WIDGET_FLAG = 2;
|
||||
|
||||
|
||||
private ListView mListView;
|
||||
|
||||
private boolean mTouchView = true;
|
||||
|
||||
private int mSelectedWidget = WIDGET_FLAG;
|
||||
|
||||
private MessageListAdapter mAdapter;
|
||||
|
||||
private FolderInfoHolder mCurrentFolder;
|
||||
@ -113,7 +108,7 @@ public class MessageList
|
||||
private boolean sortAscending = true;
|
||||
private boolean sortDateAscending = false;
|
||||
|
||||
private boolean mLeftHanded = false;
|
||||
private boolean mStars = true;
|
||||
private int mSelectedCount = 0;
|
||||
|
||||
private View mBatchButtonArea;
|
||||
@ -362,14 +357,7 @@ public class MessageList
|
||||
mBatchFlagButton.setOnClickListener(this);
|
||||
mBatchDoneButton = (Button) findViewById(R.id.batch_done_button);
|
||||
|
||||
if (mTouchView == true)
|
||||
{
|
||||
mBatchDoneButton.setOnClickListener(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
mBatchDoneButton.setVisibility(View.GONE);
|
||||
}
|
||||
mBatchDoneButton.setOnClickListener(this);
|
||||
|
||||
Intent intent = getIntent();
|
||||
mAccount = (Account)intent.getSerializableExtra(EXTRA_ACCOUNT);
|
||||
@ -476,7 +464,7 @@ public class MessageList
|
||||
{
|
||||
super.onResume();
|
||||
|
||||
mLeftHanded = K9.messageListLefthandedWidgets();
|
||||
mStars = K9.messageListStars();
|
||||
mTouchView = K9.messageListTouchable();
|
||||
|
||||
sortType = mController.getSortType();
|
||||
@ -537,34 +525,23 @@ public class MessageList
|
||||
|
||||
case KeyEvent.KEYCODE_DPAD_LEFT:
|
||||
{
|
||||
if (mQueryString != null)
|
||||
{ // no widget customization in search results yet
|
||||
return false;
|
||||
}
|
||||
else if (mBatchButtonArea.hasFocus())
|
||||
if (mBatchButtonArea.hasFocus())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
cycleVisibleWidgets(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
case KeyEvent.KEYCODE_DPAD_RIGHT:
|
||||
{
|
||||
if (mQueryString != null)
|
||||
{ // no widget customization in search results yet
|
||||
return false;
|
||||
}
|
||||
else if (mBatchButtonArea.hasFocus())
|
||||
if (mBatchButtonArea.hasFocus())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
cycleVisibleWidgets(false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -712,97 +689,6 @@ public class MessageList
|
||||
|
||||
}
|
||||
|
||||
public void cycleVisibleWidgets(boolean ascending)
|
||||
{
|
||||
if (mTouchView == true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ascending)
|
||||
{
|
||||
|
||||
switch (mSelectedWidget)
|
||||
{
|
||||
case WIDGET_FLAG:
|
||||
{
|
||||
mSelectedWidget = WIDGET_NONE;
|
||||
break;
|
||||
}
|
||||
case WIDGET_NONE:
|
||||
{
|
||||
mSelectedWidget = WIDGET_FLAG;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (mSelectedWidget)
|
||||
{
|
||||
case WIDGET_FLAG:
|
||||
{
|
||||
mSelectedWidget=WIDGET_NONE;
|
||||
break;
|
||||
}
|
||||
case WIDGET_NONE:
|
||||
{
|
||||
mSelectedWidget=WIDGET_FLAG;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
configureWidgets();
|
||||
|
||||
}
|
||||
|
||||
private void configureWidgets()
|
||||
{
|
||||
switch (mSelectedWidget)
|
||||
{
|
||||
case WIDGET_FLAG:
|
||||
hideBatchButtons();
|
||||
break;
|
||||
case WIDGET_NONE:
|
||||
hideBatchButtons();
|
||||
break;
|
||||
}
|
||||
|
||||
int count = mListView.getChildCount();
|
||||
for (int i=0; i<count; i++)
|
||||
{
|
||||
setVisibleWidgetsForListItem(mListView.getChildAt(i), mSelectedWidget);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setVisibleWidgetsForListItem(View v, int showWidget)
|
||||
{
|
||||
|
||||
Button flagged = (Button) v.findViewById(R.id.flagged);
|
||||
CheckBox selected = (CheckBox) v.findViewById(R.id.selected_checkbox);
|
||||
|
||||
if (mTouchView == true || flagged == null || selected == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (showWidget == WIDGET_NONE)
|
||||
{
|
||||
flagged.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
flagged.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void onAccounts()
|
||||
{
|
||||
Accounts.listAccounts(this);
|
||||
@ -1259,16 +1145,6 @@ public class MessageList
|
||||
flagSelected(Flag.FLAGGED, false);
|
||||
return true;
|
||||
|
||||
case R.id.batch_plain_mode:
|
||||
mSelectedWidget = WIDGET_NONE;
|
||||
configureWidgets();
|
||||
return true;
|
||||
|
||||
case R.id.batch_flag_mode:
|
||||
mSelectedWidget = WIDGET_FLAG;
|
||||
configureWidgets();
|
||||
return true;
|
||||
|
||||
case R.id.expunge:
|
||||
if (mCurrentFolder != null)
|
||||
{
|
||||
@ -1286,7 +1162,6 @@ public class MessageList
|
||||
R.id.batch_select_all, R.id.batch_deselect_all
|
||||
};
|
||||
|
||||
private final int[] batch_modes = { R.id.batch_flag_mode, R.id.batch_plain_mode };
|
||||
|
||||
private void setOpsState(Menu menu, boolean state, boolean enabled)
|
||||
{
|
||||
@ -1297,13 +1172,6 @@ public class MessageList
|
||||
}
|
||||
}
|
||||
|
||||
private void setOpsMode(Menu menu, int currentModeId)
|
||||
{
|
||||
for (int id : batch_modes)
|
||||
{
|
||||
menu.findItem(id).setVisible(id != currentModeId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu)
|
||||
@ -1318,33 +1186,22 @@ public class MessageList
|
||||
menu.findItem(R.id.list_folders).setVisible(false);
|
||||
menu.findItem(R.id.expunge).setVisible(false);
|
||||
}
|
||||
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();
|
||||
setOpsState(menu, true, anySelected);
|
||||
|
||||
boolean newFlagState = computeBatchDirection(true);
|
||||
boolean newReadState = computeBatchDirection(false);
|
||||
menu.findItem(R.id.batch_flag_op).setVisible(newFlagState);
|
||||
menu.findItem(R.id.batch_unflag_op).setVisible(!newFlagState);
|
||||
menu.findItem(R.id.batch_mark_read_op).setVisible(newReadState);
|
||||
menu.findItem(R.id.batch_mark_unread_op).setVisible(!newReadState);
|
||||
menu.findItem(R.id.batch_deselect_all).setEnabled(anySelected);
|
||||
menu.findItem(R.id.batch_select_all).setEnabled(true);
|
||||
// TODO: batch move and copy not yet implemented
|
||||
menu.findItem(R.id.batch_move_op).setVisible(false);
|
||||
menu.findItem(R.id.batch_copy_op).setVisible(false);
|
||||
}
|
||||
boolean anySelected = anySelected();
|
||||
setOpsState(menu, true, anySelected);
|
||||
|
||||
boolean newFlagState = computeBatchDirection(true);
|
||||
boolean newReadState = computeBatchDirection(false);
|
||||
menu.findItem(R.id.batch_flag_op).setVisible(newFlagState);
|
||||
menu.findItem(R.id.batch_unflag_op).setVisible(!newFlagState);
|
||||
menu.findItem(R.id.batch_mark_read_op).setVisible(newReadState);
|
||||
menu.findItem(R.id.batch_mark_unread_op).setVisible(!newReadState);
|
||||
menu.findItem(R.id.batch_deselect_all).setEnabled(anySelected);
|
||||
menu.findItem(R.id.batch_select_all).setEnabled(true);
|
||||
// TODO: batch move and copy not yet implemented
|
||||
menu.findItem(R.id.batch_move_op).setVisible(false);
|
||||
menu.findItem(R.id.batch_copy_op).setVisible(false);
|
||||
|
||||
|
||||
if (mCurrentFolder != null && mCurrentFolder.outbox)
|
||||
{
|
||||
@ -1996,7 +1853,10 @@ public class MessageList
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (mStars == false)
|
||||
{
|
||||
holder.flagged.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
holder.selected = (CheckBox) view.findViewById(R.id.selected_checkbox);
|
||||
|
||||
@ -2014,7 +1874,6 @@ public class MessageList
|
||||
|
||||
holder.subject.setTypeface(null, message.read ? Typeface.NORMAL : Typeface.BOLD);
|
||||
|
||||
setVisibleWidgetsForListItem(view, mSelectedWidget);
|
||||
// XXX TODO there has to be some way to walk our view hierarchy and get this
|
||||
holder.flagged.setTag((Integer)position);
|
||||
|
||||
@ -2410,18 +2269,14 @@ public class MessageList
|
||||
//We must set the flag before showing the buttons
|
||||
//as the buttons text depends on what is selected
|
||||
message.selected = isChecked;
|
||||
if (mTouchView == true)
|
||||
if (isChecked == true)
|
||||
{
|
||||
if (isChecked == true)
|
||||
{
|
||||
selected.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
selected.setVisibility(View.GONE);
|
||||
}
|
||||
selected.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
selected.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
toggleBatchButtons();
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class Prefs extends K9PreferenceActivity
|
||||
private static final String PREFERENCE_SENSITIVE_LOGGING = "sensitive_logging";
|
||||
|
||||
private static final String PREFERENCE_ANIMATIONS = "animations";
|
||||
private static final String PREFERENCE_MESSAGELIST_LEFTHANDED_WIDGETS = "messagelist_lefthanded_widgets";
|
||||
private static final String PREFERENCE_MESSAGELIST_STARS = "messagelist_stars";
|
||||
private static final String PREFERENCE_MESSAGELIST_TOUCHABLE = "messagelist_touchable";
|
||||
|
||||
private ListPreference mTheme;
|
||||
@ -36,7 +36,7 @@ public class Prefs extends K9PreferenceActivity
|
||||
private CheckBoxPreference mDebugLogging;
|
||||
private CheckBoxPreference mSensitiveLogging;
|
||||
private CheckBoxPreference mAnimations;
|
||||
private CheckBoxPreference mLefthandedWidgets;
|
||||
private CheckBoxPreference mStars;
|
||||
private CheckBoxPreference mTouchable;
|
||||
|
||||
|
||||
@ -124,8 +124,8 @@ public class Prefs extends K9PreferenceActivity
|
||||
mAnimations = (CheckBoxPreference)findPreference(PREFERENCE_ANIMATIONS);
|
||||
mAnimations.setChecked(K9.isAnimations());
|
||||
|
||||
mLefthandedWidgets = (CheckBoxPreference)findPreference(PREFERENCE_MESSAGELIST_LEFTHANDED_WIDGETS);
|
||||
mLefthandedWidgets.setChecked(K9.messageListLefthandedWidgets());
|
||||
mStars = (CheckBoxPreference)findPreference(PREFERENCE_MESSAGELIST_STARS);
|
||||
mStars.setChecked(K9.messageListStars());
|
||||
|
||||
mTouchable = (CheckBoxPreference)findPreference(PREFERENCE_MESSAGELIST_TOUCHABLE);
|
||||
mTouchable.setChecked(K9.messageListTouchable());
|
||||
@ -147,7 +147,7 @@ public class Prefs extends K9PreferenceActivity
|
||||
K9.setBackgroundOps(newBackgroundOps);
|
||||
|
||||
K9.setAnimations(mAnimations.isChecked());
|
||||
K9.setMessageListLefthandedWidgets(mLefthandedWidgets.isChecked());
|
||||
K9.setMessageListStars(mStars.isChecked());
|
||||
|
||||
K9.setMessageListTouchable(mTouchable.isChecked());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user