mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 15:26:58 +00:00
Use stretch effect in widgets menu
This commit is contained in:
@@ -6,7 +6,6 @@ import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.EdgeEffect
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.Utilities
|
||||
import com.android.launcher3.workprofile.PersonalWorkPagedView
|
||||
|
||||
@@ -15,7 +14,6 @@ open class StretchRecyclerViewContainer @JvmOverloads constructor(
|
||||
) : StretchRelativeLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
private val childEffect = StretchEdgeEffect(context, { invalidate() }, { postInvalidateOnAnimation() })
|
||||
private val verticalOffset = resources.getDimensionPixelSize(R.dimen.all_apps_search_vertical_offset)
|
||||
|
||||
override fun drawChild(canvas: Canvas, child: View, drawingTime: Long): Boolean {
|
||||
if (Utilities.ATLEAST_S || (child !is RecyclerView && child !is PersonalWorkPagedView)) {
|
||||
@@ -24,7 +22,7 @@ open class StretchRecyclerViewContainer @JvmOverloads constructor(
|
||||
|
||||
if (!childEffect.isFinished) {
|
||||
val save = canvas.save()
|
||||
canvas.clipRect(child.left, child.top + verticalOffset, child.right, child.bottom)
|
||||
clipChild(canvas, child)
|
||||
childEffect.setSize(width, height)
|
||||
childEffect.applyStretch(canvas, StretchEdgeEffect.POSITION_BOTTOM)
|
||||
val result = super.drawChild(canvas, child, drawingTime)
|
||||
@@ -47,4 +45,8 @@ open class StretchRecyclerViewContainer @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open fun clipChild(canvas: Canvas, child: View) {
|
||||
canvas.clipRect(child.left, child.top, child.right, child.bottom)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
android:orientation="vertical"
|
||||
android:theme="?attr/widgetsTheme">
|
||||
|
||||
<com.android.launcher3.views.SpringRelativeLayout
|
||||
<app.lawnchair.ui.StretchRecyclerViewContainer
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@@ -72,5 +72,5 @@
|
||||
android:visibility="gone"
|
||||
android:clipToPadding="false" />
|
||||
|
||||
</com.android.launcher3.views.SpringRelativeLayout>
|
||||
</app.lawnchair.ui.StretchRecyclerViewContainer>
|
||||
</com.android.launcher3.widget.picker.WidgetsFullSheet>
|
||||
@@ -135,6 +135,7 @@ public class AllAppsContainerView extends StretchRecyclerViewContainer implement
|
||||
private ScrimView mScrimView;
|
||||
private int mHeaderColor;
|
||||
private int mTabsProtectionAlpha;
|
||||
private int mSearchVerticalOffset;
|
||||
|
||||
public AllAppsContainerView(Context context) {
|
||||
this(context, null);
|
||||
@@ -157,6 +158,8 @@ public class AllAppsContainerView extends StretchRecyclerViewContainer implement
|
||||
R.dimen.dynamic_grid_cell_border_spacing);
|
||||
mHeaderProtectionColor = ColorTokens.AllAppsHeaderProtectionColor.resolveColor(context);
|
||||
|
||||
mSearchVerticalOffset = getResources().getDimensionPixelSize(R.dimen.all_apps_search_vertical_offset);
|
||||
|
||||
mLauncher.addOnDeviceProfileChangeListener(this);
|
||||
|
||||
mSearchAdapterProvider = mLauncher.createSearchAdapterProvider(this);
|
||||
@@ -797,4 +800,11 @@ public class AllAppsContainerView extends StretchRecyclerViewContainer implement
|
||||
mScrimView.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clipChild(@NonNull Canvas canvas, @NonNull View child) {
|
||||
canvas.clipRect(
|
||||
child.getLeft(), child.getTop() + mSearchVerticalOffset,
|
||||
child.getRight(), child.getBottom());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user