Merge "String changes to Contacts App (3/3)" into ub-contactsdialer-a-dev
diff --git a/Android.mk b/Android.mk
index f449a60..7d18e7d 100644
--- a/Android.mk
+++ b/Android.mk
@@ -6,12 +6,18 @@
 contacts_common_dir := ../ContactsCommon
 phone_common_dir := ../PhoneCommon
 
+ifeq ($(TARGET_BUILD_APPS),)
+support_library_root_dir := frameworks/support
+else
+support_library_root_dir := prebuilts/sdk/current/support
+endif
+
 src_dirs := src $(contacts_common_dir)/src $(phone_common_dir)/src
 res_dirs := res $(contacts_common_dir)/res $(phone_common_dir)/res
 
 LOCAL_SRC_FILES := $(call all-java-files-under, $(src_dirs))
 LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, $(res_dirs)) \
-    frameworks/support/v7/cardview/res
+    $(support_library_root_dir)/v7/cardview/res
 
 LOCAL_AAPT_FLAGS := \
     --auto-add-overlay \
diff --git a/res/layout/editor_account_header_expandable.xml b/res/layout/editor_account_header_expandable.xml
index 5d347f0..2636f9c 100644
--- a/res/layout/editor_account_header_expandable.xml
+++ b/res/layout/editor_account_header_expandable.xml
@@ -25,12 +25,22 @@
     android:focusable="true"
     >
 
+    <!-- TODO: consider making this a new style, like EditKindIconStyle -->
+    <ImageView
+        android:id="@android:id/icon"
+        android:layout_width="@dimen/editor_kind_icon_size"
+        android:layout_height="@dimen/editor_kind_icon_size"
+        android:layout_marginEnd="28dp"
+        android:layout_gravity="center_vertical"
+        />
+
     <LinearLayout
+        android:id="@+id/account_info"
         android:layout_height="wrap_content"
-        android:layout_width="0dp"
+        android:layout_width="match_parent"
         android:layout_weight="1"
-        android:paddingBottom="24dp"
-        android:paddingTop="24dp"
+        android:paddingBottom="@dimen/editor_account_header_expandable_top_bottom_padding"
+        android:paddingTop="@dimen/editor_account_header_expandable_top_bottom_padding"
         android:orientation="vertical"
         >
 
diff --git a/res/layout/editor_account_selector.xml b/res/layout/editor_account_selector.xml
index 3a1bf83..6ba18a9 100644
--- a/res/layout/editor_account_selector.xml
+++ b/res/layout/editor_account_selector.xml
@@ -40,8 +40,9 @@
         android:layout_weight="1"
         android:layout_gravity="center_vertical"
         android:orientation="vertical"
+        android:layout_marginStart="4dp"
         android:layout_marginEnd="48dp"
-        style="@android:style/Widget.Material.Spinner.Underlined">
+        >
 
         <TextView
             android:id="@+id/account_type_selector"
@@ -65,4 +66,16 @@
 
     </LinearLayout>
 
+    <ImageView
+        android:src="@drawable/ic_menu_expander_minimized_holo_light"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center_vertical|end"
+        android:layout_alignParentEnd="true"
+        android:paddingStart="@dimen/editor_round_button_padding_left"
+        android:paddingEnd="@dimen/editor_round_button_padding_right"
+        android:paddingTop="@dimen/editor_round_button_padding_top"
+        android:paddingBottom="@dimen/editor_round_button_padding_bottom"/>
+
+
 </LinearLayout>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 000a32b..cffe8c4 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -108,6 +108,12 @@
     <!-- Top margin for the first field of the compact contact editor -->
     <dimen name="editor_compact_first_field_padding">10dp</dimen>
 
+    <!-- Top and bottom padding for the two text views in editor account header expandable -->
+    <dimen name="editor_account_header_expandable_top_bottom_padding">24dp</dimen>
+
+    <!-- left padding for the two text views in editor account header expandable -->
+    <dimen name="editor_account_header_expandable_left_padding">4dp</dimen>
+
     <!-- Width and height of the expanded contact photo on the contact detail page -->
     <dimen name="detail_contact_photo_expanded_size">400dip</dimen>
 
@@ -278,4 +284,5 @@
 
     <!-- Top margin for "Saving to" account header text field. -->
     <dimen name="compact_editor_account_header_top_margin">3dp</dimen>
+
 </resources>
diff --git a/src/com/android/contacts/editor/CompactRawContactsEditorView.java b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
index d6ffdb9..09315d5 100644
--- a/src/com/android/contacts/editor/CompactRawContactsEditorView.java
+++ b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
@@ -852,7 +852,7 @@
                 EditorUiUtils.getAccountInfoContentDescription(
                         accountInfo.first, selectorTitle));
 
-        mAccountSelector.setOnClickListener(new View.OnClickListener() {
+        mAccountSelectorContainer.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 final ListPopupWindow popup = new ListPopupWindow(getContext(), null);
diff --git a/src/com/android/contacts/editor/RawContactEditorView.java b/src/com/android/contacts/editor/RawContactEditorView.java
index b6320e9..5a4c9db 100644
--- a/src/com/android/contacts/editor/RawContactEditorView.java
+++ b/src/com/android/contacts/editor/RawContactEditorView.java
@@ -31,6 +31,8 @@
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
 import android.widget.TextView;
 
 import com.android.contacts.GroupMetaDataLoader;
@@ -77,6 +79,7 @@
     private View mAccountHeader;
     private TextView mAccountHeaderTypeTextView;
     private TextView mAccountHeaderNameTextView;
+    private ImageView mAccountIconImageView;
 
     private long mRawContactId = -1;
     private boolean mAutoAddToDefaultGroup = true;
@@ -140,6 +143,17 @@
         mAccountHeader = findViewById(R.id.account_header_container);
         mAccountHeaderTypeTextView = (TextView) findViewById(R.id.account_type);
         mAccountHeaderNameTextView = (TextView) findViewById(R.id.account_name);
+        mAccountIconImageView = (ImageView) findViewById(android.R.id.icon);
+
+        // The same header is used by both full editor and read-only editor view. The header is
+        // left-aligned with read-only editor view but is not aligned well with full editor. So we
+        // need to shift the text in the header a little bit for full editor.
+        LinearLayout accountInfoView = (LinearLayout) findViewById(R.id.account_info);
+        final int topBottomPaddingDp = (int) getResources().getDimension(R.dimen
+                .editor_account_header_expandable_top_bottom_padding);
+        final int leftPaddingDp = (int) getResources().getDimension(R.dimen
+                .editor_account_header_expandable_left_padding);
+        accountInfoView.setPadding(leftPaddingDp, topBottomPaddingDp, 0, topBottomPaddingDp);
 
         mAccountSelector = findViewById(R.id.account_selector_container);
         mAccountSelectorTypeTextView = (TextView) findViewById(R.id.account_type_selector);
@@ -212,6 +226,9 @@
         mAccountHeader.setVisibility(mAccountSelector.getVisibility() == View.GONE
                 ? View.VISIBLE : View.GONE);
 
+        mAccountIconImageView.setImageDrawable(state.getRawContactAccountType(getContext())
+                .getDisplayIcon(getContext()));
+
         // Show photo editor when supported
         RawContactModifier.ensureKindExists(state, type, Photo.CONTENT_ITEM_TYPE);
         setHasPhotoEditor((type.getKindForMimetype(Photo.CONTENT_ITEM_TYPE) != null));
diff --git a/src/com/android/contacts/editor/RawContactReadOnlyEditorView.java b/src/com/android/contacts/editor/RawContactReadOnlyEditorView.java
index ad2e013..8c54b05 100644
--- a/src/com/android/contacts/editor/RawContactReadOnlyEditorView.java
+++ b/src/com/android/contacts/editor/RawContactReadOnlyEditorView.java
@@ -61,6 +61,7 @@
 
     private TextView mAccountHeaderTypeTextView;
     private TextView mAccountHeaderNameTextView;
+    private ImageView mAccountIconImageView;
 
     private String mAccountName;
     private String mAccountType;
@@ -91,6 +92,7 @@
 
         mAccountHeaderTypeTextView = (TextView) findViewById(R.id.account_type);
         mAccountHeaderNameTextView = (TextView) findViewById(R.id.account_name);
+        mAccountIconImageView = (ImageView) findViewById(android.R.id.icon);
     }
 
     /**
@@ -128,6 +130,9 @@
         mAccountHeaderTypeTextView.setText(accountInfo.second);
         updateAccountHeaderContentDescription();
 
+        mAccountIconImageView.setImageDrawable(state.getRawContactAccountType(getContext())
+                .getDisplayIcon(getContext()));
+
         // TODO: Expose data set in the UI somehow?
 
         mRawContactId = state.getRawContactId();