Merge "Fix a bug where the fast scroll track would be positioned incorrectly."
diff --git a/api/current.xml b/api/current.xml
index fb6b950..e76bd65 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -4211,6 +4211,50 @@
visibility="public"
>
</field>
+<field name="fastScrollOverlayPosition"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843592"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="fastScrollPreviewBackgroundLeft"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843590"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="fastScrollThumbDrawable"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843589"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="fastScrollTrackDrawable"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843591"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
<field name="fillAfter"
type="int"
transient="false"
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 30dd17b..87e4b5a 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -1779,6 +1779,10 @@
}
mRecycler.markChildrenDirty();
}
+
+ if (mFastScroller != null && mItemCount != mOldItemCount) {
+ mFastScroller.onItemCountChanged(mOldItemCount, mItemCount);
+ }
layoutChildren();
mInLayout = false;
diff --git a/core/java/android/widget/FastScroller.java b/core/java/android/widget/FastScroller.java
index f824ff4..4e3ef0c 100644
--- a/core/java/android/widget/FastScroller.java
+++ b/core/java/android/widget/FastScroller.java
@@ -307,10 +307,13 @@
}
if (mTrackDrawable != null) {
- final int left = mThumbDrawable.getBounds().left;
+ final Rect thumbBounds = mThumbDrawable.getBounds();
+ final int left = thumbBounds.left;
+ final int halfThumbHeight = (thumbBounds.bottom - thumbBounds.top) / 2;
final int trackWidth = mTrackDrawable.getIntrinsicWidth();
- final int trackLeft = (left + mThumbW) / 2 - trackWidth / 2;
- mTrackDrawable.setBounds(trackLeft, 0, trackLeft + trackWidth, mList.getHeight());
+ final int trackLeft = (left + mThumbW / 2) - trackWidth / 2;
+ mTrackDrawable.setBounds(trackLeft, halfThumbHeight,
+ trackLeft + trackWidth, mList.getHeight() - halfThumbHeight);
mTrackDrawable.draw(canvas);
}
@@ -393,13 +396,19 @@
}
}
}
-
+
+ void onItemCountChanged(int oldCount, int newCount) {
+ if (mAlwaysShow) {
+ mLongList = true;
+ }
+ }
+
void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
int totalItemCount) {
// Are there enough pages to require fast scroll? Recompute only if total count changes
if (mItemCount != totalItemCount && visibleItemCount > 0) {
mItemCount = totalItemCount;
- mLongList = mItemCount / visibleItemCount >= MIN_PAGES;
+ mLongList = mAlwaysShow || mItemCount / visibleItemCount >= MIN_PAGES;
}
if (!mLongList) {
if (mState != STATE_NONE) {
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index f399578..181bbcc 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -520,15 +520,20 @@
<attr name="dayPickerWeekDayViewStyle" format="reference" />
<!-- Fast scroller styles -->
- <!-- @hide -->
+ <eat-comment />
+
+ <!-- Drawable to use as the fast scroll thumb. -->
<attr name="fastScrollThumbDrawable" format="reference" />
- <!-- @hide -->
+ <!-- Drawable to use as the fast scroll index preview window background
+ when shown on the right. -->
<attr name="fastScrollPreviewBackgroundRight" format="reference" />
- <!-- @hide -->
+ <!-- Drawable to use as the fast scroll index preview window background
+ when shown on the left. -->
<attr name="fastScrollPreviewBackgroundLeft" format="reference" />
- <!-- @hide -->
+ <!-- Drawable to use as the track for the fast scroll thumb.
+ This may be null. -->
<attr name="fastScrollTrackDrawable" format="reference" />
- <!-- @hide -->
+ <!-- Position of the fast scroll index overlay window. -->
<attr name="fastScrollOverlayPosition">
<enum name="floating" value="0" />
<enum name="atThumb" value="1" />
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 1f9cb6d..6c76f57 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1403,6 +1403,10 @@
<public type="attr" name="isAlwaysSyncable" />
<public type="attr" name="verticalScrollbarPosition" />
<public type="attr" name="fastScrollAlwaysVisible" />
+ <public type="attr" name="fastScrollThumbDrawable" />
+ <public type="attr" name="fastScrollPreviewBackgroundLeft" />
+ <public type="attr" name="fastScrollTrackDrawable" />
+ <public type="attr" name="fastScrollOverlayPosition" />
<public type="anim" name="animator_fade_in" />
<public type="anim" name="animator_fade_out" />