am 56399fb8: am f78e42a2: am 6b632891: Adds badges to the expand button
* commit '56399fb87dc1b24d0a6180f54661c7e794d92305':
Adds badges to the expand button
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/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);