summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNancy Chen <nancychen@google.com>2014-11-04 23:53:44 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-11-04 23:53:44 +0000
commit99ccab53072359eec8bd0afdd06785b6b0a447f8 (patch)
tree26b0b98914467f615979afc6f21c98a668b88c96 /src
parentde48a0dacbdb17dbb6407fc11be42ae19138d728 (diff)
parent75b25b5975be11e1d609f16be0653ef7821f8ae8 (diff)
downloadandroid_packages_apps_ContactsCommon-99ccab53072359eec8bd0afdd06785b6b0a447f8.tar.gz
android_packages_apps_ContactsCommon-99ccab53072359eec8bd0afdd06785b6b0a447f8.tar.bz2
android_packages_apps_ContactsCommon-99ccab53072359eec8bd0afdd06785b6b0a447f8.zip
Merge "Modify Select Account Dialog to align with UI mocks." into lmp-mr1-dev
Diffstat (limited to 'src')
-rw-r--r--src/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java47
1 files changed, 40 insertions, 7 deletions
diff --git a/src/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java b/src/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java
index ca62ce53..33eebcad 100644
--- a/src/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java
+++ b/src/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java
@@ -26,6 +26,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.telecom.TelecomManager;
+import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -46,6 +47,7 @@ import java.util.List;
* the choice to set the phone account as default.
*/
public class SelectPhoneAccountDialogFragment extends DialogFragment {
+ private int mTitleResId;
private boolean mCanSetDefault;
private List<PhoneAccountHandle> mAccountHandles;
private boolean mIsSelected;
@@ -59,17 +61,39 @@ public class SelectPhoneAccountDialogFragment extends DialogFragment {
*
* @param fragmentManager The fragment manager.
* @param accountHandles The {@code PhoneAccountHandle}s available to select from.
+ * @param listener The listener for the results of the account selection.
*/
- public static void showAccountDialog(FragmentManager fragmentManager, boolean canSetDefault,
+ public static void showAccountDialog(FragmentManager fragmentManager,
List<PhoneAccountHandle> accountHandles, SelectPhoneAccountListener listener) {
+ showAccountDialog(fragmentManager, R.string.select_account_dialog_title, false,
+ accountHandles, listener);
+ }
+
+ /**
+ * Shows the account selection dialog.
+ * This is the preferred way to show this dialog.
+ * This method also allows specifying a custom title and "set default" checkbox.
+ *
+ * @param fragmentManager The fragment manager.
+ * @param titleResId The resource ID for the string to use in the title of the dialog.
+ * @param canSetDefault {@code true} if the dialog should include an option to set the selection
+ * as the default. False otherwise.
+ * @param accountHandles The {@code PhoneAccountHandle}s available to select from.
+ * @param listener The listener for the results of the account selection.
+ */
+ public static void showAccountDialog(FragmentManager fragmentManager, int titleResId,
+ boolean canSetDefault, List<PhoneAccountHandle> accountHandles,
+ SelectPhoneAccountListener listener) {
SelectPhoneAccountDialogFragment fragment =
- new SelectPhoneAccountDialogFragment(canSetDefault, accountHandles, listener);
+ new SelectPhoneAccountDialogFragment(
+ titleResId, canSetDefault, accountHandles, listener);
fragment.show(fragmentManager, "selectAccount");
}
- public SelectPhoneAccountDialogFragment(boolean canSetDefault,
+ public SelectPhoneAccountDialogFragment(int titleResId, boolean canSetDefault,
List<PhoneAccountHandle> accountHandles, SelectPhoneAccountListener listener) {
super();
+ mTitleResId = titleResId;
mCanSetDefault = canSetDefault;
mAccountHandles = accountHandles;
mListener = listener;
@@ -111,7 +135,7 @@ public class SelectPhoneAccountDialogFragment extends DialogFragment {
R.layout.select_account_list_item,
mAccountHandles);
- AlertDialog dialog = builder.setTitle(R.string.select_account_dialog_title)
+ AlertDialog dialog = builder.setTitle(mTitleResId)
.setAdapter(selectAccountListAdapter, selectionListener)
.create();
@@ -152,7 +176,8 @@ public class SelectPhoneAccountDialogFragment extends DialogFragment {
// Cache views for faster scrolling
rowView = inflater.inflate(mResId, null);
holder = new ViewHolder();
- holder.textView = (TextView) rowView.findViewById(R.id.text);
+ holder.labelTextView = (TextView) rowView.findViewById(R.id.label);
+ holder.numberTextView = (TextView) rowView.findViewById(R.id.number);
holder.imageView = (ImageView) rowView.findViewById(R.id.icon);
rowView.setTag(holder);
}
@@ -163,13 +188,21 @@ public class SelectPhoneAccountDialogFragment extends DialogFragment {
PhoneAccountHandle accountHandle = getItem(position);
PhoneAccount account = mTelecomManager.getPhoneAccount(accountHandle);
- holder.textView.setText(account.getLabel());
+ holder.labelTextView.setText(account.getLabel());
+ if (account.getAddress() == null ||
+ TextUtils.isEmpty(account.getAddress().getSchemeSpecificPart())) {
+ holder.numberTextView.setVisibility(View.GONE);
+ } else {
+ holder.numberTextView.setVisibility(View.VISIBLE);
+ holder.numberTextView.setText(account.getAddress().getSchemeSpecificPart());
+ }
holder.imageView.setImageDrawable(account.getIcon(getContext()));
return rowView;
}
private class ViewHolder {
- TextView textView;
+ TextView labelTextView;
+ TextView numberTextView;
ImageView imageView;
}
}