1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-08-13 17:03:48 -04:00

Implemented option to hide special accounts (issue 3060)

This commit is contained in:
baolongnt 2011-02-25 12:36:47 -08:00
parent 397d01d513
commit fce2fc12d0
5 changed files with 47 additions and 12 deletions

View File

@ -921,6 +921,9 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
<string name="count_search_title">Count search results</string> <string name="count_search_title">Count search results</string>
<string name="count_search_summary">Turn off for faster display</string> <string name="count_search_summary">Turn off for faster display</string>
<string name="hide_special_accounts_title">Hide special accounts</string>
<string name="hide_special_accounts_summary">Hide the unified inbox and all messages accounts</string>
<string name="search_title"><xliff:g id="search_name">%s</xliff:g> <xliff:g id="modifier">%s</xliff:g></string> <string name="search_title"><xliff:g id="search_name">%s</xliff:g> <xliff:g id="modifier">%s</xliff:g></string>
<string name="flagged_modifier"> - Starred</string> <string name="flagged_modifier"> - Starred</string>
<string name="unread_modifier"> - Unread</string> <string name="unread_modifier"> - Unread</string>

View File

@ -92,6 +92,13 @@
android:title="@string/count_search_title" android:title="@string/count_search_title"
android:summary="@string/count_search_summary" /> android:summary="@string/count_search_summary" />
<CheckBoxPreference
android:persistent="false"
android:key="hide_special_accounts"
android:title="@string/hide_special_accounts_title"
android:summary="@string/hide_special_accounts_summary"
android:disableDependentsState="true" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory <PreferenceCategory
@ -180,7 +187,8 @@
android:persistent="false" android:persistent="false"
android:key="start_integrated_inbox" android:key="start_integrated_inbox"
android:title="@string/start_integrated_inbox_title" android:title="@string/start_integrated_inbox_title"
android:summary="@string/start_integrated_inbox_summary" /> android:summary="@string/start_integrated_inbox_summary"
android:dependency="hide_special_accounts" />
<CheckBoxPreference <CheckBoxPreference
android:persistent="false" android:persistent="false"

View File

@ -168,6 +168,7 @@ public class K9 extends Application {
private static boolean mStartIntegratedInbox = false; private static boolean mStartIntegratedInbox = false;
private static boolean mMeasureAccounts = true; private static boolean mMeasureAccounts = true;
private static boolean mCountSearchMessages = true; private static boolean mCountSearchMessages = true;
private static boolean mHideSpecialAccounts = false;
private static boolean mZoomControlsEnabled = false; private static boolean mZoomControlsEnabled = false;
private static boolean mMobileOptimizedLayout = false; private static boolean mMobileOptimizedLayout = false;
private static boolean mQuietTimeEnabled = false; private static boolean mQuietTimeEnabled = false;
@ -422,6 +423,7 @@ public class K9 extends Application {
editor.putBoolean("startIntegratedInbox", mStartIntegratedInbox); editor.putBoolean("startIntegratedInbox", mStartIntegratedInbox);
editor.putBoolean("measureAccounts", mMeasureAccounts); editor.putBoolean("measureAccounts", mMeasureAccounts);
editor.putBoolean("countSearchMessages", mCountSearchMessages); editor.putBoolean("countSearchMessages", mCountSearchMessages);
editor.putBoolean("hideSpecialAccounts", mHideSpecialAccounts);
editor.putBoolean("messageListStars", mMessageListStars); editor.putBoolean("messageListStars", mMessageListStars);
editor.putBoolean("messageListCheckboxes", mMessageListCheckboxes); editor.putBoolean("messageListCheckboxes", mMessageListCheckboxes);
editor.putBoolean("messageListTouchable", mMessageListTouchable); editor.putBoolean("messageListTouchable", mMessageListTouchable);
@ -468,6 +470,7 @@ public class K9 extends Application {
mStartIntegratedInbox = sprefs.getBoolean("startIntegratedInbox", false); mStartIntegratedInbox = sprefs.getBoolean("startIntegratedInbox", false);
mMeasureAccounts = sprefs.getBoolean("measureAccounts", true); mMeasureAccounts = sprefs.getBoolean("measureAccounts", true);
mCountSearchMessages = sprefs.getBoolean("countSearchMessages", true); mCountSearchMessages = sprefs.getBoolean("countSearchMessages", true);
mHideSpecialAccounts = sprefs.getBoolean("hideSpecialAccounts", false);
mMessageListStars = sprefs.getBoolean("messageListStars", true); mMessageListStars = sprefs.getBoolean("messageListStars", true);
mMessageListCheckboxes = sprefs.getBoolean("messageListCheckboxes", false); mMessageListCheckboxes = sprefs.getBoolean("messageListCheckboxes", false);
mMessageListTouchable = sprefs.getBoolean("messageListTouchable", false); mMessageListTouchable = sprefs.getBoolean("messageListTouchable", false);
@ -773,7 +776,7 @@ public class K9 extends Application {
public static boolean startIntegratedInbox() { public static boolean startIntegratedInbox() {
return mStartIntegratedInbox; return !mHideSpecialAccounts && mStartIntegratedInbox;
} }
public static void setStartIntegratedInbox(boolean startIntegratedInbox) { public static void setStartIntegratedInbox(boolean startIntegratedInbox) {
@ -900,6 +903,14 @@ public class K9 extends Application {
mCountSearchMessages = countSearchMessages; mCountSearchMessages = countSearchMessages;
} }
public static boolean isHideSpecialAccounts() {
return mHideSpecialAccounts;
}
public static void setHideSpecialAccounts(boolean hideSpecialAccounts) {
mHideSpecialAccounts = hideSpecialAccounts;
}
public static boolean useGalleryBugWorkaround() { public static boolean useGalleryBugWorkaround() {
return useGalleryBugWorkaround; return useGalleryBugWorkaround;
} }

View File

@ -232,18 +232,20 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
unreadAccount = new SearchAccount(this, false, null, null); if (!K9.isHideSpecialAccounts()) {
unreadAccount.setDescription(getString(R.string.search_all_messages_title)); unreadAccount = new SearchAccount(this, false, null, null);
unreadAccount.setEmail(getString(R.string.search_all_messages_detail)); unreadAccount.setDescription(getString(R.string.search_all_messages_title));
unreadAccount.setEmail(getString(R.string.search_all_messages_detail));
integratedInboxAccount = new SearchAccount(this, true, null, null); integratedInboxAccount = new SearchAccount(this, true, null, null);
integratedInboxAccount.setDescription(getString(R.string.integrated_inbox_title)); integratedInboxAccount.setDescription(getString(R.string.integrated_inbox_title));
integratedInboxAccount.setEmail(getString(R.string.integrated_inbox_detail)); integratedInboxAccount.setEmail(getString(R.string.integrated_inbox_detail));
}
Account[] accounts = Preferences.getPreferences(this).getAccounts(); Account[] accounts = Preferences.getPreferences(this).getAccounts();
Intent intent = getIntent(); Intent intent = getIntent();
boolean startup = intent.getBooleanExtra(EXTRA_STARTUP, true); boolean startup = intent.getBooleanExtra(EXTRA_STARTUP, true);
if (startup && K9.startIntegratedInbox()) { if (startup && K9.startIntegratedInbox() && !K9.isHideSpecialAccounts()) {
onOpenAccount(integratedInboxAccount); onOpenAccount(integratedInboxAccount);
finish(); finish();
} else if (startup && accounts.length == 1 && onOpenAccount(accounts[0])) { } else if (startup && accounts.length == 1 && onOpenAccount(accounts[0])) {
@ -306,11 +308,16 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
private void refresh() { private void refresh() {
BaseAccount[] accounts = Preferences.getPreferences(this).getAccounts(); BaseAccount[] accounts = Preferences.getPreferences(this).getAccounts();
List<BaseAccount> newAccounts = new ArrayList<BaseAccount>(accounts.length + 4); List<BaseAccount> newAccounts;
if (accounts.length > 0) { if (!K9.isHideSpecialAccounts()
&& accounts.length > 0) {
newAccounts = new ArrayList<BaseAccount>(accounts.length + 2);
newAccounts.add(integratedInboxAccount); newAccounts.add(integratedInboxAccount);
newAccounts.add(unreadAccount); newAccounts.add(unreadAccount);
} }
else {
newAccounts = new ArrayList<BaseAccount>(accounts.length);
}
newAccounts.addAll(Arrays.asList(accounts)); newAccounts.addAll(Arrays.asList(accounts));

View File

@ -52,6 +52,7 @@ public class Prefs extends K9PreferenceActivity {
private static final String PREFERENCE_PRIVACY_MODE = "privacy_mode"; private static final String PREFERENCE_PRIVACY_MODE = "privacy_mode";
private static final String PREFERENCE_MEASURE_ACCOUNTS = "measure_accounts"; private static final String PREFERENCE_MEASURE_ACCOUNTS = "measure_accounts";
private static final String PREFERENCE_COUNT_SEARCH = "count_search"; private static final String PREFERENCE_COUNT_SEARCH = "count_search";
private static final String PREFERENCE_HIDE_SPECIAL_ACCOUNTS = "hide_special_accounts";
private static final String PREFERENCE_MESSAGELIST_TOUCHABLE = "messagelist_touchable"; private static final String PREFERENCE_MESSAGELIST_TOUCHABLE = "messagelist_touchable";
private static final String PREFERENCE_MESSAGELIST_PREVIEW_LINES = "messagelist_preview_lines"; private static final String PREFERENCE_MESSAGELIST_PREVIEW_LINES = "messagelist_preview_lines";
private static final String PREFERENCE_MESSAGELIST_STARS = "messagelist_stars"; private static final String PREFERENCE_MESSAGELIST_STARS = "messagelist_stars";
@ -88,6 +89,7 @@ public class Prefs extends K9PreferenceActivity {
private CheckBoxPreference mPrivacyMode; private CheckBoxPreference mPrivacyMode;
private CheckBoxPreference mMeasureAccounts; private CheckBoxPreference mMeasureAccounts;
private CheckBoxPreference mCountSearch; private CheckBoxPreference mCountSearch;
private CheckBoxPreference mHideSpecialAccounts;
private CheckBoxPreference mTouchable; private CheckBoxPreference mTouchable;
private ListPreference mPreviewLines; private ListPreference mPreviewLines;
private CheckBoxPreference mStars; private CheckBoxPreference mStars;
@ -191,6 +193,9 @@ public class Prefs extends K9PreferenceActivity {
mCountSearch = (CheckBoxPreference)findPreference(PREFERENCE_COUNT_SEARCH); mCountSearch = (CheckBoxPreference)findPreference(PREFERENCE_COUNT_SEARCH);
mCountSearch.setChecked(K9.countSearchMessages()); mCountSearch.setChecked(K9.countSearchMessages());
mHideSpecialAccounts = (CheckBoxPreference)findPreference(PREFERENCE_HIDE_SPECIAL_ACCOUNTS);
mHideSpecialAccounts.setChecked(K9.isHideSpecialAccounts());
mTouchable = (CheckBoxPreference)findPreference(PREFERENCE_MESSAGELIST_TOUCHABLE); mTouchable = (CheckBoxPreference)findPreference(PREFERENCE_MESSAGELIST_TOUCHABLE);
mTouchable.setChecked(K9.messageListTouchable()); mTouchable.setChecked(K9.messageListTouchable());
@ -298,11 +303,12 @@ public class Prefs extends K9PreferenceActivity {
K9.setUseVolumeKeysForNavigation(mVolumeNavigation.getCheckedItems()[0]); K9.setUseVolumeKeysForNavigation(mVolumeNavigation.getCheckedItems()[0]);
K9.setUseVolumeKeysForListNavigation(mVolumeNavigation.getCheckedItems()[1]); K9.setUseVolumeKeysForListNavigation(mVolumeNavigation.getCheckedItems()[1]);
K9.setManageBack(mManageBack.isChecked()); K9.setManageBack(mManageBack.isChecked());
K9.setStartIntegratedInbox(mStartIntegratedInbox.isChecked()); K9.setStartIntegratedInbox(!mHideSpecialAccounts.isChecked() && mStartIntegratedInbox.isChecked());
K9.setConfirmDelete(mConfirmActions.getCheckedItems()[0]); K9.setConfirmDelete(mConfirmActions.getCheckedItems()[0]);
K9.setKeyguardPrivacy(mPrivacyMode.isChecked()); K9.setKeyguardPrivacy(mPrivacyMode.isChecked());
K9.setMeasureAccounts(mMeasureAccounts.isChecked()); K9.setMeasureAccounts(mMeasureAccounts.isChecked());
K9.setCountSearchMessages(mCountSearch.isChecked()); K9.setCountSearchMessages(mCountSearch.isChecked());
K9.setHideSpecialAccounts(mHideSpecialAccounts.isChecked());
K9.setMessageListTouchable(mTouchable.isChecked()); K9.setMessageListTouchable(mTouchable.isChecked());
K9.setMessageListPreviewLines(Integer.parseInt(mPreviewLines.getValue())); K9.setMessageListPreviewLines(Integer.parseInt(mPreviewLines.getValue()));
K9.setMessageListStars(mStars.isChecked()); K9.setMessageListStars(mStars.isChecked());