From d954cd76c610e8fafd91aec857f4232ab49ef2cd Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Wed, 4 Sep 2013 14:01:28 -0700 Subject: Restrict the cap # of frequents on home screen to 20 Bug: 10365481 - If the counter of starred contacts is less than 20, show maximum 20 starred + frequents - If the counter of starred contacts is no less than 20, show all the starred contacts only (no frequents) Change-Id: If2b9533446671f37e64caffd85e8db330b857ecd --- .../android/dialer/list/PhoneFavoritesTileAdapter.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/com/android') diff --git a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java index 263794f67..1c6ffde38 100644 --- a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java +++ b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java @@ -121,6 +121,15 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements private static final int PIN_LIMIT = 20; + /** + * The soft limit on how many contact tiles to show. + * NOTE This soft limit would not restrict the number of starred contacts to show, rather + * 1. If the count of starred contacts is less than this limit, show 20 tiles total. + * 2. If the count of starred contacts is more than or equal to this limit, + * show all starred tiles and no frequents. + */ + private static final int TILES_SOFT_LIMIT = 20; + final Comparator mContactEntryComparator = new Comparator() { @Override public int compare(ContactEntry lhs, ContactEntry rhs) { @@ -254,6 +263,9 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements final Object dummy = new Object(); + // Track the length of {@link #mContactEntries} and compare to {@link #TILES_SOFT_LIMIT}. + int counter = 0; + while (cursor.moveToNext()) { final int starred = cursor.getInt(mStarredIndex); @@ -261,6 +273,8 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements if (starred > 0) { id = cursor.getLong(mIdIndex); + } else if (counter >= TILES_SOFT_LIMIT) { + break; } else { // The contact id for frequent contacts is stored in the .contact_id field rather // than the _id field @@ -305,6 +319,8 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements contact.pinned = pinned; mContactEntries.add(contact); + + counter++; } mAwaitingRemove = false; -- cgit v1.2.3