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

Commit 3b049bb1 authored by Alan Viverette's avatar Alan Viverette Committed by android-build-merger
Browse files

Merge "Add scroll indicators to resolver list" into nyc-dev

am: 8bb7ad59

* commit '8bb7ad59':
  Add scroll indicators to resolver list

Change-Id: I8b6dbcd2ff106bf83945084b1a4956c094234240
parents b5948bd8 8bb7ad59
Loading
Loading
Loading
Loading
+54 −5
Original line number Original line Diff line number Diff line
@@ -17,9 +17,15 @@


package com.android.internal.widget;
package com.android.internal.widget;


import com.android.internal.R;

import android.content.Context;
import android.content.Context;
import android.content.res.TypedArray;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable;
@@ -38,7 +44,6 @@ import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
import android.view.animation.AnimationUtils;
import android.view.animation.AnimationUtils;
import android.widget.AbsListView;
import android.widget.AbsListView;
import android.widget.OverScroller;
import android.widget.OverScroller;
import com.android.internal.R;


public class ResolverDrawerLayout extends ViewGroup {
public class ResolverDrawerLayout extends ViewGroup {
    private static final String TAG = "ResolverDrawerLayout";
    private static final String TAG = "ResolverDrawerLayout";
@@ -86,6 +91,8 @@ public class ResolverDrawerLayout extends ViewGroup {
    private final OverScroller mScroller;
    private final OverScroller mScroller;
    private final VelocityTracker mVelocityTracker;
    private final VelocityTracker mVelocityTracker;


    private Drawable mScrollIndicatorDrawable;

    private OnDismissedListener mOnDismissedListener;
    private OnDismissedListener mOnDismissedListener;
    private RunOnDismissedListener mRunOnDismissedListener;
    private RunOnDismissedListener mRunOnDismissedListener;


@@ -127,6 +134,8 @@ public class ResolverDrawerLayout extends ViewGroup {
                mMaxCollapsedHeight);
                mMaxCollapsedHeight);
        a.recycle();
        a.recycle();


        mScrollIndicatorDrawable = mContext.getDrawable(R.drawable.scroll_indicator_material);

        mScroller = new OverScroller(context, AnimationUtils.loadInterpolator(context,
        mScroller = new OverScroller(context, AnimationUtils.loadInterpolator(context,
                android.R.interpolator.decelerate_quint));
                android.R.interpolator.decelerate_quint));
        mVelocityTracker = VelocityTracker.obtain();
        mVelocityTracker = VelocityTracker.obtain();
@@ -202,8 +211,7 @@ public class ResolverDrawerLayout extends ViewGroup {
            }
            }
            final boolean isCollapsedNew = mCollapseOffset != 0;
            final boolean isCollapsedNew = mCollapseOffset != 0;
            if (isCollapsedOld != isCollapsedNew) {
            if (isCollapsedOld != isCollapsedNew) {
                notifyViewAccessibilityStateChangedIfNeeded(
                onCollapsedChanged(isCollapsedNew);
                        AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED);
            }
            }
        } else {
        } else {
            // Start out collapsed at first unless we restored state for otherwise
            // Start out collapsed at first unless we restored state for otherwise
@@ -442,8 +450,7 @@ public class ResolverDrawerLayout extends ViewGroup {
            mTopOffset += dy;
            mTopOffset += dy;
            final boolean isCollapsedNew = newPos != 0;
            final boolean isCollapsedNew = newPos != 0;
            if (isCollapsedOld != isCollapsedNew) {
            if (isCollapsedOld != isCollapsedNew) {
                notifyViewAccessibilityStateChangedIfNeeded(
                onCollapsedChanged(isCollapsedNew);
                        AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED);
            }
            }
            postInvalidateOnAnimation();
            postInvalidateOnAnimation();
            return dy;
            return dy;
@@ -451,6 +458,15 @@ public class ResolverDrawerLayout extends ViewGroup {
        return 0;
        return 0;
    }
    }


    private void onCollapsedChanged(boolean isCollapsed) {
        notifyViewAccessibilityStateChangedIfNeeded(
                AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED);

        if (mScrollIndicatorDrawable != null) {
            setWillNotDraw(!isCollapsed);
        }
    }

    void dispatchOnDismissed() {
    void dispatchOnDismissed() {
        if (mOnDismissedListener != null) {
        if (mOnDismissedListener != null) {
            mOnDismissedListener.onDismissed();
            mOnDismissedListener.onDismissed();
@@ -708,6 +724,15 @@ public class ResolverDrawerLayout extends ViewGroup {
        return false;
        return false;
    }
    }


    @Override
    public void onDrawForeground(Canvas canvas) {
        if (mScrollIndicatorDrawable != null) {
            mScrollIndicatorDrawable.draw(canvas);
        }

        super.onDrawForeground(canvas);
    }

    @Override
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        final int sourceWidth = MeasureSpec.getSize(widthMeasureSpec);
        final int sourceWidth = MeasureSpec.getSize(widthMeasureSpec);
@@ -794,6 +819,8 @@ public class ResolverDrawerLayout extends ViewGroup {
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        final int width = getWidth();
        final int width = getWidth();


        View indicatorHost = null;

        int ypos = mTopOffset;
        int ypos = mTopOffset;
        int leftEdge = getPaddingLeft();
        int leftEdge = getPaddingLeft();
        int rightEdge = width - getPaddingRight();
        int rightEdge = width - getPaddingRight();
@@ -802,6 +829,9 @@ public class ResolverDrawerLayout extends ViewGroup {
        for (int i = 0; i < childCount; i++) {
        for (int i = 0; i < childCount; i++) {
            final View child = getChildAt(i);
            final View child = getChildAt(i);
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            if (lp.hasNestedScrollIndicator) {
                indicatorHost = child;
            }


            if (child.getVisibility() == GONE) {
            if (child.getVisibility() == GONE) {
                continue;
                continue;
@@ -822,6 +852,20 @@ public class ResolverDrawerLayout extends ViewGroup {


            ypos = bottom + lp.bottomMargin;
            ypos = bottom + lp.bottomMargin;
        }
        }

        if (mScrollIndicatorDrawable != null) {
            if (indicatorHost != null) {
                final int left = indicatorHost.getLeft();
                final int right = indicatorHost.getRight();
                final int bottom = indicatorHost.getTop();
                final int top = bottom - mScrollIndicatorDrawable.getIntrinsicHeight();
                mScrollIndicatorDrawable.setBounds(left, top, right, bottom);
                setWillNotDraw(!isCollapsed());
            } else {
                mScrollIndicatorDrawable = null;
                setWillNotDraw(true);
            }
        }
    }
    }


    @Override
    @Override
@@ -861,6 +905,7 @@ public class ResolverDrawerLayout extends ViewGroup {
    public static class LayoutParams extends MarginLayoutParams {
    public static class LayoutParams extends MarginLayoutParams {
        public boolean alwaysShow;
        public boolean alwaysShow;
        public boolean ignoreOffset;
        public boolean ignoreOffset;
        public boolean hasNestedScrollIndicator;


        public LayoutParams(Context c, AttributeSet attrs) {
        public LayoutParams(Context c, AttributeSet attrs) {
            super(c, attrs);
            super(c, attrs);
@@ -873,6 +918,9 @@ public class ResolverDrawerLayout extends ViewGroup {
            ignoreOffset = a.getBoolean(
            ignoreOffset = a.getBoolean(
                    R.styleable.ResolverDrawerLayout_LayoutParams_layout_ignoreOffset,
                    R.styleable.ResolverDrawerLayout_LayoutParams_layout_ignoreOffset,
                    false);
                    false);
            hasNestedScrollIndicator = a.getBoolean(
                    R.styleable.ResolverDrawerLayout_LayoutParams_layout_hasNestedScrollIndicator,
                    false);
            a.recycle();
            a.recycle();
        }
        }


@@ -884,6 +932,7 @@ public class ResolverDrawerLayout extends ViewGroup {
            super(source);
            super(source);
            this.alwaysShow = source.alwaysShow;
            this.alwaysShow = source.alwaysShow;
            this.ignoreOffset = source.ignoreOffset;
            this.ignoreOffset = source.ignoreOffset;
            this.hasNestedScrollIndicator = source.hasNestedScrollIndicator;
        }
        }


        public LayoutParams(MarginLayoutParams source) {
        public LayoutParams(MarginLayoutParams source) {
+58 −48
Original line number Original line Diff line number Diff line
@@ -31,7 +31,9 @@
        android:layout_alwaysShow="true"
        android:layout_alwaysShow="true"
        android:elevation="8dp"
        android:elevation="8dp"
        android:background="@color/white">
        android:background="@color/white">
        <TextView android:id="@+id/profile_button"

        <TextView
            android:id="@+id/profile_button"
            android:layout_width="wrap_content"
            android:layout_width="wrap_content"
            android:layout_height="48dp"
            android:layout_height="48dp"
            android:layout_marginEnd="8dp"
            android:layout_marginEnd="8dp"
@@ -45,7 +47,9 @@
            android:layout_alignParentTop="true"
            android:layout_alignParentTop="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentRight="true"
            android:singleLine="true" />
            android:singleLine="true" />
        <TextView android:id="@+id/title"

        <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_height="wrap_content"
            android:minHeight="56dp"
            android:minHeight="56dp"
@@ -68,6 +72,7 @@
        android:background="@color/white"
        android:background="@color/white"
        android:elevation="8dp"
        android:elevation="8dp"
        android:nestedScrollingEnabled="true"
        android:nestedScrollingEnabled="true"
        android:scrollIndicators="top|bottom"
        android:divider="@null" />
        android:divider="@null" />


    <TextView android:id="@+id/empty"
    <TextView android:id="@+id/empty"
@@ -84,11 +89,12 @@
    <LinearLayout
    <LinearLayout
        android:id="@+id/button_bar"
        android:id="@+id/button_bar"
        android:visibility="gone"
        android:visibility="gone"
        style="?android:attr/buttonBarStyle"
        style="?attr/buttonBarStyle"
        android:layout_width="match_parent"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_height="wrap_content"
        android:layout_ignoreOffset="true"
        android:layout_ignoreOffset="true"
        android:layout_alwaysShow="true"
        android:layout_alwaysShow="true"
        android:layout_hasNestedScrollIndicator="true"
        android:gravity="end|center_vertical"
        android:gravity="end|center_vertical"
        android:orientation="horizontal"
        android:orientation="horizontal"
        android:layoutDirection="locale"
        android:layoutDirection="locale"
@@ -99,22 +105,26 @@
        android:paddingStart="12dp"
        android:paddingStart="12dp"
        android:paddingEnd="12dp"
        android:paddingEnd="12dp"
        android:elevation="8dp">
        android:elevation="8dp">
        <Button android:id="@+id/button_once"

        <Button
            android:id="@+id/button_once"
            android:layout_width="wrap_content"
            android:layout_width="wrap_content"
            android:layout_gravity="start"
            android:layout_gravity="start"
            android:maxLines="2"
            android:maxLines="2"
                style="?android:attr/buttonBarNegativeButtonStyle"
            style="?attr/buttonBarNegativeButtonStyle"
            android:minHeight="@dimen/alert_dialog_button_bar_height"
            android:minHeight="@dimen/alert_dialog_button_bar_height"
            android:layout_height="wrap_content"
            android:layout_height="wrap_content"
            android:enabled="false"
            android:enabled="false"
            android:text="@string/activity_resolver_use_once"
            android:text="@string/activity_resolver_use_once"
            android:onClick="onButtonClick" />
            android:onClick="onButtonClick" />
        <Button android:id="@+id/button_always"

        <Button
            android:id="@+id/button_always"
            android:layout_width="wrap_content"
            android:layout_width="wrap_content"
            android:layout_gravity="end"
            android:layout_gravity="end"
            android:maxLines="2"
            android:maxLines="2"
            android:minHeight="@dimen/alert_dialog_button_bar_height"
            android:minHeight="@dimen/alert_dialog_button_bar_height"
                style="?android:attr/buttonBarPositiveButtonStyle"
            style="?attr/buttonBarPositiveButtonStyle"
            android:layout_height="wrap_content"
            android:layout_height="wrap_content"
            android:enabled="false"
            android:enabled="false"
            android:text="@string/activity_resolver_use_always"
            android:text="@string/activity_resolver_use_always"
+89 −76
Original line number Original line Diff line number Diff line
@@ -22,8 +22,7 @@
    android:layout_height="match_parent"
    android:layout_height="match_parent"
    android:maxWidth="@dimen/resolver_max_width"
    android:maxWidth="@dimen/resolver_max_width"
    android:maxCollapsedHeight="144dp"
    android:maxCollapsedHeight="144dp"
    android:id="@id/contentPanel"
    android:id="@id/contentPanel">
    >


    <LinearLayout
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_width="match_parent"
@@ -38,7 +37,8 @@
            android:layout_height="64dp"
            android:layout_height="64dp"
            android:orientation="horizontal">
            android:orientation="horizontal">


            <ImageView android:id="@+id/icon"
            <ImageView
                android:id="@+id/icon"
                android:layout_width="24dp"
                android:layout_width="24dp"
                android:layout_height="24dp"
                android:layout_height="24dp"
                android:layout_gravity="start|top"
                android:layout_gravity="start|top"
@@ -46,15 +46,19 @@
                android:layout_marginEnd="16dp"
                android:layout_marginEnd="16dp"
                android:layout_marginTop="20dp"
                android:layout_marginTop="20dp"
                android:scaleType="fitCenter" />
                android:scaleType="fitCenter" />
            <TextView android:id="@+id/title"

            <TextView
                android:id="@+id/title"
                android:layout_width="0dp"
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_weight="1"
                      android:layout_height="?android:attr/listPreferredItemHeight"
                android:layout_height="?attr/listPreferredItemHeight"
                android:layout_marginStart="16dp"
                android:layout_marginStart="16dp"
                      android:textAppearance="?android:attr/textAppearanceMedium"
                android:textAppearance="?attr/textAppearanceMedium"
                android:gravity="start|center_vertical"
                android:gravity="start|center_vertical"
                android:paddingEnd="16dp" />
                android:paddingEnd="16dp" />
            <LinearLayout android:id="@+id/profile_button"

            <LinearLayout
                android:id="@+id/profile_button"
                android:layout_width="wrap_content"
                android:layout_width="wrap_content"
                android:layout_height="48dp"
                android:layout_height="48dp"
                android:layout_marginTop="4dp"
                android:layout_marginTop="4dp"
@@ -66,7 +70,9 @@
                android:focusable="true"
                android:focusable="true"
                android:visibility="gone"
                android:visibility="gone"
                style="?attr/borderlessButtonStyle">
                style="?attr/borderlessButtonStyle">
                <ImageView android:id="@+id/icon"

                <ImageView
                    android:id="@+id/icon"
                    android:layout_width="24dp"
                    android:layout_width="24dp"
                    android:layout_height="24dp"
                    android:layout_height="24dp"
                    android:layout_gravity="start|center_vertical"
                    android:layout_gravity="start|center_vertical"
@@ -74,7 +80,9 @@
                    android:layout_marginTop="12dp"
                    android:layout_marginTop="12dp"
                    android:layout_marginBottom="12dp"
                    android:layout_marginBottom="12dp"
                    android:scaleType="fitCenter" />
                    android:scaleType="fitCenter" />
                <TextView android:id="@id/text1"

                <TextView
                    android:id="@id/text1"
                    android:layout_width="wrap_content"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="start|center_vertical"
                    android:layout_gravity="start|center_vertical"
@@ -90,7 +98,7 @@
        <LinearLayout
        <LinearLayout
            android:id="@+id/button_bar"
            android:id="@+id/button_bar"
            android:visibility="gone"
            android:visibility="gone"
            style="?android:attr/buttonBarStyle"
            style="?attr/buttonBarStyle"
            android:layout_width="match_parent"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alwaysShow="true"
            android:layout_alwaysShow="true"
@@ -104,30 +112,36 @@
            android:paddingEnd="12dp"
            android:paddingEnd="12dp"
            android:background="@color/white"
            android:background="@color/white"
            android:elevation="8dp">
            android:elevation="8dp">
            <Button android:id="@+id/button_once"

            <Button
                android:id="@+id/button_once"
                android:layout_width="wrap_content"
                android:layout_width="wrap_content"
                android:layout_gravity="start"
                android:layout_gravity="start"
                android:maxLines="2"
                android:maxLines="2"
                    style="?android:attr/buttonBarNegativeButtonStyle"
                style="?attr/buttonBarNegativeButtonStyle"
                android:minHeight="@dimen/alert_dialog_button_bar_height"
                android:minHeight="@dimen/alert_dialog_button_bar_height"
                android:layout_height="wrap_content"
                android:layout_height="wrap_content"
                android:enabled="false"
                android:enabled="false"
                android:text="@string/activity_resolver_use_once"
                android:text="@string/activity_resolver_use_once"
                android:onClick="onButtonClick" />
                android:onClick="onButtonClick" />
            <Button android:id="@+id/button_always"

            <Button
                android:id="@+id/button_always"
                android:layout_width="wrap_content"
                android:layout_width="wrap_content"
                android:layout_gravity="end"
                android:layout_gravity="end"
                android:maxLines="2"
                android:maxLines="2"
                android:minHeight="@dimen/alert_dialog_button_bar_height"
                android:minHeight="@dimen/alert_dialog_button_bar_height"
                    style="?android:attr/buttonBarPositiveButtonStyle"
                style="?attr/buttonBarPositiveButtonStyle"
                android:layout_height="wrap_content"
                android:layout_height="wrap_content"
                android:enabled="false"
                android:enabled="false"
                android:text="@string/activity_resolver_use_always"
                android:text="@string/activity_resolver_use_always"
                android:onClick="onButtonClick" />
                android:onClick="onButtonClick" />
        </LinearLayout>
        </LinearLayout>
        <View android:layout_width="match_parent"

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_height="1dp"
              android:background="?android:attr/dividerVertical" />
            android:background="?attr/dividerVertical" />
    </LinearLayout>
    </LinearLayout>


    <ListView
    <ListView
@@ -139,7 +153,6 @@
        android:background="@color/white"
        android:background="@color/white"
        android:elevation="8dp"
        android:elevation="8dp"
        android:nestedScrollingEnabled="true"
        android:nestedScrollingEnabled="true"
        android:divider="@null"
        android:divider="@null" />
        />


</com.android.internal.widget.ResolverDrawerLayout>
</com.android.internal.widget.ResolverDrawerLayout>
+1 −0
Original line number Original line Diff line number Diff line
@@ -8138,6 +8138,7 @@ i
        <attr name="layout_alwaysShow" format="boolean" />
        <attr name="layout_alwaysShow" format="boolean" />
        <attr name="layout_ignoreOffset" format="boolean" />
        <attr name="layout_ignoreOffset" format="boolean" />
        <attr name="layout_gravity" />
        <attr name="layout_gravity" />
        <attr name="layout_hasNestedScrollIndicator" format="boolean" />
    </declare-styleable>
    </declare-styleable>


    <!-- @hide -->
    <!-- @hide -->