summaryrefslogtreecommitdiffstats
path: root/java/com/android/contacts
diff options
context:
space:
mode:
authortwyen <twyen@google.com>2017-11-20 15:13:07 -0800
committerCopybara-Service <copybara-piper@google.com>2017-11-20 17:43:06 -0800
commitba99befea1f4402a854351f80d8627909a532331 (patch)
treea6d98ea4ac1ba093cb7af1731fccceece0242da7 /java/com/android/contacts
parentf2d88b65fe86a7e2a67958ae0ac7e1961de9ac44 (diff)
downloadandroid_packages_apps_Dialer-ba99befea1f4402a854351f80d8627909a532331.tar.gz
android_packages_apps_Dialer-ba99befea1f4402a854351f80d8627909a532331.tar.bz2
android_packages_apps_Dialer-ba99befea1f4402a854351f80d8627909a532331.zip
Implement SIM selection dialog
Bug: 64216442,64214592,64213352 Test: N/A PiperOrigin-RevId: 176424724 Change-Id: I1709156098a14ac3bd35d98b913e7b881fcd9b2b
Diffstat (limited to 'java/com/android/contacts')
-rw-r--r--java/com/android/contacts/common/res/layout/default_account_checkbox.xml42
-rw-r--r--java/com/android/contacts/common/res/layout/select_account_list_item.xml70
-rw-r--r--java/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java57
3 files changed, 118 insertions, 51 deletions
diff --git a/java/com/android/contacts/common/res/layout/default_account_checkbox.xml b/java/com/android/contacts/common/res/layout/default_account_checkbox.xml
index b7c0cf644..1e76b74f5 100644
--- a/java/com/android/contacts/common/res/layout/default_account_checkbox.xml
+++ b/java/com/android/contacts/common/res/layout/default_account_checkbox.xml
@@ -15,22 +15,36 @@
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/default_account_checkbox_layout"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:padding="4dp"
- android:orientation="vertical">
- <CheckBox
- android:id="@+id/default_account_checkbox_view"
+ android:id="@+id/default_account_checkbox_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="20dip"
- android:layout_marginLeft="13dip"
- android:paddingStart="15dip"
+ android:padding="4dp"
+ android:paddingStart="0dp"
+ android:paddingEnd="24dp"
android:gravity="center"
- android:text="@string/set_default_account"
- android:textAlignment="viewStart"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="@color/dialer_secondary_text_color"
+ android:minHeight="56dp"
+ android:orientation="horizontal"
+ android:focusable="true">
+ <FrameLayout
+ android:layout_width="72dp"
+ android:layout_height="wrap_content">
+ <CheckBox
+ android:id="@+id/default_account_checkbox_view"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:checked="false"/>
/>
+ </FrameLayout>
+ <TextView
+ android:id="@+id/default_account_checkbox_text"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/set_default_account"
+ android:textAlignment="viewStart"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textColor="@color/dialer_secondary_text_color"
+ />
+
</LinearLayout>
diff --git a/java/com/android/contacts/common/res/layout/select_account_list_item.xml b/java/com/android/contacts/common/res/layout/select_account_list_item.xml
index fbd31e573..8f7cc7017 100644
--- a/java/com/android/contacts/common/res/layout/select_account_list_item.xml
+++ b/java/com/android/contacts/common/res/layout/select_account_list_item.xml
@@ -16,41 +16,53 @@
<!-- Layout of a single item in the InCallUI Account Chooser Dialog. -->
<com.android.contacts.common.widget.ActivityTouchLinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:padding="8dp"
- android:orientation="horizontal">
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="64dp"
+ android:padding="8dp"
+ android:paddingStart="24dp"
+ android:paddingEnd="24dp"
+ android:orientation="horizontal"
+ android:gravity="center">
<ImageView
- android:id="@+id/icon"
- android:layout_width="48dp"
- android:layout_height="48dp"
- android:scaleType="center"/>
+ android:id="@+id/icon"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:scaleType="center"/>
<LinearLayout
- android:id="@+id/text"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:layout_marginStart="8dp"
- android:gravity="start|center_vertical"
- android:orientation="vertical">
- <TextView
- android:id="@+id/label"
- android:layout_width="match_parent"
+ android:id="@+id/text"
+ android:layout_width="0dp"
android:layout_height="wrap_content"
- android:includeFontPadding="false"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textColor="@color/dialer_primary_text_color"/>
+ android:layout_weight="1"
+ android:paddingStart="24dp"
+ android:gravity="start|center_vertical"
+ android:orientation="vertical">
<TextView
- android:id="@+id/number"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:includeFontPadding="false"
- android:maxLines="1"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:visibility="gone"/>
+ android:id="@+id/label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:includeFontPadding="false"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="@color/dialer_primary_text_color"/>
+ <TextView
+ android:id="@+id/number"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:includeFontPadding="false"
+ android:maxLines="1"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:visibility="gone"/>
+ <TextView
+ android:id="@+id/hint"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:includeFontPadding="false"
+ android:maxLines="1"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:visibility="gone"/>
</LinearLayout>
</com.android.contacts.common.widget.ActivityTouchLinearLayout>
diff --git a/java/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java b/java/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java
index e21fded97..3c9d9268f 100644
--- a/java/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java
+++ b/java/com/android/contacts/common/widget/SelectPhoneAccountDialogFragment.java
@@ -55,12 +55,15 @@ public class SelectPhoneAccountDialogFragment extends DialogFragment {
private static final String ARG_TITLE_RES_ID = "title_res_id";
private static final String ARG_CAN_SET_DEFAULT = "can_set_default";
+ private static final String ARG_SET_DEFAULT_RES_ID = "set_default_res_id";
private static final String ARG_ACCOUNT_HANDLES = "account_handles";
private static final String ARG_IS_DEFAULT_CHECKED = "is_default_checked";
private static final String ARG_LISTENER = "listener";
private static final String ARG_CALL_ID = "call_id";
+ private static final String ARG_HINTS = "hints";
private List<PhoneAccountHandle> mAccountHandles;
+ private List<String> mHints;
private boolean mIsSelected;
private boolean mIsDefaultChecked;
private SelectPhoneAccountListener mListener;
@@ -78,7 +81,7 @@ public class SelectPhoneAccountDialogFragment extends DialogFragment {
SelectPhoneAccountListener listener,
@Nullable String callId) {
return newInstance(
- R.string.select_account_dialog_title, false, accountHandles, listener, callId);
+ R.string.select_account_dialog_title, false, 0, accountHandles, listener, callId, null);
}
/**
@@ -88,15 +91,22 @@ public class SelectPhoneAccountDialogFragment extends DialogFragment {
* @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 setDefaultResId The resource ID for the string to use in the "set as default" checkbox
* @param accountHandles The {@code PhoneAccountHandle}s available to select from.
* @param listener The listener for the results of the account selection.
+ * @param callId The callId to be passed back to the listener in {@link
+ * SelectPhoneAccountListener#EXTRA_CALL_ID}
+ * @param hints Additional information to be shown underneath the phone account to help user
+ * choose. Index must match {@code accountHandles}
*/
public static SelectPhoneAccountDialogFragment newInstance(
int titleResId,
boolean canSetDefault,
+ int setDefaultResId,
List<PhoneAccountHandle> accountHandles,
SelectPhoneAccountListener listener,
- @Nullable String callId) {
+ @Nullable String callId,
+ @Nullable List<String> hints) {
ArrayList<PhoneAccountHandle> accountHandlesCopy = new ArrayList<>();
if (accountHandles != null) {
accountHandlesCopy.addAll(accountHandles);
@@ -105,9 +115,13 @@ public class SelectPhoneAccountDialogFragment extends DialogFragment {
final Bundle args = new Bundle();
args.putInt(ARG_TITLE_RES_ID, titleResId);
args.putBoolean(ARG_CAN_SET_DEFAULT, canSetDefault);
+ args.putInt(ARG_SET_DEFAULT_RES_ID, setDefaultResId);
args.putParcelableArrayList(ARG_ACCOUNT_HANDLES, accountHandlesCopy);
args.putParcelable(ARG_LISTENER, listener);
args.putString(ARG_CALL_ID, callId);
+ if (hints != null) {
+ args.putStringArrayList(ARG_HINTS, new ArrayList<>(hints));
+ }
fragment.setArguments(args);
fragment.setListener(listener);
return fragment;
@@ -140,6 +154,7 @@ public class SelectPhoneAccountDialogFragment extends DialogFragment {
boolean canSetDefault = getArguments().getBoolean(ARG_CAN_SET_DEFAULT);
mAccountHandles = getArguments().getParcelableArrayList(ARG_ACCOUNT_HANDLES);
mListener = getArguments().getParcelable(ARG_LISTENER);
+ mHints = getArguments().getStringArrayList(ARG_HINTS);
if (savedInstanceState != null) {
mIsDefaultChecked = savedInstanceState.getBoolean(ARG_IS_DEFAULT_CHECKED);
}
@@ -173,7 +188,7 @@ public class SelectPhoneAccountDialogFragment extends DialogFragment {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
ListAdapter selectAccountListAdapter =
new SelectAccountListAdapter(
- builder.getContext(), R.layout.select_account_list_item, mAccountHandles);
+ builder.getContext(), R.layout.select_account_list_item, mAccountHandles, mHints);
AlertDialog dialog =
builder
@@ -189,10 +204,17 @@ public class SelectPhoneAccountDialogFragment extends DialogFragment {
LayoutInflater.from(builder.getContext())
.inflate(R.layout.default_account_checkbox, null);
- CheckBox cb = (CheckBox) checkboxLayout.findViewById(R.id.default_account_checkbox_view);
- cb.setOnCheckedChangeListener(checkListener);
- cb.setChecked(mIsDefaultChecked);
-
+ CheckBox checkBox = checkboxLayout.findViewById(R.id.default_account_checkbox_view);
+ checkBox.setOnCheckedChangeListener(checkListener);
+ checkBox.setChecked(mIsDefaultChecked);
+
+ TextView textView = checkboxLayout.findViewById(R.id.default_account_checkbox_text);
+ int setDefaultResId =
+ getArguments().getInt(ARG_SET_DEFAULT_RES_ID, R.string.set_default_account);
+ textView.setText(setDefaultResId);
+ textView.setOnClickListener((view) -> checkBox.performClick());
+ checkboxLayout.setOnClickListener((view) -> checkBox.performClick());
+ checkboxLayout.setContentDescription(getString(setDefaultResId));
dialog.getListView().addFooterView(checkboxLayout);
}
@@ -248,10 +270,15 @@ public class SelectPhoneAccountDialogFragment extends DialogFragment {
private static class SelectAccountListAdapter extends ArrayAdapter<PhoneAccountHandle> {
private int mResId;
+ private final List<String> mHints;
SelectAccountListAdapter(
- Context context, int resource, List<PhoneAccountHandle> accountHandles) {
+ Context context,
+ int resource,
+ List<PhoneAccountHandle> accountHandles,
+ @Nullable List<String> hints) {
super(context, resource, accountHandles);
+ mHints = hints;
mResId = resource;
}
@@ -269,6 +296,7 @@ public class SelectPhoneAccountDialogFragment extends DialogFragment {
holder = new ViewHolder();
holder.labelTextView = (TextView) rowView.findViewById(R.id.label);
holder.numberTextView = (TextView) rowView.findViewById(R.id.number);
+ holder.hintTextView = rowView.findViewById(R.id.hint);
holder.imageView = (ImageView) rowView.findViewById(R.id.icon);
rowView.setTag(holder);
} else {
@@ -294,6 +322,18 @@ public class SelectPhoneAccountDialogFragment extends DialogFragment {
}
holder.imageView.setImageDrawable(
PhoneAccountCompat.createIconDrawable(account, getContext()));
+ if (mHints != null && position < mHints.size()) {
+ String hint = mHints.get(position);
+ if (TextUtils.isEmpty(hint)) {
+ holder.hintTextView.setVisibility(View.GONE);
+ } else {
+ holder.hintTextView.setVisibility(View.VISIBLE);
+ holder.hintTextView.setText(hint);
+ }
+ } else {
+ holder.hintTextView.setVisibility(View.GONE);
+ }
+
return rowView;
}
@@ -301,6 +341,7 @@ public class SelectPhoneAccountDialogFragment extends DialogFragment {
TextView labelTextView;
TextView numberTextView;
+ TextView hintTextView;
ImageView imageView;
}
}