Merge "Allow styling of fast scroll decorations, add default styles"
diff --git a/api/current.txt b/api/current.txt
index cc6801b..745b33d93 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -498,6 +498,7 @@
field public static final int fastScrollOverlayPosition = 16843578; // 0x101033a
field public static final int fastScrollPreviewBackgroundLeft = 16843575; // 0x1010337
field public static final int fastScrollPreviewBackgroundRight = 16843576; // 0x1010338
+ field public static final int fastScrollStyle = 16843763; // 0x10103f3
field public static final int fastScrollTextColor = 16843609; // 0x1010359
field public static final int fastScrollThumbDrawable = 16843574; // 0x1010336
field public static final int fastScrollTrackDrawable = 16843577; // 0x1010339
@@ -1865,6 +1866,7 @@
field public static final int Widget_DeviceDefault_DropDownItem_Spinner = 16974178; // 0x1030162
field public static final int Widget_DeviceDefault_EditText = 16974154; // 0x103014a
field public static final int Widget_DeviceDefault_ExpandableListView = 16974155; // 0x103014b
+ field public static final int Widget_DeviceDefault_FastScroll = 16974316; // 0x10301ec
field public static final int Widget_DeviceDefault_FragmentBreadCrumbs = 16974311; // 0x10301e7
field public static final int Widget_DeviceDefault_GridView = 16974156; // 0x103014c
field public static final int Widget_DeviceDefault_HorizontalScrollView = 16974171; // 0x103015b
@@ -1899,6 +1901,7 @@
field public static final int Widget_DeviceDefault_Light_DropDownItem_Spinner = 16974233; // 0x1030199
field public static final int Widget_DeviceDefault_Light_EditText = 16974206; // 0x103017e
field public static final int Widget_DeviceDefault_Light_ExpandableListView = 16974207; // 0x103017f
+ field public static final int Widget_DeviceDefault_Light_FastScroll = 16974317; // 0x10301ed
field public static final int Widget_DeviceDefault_Light_FragmentBreadCrumbs = 16974312; // 0x10301e8
field public static final int Widget_DeviceDefault_Light_GridView = 16974208; // 0x1030180
field public static final int Widget_DeviceDefault_Light_HorizontalScrollView = 16974226; // 0x1030192
@@ -1956,6 +1959,7 @@
field public static final int Widget_DropDownItem_Spinner = 16973868; // 0x103002c
field public static final int Widget_EditText = 16973859; // 0x1030023
field public static final int Widget_ExpandableListView = 16973860; // 0x1030024
+ field public static final int Widget_FastScroll = 16974313; // 0x10301e9
field public static final int Widget_FragmentBreadCrumbs = 16973961; // 0x1030089
field public static final int Widget_Gallery = 16973877; // 0x1030035
field public static final int Widget_GridView = 16973874; // 0x1030032
@@ -1987,6 +1991,7 @@
field public static final int Widget_Holo_DropDownItem_Spinner = 16973995; // 0x10300ab
field public static final int Widget_Holo_EditText = 16973971; // 0x1030093
field public static final int Widget_Holo_ExpandableListView = 16973972; // 0x1030094
+ field public static final int Widget_Holo_FastScroll = 16974314; // 0x10301ea
field public static final int Widget_Holo_FragmentBreadCrumbs = 16974309; // 0x10301e5
field public static final int Widget_Holo_GridView = 16973973; // 0x1030095
field public static final int Widget_Holo_HorizontalScrollView = 16973988; // 0x10300a4
@@ -2021,6 +2026,7 @@
field public static final int Widget_Holo_Light_DropDownItem_Spinner = 16974041; // 0x10300d9
field public static final int Widget_Holo_Light_EditText = 16974014; // 0x10300be
field public static final int Widget_Holo_Light_ExpandableListView = 16974015; // 0x10300bf
+ field public static final int Widget_Holo_Light_FastScroll = 16974315; // 0x10301eb
field public static final int Widget_Holo_Light_FragmentBreadCrumbs = 16974310; // 0x10301e6
field public static final int Widget_Holo_Light_GridView = 16974016; // 0x10300c0
field public static final int Widget_Holo_Light_HorizontalScrollView = 16974034; // 0x10300d2
@@ -31138,6 +31144,7 @@
method public void setDrawSelectorOnTop(boolean);
method public void setFastScrollAlwaysVisible(boolean);
method public void setFastScrollEnabled(boolean);
+ method public void setFastScrollStyle(int);
method public void setFilterText(java.lang.String);
method public void setFriction(float);
method public void setItemChecked(int, boolean);
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 2e0f9be..32e0da6 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -582,7 +582,13 @@
/**
* Helper object that renders and controls the fast scroll thumb.
*/
- private FastScroller mFastScroller;
+ private FastScroller mFastScroll;
+
+ /**
+ * Temporary holder for fast scroller style until a FastScroller object
+ * is created.
+ */
+ private int mFastScrollStyle;
private boolean mGlobalLayoutListenerAddedFilter;
@@ -814,6 +820,9 @@
boolean enableFastScroll = a.getBoolean(R.styleable.AbsListView_fastScrollEnabled, false);
setFastScrollEnabled(enableFastScroll);
+ int fastScrollStyle = a.getResourceId(R.styleable.AbsListView_fastScrollStyle, 0);
+ setFastScrollStyle(fastScrollStyle);
+
boolean smoothScrollbar = a.getBoolean(R.styleable.AbsListView_smoothScrollbar, true);
setSmoothScrollbarEnabled(smoothScrollbar);
@@ -1243,17 +1252,31 @@
}
private void setFastScrollerEnabledUiThread(boolean enabled) {
- if (mFastScroller != null) {
- mFastScroller.setEnabled(enabled);
+ if (mFastScroll != null) {
+ mFastScroll.setEnabled(enabled);
} else if (enabled) {
- mFastScroller = new FastScroller(this);
- mFastScroller.setEnabled(true);
+ mFastScroll = new FastScroller(this, mFastScrollStyle);
+ mFastScroll.setEnabled(true);
}
resolvePadding();
- if (mFastScroller != null) {
- mFastScroller.updateLayout();
+ if (mFastScroll != null) {
+ mFastScroll.updateLayout();
+ }
+ }
+
+ /**
+ * Specifies the style of the fast scroller decorations.
+ *
+ * @param styleResId style resource containing fast scroller properties
+ * @see android.R.styleable#FastScroll
+ */
+ public void setFastScrollStyle(int styleResId) {
+ if (mFastScroll == null) {
+ mFastScrollStyle = styleResId;
+ } else {
+ mFastScroll.setStyle(styleResId);
}
}
@@ -1293,8 +1316,8 @@
}
private void setFastScrollerAlwaysVisibleUiThread(boolean alwaysShow) {
- if (mFastScroller != null) {
- mFastScroller.setAlwaysShow(alwaysShow);
+ if (mFastScroll != null) {
+ mFastScroll.setAlwaysShow(alwaysShow);
}
}
@@ -1312,17 +1335,17 @@
* @see #setFastScrollAlwaysVisible(boolean)
*/
public boolean isFastScrollAlwaysVisible() {
- if (mFastScroller == null) {
+ if (mFastScroll == null) {
return mFastScrollEnabled && mFastScrollAlwaysVisible;
} else {
- return mFastScroller.isEnabled() && mFastScroller.isAlwaysShowEnabled();
+ return mFastScroll.isEnabled() && mFastScroll.isAlwaysShowEnabled();
}
}
@Override
public int getVerticalScrollbarWidth() {
- if (mFastScroller != null && mFastScroller.isEnabled()) {
- return Math.max(super.getVerticalScrollbarWidth(), mFastScroller.getWidth());
+ if (mFastScroll != null && mFastScroll.isEnabled()) {
+ return Math.max(super.getVerticalScrollbarWidth(), mFastScroll.getWidth());
}
return super.getVerticalScrollbarWidth();
}
@@ -1335,26 +1358,26 @@
*/
@ViewDebug.ExportedProperty
public boolean isFastScrollEnabled() {
- if (mFastScroller == null) {
+ if (mFastScroll == null) {
return mFastScrollEnabled;
} else {
- return mFastScroller.isEnabled();
+ return mFastScroll.isEnabled();
}
}
@Override
public void setVerticalScrollbarPosition(int position) {
super.setVerticalScrollbarPosition(position);
- if (mFastScroller != null) {
- mFastScroller.setScrollbarPosition(position);
+ if (mFastScroll != null) {
+ mFastScroll.setScrollbarPosition(position);
}
}
@Override
public void setScrollBarStyle(int style) {
super.setScrollBarStyle(style);
- if (mFastScroller != null) {
- mFastScroller.setScrollBarStyle(style);
+ if (mFastScroll != null) {
+ mFastScroll.setScrollBarStyle(style);
}
}
@@ -1415,8 +1438,8 @@
* Notify our scroll listener (if there is one) of a change in scroll state
*/
void invokeOnItemScrollListener() {
- if (mFastScroller != null) {
- mFastScroller.onScroll(mFirstPosition, getChildCount(), mItemCount);
+ if (mFastScroll != null) {
+ mFastScroll.onScroll(mFirstPosition, getChildCount(), mItemCount);
}
if (mOnScrollListener != null) {
mOnScrollListener.onScroll(this, mFirstPosition, getChildCount(), mItemCount);
@@ -2089,8 +2112,8 @@
mRecycler.markChildrenDirty();
}
- if (mFastScroller != null && (mItemCount != mOldItemCount || mDataChanged)) {
- mFastScroller.onItemCountChanged(mItemCount);
+ if (mFastScroll != null && (mItemCount != mOldItemCount || mDataChanged)) {
+ mFastScroll.onItemCountChanged(mItemCount);
}
layoutChildren();
@@ -2532,8 +2555,8 @@
rememberSyncState();
}
- if (mFastScroller != null) {
- mFastScroller.onSizeChanged(w, h, oldw, oldh);
+ if (mFastScroll != null) {
+ mFastScroll.onSizeChanged(w, h, oldw, oldh);
}
}
@@ -2862,8 +2885,8 @@
@Override
public void onRtlPropertiesChanged(int layoutDirection) {
super.onRtlPropertiesChanged(layoutDirection);
- if (mFastScroller != null) {
- mFastScroller.setScrollbarPosition(getVerticalScrollbarPosition());
+ if (mFastScroll != null) {
+ mFastScroll.setScrollbarPosition(getVerticalScrollbarPosition());
}
}
@@ -3436,8 +3459,8 @@
return false;
}
- if (mFastScroller != null) {
- boolean intercepted = mFastScroller.onTouchEvent(ev);
+ if (mFastScroll != null) {
+ boolean intercepted = mFastScroll.onTouchEvent(ev);
if (intercepted) {
return true;
}
@@ -3926,7 +3949,7 @@
@Override
public boolean onInterceptHoverEvent(MotionEvent event) {
- if (mFastScroller != null && mFastScroller.onInterceptHoverEvent(event)) {
+ if (mFastScroll != null && mFastScroll.onInterceptHoverEvent(event)) {
return true;
}
@@ -3950,7 +3973,7 @@
return false;
}
- if (mFastScroller != null && mFastScroller.onInterceptTouchEvent(ev)) {
+ if (mFastScroll != null && mFastScroll.onInterceptTouchEvent(ev)) {
return true;
}
@@ -6311,16 +6334,16 @@
@Override
public void onChanged() {
super.onChanged();
- if (mFastScroller != null) {
- mFastScroller.onSectionsChanged();
+ if (mFastScroll != null) {
+ mFastScroll.onSectionsChanged();
}
}
@Override
public void onInvalidated() {
super.onInvalidated();
- if (mFastScroller != null) {
- mFastScroller.onSectionsChanged();
+ if (mFastScroll != null) {
+ mFastScroll.onSectionsChanged();
}
}
}
diff --git a/core/java/android/widget/FastScroller.java b/core/java/android/widget/FastScroller.java
index 01ac8fd..6d38c8f 100644
--- a/core/java/android/widget/FastScroller.java
+++ b/core/java/android/widget/FastScroller.java
@@ -24,7 +24,6 @@
import android.animation.PropertyValuesHolder;
import android.content.Context;
import android.content.res.ColorStateList;
-import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
@@ -43,7 +42,7 @@
import android.view.ViewGroup.LayoutParams;
import android.view.ViewGroupOverlay;
import android.widget.AbsListView.OnScrollListener;
-import com.android.internal.R;
+import android.widget.ImageView.ScaleType;
/**
* Helper class for AbsListView to draw and control the Fast Scroll thumb
@@ -76,24 +75,6 @@
/** Scroll thumb and preview being dragged by user. */
private static final int STATE_DRAGGING = 2;
- /** Styleable attributes. */
- private static final int[] ATTRS = new int[] {
- android.R.attr.fastScrollTextColor,
- android.R.attr.fastScrollThumbDrawable,
- android.R.attr.fastScrollTrackDrawable,
- android.R.attr.fastScrollPreviewBackgroundLeft,
- android.R.attr.fastScrollPreviewBackgroundRight,
- android.R.attr.fastScrollOverlayPosition
- };
-
- // Styleable attribute indices.
- private static final int TEXT_COLOR = 0;
- private static final int THUMB_DRAWABLE = 1;
- private static final int TRACK_DRAWABLE = 2;
- private static final int PREVIEW_BACKGROUND_LEFT = 3;
- private static final int PREVIEW_BACKGROUND_RIGHT = 4;
- private static final int OVERLAY_POSITION = 5;
-
// Positions for preview image and text.
private static final int OVERLAY_FLOATING = 0;
private static final int OVERLAY_AT_THUMB = 1;
@@ -115,7 +96,7 @@
private final TextView mSecondaryText;
private final ImageView mThumbImage;
private final ImageView mTrackImage;
- private final ImageView mPreviewImage;
+ private final View mPreviewImage;
/**
* Preview image resource IDs for left- and right-aligned layouts. See
@@ -127,13 +108,25 @@
* Padding in pixels around the preview text. Applied as layout margins to
* the preview text and padding to the preview image.
*/
- private final int mPreviewPadding;
+ private int mPreviewPadding;
- /** Whether there is a track image to display. */
- private final boolean mHasTrackImage;
+ private int mPreviewMinWidth;
+ private int mPreviewMinHeight;
+ private int mThumbMinWidth;
+ private int mThumbMinHeight;
+
+ /** Theme-specified text size. Used only if text appearance is not set. */
+ private float mTextSize;
+
+ /** Theme-specified text color. Used only if text appearance is not set. */
+ private ColorStateList mTextColor;
+
+ private Drawable mThumbDrawable;
+ private Drawable mTrackDrawable;
+ private int mTextAppearance;
/** Total width of decorations. */
- private final int mWidth;
+ private int mWidth;
/** Set containing decoration transition animations. */
private AnimatorSet mDecorAnimation;
@@ -245,89 +238,143 @@
}
};
- public FastScroller(AbsListView listView) {
+ public FastScroller(AbsListView listView, int styleResId) {
mList = listView;
- mOverlay = listView.getOverlay();
final Context context = listView.getContext();
mScaledTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
+ mScrollBarStyle = listView.getScrollBarStyle();
- final Resources res = context.getResources();
- final TypedArray ta = context.getTheme().obtainStyledAttributes(ATTRS);
+ mScrollCompleted = true;
+ mState = STATE_VISIBLE;
+ mMatchDragPosition =
+ context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.HONEYCOMB;
- final ImageView trackImage = new ImageView(context);
- mTrackImage = trackImage;
+ mTrackImage = new ImageView(context);
+ mTrackImage.setScaleType(ScaleType.FIT_XY);
+ mThumbImage = new ImageView(context);
+ mThumbImage.setScaleType(ScaleType.FIT_XY);
+ mPreviewImage = new View(context);
+ mPreviewImage.setAlpha(0f);
+ mPrimaryText = createPreviewTextView(context);
+ mSecondaryText = createPreviewTextView(context);
+
+ setStyle(styleResId);
+
+ final ViewGroupOverlay overlay = listView.getOverlay();
+ mOverlay = overlay;
+ overlay.add(mTrackImage);
+ overlay.add(mThumbImage);
+ overlay.add(mPreviewImage);
+ overlay.add(mPrimaryText);
+ overlay.add(mSecondaryText);
+
+ getSectionsFromIndexer();
+ updateLongList(listView.getChildCount(), listView.getCount());
+ setScrollbarPosition(listView.getVerticalScrollbarPosition());
+ postAutoHide();
+ }
+
+ private void updateAppearance() {
+ final Context context = mList.getContext();
int width = 0;
// Add track to overlay if it has an image.
- final Drawable trackDrawable = ta.getDrawable(TRACK_DRAWABLE);
- if (trackDrawable != null) {
- mHasTrackImage = true;
- trackImage.setBackground(trackDrawable);
- mOverlay.add(trackImage);
- width = Math.max(width, trackDrawable.getIntrinsicWidth());
- } else {
- mHasTrackImage = false;
+ mTrackImage.setImageDrawable(mTrackDrawable);
+ if (mTrackDrawable != null) {
+ width = Math.max(width, mTrackDrawable.getIntrinsicWidth());
}
- final ImageView thumbImage = new ImageView(context);
- mThumbImage = thumbImage;
-
// Add thumb to overlay if it has an image.
- final Drawable thumbDrawable = ta.getDrawable(THUMB_DRAWABLE);
- if (thumbDrawable != null) {
- thumbImage.setImageDrawable(thumbDrawable);
- mOverlay.add(thumbImage);
- width = Math.max(width, thumbDrawable.getIntrinsicWidth());
+ mThumbImage.setImageDrawable(mThumbDrawable);
+ mThumbImage.setMinimumWidth(mThumbMinWidth);
+ mThumbImage.setMinimumHeight(mThumbMinHeight);
+ if (mThumbDrawable != null) {
+ width = Math.max(width, mThumbDrawable.getIntrinsicWidth());
}
- // If necessary, apply minimum thumb width and height.
- if (thumbDrawable.getIntrinsicWidth() <= 0 || thumbDrawable.getIntrinsicHeight() <= 0) {
- final int minWidth = res.getDimensionPixelSize(R.dimen.fastscroll_thumb_width);
- thumbImage.setMinimumWidth(minWidth);
- thumbImage.setMinimumHeight(
- res.getDimensionPixelSize(R.dimen.fastscroll_thumb_height));
- width = Math.max(width, minWidth);
+ // Account for minimum thumb width.
+ mWidth = Math.max(width, mThumbMinWidth);
+
+ mPreviewImage.setMinimumWidth(mPreviewMinWidth);
+ mPreviewImage.setMinimumHeight(mPreviewMinHeight);
+
+ if (mTextAppearance != 0) {
+ mPrimaryText.setTextAppearance(context, mTextAppearance);
+ mSecondaryText.setTextAppearance(context, mTextAppearance);
}
- mWidth = width;
+ if (mTextColor != null) {
+ mPrimaryText.setTextColor(mTextColor);
+ mSecondaryText.setTextColor(mTextColor);
+ }
- final int previewSize = res.getDimensionPixelSize(R.dimen.fastscroll_overlay_size);
- mPreviewImage = new ImageView(context);
- mPreviewImage.setMinimumWidth(previewSize);
- mPreviewImage.setMinimumHeight(previewSize);
- mPreviewImage.setAlpha(0f);
- mOverlay.add(mPreviewImage);
+ if (mTextSize > 0) {
+ mPrimaryText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
+ mSecondaryText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
+ }
- mPreviewPadding = res.getDimensionPixelSize(R.dimen.fastscroll_overlay_padding);
-
- final int textMinSize = Math.max(0, previewSize - mPreviewPadding);
- mPrimaryText = createPreviewTextView(context, ta);
+ final int textMinSize = Math.max(0, mPreviewMinHeight);
mPrimaryText.setMinimumWidth(textMinSize);
mPrimaryText.setMinimumHeight(textMinSize);
- mOverlay.add(mPrimaryText);
- mSecondaryText = createPreviewTextView(context, ta);
mSecondaryText.setMinimumWidth(textMinSize);
mSecondaryText.setMinimumHeight(textMinSize);
- mOverlay.add(mSecondaryText);
- mPreviewResId[PREVIEW_LEFT] = ta.getResourceId(PREVIEW_BACKGROUND_LEFT, 0);
- mPreviewResId[PREVIEW_RIGHT] = ta.getResourceId(PREVIEW_BACKGROUND_RIGHT, 0);
- mOverlayPosition = ta.getInt(OVERLAY_POSITION, OVERLAY_FLOATING);
- ta.recycle();
-
- mScrollBarStyle = listView.getScrollBarStyle();
- mScrollCompleted = true;
- mState = STATE_VISIBLE;
- mMatchDragPosition = context.getApplicationInfo().targetSdkVersion
- >= Build.VERSION_CODES.HONEYCOMB;
-
- getSectionsFromIndexer();
refreshDrawablePressedState();
- updateLongList(listView.getChildCount(), listView.getCount());
- setScrollbarPosition(mList.getVerticalScrollbarPosition());
- postAutoHide();
+ }
+
+ public void setStyle(int resId) {
+ final Context context = mList.getContext();
+ final TypedArray ta = context.obtainStyledAttributes(null,
+ com.android.internal.R.styleable.FastScroll, android.R.attr.fastScrollStyle, resId);
+ final int N = ta.getIndexCount();
+ for (int i = 0; i < N; i++) {
+ final int index = ta.getIndex(i);
+ switch (index) {
+ case com.android.internal.R.styleable.FastScroll_position:
+ mOverlayPosition = ta.getInt(index, OVERLAY_FLOATING);
+ break;
+ case com.android.internal.R.styleable.FastScroll_backgroundLeft:
+ mPreviewResId[PREVIEW_LEFT] = ta.getResourceId(index, 0);
+ break;
+ case com.android.internal.R.styleable.FastScroll_backgroundRight:
+ mPreviewResId[PREVIEW_RIGHT] = ta.getResourceId(index, 0);
+ break;
+ case com.android.internal.R.styleable.FastScroll_thumbDrawable:
+ mThumbDrawable = ta.getDrawable(index);
+ break;
+ case com.android.internal.R.styleable.FastScroll_trackDrawable:
+ mTrackDrawable = ta.getDrawable(index);
+ break;
+ case com.android.internal.R.styleable.FastScroll_textAppearance:
+ mTextAppearance = ta.getResourceId(index, 0);
+ break;
+ case com.android.internal.R.styleable.FastScroll_textColor:
+ mTextColor = ta.getColorStateList(index);
+ break;
+ case com.android.internal.R.styleable.FastScroll_textSize:
+ mTextSize = ta.getDimensionPixelSize(index, 0);
+ break;
+ case com.android.internal.R.styleable.FastScroll_minWidth:
+ mPreviewMinWidth = ta.getDimensionPixelSize(index, 0);
+ break;
+ case com.android.internal.R.styleable.FastScroll_minHeight:
+ mPreviewMinHeight = ta.getDimensionPixelSize(index, 0);
+ break;
+ case com.android.internal.R.styleable.FastScroll_thumbMinWidth:
+ mThumbMinWidth = ta.getDimensionPixelSize(index, 0);
+ break;
+ case com.android.internal.R.styleable.FastScroll_thumbMinHeight:
+ mThumbMinHeight = ta.getDimensionPixelSize(index, 0);
+ break;
+ case com.android.internal.R.styleable.FastScroll_padding:
+ mPreviewPadding = ta.getDimensionPixelSize(index, 0);
+ break;
+ }
+ }
+
+ updateAppearance();
}
/**
@@ -469,17 +516,11 @@
/**
* Creates a view into which preview text can be placed.
*/
- private TextView createPreviewTextView(Context context, TypedArray ta) {
+ private TextView createPreviewTextView(Context context) {
final LayoutParams params = new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
- final Resources res = context.getResources();
- final int minSize = res.getDimensionPixelSize(R.dimen.fastscroll_overlay_size);
- final ColorStateList textColor = ta.getColorStateList(TEXT_COLOR);
- final float textSize = res.getDimensionPixelSize(R.dimen.fastscroll_overlay_text_size);
final TextView textView = new TextView(context);
textView.setLayoutParams(params);
- textView.setTextColor(textColor);
- textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
textView.setSingleLine(true);
textView.setEllipsize(TruncateAt.MIDDLE);
textView.setGravity(Gravity.CENTER);
@@ -603,7 +644,7 @@
view.measure(widthMeasureSpec, heightMeasureSpec);
// Align to the left or right.
- final int width = view.getMeasuredWidth();
+ final int width = Math.min(adjMaxWidth, view.getMeasuredWidth());
final int left;
final int right;
if (mLayoutFromRight) {
@@ -1020,7 +1061,7 @@
}
final Rect bounds = mTempBounds;
- final ImageView preview = mPreviewImage;
+ final View preview = mPreviewImage;
final TextView showing;
final TextView target;
if (mShowingPrimary) {
@@ -1046,10 +1087,10 @@
hideShowing.addListener(mSwitchPrimaryListener);
// Apply preview image padding and animate bounds, if necessary.
- bounds.left -= mPreviewImage.getPaddingLeft();
- bounds.top -= mPreviewImage.getPaddingTop();
- bounds.right += mPreviewImage.getPaddingRight();
- bounds.bottom += mPreviewImage.getPaddingBottom();
+ bounds.left -= preview.getPaddingLeft();
+ bounds.top -= preview.getPaddingTop();
+ bounds.right += preview.getPaddingRight();
+ bounds.bottom += preview.getPaddingBottom();
final Animator resizePreview = animateBounds(preview, bounds);
resizePreview.setDuration(DURATION_RESIZE);
@@ -1097,8 +1138,8 @@
final int top = container.top;
final int bottom = container.bottom;
- final ImageView trackImage = mTrackImage;
- final ImageView thumbImage = mThumbImage;
+ final View trackImage = mTrackImage;
+ final View thumbImage = mThumbImage;
final float min = trackImage.getTop();
final float max = trackImage.getBottom();
final float offset = min;
@@ -1109,7 +1150,7 @@
final float previewPos = mOverlayPosition == OVERLAY_AT_THUMB ? thumbMiddle : 0;
// Center the preview on the thumb, constrained to the list bounds.
- final ImageView previewImage = mPreviewImage;
+ final View previewImage = mPreviewImage;
final float previewHalfHeight = previewImage.getHeight() / 2f;
final float minP = top + previewHalfHeight;
final float maxP = bottom - previewHalfHeight;
@@ -1122,11 +1163,7 @@
}
private float getPosFromMotionEvent(float y) {
- final Rect container = mContainerRect;
- final int top = container.top;
- final int bottom = container.bottom;
-
- final ImageView trackImage = mTrackImage;
+ final View trackImage = mTrackImage;
final float min = trackImage.getTop();
final float max = trackImage.getBottom();
final float offset = min;
@@ -1393,7 +1430,7 @@
* @return Whether the coordinate is inside the scroller's activation area.
*/
private boolean isPointInside(float x, float y) {
- return isPointInsideX(x) && (mHasTrackImage || isPointInsideY(y));
+ return isPointInsideX(x) && (mTrackDrawable != null || isPointInsideY(y));
}
private boolean isPointInsideX(float x) {
diff --git a/core/res/res/drawable-hdpi/scrollbar_handle_accelerated_anim2.9.png b/core/res/res/drawable-hdpi/scrollbar_handle_accelerated_anim2.9.png
index 6eddc3f..fb9e7aa 100644
--- a/core/res/res/drawable-hdpi/scrollbar_handle_accelerated_anim2.9.png
+++ b/core/res/res/drawable-hdpi/scrollbar_handle_accelerated_anim2.9.png
Binary files differ
diff --git a/core/res/res/drawable-ldpi/scrollbar_handle_accelerated_anim2.9.png b/core/res/res/drawable-ldpi/scrollbar_handle_accelerated_anim2.9.png
index 0562c03..a4ca3e0 100644
--- a/core/res/res/drawable-ldpi/scrollbar_handle_accelerated_anim2.9.png
+++ b/core/res/res/drawable-ldpi/scrollbar_handle_accelerated_anim2.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/scrollbar_handle_accelerated_anim2.9.png b/core/res/res/drawable-mdpi/scrollbar_handle_accelerated_anim2.9.png
index 766e4c0..6d83bb4 100644
--- a/core/res/res/drawable-mdpi/scrollbar_handle_accelerated_anim2.9.png
+++ b/core/res/res/drawable-mdpi/scrollbar_handle_accelerated_anim2.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/scrollbar_handle_accelerated_anim2.9.png b/core/res/res/drawable-xhdpi/scrollbar_handle_accelerated_anim2.9.png
index 3cf84a5..70856c0 100644
--- a/core/res/res/drawable-xhdpi/scrollbar_handle_accelerated_anim2.9.png
+++ b/core/res/res/drawable-xhdpi/scrollbar_handle_accelerated_anim2.9.png
Binary files differ
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 9dcefee..7254403 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -2739,6 +2739,8 @@
<!-- Enables the fast scroll thumb that can be dragged to quickly scroll through
the list. -->
<attr name="fastScrollEnabled" format="boolean" />
+ <!-- Specifies the style of the fast scroll decorations. -->
+ <attr name="fastScrollStyle" format="reference" />
<!-- When set to true, the list will use a more refined calculation
method based on the pixels height of the items visible on screen. This
property is set to true by default but should be set to false if your adapter
@@ -2807,6 +2809,36 @@
</declare-styleable>
<declare-styleable name="EditText">
</declare-styleable>
+ <declare-styleable name="FastScroll">
+ <!-- Drawable used for the scroll bar thumb. -->
+ <attr name="thumbDrawable" format="reference" />
+ <!-- Minimum width of the thumb. -->
+ <attr name="thumbMinWidth" format="dimension" />
+ <!-- Minimum height of the thumb. -->
+ <attr name="thumbMinHeight" format="dimension" />
+ <!-- Drawable used for the scroll bar track. -->
+ <attr name="trackDrawable" format="reference" />
+ <!-- Drawable used for the section header preview when right-aligned. -->
+ <attr name="backgroundRight" format="reference" />
+ <!-- Drawable used for the section header preview when left-aligned. -->
+ <attr name="backgroundLeft" format="reference" />
+ <!-- Position of section header preview. -->
+ <attr name="position">
+ <!-- Floating at the top of the content. -->
+ <enum name="floating" value="0" />
+ <!-- Pinned alongside the thumb. -->
+ <enum name="atThumb" value="1" />
+ </attr>
+ <attr name="textAppearance" />
+ <attr name="textColor" />
+ <attr name="textSize" />
+ <!-- Minimum width of the section header preview. -->
+ <attr name="minWidth" />
+ <!-- Minimum height of the section header preview. -->
+ <attr name="minHeight" />
+ <!-- Padding for the section header preview. -->
+ <attr name="padding" />
+ </declare-styleable>
<declare-styleable name="FrameLayout">
<!-- Defines the drawable to draw over the content. This can be used as an overlay.
The foreground drawable participates in the padding of the content if the gravity
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index db5d01f..c6d2947 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -50,16 +50,6 @@
<!-- Margin at the edge of the screen to ignore touch events for in the windowshade. -->
<dimen name="status_bar_edge_ignore">5dp</dimen>
- <!-- 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">52sp</dimen>
- <!-- Padding of the fastscroll overlay -->
- <dimen name="fastscroll_overlay_padding">16dp</dimen>
- <!-- Width of the fastscroll thumb -->
- <dimen name="fastscroll_thumb_width">64dp</dimen>
- <!-- Height of the fastscroll thumb -->
- <dimen name="fastscroll_thumb_height">52dp</dimen>
<!-- Min width for a tablet device -->
<dimen name="min_xlarge_screen_width">800dp</dimen>
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index dc111f5..dcaf6b3 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -2093,10 +2093,16 @@
<eat-comment />
<public type="attr" name="fragmentBreadCrumbsStyle" />
+ <public type="attr" name="fastScrollStyle" />
<public type="style" name="Widget.Holo.FragmentBreadCrumbs" />
<public type="style" name="Widget.Holo.Light.FragmentBreadCrumbs" />
<public type="style" name="Widget.DeviceDefault.FragmentBreadCrumbs" />
<public type="style" name="Widget.DeviceDefault.Light.FragmentBreadCrumbs" />
+ <public type="style" name="Widget.FastScroll" />
+ <public type="style" name="Widget.Holo.FastScroll" />
+ <public type="style" name="Widget.Holo.Light.FastScroll" />
+ <public type="style" name="Widget.DeviceDefault.FastScroll" />
+ <public type="style" name="Widget.DeviceDefault.Light.FastScroll" />
</resources>
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index 177ab51..b1a86f8c 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -292,6 +292,7 @@
<style name="Widget.AbsListView">
<item name="android:scrollbars">vertical</item>
<item name="android:fadingEdge">vertical</item>
+ <item name="android:fastScrollStyle">?android:attr/fastScrollStyle</item>
</style>
<style name="Widget.GestureOverlayView">
@@ -2589,4 +2590,27 @@
<item name="android:textStyle">bold</item>
</style>
+ <style name="Widget.FastScroll">
+ <item name="android:thumbDrawable">?android:attr/fastScrollThumbDrawable</item>
+ <item name="android:trackDrawable">?android:attr/fastScrollTrackDrawable</item>
+ <item name="android:backgroundLeft">?android:attr/fastScrollPreviewBackgroundLeft</item>
+ <item name="android:backgroundRight">?android:attr/fastScrollPreviewBackgroundRight</item>
+ <item name="android:position">?android:attr/fastScrollOverlayPosition</item>
+ <item name="android:textColor">?android:attr/fastScrollTextColor</item>
+ <item name="android:thumbMinWidth">64dp</item>
+ <item name="android:thumbMinHeight">52dp</item>
+ <item name="android:textSize">52sp</item>
+ <item name="android:minWidth">72dp</item>
+ <item name="android:minHeight">72dp</item>
+ <item name="android:padding">16dp</item>
+ </style>
+
+ <style name="Widget.Holo.FastScroll" parent="Widget.FastScroll">
+ <item name="android:thumbMinWidth">0dp</item>
+ <item name="android:thumbMinHeight">0dp</item>
+ </style>
+
+ <style name="Widget.Holo.Light.FastScroll" parent="Widget.Holo.FastScroll">
+ </style>
+
</resources>
diff --git a/core/res/res/values/styles_device_defaults.xml b/core/res/res/values/styles_device_defaults.xml
index eca639f..512c9b8 100644
--- a/core/res/res/values/styles_device_defaults.xml
+++ b/core/res/res/values/styles_device_defaults.xml
@@ -206,6 +206,9 @@
<style name="Widget.DeviceDefault.ExpandableListView.White" parent="Widget.Holo.ExpandableListView.White">
</style>
+ <style name="Widget.DeviceDefault.FastScroll" parent="Widget.Holo.FastScroll">
+
+ </style>
<style name="Widget.DeviceDefault.FragmentBreadCrumbs" parent="Widget.Holo.FragmentBreadCrumbs">
</style>
@@ -312,6 +315,9 @@
<style name="Widget.DeviceDefault.Light.ExpandableListView" parent="Widget.Holo.Light.ExpandableListView" >
</style>
+ <style name="Widget.DeviceDefault.Light.FastScroll" parent="Widget.Holo.Light.FastScroll">
+
+ </style>
<style name="Widget.DeviceDefault.Light.FragmentBreadCrumbs" parent="Widget.Holo.Light.FragmentBreadCrumbs">
</style>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 3c3feca..26a56a5 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -332,11 +332,6 @@
<java-symbol type="dimen" name="default_gap" />
<java-symbol type="dimen" name="dropdownitem_icon_width" />
<java-symbol type="dimen" name="dropdownitem_text_padding_left" />
- <java-symbol type="dimen" name="fastscroll_overlay_size" />
- <java-symbol type="dimen" name="fastscroll_overlay_text_size" />
- <java-symbol type="dimen" name="fastscroll_overlay_padding" />
- <java-symbol type="dimen" name="fastscroll_thumb_height" />
- <java-symbol type="dimen" name="fastscroll_thumb_width" />
<java-symbol type="dimen" name="password_keyboard_spacebar_vertical_correction" />
<java-symbol type="dimen" name="search_view_preferred_width" />
<java-symbol type="dimen" name="textview_error_popup_default_width" />
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index bbd4864..b79f916c 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -249,6 +249,7 @@
<item name="editTextStyle">@android:style/Widget.EditText</item>
<item name="expandableListViewStyle">@android:style/Widget.ExpandableListView</item>
<item name="expandableListViewWhiteStyle">@android:style/Widget.ExpandableListView.White</item>
+ <item name="fastScrollStyle">@android:style/Widget.FastScroll</item>
<item name="galleryStyle">@android:style/Widget.Gallery</item>
<item name="gestureOverlayViewStyle">@android:style/Widget.GestureOverlayView</item>
<item name="gridViewStyle">@android:style/Widget.GridView</item>
@@ -403,7 +404,6 @@
<item name="fastScrollPreviewBackgroundLeft">@android:drawable/menu_submenu_background</item>
<item name="fastScrollOverlayPosition">floating</item>
<item name="fastScrollTextColor">@android:color/primary_text_dark</item>
-
<!-- Pointer style -->
<item name="pointerStyle">@android:style/Pointer</item>
@@ -1108,6 +1108,7 @@
<item name="editTextStyle">@android:style/Widget.Holo.EditText</item>
<item name="expandableListViewStyle">@android:style/Widget.Holo.ExpandableListView</item>
<item name="expandableListViewWhiteStyle">@android:style/Widget.Holo.ExpandableListView.White</item>
+ <item name="fastScrollStyle">@android:style/Widget.Holo.FastScroll</item>
<item name="galleryStyle">@android:style/Widget.Holo.Gallery</item>
<item name="gestureOverlayViewStyle">@android:style/Widget.Holo.GestureOverlayView</item>
<item name="gridViewStyle">@android:style/Widget.Holo.GridView</item>
@@ -1436,6 +1437,7 @@
<item name="editTextStyle">@android:style/Widget.Holo.Light.EditText</item>
<item name="expandableListViewStyle">@android:style/Widget.Holo.Light.ExpandableListView</item>
<item name="expandableListViewWhiteStyle">@android:style/Widget.Holo.Light.ExpandableListView.White</item>
+ <item name="fastScrollStyle">@android:style/Widget.Holo.Light.FastScroll</item>
<item name="galleryStyle">@android:style/Widget.Holo.Light.Gallery</item>
<item name="gestureOverlayViewStyle">@android:style/Widget.Holo.Light.GestureOverlayView</item>
<item name="gridViewStyle">@android:style/Widget.Holo.Light.GridView</item>