1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-24 08:38:51 -05:00

Disable account move menu items when account is at an end of the list.

Conflicts:

	src/com/fsck/k9/activity/Accounts.java
This commit is contained in:
danapple 2011-09-05 12:45:33 -05:00
parent 06cabdbde1
commit 2867a90286

View File

@ -1,6 +1,15 @@
package com.fsck.k9.activity;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
@ -12,27 +21,45 @@ import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.util.TypedValue;
import android.view.*;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.*;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
import com.fsck.k9.*;
import com.fsck.k9.helper.SizeFormatter;
import com.fsck.k9.Account;
import com.fsck.k9.AccountStats;
import com.fsck.k9.BaseAccount;
import com.fsck.k9.FontSizes;
import com.fsck.k9.K9;
import com.fsck.k9.Preferences;
import com.fsck.k9.R;
import com.fsck.k9.SearchAccount;
import com.fsck.k9.SearchSpecification;
import com.fsck.k9.activity.setup.AccountSettings;
import com.fsck.k9.activity.setup.AccountSetupBasics;
import com.fsck.k9.activity.setup.Prefs;
import com.fsck.k9.controller.MessagingController;
import com.fsck.k9.controller.MessagingListener;
import com.fsck.k9.helper.SizeFormatter;
import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.store.StorageManager;
import com.fsck.k9.view.ColorChip;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
public class Accounts extends K9ListActivity implements OnItemClickListener, OnClickListener {
/**
@ -323,9 +350,29 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
StorageManager.getInstance(getApplication()).removeListener(storageListener);
}
private BaseAccount[] accounts = new BaseAccount[0];
private enum ACCOUNT_LOCATION {
TOP, MIDDLE, BOTTOM;
}
private EnumSet<ACCOUNT_LOCATION> accountLocation(BaseAccount account) {
EnumSet<ACCOUNT_LOCATION> accountLocation = EnumSet.of(ACCOUNT_LOCATION.MIDDLE);
if (accounts.length > 0) {
if (accounts[0].equals(account)) {
accountLocation.remove(ACCOUNT_LOCATION.MIDDLE);
accountLocation.add(ACCOUNT_LOCATION.TOP);
}
if (accounts[accounts.length - 1].equals(account)) {
accountLocation.remove(ACCOUNT_LOCATION.MIDDLE);
accountLocation.add(ACCOUNT_LOCATION.BOTTOM);
}
}
return accountLocation;
}
private void refresh() {
BaseAccount[] accounts = Preferences.getPreferences(this).getAccounts();
accounts = Preferences.getPreferences(this).getAccounts();
List<BaseAccount> newAccounts;
if (!K9.isHideSpecialAccounts()
@ -763,6 +810,21 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
}
}
}
else {
EnumSet<ACCOUNT_LOCATION> accountLocation = accountLocation(account);
if (accountLocation.contains(ACCOUNT_LOCATION.TOP)) {
menu.findItem(R.id.move_up).setEnabled(false);
}
else {
menu.findItem(R.id.move_up).setEnabled(true);
}
if (accountLocation.contains(ACCOUNT_LOCATION.BOTTOM)) {
menu.findItem(R.id.move_down).setEnabled(false);
}
else {
menu.findItem(R.id.move_down).setEnabled(true);
}
}
}
class AccountsAdapter extends ArrayAdapter<BaseAccount> {