Merge "Remove unused resources"
diff --git a/src/com/android/contacts/activities/DialtactsActivity.java b/src/com/android/contacts/activities/DialtactsActivity.java
index a9bb394..8d57288 100644
--- a/src/com/android/contacts/activities/DialtactsActivity.java
+++ b/src/com/android/contacts/activities/DialtactsActivity.java
@@ -172,7 +172,7 @@
 
         @Override
         public void onPageSelected(int position) {
-            if (DEBUG) Log.d(TAG, "onPageSelected: " + position);
+            if (DEBUG) Log.d(TAG, "onPageSelected: position: " + position);
             final ActionBar actionBar = getActionBar();
             if (mDialpadFragment != null && !mDuringSwipe) {
                 if (DEBUG) {
@@ -233,7 +233,23 @@
         public void onPageScrollStateChanged(int state) {
             switch (state) {
                 case ViewPager.SCROLL_STATE_IDLE: {
-                    if (DEBUG) Log.d(TAG, "onPageScrollStateChanged() with SCROLL_STATE_IDLE");
+                    if (mNextPosition == -1) {
+                        // This happens when the user drags the screen just after launching the
+                        // application, and settle down the same screen without actually swiping it.
+                        // At that moment mNextPosition is apparently -1 yet, and we expect it
+                        // being updated by onPageSelected(), which is *not* called if the user
+                        // settle down the exact same tab after the dragging.
+                        if (DEBUG) {
+                            Log.d(TAG, "Next position is not specified correctly. Use current tab ("
+                                    + mViewPager.getCurrentItem() + ")");
+                        }
+                        mNextPosition = mViewPager.getCurrentItem();
+                    }
+                    if (DEBUG) {
+                        Log.d(TAG, "onPageScrollStateChanged() with SCROLL_STATE_IDLE. "
+                                + "mCurrentPosition: " + mCurrentPosition
+                                + ", mNextPosition: " + mNextPosition);
+                    }
                     // Interpret IDLE as the end of migration (both swipe and tab click)
                     mDuringSwipe = false;
                     mUserTabClick = false;
@@ -246,6 +262,13 @@
                     } else if (mCurrentPosition == TAB_INDEX_FAVORITES
                             && mNextPosition == TAB_INDEX_CALL_LOG) {
                         sendFragmentVisibilityChange(mNextPosition, true /* visible */ );
+                    } else if (mCurrentPosition == TAB_INDEX_DIALER
+                            && mNextPosition == TAB_INDEX_DIALER) {
+                        // Dragged the dialer screen, but remained in the dialer screen.
+                        // During user's dragging the dialer, we show the ActonBar, so we need to
+                        // explicitly reset it in this exact case.
+                        sendFragmentVisibilityChange(TAB_INDEX_DIALER, true);
+                        sendFragmentVisibilityChange(TAB_INDEX_CALL_LOG, false);
                     } else {
                         sendFragmentVisibilityChange(mCurrentPosition, false /* not visible */ );
                         sendFragmentVisibilityChange(mNextPosition, true /* visible */ );
@@ -1097,6 +1120,10 @@
     }
 
     private void sendFragmentVisibilityChange(int position, boolean visibility) {
+        if (DEBUG) {
+            Log.d(TAG, "sendFragmentVisibiltyChange(). position: " + position
+                    + ", visibility: " + visibility);
+        }
         // Position can be -1 initially. See PageChangeListener.
         if (position >= 0) {
             final Fragment fragment = getFragmentAt(position);