diff options
author | Yorke Lee <yorkelee@google.com> | 2013-07-31 16:05:46 -0700 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2013-08-07 14:10:44 -0700 |
commit | 55f3ec9f882b2389e498ea68f68ce8670c5d4c73 (patch) | |
tree | 8c40696ca3cd739bb606f7e90ecc23d4e2ae8662 /tests | |
parent | fb585079cc4c522c27f6dd6bf03fd296535960f3 (diff) |
Integrate pinning support with drag and drop UI
* Added the concept of a blank entry. This is used to keep the
rest of the list in place while a contact is being dragged.
Blank entries appear as invisible views for now.
* Added the concept of a DEMOTED contact, which is used to
indicate that a contact should never be displayed in the favorites
list.
* Pinned position management methods and tests
Added two methods to handle assigning of contact positions based
on their pinned positions, as well as reflowing of contacts
when a contact is pinned at a new position.
The assigning of contact positions works as defined below:
1) All contacts with pinned positions are assigned their defined
pinned positions as necessary.
2) If two contacts have been given the same pinned position, they are
ranked based on the order returned from the ContactsProvider (
alphabetical by display name). The second contact is then pushed to
the next position, bumping all corresponding pinned contacts down
by one spot as necessary.
3) If there is a contact with a pinned position that is greater than
the number of starred + frequent contacts (this can happen if user clears
frequents, for example), then it is simply treated as an unpinned contacts.
4) All unpinned contacts flow to fill in the gaps between pinned contacts.
The reflowing of contacts works as defined below:
1) Pinning a contact at a new spot replacing an unpinned contact simply
pins it at that position.
2) Pinning a contact at a new spot where there was already an existing
pinned contact bumps that replaced pinned contact down by one spot
alongside all subsequent pinned contacts as necessary.
I.e. contact A is pinned at position 2.
Before: [A][1][P][P][4][P] After: [0][1][A][P][P][P]
3) If there is no more space at the end of the list to bump the pinned
contacts one spot further, then the replaced pinned contacts will shift
to the left to take the space of the original moved contact.
I.e. contact A is pinned at position 3.
Before: [A][1][P][P][P][P] After: [0][P][P][A][P][P]
* We no longer perform dynamic updates of the in-memory list.
Instead, when a contact is dropped at a new location, the new
positions are sent to the ContactsProvider, which updates the database
and notifies the adapter that there is a new cursor with updated data.
The new list of ContactEntries is then reconstructed from this new cursor.
Note that animation behavior with the newly introduced pinned contacts
is pretty janky looking - Instead of flowing together with the rest of the
unpinned contacts, pinned contacts should remain in position and not animate
on a dataset change. Likewise for empty contacts. In order to support this,
the animation logic will have to be rewritten to take into account
not just soley where the dragged contact was dropped, but also the old and new
position of each and every single contact in the list, before and after
the database refresh.
Change-Id: I5c9542a7fec529f5d965eebe76acbebe1fc10357
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/dialer/list/PhoneFavoritesTileAdapterTest.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/src/com/android/dialer/list/PhoneFavoritesTileAdapterTest.java b/tests/src/com/android/dialer/list/PhoneFavoritesTileAdapterTest.java new file mode 100644 index 000000000..40d171c8c --- /dev/null +++ b/tests/src/com/android/dialer/list/PhoneFavoritesTileAdapterTest.java @@ -0,0 +1,46 @@ +package com.android.dialer.list; + +import android.test.AndroidTestCase; + +public class PhoneFavoritesTileAdapterTest extends AndroidTestCase { + private PhoneFavoritesTileAdapter mAdapter; + + @Override + protected void setUp() throws Exception { + super.setUp(); + mAdapter = new PhoneFavoritesTileAdapter(getContext(), null, 3, 1); + } + + /** + * TODO Krelease: Add tests + * + * Test cases (various combinations of): + * No pinned contacts + * One pinned contact + * Multiple pinned contacts with differing pinned positions + * Multiple pinned contacts with conflicting pinned positions + * Pinned contacts with pinned positions at the start, middle, end, and outside the list + */ + public void testArrangeContactsByPinnedPosition() { + + } + + /** + * TODO Krelease: Add tests + * + * This method assumes that contacts have already been reordered by + * arrangeContactsByPinnedPosition, so we can test it with a less expansive set of test data. + * + * Test cases: + * Pin a single contact at the start, middle and end of a completely unpinned list + * Pin a single contact at the start, middle and end of a list with various numbers of + * pinned contacts + * Pin a single contact at the start, middle and end of a list where all contacts are pinned + * such that contacts are forced to the left as necessary. + */ + public void testGetReflowedPinnedPositions() { + + } + + +} |