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

Commit 90478f13 authored by Tingting Wang's avatar Tingting Wang Committed by Android (Google) Code Review
Browse files

Merge "Fix nit comments on quick contact suggestion card." into ub-contactsdialer-a-dev

parents c679817c e29b6943
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -24,4 +24,7 @@
    <!-- Number of lines the QuickContact title can have -->
    <integer name="quickcontact_title_lines">1</integer>

    <!-- Max suggestions limit showing in quick contact suggestion card [CHAR LIMIT=30]-->
    <integer name="quickcontact_suggestions_limit">10</integer>

</resources>
+1 −1
Original line number Diff line number Diff line
@@ -777,7 +777,7 @@
    <!-- Button used in quick contact suggestion card to merge selected contacts. [CHAR LIMIT=30]-->
    <string name="quickcontact_suggestion_merge_button">Merge</string>

    <!-- Suggestions number in quick contact suggestion card [CHAR LIMIT=30] -->
    <!-- Suggestions number in quick contact suggestion card [CHAR LIMIT=60] -->
    <plurals name="quickcontact_suggestions_number">
        <item quantity="one">1 suggested contact</item>
        <item quantity="other"><xliff:g id="count">%d</xliff:g> suggested contacts</item>
+52 −38
Original line number Diff line number Diff line
@@ -255,6 +255,7 @@ public class QuickContactActivity extends ContactsActivity
    private View mSuggestionSeparator;
    private Button mSuggestionsMergeButton;
    private boolean mIsSuggestionListCollapsed;
    private long mPreviousSuggestionForContactId = 0;

    private MultiShrinkScroller mScroller;
    private SelectAccountDialogFragmentListener mSelectAccountFragmentListener;
@@ -489,7 +490,11 @@ public class QuickContactActivity extends ContactsActivity
        final int suggestionNumber = mSuggestions.size();
        final String suggestionSummary = getSuggestionAccountSummary(mSuggestions);

        if (suggestionNumber > 0) {
        if (suggestionNumber <= 0) {
            mSelectedAggregationIds.clear();
            return;
        }

        mSuggestionCardView.setVisibility(View.VISIBLE);

        // Take the first suggestion 's photo as the summary photo.
@@ -509,10 +514,17 @@ public class QuickContactActivity extends ContactsActivity
                R.plurals.quickcontact_suggestions_number, suggestionNumber, suggestionNumber));
        mSuggestionSummary.setText(suggestionSummary);

        final Set<Long> suggestionContactIds = new HashSet<>();
        for (Suggestion suggestion : mSuggestions) {
            mSuggestionList.addView(inflateSuggestionListView(suggestion));
            suggestionContactIds.add(suggestion.contactId);
        }

        // Remove contact Ids that are not suggestions.
        final Set<Long> selectedSuggestionIds = com.google.common.collect.Sets.intersection(
                mSelectedAggregationIds, suggestionContactIds);
        mSelectedAggregationIds = new TreeSet<>(selectedSuggestionIds);

        mSuggestionExpansionButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
@@ -523,10 +535,6 @@ public class QuickContactActivity extends ContactsActivity
                }
            }
        });

        } else {
            mSuggestionCardView.setVisibility(View.GONE);
        }
    }

    private void collapseSuggestionList() {
@@ -563,7 +571,7 @@ public class QuickContactActivity extends ContactsActivity
            }
        }

        Set<String> accountTypeWithNumber = new HashSet<>();
        final Set<String> accountTypeWithNumber = new HashSet<>();
        for (String accountType : accountTypeMap.keySet()) {
            final String number = getResources().getQuantityString(
                    R.plurals.quickcontact_suggestion_account_type_number,
@@ -927,9 +935,8 @@ public class QuickContactActivity extends ContactsActivity
                if (!mSelectedAggregationIds.contains(mContactData.getId())) {
                    mSelectedAggregationIds.add(mContactData.getId());
                }
                TreeSet<Long> mergedContactIds = new TreeSet<Long>(mSelectedAggregationIds);
                mSelectedAggregationIds.clear(); // Clear selected ids for merged contact.
                JoinContactsDialogFragment.start(QuickContactActivity.this, mergedContactIds);
                JoinContactsDialogFragment.start(
                        QuickContactActivity.this, mSelectedAggregationIds);
            }
        });

@@ -1320,11 +1327,18 @@ public class QuickContactActivity extends ContactsActivity
        if (mAggregationSuggestionEngine == null) {
            mAggregationSuggestionEngine = new AggregationSuggestionEngine(this);
            mAggregationSuggestionEngine.setListener(this);
            mAggregationSuggestionEngine.setSuggestionsLimit(10);
            mAggregationSuggestionEngine.setSuggestionsLimit(getResources().getInteger(
                    R.integer.quickcontact_suggestions_limit));
            mAggregationSuggestionEngine.start();
        }

        mAggregationSuggestionEngine.setContactId(mContactData.getId());
        if (mPreviousSuggestionForContactId != 0
                && mPreviousSuggestionForContactId != mContactData.getId()) {
            // Clear selected Ids when listing suggestions for new contact Id.
            mSelectedAggregationIds.clear();
        }
        mPreviousSuggestionForContactId = mContactData.getId();

        // Trigger suggestion engine to compute suggestions.
        final ContentValues values = new ContentValues();