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

Commit 5ea7f5a8 authored by yaolu's avatar yaolu Committed by android-build-merger
Browse files

Remove the expand/collapse behavior of the QuickContact contact card

am: 139a03bd

Change-Id: I3ecf9a6e0045335847e206f62dbdaf3b52811da0
parents 87adffee 139a03bd
Loading
Loading
Loading
Loading
+0 −2
Original line number Original line Diff line number Diff line
@@ -712,8 +712,6 @@
    <string name="expanding_entry_card_view_see_more">See more</string>
    <string name="expanding_entry_card_view_see_more">See more</string>
    <!-- Button Label to see less on an ExpandingEntryCardView [CHAR LIMIT=40] -->
    <!-- Button Label to see less on an ExpandingEntryCardView [CHAR LIMIT=40] -->
    <string name="expanding_entry_card_view_see_less">See less</string>
    <string name="expanding_entry_card_view_see_less">See less</string>
    <!-- Button Label to see all on an ExpandingEntryCardView [CHAR LIMIT=40] -->
    <string name="expanding_entry_card_view_see_all">See all</string>


    <!-- Title of recent card. [CHAR LIMIT=60] -->
    <!-- Title of recent card. [CHAR LIMIT=60] -->
    <string name="recent_card_title">Recent</string>
    <string name="recent_card_title">Recent</string>
+10 −81
Original line number Original line Diff line number Diff line
@@ -244,8 +244,6 @@ public class ExpandingEntryCardView extends CardView {
    private View mExpandCollapseButton;
    private View mExpandCollapseButton;
    private TextView mExpandCollapseTextView;
    private TextView mExpandCollapseTextView;
    private TextView mTitleTextView;
    private TextView mTitleTextView;
    private CharSequence mExpandButtonText;
    private CharSequence mCollapseButtonText;
    private OnClickListener mOnClickListener;
    private OnClickListener mOnClickListener;
    private OnCreateContextMenuListener mOnCreateContextMenuListener;
    private OnCreateContextMenuListener mOnCreateContextMenuListener;
    private boolean mIsExpanded = false;
    private boolean mIsExpanded = false;
@@ -263,11 +261,6 @@ public class ExpandingEntryCardView extends CardView {
    private final ImageView mExpandCollapseArrow;
    private final ImageView mExpandCollapseArrow;
    private int mThemeColor;
    private int mThemeColor;
    private ColorFilter mThemeColorFilter;
    private ColorFilter mThemeColorFilter;
    /**
     * Whether to prioritize the first entry type. If prioritized, we should show at least two
     * of this entry type.
     */
    private boolean mShowFirstEntryTypeTwice;
    private boolean mIsAlwaysExpanded;
    private boolean mIsAlwaysExpanded;
    /** The ViewGroup to run the expand/collapse animation on */
    /** The ViewGroup to run the expand/collapse animation on */
    private ViewGroup mAnimationViewGroup;
    private ViewGroup mAnimationViewGroup;
@@ -319,22 +312,14 @@ public class ExpandingEntryCardView extends CardView {
        mBadgeIds = new ArrayList<Integer>();
        mBadgeIds = new ArrayList<Integer>();
    }
    }


    public void initialize(List<List<Entry>> entries, int numInitialVisibleEntries,
            boolean isExpanded, boolean isAlwaysExpanded, ExpandingEntryCardViewListener listener,
            ViewGroup animationViewGroup) {
        initialize(entries, numInitialVisibleEntries, isExpanded, isAlwaysExpanded,
                listener, animationViewGroup, /* showFirstEntryTypeTwice = */ false);
    }

    /**
    /**
     * Sets the Entry list to display.
     * Sets the Entry list to display.
     *
     *
     * @param entries The Entry list to display.
     * @param entries The Entry list to display.
     */
     */
    public void initialize(List<List<Entry>> entries, int numInitialVisibleEntries,
    public void initialize(List<List<Entry>> entries, int numInitialVisibleEntries,
            boolean isExpanded, boolean isAlwaysExpanded,
            boolean isExpanded, boolean isAlwaysExpanded, ExpandingEntryCardViewListener listener,
            ExpandingEntryCardViewListener listener, ViewGroup animationViewGroup,
            ViewGroup animationViewGroup) {
            boolean showFirstEntryTypeTwice) {
        LayoutInflater layoutInflater = LayoutInflater.from(getContext());
        LayoutInflater layoutInflater = LayoutInflater.from(getContext());
        mIsExpanded = isExpanded;
        mIsExpanded = isExpanded;
        mIsAlwaysExpanded = isAlwaysExpanded;
        mIsAlwaysExpanded = isAlwaysExpanded;
@@ -344,7 +329,6 @@ public class ExpandingEntryCardView extends CardView {
        mEntries = entries;
        mEntries = entries;
        mNumEntries = 0;
        mNumEntries = 0;
        mAllEntriesInflated = false;
        mAllEntriesInflated = false;
        mShowFirstEntryTypeTwice = showFirstEntryTypeTwice;
        for (List<Entry> entryList : mEntries) {
        for (List<Entry> entryList : mEntries) {
            mNumEntries += entryList.size();
            mNumEntries += entryList.size();
            mEntryViews.add(new ArrayList<View>());
            mEntryViews.add(new ArrayList<View>());
@@ -368,30 +352,6 @@ public class ExpandingEntryCardView extends CardView {
        applyColor();
        applyColor();
    }
    }


    /**
     * Sets the text for the expand button.
     *
     * @param expandButtonText The expand button text.
     */
    public void setExpandButtonText(CharSequence expandButtonText) {
        mExpandButtonText = expandButtonText;
        if (mExpandCollapseTextView != null && !mIsExpanded) {
            mExpandCollapseTextView.setText(expandButtonText);
        }
    }

    /**
     * Sets the text for the expand button.
     *
     * @param expandButtonText The expand button text.
     */
    public void setCollapseButtonText(CharSequence expandButtonText) {
        mCollapseButtonText = expandButtonText;
        if (mExpandCollapseTextView != null && mIsExpanded) {
            mExpandCollapseTextView.setText(mCollapseButtonText);
        }
    }

    @Override
    @Override
    public void setOnClickListener(OnClickListener listener) {
    public void setOnClickListener(OnClickListener listener) {
        mOnClickListener = listener;
        mOnClickListener = listener;
@@ -468,19 +428,9 @@ public class ExpandingEntryCardView extends CardView {
                viewsToDisplay.add(entryViewList.get(0));
                viewsToDisplay.add(entryViewList.get(0));
                numInViewGroup++;
                numInViewGroup++;


                int indexInEntryViewList = 1;
                if (mShowFirstEntryTypeTwice && i == 0 && entryViewList.size() > 1) {
                    viewsToDisplay.add(entryViewList.get(1));
                    numInViewGroup++;
                    extraEntries--;
                    indexInEntryViewList++;
                }

                // Insert entries in this list to hit mCollapsedEntriesCount.
                // Insert entries in this list to hit mCollapsedEntriesCount.
                for (int j = indexInEntryViewList;
                for (int j = 1; j < entryViewList.size() && numInViewGroup < mCollapsedEntriesCount
                        j < entryViewList.size() && numInViewGroup < mCollapsedEntriesCount &&
                        && extraEntries > 0; j++) {
                        extraEntries > 0;
                        j++) {
                    viewsToDisplay.add(entryViewList.get(j));
                    viewsToDisplay.add(entryViewList.get(j));
                    numInViewGroup++;
                    numInViewGroup++;
                    extraEntries--;
                    extraEntries--;
@@ -532,22 +482,14 @@ public class ExpandingEntryCardView extends CardView {
    }
    }


    private CharSequence getExpandButtonText() {
    private CharSequence getExpandButtonText() {
        if (!TextUtils.isEmpty(mExpandButtonText)) {
            return mExpandButtonText;
        } else {
        // Default to "See more".
        // Default to "See more".
        return getResources().getText(R.string.expanding_entry_card_view_see_more);
        return getResources().getText(R.string.expanding_entry_card_view_see_more);
    }
    }
    }


    private CharSequence getCollapseButtonText() {
    private CharSequence getCollapseButtonText() {
        if (!TextUtils.isEmpty(mCollapseButtonText)) {
            return mCollapseButtonText;
        } else {
        // Default to "See less".
        // Default to "See less".
        return getResources().getText(R.string.expanding_entry_card_view_see_less);
        return getResources().getText(R.string.expanding_entry_card_view_see_less);
    }
    }
    }


    /**
    /**
     * Inflates the initial entries to be shown.
     * Inflates the initial entries to be shown.
@@ -569,18 +511,8 @@ public class ExpandingEntryCardView extends CardView {
                        /* showIcon = */ View.VISIBLE));
                        /* showIcon = */ View.VISIBLE));
                numInflated++;
                numInflated++;


                int indexInEntryViewList = 1;
                if (mShowFirstEntryTypeTwice && i == 0 && entryList.size() > 1) {
                    entryViewList.add(createEntryView(layoutInflater, entryList.get(1),
                        /* showIcon = */ View.INVISIBLE));
                    numInflated++;
                    extraEntries--;
                    indexInEntryViewList++;
                }

                // Inflate entries in this list to hit mCollapsedEntriesCount.
                // Inflate entries in this list to hit mCollapsedEntriesCount.
                for (int j = indexInEntryViewList; j < entryList.size()
                for (int j = 1; j < entryList.size() && numInflated < mCollapsedEntriesCount
                        && numInflated < mCollapsedEntriesCount
                        && extraEntries > 0; j++) {
                        && extraEntries > 0; j++) {
                    entryViewList.add(createEntryView(layoutInflater, entryList.get(j),
                    entryViewList.add(createEntryView(layoutInflater, entryList.get(j),
                            /* showIcon = */ View.INVISIBLE));
                            /* showIcon = */ View.INVISIBLE));
@@ -851,10 +783,7 @@ public class ExpandingEntryCardView extends CardView {
            mBadgeContainer.removeAllViews();
            mBadgeContainer.removeAllViews();
        } else {
        } else {
            int numberOfMimeTypesShown = mCollapsedEntriesCount;
            int numberOfMimeTypesShown = mCollapsedEntriesCount;
            if (mShowFirstEntryTypeTwice && mEntries.size() > 0

                    && mEntries.get(0).size() > 1) {
                numberOfMimeTypesShown--;
            }
            // Inflate badges if not yet created
            // Inflate badges if not yet created
            if (mBadges.size() < mEntries.size() - numberOfMimeTypesShown) {
            if (mBadges.size() < mEntries.size() - numberOfMimeTypesShown) {
                for (int i = numberOfMimeTypesShown; i < mEntries.size(); i++) {
                for (int i = numberOfMimeTypesShown; i < mEntries.size(); i++) {
+2 −9
Original line number Original line Diff line number Diff line
@@ -1071,8 +1071,6 @@ public class QuickContactActivity extends ContactsActivity
        mPermissionExplanationCard.setOnClickListener(mEntryClickHandler);
        mPermissionExplanationCard.setOnClickListener(mEntryClickHandler);
        mNoContactDetailsCard.setOnClickListener(mEntryClickHandler);
        mNoContactDetailsCard.setOnClickListener(mEntryClickHandler);
        mContactCard.setOnClickListener(mEntryClickHandler);
        mContactCard.setOnClickListener(mEntryClickHandler);
        mContactCard.setExpandButtonText(
        getResources().getString(R.string.expanding_entry_card_view_see_all));
        mContactCard.setOnCreateContextMenuListener(mEntryContextMenuListener);
        mContactCard.setOnCreateContextMenuListener(mEntryContextMenuListener);


        mRecentCard.setOnClickListener(mEntryClickHandler);
        mRecentCard.setOnClickListener(mEntryClickHandler);
@@ -1548,17 +1546,12 @@ public class QuickContactActivity extends ContactsActivity
        final String customAboutCardName = cp2DataCardModel.customAboutCardName;
        final String customAboutCardName = cp2DataCardModel.customAboutCardName;


        if (contactCardEntries.size() > 0) {
        if (contactCardEntries.size() > 0) {
            final boolean firstEntriesArePrioritizedMimeType =
                    !TextUtils.isEmpty(mExtraPrioritizedMimeType) &&
                    mCachedCp2DataCardModel.dataItemsMap.containsKey(mExtraPrioritizedMimeType) &&
                    mCachedCp2DataCardModel.dataItemsMap.get(mExtraPrioritizedMimeType).size() != 0;
            mContactCard.initialize(contactCardEntries,
            mContactCard.initialize(contactCardEntries,
                    /* numInitialVisibleEntries = */ MIN_NUM_CONTACT_ENTRIES_SHOWN,
                    /* numInitialVisibleEntries = */ MIN_NUM_CONTACT_ENTRIES_SHOWN,
                    /* isExpanded = */ mContactCard.isExpanded(),
                    /* isExpanded = */ mContactCard.isExpanded(),
                    /* isAlwaysExpanded = */ false,
                    /* isAlwaysExpanded = */ true,
                    mExpandingEntryCardViewListener,
                    mExpandingEntryCardViewListener,
                    mScroller,
                    mScroller);
                    firstEntriesArePrioritizedMimeType);
            if (mContactCard.getVisibility() == View.GONE && mShouldLog) {
            if (mContactCard.getVisibility() == View.GONE && mShouldLog) {
                Logger.logQuickContactEvent(mReferrer, mContactType, CardType.CONTACT,
                Logger.logQuickContactEvent(mReferrer, mContactType, CardType.CONTACT,
                        ActionType.UNKNOWN_ACTION, /* thirdPartyAction */ null);
                        ActionType.UNKNOWN_ACTION, /* thirdPartyAction */ null);