Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8636ace6 authored by Alan Viverette's avatar Alan Viverette
Browse files

Allow styling of fast scroll decorations, add default styles

Also fixes bad old-style thumb 9-patches.

BUG: 11030706
Change-Id: I51abba952acf87586449fbda329212b435d1d6df
parent 0160bcbe
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -498,6 +498,7 @@ package android {
    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 @@ package android {
    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 @@ package android {
    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 @@ package android {
    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 @@ package android {
    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 @@ package android {
    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 @@ package android.widget {
    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);
+58 −35
Original line number Diff line number Diff line
@@ -581,7 +581,13 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
    /**
     * 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;

@@ -813,6 +819,9 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
        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);

@@ -1242,17 +1251,31 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
    }

    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);
        }
    }

@@ -1292,8 +1315,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
    }

    private void setFastScrollerAlwaysVisibleUiThread(boolean alwaysShow) {
        if (mFastScroller != null) {
            mFastScroller.setAlwaysShow(alwaysShow);
        if (mFastScroll != null) {
            mFastScroll.setAlwaysShow(alwaysShow);
        }
    }

@@ -1311,17 +1334,17 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
     * @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();
    }
@@ -1334,26 +1357,26 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
     */
    @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);
        }
    }

@@ -1414,8 +1437,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
     * 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);
@@ -2088,8 +2111,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
            mRecycler.markChildrenDirty();
        }

        if (mFastScroller != null && (mItemCount != mOldItemCount || mDataChanged)) {
            mFastScroller.onItemCountChanged(mItemCount);
        if (mFastScroll != null && (mItemCount != mOldItemCount || mDataChanged)) {
            mFastScroll.onItemCountChanged(mItemCount);
        }

        layoutChildren();
@@ -2503,8 +2526,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
            rememberSyncState();
        }

        if (mFastScroller != null) {
            mFastScroller.onSizeChanged(w, h, oldw, oldh);
        if (mFastScroll != null) {
            mFastScroll.onSizeChanged(w, h, oldw, oldh);
        }
    }

@@ -2833,8 +2856,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
    @Override
    public void onRtlPropertiesChanged(int layoutDirection) {
        super.onRtlPropertiesChanged(layoutDirection);
        if (mFastScroller != null) {
           mFastScroller.setScrollbarPosition(getVerticalScrollbarPosition());
        if (mFastScroll != null) {
           mFastScroll.setScrollbarPosition(getVerticalScrollbarPosition());
        }
    }

@@ -3407,8 +3430,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
            return false;
        }

        if (mFastScroller != null) {
            boolean intercepted = mFastScroller.onTouchEvent(ev);
        if (mFastScroll != null) {
            boolean intercepted = mFastScroll.onTouchEvent(ev);
            if (intercepted) {
                return true;
            }
@@ -3897,7 +3920,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te

    @Override
    public boolean onInterceptHoverEvent(MotionEvent event) {
        if (mFastScroller != null && mFastScroller.onInterceptHoverEvent(event)) {
        if (mFastScroll != null && mFastScroll.onInterceptHoverEvent(event)) {
            return true;
        }

@@ -3921,7 +3944,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
            return false;
        }

        if (mFastScroller != null && mFastScroller.onInterceptTouchEvent(ev)) {
        if (mFastScroll != null && mFastScroll.onInterceptTouchEvent(ev)) {
            return true;
        }

@@ -6282,16 +6305,16 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
        @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();
            }
        }
    }
+141 −104

File changed.

Preview size limit exceeded, changes collapsed.

+146 B (2.02 KiB)
Loading image diff...
+122 B (1.14 KiB)
Loading image diff...
Loading