summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCassie(Yitong) Wang <cassieyw@google.com>2019-09-26 13:40:43 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-09-26 13:40:43 -0700
commitd3037760075ce58012daf2133896669a590952d4 (patch)
tree284e5fba15db3b152a2a51a47b3ee07f858dfb6b
parentdcaceda50ba0e11d817eebc75d109446985f99f2 (diff)
parentccf8f4a678b41837020f4d8ec6d847b3dd72e0e1 (diff)
downloadDialer-d3037760075ce58012daf2133896669a590952d4.tar.gz
Show Contact avatar and phone number label on Dialpad page am: 72c8e59891 am: 32e21f9521
am: ccf8f4a678 Change-Id: I348f411985db37128646b7e05e8258792af50f3d
-rw-r--r--res/layout/dialpad_info.xml13
-rw-r--r--res/layout/dialpad_user_profile.xml51
-rw-r--r--res/values/configs.xml4
-rw-r--r--res/values/dimens.xml4
-rw-r--r--src/com/android/car/dialer/ui/common/UiCallLogLiveData.java3
-rw-r--r--src/com/android/car/dialer/ui/dialpad/DialpadFragment.java45
-rw-r--r--tests/robotests/src/com/android/car/dialer/ui/dialpad/DialpadFragmentTest.java4
7 files changed, 110 insertions, 14 deletions
diff --git a/res/layout/dialpad_info.xml b/res/layout/dialpad_info.xml
index d9411da6..f1827219 100644
--- a/res/layout/dialpad_info.xml
+++ b/res/layout/dialpad_info.xml
@@ -51,14 +51,13 @@
app:layout_constraintStart_toEndOf="@id/title"
app:layout_constraintEnd_toEndOf="parent"/>
- <TextView
- android:id="@+id/display_name"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="@style/TextAppearance.DialpadDisplayName"
- android:singleLine="true"
- android:layout_marginTop="@dimen/display_name_padding"
+ <include
+ layout="@layout/dialpad_user_profile"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_marginTop="@dimen/dialpad_user_profile_padding"
app:layout_constraintTop_toBottomOf="@id/title"
+ app:layout_constraintBottom_toTopOf="@+id/call_button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
diff --git a/res/layout/dialpad_user_profile.xml b/res/layout/dialpad_user_profile.xml
new file mode 100644
index 00000000..90f4edec
--- /dev/null
+++ b/res/layout/dialpad_user_profile.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<androidx.constraintlayout.widget.ConstraintLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <TextView
+ android:id="@+id/display_name"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="@style/TextAppearance.DialpadDisplayName"
+ android:singleLine="true"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"/>
+
+ <TextView
+ android:id="@+id/label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:singleLine="true"
+ android:layout_marginTop="@dimen/dialpad_contact_label_margin"
+ app:layout_constraintTop_toBottomOf="@id/display_name"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"/>
+
+ <ImageView
+ android:id="@+id/dialpad_contact_avatar"
+ android:layout_height="@dimen/dialpad_contact_avatar_size"
+ android:layout_width="@dimen/dialpad_contact_avatar_size"
+ app:layout_constraintTop_toTopOf="@id/label"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"/>
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/res/values/configs.xml b/res/values/configs.xml
index 006ccb29..e0345e0f 100644
--- a/res/values/configs.xml
+++ b/res/values/configs.xml
@@ -16,9 +16,11 @@
-->
<resources>
- <bool name="config_enable_dial_motion">true</bool>
<item name="config_dial_motion_scale_start" format="float" type="integer">1.5</item>
<integer name="config_dial_motion_duration">200</integer>
<item name="config_background_image_alpha" format="float" type="dimen">1.0</item>
<item name="config_background_image_error_alpha" format="float" type="dimen">1.0</item>
+
+ <bool name="config_enable_dial_motion">true</bool>
+ <bool name="config_show_detailed_user_profile_on_dialpad">false</bool>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 64f0bfbc..44f0e958 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -82,11 +82,13 @@
<dimen name="dialpad_info_title_padding_size">@*android:dimen/car_padding_4</dimen>
<dimen name="dialpad_info_edge_padding_size">@*android:dimen/car_padding_2</dimen>
<dimen name="dialpad_info_guideline">@dimen/touch_target_size</dimen>
- <dimen name="display_name_padding">@*android:dimen/car_padding_3</dimen>
+ <dimen name="dialpad_user_profile_padding">@*android:dimen/car_padding_3</dimen>
<dimen name="call_state_padding">@*android:dimen/car_padding_3</dimen>
<dimen name="dialpad_info_title_container_size">@dimen/touch_target_size</dimen>
<dimen name="dialpad_info_title_text_size_max">28sp</dimen>
<dimen name="dialpad_info_title_text_size_min">24sp</dimen>
+ <dimen name="dialpad_contact_avatar_size">64dp</dimen>
+ <dimen name="dialpad_contact_label_margin">12dp</dimen>
<!-- Keypad dimensions -->
<dimen name="keypad_minimum_size">@dimen/touch_target_size</dimen>
diff --git a/src/com/android/car/dialer/ui/common/UiCallLogLiveData.java b/src/com/android/car/dialer/ui/common/UiCallLogLiveData.java
index 9a5e8467..d200b602 100644
--- a/src/com/android/car/dialer/ui/common/UiCallLogLiveData.java
+++ b/src/com/android/car/dialer/ui/common/UiCallLogLiveData.java
@@ -149,7 +149,8 @@ public class UiCallLogLiveData extends MediatorLiveData<List<Object>> {
} else {
title = mContext.getString(R.string.unknown);
}
- PhoneNumber phoneNumber = contact != null ? contact.getPhoneNumber(number) : null;
+ PhoneNumber phoneNumber = contact != null
+ ? contact.getPhoneNumber(mContext, number) : null;
UiCallLog uiCallLog = new UiCallLog(
title,
diff --git a/src/com/android/car/dialer/ui/dialpad/DialpadFragment.java b/src/com/android/car/dialer/ui/dialpad/DialpadFragment.java
index e0a2f5a2..94a22d6e 100644
--- a/src/com/android/car/dialer/ui/dialpad/DialpadFragment.java
+++ b/src/com/android/car/dialer/ui/dialpad/DialpadFragment.java
@@ -28,6 +28,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
+import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -37,8 +38,10 @@ import com.android.car.apps.common.util.ViewUtils;
import com.android.car.dialer.R;
import com.android.car.dialer.log.L;
import com.android.car.dialer.telecom.UiCallManager;
+import com.android.car.dialer.ui.view.ContactAvatarOutputlineProvider;
import com.android.car.telephony.common.Contact;
import com.android.car.telephony.common.InMemoryPhoneBook;
+import com.android.car.telephony.common.PhoneNumber;
import com.android.car.telephony.common.TelecomUtils;
import com.google.common.annotations.VisibleForTesting;
@@ -74,7 +77,12 @@ public class DialpadFragment extends AbstractDialpadFragment {
.build();
private TextView mTitleView;
+ @Nullable
private TextView mDisplayName;
+ @Nullable
+ private TextView mLabel;
+ @Nullable
+ private ImageView mAvatar;
private ImageButton mDeleteButton;
private int mMode;
@@ -122,6 +130,11 @@ public class DialpadFragment extends AbstractDialpadFragment {
mMode == MODE_EMERGENCY ? R.style.TextAppearance_EmergencyDialNumber
: R.style.TextAppearance_DialNumber);
mDisplayName = rootView.findViewById(R.id.display_name);
+ mLabel = rootView.findViewById(R.id.label);
+ mAvatar = rootView.findViewById(R.id.dialpad_contact_avatar);
+ if (mAvatar != null) {
+ mAvatar.setOutlineProvider(ContactAvatarOutputlineProvider.get());
+ }
View callButton = rootView.findViewById(R.id.call_button);
callButton.setOnClickListener(v -> {
@@ -222,13 +235,37 @@ public class DialpadFragment extends AbstractDialpadFragment {
ViewUtils.setVisible(mDeleteButton, true);
}
- presentContactName(number);
+ presentContactInfo(number.toString());
}
- private void presentContactName(@NonNull StringBuffer number) {
- Contact contact = InMemoryPhoneBook.get().lookupContactEntry(number.toString());
- // OEM might remove the display name view.
+ private void presentContactInfo(@NonNull String number) {
+ Contact contact = InMemoryPhoneBook.get().lookupContactEntry(number);
ViewUtils.setText(mDisplayName, contact == null ? "" : contact.getDisplayName());
+ if (contact != null && getResources().getBoolean(
+ R.bool.config_show_detailed_user_profile_on_dialpad)) {
+ presentContactDetail(contact, number);
+ } else {
+ resetContactInfo();
+ }
+ }
+
+ private void presentContactDetail(@Nullable Contact contact, @NonNull String number) {
+ PhoneNumber phoneNumber = contact.getPhoneNumber(getContext(), number);
+ CharSequence readableLabel = phoneNumber.getReadableLabel(
+ getContext().getResources());
+ ViewUtils.setText(mLabel, phoneNumber.isPrimary() ? getContext().getString(
+ R.string.primary_number_description, readableLabel) : readableLabel);
+ ViewUtils.setVisible(mLabel, true);
+
+ if (mAvatar != null) {
+ TelecomUtils.setContactBitmapAsync(getContext(), mAvatar, contact, null);
+ }
+ ViewUtils.setVisible(mAvatar, true);
+ }
+
+ private void resetContactInfo() {
+ ViewUtils.setVisible(mLabel, false);
+ ViewUtils.setVisible(mAvatar, false);
}
private int getTopOffset() {
diff --git a/tests/robotests/src/com/android/car/dialer/ui/dialpad/DialpadFragmentTest.java b/tests/robotests/src/com/android/car/dialer/ui/dialpad/DialpadFragmentTest.java
index 6b349213..5f7df33d 100644
--- a/tests/robotests/src/com/android/car/dialer/ui/dialpad/DialpadFragmentTest.java
+++ b/tests/robotests/src/com/android/car/dialer/ui/dialpad/DialpadFragmentTest.java
@@ -18,6 +18,8 @@ package com.android.car.dialer.ui.dialpad;
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import android.content.Context;
@@ -35,6 +37,7 @@ import com.android.car.dialer.testutils.ShadowCallLogCalls;
import com.android.car.dialer.testutils.ShadowInMemoryPhoneBook;
import com.android.car.telephony.common.Contact;
import com.android.car.telephony.common.InMemoryPhoneBook;
+import com.android.car.telephony.common.PhoneNumber;
import com.android.car.telephony.common.TelecomUtils;
import org.junit.After;
@@ -201,6 +204,7 @@ public class DialpadFragmentTest {
public void testDisplayName() {
ShadowInMemoryPhoneBook phoneBook = Shadow.extract(InMemoryPhoneBook.get());
when(mMockContact.getDisplayName()).thenReturn(DISPALY_NAME);
+ when(mMockContact.getPhoneNumber(any(), any())).thenReturn(mock(PhoneNumber.class));
phoneBook.add(DIAL_NUMBER, mMockContact);
mDialpadFragment = DialpadFragment.newPlaceCallDialpad();