Some ListsFragment cleanups.

- Delete unused shortcut code.
+ Consolidate logic for reporting the current lists view.
+ Change page position logic to make private the list fragment's
calculation of the type of tab in RTL.

Bug: 21328994
Change-Id: Ic05a895fce77fea668798fca6e67863a2fcfd88a
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index 56d5ad1..502b845 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -585,7 +585,7 @@
     public void onClick(View view) {
         switch (view.getId()) {
             case R.id.floating_action_button:
-                if (mListsFragment.getTabPosition() == ListsFragment.TAB_INDEX_ALL_CONTACTS) {
+                if (mListsFragment.getCurrentTabIndex() == ListsFragment.TAB_INDEX_ALL_CONTACTS) {
                     DialerUtils.startActivityWithErrorToast(
                             this,
                             IntentUtil.getNewContactIntent(),
@@ -1162,25 +1162,25 @@
 
     @Override
     public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
-        position = mListsFragment.getRtlPosition(position);
-        // Only scroll the button when the first tab is selected. The button should scroll from
-        // the middle to right position only on the transition from the first tab to the second
-        // tab.
-        // If the app is in RTL mode, we need to check against the second tab, rather than the
-        // first. This is because if we are scrolling between the first and second tabs, the
-        // viewpager will report that the starting tab position is 1 rather than 0, due to the
-        // reversal of the order of the tabs.
-        final boolean isLayoutRtl = DialerUtils.isRtl();
-        final boolean shouldScrollButton = position == (isLayoutRtl
-                ? ListsFragment.TAB_INDEX_RECENTS : ListsFragment.TAB_INDEX_SPEED_DIAL);
-        if (shouldScrollButton && !mIsLandscape) {
-            mFloatingActionButtonController.onPageScrolled(
-                    isLayoutRtl ? 1 - positionOffset : positionOffset);
-        } else if (position != ListsFragment.TAB_INDEX_SPEED_DIAL) {
+        int tabIndex = mListsFragment.getCurrentTabIndex();
+
+        // Scroll the button from center to end when moving from the Speed Dial to Recents tab.
+        // In RTL, scroll when the current tab is Recents instead of Speed Dial, because the order
+        // of the tabs is reversed and the ViewPager returns the left tab position during scroll.
+        boolean isRtl = DialerUtils.isRtl();
+        if (!isRtl && tabIndex == ListsFragment.TAB_INDEX_SPEED_DIAL && !mIsLandscape) {
+            mFloatingActionButtonController.onPageScrolled(positionOffset);
+        } else if (isRtl && tabIndex == ListsFragment.TAB_INDEX_RECENTS && !mIsLandscape) {
+            mFloatingActionButtonController.onPageScrolled(1 - positionOffset);
+        } else if (tabIndex != ListsFragment.TAB_INDEX_SPEED_DIAL) {
             mFloatingActionButtonController.onPageScrolled(1);
         }
+    }
 
-        if (position == ListsFragment.TAB_INDEX_ALL_CONTACTS) {
+    @Override
+    public void onPageSelected(int position) {
+        int tabIndex = mListsFragment.getCurrentTabIndex();
+        if (tabIndex == ListsFragment.TAB_INDEX_ALL_CONTACTS) {
             mFloatingActionButtonController.changeIcon(
                     getResources().getDrawable(R.drawable.ic_person_add_24dp),
                     getResources().getString(R.string.search_shortcut_create_new_contact));
@@ -1192,10 +1192,6 @@
     }
 
     @Override
-    public void onPageSelected(int position) {
-    }
-
-    @Override
     public void onPageScrollStateChanged(int state) {
     }
 
@@ -1239,7 +1235,7 @@
      */
     private void updateFloatingActionButtonControllerAlignment(boolean animate) {
         int align = (!mIsLandscape &&
-                mListsFragment.getTabPosition() == ListsFragment.TAB_INDEX_SPEED_DIAL) ?
+                mListsFragment.getCurrentTabIndex() == ListsFragment.TAB_INDEX_SPEED_DIAL) ?
                 FloatingActionButtonController.ALIGN_MIDDLE :
                         FloatingActionButtonController.ALIGN_END;
         mFloatingActionButtonController.align(align, 0 /* offsetX */, 0 /* offsetY */, animate);