Merge "Import translations. DO NOT MERGE"
diff --git a/res/drawable-hdpi/ic_done_wht_24dp.png b/res/drawable-hdpi/ic_done_wht_24dp.png
new file mode 100644
index 0000000..12ce8e0
--- /dev/null
+++ b/res/drawable-hdpi/ic_done_wht_24dp.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_menu_done_holo_dark.png b/res/drawable-hdpi/ic_menu_done_holo_dark.png
deleted file mode 100644
index 750c77e..0000000
--- a/res/drawable-hdpi/ic_menu_done_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_menu_done_holo_light.png b/res/drawable-hdpi/ic_menu_done_holo_light.png
deleted file mode 100644
index 2c07476..0000000
--- a/res/drawable-hdpi/ic_menu_done_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_done_wht_24dp.png b/res/drawable-mdpi/ic_done_wht_24dp.png
new file mode 100644
index 0000000..1032711
--- /dev/null
+++ b/res/drawable-mdpi/ic_done_wht_24dp.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_menu_done_holo_dark.png b/res/drawable-mdpi/ic_menu_done_holo_dark.png
deleted file mode 100644
index 7ec8c8f..0000000
--- a/res/drawable-mdpi/ic_menu_done_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_menu_done_holo_light.png b/res/drawable-mdpi/ic_menu_done_holo_light.png
deleted file mode 100644
index d18b783..0000000
--- a/res/drawable-mdpi/ic_menu_done_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_done_wht_24dp.png b/res/drawable-xhdpi/ic_done_wht_24dp.png
new file mode 100644
index 0000000..e34b73e
--- /dev/null
+++ b/res/drawable-xhdpi/ic_done_wht_24dp.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_menu_done_holo_dark.png b/res/drawable-xhdpi/ic_menu_done_holo_dark.png
deleted file mode 100644
index b9af04a..0000000
--- a/res/drawable-xhdpi/ic_menu_done_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_menu_done_holo_light.png b/res/drawable-xhdpi/ic_menu_done_holo_light.png
deleted file mode 100644
index 7cde3e5..0000000
--- a/res/drawable-xhdpi/ic_menu_done_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_done_wht_24dp.png b/res/drawable-xxhdpi/ic_done_wht_24dp.png
new file mode 100644
index 0000000..4c6a653
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_done_wht_24dp.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_menu_done_holo_dark.png b/res/drawable-xxhdpi/ic_menu_done_holo_dark.png
deleted file mode 100644
index 7f6919c..0000000
--- a/res/drawable-xxhdpi/ic_menu_done_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_menu_done_holo_light.png b/res/drawable-xxhdpi/ic_menu_done_holo_light.png
deleted file mode 100644
index 9a6f448..0000000
--- a/res/drawable-xxhdpi/ic_menu_done_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_done_wht_24dp.png b/res/drawable-xxxhdpi/ic_done_wht_24dp.png
new file mode 100644
index 0000000..2e36684
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_done_wht_24dp.png
Binary files differ
diff --git a/res/drawable/item_background_material_borderless_dark.xml b/res/drawable/item_background_material_borderless_dark.xml
new file mode 100644
index 0000000..693bcaf
--- /dev/null
+++ b/res/drawable/item_background_material_borderless_dark.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+
+<!-- Based on the Theme.Material's default selectableItemBackgroundBorderless -->
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+    android:color="@color/ripple_material_dark" />
\ No newline at end of file
diff --git a/res/drawable/item_background_material_dark.xml b/res/drawable/item_background_material_dark.xml
new file mode 100644
index 0000000..87b1e17
--- /dev/null
+++ b/res/drawable/item_background_material_dark.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+
+<!-- Based on the Theme.Material's default selectableItemBackground -->
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+    android:color="@color/ripple_material_dark" >
+    <item android:id="@android:id/mask">
+        <color android:color="@android:color/white" />
+    </item>
+</ripple>
\ No newline at end of file
diff --git a/res/drawable/quickcontact_card_border.xml b/res/drawable/quickcontact_card_border.xml
new file mode 100644
index 0000000..f0daea1
--- /dev/null
+++ b/res/drawable/quickcontact_card_border.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle">
+    <stroke
+        android:width="@dimen/expanding_entry_card_border_width"
+        android:color="@color/card_margin_color"/>
+</shape>
diff --git a/res/layout/editor_custom_action_bar.xml b/res/layout/editor_custom_action_bar.xml
index af7b738..7a31b92 100644
--- a/res/layout/editor_custom_action_bar.xml
+++ b/res/layout/editor_custom_action_bar.xml
@@ -14,52 +14,32 @@
      limitations under the License.
 -->
 
-<FrameLayout
+<LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="match_parent">
+    android:layout_height="match_parent"
+    android:orientation="horizontal">
 
-    <LinearLayout
+    <ImageView
         android:id="@+id/save_menu_item"
-        android:layout_width="wrap_content"
-        android:layout_height="match_parent"
-        android:divider="?android:attr/dividerVertical"
-        android:showDividers="end"
-        android:dividerPadding="12dip"
-        android:orientation="horizontal"
         android:focusable="true"
-        android:clickable="true">
+        android:clickable="true"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center_vertical"
+        android:layout_marginEnd="8dip"
+        android:src="@drawable/ic_done_wht_24dp"
+        style="?android:attr/actionButtonStyle"
+        android:description="@string/menu_done" />
 
-        <LinearLayout
-            android:layout_width="wrap_content"
-            android:layout_height="match_parent"
-            android:orientation="horizontal"
-            android:duplicateParentState="true"
-            style="?android:attr/actionButtonStyle">
+    <TextView
+        android:id="@+id/title"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center_vertical"
+        android:textAppearance="?android:attr/textAppearanceMedium"
+        android:textColor="@color/actionbar_text_color"
+        android:text="@string/menu_done"
+        style="@android:style/TextAppearance.Material.Widget.ActionBar.Title" />
 
-            <ImageView
-                android:id="@+id/icon"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_gravity="center_vertical"
-                android:layout_marginRight="8dip"
-                android:layout_marginEnd="8dip"
-                android:src="@drawable/ic_menu_done_holo_light"
-                android:description="@string/menu_done" />
-
-            <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_gravity="center_vertical"
-                android:layout_marginRight="20dip"
-                android:layout_marginEnd="20dip"
-                android:textAppearance="?android:attr/textAppearanceMedium"
-                android:textColor="@color/actionbar_text_color"
-                android:text="@string/menu_done"
-                style="@android:style/Widget.Holo.ActionBar.TabText" />
-
-        </LinearLayout>
-
-    </LinearLayout>
-
-</FrameLayout>
\ No newline at end of file
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/quickcontact_content.xml b/res/layout/quickcontact_content.xml
index b5b2a83..ec2073a 100644
--- a/res/layout/quickcontact_content.xml
+++ b/res/layout/quickcontact_content.xml
@@ -18,8 +18,7 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:fillViewport="true"
-    android:id="@+id/content_scroller"
-    android:background="@color/card_margin_color">
+    android:id="@+id/content_scroller">
 
     <!-- All the cards should be inserted into this LinearLayout -->
     <LinearLayout
@@ -27,16 +26,37 @@
         android:layout_height="match_parent"
         android:orientation="vertical"
         android:id="@+id/card_container">
-        <com.android.contacts.quickcontact.ExpandingEntryCardView
-            style="@style/ExpandingEntryCardStyle"
-            android:id="@+id/communication_card"
-            android:layout_marginTop="@dimen/communication_card_marginTop"
-            android:visibility="gone" />
 
-        <com.android.contacts.quickcontact.ExpandingEntryCardView
-            style="@style/ExpandingEntryCardStyle"
-            android:id="@+id/recent_card"
-            android:visibility="gone" />
+        <!-- We cannot set the border directly on ExpandingEntryCardView without it looking
+             funny because of the card's elevation value. So we need a parent FrameLayout -->
+        <FrameLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:background="@drawable/quickcontact_card_border">
+            <com.android.contacts.quickcontact.ExpandingEntryCardView
+                style="@style/ExpandingEntryCardStyle"
+                android:id="@+id/communication_card"
+                android:layout_marginTop="@dimen/communication_card_marginTop"
+                android:visibility="gone" />
+        </FrameLayout>
+
+        <FrameLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:background="@drawable/quickcontact_card_border">
+            <com.android.contacts.quickcontact.ExpandingEntryCardView
+                style="@style/ExpandingEntryCardStyle"
+                android:id="@+id/recent_card"
+                android:visibility="gone" />
+        </FrameLayout>
+
+        <!-- Fill the rest of the LinearLayout with the correct background color -->
+        <View
+            android:id="@+id/card_empty_space"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:background="@color/card_margin_color" />
+
     </LinearLayout>
 
 </com.android.contacts.widget.TouchlessScrollView>
\ No newline at end of file
diff --git a/res/layout/quickcontact_header.xml b/res/layout/quickcontact_header.xml
index 0c51746..50c4af0 100644
--- a/res/layout/quickcontact_header.xml
+++ b/res/layout/quickcontact_header.xml
@@ -28,7 +28,14 @@
         android:id="@+id/photo"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:scaleType="centerCrop"
+        android:clickable="false"
+        android:scaleType="centerCrop" />
+
+    <View
+        android:id="@+id/photo_touch_intercept_overlay"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:background="@drawable/item_background_material_dark"
         android:contentDescription="@string/description_contact_photo" />
 
     <!-- Need to set a non null background on Toolbar in order for MenuItem ripples to be drawn on
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 89f39b8..76de472 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -52,4 +52,7 @@
 
     <color name="call_arrow_green">#2aad6f</color>
     <color name="call_arrow_red">#ff2e58</color>
+
+    <!-- Color of ripples use by Theme.Material. Taken from res/values/colors_material.xml -->
+    <color name="ripple_material_dark">#20ffffff</color>
 </resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 5a2f7ab..79dd5d6 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -147,6 +147,9 @@
     <dimen name="expanding_entry_card_marginStart">12dp</dimen>
     <dimen name="expanding_entry_card_marginEnd">12dp</dimen>
     <dimen name="expanding_entry_card_marginBottom">12dp</dimen>
+    <!-- Width of the grey border surrounding the expanding entry cards. If we ever add
+         a rounded corner to the expanding entry cards, than we will need to increase this value -->
+    <dimen name="expanding_entry_card_border_width">12dp</dimen>
 
     <!-- Top margin for the communication card, used to add space from header. -->
     <dimen name="communication_card_marginTop">12dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 434a62b..643e674 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -626,6 +626,16 @@
     <!-- Message in the contact editor prompt that asks the user which account they want to save the newly created contact to. [CHAR LIMIT=NONE] -->
     <string name="contact_editor_prompt_multiple_accounts">You can synchronize your new contact with one of the following accounts. Which do you want to use?</string>
 
+    <!-- Title of the ContactEditorActivity when creating a new contact. The char
+         limit is short and cannot be increased, since this needs to be displayed in a single line
+         at a pre-determined text size. [CHAR LIMIT=20] -->
+    <string name="contact_editor_title_new_contact">Add new contact</string>
+
+    <!-- Title of the ContactEditorActivity when editing a contact that already exists. The char
+         limit is short and cannot be increased, since this needs to be displayed in a single line
+         at a pre-determined text size. [CHAR LIMIT=20] -->
+    <string name="contact_editor_title_existing_contact">Edit contact</string>
+
     <!-- Button label to indicate that the user wants to save the newly created contact locally (instead of backing it up online) [CHAR LIMIT=20] -->
     <string name="keep_local">Keep local</string>
 
diff --git a/res/values/styles.xml b/res/values/styles.xml
index ef66126..d29074b 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -43,6 +43,9 @@
         <item name="android:windowIsTranslucent">true</item>
         <item name="android:windowNoTitle">true</item>
         <item name="android:listViewStyle">@style/ListViewStyle</item>
+        <!-- We need to use a light ripple behind ActionBar items in order for them to
+             be visible when using some of the darker ActionBar tints -->
+        <item name="android:actionBarItemBackground">@drawable/item_background_material_borderless_dark</item>
     </style>
 
     <style name="PeopleTheme" parent="@android:style/Theme.Material.Light">
diff --git a/src/com/android/contacts/activities/ContactEditorActivity.java b/src/com/android/contacts/activities/ContactEditorActivity.java
index d47449d..5f382a7 100644
--- a/src/com/android/contacts/activities/ContactEditorActivity.java
+++ b/src/com/android/contacts/activities/ContactEditorActivity.java
@@ -30,6 +30,7 @@
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.View.OnClickListener;
+import android.widget.TextView;
 
 import com.android.contacts.ContactSaveService;
 import com.android.contacts.ContactsActivity;
@@ -106,6 +107,14 @@
                     mFragment.doSaveAction();
                 }
             });
+            TextView title = (TextView) customActionBarView.findViewById(R.id.title);
+            if (Intent.ACTION_EDIT.equals(action)) {
+                title.setText(getResources().getString(
+                        R.string.contact_editor_title_existing_contact));
+            } else {
+                title.setText(getResources().getString(
+                        R.string.contact_editor_title_new_contact));
+            }
             // Show the custom action bar but hide the home icon and title
             actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
                     ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME |
diff --git a/src/com/android/contacts/detail/ContactDetailFragment.java b/src/com/android/contacts/detail/ContactDetailFragment.java
index 6573fa2..805ee39 100644
--- a/src/com/android/contacts/detail/ContactDetailFragment.java
+++ b/src/com/android/contacts/detail/ContactDetailFragment.java
@@ -1357,6 +1357,10 @@
             return true;
         }
 
+        public boolean shouldCollapseWith(DetailViewEntry entry, Context context) {
+            return false;
+        }
+
         @Override
         public void click(View clickedView, Listener fragmentListener) {
             if (fragmentListener == null || intent == null) return;
diff --git a/src/com/android/contacts/quickcontact/DataAction.java b/src/com/android/contacts/quickcontact/DataAction.java
index a0df1e6..37021ec 100644
--- a/src/com/android/contacts/quickcontact/DataAction.java
+++ b/src/com/android/contacts/quickcontact/DataAction.java
@@ -334,6 +334,10 @@
         return true;
     }
 
+    public boolean shouldCollapseWith(Action t, Context context) {
+        return false;
+    }
+
     @Override
     public Integer getTimesUsed() {
         return mTimesUsed;
diff --git a/src/com/android/contacts/widget/MultiShrinkScroller.java b/src/com/android/contacts/widget/MultiShrinkScroller.java
index 18f032a..5c00a0a 100644
--- a/src/com/android/contacts/widget/MultiShrinkScroller.java
+++ b/src/com/android/contacts/widget/MultiShrinkScroller.java
@@ -79,6 +79,8 @@
     private View mTransparentView;
     private MultiShrinkScrollerListener mListener;
     private TextView mLargeTextView;
+    private View mPhotoTouchInterceptOverlay;
+    private View mLeftOverSpaceView;
     /** Contains desired location/size of the title, once the header is fully compressed */
     private TextView mInvisiblePlaceholderTextView;
     private int mHeaderTintColor;
@@ -134,7 +136,7 @@
     private final AnimatorListener mHeaderExpandAnimationListener = new AnimatorListenerAdapter() {
         @Override
         public void onAnimationEnd(Animator animation) {
-            mPhotoView.setClickable(true);
+            mPhotoTouchInterceptOverlay.setClickable(true);
         }
     };
 
@@ -216,15 +218,20 @@
         mTransparentView = findViewById(R.id.transparent_view);
         mLargeTextView = (TextView) findViewById(R.id.large_title);
         mInvisiblePlaceholderTextView = (TextView) findViewById(R.id.placeholder_textview);
+        mLeftOverSpaceView = findViewById(R.id.card_empty_space);
         mListener = listener;
 
         mPhotoView = (QuickContactImageView) findViewById(R.id.photo);
-        mPhotoView.setOnClickListener(new OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                expandCollapseHeader();
-            }
-        });
+
+        if (!mIsTwoPanel) {
+            mPhotoTouchInterceptOverlay = findViewById(R.id.photo_touch_intercept_overlay);
+            mPhotoTouchInterceptOverlay.setOnClickListener(new OnClickListener() {
+                @Override
+                public void onClick(View v) {
+                    expandCollapseHeader();
+                }
+            });
+        }
 
         final WindowManager windowManager = (WindowManager) getContext().getSystemService(
                 Context.WINDOW_SERVICE);
@@ -375,7 +382,7 @@
      * complete.
      */
     private void expandCollapseHeader() {
-        mPhotoView.setClickable(false);
+        mPhotoTouchInterceptOverlay.setClickable(false);
         if (getHeaderHeight() != mMaximumHeaderHeight) {
             // Expand header
             final ObjectAnimator animator = ObjectAnimator.ofInt(this, "headerHeight",
@@ -628,10 +635,10 @@
         if (!mIsTwoPanel) {
             return mTransparentStartHeight
                     // How much the Header view can compress
-                    + mIntermediateHeaderHeight - mMinimumHeaderHeight
+                    + mIntermediateHeaderHeight - getFullyCompressedHeaderHeight()
                     // How much the ScrollView can scroll. 0, if child is smaller than ScrollView.
                     + Math.max(0, mScrollViewChild.getHeight() - getHeight()
-                    + mMinimumHeaderHeight);
+                    + getFullyCompressedHeaderHeight());
         } else {
             return mTransparentStartHeight
                     // How much the ScrollView can scroll. 0, if child is smaller than ScrollView.
@@ -657,16 +664,32 @@
         }
         final LinearLayout.LayoutParams toolbarLayoutParams
                 = (LayoutParams) mToolbar.getLayoutParams();
-        if (toolbarLayoutParams.height != mMinimumHeaderHeight) {
+        if (toolbarLayoutParams.height > getFullyCompressedHeaderHeight()) {
             final int originalValue = toolbarLayoutParams.height;
             toolbarLayoutParams.height -= delta;
-            toolbarLayoutParams.height = Math.max(toolbarLayoutParams.height, mMinimumHeaderHeight);
+            toolbarLayoutParams.height = Math.max(toolbarLayoutParams.height,
+                    getFullyCompressedHeaderHeight());
             mToolbar.setLayoutParams(toolbarLayoutParams);
             delta -= originalValue - toolbarLayoutParams.height;
         }
         mScrollView.scrollBy(0, delta);
     }
 
+    /**
+     * Returns the minimum size that we want to compress the header to, given that we don't want to
+     * allow the the ScrollView to scroll unless there is new content off of the edge of ScrollView.
+     */
+    private int getFullyCompressedHeaderHeight() {
+        final LinearLayout.LayoutParams toolbarLayoutParams
+                = (LayoutParams) mToolbar.getLayoutParams();
+        final int usedScrollViewSpace = mScrollViewChild.getHeight()
+                - mLeftOverSpaceView.getHeight();
+        final int leftOverSpace = -getHeight() + usedScrollViewSpace + toolbarLayoutParams.height;
+        return Math.min(
+                Math.max(toolbarLayoutParams.height - leftOverSpace, mMinimumHeaderHeight),
+                mIntermediateHeaderHeight);
+    }
+
     private void scrollDown(int delta) {
         if (mScrollView.getScrollY() > 0) {
             final int originalValue = mScrollView.getScrollY();