diff options
| -rw-r--r-- | core/java/android/widget/FastScroller.java | 31 | ||||
| -rw-r--r-- | core/res/res/values/dimens.xml | 2 |
2 files changed, 28 insertions, 5 deletions
diff --git a/core/java/android/widget/FastScroller.java b/core/java/android/widget/FastScroller.java index 4614c53eb9b2..01ac8fdba6d0 100644 --- a/core/java/android/widget/FastScroller.java +++ b/core/java/android/widget/FastScroller.java @@ -29,6 +29,7 @@ import android.content.res.TypedArray; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Build; +import android.text.TextUtils; import android.text.TextUtils.TruncateAt; import android.util.IntProperty; import android.util.MathUtils; @@ -176,6 +177,9 @@ class FastScroller { */ private int mState; + /** Whether the preview image is visible. */ + private boolean mShowingPreview; + private BaseAdapter mListAdapter; private SectionIndexer mSectionIndexer; @@ -769,6 +773,8 @@ class FastScroller { mDecorAnimation = new AnimatorSet(); mDecorAnimation.playTogether(fadeOut, slideOut); mDecorAnimation.start(); + + mShowingPreview = false; } /** @@ -790,6 +796,8 @@ class FastScroller { mDecorAnimation = new AnimatorSet(); mDecorAnimation.playTogether(fadeIn, fadeOut, slideIn); mDecorAnimation.start(); + + mShowingPreview = false; } /** @@ -809,6 +817,8 @@ class FastScroller { mDecorAnimation = new AnimatorSet(); mDecorAnimation.playTogether(fadeIn, slideIn); mDecorAnimation.start(); + + mShowingPreview = true; } private void postAutoHide() { @@ -982,9 +992,10 @@ class FastScroller { if (mCurrentSection != sectionIndex) { mCurrentSection = sectionIndex; - if (transitionPreviewLayout(sectionIndex)) { + final boolean hasPreview = transitionPreviewLayout(sectionIndex); + if (!mShowingPreview && hasPreview) { transitionToDragging(); - } else { + } else if (mShowingPreview && !hasPreview) { transitionToVisible(); } } @@ -1072,7 +1083,7 @@ class FastScroller { mPreviewAnimation.start(); - return (text != null && text.length() > 0); + return !TextUtils.isEmpty(text); } /** @@ -1184,7 +1195,19 @@ class FastScroller { / positionsInSection; } - return (section + posWithinSection) / sectionCount; + float result = (section + posWithinSection) / sectionCount; + + // Fake out the scroll bar for the last item. Since the section indexer + // won't ever actually move the list in this end space, make scrolling + // across the last item account for whatever space is remaining. + if (firstVisibleItem > 0 && firstVisibleItem + visibleItemCount == totalItemCount) { + final View lastChild = mList.getChildAt(visibleItemCount - 1); + final float lastItemVisible = (float) (mList.getHeight() - mList.getPaddingBottom() + - lastChild.getTop()) / lastChild.getHeight(); + result += (1 - result) * lastItemVisible; + } + + return result; } /** diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index aad62520e309..f96195c8cd8d 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -53,7 +53,7 @@ <!-- Minimum size of the fastscroll overlay --> <dimen name="fastscroll_overlay_size">104dp</dimen> <!-- Text size of the fastscroll overlay --> - <dimen name="fastscroll_overlay_text_size">24sp</dimen> + <dimen name="fastscroll_overlay_text_size">52sp</dimen> <!-- Padding of the fastscroll overlay --> <dimen name="fastscroll_overlay_padding">16dp</dimen> <!-- Width of the fastscroll thumb --> |