mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-15 22:15:15 -05:00
Hide the batch archive button preference if none of our accounts have an archive folder.
Hide the batch archive button in the MessageList if none of the visible account(s) have an archive folder.
This commit is contained in:
parent
e94db81ecb
commit
42d6462946
@ -366,6 +366,7 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
|
||||
<string name="global_settings_mark_read">Mark read/unread</string>
|
||||
<string name="global_settings_delete">Delete</string>
|
||||
<string name="global_settings_archive">Move to archive</string>
|
||||
<string name="global_settings_archive_disabled_reason">No archive folders.</string>
|
||||
<string name="global_settings_move">Move</string>
|
||||
<string name="global_settings_flag">Flag</string>
|
||||
<string name="global_settings_unselect">Unselect</string>
|
||||
|
@ -827,11 +827,12 @@ public class MessageList
|
||||
|
||||
mController.addListener(mAdapter.mListener);
|
||||
|
||||
final Preferences preferences = Preferences.getPreferences(this);
|
||||
|
||||
Account[] accountsWithNotification;
|
||||
if (mAccount != null) {
|
||||
accountsWithNotification = new Account[] { mAccount };
|
||||
} else {
|
||||
Preferences preferences = Preferences.getPreferences(this);
|
||||
accountsWithNotification = preferences.getAccounts();
|
||||
}
|
||||
|
||||
@ -842,8 +843,32 @@ public class MessageList
|
||||
if (mAdapter.messages.isEmpty()) {
|
||||
if (mFolderName != null) {
|
||||
mController.listLocalMessages(mAccount, mFolderName, mAdapter.mListener);
|
||||
// Hide the archive button if we don't have an archive folder.
|
||||
if (!mAccount.hasArchiveFolder()) {
|
||||
mBatchArchiveButton.setVisibility(View.GONE);
|
||||
}
|
||||
} else if (mQueryString != null) {
|
||||
mController.searchLocalMessages(mAccountUuids, mFolderNames, null, mQueryString, mIntegrate, mQueryFlags, mForbiddenFlags, mAdapter.mListener);
|
||||
boolean hasArchiveFolder = false;
|
||||
if(mAccountUuids == null) {
|
||||
for (final Account acct : preferences.getAccounts()) {
|
||||
if (acct != null && acct.hasArchiveFolder()) {
|
||||
hasArchiveFolder = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (final String accountUuid : mAccountUuids) {
|
||||
final Account acct = preferences.getAccount(accountUuid);
|
||||
if (acct != null && acct.hasArchiveFolder()) {
|
||||
hasArchiveFolder = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!hasArchiveFolder) {
|
||||
mBatchArchiveButton.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -19,6 +19,7 @@ import android.preference.Preference;
|
||||
import android.preference.Preference.OnPreferenceClickListener;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.fsck.k9.Account;
|
||||
import com.fsck.k9.K9;
|
||||
import com.fsck.k9.Preferences;
|
||||
import com.fsck.k9.R;
|
||||
@ -366,6 +367,19 @@ public class Prefs extends K9PreferenceActivity {
|
||||
mBatchButtonsMove.setChecked(K9.batchButtonsMove());
|
||||
mBatchButtonsFlag.setChecked(K9.batchButtonsFlag());
|
||||
mBatchButtonsUnselect.setChecked(K9.batchButtonsUnselect());
|
||||
|
||||
// If we don't have any accounts with an archive folder, then don't enable the preference.
|
||||
boolean hasArchiveFolder = false;
|
||||
for(final Account acct : Preferences.getPreferences(this).getAccounts()) {
|
||||
if(acct.hasArchiveFolder()) {
|
||||
hasArchiveFolder = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!hasArchiveFolder) {
|
||||
mBatchButtonsArchive.setEnabled(false);
|
||||
mBatchButtonsArchive.setSummary(R.string.global_settings_archive_disabled_reason);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveSettings() {
|
||||
|
Loading…
Reference in New Issue
Block a user