Merge "Import translations. DO NOT MERGE" into lmp-dev
diff --git a/res/layout/quickcontact_expanding_entry_card_button.xml b/res/layout/quickcontact_expanding_entry_card_button.xml
index 2896945..fef2959 100644
--- a/res/layout/quickcontact_expanding_entry_card_button.xml
+++ b/res/layout/quickcontact_expanding_entry_card_button.xml
@@ -15,25 +15,43 @@
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ style="@style/SelectableItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="vertical"
- style="@style/SelectableItem" >
+ android:orientation="vertical" >
<View
android:layout_width="match_parent"
android:layout_height="@dimen/expanding_entry_card_item_separator_height"
android:background="@color/expanding_entry_card_item_separator_color" />
- <TextView
- android:id="@+id/text"
- android:layout_width="wrap_content"
+ <LinearLayout
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:drawablePadding="@dimen/expanding_entry_card_button_drawable_padding"
- android:gravity="center_vertical"
- android:paddingBottom="@dimen/expanding_entry_card_button_padding_vertical"
- android:paddingStart="@dimen/expanding_entry_card_button_padding_start"
- android:paddingTop="@dimen/expanding_entry_card_button_padding_vertical"
- android:textColor="@color/expanding_entry_card_button_text_color" />
+ android:orientation="horizontal" >
+
+ <TextView
+ android:id="@+id/text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:drawablePadding="@dimen/expanding_entry_card_button_drawable_padding"
+ android:gravity="center_vertical"
+ android:layout_weight="0"
+ android:paddingBottom="@dimen/expanding_entry_card_button_padding_vertical"
+ android:paddingStart="@dimen/expanding_entry_card_button_padding_start"
+ android:paddingTop="@dimen/expanding_entry_card_button_padding_vertical"
+ android:textColor="@color/expanding_entry_card_button_text_color" />
+
+ <LinearLayout
+ android:id="@+id/badge_container"
+ android:gravity="end"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginRight="11dp"
+ android:layout_marginTop="@dimen/expanding_entry_card_button_padding_vertical"
+ android:layout_weight="1"
+ android:alpha=".3"
+ android:orientation="horizontal" />
+ </LinearLayout>
</LinearLayout>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index f0376f6..0d516eb 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -168,6 +168,8 @@
<dimen name="expanding_entry_card_item_alternate_icon_margin_end">0dp</dimen>
<dimen name="expanding_entry_card_item_alternate_icon_margin_bottom">10dp</dimen>
+ <dimen name="expanding_entry_card_badge_separator_margin">8dp</dimen>
+
<dimen name="people_activity_card_elevation">2dp</dimen>
<!-- The width the that the tabs occupy in the ActionBar when in landscape mode.
426dp is the height of a "small" screen. We should leave 240dp for
diff --git a/src/com/android/contacts/editor/StructuredNameEditorView.java b/src/com/android/contacts/editor/StructuredNameEditorView.java
index bf548f6..3408435 100644
--- a/src/com/android/contacts/editor/StructuredNameEditorView.java
+++ b/src/com/android/contacts/editor/StructuredNameEditorView.java
@@ -155,6 +155,7 @@
mSnapshot.getContentValues().clear();
mSnapshot.setDisplayName(values.getDisplayName());
+ mSnapshot.setMimeType(StructuredName.CONTENT_ITEM_TYPE);
for (String field : structuredNameMap.keySet()) {
mSnapshot.getContentValues().put(field, structuredNameMap.get(field));
}
diff --git a/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java b/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java
index a0bed05..0008a95 100644
--- a/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java
+++ b/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java
@@ -182,6 +182,8 @@
private boolean mIsAlwaysExpanded;
/** The ViewGroup to run the expand/collapse animation on */
private ViewGroup mAnimationViewGroup;
+ private LinearLayout mBadgeContainer;
+ private final List<ImageView> mBadges;
private final OnClickListener mExpandCollapseButtonListener = new OnClickListener() {
@Override
@@ -214,8 +216,9 @@
R.layout.quickcontact_expanding_entry_card_button, this, false);
mExpandCollapseTextView = (TextView) mExpandCollapseButton.findViewById(R.id.text);
mExpandCollapseButton.setOnClickListener(mExpandCollapseButtonListener);
+ mBadgeContainer = (LinearLayout) mExpandCollapseButton.findViewById(R.id.badge_container);
-
+ mBadges = new ArrayList<ImageView>();
}
/**
@@ -555,6 +558,7 @@
private void updateExpandCollapseButton(CharSequence buttonText) {
final Drawable arrow = mIsExpanded ? mCollapseArrowDrawable : mExpandArrowDrawable;
+ updateBadges();
if (getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
mExpandCollapseTextView.setCompoundDrawablesWithIntrinsicBounds(null, null, arrow,
null);
@@ -565,6 +569,36 @@
mExpandCollapseTextView.setText(buttonText);
}
+ private void updateBadges() {
+ if (mIsExpanded) {
+ mBadgeContainer.removeAllViews();
+ } else {
+ // Inflate badges if not yet created
+ if (mBadges.size() < mEntries.size() - mCollapsedEntriesCount) {
+ for (int i = mCollapsedEntriesCount; i < mEntries.size(); i++) {
+ Drawable badgeDrawable = mEntries.get(i).get(0).getIcon();
+ if (badgeDrawable != null) {
+ ImageView badgeView = new ImageView(getContext());
+ LinearLayout.LayoutParams badgeViewParams = new LinearLayout.LayoutParams(
+ (int) getResources().getDimension(
+ R.dimen.expanding_entry_card_item_icon_width),
+ (int) getResources().getDimension(
+ R.dimen.expanding_entry_card_item_icon_height));
+ badgeViewParams.setMarginEnd((int) getResources().getDimension(
+ R.dimen.expanding_entry_card_badge_separator_margin));
+ badgeView.setLayoutParams(badgeViewParams);
+ badgeView.setImageDrawable(badgeDrawable);
+ mBadges.add(badgeView);
+ }
+ }
+ }
+ mBadgeContainer.removeAllViews();
+ for (ImageView badge : mBadges) {
+ mBadgeContainer.addView(badge);
+ }
+ }
+ }
+
private void expand() {
ChangeBounds boundsTransition = new ChangeBounds();
boundsTransition.setDuration(DURATION_EXPAND_ANIMATION_CHANGE_BOUNDS);
diff --git a/src/com/android/contacts/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java
index 43066d6..314fb34 100644
--- a/src/com/android/contacts/quickcontact/QuickContactActivity.java
+++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java
@@ -290,20 +290,21 @@
// so the exact usage type is not necessary in all cases
String usageType = DataUsageFeedback.USAGE_TYPE_CALL;
- final String scheme = intent.getData().getScheme();
- if ((scheme != null && scheme.equals(CallUtil.SCHEME_SMSTO)) ||
+ final Uri intentUri = intent.getData();
+ if ((intentUri != null && intentUri.getScheme() != null &&
+ intentUri.getScheme().equals(CallUtil.SCHEME_SMSTO)) ||
(intent.getType() != null && intent.getType().equals(MIMETYPE_SMS))) {
usageType = DataUsageFeedback.USAGE_TYPE_SHORT_TEXT;
}
// Data IDs start at 1 so anything less is invalid
if (dataId > 0) {
- final Uri uri = DataUsageFeedback.FEEDBACK_URI.buildUpon()
+ final Uri dataUsageUri = DataUsageFeedback.FEEDBACK_URI.buildUpon()
.appendPath(String.valueOf(dataId))
.appendQueryParameter(DataUsageFeedback.USAGE_TYPE, usageType)
.build();
final boolean successful = getContentResolver().update(
- uri, new ContentValues(), null, null) > 0;
+ dataUsageUri, new ContentValues(), null, null) > 0;
if (!successful) {
Log.w(TAG, "DataUsageFeedback increment failed");
}
@@ -997,11 +998,25 @@
if (dataItem instanceof ImDataItem) {
final ImDataItem im = (ImDataItem) dataItem;
intent = ContactsUtils.buildImIntent(this, im).first;
- header = getResources().getString(R.string.header_im_entry);
final boolean isEmail = im.isCreatedFromEmail();
- final int protocol = isEmail ? Im.PROTOCOL_GOOGLE_TALK : im.getProtocol();
- subHeader = Im.getProtocolLabel(getResources(), protocol,
- im.getCustomProtocol()).toString();
+ final int protocol;
+ if (!im.isProtocolValid()) {
+ protocol = Im.PROTOCOL_CUSTOM;
+ } else {
+ protocol = isEmail ? Im.PROTOCOL_GOOGLE_TALK : im.getProtocol();
+ }
+ if (protocol == Im.PROTOCOL_CUSTOM) {
+ // If the protocol is custom, display the "IM" entry header as well to distinguish
+ // this entry from other ones
+ header = getResources().getString(R.string.header_im_entry);
+ subHeader = Im.getProtocolLabel(getResources(), protocol,
+ im.getCustomProtocol()).toString();
+ text = im.getData();
+ } else {
+ header = Im.getProtocolLabel(getResources(), protocol,
+ im.getCustomProtocol()).toString();
+ subHeader = im.getData();
+ }
} else if (dataItem instanceof OrganizationDataItem) {
final OrganizationDataItem organization = (OrganizationDataItem) dataItem;
header = getResources().getString(R.string.header_organization_entry);
@@ -1049,8 +1064,8 @@
}
header = getResources().getString(R.string.header_event_entry);
if (event.hasKindTypeColumn(kind)) {
- subHeader = getResources().getString(Event.getTypeResource(
- event.getKindTypeColumn(kind)));
+ subHeader = Event.getTypeLabel(getResources(), event.getKindTypeColumn(kind),
+ event.getLabel()).toString();
}
text = DateUtils.formatDate(this, dataString);
} else if (dataItem instanceof RelationDataItem) {
diff --git a/src/com/android/contacts/widget/TouchlessScrollView.java b/src/com/android/contacts/widget/TouchlessScrollView.java
index 693dcbc..a0c0eb2 100644
--- a/src/com/android/contacts/widget/TouchlessScrollView.java
+++ b/src/com/android/contacts/widget/TouchlessScrollView.java
@@ -1,6 +1,7 @@
package com.android.contacts.widget;
import android.content.Context;
+import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ScrollView;
@@ -9,7 +10,7 @@
* A {@link ScrollView} that doesn't respond or intercept touch events.
*
* This is used in combination with {@link com.android.contacts.widget.MultiShrinkScroller} so
- * that MultiShrinkScroller can handle all scrolling.
+ * that MultiShrinkScroller can handle all scrolling & saving.
*/
public class TouchlessScrollView extends ScrollView {
@@ -25,6 +26,17 @@
super(context, attrs, defStyleAttr);
}
+ @Override
+ protected Parcelable onSaveInstanceState() {
+ // Do not save the current scroll position. Always store scrollY=0 and delegate
+ // responsibility of saving state to the MultiShrinkScroller.
+ final int scrollY = getScrollY();
+ setScrollY(0);
+ final Parcelable returnValue = super.onSaveInstanceState();
+ setScrollY(scrollY);
+ return returnValue;
+ }
+
/**
* {@inheritDoc}
*/