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

Commit d1ca75bf authored by Alan Viverette's avatar Alan Viverette
Browse files

Quantum ripple for ListView selector

Also fixes row clipping and ripple alpha channel. Only supports showing
ripple on a single list row -- multiple rows for focus traversal and
drag-to-open are coming soon.

BUG: 13212804
BUG: 14257108
Change-Id: Ided15611dc868a513e8d2a994723cdf57b0d206c
parent e77bb36d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -12761,6 +12761,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        mPrivateFlags &= ~PFLAG_CANCEL_NEXT_UP_EVENT;
        mPrivateFlags3 &= ~PFLAG3_IS_LAID_OUT;
        if (mBackground != null) {
            mBackground.clearHotspots();
        }
        removeUnsetPressCallback();
        removeLongPressCallback();
        removePerformClickCallback();
+19 −3
Original line number Diff line number Diff line
@@ -543,7 +543,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
    /**
     * The last CheckForTap runnable we posted, if any
     */
    private Runnable mPendingCheckForTap;
    private CheckForTap mPendingCheckForTap;

    /**
     * The last CheckForKeyLongPress runnable we posted, if any
@@ -2126,7 +2126,9 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        super.onLayout(changed, l, t, r, b);

        mInLayout = true;

        final int childCount = getChildCount();
        if (changed) {
            for (int i = 0; i < childCount; i++) {
@@ -3185,7 +3187,10 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
        return INVALID_ROW_ID;
    }

    final class CheckForTap implements Runnable {
    private final class CheckForTap implements Runnable {
        float x;
        float y;

        @Override
        public void run() {
            if (mTouchMode == TOUCH_MODE_DOWN) {
@@ -3205,7 +3210,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
                        final boolean longClickable = isLongClickable();

                        if (mSelector != null) {
                            Drawable d = mSelector.getCurrent();
                            final Drawable d = mSelector.getCurrent();
                            if (d != null && d instanceof TransitionDrawable) {
                                if (longClickable) {
                                    ((TransitionDrawable) d).startTransition(longPressTimeout);
@@ -3213,6 +3218,9 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
                                    ((TransitionDrawable) d).resetTransition();
                                }
                            }
                            if (d.supportsHotspots()) {
                                d.setHotspot(R.attr.state_pressed, x, y);
                            }
                        }

                        if (longClickable) {
@@ -3596,6 +3604,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
                        mPendingCheckForTap = new CheckForTap();
                    }

                    mPendingCheckForTap.x = ev.getX();
                    mPendingCheckForTap.y = ev.getY();
                    postDelayed(mPendingCheckForTap, ViewConfiguration.getTapTimeout());
                }
            }
@@ -3705,6 +3715,9 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
                                if (d != null && d instanceof TransitionDrawable) {
                                    ((TransitionDrawable) d).resetTransition();
                                }
                                if (mSelector.supportsHotspots()) {
                                    mSelector.setHotspot(R.attr.state_pressed, x, ev.getY());
                                }
                            }
                            if (mTouchModeReset != null) {
                                removeCallbacks(mTouchModeReset);
@@ -3716,6 +3729,9 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
                                    mTouchMode = TOUCH_MODE_REST;
                                    child.setPressed(false);
                                    setPressed(false);
                                    if (mSelector != null && mSelector.supportsHotspots()) {
                                        mSelector.removeHotspot(R.attr.state_pressed);
                                    }
                                    if (!mDataChanged && !mIsDetaching && isAttachedToWindow()) {
                                        performClick.run();
                                    }
+22 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<touch-feedback xmlns:android="http://schemas.android.com/apk/res/android"
    android:tint="?attr/colorButtonPressed">
    <item android:id="@id/mask">
        <color android:color="@color/white" />
    </item>
</touch-feedback>
+6 −5
Original line number Diff line number Diff line
@@ -21,7 +21,8 @@
    android:gravity="center_vertical"
    android:paddingStart="16dip"
    android:paddingEnd="12dip"
    android:minHeight="?android:attr/listPreferredItemHeightSmall">
    android:minHeight="?attr/listPreferredItemHeightSmall"
    android:background="@color/transparent">

    <LinearLayout
        android:layout_width="wrap_content"
@@ -33,8 +34,8 @@
        <TextView android:id="@android:id/text1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceListItem"
            android:textColor="?android:attr/textColorAlertDialogListItem"
            android:textAppearance="?attr/textAppearanceListItem"
            android:textColor="?attr/textColorAlertDialogListItem"
            android:gravity="center_vertical|start"
            android:singleLine="true"
            android:ellipsize="marquee" />
@@ -42,8 +43,8 @@
        <TextView android:id="@android:id/text2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceListItemSecondary"
            android:textColor="?android:attr/textColorAlertDialogListItem"
            android:textAppearance="?attr/textAppearanceListItemSecondary"
            android:textColor="?attr/textColorAlertDialogListItem"
            android:gravity="center_vertical|start"
            android:singleLine="true"
            android:ellipsize="marquee" />
+6 −6
Original line number Diff line number Diff line
@@ -480,7 +480,7 @@ please see styles_device_defaults.xml.
    <style name="Widget.Quantum.AbsListView" parent="Widget.AbsListView"/>

    <style name="Widget.Quantum.AutoCompleteTextView" parent="Widget.AutoCompleteTextView">
        <item name="dropDownSelector">@drawable/list_selector_holo_dark</item>
        <item name="dropDownSelector">@drawable/list_selector_quantum</item>
        <item name="popupBackground">?attr/colorBackground</item>
    </style>

@@ -654,7 +654,7 @@ please see styles_device_defaults.xml.

    <style name="Widget.Quantum.Spinner" parent="Widget.Spinner.DropDown">
        <item name="background">@drawable/spinner_background_quantum</item>
        <item name="dropDownSelector">@drawable/list_selector_holo_dark</item>
        <item name="dropDownSelector">@drawable/list_selector_quantum</item>
        <item name="popupBackground">?attr/colorBackground</item>
        <item name="dropDownVerticalOffset">0dip</item>
        <item name="dropDownHorizontalOffset">0dip</item>
@@ -713,7 +713,7 @@ please see styles_device_defaults.xml.
    <style name="Widget.Quantum.QuickContactBadgeSmall.WindowLarge" parent="Widget.QuickContactBadgeSmall.WindowLarge"/>

    <style name="Widget.Quantum.ListPopupWindow" parent="Widget.ListPopupWindow">
        <item name="dropDownSelector">@drawable/list_selector_holo_dark</item>
        <item name="dropDownSelector">@drawable/list_selector_quantum</item>
        <item name="popupBackground">?attr/colorBackground</item>
        <item name="dropDownVerticalOffset">0dip</item>
        <item name="dropDownHorizontalOffset">0dip</item>
@@ -851,7 +851,7 @@ please see styles_device_defaults.xml.
    <style name="Widget.Quantum.Light.AbsListView" parent="Widget.Quantum.AbsListView"/>

    <style name="Widget.Quantum.Light.AutoCompleteTextView" parent="Widget.AutoCompleteTextView">
        <item name="dropDownSelector">@drawable/list_selector_holo_light</item>
        <item name="dropDownSelector">@drawable/list_selector_quantum</item>
        <item name="popupBackground">?attr/colorBackground</item>
    </style>

@@ -938,7 +938,7 @@ please see styles_device_defaults.xml.

    <style name="Widget.Quantum.Light.Spinner" parent="Widget.Quantum.Spinner">
        <item name="background">@drawable/spinner_background_quantum</item>
        <item name="dropDownSelector">@drawable/list_selector_holo_light</item>
        <item name="dropDownSelector">@drawable/list_selector_quantum</item>
        <item name="popupBackground">?attr/colorBackground</item>
        <item name="dropDownVerticalOffset">0dip</item>
        <item name="dropDownHorizontalOffset">0dip</item>
@@ -962,7 +962,7 @@ please see styles_device_defaults.xml.
    <style name="Widget.Quantum.Light.QuickContactBadgeSmall.WindowLarge" parent="Widget.Quantum.QuickContactBadgeSmall.WindowLarge"/>

    <style name="Widget.Quantum.Light.ListPopupWindow" parent="Widget.ListPopupWindow">
        <item name="dropDownSelector">@drawable/list_selector_holo_light</item>
        <item name="dropDownSelector">@drawable/list_selector_quantum</item>
        <item name="popupBackground">?attr/colorBackground</item>
        <item name="dropDownVerticalOffset">0dip</item>
        <item name="dropDownHorizontalOffset">0dip</item>
Loading