1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

Provide user control over the account size measurement and search

result counting that are displayed in the Accouts Activity.  These can
both be slow, so some users may opt-out.
This commit is contained in:
Daniel Applebaum 2010-04-19 02:55:02 +00:00
parent 1d361d751e
commit e22f3d2c1b
7 changed files with 67 additions and 6 deletions

View File

@ -635,6 +635,7 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
<string name="display_preferences">Global Preferences</string>
<string name="debug_preferences">Debugging</string>
<string name="operational_preferences">Sync</string>
<string name="accountlist_preferences">Account List</string>
<string name="messagelist_preferences">Message Lists</string>
<string name="settings_theme_label">Theme</string>
@ -683,6 +684,12 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
<string name="gestures_title">Gestures</string>
<string name="gestures_summary">Accept gesture control</string>
<string name="measure_accounts_title">Show account size</string>
<string name="measure_accounts_summary">Turn off for faster display</string>
<string name="count_search_title">Count search results</string>
<string name="count_search_summary">Turn off for faster display</string>
<string name="search_unread_messages_title">All unread messages</string>
<string name="search_unread_messages_detail">Unread messages in searchable accounts</string>

View File

@ -42,6 +42,16 @@
android:title="@string/gestures_title"
android:summary="@string/gestures_summary"
/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/accountlist_preferences" android:key="accountlist_preferences">
<CheckBoxPreference
android:key="measure_accounts"
android:title="@string/measure_accounts_title"
android:summary="@string/measure_accounts_summary"/>
<CheckBoxPreference
android:key="count_search"
android:title="@string/count_search_title"
android:summary="@string/count_search_summary"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/messagelist_preferences" android:key="messagelist_preferences">
<CheckBoxPreference

View File

@ -430,7 +430,10 @@ public class Account implements BaseAccount
int unreadMessageCount = 0;
int flaggedMessageCount = 0;
LocalStore localStore = getLocalStore();
stats.size = localStore.getSize();
if (K9.measureAccounts())
{
stats.size = localStore.getSize();
}
Account.FolderMode aMode = getFolderDisplayMode();
Preferences prefs = Preferences.getPreferences(context);
for (LocalFolder folder : localStore.getPersonalNamespaces())

View File

@ -7,7 +7,7 @@ import java.io.Serializable;
public class AccountStats implements Serializable
{
public long size = 0;
public long size = -1;
public int unreadMessageCount = 0;
public int flaggedMessageCount = 0;
}

View File

@ -72,6 +72,8 @@ public class K9 extends Application
private static boolean mMessageListCheckboxes = false;
private static boolean mMessageListTouchable = false;
private static boolean mGesturesEnabled = true;
private static boolean mMeasureAccounts = true;
private static boolean mCountSearchMessages = true;
/**
* We use WebSettings.getBlockNetworkLoads() to prevent the WebView that displays email
@ -319,6 +321,8 @@ public class K9 extends Application
editor.putString("backgroundOperations", K9.backgroundOps.toString());
editor.putBoolean("animations", mAnimations);
editor.putBoolean("gesturesEnabled", mGesturesEnabled);
editor.putBoolean("measureAccounts", mMeasureAccounts);
editor.putBoolean("countSearchMessages", mCountSearchMessages);
editor.putBoolean("messageListStars",mMessageListStars);
editor.putBoolean("messageListCheckboxes",mMessageListCheckboxes);
editor.putBoolean("messageListTouchable",mMessageListTouchable);
@ -336,6 +340,8 @@ public class K9 extends Application
DEBUG_SENSITIVE = sprefs.getBoolean("enableSensitiveLogging", false);
mAnimations = sprefs.getBoolean("animations", true);
mGesturesEnabled = sprefs.getBoolean("gesturesEnabled", true);
mMeasureAccounts = sprefs.getBoolean("measureAccounts", true);
mCountSearchMessages = sprefs.getBoolean("countSearchMessages", true);
mMessageListStars = sprefs.getBoolean("messageListStars",true);
mMessageListCheckboxes = sprefs.getBoolean("messageListCheckboxes",false);
mMessageListTouchable = sprefs.getBoolean("messageListTouchable",false);
@ -535,4 +541,24 @@ public class K9 extends Application
}
}
}
public static boolean measureAccounts()
{
return mMeasureAccounts;
}
public static void setMeasureAccounts(boolean measureAccounts)
{
mMeasureAccounts = measureAccounts;
}
public static boolean countSearchMessages()
{
return mCountSearchMessages;
}
public static void setCountSearchMessages(boolean countSearchMessages)
{
mCountSearchMessages = countSearchMessages;
}
}

View File

@ -101,7 +101,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
public void run()
{
AccountStats stats = accountStats.get(account.getUuid());
if (stats != null)
if (newSize != -1 && stats != null && K9.measureAccounts())
{
stats.size = newSize;
}
@ -420,14 +420,16 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
for (BaseAccount account : newAccounts)
{
pendingWork.put(account, "true");
if (account instanceof Account)
{
pendingWork.put(account, "true");
Account realAccount = (Account)account;
MessagingController.getInstance(getApplication()).getAccountStats(Accounts.this, realAccount, mListener);
}
else if (account instanceof SearchAccount)
else if (K9.countSearchMessages() && account instanceof SearchAccount)
{
pendingWork.put(account, "true");
SearchAccount searchAccount = (SearchAccount)account;
MessagingController.getInstance(getApplication()).searchLocalMessages(searchAccount, null, mListener);
@ -791,7 +793,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
}
AccountStats stats = accountStats.get(account.getUuid());
if (stats != null && account instanceof Account)
if (stats != null && account instanceof Account && stats.size >= 0)
{
holder.email.setText(SizeFormatter.formatSize(Accounts.this, stats.size));
}

View File

@ -31,6 +31,8 @@ public class Prefs extends K9PreferenceActivity
private static final String PREFERENCE_MESSAGELIST_CHECKBOXES = "messagelist_checkboxes";
private static final String PREFERENCE_MESSAGELIST_TOUCHABLE = "messagelist_touchable";
private static final String PREFERENCE_MEASURE_ACCOUNTS = "measure_accounts";
private static final String PREFERENCE_COUNT_SEARCH = "count_search";
private ListPreference mTheme;
private ListPreference mDateFormat;
private ListPreference mBackgroundOps;
@ -41,6 +43,8 @@ public class Prefs extends K9PreferenceActivity
private CheckBoxPreference mStars;
private CheckBoxPreference mCheckboxes;
private CheckBoxPreference mTouchable;
private CheckBoxPreference mMeasureAccounts;
private CheckBoxPreference mCountSearch;
private String initBackgroundOps;
@ -137,6 +141,12 @@ public class Prefs extends K9PreferenceActivity
mTouchable = (CheckBoxPreference)findPreference(PREFERENCE_MESSAGELIST_TOUCHABLE);
mTouchable.setChecked(K9.messageListTouchable());
mMeasureAccounts = (CheckBoxPreference)findPreference(PREFERENCE_MEASURE_ACCOUNTS);
mMeasureAccounts.setChecked(K9.measureAccounts());
mCountSearch = (CheckBoxPreference)findPreference(PREFERENCE_COUNT_SEARCH);
mCountSearch.setChecked(K9.countSearchMessages());
}
@Override
@ -160,6 +170,9 @@ public class Prefs extends K9PreferenceActivity
K9.setMessageListTouchable(mTouchable.isChecked());
K9.setMeasureAccounts(mMeasureAccounts.isChecked());
K9.setCountSearchMessages(mCountSearch.isChecked());
Editor editor = preferences.edit();
K9.save(editor);
DateFormatter.setDateFormat(editor, mDateFormat.getValue());