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

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

Merge "Removing ViewScrim and cutom drawing code" into ub-launcher3-master

parents 3a030ef9 1642f717
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -101,9 +101,6 @@
    <!-- View ID used by cell layout to jail its content -->
    <item type="id" name="cell_layout_jail_id" />

    <!-- Tag id used for view scrim -->
    <item type="id" name="view_scrim" />

    <!-- View IDs to store item highlight information -->
    <item type="id" name="view_unhighlight_background" />
    <item type="id" name="view_highlighted" />
+1 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ public class InsettableFrameLayout extends FrameLayout implements Insettable {
    }

    public static class LayoutParams extends FrameLayout.LayoutParams {
        boolean ignoreInsets = false;
        public boolean ignoreInsets = false;

        public LayoutParams(Context c, AttributeSet attrs) {
            super(c, attrs);
+0 −10
Original line number Diff line number Diff line
@@ -47,7 +47,6 @@ import com.android.launcher3.Workspace;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.graphics.ViewScrim;
import com.android.launcher3.graphics.WorkspaceAndHotseatScrim;
import com.android.launcher3.keyboard.ViewGroupFocusHelper;
import com.android.launcher3.uioverrides.UiFactory;
@@ -124,15 +123,6 @@ public class DragLayer extends BaseDragLayer<Launcher> {
        return mDragController.dispatchKeyEvent(event) || super.dispatchKeyEvent(event);
    }

    @Override
    protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
        ViewScrim scrim = ViewScrim.get(child);
        if (scrim != null) {
            scrim.draw(canvas, getWidth(), getHeight());
        }
        return super.drawChild(canvas, child, drawingTime);
    }

    @Override
    protected boolean findActiveController(MotionEvent ev) {
        if (mActivity.getStateManager().getState().disableInteraction) {
+0 −65
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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.
 */
package com.android.launcher3.graphics;

import android.graphics.Canvas;
import android.graphics.Color;
import android.view.View;
import android.view.animation.Interpolator;

import com.android.launcher3.R;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.uioverrides.WallpaperColorInfo;

import androidx.core.graphics.ColorUtils;

/**
 * Simple scrim which draws a color
 */
public class ColorScrim extends ViewScrim {

    private final int mColor;
    private final Interpolator mInterpolator;
    private int mCurrentColor;

    public ColorScrim(View view, int color, Interpolator interpolator) {
        super(view);
        mColor = color;
        mInterpolator = interpolator;
    }

    @Override
    protected void onProgressChanged() {
        mCurrentColor = ColorUtils.setAlphaComponent(mColor,
                Math.round(mInterpolator.getInterpolation(mProgress) * Color.alpha(mColor)));
    }

    @Override
    public void draw(Canvas canvas, int width, int height) {
        if (mProgress > 0) {
            canvas.drawColor(mCurrentColor);
        }
    }

    public static ColorScrim createExtractedColorScrim(View view) {
        WallpaperColorInfo colors = WallpaperColorInfo.getInstance(view.getContext());
        int alpha = view.getResources().getInteger(R.integer.extracted_color_gradient_alpha);
        ColorScrim scrim = new ColorScrim(view, ColorUtils.setAlphaComponent(
                colors.getSecondaryColor(), alpha), Interpolators.LINEAR);
        scrim.attach();
        return scrim;
    }
}
+0 −77
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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.
 */

package com.android.launcher3.graphics;

import android.graphics.Canvas;
import android.util.Property;
import android.view.View;
import android.view.ViewParent;

import com.android.launcher3.R;

/**
 * A utility class that can be used to draw a scrim behind a view
 */
public abstract class ViewScrim<T extends View> {

    public static Property<ViewScrim, Float> PROGRESS =
            new Property<ViewScrim, Float>(Float.TYPE, "progress") {
                @Override
                public Float get(ViewScrim viewScrim) {
                    return viewScrim.mProgress;
                }

                @Override
                public void set(ViewScrim object, Float value) {
                    object.setProgress(value);
                }
            };

    protected final T mView;
    protected float mProgress = 0;

    public ViewScrim(T view) {
        mView = view;
    }

    public void attach() {
        mView.setTag(R.id.view_scrim, this);
    }

    public void setProgress(float progress) {
        if (mProgress != progress) {
            mProgress = progress;
            onProgressChanged();
            invalidate();
        }
    }

    public abstract void draw(Canvas canvas, int width, int height);

    protected void onProgressChanged() { }

    public void invalidate() {
        ViewParent parent = mView.getParent();
        if (parent != null) {
            ((View) parent).invalidate();
        }
    }

    public static ViewScrim get(View view) {
        return (ViewScrim) view.getTag(R.id.view_scrim);
    }
}
Loading