Save sort type and sort order for search views (e.g. Unified Inbox)

This commit is contained in:
cketti 2012-05-16 20:35:55 +02:00
parent e2b109e7ea
commit 6d19d9c829
2 changed files with 18 additions and 3 deletions

View File

@ -462,6 +462,9 @@ public class K9 extends Application {
editor.putBoolean("confirmSpam", mConfirmSpam);
editor.putBoolean("confirmMarkAllAsRead", mConfirmMarkAllAsRead);
editor.putString("sortTypeEnum", mSortType.name());
editor.putBoolean("sortAscending", mSortAscending.get(mSortType));
editor.putBoolean("keyguardPrivacy", mKeyguardPrivacy);
editor.putBoolean("compactLayouts", compactLayouts);
@ -475,9 +478,6 @@ public class K9 extends Application {
super.onCreate();
app = this;
mSortType = Account.DEFAULT_SORT_TYPE;
mSortAscending.put(Account.DEFAULT_SORT_TYPE, Account.DEFAULT_SORT_ASCENDING);
galleryBuggy = checkForBuggyGallery();
Preferences prefs = Preferences.getPreferences(this);
@ -619,6 +619,15 @@ public class K9 extends Application {
mConfirmSpam = sprefs.getBoolean("confirmSpam", false);
mConfirmMarkAllAsRead = sprefs.getBoolean("confirmMarkAllAsRead", true);
try {
String value = sprefs.getString("sortTypeEnum", Account.DEFAULT_SORT_TYPE.name());
mSortType = SortType.valueOf(value);
} catch (Exception e) {
mSortType = Account.DEFAULT_SORT_TYPE;
}
boolean sortAscending = sprefs.getBoolean("sortAscending", Account.DEFAULT_SORT_ASCENDING);
mSortAscending.put(mSortType, sortAscending);
mKeyguardPrivacy = sprefs.getBoolean("keyguardPrivacy", false);

View File

@ -12,6 +12,7 @@ import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences.Editor;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
@ -1211,6 +1212,11 @@ public class MessageList
K9.setSortType(mSortType);
mSortAscending = K9.isSortAscending(mSortType);
mSortDateAscending = K9.isSortAscending(SortType.SORT_DATE);
Preferences prefs = Preferences.getPreferences(getApplicationContext());
Editor editor = prefs.getPreferences().edit();
K9.save(editor);
editor.commit();
}
reSort();
}