1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-25 00:58:50 -05:00

Make actions shown in message view menu configurable

Fixes #5850.
This commit is contained in:
Leon Handreke 2013-08-24 10:34:52 +01:00
parent 09c27d94b8
commit 22639a7361
8 changed files with 168 additions and 13 deletions

View File

@ -56,6 +56,30 @@
android:icon="?attr/iconActionDelete" android:icon="?attr/iconActionDelete"
android:showAsAction="always" android:showAsAction="always"
android:title="@string/delete_action"/> android:title="@string/delete_action"/>
<!-- MessageView -->
<item
android:id="@+id/archive"
android:icon="?attr/iconActionArchive"
android:showAsAction="ifRoom"
android:title="@string/archive_action"/>
<!-- MessageView -->
<item
android:id="@+id/spam"
android:icon="?attr/iconActionSpam"
android:showAsAction="ifRoom"
android:title="@string/spam_action"/>
<!-- MessageView -->
<item
android:id="@+id/move"
android:icon="?attr/iconActionMoveOrCopy"
android:showAsAction="ifRoom"
android:title="@string/move_action"/>
<!-- MessageView -->
<item
android:id="@+id/copy"
android:icon="?attr/iconActionMoveOrCopy"
android:showAsAction="ifRoom"
android:title="@string/copy_action"/>
<!-- MessageView --> <!-- MessageView -->
<item <item

View File

@ -1153,4 +1153,7 @@ Please submit bug reports, contribute new features and ask questions at
<string name="mark_all_as_read">Mark all as read</string> <string name="mark_all_as_read">Mark all as read</string>
<string name="global_settings_colorize_missing_contact_pictures">Colorize missing contact pictures</string> <string name="global_settings_colorize_missing_contact_pictures">Colorize missing contact pictures</string>
<string name="global_settings_messageview_visible_refile_actions_title">Visisble message actions</string>
<string name="global_settings_messageview_visible_refile_actions_summary">Show selected actions in the message view menu</string>
</resources> </resources>

View File

@ -225,6 +225,15 @@
android:title="@string/global_settings_messageview_fixedwidth_label" android:title="@string/global_settings_messageview_fixedwidth_label"
android:summary="@string/global_settings_messageview_fixedwidth_summary" /> android:summary="@string/global_settings_messageview_fixedwidth_summary" />
<com.fsck.k9.preferences.CheckBoxListPreference
android:persistent="false"
android:key="messageview_visible_refile_actions"
android:title="@string/global_settings_messageview_visible_refile_actions_title"
android:summary="@string/global_settings_messageview_visible_refile_actions_summary"
android:dialogTitle="@string/global_settings_messageview_visible_refile_actions_title"
android:positiveButtonText="@android:string/ok"
android:negativeButtonText="@android:string/cancel" />
<CheckBoxPreference <CheckBoxPreference
android:persistent="false" android:persistent="false"
android:key="messageview_mobile_layout" android:key="messageview_mobile_layout"

View File

@ -263,6 +263,13 @@ public class K9 extends Application {
private static SplitViewMode sSplitViewMode = SplitViewMode.NEVER; private static SplitViewMode sSplitViewMode = SplitViewMode.NEVER;
private static boolean sColorizeMissingContactPictures = true; private static boolean sColorizeMissingContactPictures = true;
private static boolean sMessageViewArchiveActionVisible = false;
private static boolean sMessageViewDeleteActionVisible = true;
private static boolean sMessageViewMoveActionVisible = false;
private static boolean sMessageViewCopyActionVisible = false;
private static boolean sMessageViewSpamActionVisible = false;
/** /**
* @see #areDatabasesUpToDate() * @see #areDatabasesUpToDate()
*/ */
@ -541,6 +548,13 @@ public class K9 extends Application {
editor.putBoolean("threadedView", sThreadedViewEnabled); editor.putBoolean("threadedView", sThreadedViewEnabled);
editor.putString("splitViewMode", sSplitViewMode.name()); editor.putString("splitViewMode", sSplitViewMode.name());
editor.putBoolean("colorizeMissingContactPictures", sColorizeMissingContactPictures); editor.putBoolean("colorizeMissingContactPictures", sColorizeMissingContactPictures);
editor.putBoolean("messageViewArchiveActionVisible", sMessageViewArchiveActionVisible);
editor.putBoolean("messageViewDeleteActionVisible", sMessageViewDeleteActionVisible);
editor.putBoolean("messageViewMoveActionVisible", sMessageViewMoveActionVisible);
editor.putBoolean("messageViewCopyActionVisible", sMessageViewCopyActionVisible);
editor.putBoolean("messageViewSpamActionVisible", sMessageViewSpamActionVisible);
fontSizes.save(editor); fontSizes.save(editor);
} }
@ -766,6 +780,13 @@ public class K9 extends Application {
sColorizeMissingContactPictures = sprefs.getBoolean("colorizeMissingContactPictures", true); sColorizeMissingContactPictures = sprefs.getBoolean("colorizeMissingContactPictures", true);
sMessageViewArchiveActionVisible = sprefs.getBoolean("messageViewArchiveActionVisible", false);
sMessageViewDeleteActionVisible = sprefs.getBoolean("messageViewDeleteActionVisible", true);
sMessageViewMoveActionVisible = sprefs.getBoolean("messageViewMoveActionVisible", false);
sMessageViewCopyActionVisible = sprefs.getBoolean("messageViewCopyActionVisible", false);
sMessageViewSpamActionVisible = sprefs.getBoolean("messageViewSpamActionVisible", false);
K9.setK9Language(sprefs.getString("language", "")); K9.setK9Language(sprefs.getString("language", ""));
int themeValue = sprefs.getInt("theme", Theme.LIGHT.ordinal()); int themeValue = sprefs.getInt("theme", Theme.LIGHT.ordinal());
@ -1327,6 +1348,50 @@ public class K9 extends Application {
} }
public static boolean isMessageViewArchiveActionVisible() {
return sMessageViewArchiveActionVisible;
}
public static void setMessageViewArchiveActionVisible(boolean messageViewArchiveActionVisible) {
sMessageViewArchiveActionVisible = messageViewArchiveActionVisible;
}
public static boolean isMessageViewDeleteActionVisible() {
return sMessageViewDeleteActionVisible;
}
public static void setMessageViewDeleteActionVisible(
boolean messageViewDeleteActionVisible) {
sMessageViewDeleteActionVisible = messageViewDeleteActionVisible;
}
public static boolean isMessageViewMoveActionVisible() {
return sMessageViewMoveActionVisible;
}
public static void setMessageViewMoveActionVisible(
boolean messageViewMoveActionVisible) {
sMessageViewMoveActionVisible = messageViewMoveActionVisible;
}
public static boolean isMessageViewCopyActionVisible() {
return sMessageViewCopyActionVisible;
}
public static void setMessageViewCopyActionVisible(
boolean messageViewCopyActionVisible) {
sMessageViewCopyActionVisible = messageViewCopyActionVisible;
}
public static boolean isMessageViewSpamActionVisible() {
return sMessageViewSpamActionVisible;
}
public static void setMessageViewSpamActionVisible(
boolean messageViewSpamActionVisible) {
sMessageViewSpamActionVisible = messageViewSpamActionVisible;
}
/** /**
* Check if we already know whether all databases are using the current database schema. * Check if we already know whether all databases are using the current database schema.
* *

View File

@ -973,8 +973,12 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|| !mMessageViewFragment.isInitialized()) { || !mMessageViewFragment.isInitialized()) {
menu.findItem(R.id.next_message).setVisible(false); menu.findItem(R.id.next_message).setVisible(false);
menu.findItem(R.id.previous_message).setVisible(false); menu.findItem(R.id.previous_message).setVisible(false);
menu.findItem(R.id.delete).setVisible(false);
menu.findItem(R.id.single_message_options).setVisible(false); menu.findItem(R.id.single_message_options).setVisible(false);
menu.findItem(R.id.delete).setVisible(false);
menu.findItem(R.id.archive).setVisible(false);
menu.findItem(R.id.move).setVisible(false);
menu.findItem(R.id.copy).setVisible(false);
menu.findItem(R.id.spam).setVisible(false);
menu.findItem(R.id.refile).setVisible(false); menu.findItem(R.id.refile).setVisible(false);
menu.findItem(R.id.toggle_unread).setVisible(false); menu.findItem(R.id.toggle_unread).setVisible(false);
menu.findItem(R.id.select_text).setVisible(false); menu.findItem(R.id.select_text).setVisible(false);
@ -1022,20 +1026,28 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
menu.findItem(R.id.toggle_unread).setTitle(R.string.mark_as_read_action); menu.findItem(R.id.toggle_unread).setTitle(R.string.mark_as_read_action);
} }
menu.findItem(R.id.copy).setVisible(mMessageViewFragment.isCopyCapable());
// Jellybean has built-in long press selection support // Jellybean has built-in long press selection support
menu.findItem(R.id.select_text).setVisible(Build.VERSION.SDK_INT < 16); menu.findItem(R.id.select_text).setVisible(Build.VERSION.SDK_INT < 16);
if (mMessageViewFragment.isMoveCapable()) { menu.findItem(R.id.delete).setVisible(K9.isMessageViewDeleteActionVisible());
menu.findItem(R.id.move).setVisible(true); menu.findItem(R.id.copy).setVisible(mMessageViewFragment.isCopyCapable()
menu.findItem(R.id.archive).setVisible(mMessageViewFragment.canMessageBeArchived()); && K9.isMessageViewCopyActionVisible());
menu.findItem(R.id.spam).setVisible(mMessageViewFragment.canMessageBeMovedToSpam()); menu.findItem(R.id.move).setVisible(mMessageViewFragment.isMoveCapable()
} else { && K9.isMessageViewMoveActionVisible());
menu.findItem(R.id.move).setVisible(false); menu.findItem(R.id.archive).setVisible(mMessageViewFragment.isMoveCapable()
menu.findItem(R.id.archive).setVisible(false); && mMessageViewFragment.canMessageBeArchived()
menu.findItem(R.id.spam).setVisible(false); && K9.isMessageViewArchiveActionVisible());
} menu.findItem(R.id.spam).setVisible(mMessageViewFragment.isMoveCapable()
&& mMessageViewFragment.canMessageBeMovedToSpam()
&& K9.isMessageViewSpamActionVisible());
Menu refileSubmenu = menu.findItem(R.id.refile).getSubMenu();
refileSubmenu.findItem(R.id.copy).setVisible(mMessageViewFragment.isCopyCapable());
refileSubmenu.findItem(R.id.move).setVisible(mMessageViewFragment.isMoveCapable());
refileSubmenu.findItem(R.id.archive).setVisible(mMessageViewFragment.isMoveCapable()
&& mMessageViewFragment.canMessageBeArchived());
refileSubmenu.findItem(R.id.spam).setVisible(mMessageViewFragment.isMoveCapable()
&& mMessageViewFragment.canMessageBeMovedToSpam());
if (mMessageViewFragment.allHeadersVisible()) { if (mMessageViewFragment.allHeadersVisible()) {
menu.findItem(R.id.show_headers).setVisible(false); menu.findItem(R.id.show_headers).setVisible(false);

View File

@ -76,6 +76,7 @@ public class Prefs extends K9PreferenceActivity {
private static final String PREFERENCE_MESSAGELIST_COLORIZE_MISSING_CONTACT_PICTURES = private static final String PREFERENCE_MESSAGELIST_COLORIZE_MISSING_CONTACT_PICTURES =
"messagelist_colorize_missing_contact_pictures"; "messagelist_colorize_missing_contact_pictures";
private static final String PREFERENCE_MESSAGEVIEW_FIXEDWIDTH = "messageview_fixedwidth_font"; private static final String PREFERENCE_MESSAGEVIEW_FIXEDWIDTH = "messageview_fixedwidth_font";
private static final String PREFERENCE_MESSAGEVIEW_VISIBLE_REFILE_ACTIONS = "messageview_visible_refile_actions";
private static final String PREFERENCE_MESSAGEVIEW_RETURN_TO_LIST = "messageview_return_to_list"; private static final String PREFERENCE_MESSAGEVIEW_RETURN_TO_LIST = "messageview_return_to_list";
private static final String PREFERENCE_MESSAGEVIEW_SHOW_NEXT = "messageview_show_next"; private static final String PREFERENCE_MESSAGEVIEW_SHOW_NEXT = "messageview_show_next";
@ -133,6 +134,7 @@ public class Prefs extends K9PreferenceActivity {
private CheckBoxPreference mDebugLogging; private CheckBoxPreference mDebugLogging;
private CheckBoxPreference mSensitiveLogging; private CheckBoxPreference mSensitiveLogging;
private CheckBoxPreference mWrapFolderNames; private CheckBoxPreference mWrapFolderNames;
private CheckBoxListPreference mVisibleRefileActions;
private CheckBoxPreference mQuietTimeEnabled; private CheckBoxPreference mQuietTimeEnabled;
private com.fsck.k9.preferences.TimePickerPreference mQuietTimeStarts; private com.fsck.k9.preferences.TimePickerPreference mQuietTimeStarts;
@ -410,6 +412,26 @@ public class Prefs extends K9PreferenceActivity {
mWrapFolderNames = (CheckBoxPreference)findPreference(PREFERENCE_FOLDERLIST_WRAP_NAME); mWrapFolderNames = (CheckBoxPreference)findPreference(PREFERENCE_FOLDERLIST_WRAP_NAME);
mWrapFolderNames.setChecked(K9.wrapFolderNames()); mWrapFolderNames.setChecked(K9.wrapFolderNames());
mVisibleRefileActions = (CheckBoxListPreference) findPreference(PREFERENCE_MESSAGEVIEW_VISIBLE_REFILE_ACTIONS);
CharSequence[] visibleRefileActionsEntries = {
getString(R.string.delete_action),
getString(R.string.archive_action),
getString(R.string.move_action),
getString(R.string.copy_action),
getString(R.string.spam_action),
};
boolean[] visibleRefileActionsValues = {
K9.isMessageViewDeleteActionVisible(),
K9.isMessageViewArchiveActionVisible(),
K9.isMessageViewMoveActionVisible(),
K9.isMessageViewCopyActionVisible(),
K9.isMessageViewSpamActionVisible(),
};
mVisibleRefileActions.setItems(visibleRefileActionsEntries);
mVisibleRefileActions.setCheckedItems(visibleRefileActionsValues);
mSplitViewMode = (ListPreference) findPreference(PREFERENCE_SPLITVIEW_MODE); mSplitViewMode = (ListPreference) findPreference(PREFERENCE_SPLITVIEW_MODE);
initListPreference(mSplitViewMode, K9.getSplitViewMode().name(), initListPreference(mSplitViewMode, K9.getSplitViewMode().name(),
mSplitViewMode.getEntries(), mSplitViewMode.getEntryValues()); mSplitViewMode.getEntries(), mSplitViewMode.getEntryValues());
@ -478,6 +500,11 @@ public class Prefs extends K9PreferenceActivity {
K9.setMobileOptimizedLayout(mMobileOptimizedLayout.isChecked()); K9.setMobileOptimizedLayout(mMobileOptimizedLayout.isChecked());
K9.setAutofitWidth(mAutofitWidth.isChecked()); K9.setAutofitWidth(mAutofitWidth.isChecked());
K9.setQuietTimeEnabled(mQuietTimeEnabled.isChecked()); K9.setQuietTimeEnabled(mQuietTimeEnabled.isChecked());
K9.setMessageViewDeleteActionVisible(mVisibleRefileActions.getCheckedItems()[0]);
K9.setMessageViewArchiveActionVisible(mVisibleRefileActions.getCheckedItems()[1]);
K9.setMessageViewMoveActionVisible(mVisibleRefileActions.getCheckedItems()[2]);
K9.setMessageViewCopyActionVisible(mVisibleRefileActions.getCheckedItems()[3]);
K9.setMessageViewSpamActionVisible(mVisibleRefileActions.getCheckedItems()[4]);
K9.setQuietTimeStarts(mQuietTimeStarts.getTime()); K9.setQuietTimeStarts(mQuietTimeStarts.getTime());
K9.setQuietTimeEnds(mQuietTimeEnds.getTime()); K9.setQuietTimeEnds(mQuietTimeEnds.getTime());

View File

@ -230,6 +230,21 @@ public class GlobalSettings {
s.put("colorizeMissingContactPictures", Settings.versions( s.put("colorizeMissingContactPictures", Settings.versions(
new V(29, new BooleanSetting(true)) new V(29, new BooleanSetting(true))
)); ));
s.put("messageViewDeleteActionVisible", Settings.versions(
new V(30, new BooleanSetting(true))
));
s.put("messageViewArchiveActionVisible", Settings.versions(
new V(30, new BooleanSetting(true))
));
s.put("messageViewMoveActionVisible", Settings.versions(
new V(30, new BooleanSetting(true))
));
s.put("messageViewCopyActionVisible", Settings.versions(
new V(30, new BooleanSetting(true))
));
s.put("messageViewSpamActionVisible", Settings.versions(
new V(30, new BooleanSetting(true))
));
SETTINGS = Collections.unmodifiableMap(s); SETTINGS = Collections.unmodifiableMap(s);

View File

@ -35,7 +35,7 @@ public class Settings {
* *
* @see SettingsExporter * @see SettingsExporter
*/ */
public static final int VERSION = 28; public static final int VERSION = 30;
public static Map<String, Object> validate(int version, Map<String, public static Map<String, Object> validate(int version, Map<String,
TreeMap<Integer, SettingsDescription>> settings, TreeMap<Integer, SettingsDescription>> settings,