mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-17 07:30:16 -05:00
Add global setting to enable/disable threaded view
This commit is contained in:
parent
889e2502be
commit
5778d135fb
@ -1150,4 +1150,7 @@ http://k9mail.googlecode.com/
|
||||
|
||||
<string name="global_settings_background_as_unread_indicator_label">Use background as (un)read indicator</string>
|
||||
<string name="global_settings_background_as_unread_indicator_summary">Show read and unread messages with different background colors</string>
|
||||
|
||||
<string name="global_settings_threaded_view_label">Threaded view</string>
|
||||
<string name="global_settings_threaded_view_summary">Collapse messages belonging to the same thread</string>
|
||||
</resources>
|
||||
|
@ -144,6 +144,12 @@
|
||||
android:summary="@string/global_settings_background_as_unread_indicator_summary"
|
||||
/>
|
||||
|
||||
<CheckBoxPreference
|
||||
android:persistent="false"
|
||||
android:key="threaded_view"
|
||||
android:title="@string/global_settings_threaded_view_label"
|
||||
android:summary="@string/global_settings_threaded_view_summary" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
|
@ -205,6 +205,8 @@ public class K9 extends Application {
|
||||
private static HashMap<SortType, Boolean> mSortAscending = new HashMap<SortType, Boolean>();
|
||||
|
||||
private static boolean sUseBackgroundAsUnreadIndicator = true;
|
||||
private static boolean sThreadedViewEnabled = true;
|
||||
|
||||
|
||||
/**
|
||||
* The MIME type(s) of attachments we're willing to view.
|
||||
@ -472,6 +474,7 @@ public class K9 extends Application {
|
||||
|
||||
editor.putString("attachmentdefaultpath", mAttachmentDefaultPath);
|
||||
editor.putBoolean("useBackgroundAsUnreadIndicator", sUseBackgroundAsUnreadIndicator);
|
||||
editor.putBoolean("threadedView", sThreadedViewEnabled);
|
||||
fontSizes.save(editor);
|
||||
}
|
||||
|
||||
@ -641,6 +644,7 @@ public class K9 extends Application {
|
||||
|
||||
mAttachmentDefaultPath = sprefs.getString("attachmentdefaultpath", Environment.getExternalStorageDirectory().toString());
|
||||
sUseBackgroundAsUnreadIndicator = sprefs.getBoolean("useBackgroundAsUnreadIndicator", true);
|
||||
sThreadedViewEnabled = sprefs.getBoolean("threadedView", true);
|
||||
fontSizes.load(sprefs);
|
||||
|
||||
try {
|
||||
@ -1127,4 +1131,12 @@ public class K9 extends Application {
|
||||
public static synchronized void setUseBackgroundAsUnreadIndicator(boolean enabled) {
|
||||
sUseBackgroundAsUnreadIndicator = enabled;
|
||||
}
|
||||
|
||||
public static synchronized boolean isThreadedViewEnabled() {
|
||||
return sThreadedViewEnabled;
|
||||
}
|
||||
|
||||
public static synchronized void setThreadedViewEnabled(boolean enable) {
|
||||
sThreadedViewEnabled = enable;
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,6 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
private boolean mSingleFolderMode;
|
||||
private boolean mSingleAccountMode;
|
||||
private boolean mIsRemote;
|
||||
private boolean mThreadViewEnabled = true; //TODO: this should be a setting
|
||||
|
||||
/**
|
||||
* {@code true} if the message list should be displayed as flat list (i.e. no threading)
|
||||
@ -129,7 +128,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
if (mMessageListFragment == null) {
|
||||
FragmentTransaction ft = fragmentManager.beginTransaction();
|
||||
mMessageListFragment = MessageListFragment.newInstance(mSearch,
|
||||
(mThreadViewEnabled && !mNoThreading), mIsRemote);
|
||||
(K9.isThreadedViewEnabled() && !mNoThreading), mIsRemote);
|
||||
ft.add(R.id.message_list_container, mMessageListFragment);
|
||||
ft.commit();
|
||||
}
|
||||
@ -164,13 +163,13 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
mNoThreading = intent.getBooleanExtra(EXTRA_NO_THREADING, false);
|
||||
}
|
||||
|
||||
String[] accounts = mSearch.getAccountUuids();
|
||||
mSingleAccountMode = ( accounts != null && accounts.length == 1
|
||||
&& !accounts[0].equals(SearchSpecification.ALL_ACCOUNTS));
|
||||
String[] accountUuids = mSearch.getAccountUuids();
|
||||
mSingleAccountMode = (accountUuids.length == 1 && !mSearch.searchAllAccounts());
|
||||
mSingleFolderMode = mSingleAccountMode && (mSearch.getFolderNames().size() == 1);
|
||||
|
||||
if (mSingleAccountMode) {
|
||||
mAccount = Preferences.getPreferences(this).getAccount(accounts[0]);
|
||||
Preferences prefs = Preferences.getPreferences(getApplicationContext());
|
||||
mAccount = prefs.getAccount(accountUuids[0]);
|
||||
|
||||
if (mAccount != null && !mAccount.isAvailable(this)) {
|
||||
Log.i(K9.LOG_TAG, "not opening MessageList of unavailable account");
|
||||
|
@ -86,8 +86,11 @@ public class Prefs extends K9PreferenceActivity {
|
||||
|
||||
private static final String PREFERENCE_ATTACHMENT_DEF_PATH = "attachment_default_path";
|
||||
private static final String PREFERENCE_BACKGROUND_AS_UNREAD_INDICATOR = "messagelist_background_as_unread_indicator";
|
||||
private static final String PREFERENCE_THREADED_VIEW = "threaded_view";
|
||||
|
||||
private static final int ACTIVITY_CHOOSE_FOLDER = 1;
|
||||
|
||||
|
||||
private ListPreference mLanguage;
|
||||
private ListPreference mTheme;
|
||||
private ListPreference mDateFormat;
|
||||
@ -126,6 +129,8 @@ public class Prefs extends K9PreferenceActivity {
|
||||
private CheckBoxPreference mBatchButtonsFlag;
|
||||
private CheckBoxPreference mBatchButtonsUnselect;
|
||||
private CheckBoxPreference mBackgroundAsUnreadIndicator;
|
||||
private CheckBoxPreference mThreadedView;
|
||||
|
||||
|
||||
public static void actionPrefs(Context context) {
|
||||
Intent i = new Intent(context, Prefs.class);
|
||||
@ -230,6 +235,10 @@ public class Prefs extends K9PreferenceActivity {
|
||||
|
||||
mChangeContactNameColor = (CheckBoxPreference)findPreference(PREFERENCE_MESSAGELIST_CONTACT_NAME_COLOR);
|
||||
mChangeContactNameColor.setChecked(K9.changeContactNameColor());
|
||||
|
||||
mThreadedView = (CheckBoxPreference) findPreference(PREFERENCE_THREADED_VIEW);
|
||||
mThreadedView.setChecked(K9.isThreadedViewEnabled());
|
||||
|
||||
if (K9.changeContactNameColor()) {
|
||||
mChangeContactNameColor.setSummary(R.string.global_settings_registered_name_color_changed);
|
||||
} else {
|
||||
@ -412,6 +421,7 @@ public class Prefs extends K9PreferenceActivity {
|
||||
K9.setMessageListSenderAboveSubject(mSenderAboveSubject.isChecked());
|
||||
K9.setShowContactName(mShowContactName.isChecked());
|
||||
K9.setUseBackgroundAsUnreadIndicator(mBackgroundAsUnreadIndicator.isChecked());
|
||||
K9.setThreadedViewEnabled(mThreadedView.isChecked());
|
||||
K9.setChangeContactNameColor(mChangeContactNameColor.isChecked());
|
||||
K9.setMessageViewFixedWidthFont(mFixedWidth.isChecked());
|
||||
K9.setMessageViewReturnToList(mReturnToList.isChecked());
|
||||
|
@ -729,7 +729,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
|
||||
String[] accountUuids = mSearch.getAccountUuids();
|
||||
|
||||
mSingleAccountMode = false;
|
||||
if (accountUuids.length == 1 && !accountUuids[0].equals(SearchSpecification.ALL_ACCOUNTS)) {
|
||||
if (accountUuids.length == 1 && !mSearch.searchAllAccounts()) {
|
||||
mSingleAccountMode = true;
|
||||
mAccount = mPreferences.getAccount(accountUuids[0]);
|
||||
}
|
||||
|
@ -219,6 +219,9 @@ public class GlobalSettings {
|
||||
s.put("useBackgroundAsUnreadIndicator", Settings.versions(
|
||||
new V(19, new BooleanSetting(true))
|
||||
));
|
||||
s.put("threadedView", Settings.versions(
|
||||
new V(20, new BooleanSetting(true))
|
||||
));
|
||||
|
||||
SETTINGS = Collections.unmodifiableMap(s);
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class Settings {
|
||||
*
|
||||
* @see SettingsExporter
|
||||
*/
|
||||
public static final int VERSION = 19;
|
||||
public static final int VERSION = 20;
|
||||
|
||||
public static Map<String, Object> validate(int version, Map<String,
|
||||
TreeMap<Integer, SettingsDescription>> settings,
|
||||
|
@ -356,6 +356,15 @@ public class LocalSearch implements SearchSpecification {
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not to search all accounts.
|
||||
*
|
||||
* @return {@code true} if all accounts should be searched.
|
||||
*/
|
||||
public boolean searchAllAccounts() {
|
||||
return (mAccountUuids.size() == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the condition tree.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user