Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f78e42a2 authored by Paul Soulos's avatar Paul Soulos Committed by Android Git Automerger
Browse files

am 6b632891: Adds badges to the expand button

* commit '6b632891':
  Adds badges to the expand button
parents 93f39bb8 6b632891
Loading
Loading
Loading
Loading
+29 −11
Original line number Diff line number Diff line
@@ -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" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        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
+2 −0
Original line number Diff line number Diff line
@@ -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
+35 −1
Original line number Diff line number Diff line
@@ -182,6 +182,8 @@ public class ExpandingEntryCardView extends LinearLayout {
    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 @@ public class ExpandingEntryCardView extends LinearLayout {
                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 @@ public class ExpandingEntryCardView extends LinearLayout {

    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 @@ public class ExpandingEntryCardView extends LinearLayout {
        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);