Merge "Turn the Aizy into a scrollbar again, similar to the old FastScroll"
diff --git a/src/com/android/contacts/activities/ContactBrowserActivity.java b/src/com/android/contacts/activities/ContactBrowserActivity.java
index 27fdb60..b7afc1b 100644
--- a/src/com/android/contacts/activities/ContactBrowserActivity.java
+++ b/src/com/android/contacts/activities/ContactBrowserActivity.java
@@ -237,24 +237,36 @@
     private void configureListFragment(boolean fromRequest) {
         boolean searchMode = mSearchMode;
         if (fromRequest) {
-            if (mRequest.getDisplayWithPhoneNumbersOnly()) {
-                mContactListFilterController.setContactListFilter(new ContactListFilter(
-                        ContactListFilter.FILTER_TYPE_WITH_PHONE_NUMBERS_ONLY), false);
+            ContactListFilter filter = null;
+            int actionCode = mRequest.getActionCode();
+            switch (actionCode) {
+                case ContactsRequest.ACTION_ALL_CONTACTS:
+                    filter = new ContactListFilter(ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS);
+                    break;
+                case ContactsRequest.ACTION_CONTACTS_WITH_PHONES:
+                    filter = new ContactListFilter(
+                            ContactListFilter.FILTER_TYPE_WITH_PHONE_NUMBERS_ONLY);
+                    break;
+
+                // TODO: handle FREQUENT and STREQUENT according to the spec
+                case ContactsRequest.ACTION_FREQUENT:
+                case ContactsRequest.ACTION_STREQUENT:
+                    // For now they are treated the same as STARRED
+                case ContactsRequest.ACTION_STARRED:
+                    filter = new ContactListFilter(ContactListFilter.FILTER_TYPE_STARRED);
+                    break;
+            }
+
+            if (filter != null) {
+                mContactListFilterController.setContactListFilter(filter, false);
                 searchMode = false;
+            } else if (mRequest.getActionCode() == ContactsRequest.ACTION_ALL_CONTACTS) {
+                mContactListFilterController.setContactListFilter(new ContactListFilter(
+                        ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS), false);
             }
         } else {
             if (mHasActionBar) {
                 searchMode = mActionBarAdapter.isSearchMode();
-            } else {
-// TODO: reenable FREQUENT, STARRED and STREQUENT
-//                int actionCode = mRequest.getActionCode();
-//                if (actionCode == ContactsRequest.ACTION_FREQUENT ||
-//                        actionCode == ContactsRequest.ACTION_STARRED ||
-//                        actionCode == ContactsRequest.ACTION_STREQUENT) {
-//                    mode = ContactBrowserMode.MODE_FAVORITES;
-//                } else {
-//                    mode = ContactBrowserMode.MODE_CONTACTS;
-//                }
             }
         }
 
diff --git a/src/com/android/contacts/list/ContactsIntentResolver.java b/src/com/android/contacts/list/ContactsIntentResolver.java
index d1525fb..3b34cb5 100644
--- a/src/com/android/contacts/list/ContactsIntentResolver.java
+++ b/src/com/android/contacts/list/ContactsIntentResolver.java
@@ -53,7 +53,6 @@
 
     public ContactsRequest resolveIntent(Intent intent) {
         ContactsRequest request = new ContactsRequest();
-        request.setDisplayOnlyVisible(true);
 
         String action = intent.getAction();
 
@@ -62,11 +61,9 @@
         if (UI.LIST_DEFAULT.equals(action) ) {
             request.setActionCode(ContactsRequest.ACTION_DEFAULT);
         } else if (UI.LIST_ALL_CONTACTS_ACTION.equals(action)) {
-            request.setActionCode(ContactsRequest.ACTION_DEFAULT);
-            request.setDisplayOnlyVisible(false);
+            request.setActionCode(ContactsRequest.ACTION_ALL_CONTACTS);
         } else if (UI.LIST_CONTACTS_WITH_PHONES_ACTION.equals(action)) {
-            request.setActionCode(ContactsRequest.ACTION_DEFAULT);
-            request.setDisplayWithPhoneNumbersOnly(true);
+            request.setActionCode(ContactsRequest.ACTION_CONTACTS_WITH_PHONES);
         } else if (UI.LIST_STARRED_ACTION.equals(action)) {
             request.setActionCode(ContactsRequest.ACTION_STARRED);
         } else if (UI.LIST_FREQUENT_ACTION.equals(action)) {
diff --git a/src/com/android/contacts/list/ContactsRequest.java b/src/com/android/contacts/list/ContactsRequest.java
index 331dc93..aefa451 100644
--- a/src/com/android/contacts/list/ContactsRequest.java
+++ b/src/com/android/contacts/list/ContactsRequest.java
@@ -29,6 +29,12 @@
     /** Default mode: browse contacts */
     public static final int ACTION_DEFAULT = 10;
 
+    /** Show all contacts */
+    public static final int ACTION_ALL_CONTACTS = 15;
+
+    /** Show all contacts with phone numbers */
+    public static final int ACTION_CONTACTS_WITH_PHONES = 17;
+
     /** Show contents of a specific group */
     public static final int ACTION_GROUP = 20;
 
@@ -74,8 +80,6 @@
     private CharSequence mTitle;
     private boolean mSearchMode;
     private String mQueryString;
-    private boolean mDisplayOnlyWithPhones;
-    private boolean mDisplayOnlyVisible;
     private String mGroupName;
     private boolean mLegacyCompatibilityMode;
     private boolean mDirectorySearchEnabled = true;
@@ -91,8 +95,6 @@
         mTitle = request.mTitle;
         mSearchMode = request.mSearchMode;
         mQueryString = request.mQueryString;
-        mDisplayOnlyWithPhones = request.mDisplayOnlyWithPhones;
-        mDisplayOnlyVisible = request.mDisplayOnlyVisible;
         mGroupName = request.mGroupName;
         mLegacyCompatibilityMode = request.mLegacyCompatibilityMode;
         mDirectorySearchEnabled = request.mDirectorySearchEnabled;
@@ -114,8 +116,6 @@
             request.mTitle = source.readCharSequence();
             request.mSearchMode = source.readInt() != 0;
             request.mQueryString = source.readString();
-            request.mDisplayOnlyWithPhones = source.readInt() != 0;
-            request.mDisplayOnlyVisible = source.readInt() != 0;
             request.mGroupName = source.readString();
             request.mLegacyCompatibilityMode  = source.readInt() != 0;
             request.mDirectorySearchEnabled = source.readInt() != 0;
@@ -131,8 +131,6 @@
         dest.writeCharSequence(mTitle);
         dest.writeInt(mSearchMode ? 1 : 0);
         dest.writeString(mQueryString);
-        dest.writeInt(mDisplayOnlyWithPhones ? 1 : 0);
-        dest.writeInt(mDisplayOnlyVisible ? 1 : 0);
         dest.writeString(mGroupName);
         dest.writeInt(mLegacyCompatibilityMode ? 1 : 0);
         dest.writeInt(mDirectorySearchEnabled ? 1 : 0);
@@ -175,22 +173,6 @@
         mActionCode = actionCode;
     }
 
-    public boolean getDisplayOnlyVisible() {
-        return mDisplayOnlyVisible;
-    }
-
-    public void setDisplayOnlyVisible(boolean flag) {
-        mDisplayOnlyVisible = flag;
-    }
-
-    public boolean getDisplayWithPhoneNumbersOnly() {
-        return mDisplayOnlyWithPhones;
-    }
-
-    public void setDisplayWithPhoneNumbersOnly(boolean option) {
-        mDisplayOnlyWithPhones = option;
-    }
-
     public boolean isSearchMode() {
         return mSearchMode;
     }
diff --git a/src/com/android/contacts/widget/ListViewUtils.java b/src/com/android/contacts/widget/ListViewUtils.java
index bfa686e..f5af63b 100644
--- a/src/com/android/contacts/widget/ListViewUtils.java
+++ b/src/com/android/contacts/widget/ListViewUtils.java
@@ -47,7 +47,7 @@
 
             @Override
             public void run() {
-                int firstPosition = listView.getFirstVisiblePosition();
+                int firstPosition = listView.getFirstVisiblePosition() + 1;
                 int lastPosition = listView.getLastVisiblePosition();
                 if (position >= firstPosition && position <= lastPosition) {
                     return; // Already on screen
@@ -62,13 +62,19 @@
                     if (preliminaryPosition >= listView.getCount()) {
                         preliminaryPosition = listView.getCount() - 1;
                     }
+                    if (preliminaryPosition < firstPosition) {
+                        listView.setSelection(preliminaryPosition);
+                    }
                 } else {
                     preliminaryPosition = position - twoScreens;
                     if (preliminaryPosition < 0) {
                         preliminaryPosition = 0;
                     }
+                    if (preliminaryPosition > lastPosition) {
+                        listView.setSelection(preliminaryPosition);
+                    }
                 }
-                listView.setSelection(preliminaryPosition);
+
                 scrollToFinalPosition(listView, position);
             }
         });