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

Commit ea53ca3a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Removing custom state definition from FastBitmapDrawable" into ub-launcher3-dorval

parents 1cabfa1d 2a76e3fb
Loading
Loading
Loading
Loading
+49 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<!--
 Copyright 2017, 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.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_activated="true">
        <set>
            <objectAnimator
                android:duration="225"
                android:propertyName="scaleX"
                android:valueTo="1.15"
                android:valueType="floatType" />
            <objectAnimator
                android:duration="225"
                android:propertyName="scaleY"
                android:valueTo="1.15"
                android:valueType="floatType" />
        </set>
    </item>

    <item>
        <set>
            <objectAnimator
                android:duration="275"
                android:propertyName="scaleX"
                android:valueTo="1"
                android:valueType="floatType" />
            <objectAnimator
                android:duration="275"
                android:propertyName="scaleY"
                android:valueTo="1"
                android:valueType="floatType" />
        </set>
    </item>

</selector>
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
    android:id="@+id/icon"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:stateListAnimator="@animator/all_apps_fastscroll_icon_anim"
    launcher:iconDisplay="all_apps"
    launcher:centerVertically="true"
    android:paddingLeft="4dp"
+0 −4
Original line number Diff line number Diff line
@@ -36,10 +36,6 @@ import com.android.launcher3.util.Themes;
 */
public class BaseRecyclerViewFastScrollBar {

    public interface FastScrollFocusableView {
        void setFastScrollFocusState(final FastBitmapDrawable.State focusState, boolean animated);
    }

    private static final Property<BaseRecyclerViewFastScrollBar, Integer> TRACK_WIDTH =
            new Property<BaseRecyclerViewFastScrollBar, Integer>(Integer.class, "width") {

+16 −72
Original line number Diff line number Diff line
@@ -53,8 +53,7 @@ import java.text.NumberFormat;
 * because we want to make the bubble taller than the text and TextView's clip is
 * too aggressive.
 */
public class BubbleTextView extends TextView
        implements BaseRecyclerViewFastScrollBar.FastScrollFocusableView, ItemInfoUpdateReceiver {
public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver {

    // Dimensions in DP
    private static final float AMBIENT_SHADOW_RADIUS = 2.5f;
@@ -67,6 +66,8 @@ public class BubbleTextView extends TextView
    private static final int DISPLAY_ALL_APPS = 1;
    private static final int DISPLAY_FOLDER = 2;

    private static final int[] STATE_PRESSED = new int[] {android.R.attr.state_pressed};

    private final Launcher mLauncher;
    private Drawable mIcon;
    private final boolean mCenterVertically;
@@ -232,14 +233,21 @@ public class BubbleTextView extends TextView
    }

    @Override
    public void setPressed(boolean pressed) {
        super.setPressed(pressed);

    public void refreshDrawableState() {
        if (!mIgnorePressedStateChange) {
            updateIconState();
            super.refreshDrawableState();
        }
    }

    @Override
    protected int[] onCreateDrawableState(int extraSpace) {
        final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
        if (mStayPressed) {
            mergeDrawableStates(drawableState, STATE_PRESSED);
        }
        return drawableState;
    }

    /** Returns the icon for this view. */
    public Drawable getIcon() {
        return mIcon;
@@ -250,17 +258,6 @@ public class BubbleTextView extends TextView
        return mLayoutHorizontal;
    }

    private void updateIconState() {
        if (mIcon instanceof FastBitmapDrawable) {
            FastBitmapDrawable d = (FastBitmapDrawable) mIcon;
            if (isPressed() || mStayPressed) {
                d.animateState(FastBitmapDrawable.State.PRESSED);
            } else {
                d.animateState(FastBitmapDrawable.State.NORMAL);
            }
        }
    }

    @Override
    public void setOnLongClickListener(OnLongClickListener l) {
        super.setOnLongClickListener(l);
@@ -334,7 +331,7 @@ public class BubbleTextView extends TextView
                    this, mPressedBackground);
        }

        updateIconState();
        refreshDrawableState();
    }

    void clearPressedBackground() {
@@ -364,7 +361,7 @@ public class BubbleTextView extends TextView

        mPressedBackground = null;
        mIgnorePressedStateChange = false;
        updateIconState();
        refreshDrawableState();
        return result;
    }

@@ -544,10 +541,6 @@ public class BubbleTextView extends TextView
    @Override
    public void reapplyItemInfo(ItemInfoWithIcon info) {
        if (getTag() == info) {
            FastBitmapDrawable.State prevState = FastBitmapDrawable.State.NORMAL;
            if (mIcon instanceof FastBitmapDrawable) {
                prevState = ((FastBitmapDrawable) mIcon).getCurrentState();
            }
            mIconLoadRequest = null;
            mDisableRelayout = true;

@@ -566,12 +559,6 @@ public class BubbleTextView extends TextView
                applyFromPackageItemInfo((PackageItemInfo) info);
            }

            // If we are reapplying over an old icon, then we should update the new icon to the same
            // state as the old icon
            if (mIcon instanceof FastBitmapDrawable) {
                ((FastBitmapDrawable) mIcon).setState(prevState);
            }

            mDisableRelayout = false;
        }
    }
@@ -593,34 +580,6 @@ public class BubbleTextView extends TextView
        }
    }

    @Override
    public void setFastScrollFocusState(final FastBitmapDrawable.State focusState, boolean animated) {
        // We can only set the fast scroll focus state on a FastBitmapDrawable
        if (!(mIcon instanceof FastBitmapDrawable)) {
            return;
        }

        FastBitmapDrawable d = (FastBitmapDrawable) mIcon;
        if (animated) {
            FastBitmapDrawable.State prevState = d.getCurrentState();
            if (d.animateState(focusState)) {
                // If the state was updated, then update the view accordingly
                animate().scaleX(focusState.viewScale)
                        .scaleY(focusState.viewScale)
                        .setStartDelay(getStartDelayForStateChange(prevState, focusState))
                        .setDuration(d.getDurationForStateChange(prevState, focusState))
                        .start();
            }
        } else {
            if (d.setState(focusState)) {
                // If the state was updated, then update the view accordingly
                animate().cancel();
                setScaleX(focusState.viewScale);
                setScaleY(focusState.viewScale);
            }
        }
    }

    /**
     * Returns true if the view can show custom shortcuts.
     */
@@ -629,21 +588,6 @@ public class BubbleTextView extends TextView
                .isEmpty();
    }

    /**
     * Returns the start delay when animating between certain {@link FastBitmapDrawable} states.
     */
    private static int getStartDelayForStateChange(final FastBitmapDrawable.State fromState,
            final FastBitmapDrawable.State toState) {
        switch (toState) {
            case NORMAL:
                switch (fromState) {
                    case FAST_SCROLL_HIGHLIGHTED:
                        return FastBitmapDrawable.FAST_SCROLL_INACTIVE_DURATION / 4;
                }
        }
        return 0;
    }

    /**
     * Interface to be implemented by the grand parent to allow click shadow effect.
     */
Loading