mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 18:58:19 +00:00
Move TransformingTouchDelegate logic to BaseContainerView.
In ag/1460444 we used TransformingTouchDelegate to extend the touch target for the widgets list. Now both WidgetsContainerView and AllAppsContainerView will use the same TransformingTouchDelegate logic to extend the touch target for their respective lists. This is part of a larger refactor where in a follow up CL, we will handle the logic for dismissing WCV and AACV when touching outside of its content in BaseContainerView. (currently broken in WCV). Change-Id: I7fddb456bba34a6533f8824da0481d308a8b715e
This commit is contained in:
@@ -18,6 +18,7 @@ package com.android.launcher3;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.InsetDrawable;
|
||||
@@ -27,6 +28,7 @@ import android.widget.FrameLayout;
|
||||
|
||||
import com.android.launcher3.allapps.AllAppsContainerView;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.util.TransformingTouchDelegate;
|
||||
|
||||
/**
|
||||
* A base container view, which supports resizing.
|
||||
@@ -39,12 +41,14 @@ public abstract class BaseContainerView extends FrameLayout
|
||||
protected int mContainerPaddingTop;
|
||||
protected int mContainerPaddingBottom;
|
||||
|
||||
private InsetDrawable mRevealDrawable;
|
||||
protected final Drawable mBaseDrawable;
|
||||
private final Rect mBgPaddingRect = new Rect();
|
||||
|
||||
private View mRevealView;
|
||||
private View mContent;
|
||||
|
||||
private TransformingTouchDelegate mTouchDelegate;
|
||||
|
||||
public BaseContainerView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
@@ -72,6 +76,12 @@ public abstract class BaseContainerView extends FrameLayout
|
||||
|
||||
DeviceProfile grid = Launcher.getLauncher(getContext()).getDeviceProfile();
|
||||
grid.addLauncherLayoutChangedListener(this);
|
||||
|
||||
View touchDelegateTargetView = getTouchDelegateTargetView();
|
||||
if (touchDelegateTargetView != null) {
|
||||
mTouchDelegate = new TransformingTouchDelegate(touchDelegateTargetView);
|
||||
((View) touchDelegateTargetView.getParent()).setTouchDelegate(mTouchDelegate);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,6 +102,21 @@ public abstract class BaseContainerView extends FrameLayout
|
||||
updatePaddings();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
getRevealView().getBackground().getPadding(mBgPaddingRect);
|
||||
|
||||
View touchDelegateTargetView = getTouchDelegateTargetView();
|
||||
if (touchDelegateTargetView != null) {
|
||||
mTouchDelegate.setBounds(
|
||||
touchDelegateTargetView.getLeft() - mBgPaddingRect.left,
|
||||
touchDelegateTargetView.getTop() - mBgPaddingRect.top,
|
||||
touchDelegateTargetView.getRight() + mBgPaddingRect.right,
|
||||
touchDelegateTargetView.getBottom() + mBgPaddingRect.bottom);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLauncherLayoutChanged() {
|
||||
updatePaddings();
|
||||
@@ -130,14 +155,12 @@ public abstract class BaseContainerView extends FrameLayout
|
||||
}
|
||||
}
|
||||
|
||||
mRevealDrawable = new InsetDrawable(mBaseDrawable,
|
||||
InsetDrawable revealDrawable = new InsetDrawable(mBaseDrawable,
|
||||
mContainerPaddingLeft, mContainerPaddingTop, mContainerPaddingRight,
|
||||
mContainerPaddingBottom);
|
||||
mRevealView.setBackground(mRevealDrawable);
|
||||
if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP && this instanceof AllAppsContainerView) {
|
||||
// Skip updating the content background
|
||||
} else {
|
||||
mContent.setBackground(mRevealDrawable);
|
||||
}
|
||||
mRevealView.setBackground(revealDrawable);
|
||||
mContent.setBackground(revealDrawable);
|
||||
}
|
||||
|
||||
public abstract View getTouchDelegateTargetView();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user