mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-25 00:58:50 -05:00
Create default sort setting by preference
This commit is contained in:
parent
de2c6cdae3
commit
ff6e1f6c85
@ -149,6 +149,24 @@
|
|||||||
<item>NOT_SECOND_CLASS</item>
|
<item>NOT_SECOND_CLASS</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="account_settings_sort_type_entries">
|
||||||
|
<item>@string/sort_by_date</item>
|
||||||
|
<item>@string/sort_by_subject</item>
|
||||||
|
<item>@string/sort_by_sender</item>
|
||||||
|
<item>@string/sort_by_unread</item>
|
||||||
|
<item>@string/sort_by_flag</item>
|
||||||
|
<item>@string/sort_by_attach</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="account_settings_sort_type_values">
|
||||||
|
<item>SORT_DATE</item>
|
||||||
|
<item>SORT_SUBJECT</item>
|
||||||
|
<item>SORT_SENDER</item>
|
||||||
|
<item>SORT_UNREAD</item>
|
||||||
|
<item>SORT_FLAGGED</item>
|
||||||
|
<item>SORT_ATTACHMENT</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
<string-array name="account_settings_show_pictures_entries">
|
<string-array name="account_settings_show_pictures_entries">
|
||||||
<item>@string/account_settings_show_pictures_never</item>
|
<item>@string/account_settings_show_pictures_never</item>
|
||||||
<item>@string/account_settings_show_pictures_only_from_contacts</item>
|
<item>@string/account_settings_show_pictures_only_from_contacts</item>
|
||||||
|
@ -553,6 +553,10 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
|
|||||||
<string name="account_settings_enable_move_buttons_label">Enable refile buttons</string>
|
<string name="account_settings_enable_move_buttons_label">Enable refile buttons</string>
|
||||||
<string name="account_settings_enable_move_buttons_summary">Show the Archive, Move, and Spam buttons.</string>
|
<string name="account_settings_enable_move_buttons_summary">Show the Archive, Move, and Spam buttons.</string>
|
||||||
|
|
||||||
|
<string name="account_settings_sort_type_label">Default Sort Type</string>
|
||||||
|
<string name="account_settings_sort_ascending_label">Sort order</string>
|
||||||
|
<string name="account_settings_sort_ascending_summary">Sort in ascending order</string>
|
||||||
|
|
||||||
<string name="account_settings_show_pictures_label">Always show images</string>
|
<string name="account_settings_show_pictures_label">Always show images</string>
|
||||||
<string name="account_settings_show_pictures_never">No</string>
|
<string name="account_settings_show_pictures_never">No</string>
|
||||||
<string name="account_settings_show_pictures_only_from_contacts">From contacts</string>
|
<string name="account_settings_show_pictures_only_from_contacts">From contacts</string>
|
||||||
|
@ -56,6 +56,21 @@
|
|||||||
android:title="@string/account_settings_color_label"
|
android:title="@string/account_settings_color_label"
|
||||||
android:summary="@string/account_settings_color_summary" />
|
android:summary="@string/account_settings_color_summary" />
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
android:persistent="false"
|
||||||
|
android:key="sort_type_enum"
|
||||||
|
android:title="@string/account_settings_sort_type_label"
|
||||||
|
android:entries="@array/account_settings_sort_type_entries"
|
||||||
|
android:entryValues="@array/account_settings_sort_type_values"
|
||||||
|
android:dialogTitle="@string/account_settings_sort_type_label" />
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:persistent="false"
|
||||||
|
android:key="sort_ascending"
|
||||||
|
android:title="@string/account_settings_sort_ascending_label"
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:summary="@string/account_settings_sort_ascending_summary" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
|
@ -7,6 +7,7 @@ import android.net.ConnectivityManager;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.fsck.k9.controller.MessagingController.SORT_TYPE;
|
||||||
import com.fsck.k9.crypto.Apg;
|
import com.fsck.k9.crypto.Apg;
|
||||||
import com.fsck.k9.crypto.CryptoProvider;
|
import com.fsck.k9.crypto.CryptoProvider;
|
||||||
import com.fsck.k9.helper.Utility;
|
import com.fsck.k9.helper.Utility;
|
||||||
@ -77,6 +78,9 @@ public class Account implements BaseAccount {
|
|||||||
public static final String IDENTITY_EMAIL_KEY = "email";
|
public static final String IDENTITY_EMAIL_KEY = "email";
|
||||||
public static final String IDENTITY_DESCRIPTION_KEY = "description";
|
public static final String IDENTITY_DESCRIPTION_KEY = "description";
|
||||||
|
|
||||||
|
public static final SORT_TYPE DEFAULT_SORT_TYPE = SORT_TYPE.SORT_DATE;
|
||||||
|
public static final boolean DEFAULT_SORT_ASCENDING = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
@ -121,6 +125,8 @@ public class Account implements BaseAccount {
|
|||||||
private boolean mSaveAllHeaders;
|
private boolean mSaveAllHeaders;
|
||||||
private boolean mPushPollOnConnect;
|
private boolean mPushPollOnConnect;
|
||||||
private boolean mNotifySync;
|
private boolean mNotifySync;
|
||||||
|
private SORT_TYPE mSortType;
|
||||||
|
private boolean mSortAscending;
|
||||||
private ShowPictures mShowPictures;
|
private ShowPictures mShowPictures;
|
||||||
private boolean mEnableMoveButtons;
|
private boolean mEnableMoveButtons;
|
||||||
private boolean mIsSignatureBeforeQuotedText;
|
private boolean mIsSignatureBeforeQuotedText;
|
||||||
@ -210,6 +216,8 @@ public class Account implements BaseAccount {
|
|||||||
mFolderSyncMode = FolderMode.FIRST_CLASS;
|
mFolderSyncMode = FolderMode.FIRST_CLASS;
|
||||||
mFolderPushMode = FolderMode.FIRST_CLASS;
|
mFolderPushMode = FolderMode.FIRST_CLASS;
|
||||||
mFolderTargetMode = FolderMode.NOT_SECOND_CLASS;
|
mFolderTargetMode = FolderMode.NOT_SECOND_CLASS;
|
||||||
|
mSortType = DEFAULT_SORT_TYPE;
|
||||||
|
mSortAscending = DEFAULT_SORT_ASCENDING;
|
||||||
mShowPictures = ShowPictures.NEVER;
|
mShowPictures = ShowPictures.NEVER;
|
||||||
mEnableMoveButtons = false;
|
mEnableMoveButtons = false;
|
||||||
mIsSignatureBeforeQuotedText = false;
|
mIsSignatureBeforeQuotedText = false;
|
||||||
@ -331,6 +339,15 @@ public class Account implements BaseAccount {
|
|||||||
(random.nextInt(0x70) * 0xffff) +
|
(random.nextInt(0x70) * 0xffff) +
|
||||||
0xff000000);
|
0xff000000);
|
||||||
|
|
||||||
|
try {
|
||||||
|
mSortType = SORT_TYPE.valueOf(prefs.getString(mUuid + ".sortTypeEnum",
|
||||||
|
SORT_TYPE.SORT_DATE.name()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
mSortType = SORT_TYPE.SORT_DATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
mSortAscending = prefs.getBoolean(mUuid + ".sortAscending", false);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mShowPictures = ShowPictures.valueOf(prefs.getString(mUuid + ".showPicturesEnum",
|
mShowPictures = ShowPictures.valueOf(prefs.getString(mUuid + ".showPicturesEnum",
|
||||||
ShowPictures.NEVER.name()));
|
ShowPictures.NEVER.name()));
|
||||||
@ -463,6 +480,8 @@ public class Account implements BaseAccount {
|
|||||||
editor.remove(mUuid + ".messageFormatAuto");
|
editor.remove(mUuid + ".messageFormatAuto");
|
||||||
editor.remove(mUuid + ".quoteStyle");
|
editor.remove(mUuid + ".quoteStyle");
|
||||||
editor.remove(mUuid + ".quotePrefix");
|
editor.remove(mUuid + ".quotePrefix");
|
||||||
|
editor.remove(mUuid + ".sortTypeEnum");
|
||||||
|
editor.remove(mUuid + ".sortAscending");
|
||||||
editor.remove(mUuid + ".showPicturesEnum");
|
editor.remove(mUuid + ".showPicturesEnum");
|
||||||
editor.remove(mUuid + ".replyAfterQuote");
|
editor.remove(mUuid + ".replyAfterQuote");
|
||||||
editor.remove(mUuid + ".stripSignature");
|
editor.remove(mUuid + ".stripSignature");
|
||||||
@ -595,6 +614,8 @@ public class Account implements BaseAccount {
|
|||||||
editor.putString(mUuid + ".spamFolderName", mSpamFolderName);
|
editor.putString(mUuid + ".spamFolderName", mSpamFolderName);
|
||||||
editor.putString(mUuid + ".autoExpandFolderName", mAutoExpandFolderName);
|
editor.putString(mUuid + ".autoExpandFolderName", mAutoExpandFolderName);
|
||||||
editor.putInt(mUuid + ".accountNumber", mAccountNumber);
|
editor.putInt(mUuid + ".accountNumber", mAccountNumber);
|
||||||
|
editor.putString(mUuid + ".sortTypeEnum", mSortType.name());
|
||||||
|
editor.putBoolean(mUuid + ".sortAscending", mSortAscending);
|
||||||
editor.putString(mUuid + ".showPicturesEnum", mShowPictures.name());
|
editor.putString(mUuid + ".showPicturesEnum", mShowPictures.name());
|
||||||
editor.putBoolean(mUuid + ".enableMoveButtons", mEnableMoveButtons);
|
editor.putBoolean(mUuid + ".enableMoveButtons", mEnableMoveButtons);
|
||||||
editor.putString(mUuid + ".folderDisplayMode", mFolderDisplayMode.name());
|
editor.putString(mUuid + ".folderDisplayMode", mFolderDisplayMode.name());
|
||||||
@ -1000,6 +1021,22 @@ public class Account implements BaseAccount {
|
|||||||
this.mNotifySync = showOngoing;
|
this.mNotifySync = showOngoing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized SORT_TYPE getSortType() {
|
||||||
|
return mSortType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void setSortType(SORT_TYPE sortType) {
|
||||||
|
mSortType = sortType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized boolean isSortAscending() {
|
||||||
|
return mSortAscending;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void setSortAscending(boolean sortAscending) {
|
||||||
|
mSortAscending = sortAscending;
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized ShowPictures getShowPictures() {
|
public synchronized ShowPictures getShowPictures() {
|
||||||
return mShowPictures;
|
return mShowPictures;
|
||||||
}
|
}
|
||||||
|
@ -809,8 +809,10 @@ public class MessageList
|
|||||||
mStars = K9.messageListStars();
|
mStars = K9.messageListStars();
|
||||||
mCheckboxes = K9.messageListCheckboxes();
|
mCheckboxes = K9.messageListCheckboxes();
|
||||||
|
|
||||||
sortType = mController.getSortType();
|
sortType = mAccount.getSortType();
|
||||||
sortAscending = mController.isSortAscending(sortType);
|
mController.setSortType(sortType);
|
||||||
|
sortAscending = mAccount.isSortAscending();
|
||||||
|
mController.setSortAscending(sortType, sortAscending);
|
||||||
sortDateAscending = mController.isSortAscending(SORT_TYPE.SORT_DATE);
|
sortDateAscending = mController.isSortAscending(SORT_TYPE.SORT_DATE);
|
||||||
|
|
||||||
mController.addListener(mAdapter.mListener);
|
mController.addListener(mAdapter.mListener);
|
||||||
|
@ -28,6 +28,7 @@ import com.fsck.k9.activity.ChooseIdentity;
|
|||||||
import com.fsck.k9.activity.ColorPickerDialog;
|
import com.fsck.k9.activity.ColorPickerDialog;
|
||||||
import com.fsck.k9.activity.K9PreferenceActivity;
|
import com.fsck.k9.activity.K9PreferenceActivity;
|
||||||
import com.fsck.k9.activity.ManageIdentities;
|
import com.fsck.k9.activity.ManageIdentities;
|
||||||
|
import com.fsck.k9.controller.MessagingController.SORT_TYPE;
|
||||||
import com.fsck.k9.crypto.Apg;
|
import com.fsck.k9.crypto.Apg;
|
||||||
import com.fsck.k9.mail.Store;
|
import com.fsck.k9.mail.Store;
|
||||||
import com.fsck.k9.service.MailService;
|
import com.fsck.k9.service.MailService;
|
||||||
@ -53,6 +54,8 @@ public class AccountSettings extends K9PreferenceActivity {
|
|||||||
private static final String PREFERENCE_FREQUENCY = "account_check_frequency";
|
private static final String PREFERENCE_FREQUENCY = "account_check_frequency";
|
||||||
private static final String PREFERENCE_DISPLAY_COUNT = "account_display_count";
|
private static final String PREFERENCE_DISPLAY_COUNT = "account_display_count";
|
||||||
private static final String PREFERENCE_DEFAULT = "account_default";
|
private static final String PREFERENCE_DEFAULT = "account_default";
|
||||||
|
private static final String PREFERENCE_SORT_TYPE = "sort_type_enum";
|
||||||
|
private static final String PREFERENCE_SORT_ASCENDING = "sort_ascending";
|
||||||
private static final String PREFERENCE_SHOW_PICTURES = "show_pictures_enum";
|
private static final String PREFERENCE_SHOW_PICTURES = "show_pictures_enum";
|
||||||
private static final String PREFERENCE_ENABLE_MOVE_BUTTONS = "enable_move_buttons";
|
private static final String PREFERENCE_ENABLE_MOVE_BUTTONS = "enable_move_buttons";
|
||||||
private static final String PREFERENCE_NOTIFY = "account_notify";
|
private static final String PREFERENCE_NOTIFY = "account_notify";
|
||||||
@ -121,6 +124,8 @@ public class AccountSettings extends K9PreferenceActivity {
|
|||||||
private CheckBoxPreference mAccountDefault;
|
private CheckBoxPreference mAccountDefault;
|
||||||
private CheckBoxPreference mAccountNotify;
|
private CheckBoxPreference mAccountNotify;
|
||||||
private CheckBoxPreference mAccountNotifySelf;
|
private CheckBoxPreference mAccountNotifySelf;
|
||||||
|
private ListPreference mAccountSortType;
|
||||||
|
private CheckBoxPreference mAccountSortAscending;
|
||||||
private ListPreference mAccountShowPictures;
|
private ListPreference mAccountShowPictures;
|
||||||
private CheckBoxPreference mAccountEnableMoveButtons;
|
private CheckBoxPreference mAccountEnableMoveButtons;
|
||||||
private CheckBoxPreference mAccountNotifySync;
|
private CheckBoxPreference mAccountNotifySync;
|
||||||
@ -427,6 +432,22 @@ public class AccountSettings extends K9PreferenceActivity {
|
|||||||
mAccountEnableMoveButtons.setEnabled(mIsMoveCapable);
|
mAccountEnableMoveButtons.setEnabled(mIsMoveCapable);
|
||||||
mAccountEnableMoveButtons.setChecked(mAccount.getEnableMoveButtons());
|
mAccountEnableMoveButtons.setChecked(mAccount.getEnableMoveButtons());
|
||||||
|
|
||||||
|
mAccountSortType = (ListPreference) findPreference(PREFERENCE_SORT_TYPE);
|
||||||
|
mAccountSortType.setValue("" + mAccount.getSortType());
|
||||||
|
mAccountSortType.setSummary(mAccountSortType.getEntry());
|
||||||
|
mAccountSortType.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
final String summary = newValue.toString();
|
||||||
|
int index = mAccountSortType.findIndexOfValue(summary);
|
||||||
|
mAccountSortType.setSummary(mAccountSortType.getEntries()[index]);
|
||||||
|
mAccountSortType.setValue(summary);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mAccountSortAscending = (CheckBoxPreference) findPreference(PREFERENCE_SORT_ASCENDING);
|
||||||
|
mAccountSortAscending.setChecked(mAccount.isSortAscending());
|
||||||
|
|
||||||
mAccountShowPictures = (ListPreference) findPreference(PREFERENCE_SHOW_PICTURES);
|
mAccountShowPictures = (ListPreference) findPreference(PREFERENCE_SHOW_PICTURES);
|
||||||
mAccountShowPictures.setValue("" + mAccount.getShowPictures());
|
mAccountShowPictures.setValue("" + mAccount.getShowPictures());
|
||||||
mAccountShowPictures.setSummary(mAccountShowPictures.getEntry());
|
mAccountShowPictures.setSummary(mAccountShowPictures.getEntry());
|
||||||
@ -750,6 +771,9 @@ public class AccountSettings extends K9PreferenceActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mAccount.setSortType(SORT_TYPE.valueOf(mAccountSortType.getValue()));
|
||||||
|
mAccount.setSortAscending(mAccountSortAscending.isChecked());
|
||||||
|
|
||||||
mAccount.setShowPictures(Account.ShowPictures.valueOf(mAccountShowPictures.getValue()));
|
mAccount.setShowPictures(Account.ShowPictures.valueOf(mAccountShowPictures.getValue()));
|
||||||
|
|
||||||
if (mIsPushCapable) {
|
if (mIsPushCapable) {
|
||||||
|
@ -173,7 +173,7 @@ public class MessagingController implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private SORT_TYPE sortType = SORT_TYPE.SORT_DATE;
|
private SORT_TYPE sortType = Account.DEFAULT_SORT_TYPE;
|
||||||
|
|
||||||
private MessagingListener checkMailListener = null;
|
private MessagingListener checkMailListener = null;
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import com.fsck.k9.Account;
|
|||||||
import com.fsck.k9.K9;
|
import com.fsck.k9.K9;
|
||||||
import com.fsck.k9.R;
|
import com.fsck.k9.R;
|
||||||
import com.fsck.k9.Account.FolderMode;
|
import com.fsck.k9.Account.FolderMode;
|
||||||
|
import com.fsck.k9.controller.MessagingController.SORT_TYPE;
|
||||||
import com.fsck.k9.crypto.Apg;
|
import com.fsck.k9.crypto.Apg;
|
||||||
import com.fsck.k9.mail.store.StorageManager;
|
import com.fsck.k9.mail.store.StorageManager;
|
||||||
import com.fsck.k9.preferences.Settings.*;
|
import com.fsck.k9.preferences.Settings.*;
|
||||||
@ -156,6 +157,12 @@ public class AccountSettings {
|
|||||||
s.put("sentFolderName", Settings.versions(
|
s.put("sentFolderName", Settings.versions(
|
||||||
new V(1, new StringSetting("Sent"))
|
new V(1, new StringSetting("Sent"))
|
||||||
));
|
));
|
||||||
|
s.put("sortTypeEnum", Settings.versions(
|
||||||
|
new V(1, new EnumSetting(SORT_TYPE.class, Account.DEFAULT_SORT_TYPE))
|
||||||
|
));
|
||||||
|
s.put("sortAscending", Settings.versions(
|
||||||
|
new V(1, new BooleanSetting(Account.DEFAULT_SORT_ASCENDING))
|
||||||
|
));
|
||||||
s.put("showPicturesEnum", Settings.versions(
|
s.put("showPicturesEnum", Settings.versions(
|
||||||
new V(1, new EnumSetting(Account.ShowPictures.class, Account.ShowPictures.NEVER))
|
new V(1, new EnumSetting(Account.ShowPictures.class, Account.ShowPictures.NEVER))
|
||||||
));
|
));
|
||||||
|
Loading…
Reference in New Issue
Block a user