Change padding in account selection dialog (2/2)
This CL fixes the padding in account selection dialog opened
when importing contacts. The account_selector_list_item_condensed.xml
is created based on account_selector_list_item.xml and with unique
margin settings. This is because account_selector_list_item.xml was
used in 3 places, and it didn't align well with the importing contacts
dialog.
Screenshots: https://drive.google.com/a/google.com/folderview?id=0BwSNbQ_IWQd2Zlh0OExxSkJtQ0U&usp=sharing
Bug: 22292872
Change-Id: I98f3093dd20bf87354676647355984d1427e21af
diff --git a/src/com/android/contacts/common/editor/SelectAccountDialogFragment.java b/src/com/android/contacts/common/editor/SelectAccountDialogFragment.java
index c2ebbbf..d4a23f0 100644
--- a/src/com/android/contacts/common/editor/SelectAccountDialogFragment.java
+++ b/src/com/android/contacts/common/editor/SelectAccountDialogFragment.java
@@ -24,6 +24,7 @@
import android.content.DialogInterface;
import android.os.Bundle;
+import com.android.contacts.common.R;
import com.android.contacts.common.model.account.AccountWithDataSet;
import com.android.contacts.common.util.AccountsListAdapter;
import com.android.contacts.common.util.AccountsListAdapter.AccountListFilter;
@@ -76,6 +77,7 @@
final AccountListFilter filter = (AccountListFilter) args.getSerializable(KEY_LIST_FILTER);
final AccountsListAdapter accountAdapter = new AccountsListAdapter(builder.getContext(),
filter);
+ accountAdapter.setCustomLayout(R.layout.account_selector_list_item_condensed);
final DialogInterface.OnClickListener clickListener =
new DialogInterface.OnClickListener() {
diff --git a/src/com/android/contacts/common/util/AccountsListAdapter.java b/src/com/android/contacts/common/util/AccountsListAdapter.java
index 84435df..2c7a349 100644
--- a/src/com/android/contacts/common/util/AccountsListAdapter.java
+++ b/src/com/android/contacts/common/util/AccountsListAdapter.java
@@ -41,6 +41,7 @@
private final List<AccountWithDataSet> mAccounts;
private final AccountTypeManager mAccountTypes;
private final Context mContext;
+ private int mCustomLayout = -1;
/**
* Filters that affect the list of accounts that is displayed by this adapter.
@@ -81,10 +82,15 @@
accountListFilter == AccountListFilter.ACCOUNTS_CONTACT_WRITABLE));
}
+ public void setCustomLayout(int customLayout) {
+ mCustomLayout = customLayout;
+ }
+
@Override
public View getView(int position, View convertView, ViewGroup parent) {
- final View resultView = convertView != null ? convertView
- : mInflater.inflate(R.layout.account_selector_list_item, parent, false);
+ final View resultView = convertView != null ? convertView :
+ mInflater.inflate(mCustomLayout > 0 ? mCustomLayout :
+ R.layout.account_selector_list_item, parent, false);
final TextView text1 = (TextView) resultView.findViewById(android.R.id.text1);
final TextView text2 = (TextView) resultView.findViewById(android.R.id.text2);