Merge "Share currently shown contact over NFC."
diff --git a/res/layout-xlarge/account_selector_list_item.xml b/res/layout-xlarge/account_selector_list_item.xml
index 38acfc5..32fd0a5 100644
--- a/res/layout-xlarge/account_selector_list_item.xml
+++ b/res/layout-xlarge/account_selector_list_item.xml
@@ -16,9 +16,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:minHeight="?android:attr/listPreferredItemHeight"
->
+ android:layout_height="?android:attr/listPreferredItemHeight">
<ImageView android:id="@android:id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/layout/account_selector_list_item.xml b/res/layout/account_selector_list_item.xml
index 6fe2a50..7930f54 100644
--- a/res/layout/account_selector_list_item.xml
+++ b/res/layout/account_selector_list_item.xml
@@ -16,10 +16,9 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
+ android:layout_height="@dimen/account_selector_min_item_height"
android:paddingLeft="@dimen/account_selector_horizontal_margin"
- android:paddingRight="@dimen/account_selector_horizontal_margin"
- android:minHeight="@dimen/account_selector_min_item_height" >
+ android:paddingRight="@dimen/account_selector_horizontal_margin" >
<TextView android:id="@android:id/text1"
android:layout_width="match_parent"
diff --git a/src/com/android/contacts/editor/ContactEditorFragment.java b/src/com/android/contacts/editor/ContactEditorFragment.java
index 8cab92a..ba2794d 100644
--- a/src/com/android/contacts/editor/ContactEditorFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorFragment.java
@@ -670,7 +670,8 @@
@Override
public void onClick(View v) {
final ListPopupWindow popup = new ListPopupWindow(mContext, null);
- final AccountsListAdapter adapter = new AccountsListAdapter(mContext, true);
+ final AccountsListAdapter adapter =
+ new AccountsListAdapter(mContext, true, currentAccount);
popup.setWidth(anchorView.getWidth());
popup.setAnchorView(anchorView);
popup.setAdapter(adapter);
diff --git a/src/com/android/contacts/util/AccountsListAdapter.java b/src/com/android/contacts/util/AccountsListAdapter.java
index 97a9f84..1a8b3ea 100644
--- a/src/com/android/contacts/util/AccountsListAdapter.java
+++ b/src/com/android/contacts/util/AccountsListAdapter.java
@@ -17,8 +17,8 @@
package com.android.contacts.util;
import com.android.contacts.R;
-import com.android.contacts.model.AccountTypeManager;
import com.android.contacts.model.AccountType;
+import com.android.contacts.model.AccountTypeManager;
import android.accounts.Account;
import android.content.Context;
@@ -29,6 +29,7 @@
import android.widget.ImageView;
import android.widget.TextView;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -41,9 +42,25 @@
private final Context mContext;
public AccountsListAdapter(Context context, boolean writableOnly) {
+ this(context, writableOnly, null);
+ }
+
+ /**
+ * @param currentAccount the Account currently selected by the user, which should come
+ * first in the list. Can be null.
+ */
+ public AccountsListAdapter(Context context, boolean writableOnly,
+ Account currentAccount) {
mContext = context;
mAccountTypes = AccountTypeManager.getInstance(context);
- mAccounts = mAccountTypes.getAccounts(writableOnly);
+ // We don't want possible side-effect toward AccountTypeManager
+ mAccounts = new ArrayList<Account>(mAccountTypes.getAccounts(writableOnly));
+ if (currentAccount != null
+ && !mAccounts.isEmpty()
+ && !mAccounts.get(0).equals(currentAccount)
+ && mAccounts.remove(currentAccount)) {
+ mAccounts.add(0, currentAccount);
+ }
mInflater = LayoutInflater.from(context);
}